Skip to content

Preserve queued command and card order through recovery - #36430

Merged
brennanb2025 merged 33 commits into
mainfrom
brennanb2025/queue-switch-on-flip
Oct 31, 2026
Merged

brennanb2025 merged 33 commits into
mainfrom
brennanb2025/queue-switch-on-flip

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4190 $\color{#cf222e}{\Huge{\mathbf{−}}}$​90 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4100
Prod 55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2636 $\color{#cf222e}{\Huge{\mathbf{−}}}$​287 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2349

Problem

A later send can run ahead of a waiting /compact when its client has an old queue snapshot. Stop, restart and history replacement can also expose gaps in how waiting cards retain their order and original delivery identity. The stale-client case is tracked in STA-13076.

What changes for users

This follows the queue controls shipped in #36588. This PR keeps waiting commands and their earlier messages ahead of later sends, including a direct steer from a client that has not seen the command yet.

Editing or removing an earlier card does not let a later input jump the work already running. Delivery, Stop, restart, rewind and history replacement preserve each message's identity, original receipt and required queue order. A send whose outcome is uncertain is not automatically repeated. Stop keeps its existing cancellation and preparation behavior.

How it works

The host chooses the next input from the current saved queue before handing it to the agent. Each input retains its own place and source evidence; recovery preserves the earlier work it still owes while respecting cards the user moved. History replacement carries those relationships and original acceptance receipts into the new history. Current card state controls whether delivery may proceed. No new saved send mode or Stop state is added.

Dependency and compatibility

#36588 is merged into main. This follow-up keeps its queue controls and default.

The switch advertises agent-session.queued-messages.v2; older paired hosts retain their existing launch and send paths, with no minimum host version. The current older-phone adapter remains unchanged; the deferred choice below remains separate from this ordering fix.

Differences from the common pattern

The control/default and phone labels below carry forward the approved behavior already shipped in #36588; this follow-up changes ordering and recovery.

  • Intended: queueing defaults on and users can turn it off, as requested. With it off, the alternate shortcut queues one message.
  • Intended: waiting commands retain their earlier-message order across stale clients, card removal and recovery. A direct steer cannot bypass a merely waiting command.
  • Intended: the existing Stop order and preparation commitment remain unchanged, including cancellation, unknown delivery and the next send's context.
  • Intended: idle cards read Send and working cards read Steer, retaining the approved wording for entry into a running turn.
  • Temporary: older-phone behavior while a command is waiting remains as-is. Brennan decides A/B/C after the queue lands, tracked in STA-13042.
  • Temporary: the phone follows the host's Queue/Steer setting; a phone-only preference (as the common pattern has) is listed for a product decision, tracked in STA-13101.

Verification

Reviewed head: 89feff1f29e584d053bf85f5034da688b75c70c2. Main is merged, the PR is out of draft, and all executed head checks passed: 35 successful checks and 17 skipped. All twelve unit shards, static analysis/typecheck, both package jobs and wire compatibility passed. Skipped checks are not execution evidence.

Production fixtures cover stale-client command order, original IDs and acceptance receipts, attachments, Stop/uncertain outcomes, replacement/reopen, conversion and rollback. Performance contracts bound operations on larger corpora; they do not claim whole-app latency. The final two-file test-contract repair passed all 29 tests without changing production.

Previous-build state was carried through graceful upgrade and normal delivery with real Claude and Codex. Both completed queued compact before later text, Stop/header Resume, edit/explicit Send, idle Rewind with a context-aware reply, and terminal-history adoption with a real continuation. Saved IDs/order and known history survived; named replies arrived once. Full-window screenshots are in the review status comment.

Draft survival remains unverified because the QA renderer origin changed; the old draft bytes are preserved. Rewind with waiting cards remains disabled by unchanged main code; the app run covered the supported idle action, while production fixtures cover retained-cohort replacement. Existing restart pause labels and explicit-send release behavior are unchanged.

Claude compact completed before the queued reply

The exact held-arrow browser case was run once on this head in the admitted QA checkout with required mobile dependencies: 1 passed, 9 filtered out. The historical main-path failure did not reproduce; its cause remains unknown. No delay, tolerance or timing repair was added. Historical failed job.

A historical agent-failure checkpoint observed zero callbacks where it expected one. Its cause remains unknown and the observation is unrefuted. One bounded source investigation/probe did not establish a PR-caused user-visible defect; its passing checkpoints do not explain the historical failure. Historical failed job.

The Windows compiler-parity check initially timed out without output. One failed-only retry on the same source passed all twenty parity entries with unchanged deadlines and checks; the original timeout cause remains unknown. Successful retry.

The unchanged optimistic-reorder shortcut can send the former head during a queue preview. This separate main bug is tracked in STA-13165; it is not repaired here.

Released clients read the v1 name with an unfinished queue UI; they never
see v2 and keep sending immediately.
The follow-up choice is now a Queue / Steer setting saved under
nativeChatFollowUpBehavior, Steer by default; the old
nativeChatQueueFollowUps switch, which every install saved as true
while queueing was dark, is retired on load. Every reader goes through
native-chat-follow-up-behavior.

While the agent works, Enter follows the setting and Cmd/Ctrl+Enter
sends the draft the other way; the alternate flips the setting before
the queue's own rules (a waiting command still queues, prompts no one
here can answer still send now) and never applies while Stopping.
Cmd/Ctrl+Shift+Enter steers the head card only and leaves the draft.
An idle agent's card reads Send, and the card menu no longer offers
"Turn off queueing".
While the agent works on a host that queues, holding Send opens a
Queue / Steer sheet; a choice other than the host's setting sends the
alternate, resolved against the chat as it is when it lands, by the
desktop's rule. Release and dismiss send nothing. The phone reads the
host's new follow-up setting (absent reads as Steer), and an idle
agent's card reads Send.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 30, 2026 19:57
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4affcd97-d640-4f87-8056-023d2cef2233
Commits

Reviewing files that changed from the base of the PR and between 254f751 and ae2aa89.

Files selected for processing: 5
  • mobile/src/session/mobile-follow-up-preference.test.tsx
  • src/renderer/src/components/native-chat/NativeChatInterruptedContinue.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test-harness.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx
  • src/renderer/src/hooks/ipc-events/runtime-client-ipc-bridge.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.

Walkthrough

The change replaces the queue-follow-ups boolean with a Queue or Steer preference, defaults it to Steer, and distributes preference updates through runtime settings and client events. Desktop and mobile composers can select the alternate send behavior. Desktop keyboard shortcuts and queued-message controls now steer the eligible head card. The queued-messages runtime capability advances to v2. Tests and translations are updated across both clients.

Merge Risk: Low · up to ae2aa

Briefly after reordering, the head-steering shortcut may send a different queued message than the one displayed first. Merge with this limitation noted.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly describes the pull request’s main change: preserving queued command and card order during recovery.
Description check Passed The description is detailed, relevant, and covers the problem, user-visible changes, implementation approach, compatibility, linked issues, visual proof, testing, known limitations, and historical che…
Full details: Description check

Explanation

The description is detailed, relevant, and covers the problem, user-visible changes, implementation approach, compatibility, linked issues, visual proof, testing, known limitations, and historical check results. It does not reproduce every template heading or checklist item, but the required information is mostly present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 23.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 38 functions across 83 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ce198e8-d24f-437b-ba4b-efec20f458d0
Commits

Reviewing files that changed from the base of the PR and between f06399f and 8e1438b.

Files selected for processing: 97
  • mobile/src/components/composer-input/ComposerSendButton.tsx
  • mobile/src/i18n/locales/de.json
  • mobile/src/i18n/locales/en.json
  • mobile/src/i18n/locales/es.json
  • mobile/src/i18n/locales/fr.json
  • mobile/src/i18n/locales/ja.json
  • mobile/src/i18n/locales/ko.json
  • mobile/src/i18n/locales/pt.json
  • mobile/src/i18n/locales/ru.json
  • mobile/src/i18n/locales/tr.json
  • mobile/src/i18n/locales/zh-Hant.json
  • mobile/src/i18n/locales/zh.json
  • mobile/src/session/MobileNativeChatOverlay.tsx
  • mobile/src/session/MobileNativeChatView.tsx
  • mobile/src/session/MobileQueuedMessageCardRow.tsx
  • mobile/src/session/mobile-native-chat-controller-contract.ts
  • mobile/src/session/mobile-structured-agent-session-contract.ts
  • mobile/src/session/mobile-structured-agent-session-send.ts
  • mobile/src/session/native-chat/composer/MobileNativeChatComposer.structured.test.ts
  • mobile/src/session/native-chat/composer/MobileNativeChatComposer.tsx
  • mobile/src/session/native-chat/composer/MobileNativeChatSendButton.tsx
  • mobile/src/session/native-chat/composer/mobile-native-chat-draft-inputs.ts
  • mobile/src/session/native-chat/composer/use-mobile-native-chat-composer-tray.ts
  • mobile/src/session/native-chat/composer/use-mobile-native-chat-image-attachments.ts
  • mobile/src/session/native-chat/input/MobileNativeChatQueuedMessages.tsx
  • mobile/src/session/native-chat/mobile-native-chat-send.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • mobile/src/session/use-mobile-native-chat-queue-follow-ups.ts
  • mobile/src/session/use-mobile-session-image-attachments.ts
  • mobile/src/session/use-mobile-structured-agent-session-queued.test.tsx
  • mobile/src/session/use-mobile-structured-agent-session.ts
  • mobile/src/session/use-mobile-structured-native-chat-send-bridge.ts
  • mobile/src/session/use-mobile-structured-send-with-outcome.ts
  • mobile/src/session/use-mobile-structured-turn-indicator.ts
  • mobile/src/transport/settings-read-operations.ts
  • src/main/persistence/applying-settings/persistence-settings-ui-defaults.test.ts
  • src/main/persistence/applying-settings/terminal-settings-migrations.ts
  • src/main/runtime/rpc/methods/structured-agent-session-queued-edit.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-queued-methods.ts
  • src/main/runtime/runtime-client-settings-shape.ts
  • src/main/runtime/runtime-client-settings.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/main/runtime/structured-agent-session-codex-turn-end-settlement.test.ts
  • src/renderer/src/components/native-chat/NativeChatAgentMessageRow.test.tsx
  • src/renderer/src/components/native-chat/NativeChatComposerPane.tsx
  • src/renderer/src/components/native-chat/NativeChatQueuedMessageCard.tsx
  • src/renderer/src/components/native-chat/NativeChatQueuedMessageComposer.raw-task.test.tsx
  • src/renderer/src/components/native-chat/NativeChatQueuedMessageList.arrival.test.tsx
  • src/renderer/src/components/native-chat/NativeChatQueuedMessageList.inline-edit.test.tsx
  • src/renderer/src/components/native-chat/NativeChatQueuedMessageList.test.tsx
  • src/renderer/src/components/native-chat/NativeChatQueuedMessageList.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.stopping.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test-harness.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.test.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/native-chat-composer-types.ts
  • src/renderer/src/components/native-chat/native-chat-structured-composer-dispatch.ts
  • src/renderer/src/components/native-chat/native-chat-structured-stop-controls.ts
  • src/renderer/src/components/native-chat/native-chat-submission-navigation.test.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-queue-request.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-queue-request.ts
  • src/renderer/src/components/native-chat/structured-agent-session-send-slot.ts
  • src/renderer/src/components/native-chat/structured-agent-session-view-contract.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-edit-session.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.steer.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-keydown.ts
  • src/renderer/src/components/native-chat/use-native-chat-composer-submit.ts
  • src/renderer/src/components/native-chat/use-native-chat-structured-composer-send.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-sends.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session.queued-gating.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session.ts
  • src/renderer/src/components/native-chat/use-structured-native-chat-submit-reveal.test.ts
  • src/renderer/src/components/native-chat/use-structured-native-chat-submit-reveal.ts
  • src/renderer/src/components/settings/ChatBehaviorSetting.test.tsx
  • src/renderer/src/components/settings/ChatBehaviorSetting.tsx
  • src/renderer/src/components/settings/chat-behavior-search.ts
  • src/renderer/src/i18n/locales/de.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/pt.json
  • src/renderer/src/i18n/locales/ru.json
  • src/renderer/src/i18n/locales/tr.json
  • src/renderer/src/i18n/locales/zh-Hant.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-session-runtime-capabilities.ts
  • src/shared/agent-session-wire.ts
  • src/shared/default-global-settings.ts
  • src/shared/global-settings-types.ts
  • src/shared/native-chat-follow-up-behavior.ts
  • src/shared/rpc-contract/structured-agent-session-params.ts
  • src/shared/structured-agent-session-queued-cards.test.ts
  • src/shared/structured-agent-session-queued-cards.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.

@brennanb2025 brennanb2025 changed the title Native chat: queue a message while the agent works (Cmd/Ctrl+Enter or hold Send); Enter still steers by default Turn on native chat queueing by default Oct 30, 2026
@brennanb2025 brennanb2025 changed the title Turn on native chat queueing by default Preserve queued command and card order through recovery Oct 31, 2026
@brennanb2025

brennanb2025 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

A client with an old queue snapshot could send past a waiting /compact and its earlier messages. This follow-up to merged #36588 keeps that work ahead of later sends, and retains original message identities and receipts through recovery and history replacement. Stop and uncertain-delivery behavior remain unchanged.

Reviewed and QA-tested head: 89feff1f29e584d053bf85f5034da688b75c70c2. Six review rounds concluded with the selected design retained; the final test-only repairs are independently accepted. Main is merged, and there are no commits after the QA head. All executed head checks passed: 35 success, 17 skipped, including all twelve unit shards, static analysis/typecheck, both package jobs and wire compatibility. Skipped checks remain unexecuted.

The review repaired order/recovery ownership, complete-cohort restoration before cleanup, transactional rollback and original receipt handling. Production fixtures cover stale-direct command order, original body/options/images, Stop and uncertain outcomes, replacement/reopen, format conversion and failure rollback. Performance contracts measure bounded operations on larger corpora, not whole-app latency. The final two-file repair ran all 29 tests successfully without changing production. The final common-pattern comparison and readiness source review carry across those test-only commits.

Real Claude and Codex runs used previous-build saved conversations and terminal histories, then the normal UI through actual replies. Saved card IDs/order and known history carried; edited and explicit sends delivered the selected text once. Both agents completed queued /compact before later text, Stop/header Resume, supported idle Rewind and context-aware continuation, and Session History → Resume in New Chat → real continuation. The initial Claude compact was refused because its task went into the background; a targeted foreground-task completion then succeeded. Claude's header Resume was also completed separately. These targeted completions did not rerun passed flows.

Limits and carried concerns:

  • Draft survival across upgrade is unverified: the QA renderer port changed, creating another browser origin. The old draft bytes remain preserved; this is not evidence of PR data loss.
  • Rewind with waiting cards is disabled by unchanged main code. The run exercised supported idle Rewind; retained-cohort replacement is fixture-covered. Restart's Paused→Queued label and explicit-send release of the remaining cards are unchanged main behavior; no unsolicited resend was observed before release.
  • The historical failure-callback checkpoint observed zero callbacks. Its cause remains unknown and unrefuted; one bounded source/probe investigation established no PR-caused user-visible defect. Later passes do not explain it.
  • The exact held-arrow browser case ran once with required dependencies: 1 passed, 9 filtered. The historical main-path failure did not reproduce; its timing cause remains unknown. No patch, tolerance change or retry was used.
  • Windows compiler parity initially timed out silently; one failed-only retry on the same source passed all twenty original entries with unchanged deadlines/checks. Successful retry. The initial timeout cause remains unknown.
  • The unchanged optimistic-reorder shortcut bug is tracked separately in STA-13165; it is not repaired here.
  • Temporary: older-phone behavior while a command is waiting remains as-is; the product choice is tracked in STA-13042.
  • Temporary: the phone follows the host's Queue/Steer setting; a phone-only preference (as the common pattern has) is listed for a product decision, tracked in STA-13101.

For Brennan's review

Full-window screenshots from the admitted QA round follow. The prior build is pinned main 0d94c0ba8f6; the candidate is the head above. No new phone interaction or mobile/test diff remains relative to incoming main.

Recovery Prior build Candidate first paint
Claude claude before upgrade claude after upgrade
Codex codex before upgrade codex after upgrade
Completed action Claude Codex
Saved-card delivery and edit Claude Saved-card delivery and edit Codex Saved-card delivery and edit
Stop, edit and explicit Send Claude Stop, edit and explicit Send Codex Stop, edit and explicit Send
Rewind then real continuation Claude Rewind then real continuation Codex Rewind then real continuation
Terminal-history adoption then real continuation Claude Terminal-history adoption then real continuation Codex Terminal-history adoption then real continuation

Claude targeted compact completion (Codex compact result is visible in the Stop result above):

Claude compact before later queued reply

Claude header Resume: paused card Actual reply after Resume
Claude Paused before header Resume Claude actual reply after header Resume

Two places for human judgment:

Readiness tracking is resolved: the carried phone-only-preference deferral remains Temporary and is tracked in STA-13101.

@brennanb2025
brennanb2025 merged commit c64e1f6 into main Oct 31, 2026
52 of 53 checks passed
LuweiLiao added a commit to LuweiLiao/orca that referenced this pull request Oct 31, 2026
…ai#36430)

Adapt upstream input ordering to LLW journal rows, retaining input lineage on epoch replacement without migrating the log storage format.

(cherry picked from commit c64e1f6)
@brennanb2025
brennanb2025 deleted the brennanb2025/queue-switch-on-flip branch November 1, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant