You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve terminal exit queries across snapshot restore - #34723
Ctrl+C could leave Codex waiting for two seconds and allow a late terminal reply to spill into the shell. A live device-attributes query could disappear when a snapshot replaced queued output. Preserve that query and answer it once, in order.
What Changed
Recover snapshot-covered primary-device queries in the renderer through the existing configured reply handler after the terminal parse barrier. Preserve pending parser tails and suppress duplicate or retired-stream replies.
Keep server-owned stateless query debt when initial or requested multiplex snapshots cover pending output. Replay only owed occurrences, retain existing capability and mobile ownership rules, and settle debt only when output is actually sent. Use existing stream frames and bounded query inventory.
Why
Snapshots contain terminal cells but omit live query commands. A sequence cutoff previously discarded both the covered display bytes and the unanswered query. Replying before earlier terminal reports or injecting queries into an incomplete parser command would also be unsafe; the fix preserves ordering and parser state.
Linked Issue
Supplied remote-terminal report: slow Ctrl+C exit and terminal characters left afterward.
Visual Proof
Before: real paired terminal, Ctrl+C during an in-flight restore, snapshot covers the live query. No reply arrives; the raw fixture times out after 2002 ms.
After: identical controlled race receives the configured device-attributes reply in 42 ms total, approximately 23 ms after the test releases the snapshot. Restore generation stays unchanged and shell input still works.
Real Codex 0.165.0 also exited to a clean shell and accepted a subsequent command. This is behavior evidence, not a measured latency result for the real CLI.
Testing
Independent review: 62 tests across seven focused suites passed, plus three real-xterm parser-state cases.
Red/green renderer and server regressions cover FIFO replies, split queries, duplicate ranges, stream retirement, CSI/OSC/DCS tails, configured ConPTY/Sixel replies, output ACK/pause recovery, and bounded replay occurrences.
Separate hidden Electron verifier exercised actual paired transport before/after, then clean shell input. Exact production files match the reviewed candidate.
Final-head CI: all 55 reported checks settled successfully, including Ubuntu, Debian, and Fedora WSL.
Required local ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: 26/27 checks passed. The unit check had 545 passing suites and 7,264 passing tests; three cross-version suites timed out during shared release-source preparation. All three failed suites passed in the isolated retry: 55/55 tests with ORCA_DISABLE_SHARED_RELEASE_CACHE=1 and one worker. The initial failure log is retained.
Review
Work stays proportional to covered output, with the existing buffer caps, 4096-character scanner carry, and 16-entry yielded-query ledger. No new polling, timers, subprocesses, protocol opcodes, or resource owners. Snapshot-covered cursor-position queries remain suppressed. Folder workspaces and mobile reply ownership retain existing behavior.
Agent skill upstream boundary
No upstream skill-installer source was copied.
Notes
Runtime proof used macOS paired loopback. Native Windows/WSL/Linux and physical mobile were not exercised locally. Existing pending-output overflow and a snapshot retrieval that itself exceeds the CLI timeout are outside this retained-query fix. Targets main after #34721 was merged. The original parent commit includes that already-merged one-line test-import repair.
Checklist
Focused fix with independent review and before/after evidence.
Compatibility, ordering, cleanup, and performance reviewed.
Required local affected checks, scoped retry, and final-head CI complete.
The change adds DA1 query replay for multiplex snapshots and DA1 query handling during hidden-output restoration. Multiplex streams track yielded queries when output is discarded, replay matching queries covered by snapshots, and settle replayed queries after delivery. Hidden-output restoration scans covered output and schedules replies after terminal parsing. Startup and renderer handling use shared DA1 query sequences.
Priority: Normal
Merge Risk: Low · previous review 77ab4
Replay tests can pass on output the viewer discards, leaving a regression undetected. Correct the cutoff before relying on those tests.
Pre-merge checks: 3 · 2
Failed checks: 2 warnings
Check name
Status
Explanation
Resolution
Description check
The description is detailed and covers the required change, rationale, testing, visual proof, compatibility notes, and checklist. However, the Linked Issue section provides only a report description a…
Add the actual linked issue reference in the required format, such as Fixes #34722, or provide the applicable pre-existing issue number.
Docstring Coverage
Docstring coverage is 30.00% 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 checks: 3 passed
Check name
Status
Explanation
Title check
The title clearly identifies the main change: preserving terminal exit queries during snapshot restoration.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description is detailed and covers the required change, rationale, testing, visual proof, compatibility notes, and checklist. However, the Linked Issue section provides only a report description and does not include an actual issue reference.
Resolution
Add the actual linked issue reference in the required format, such as Fixes #34722, or provide the applicable pre-existing issue number.
Full details: Docstring Coverage
Explanation
Docstring coverage is 30.00% 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 10 functions across 16 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Supported by static analysis
Script executed:
set -eu
printf'%s\n''--- yielded-query replay module ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-yielded-queries.ts | sed -n '1,180p'printf'%s\n''--- replay and snapshot helpers/callers ---'
rg -n -F --glob '*.ts' -e 'replaySnapshotCoveredStatelessQueries' -e 'getOutputAfterSnapshotSeq' -e 'serializeBudgetedRequestedSnapshot' -e 'sendAckRecoverySnapshot' -e 'ackPendingOutputOverflowed' -e 'queueOrSendOutput' -- src/main/runtime/rpc/methods/terminal src/main/runtime/rpc | head -200
printf'%s\n''--- snapshot/replay caller definitions ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-stream-replay.ts | sed -n '1,180p'printf'%s\n''--- flow control ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-flow-control.ts | sed -n '1,180p'printf'%s\n''--- frame delivery ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-frame-delivery.ts | sed -n '1,180p'printf'%s\n''--- pause and cleanup ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-slot-frames.ts | sed -n '60,125p'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-cleanup.ts | sed -n '1,55p'
Repository: stablyai/orca
Length of output: 44318
Script executed:
set -eu
printf'%s\n''--- slot-frame snapshot branch ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-slot-frames.ts | sed -n '145,275p'printf'%s\n''--- initial snapshot branch ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-initial-snapshot.ts | sed -n '90,155p'printf'%s\n''--- yielded-query registration callers ---'
rg -n -F --glob '*.ts' -e 'recordYieldedTerminalQueries' -e 'yieldedQueryScan' -e 'outputBatcher' -- src/main/runtime/rpc/methods/terminal | head -160
printf'%s\n''--- stream initialization and output ingestion ---'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-stream-initialization.ts | sed -n '1,120p'
nl -ba src/main/runtime/rpc/methods/terminal/terminal-multiplex-output.ts 2>/dev/null | sed -n '1,220p'||true
Repository: stablyai/orca
Length of output: 19765
Preserve covered query debt across ACK recovery.
sendRequestedSnapshot replays covered queries before it queues the remaining live output. Under ACK backpressure, the replay chunk can enter ackPendingOutput first and then be removed by byte-budget trimming. Recovery sends the snapshot but does not replay or answer the query.
A retained numeric live chunk can then call settleDeliveredYieldedQueries(stream, chunk.seq). That removes the covered query because its sequence is below the live chunk, although the renderer never received the replay and main never called runtime.answerYieldedTerminalQueries. Track the recovery snapshot boundary and preserve covered query debt until the matching replay is sent or the debt is handed to answerUndeliveredYieldedQueries.
Route replayed query output through the replay-guarded path.
When a covered DA1 matches the sole owner’s yielded query, replaySnapshotCoveredStatelessQueries queues it as ordinary Output. The renderer then parses it through writePtyOutputToXterm, so isReplaying() is false. The covered numeric chunk separately schedules answerSnapshotCoveredPrimaryDeviceAttributes() after its parse barrier. Both paths can send a reply for the same query.
Route only the synthetic replay frame through the existing replay-specific path, such as replayDataCallback/replayIntoTerminal. Preserve the covered-source reply.
…ed replays
- Mark yielded queries discarded when ACK overflow trimming, the recovery
cutoff, or snapshot-buffer overflow drops their output unsent, and replay
them after the covering snapshot (including the ACK recovery snapshot).
- Purge snapshot query replays and escape-tail frames still queued behind the
ACK window when a newer snapshot is published, and put new replays at the
head of the ACK queue so they follow their snapshot.
- Share isPrimaryDeviceAttributesQuerySequence across DA1 call sites.
- Move replayed-query settlement into settleReplayedYieldedQuery.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
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 reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Use the latest snapshot sequence as the default cutoff.
Several replay tests call outputAfterLastSnapshot() without an argument. With a cutoff of zero, the helper counts a sequence-tagged DA1 query even when the latest snapshot covers it and the viewer drops it. Those tests can pass without a usable replay. Read the latest SnapshotStart payload’s seq by default; keep the explicit cutoff for the batched-query test. (raw.githubusercontent.com)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Ctrl+C could leave Codex waiting for two seconds and allow a late terminal reply to spill into the shell. A live device-attributes query could disappear when a snapshot replaced queued output. Preserve that query and answer it once, in order.
What Changed
Recover snapshot-covered primary-device queries in the renderer through the existing configured reply handler after the terminal parse barrier. Preserve pending parser tails and suppress duplicate or retired-stream replies.
Keep server-owned stateless query debt when initial or requested multiplex snapshots cover pending output. Replay only owed occurrences, retain existing capability and mobile ownership rules, and settle debt only when output is actually sent. Use existing stream frames and bounded query inventory.
Why
Snapshots contain terminal cells but omit live query commands. A sequence cutoff previously discarded both the covered display bytes and the unanswered query. Replying before earlier terminal reports or injecting queries into an incomplete parser command would also be unsafe; the fix preserves ordering and parser state.
Linked Issue
Supplied remote-terminal report: slow Ctrl+C exit and terminal characters left afterward.
Visual Proof
Before: real paired terminal, Ctrl+C during an in-flight restore, snapshot covers the live query. No reply arrives; the raw fixture times out after 2002 ms.
After: identical controlled race receives the configured device-attributes reply in 42 ms total, approximately 23 ms after the test releases the snapshot. Restore generation stays unchanged and shell input still works.
Real Codex 0.165.0 also exited to a clean shell and accepted a subsequent command. This is behavior evidence, not a measured latency result for the real CLI.
Testing
ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: 26/27 checks passed. The unit check had 545 passing suites and 7,264 passing tests; three cross-version suites timed out during shared release-source preparation. All three failed suites passed in the isolated retry: 55/55 tests withORCA_DISABLE_SHARED_RELEASE_CACHE=1and one worker. The initial failure log is retained.Review
Work stays proportional to covered output, with the existing buffer caps, 4096-character scanner carry, and 16-entry yielded-query ledger. No new polling, timers, subprocesses, protocol opcodes, or resource owners. Snapshot-covered cursor-position queries remain suppressed. Folder workspaces and mobile reply ownership retain existing behavior.
Agent skill upstream boundary
Notes
Runtime proof used macOS paired loopback. Native Windows/WSL/Linux and physical mobile were not exercised locally. Existing pending-output overflow and a snapshot retrieval that itself exceeds the CLI timeout are outside this retained-query fix. Targets
mainafter #34721 was merged. The original parent commit includes that already-merged one-line test-import repair.Checklist