Repository navigation
fix(native-chat): keep queued messages in the chat's own record, so a refused one can't be skipped - #30418
Conversation
…n its card write fails Every reader of a queued card goes through one derived view of the journal's dispatch facts, so a card whose message was refused reads as returned even when its card-table update and heal both failed. One decision and one writer store the derived state for every action.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 Walkthrough
Priority: ⬆️ High Merge Risk: 🟡 Moderate · up to
|
Review loop status: ready for Brennan's reviewThe problem. In a native chat, messages can wait in a queue while the agent is busy. When the agent refuses a queued message, Orca's rule is that the message comes back as a "returned" card. The cards behind it then wait until you Send or Delete it. The card's state was saved in a separate write from the chat's record of the refusal. If that write failed, and the later repair write also failed, the card still read as "handed off". The queue then sent the next message past the refused one. The refused card also disappeared: its Send said "already sent" and its Delete did nothing. What changes for users. When saves succeed, nothing you see changes. When those writes fail, the refused message now still comes back as a blocking card, and Send, Delete and Edit on it work. Every reader now works out a card's state from the chat's own saved record, so a failed save can no longer make the queue skip a refused message. Review. One full round with four independent reviewers: the queue journal, the host and clients, a main-vs-branch trace of everything the user sees, and an architecture challenger. That was followed by the readiness checklist. They found no P0, P1 or P2 problems, so no code fixes were needed. The challenger kept the design: it is the same move earlier fixes made for the Stop and restart pauses, which were also changed to derive their state from the chat's record. The common transactional alternative writes its queue hold after the commit and only logs a failure, so it has this same bug. Deferred (P3, not fixed here):
Verified.
Not verified.
QA noticed these on both arms. The PR didn't cause them; they're listed for the lane:
For Brennan's reviewThree places where a human judgment matters:
|
…, not a second table A queued message lived in its own SQL table, and a hook that may be skipped copied each refusal from the journal into it. When that write failed, a refused card vanished: the cards behind it sent, and its Send and Delete did nothing. Each queued message is now a `queue` row in the chat's journal beside the submission that hands it off and the dispatch row that answers it. The reducer folds the card from those rows, so a refusal returns the card and holds the cards behind it with nothing written, and replay reads the same. Every action writes its own rows in one transaction. Cards an earlier build stored are read through the same classification until they move: each action moves its own card, and a bulk import runs once per open. A new epoch restates every card still owed an answer in the transaction that deletes the old rows. The settlement hook and its savepoint, the open-time heal, the drain's heal and the derived-card view are gone. The published card list is unchanged.
Cards are written through the journal, so tests queue them with their body alone and hand them off under their real fingerprint. Tests of the removed settlement hook, heal and SQL store are deleted; the text-update spec now covers the edit decision alone, and a test of an earlier build's stored holds seeds the legacy table and reads the imported cards. Rolling over an epoch now keeps a card whose hand-off was never handed over, so that test checks the retried id never sends rather than that nothing sends.
…ew epoch and a restart One whole-flow test through the host: the refusal writes no card row, a rewind that retires the refused hand-off and a rolled-over epoch keep the card returned, a restart and Resume send nothing behind it, its own Send refused again still holds the queue, and its Delete releases the next card in order.
…nal once, each read the same One mixed-import test through the host. The first open's import fails and moves nothing, yet every card reads as it will; Delete and Send each move only their own card. The next open moves the rest in one transaction, writing a refusal only where its hand-off is gone, nothing for answered cards, and leaving an unreadable row on disk. A later command turn spends a moved command card, a third open writes nothing, an old Delete replays from its receipt, and a chat with only answered legacy rows clears them in a delete-only transaction.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Remove the stale third argument in clearContext. It breaks… · queued-message-pause.spec.ts:72
src/main/native-chat/agent-session-journal/queued-message-pause.spec.ts:72
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRemove the stale third argument in
clearContext. It breaks the CI typecheck.This PR changes
JournalContextController.clearto take two parameters:boundaryandreceipt(journal-context-controller.tsLine 26). TheclearContexthelper still passes`caller-clear-${clock}`as a third argument.pnpm run typecheck:cifails at Line 72 with TS2554: "Expected 2 arguments, but got 3". This failure blocks the PR checks. Delete the argument. The other callers in this PR, such asagent-session-attachment-claims.test.ts, already pass only two arguments.🐛 Proposed fix
function clearContext(journal: AgentSessionJournal) { return journal.context.clear( { operationId: `clear-${++clock}`, afterFence: 0, clearedAt: clock }, - { write: () => {}, committed: () => {} }, - `caller-clear-${clock}` + { write: () => {}, committed: () => {} } ) }Source: Pipeline failures
🟠 Major · Add the missing queue fixture. · journal-unknown-row-kind.spec.ts:120-135
src/main/native-chat/agent-session-journal/journal-unknown-row-kind.spec.ts:120-135
🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAdd the missing
queuefixture.
rowOfEveryKind()requires one entry for everyJournalRow['kind'], but it omitsqueue. TypeScript therefore reportsTS2741, andpnpm run typecheck:cifails.Suggested fix
import { AGENT_JOURNAL_THREAD_SCOPE, + AGENT_SESSION_JOURNAL_QUEUE_SCHEMA_VERSION, AGENT_SESSION_JOURNAL_SCHEMA_VERSION, type AgentJournalItemIdentity, type AgentSessionJournalIdentity } from '../../../shared/agent-session-journal-types' @@ 'lifecycle-batch': { ...base, seq: 6, kind: 'lifecycle-batch', settlementId: 's', mutations: [{ kind: 'tombstone', itemId: 'i', revision: 3 }] - } + }, + queue: { + ...base, + v: AGENT_SESSION_JOURNAL_QUEUE_SCHEMA_VERSION, + seq: 7, + kind: 'queue', + messageId: 'q', + change: { op: 'withdrawn' } + }
🧹 Nitpick comments: 1
src/main/native-chat/agent-session-wire/structured-agent-session-queued-refused-card.test.ts: 1
120-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert that Resume succeeds.
If
rig.resume()returns an error, the cards can remain held and the later assertions can still pass. Check the result so this test verifies the successful Resume path.Proposed change
- await rig.resume() + expect(await rig.resume()).toMatchObject({ ok: true })
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d6ecd96d-09bd-4eab-8ecd-7aaebe1e5b49
📒 Files selected for processing: 67
src/main/native-chat/agent-session-attachments/agent-session-attachment-claims.test.tssrc/main/native-chat/agent-session-journal/command-receipt-transaction.spec.tssrc/main/native-chat/agent-session-journal/journal-closed-sets.test.tssrc/main/native-chat/agent-session-journal/journal-context-clear.tssrc/main/native-chat/agent-session-journal/journal-context-controller.tssrc/main/native-chat/agent-session-journal/journal-dispatch-reducer.tssrc/main/native-chat/agent-session-journal/journal-dispatch-settlement.tssrc/main/native-chat/agent-session-journal/journal-epoch-controller.tssrc/main/native-chat/agent-session-journal/journal-epoch-replacement.spec.tssrc/main/native-chat/agent-session-journal/journal-epoch-replacement.tssrc/main/native-chat/agent-session-journal/journal-epoch-rollover.tssrc/main/native-chat/agent-session-journal/journal-queue-events.tssrc/main/native-chat/agent-session-journal/journal-queue-fold.tssrc/main/native-chat/agent-session-journal/journal-queue-import.tssrc/main/native-chat/agent-session-journal/journal-queue-retention.tssrc/main/native-chat/agent-session-journal/journal-queued-message-contracts.test.tssrc/main/native-chat/agent-session-journal/journal-queued-messages.tssrc/main/native-chat/agent-session-journal/journal-reducer.tssrc/main/native-chat/agent-session-journal/journal-row-schema.tssrc/main/native-chat/agent-session-journal/journal-row-writer.tssrc/main/native-chat/agent-session-journal/journal-store-collaborators.tssrc/main/native-chat/agent-session-journal/journal-store-contracts.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-journal/journal-submission-hook.tssrc/main/native-chat/agent-session-journal/journal-submission-queued-link.spec.tssrc/main/native-chat/agent-session-journal/journal-submission-writer.tssrc/main/native-chat/agent-session-journal/journal-unsent-send-hold.spec.tssrc/main/native-chat/agent-session-journal/journal-unsent-send-hold.tssrc/main/native-chat/agent-session-journal/queued-message-bookkeeping-failure.spec.tssrc/main/native-chat/agent-session-journal/queued-message-delivered-echo.spec.tssrc/main/native-chat/agent-session-journal/queued-message-delivered-echo.tssrc/main/native-chat/agent-session-journal/queued-message-edit-leases.test.tssrc/main/native-chat/agent-session-journal/queued-message-holds.tssrc/main/native-chat/agent-session-journal/queued-message-pause.spec.tssrc/main/native-chat/agent-session-journal/queued-message-positions.tssrc/main/native-chat/agent-session-journal/queued-message-retention.tssrc/main/native-chat/agent-session-journal/queued-message-settlement.tssrc/main/native-chat/agent-session-journal/queued-message-store.spec.tssrc/main/native-chat/agent-session-journal/queued-message-stored-row.tssrc/main/native-chat/agent-session-journal/queued-message-table.tssrc/main/native-chat/agent-session-journal/queued-message-text-update.spec.tssrc/main/native-chat/agent-session-journal/queued-message-text-update.tssrc/main/native-chat/agent-session-wire/structured-agent-session-clear-rewind.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-codex-version-recovery.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-conversation-open.tssrc/main/native-chat/agent-session-wire/structured-agent-session-ended-prompt-cancel.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-event-recovery.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-lifetime.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-action-receipts.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-card-holds.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-edit.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-legacy-import.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-message-rig.test-fixture.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-messages.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-messages.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-mutations.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-pause.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-refused-card.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-send-answer.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-withdrawn-draft.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-restart-interruption-test-harness.tssrc/main/native-chat/agent-session-wire/structured-agent-session-stop-event.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-unsent-send-hold.test.tssrc/main/native-chat/agent-session-wire/structured-conversation-command.tssrc/main/runtime/agent-session-conversation-clear-commit.test.tssrc/main/runtime/structured-agent-session-failure-logging.test.tssrc/shared/agent-session-journal-types.ts
💤 Files with no reviewable changes: 14
- src/main/native-chat/agent-session-journal/queued-message-bookkeeping-failure.spec.ts
- src/main/native-chat/agent-session-journal/queued-message-retention.ts
- src/main/native-chat/agent-session-journal/journal-submission-hook.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-queued-message-rig.test-fixture.ts
- src/main/native-chat/agent-session-journal/queued-message-holds.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-restart-interruption-test-harness.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-queued-withdrawn-draft.test.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-codex-version-recovery.test.ts
- src/main/native-chat/agent-session-journal/journal-queued-message-contracts.test.ts
- src/main/native-chat/agent-session-journal/queued-message-store.spec.ts
- src/main/native-chat/agent-session-journal/queued-message-positions.ts
- src/main/native-chat/agent-session-journal/queued-message-edit-leases.test.ts
- src/main/native-chat/agent-session-wire/structured-agent-session-queued-pause.ts
- src/main/native-chat/agent-session-journal/queued-message-settlement.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
The row-kind table lists a queue row, the clear and legacy-import tests match the current signatures, and the downgrade test keeps only the leftover-send case: a queued card is now a newer-version journal row an older build keeps read-only, and users don't downgrade.
…on hook No caller passes one since the queue's savepoint bookkeeping left.
…uilds read The highest version this build reads is now 4, the queue row's. A newer build's row in these probes is written at version 3 so the older build meets its kind, not a newer version, and the Stop-event probe hands the older build the rows as stored, since a read raises each row's version.
The legacy-import test opens real SQLite, so it runs in the Node runtime project. The newest version this build reads is now 4, and a read raises a row's version to it, so the turn-lifecycle test no longer pins the in-memory version (the written one stays pinned by journalRowSchemaVersion).
…s both The per-row delivery check returned only the first waiting card an echo proved delivered, so when one settlement carried echoes for two cards the second stayed waiting and was sent again. It now returns every card the row proves delivered, and the fold withdraws each; replay folds the same.
…urnal first While the open's import had failed, an earlier build's card that read as refused through its hand-off lost that reading when an in-place rewind retired the hand-off: it disappeared and the card behind it sent. The rewind now adopts every legacy card ahead of its tombstones and deletes their rows in its own transaction, as an epoch replacement already does, so the fold latches each card's reading before its hand-off is gone.
…l unconfirmed The import dropped a legacy card handed off as a send whose delivery was unknown, though the fold keeps such a card linked and a later refusal returns it. The import now keeps every card whose hand-off a later row can still answer, through the same check the reducer folds dispatch rows by.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fb158b77-c26b-4396-93ac-139adc564e4f
📒 Files selected for processing: 18
config/scripts/vitest-node-runtime-files.mjssrc/main/codex/codex-structured-journal-translation-turn-lifecycle.test.tssrc/main/native-chat/agent-session-journal/command-receipt-transaction.spec.tssrc/main/native-chat/agent-session-journal/journal-context-rewind.tssrc/main/native-chat/agent-session-journal/journal-queue-fold.tssrc/main/native-chat/agent-session-journal/journal-queue-import.tssrc/main/native-chat/agent-session-journal/journal-queued-messages.tssrc/main/native-chat/agent-session-journal/journal-row-writer.tssrc/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-journal/journal-unknown-row-kind.spec.tssrc/main/native-chat/agent-session-journal/queued-message-delivered-echo.spec.tssrc/main/native-chat/agent-session-journal/queued-message-delivered-echo.tssrc/main/native-chat/agent-session-journal/queued-message-pause.spec.tssrc/main/native-chat/agent-session-wire/structured-agent-session-queued-legacy-import.test.tssrc/shared/agent-session-turn-record.test.tstests/e2e/cross-version-wire/agent-session-newer-chat-refusal.unit.test.tstests/e2e/cross-version-wire/agent-session-stop-event-downgrade.unit.test.tstests/e2e/cross-version-wire/kept-card-downgrade.unit.test.ts
💤 Files with no reviewable changes: 2
- src/main/codex/codex-structured-journal-translation-turn-lifecycle.test.ts
- src/main/native-chat/agent-session-journal/command-receipt-transaction.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…ecycle-queue-derived-cards
|
Final review and real-agent QA complete on the current head A real Claude and Codex re-run on this head (M4Air, ticket 1625; instrumented QA build that switches on the still-dark mid-turn queue, source restored after) passed both flows for both agents:
The image-edit flow below passed on the previous head Queued messages could disappear after a refused send or be sent twice after Stop/restart because the queue kept a separate saved outcome. This PR keeps each queued message in the conversation record; a message that may have reached the agent stays in the conversation and is never automatically queued again. Final review and real-agent QA complete on Current-head desktop checks passed. The earlier exact-head run passed Claude ordinary queue/drain, Claude Stop → Paused → actual Resume, Claude normal close/reopen, Codex Stop → Paused → actual Resume, and Codex normal close/reopen. The owner's final M4Air takeover then completed Codex ordinary queue/drain, queued image replacement/text editing, and three-card FIFO on this same head using the real Codex CLI. During an actual running Grok waived by Brennan (10-21): "We're out of grok usage right now. So skip it and test w/ unit tests" Grok has tests-only evidence from the earlier Retained limitations and follow-ups. The incoming model-choice change removed the old missing-positive model-catalog Fast refusal. Inherited omitted-default restoration (STA-11572) and the separate reported-disabled-Fast restriction remain qualified, without an alignment claim or waiver. The temporary Claude unwritten Stop failure returned-card exception (STA-11660), failed-import retained/live/reconnecting/paged-history correction after reopen (STA-11608), and recovery work in STA-11448/#30580 remain as documented below. Stopped-text carry is unchanged. Stop evidence proves queue pause/resume, not native sleeping-command cancellation. Stale Settings copy saying image messages send immediately predates this PR; the owner assigned its correction to the B1 recovery follow-up. No completed fix of that copy is claimed here. Evidence boundaries. Upgrade and native-phone evidence below is from Current-head final Codex evidence ( Current-head driver preparation failure ( The whole-window screenshot shows onboarding over the empty Codex chat. No acceptance input or CDP file-drop call occurred; this is setup evidence only. Current-head incomplete attachment setup ( These screenshots show Settings and the empty configured Codex chat before any base turn or queued card. They do not demonstrate queue delivery or image replacement.
Current-head desktop evidence ( Claude: ordinary queued message and real reply: Claude: Paused, reply after actual Resume, and reopened chat: Codex: queued during a real command, Paused, and reply after actual Resume: Codex: reopened same chat with no duplicate or queue: Historical completed review on Queued messages could disappear after a refused send or be sent twice after Stop/restart because the queue kept a separate saved outcome. This PR keeps each queued message in the conversation record; a message that may have reached the agent stays in the conversation and is never automatically queued again. Final review complete on Grok waived by Brennan (10-21): "We're out of grok usage right now. So skip it and test w/ unit tests" Completed desktop checks on this head. Genuine Claude and Codex chats created by the previous Additional desktop checks passed on this head. In the corrected FIFO run, all three cards visibly waited together during a real Codex turn, then each produced one real reply in order. Records join each card to exactly one host submission, accepted dispatch, native input and reply. A separate Stop test retained its queued card as Paused with zero delivery during a bounded observation; the actual Resume control then delivered it once and produced one real reply. Earlier setup/driver failures and the incomplete two-card attempt remain separate evidence, never passes. Both rigs are stopped and profiles preserved. Observed limitation: the native sleeping command remained live after Stop while the queue stayed paused. This establishes queue pause and delivery behavior, not termination of that command. No main comparison or PR attribution was established for this observation. The lane owner is tracking that possibly inherited command-cancellation behavior separately; no additional Stop reproduction or process-cancellation change was made here. Temporary difference: an already-open chat that reconnects or pages older history after a failed upgrade import shows the stopped message only after reopen; tracked in STA-11608. The owner has ruled that history publication and older-client approval controls will be repaired in that separate follow-up. This PR keeps its snapshot correction. The final main merge and source comparison are complete. The final-head native phone check is complete. The ordinary small-history phone re-entry does not exercise or close the failed-import retained-history follow-up. Not changed here: a later send can carry an earlier stopped request's text, and the agent may answer that earlier request. The same saved-chat experiment on merged main produced the same six-message provider sequence as the branch. This is inherited behavior; there is no demonstrated false cancellation proof or queue regression. Pause loss across restart also reproduced on main. Claude can still refuse an omitted effort after an earlier override (STA-11572), or Fast when a listed model lacks positive capability evidence (STA-11451). These checks are inherited from main and owned by separate work; this review does not claim they are aligned or waived. Coverage limits: saved For Brennan's review: final-head screenshots below cover the completed desktop and native iOS checks. Separately labelled pre-merge screenshots remain historical evidence. The history publication repair remains tracked in STA-11608. Final-head desktop evidence ( Both saved chats after upgrade, with the previous reply and two new real replies:
Ordinary queue/drain completed with Claude; the image flow below also shows Codex's completed ordinary queued reply: Codex queued image/text before editing, the blue replacement in the editor, and the real reply after Save:
The running turn ended while the editor was open, so Save drained immediately; no saved card still waiting was captured. Retained journal and provider records confirm one delivery of the edited text and exact replacement PNG bytes. Final-head desktop FIFO and Stop/Resume ( Three cards waited together, then each produced one real reply in order:
Stop kept the queued card paused; the actual Resume control delivered it once and produced one real reply:
Native phone acceptance and cleanup. One actual native Send of Final-head native iOS phone evidence ( The actual paired iOS app sent one message while a real Codex turn ran. One queued card drained normally to one real reply; reopening the workspace kept the message and reply without reviving the card.
The invalid older QA host remains visible beside the fresh connected host in the pairing screenshot. The test used the fresh host and a new chat throughout. This is ordinary iOS Codex coverage; Android, mobile images/editing/FIFO/Stop/Resume/restart/upgrade and the failed-import retained-history follow-up were not repeated on phone. Historical pre-merge evidence ( Image edit and actual delivered replacement
Stop holds the queue; Resume sends each card once
Old chats after restart: two real replies each
Three queued messages, in order, once each Inherited stopped-text carry reproduced on merged main Pre-merge native iOS phone: pair, queue, drain and reply
For Brennan's review: the current-head galleries show the edited attachment, natural three-message drain, both agents' actual Resume and close/reopen results. Earlier main/branch upgrade and Stop comparisons retain their original head labels. The remaining user-facing recovery differences and follow-up ownership are stated above; no new product decision is requested by this final round. |
One provider echo proves one delivery, yet it withdrew every waiting card with the same text whose hand-off was refused, so a second identical card was lost. The fold now pairs each echo with one card: on its own row the earliest-positioned match no other echo of that row took, and for a card that waits again the earliest applied echo no card has taken. Paired echoes live in the fold's state, so live and replay pair the same; readers of cards not yet imported work on a copy.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8348c0cf-199c-41b6-993e-2121da8b5bda
📒 Files selected for processing: 4
src/main/native-chat/agent-session-journal/journal-queue-fold.tssrc/main/native-chat/agent-session-journal/journal-queue-import.tssrc/main/native-chat/agent-session-journal/queued-message-delivered-echo.spec.tssrc/main/native-chat/agent-session-journal/queued-message-delivered-echo.ts
🚧 Files skipped from review as they are similar to previous changes: 3
- src/main/native-chat/agent-session-journal/queued-message-delivered-echo.spec.ts
- src/main/native-chat/agent-session-journal/queued-message-delivered-echo.ts
- src/main/native-chat/agent-session-journal/journal-queue-fold.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
…only on proof it never got it Pressing Stop after Orca handed a queued or steered message to the agent, before the agent confirmed it, put the card back in the queue, and Resume or the next send sent it again. A check matching the agent's echo of the text was the only guard against a double send, and it kept trading a resend for a lost card. Whether the card waited again was decided by the rejection's category, not by proof the agent never got the message. A refused hand-off now waits again only where Orca proves the agent never received it: the host still held it, or whoever settled it recorded that. A failure still returns the card and holds the cards behind it. Anything else may have reached the agent, so the card is spent and its message reads as sent, derived on every fold from the stored rejection: with the turn it was answered into, as that turn's unconfirmed message where it was handed over; withdrawn before any turn opened, as a person's own send a Stop took back. The reopen mark ignores a recovered doubt, and the restart reconciler no longer judges a queued hand-off unsent from what history lacks. The echo text matching and its pairing are deleted. A close or quit while the agent starts settles sends with the unrun hold. The host hands nothing to a child before its start answers (structured-agent-session-delivery-loop.ts: a handover needs phase ready), so such a send went to an earlier child and may have run: it now reads as sent instead of waiting again.
…run lets the card wait again Claude says when it removed a send without running it: the interrupt receipt's cancelled list, or a command_lifecycle cancelled, discarded or refused frame for a command that never started. Every one settles through rejectClaudeDispatchWaiters, which now marks the settlement unrun. For a queued card's hand-off the host records that as proof the agent never got it, so the card waits again under the queue's pause. A direct send keeps the plain refusal: there the proof would owe it as stopped history.
…lows the same rule on upgrade Earlier builds put a card back to waiting after any refusal without a verdict and cleared its link, so a card the agent may already have would be sent again after the upgrade. The card's own hand-offs in the journal decide now: unchanged and last sent as one that may have reached the agent, it is spent on that hand-off and its message reads as sent; edited or sent again since, it is held for its own Send under a host-only marker that publishes as a plain hold; with no hand-off in doubt, including one that never left Orca, it waits as before. The import writes a card spent on a hand-off in doubt, so its message shows.
… uses it The lookup's callback lost the narrowing of the row's change, which the mobile test typecheck rejects.
…in the Stop tests Three tests pinned the old rule, that a card handed into a running turn comes back to waiting when a Stop ends it. Under the new rule nothing proves the agent never got it, so the card is spent: with the turn named, its message reads as that turn's unconfirmed one; without, as a send the Stop took back. Neither is ever sent again.
…ecycle-queue-derived-cards Conflicts, resolved so main's change stands and queued messages stay in the chat's journal, sent again only on proof the agent never got them: - #28046 (choices fixed per accepted message): its options type and its one reader reach the journal's queue row and the card fold too; the queued_messages writers it retyped stay deleted. - #30403 (Codex late receipt): the late settlement keeps both main's accept-at-its-turn path and this branch's unrun proof for a card. - A drain logging test main deleted stays deleted.
…he agent waits again A Stop that aborts a hand-off after its row is written but before the agent call now records the withdrawal as never reaching the agent, for queued hand-offs only, so plan D's rule returns the card to waiting under the Stop's pause instead of spending it. Direct sends keep the plain withdrawal (the flag would owe them as stopped history). The agent's own refusal while aborted is kept rather than overwritten, and an abort thrown during the call stays in doubt.
…t waits again The abort signal reaches only an adapter's preparation (its options, the previous turn opening), never its write, so the signal's own reason thrown back is the adapter saying nothing was written. The handover now reads that, for queued hand-offs only, as never reaching the agent, so the card waits again under the Stop's pause. Claude no longer wraps that abort as an option refusal, which had returned a stopped card as a refused one blocking the queue. A real refusal keeps its cause and its barrier; any other throw stays in doubt and is never resent.
…ecycle-queue-derived-cards
…ard through the journal queue Main's #30396 wrote its backlog card with the stored fingerprint and host-instance stamp the journal queue derives instead; the card the Continue must yield to is the same waiting card.
…s cancelled-unrun receipt carries
Adapts the journal-queue design to the queued-message image edit from main: JournalQueuedMessages.update decides through the shared queuedMessageWithEdit rule (queuedMessageUpdateDecision) and claims only newly added uploads in the edit's own journal transaction. The old queue-table writer main renamed (updateQueuedMessage) stays deleted; its claim moved onto the journal update.
* fix(git): preserve unmerged branches with no net file changes * fix(workspace): show launch actions in empty tab groups (#32182) * fix(workspace): show launch actions in empty tab groups * fix(workspace): resolve empty-pane browser policy by owner * Scope daemon inventories for safe worktree teardown (#32171) * Fix scoped daemon inventories without changing terminal input routes * Serialize daemon owner inventory refreshes safely * Serialize daemon owner inventory refreshes safely * test(daemon): protect baseline inventory budgets and recovery * fix(daemon): clear route proof during synthetic exits (#32196) * docs: condense test anti-pattern guidance (#32201) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * refactor: colocate repository draft input and tests (#32155) * test: consolidate discovery coverage and replace copied oracles (#32211) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * test: retire copied oracles and implementation inventories (#32206) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * test: remove classification inventories and verify settled boundaries (#32216) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * test: keep explicit regressions without legacy algorithm copies (#32218) * test: keep explicit regressions without legacy algorithm copies * test: use Number.NaN in latency fixtures --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * ci: avoid slow Ubuntu mirrors during WebKit setup (#32205) * ci: reuse bounded Ubuntu mirror setup for WebKit * ci: preserve Ubuntu setup for dispatched older refs * perf(renderer): scope runtime connection and parking subscriptions (#32199) * fix(chat): allow visuals to declare open without breaking scripts (#32226) * fix(native-chat): keep queued messages in the chat's own record, so a refused one can't be skipped (#30418) * fix(native-chat): a refused queued message still blocks the queue when its card write fails Every reader of a queued card goes through one derived view of the journal's dispatch facts, so a card whose message was refused reads as returned even when its card-table update and heal both failed. One decision and one writer store the derived state for every action. * refactor(native-chat): keep each queued message in the chat's journal, not a second table A queued message lived in its own SQL table, and a hook that may be skipped copied each refusal from the journal into it. When that write failed, a refused card vanished: the cards behind it sent, and its Send and Delete did nothing. Each queued message is now a `queue` row in the chat's journal beside the submission that hands it off and the dispatch row that answers it. The reducer folds the card from those rows, so a refusal returns the card and holds the cards behind it with nothing written, and replay reads the same. Every action writes its own rows in one transaction. Cards an earlier build stored are read through the same classification until they move: each action moves its own card, and a bulk import runs once per open. A new epoch restates every card still owed an answer in the transaction that deletes the old rows. The settlement hook and its savepoint, the open-time heal, the drain's heal and the derived-card view are gone. The published card list is unchanged. * test(native-chat): adapt the queue tests to cards kept in the journal Cards are written through the journal, so tests queue them with their body alone and hand them off under their real fingerprint. Tests of the removed settlement hook, heal and SQL store are deleted; the text-update spec now covers the edit decision alone, and a test of an earlier build's stored holds seeds the legacy table and reads the imported cards. Rolling over an epoch now keeps a card whose hand-off was never handed over, so that test checks the retried id never sends rather than that nothing sends. * test(native-chat): a refused card holds the queue through rewind, a new epoch and a restart One whole-flow test through the host: the refusal writes no card row, a rewind that retires the refused hand-off and a rolled-over epoch keep the card returned, a restart and Resume send nothing behind it, its own Send refused again still holds the queue, and its Delete releases the next card in order. * test(native-chat): an earlier build's queued cards move into the journal once, each read the same One mixed-import test through the host. The first open's import fails and moves nothing, yet every card reads as it will; Delete and Send each move only their own card. The next open moves the rest in one transaction, writing a refusal only where its hand-off is gone, nothing for answered cards, and leaving an unreadable row on disk. A later command turn spends a moved command card, a third open writes nothing, an old Delete replays from its receipt, and a chat with only answered legacy rows clears them in a delete-only transaction. * test(native-chat): adapt typechecked tests to cards kept in the journal The row-kind table lists a queue row, the clear and legacy-import tests match the current signatures, and the downgrade test keeps only the leftover-send case: a queued card is now a newer-version journal row an older build keeps read-only, and users don't downgrade. * refactor(native-chat): drop the journal row writer's unused transaction hook No caller passes one since the queue's savepoint bookkeeping left. * test(native-chat): downgrade probes write rows at the version older builds read The highest version this build reads is now 4, the queue row's. A newer build's row in these probes is written at version 3 so the older build meets its kind, not a newer version, and the Stop-event probe hands the older build the rows as stored, since a read raises each row's version. * test(native-chat): unit tests follow the queue row's version 4 The legacy-import test opens real SQLite, so it runs in the Node runtime project. The newest version this build reads is now 4, and a read raises a row's version to it, so the turn-lifecycle test no longer pins the in-memory version (the written one stays pinned by journalRowSchemaVersion). * fix(native-chat): one batch echoing two refused queued messages spends both The per-row delivery check returned only the first waiting card an echo proved delivered, so when one settlement carried echoes for two cards the second stayed waiting and was sent again. It now returns every card the row proves delivered, and the fold withdraws each; replay folds the same. * fix(native-chat): a rewind moves an earlier build's cards into the journal first While the open's import had failed, an earlier build's card that read as refused through its hand-off lost that reading when an in-place rewind retired the hand-off: it disappeared and the card behind it sent. The rewind now adopts every legacy card ahead of its tombstones and deletes their rows in its own transaction, as an epoch replacement already does, so the fold latches each card's reading before its hand-off is gone. * fix(native-chat): keep an earlier build's card whose hand-off is still unconfirmed The import dropped a legacy card handed off as a send whose delivery was unknown, though the fold keeps such a card linked and a later refusal returns it. The import now keeps every card whose hand-off a later row can still answer, through the same check the reducer folds dispatch rows by. * fix(native-chat): one delivery echo withdraws at most one queued card One provider echo proves one delivery, yet it withdrew every waiting card with the same text whose hand-off was refused, so a second identical card was lost. The fold now pairs each echo with one card: on its own row the earliest-positioned match no other echo of that row took, and for a card that waits again the earliest applied echo no card has taken. Paired echoes live in the fold's state, so live and replay pair the same; readers of cards not yet imported work on a copy. * fix(native-chat): a queued message handed to the agent is sent again only on proof it never got it Pressing Stop after Orca handed a queued or steered message to the agent, before the agent confirmed it, put the card back in the queue, and Resume or the next send sent it again. A check matching the agent's echo of the text was the only guard against a double send, and it kept trading a resend for a lost card. Whether the card waited again was decided by the rejection's category, not by proof the agent never got the message. A refused hand-off now waits again only where Orca proves the agent never received it: the host still held it, or whoever settled it recorded that. A failure still returns the card and holds the cards behind it. Anything else may have reached the agent, so the card is spent and its message reads as sent, derived on every fold from the stored rejection: with the turn it was answered into, as that turn's unconfirmed message where it was handed over; withdrawn before any turn opened, as a person's own send a Stop took back. The reopen mark ignores a recovered doubt, and the restart reconciler no longer judges a queued hand-off unsent from what history lacks. The echo text matching and its pairing are deleted. A close or quit while the agent starts settles sends with the unrun hold. The host hands nothing to a child before its start answers (structured-agent-session-delivery-loop.ts: a handover needs phase ready), so such a send went to an earlier child and may have run: it now reads as sent instead of waiting again. * fix(native-chat): Claude's report that it removed a queued message unrun lets the card wait again Claude says when it removed a send without running it: the interrupt receipt's cancelled list, or a command_lifecycle cancelled, discarded or refused frame for a command that never started. Every one settles through rejectClaudeDispatchWaiters, which now marks the settlement unrun. For a queued card's hand-off the host records that as proof the agent never got it, so the card waits again under the queue's pause. A direct send keeps the plain refusal: there the proof would owe it as stopped history. * fix(native-chat): an earlier build's card stopped after hand-over follows the same rule on upgrade Earlier builds put a card back to waiting after any refusal without a verdict and cleared its link, so a card the agent may already have would be sent again after the upgrade. The card's own hand-offs in the journal decide now: unchanged and last sent as one that may have reached the agent, it is spent on that hand-off and its message reads as sent; edited or sent again since, it is held for its own Send under a host-only marker that publishes as a plain hold; with no hand-off in doubt, including one that never left Orca, it waits as before. The import writes a card spent on a hand-off in doubt, so its message shows. * fix(native-chat): read a queued row's hand-off before the lookup that uses it The lookup's callback lost the narrowing of the row's change, which the mobile test typecheck rejects. * test(native-chat): a card steered into a turn a Stop ends stays sent in the Stop tests Three tests pinned the old rule, that a card handed into a running turn comes back to waiting when a Stop ends it. Under the new rule nothing proves the agent never got it, so the card is spent: with the turn named, its message reads as that turn's unconfirmed one; without, as a send the Stop took back. Neither is ever sent again. * fix(native-chat): a queued message stopped before Orca handed it to the agent waits again A Stop that aborts a hand-off after its row is written but before the agent call now records the withdrawal as never reaching the agent, for queued hand-offs only, so plan D's rule returns the card to waiting under the Stop's pause instead of spending it. Direct sends keep the plain withdrawal (the flag would owe them as stopped history). The agent's own refusal while aborted is kept rather than overwritten, and an abort thrown during the call stays in doubt. * fix(native-chat): a queued message stopped while the agent prepares it waits again The abort signal reaches only an adapter's preparation (its options, the previous turn opening), never its write, so the signal's own reason thrown back is the adapter saying nothing was written. The handover now reads that, for queued hand-offs only, as never reaching the agent, so the card waits again under the Stop's pause. Claude no longer wraps that abort as an option refusal, which had returned a stopped card as a refused one blocking the queue. A real refusal keeps its cause and its barrier; any other throw stays in doubt and is never resent. * test(native-chat): the usage-limit Continue backlog case writes its card through the journal queue Main's #30396 wrote its backlog card with the stored fingerprint and host-instance stamp the journal queue derives instead; the card the Continue must yield to is the same waiting card. * test(claude): the real-CLI queued Stop expects the unrun mark Claude's cancelled-unrun receipt carries * fix(native-chat): retain spent legacy messages when import fails * Bound per-write chat selector work and guard ownership scans (#32109) * Guard per-write chat selector work with shared ownership indexes * Use checked sender session identities in the scale fixture * Read each indexed tab row once during snapshot rebuilds * Fix lexical binding and cache matching in selector lint rules * Keep behavioral selector guards and resolve imported bindings * Require selector binding definitions to declare functions * Key performance subscribers by saved chat scope * Show activity status with worktree-style counts (#26443) * Show prioritized agent counts on the activity bell * Move activity badge into the corner and shrink its count * Use a fixed side column for activity status and counts * Fix activity count spacing and status alignment * Use worktree-style superscript counts for activity * Keep activity count positions and update only number styling * Keep idle layout fixtures out of active agent status updates * Show child workspace statuses in the children toggle (#32224) * Show child workspace status counts in lineage toggle * Give child status summaries room and wrap narrow layouts * Use solid working dots and keep child summaries on one line * Restore children icon and clarify worktree tooltip * Keep child totals clear of status counts in narrow layouts * fix: preserve workspace review references when clearing active reviews (#32263) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * Saving a file, then closing that tab mid-save, no longer leaves its other tabs looking clean (STA-11786) (#32259) * fix(editor): settle a save's shared record when the saving tab closed mid-write With one file open in two workspaces, closing the saving tab while its write was in flight left the other tab's disk baseline, dirty flag, draft and loaded text on the pre-save version: every completion step looked the closed tab up by id and found nothing, and the saved event listed only the closed tab as the record's views. An undo back to the old text then read as clean and closed without asking. The write now captures its record id with no await before the write, and completion (rebaseline, dirty/draft settle, conflict clear or refusal banner, saved event's view list) goes through a live view of that record, preferring a writable one. The save runner and the write-lock wait do the same, so a save queued by a tab that closes still writes through the record's remaining view. The chat visual's saved-event listener also falls back to the record's views. Co-Authored-By: Claude <noreply@anthropic.com> * fix(editor): follow a closed saver's record through re-keys, kept records and listeners Review follow-ups to the closed-saving-tab fix: - Completion now finds the record through the view ids captured before the write, not the record id: a re-key mid-write (an unpinned runtime tab resolving its pairing) keeps views but changes the id, which brought the original bug back. - A fallback writer (asking view closed while queued or waiting on the file lock) is chosen like autosave/restart's writer: writable and on a current connection, so a stale-connection sibling no longer throws when a current view exists. - With no view of the record left, a kept record (no-prompt removal) is dropped when the write saved its text, else rebaselined; other open views of the file (a detached peer) take the written baseline, keeping their edits. - A save may mark a record clean through a read-only or CSV-preview view (markFileDirty `written`); such views still never become dirty. - Markdown preview refresh and the CSV pending-cell listener match the saved event's record views, not only the saving view's id. Co-Authored-By: Claude <noreply@anthropic.com> * test(editor): name the closed-view save harness as a test fixture The focus-read ratchet scans non-test sources; the `.test-fixture.ts` suffix marks this harness as test-only like the repo's other fixtures. Co-Authored-By: Claude <noreply@anthropic.com> * test(ci): list the closed-view save rig as a unit support bridge The rig builds on the autosave test fixture, which takes the editor slice harness, so the routing check saw it as a product consumer of that harness. Bridges are an explicit list, like the browser drawn-from-main fixture. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com> * Show task names for Codex subagents (#32243) * fix: name Codex subagents from rollout metadata * Hide generic default role in child agent rows * Reject non-regular Codex identity transcripts without blocking * [comment audit] Shorten preload comments (#32257) * chore: audit preload root comments and track repository coverage * docs: track repository comment audit coverage * chore: keep comment audit tracker local * chore: shorten preload API contract comments --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * fix: offload macOS deletion spawns and reduce branch cleanup (#32227) * fix: reduce worktree deletion branch cleanup overhead Refresh only the remote base branches needed to prove a branch merged, with automatic maintenance disabled. Skip merge simulation when no common ancestor is available and preserve the branch when its remote base cannot be refreshed. * fix: preserve fetch mappings and live branch cleanup fallbacks * fix: spawn macOS worktree deletion commands off the main thread * test: remove redundant cases and start comprehensive value tracker (#32269) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * fix(web): the browser client advertises the desktop's chat capabilities, so its host opens chats (#32253) * fix(web): the browser client advertises the desktop's chat capabilities, so its host opens chats The browser client's handshake never named agent-session.structured.v1, so a paired host refused every agentSession call with structured_agent_session_unsupported and withheld chat tabs. The desktop window, the Electron remote handshake and the browser client now build their lists from one shared array of what the renderer's chat implements. Fixes #32145 * refactor(web): keep the browser client's capability list beside the desktop's in shared The host-side test parses both handshakes with the host's own parser, which the node typecheck project can only import from src/shared. * test(web): assert close-intent support in the auth frame, not the whole capability list * fix(terminal): a timed-out CLI split names its pending pane, and a retry can never re-run its command (#32278) * fix(terminal): a timed-out CLI split names its pending pane and can be retried without splitting again Fixes #32169 * fix(terminal): a blank retry id or a closed pane never re-runs a split's command * refactor(terminal): a split retry only waits for its pane and never asks the window again * fix(terminal): a split missing from the graph is reported pending, never closed * fix(ssh): never block or over-read on an SSH identity file (#32274) Every place Orca reads an SSH key or identity file now goes through one reader that refuses directories, FIFOs and devices (including through symlinks) with a nonblocking open, and caps the read at 1 MB. An auth failure now names any identity file that was skipped and why. Fixes #31965. Reported by @Huge, who also proposed the first fix in #31966. Co-authored-by: Martin Vlach <mr.huge@seznam.cz> * test: finish fixture work before unit-test cleanup (#32285) * fix(mobile): keep a terminal tab's chat identity while its handle is unchanged (#32251) * fix(mobile): keep a terminal tab's chat identity while its handle is unchanged A status frame that omits agentType or providerSession flipped chat back to the terminal for tabs with no launchAgent (#31977), and left a launched tab with no session to read (#32134). Mobile now remembers the last resolved agent and session per tab and handle, so a missing field is treated as missing evidence. * fix(mobile): keep remembered chat read-only and drop it on relaunch A chat resolved only from this phone's memory may sit on a bare shell, so its writes stay locked until live status confirms the agent. A live agent frame without a session no longer inherits the previous conversation, and the latest remembered agent outranks an older launch hint. * fix(mobile): gate native-chat image sends on a confirmed live agent An image send from a chat only this phone remembers could paste into a bare shell; it now shares the confirmed-agent gate with text sends. * fix(mobile): type remembered chat identity structurally Importing MobileSessionTab into the eligibility module pulled React Native globals into the e2e program through nested-agent-idle-session-owner.spec.ts, retyping setTimeout as number there. * fix(terminal): never present a half-built synchronized-output frame on reveal or recovery (#32281) Settled reveal and every other atlas recovery forced the current xterm buffer onto the screen even while a TUI held DEC 2026 synchronized output. Codex erases rows inside each held redraw, so a reveal mid-redraw showed a blank pane for a frame (#32198). Viewport presents now have one mode: they keep the last coherent canvas and let xterm present when the TUI closes the frame, bounded by xterm's 1s synchronized-output safety timeout. Structural replay keeps its retained frame up until an open synchronized frame closes, bounded by its existing hold cap. Co-authored-by: YEONGUK LEE <contact@abruption.dev> * refactor(renderer): colocate task page pagination rules (#32297) * perf(test): bundle Zod once per isolated Vitest invocation (#32298) * Use incremental tsrs locally and update Bun to 1.4.4 (#32276) * Use incremental tsrs for local typechecks * Update pinned Bun to 1.4.4 * fix(deps): bump dompurify to 3.4.17 and docs next to 16.4.1 for security advisories dompurify 3.4.17 patches GHSA-cg2g-xh64-v4q7, GHSA-mrv2-3pqr-j5jr and GHSA-c6gr-qvv4-5v3f in the root and mobile lockfiles. next 16.4.1 patches GHSA-2464-fhr4-w9xw, GHSA-673q-mjm6-r5xr and GHSA-p3m5-59mp-jv5r in the docs site. * Prepare mobile bundle for smoke benchmarks * Give native compiler benchmarks a larger ARM runner --------- Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> * test: trim redundant coverage and fix vacuous assertions (#32305) * test: remove redundant cases and repair behavioral assertions * docs: reconcile audit records with current main * fix(deps): apply security updates from #32101 Apply the six-file DOMPurify 3.4.17 and Next.js 16.4.1 patch from PR #32101 to resolve the dependency security gate for this test audit. Original patch by Brennan Benson. * test: satisfy changed-line quality gates Add required braces and replace filter indexing with find. Rerun both CI quality gates and the 27 affected relay tests; refresh audit hashes and record the corrections. --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> * fix(ci): retain ambiguous unit-test import consumers (#32366) * test: exercise real boundaries and trim redundant cases (#32353) * test: replace redundant checks with observed behavior * docs: reconcile completed audit batches and upstream review --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> * fix(git): retain zero-net history with current merge-base guards --------- Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Co-authored-by: OrcaWin <alpha-eng@stably.ai> Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Martin Vlach <mr.huge@seznam.cz> Co-authored-by: YEONGUK LEE <contact@abruption.dev>
































































ELI5
You can queue messages behind a running chat turn. Two things went wrong with them. First, if the agent refused a queued message, it was supposed to come back as a card that holds the queue until you press its own Send or Delete; but when a bookkeeping save failed, the card silently vanished and the next message went out. Second, if you pressed Stop (or Orca restarted) after a queued message had already been handed to the agent, Orca put it back in the queue and sent it again later, even though the agent may already have had it. The only guard against that double send was matching the agent's echo of the text, and that guard kept producing new bugs. Now each queued message lives in the chat's own saved record, and a message that may have reached the agent stays in the conversation instead of going back to the queue.
What Changed
The problem.
What you see now.
The mechanism.
queueentry kind records queue, edit, move, hold and withdraw, and each action writes its entries in one transaction. Handing a card to the agent is the send entry that already names the card. A refusal writes only the rejection the delivery path already writes; the returned card and its hold on the queue are worked out from it when the journal is read. The old queue table, its settlement writer, its repair and the derived-card view are deleted.queuedHandOffOutcome). A failure brings the card back as a blocking card. Proof the agent never got it puts the card back to waiting. Proof means the host still held it, or whoever settled it recorded that it never reached the agent (Claude's report that it removed a queued message unrun now records this). Anything else is in doubt: the card stays spent and its message shows as unconfirmed, using the existing "couldn't confirm" state that every client already draws. This is worked out each time the journal is read, from the stored rejection, so nothing new is saved.Existing queued cards (moving from the old table).
Compatibility. No new saved field and no wire change. The upgrade's held card uses one new host-only value of the existing hold reason, published as a plain hold. The host now publishes an existing state ("couldn't confirm", or a stopped direct send) where it used to publish a returned card, and desktop, phone and older clients already draw both. Everything runs on the host that owns the chat, including over SSH.
STA-11036 (a delivered queued message sent twice). After this PR it can't happen: nothing puts a message that may have reached the agent back in the queue, so there is nothing to send twice and no echo to match. No separate card write exists any more either, so a failed save can't lose the outcome.
Fixed in review.
Why
Both bugs came from the queue deciding something it couldn't know from what it stored.
Differences from the common pattern and from the plan:
Not changed here: Claude can still refuse an omitted effort after an earlier override (STA-11572), or Fast when the agent reports a disabling reason other than a user preference or required opt-in. The incoming model-choice change removed the earlier missing-positive catalog Fast check; its old STA-11451 trace no longer applies to this head. The remaining checks are inherited from main and owned by the separate Claude model-switch work. This review does not claim they are aligned or waived.
Not changed here: A later send carries a stopped request’s text, and the agent may answer that earlier request. Real QA reproduced the same behavior on main using the same saved chat; this PR does not change it.
Linked Issue
Part of the native-chat send lifecycle work. Not a GitHub issue. Tracked in STA-11036 (a delivered queued message sent twice); see the STA-11036 paragraph above.
Visual Proof
The current head is
ef47118d3bc3693423ab185726da758a0a350d6d, after the latest main merge. All 44 CI checks finished (27 successful, 17 skipped); the bounded source review found no new proven merge regression, and four named lifecycle files passed all 25 tests. Exact-head real-agent QA passed Claude ordinary queue/drain, Stop with actual Resume and normal close/reopen, plus Codex Stop with actual Resume and normal close/reopen. The owner's final M4Air takeover also passed Codex ordinary queue/drain, image A removal and B replacement with edited text, and three cards waiting together then draining naturally in order. Codex's own saved record confirms the edited text and byte-identical B, no A or original text, and one reply each: “Blue, with a white letter B.”, “Q2-OK”, “Q3-OK”. The app was stopped by its recorded PID, admission1488 is done, and the owner's real-config hashes match. Current-head screenshots and the full results are in the single review status comment.Earlier failed driver/setup attempts are preserved separately and never counted as passes: ticket1381 ordinary-Codex method, ticket1439 unavailable attachment method, ticket1475 preparation parse error, and the loop's initial ticket1488 dev app exit. The owner traced that exit to the dev parent watchdog and corrected the rig for the successful takeover. Stale Settings copy about immediate image sends predates this PR and is owned by the B1 recovery follow-up; no current-head copy fix is claimed.
The upgrade and phone evidence below belongs to the earlier
293bb8254496head. Those unchanged flows were excluded from the latest bounded rerun by the lane owner; the screenshots retain their original head labels. Grok remains covered by tests only under Brennan’s usage waiver. The queue is feature gated in shipped builds; the app tests use only the approved test capability advertisement and read-only store exposure.Earlier completed review and QA (
293bb8254496)CI was green on earlier head
293bb82544967f097081040cb21d7d55ce17636c, including the WSL retry; GitHub reports no merge conflicts. Main is merged, 19 targeted files passed (347 tests), and the final source/readiness review found no new proven regression with the inherited and temporary differences recorded above. Grok was covered by tests only: three named shared adapter/lifecycle files passed (53 tests) under Brennan's usage waiver.Desktop QA on this head carried genuine Claude and Codex chats from the previous
e9bfdafc1dddbuild through an actual restart/upgrade. Both reopened through Session History and produced two new real replies each. Both completed ordinary queue/drain with one delivery and reply. Codex also completed queued image replacement and text editing: Save delivered the exact blue replacement PNG and edited text, followed by the realBLUE_ONLY_1168reply. These were fresh builds with the approved test-only queue capability advertisement and read-only store exposure; queue availability is feature gated in the shipped build.The remaining desktop checks passed under M4Air admission1227 on this same head. Three cards waited together during a real Codex turn and drained in order, with one host submission, accepted dispatch, native input and real reply for each. A separate running turn was stopped with a card queued: it stayed Paused with no delivery during the bounded observation, then the actual Resume control delivered it once and produced one real reply. The earlier incomplete attempts remain recorded separately. Both desktop rigs are stopped and their profiles/evidence preserved.
One additional observation: the native sleeping command remained live after Stop while the queue correctly stayed paused. This run establishes queue pause and delivery behavior; it does not establish that Stop terminated the command, or that this observation is a regression. Final-head native iOS phone QA also passed: one actual mobile Send showed one queued card, drained normally to one real Codex reply, and stayed correct after workspace re-entry. Host journal and independent provider receipts each confirm exactly one delivery and reply. The first harness-only attempt sent no mobile message and remains incomplete; one diagnosed, approved correction produced the accepted evidence. The final review is complete on this head. The failed-import history publication repair remains a separate follow-up tracked in STA-11608.
Earlier-head desktop evidence (
293bb8254496, ticket1168)Both saved chats after upgrade, with the previous reply and two new real replies:
Ordinary queue/drain completed with Claude; the image flow below also shows Codex's completed ordinary queued reply:
Codex queued image/text before editing, the blue replacement in the editor, and the real reply after Save:
The running turn ended while the editor was open, so Save drained immediately; no saved card still waiting was captured. Retained journal and provider records confirm one delivery of the edited text and exact replacement PNG bytes.
Earlier-head desktop FIFO and Stop/Resume (
293bb8254496, ticket1227)Three cards waited together, then each produced one real reply in order:
Stop kept the queued card paused; the actual Resume control delivered it once and produced one real reply:
Pre-merge desktop evidence (
e9bfdafc1ddd)Image edit and actual delivered replacement
Stop holds the queue; Resume sends each card once
Old chats after restart: two real replies each
Three queued messages, in order, once each
Inherited stopped-text carry reproduced on merged main
Earlier-head native iOS phone evidence (
293bb8254496, ticket1169)The actual paired iOS app sent one message while a real Codex turn ran. One queued card drained normally to one real reply; reopening the workspace kept the message and reply without reviving the card.
The invalid older QA host remains visible beside the fresh connected host in the pairing screenshot. The test used the fresh host and a new chat throughout. This is ordinary iOS Codex coverage; Android, mobile images/editing/FIFO/Stop/Resume/restart/upgrade and the failed-import retained-history follow-up were not repeated on phone.
Pre-merge native iOS phone evidence (
e9bfdafc1ddd)Phone coverage is this ordinary Codex flow only; Android, images, multi-card FIFO, editing, Stop/Resume, restart and upgrade were not repeated on phone.
Earlier-head evidence
The evidence below is from earlier reviewed heads, ending at e9513f8. The desktop results above are from e9bfdaf; the older screenshots below do not certify this head.
Real Electron QA on a separate Mac, with the real Codex and Claude Code CLIs (both builds used the same local switch that turns on mid-turn queuing, which is hidden in shipped builds). Every flow matched main: queuing and draining, Edit, Delete, Steer, Stop and Resume, restart, /compact, a refused card, and the upgrade. The Stop-after-hand-over change could not be shown live: both agents confirm a handed-over message within milliseconds, so a Stop clicked from the UI always lands after the confirmation, on main and on this branch alike. That case is covered by the automated tests. A final smoke run on Windows at the last head (real Codex and Claude) passed all eight flows, including a Stop 46 ms after hand-over (the message stays in the conversation and is never resent) and a Stop while the agent was still starting up (the card waits again).
Upgrade: a profile made by a main build, then opened by this branch
Stop right after a queued message is handed over (Codex)
A refused queued message (failed start), then Send
Testing
structured-agent-session-queued-stop-row.test.ts, a card handed over and stopped before the agent confirms it:structured-agent-session-stop-aborts-start.test.ts: a queued card stopped before the agent call, or while the agent prepares it, waits again under the Stop.claude-structured-message-options.test.ts: a Stop while Claude applies a message's model choice is a stop, not a refusal; a real refusal still is one.structured-agent-session-claude-queued-stop.test.ts: a card sent into a running Claude turn, which Claude reports cancelled unrun, comes back paused and is not sent twice.journal-dispatch-settlement.test.ts: the one rule. A Stop puts a card back to waiting only with proof the agent never got it; a restart or close before hand-over puts it back to waiting; a failure returns the card.structured-agent-session-queued-legacy-import.test.ts:structured-agent-session-queued-refused-card.test.ts, the refused card through the host: it holds the cards behind it through a rewind, a history rollover, a restart and a Resume; its Send is refused again and still holds; Delete releases it and the next card sends.Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (CI will cover)Author: @BrennanKB5