Repository navigation
fix(native-chat): draw a waiting send after the turn ahead of it - #25203
Closed
brennanb2025 wants to merge 1 commit into
Closed
brennanb2025 wants to merge 1 commit into
brennanb2025 wants to merge 1 commit into
Conversation
Codex can be handed a second send before the first one's turn opens. That turn's rows are then written after the second send's handover row, so the second send was drawn between the first message and its reply, and stayed there if a Stop left it in doubt. A handed-over send outside any turn is now drawn past the end of every turn whose opener the journal wrote before it, in journal order. A send steered into a running turn stays where it joined.
6 of 9 tasks
Contributor
Author
|
Closing in favour of #25217. This PR fixed the symptom when drawing: it moved a waiting message below the previous reply. Review showed the real cause is earlier. The host recorded where a message belongs at the moment it handed it over, before the agent decided whether it started a new turn or joined the running one. So a message that actually joined the turn was drawn as if it hadn't. The drawing rule couldn't tell those cases apart, and it misplaced a Claude follow-up that had been folded into the running turn. #25217 fixes it at delivery instead. The next queued message waits until the turn ahead has opened or settled, so it's recorded, and drawn, in the right place. |
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.
ELI5
If you send two messages while the agent is busy, both wait in line. When the agent picks them up, the second one could show up in the middle of the agent's reply to the first, above text the agent was still writing. Now a message that is waiting always shows after the reply it is waiting behind, and moves down as that reply grows.
What Changed
The problem.
/compact) is queued. When the turn ends, Orca hands the queued messages to Codex one after another.Before / after (two messages queued behind
/compact):User-facing change, called out: this moves live, in-flight messages, not only ones a Stop left behind. A message waiting for the turn ahead of it now draws below that turn's latest row and moves down while that turn streams, instead of staying above the reply.
Mechanism.
The shared message projection (
src/shared/structured-agent-session-message-projection.ts, used by desktop and phone) now draws a handed-over message that belongs to no turn past the end of every turn whose opener the journal wrote before that message's own row.The rule is in
src/shared/native-chat-waiting-send-placement.ts. It compares journal positions only, never clocks: the message's own row is already its handover row, so the host publishes nothing new.A message steered into a running turn belongs to that turn, so it stays where it joined. A turn the message itself opened is not one it waits on.
A queued message the host has not handed over yet is unchanged.
nativeChatMessagesWaitingBehindLiveTurnstill draws it after a running command, and this rule never touches it.The cost is one pass over the loaded rows, only when the chat holds a handed-over message outside any turn. Each such message is then placed with a binary search. Measured on the shared projection (milliseconds per update, median of 9 interleaved rounds):
A chat with no handed-over message pays nothing extra, and the cost grows with the rows loaded, not with rows times messages. The before and after drew identically in every benchmark case. Those cases have no message waiting behind a turn.
Why
mainyet) places a message a Stop took back with the same journal-order rule. The two will share this module once both land. This PR keeps the helper standalone and exported so that can be a one-line switch.Linked Issue
Closes STA-9348 (https://linear.app/stably/issue/STA-9348).
Visual Proof
To be added from a live QA run: before and after of two messages queued behind
/compact, while the first reply streams.Testing
New tests:
src/shared/structured-agent-session-message-projection-waiting-send.test.ts, built from the journals the shipped host wrote in the review runs:src/main/runtime/structured-agent-session-codex-waiting-send-placement.test.ts, end to end through the real host, journal and Codex adapter with the Codex stand-in, drawn by the client's own projection:/compact, both handed over before the first turn opens: the second draws after "working on the first";Each rule was checked by breaking it and watching its tests fail:
Run locally:
tc:node,tc:web, mobiletscand the mobile tests typecheck ratchet pass.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)