mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
On mobile, a text send that failed for almost any reason showed **"Not sent. Community changed."** The composer caught every `StateError` as a community switch, and relay failures such as a briefly disconnected socket (`RelaySession.publish` throws "Relay session is not connected") are also `StateError`s. So a reconnect blip during a send told the user they had switched communities when they hadn't. The community-switch guards in message, forum and channel-action delivery now throw a dedicated `ActiveCommunityChangedError`, and an unconnected publish throws `RelayNotConnectedError`. Both still extend `StateError`, so every existing `on StateError` caller behaves as before. The composer now reports: | Failure | Message | | --- | --- | | Active community changed mid-send | Not sent. Community changed. | | Relay socket not connected | Not sent. No connection. | | Relay never acknowledged the event (ack timeout) | Not confirmed. The relay didn't respond. | | A relay request timed out before the event was published (e.g. a roster lookup) | Not sent. The relay didn't respond. | | Connection lost after the event was sent, before its acknowledgement | Not confirmed. Connection lost. | | Relay rejected the event, or anything else | Not sent: *relay reason or error text* | The two "Not confirmed" cases may still have been accepted by the relay, so they avoid a definite "Not sent" that would invite a duplicate resend. Pending publishes rejected by a disconnect or backgrounding now complete with a typed `RelayAckLostError` instead of a generic exception, and an unacknowledged publish times out with `RelayAckTimeoutError` (still a `TimeoutException`) so it can be told apart from earlier timeouts. The draft is restored in every case, as before. ### Validation - Added [composer widget tests](https://github.com/block/buzz/pull/9156/files#diff-101740841aadcb902d0717f3909debe16073c672e73be74a5b908bf11dfc8782) for each non-community failure (disconnect, timeout before publishing, ack timeout, connection lost before acknowledgement, relay rejection, other `StateError`), checking the snackbar text, that the draft is restored, and whether the message EVENT was sent. The disconnect, timeout and connection-lost cases run through the real relay session (a pending publish rejected by backgrounding, a history request that times out before any message EVENT). The existing community-switch journey goes through the real channel-action guard. - Simulator (iPhone 17 Pro, debug build of this branch signed in to a test community): opened a channel and sent a message; it was delivered and the composer cleared normally. Limitation: the error paths themselves were exercised only by widget tests, since the simulator shares the Mac's network and I couldn't drop the relay connection for it alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Tom Brow <tomb@squareup.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>