Repository navigation
Never lose a message when a send fails - #7784
Merged
ymichael merged 2 commits intoNov 18, 2026
Merged
Conversation
Every composer send path cleared the draft before awaiting the request and, on failure, restored it only into an empty composer. Text typed while the request was pending silently replaced the failed message. Queued-message and sent-message edits were likewise dropped when their message disappeared. Route the thread follow-up, shortcut, handoff and new-thread sends through one sendPromptDraft helper that merges the unsent draft ahead of anything typed since. Edits whose queued or sent message disappears now move into the composer with a warning instead of vanishing. restoreIfEmpty is renamed seedIfEmpty because only initial-prompt seeding still uses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ymichael
deleted the
bb/never-lose-a-message-when-a-send-fails-thr_enbyak9n2z
branch
November 18, 2026 21:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Every composer send path cleared the draft before awaiting the request. On failure it called
restoreIfEmpty, which writes the submitted draft back only if the composer is still empty. If the user had started typing while the request was pending (common on flaky Connect or mobile links), the failed message's text and attachments were dropped and the only trace was a generic "Failed to send message" toast. The same clear → await → restore-if-empty sequence was copied into the thread follow-up send, the modifier/shortcut send, the handoff send (ThreadDetailPromptArea) and the new-thread send (NewThreadComposer). A related gap: an inline queued-message edit was dropped silently when its message left the queue (deleted, sent elsewhere, edit hold rejected, or a 404 on save). A sent-message edit was also dropped when its message left the timeline; that case showed a warning toast, but the edited text was still lost.Credit: found through T3 Code's fixes for the same bug, pingdotgg/t3code#35102 and #32732.
What changed
@bb/client-core:mergeUnsentPromptDraft(unsent, current)puts the unsent draft first, then a blank line, then whatever is in the composer now. It shifts the newer mentions by the new offset, dedupes attachments by path, and does nothing if the composer already holds the same draft.usePromptDraftStorage: a new controller methodrestoreUnsentand one sharedsendPromptDraft(controller, submittedDraft, send)helper: clear if current matches, run the send, and on failure merge the draft back (only if this call cleared it). All four send paths now go through it, so none of them restores the draft on its own anymore.restoreIfEmptyis renamedseedIfEmptybecause initial-prompt seeding is now its only use, so it can't be mistaken for failure recovery.ThreadScreen): if the edited message leaves the timeline, a changed edit is merged into the thread composer the same way, guarded against running twice.The failure toast text is unchanged. The message now reappears in the composer, so I didn't add more wording to the toast. There are no wire, CLI or settings changes.
How you verified
Live repro on origin/main (02264cf) with
pnpm devand a fresh data dir, a fixture thread, and headless Chrome via dev-browser. Puppeteer request interception heldPOST /api/v1/threads/:id/send:FIRST message that the user sent, pressed Enter (the request was held and the composer cleared), typedSECOND draft typed while sending, then aborted the request (net::ERR_FAILED).SECOND draft typed while sending; the first message was gone from the composer and from localStorage; toast "Failed to send message".FIRST message that the user sent\n\nSECOND draft typed while sending(also persisted).fixture plus my EDITED words, then deleted the message from another client (bb thread queue delete).fixture plus my EDITED words\n\nnewer composer text, with a warning toast.Tests (each new or updated case fails against main's composer sources and passes here; 15 failures in
ThreadDetailPromptArea.test.tsxon main):ThreadDetailPromptArea.test.tsx: the existing "serializes … without losing edits" matrix (ordinary/modifier × same callback/remount/sibling) used to assert the lossy result (draft = only the newer edit). It now asserts the merge. Added a test for a failed handoff merged back with real storage, and queued-edit tests for leaving the queue, no changes, and a 404 on save.ThreadScreen.test.tsx: a changed sent-message edit moves into the composer when its message leaves the timeline.usePromptDraftStorage.test.tsx:sendPromptDraftsuccess, failure-with-newer-text, and never-cleared cases.client-core/test/prompt-draft.test.ts: merge order, mention offsets, attachment dedupe, idempotence.Commands:
pnpm exec turbo run lint typecheck --filter=@bb/app --filter=@bb/client-core,pnpm exec turbo run test --filter=@bb/client-core, and the targeted@bb/apptest files above.🤖 Generated with Claude Code