Repository navigation
Show a steered queue-mode send once instead of twice - #7531
Merged
ymichael merged 1 commit intoNov 13, 2026
Merged
Conversation
With Enter set to queue, a send to a thread whose turn is held open only by background agents is steered by the server. The app had predicted a queued send, so on the "sent" reply it appended a temporary user row, even when the realtime timeline refresh had already delivered the real one. The message showed twice until the next timeline refresh. The send reply now carries messageSequence, the thread event sequence of the delivered message (null when nothing was recorded, such as /clear). The app adds the temporary row only to timeline caches whose maxSeq has not reached it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/fix-thread-submission-race-condition-thr_kk5mynmymg
branch
November 13, 2026 21:06
This was referenced Nov 15, 2026
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
With Enter set to queue, a message sent to a Claude Code thread whose turn is held open only by background agents (main run idle) is steered by the server. That is by design since #5564. The client had predicted a queued send. When the
sentreply arrived,applySendThreadMessageSuccessremoved the queue placeholder and appended an optimistic user row to every timeline cache. It never checked whether the realtime timeline refresh had already delivered the real row. When the refresh won the race, the message showed twice, back to back. One copy disappeared on the next timeline refresh, usually the agent's reply.What changed
sendMessageResponseSchema'ssentvariant gainsmessageSequence: number | null. It is the thread event sequence of the delivered message'sclient/turn/requestedevent, comparable with a timeline'smaxSeq. It is null when the send recorded no message (/clear, or a drained row that vanished).sendQueuedMessageResponseSchemagets its own schema with the old shape: that path inserts its optimistic row before the request and never after, so it needs no position.sendThreadMessagereturns the recorded sequence for start, steer and reprovision dispatch.dispatchTurnDuringReprovisionnow returns{ messageSequence } | nullinstead of a boolean.requestThreadProvisionandrequestThreadTargetReprovisionreturn{ context, messageSequence }, so a thread's first dispatch reports it too.DispatchAttemptOutcome'sdispatchedvariant carries the sequence through toacceptThreadSendRequest.insertOptimisticTimelineRowUnlessDeliveredadds the temporary row only to timeline caches whosemaxSeqis belowmessageSequence, or to all caches when it is null. The timeline-row update predicate now receives the cached response instead of the query key.bb thread tellguide documentsmessageSequencein--jsonoutput. The plugin SDK is bumped to 0.6.144 because its bundled types include the server contract.How you verified
New app test table in
thread-runtime-cache-owner.test.ts:Against the original client code, case 1 fails with the duplicate.
Server send tests now assert that
messageSequenceequals the recordedclient/turn/requestedsequence. This includes the held-turn queue→steer case and the reprovision dispatch.Locally:
test/threadsandtest/publicpass (119 files, 1317 tests).turbo run typecheck lintpasses for the affected packages; it was re-run after rebasing.build:typespasses.Live: I ran
pnpm start:worktreewith a Claude Code thread held open by a background agent and Enter set to queue. The main and branch app bundles ran behind identical proxies that delay the send reply by 0.3 s. Real Enter on desktop (1440×900) and a real tap on send on phone (390×844), sampling timeline user rows every 30 ms:bb thread tell --mode queue --jsonreturnedmessageSequence: 81, andbb thread logshows event 81 is that message's steer.Not changed: the "Queue 1" placeholder that shows alongside the steered message while the request is in flight.
🤖 Generated with Claude Code