Repository navigation
Fix Codex status after Ctrl+C copy and side-chat navigation - #24339
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (21)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes Ctrl+C intent filtering for Codex and Droid. It adds Codex transcript turn-state reconciliation and native-watcher-based polling. Server and relay paths use Codex-specific polling to propagate transcript status changes. Tests cover inference, transcript reconciliation, scheduling, and Codex interruption status. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The change makes Codex interruption status depend on recorded cancellation rather than Ctrl+C alone. No concrete merge-blocking risk is established; normal CI checks should complete before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves cancellation reporting, but completion and cancellation events can arrive in an order that hides a recorded interruption. No expanded external access or elevated permissions were demonstrated; transcript integrity and recovery behavior remain partially established. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/codex-ctrl-c-status.spec.ts (1)
37-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReplace the fixed 1,000 ms wait with a deterministic check.
waitForTimeout(1_000)passes if the inference timer is slow. It also adds a fixed delay on every run. This is a low-value flakiness risk, so you can defer it. Consider polling thatinterruptedstays at count 0 for a set window, for example withexpect.pollortoHaveCount(0)using a timeout. The fixed wait is still acceptable when the goal is to outlast the 500 ms settle timer.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f5f7c343-3436-4d0d-8899-27a76a56e760
📒 Files selected for processing (8)
src/main/agent-hooks/server-codex-ctrl-c-inference.test.tssrc/main/agent-hooks/server/server-status-inference.tssrc/renderer/src/components/terminal-pane/agent-interrupt-inference.test.tssrc/renderer/src/components/terminal-pane/agent-interrupt-inference.tssrc/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.test.tssrc/renderer/src/components/terminal-pane/pty-connection-interrupt-inference.test.tssrc/shared/agent-interrupt-intent.tstests/e2e/codex-ctrl-c-status.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
There was a problem hiding this comment.
Important
The change is sound and well-tested for the paths it touches, but it breaks two existing tests that this PR does not update — CI will be red until they are retargeted.
Reviewed changes
- Shared
shouldIgnoreInterruptIntentguard — new predicate insrc/shared/agent-interrupt-intent.tsthat suppresses Ctrl+C interrupt inference forcodexin addition to the existingdroid, consumed by both the renderer and the host. - Renderer inference —
agent-interrupt-inference.tsdeletes its local droid-only helper and calls the shared guard; Codex Ctrl+C now clears the pending baseline instead of arming the 500 ms settle timer. - Host inference —
server-status-inference.tsreplaces its inline droid check with the shared guard, so a direct or older-client request is refused on the host too. - Tests — new host unit test, new e2e spec, plus parameterized renderer tests and fixture flips from
codextocustom-agentto keep the non-ignored interrupt paths covered.
⚠️ Two existing Codex cancel-verdict tests fail after this change
src/main/agent-hooks/server-main-agent-turn-verdicts.test.ts is not in this diff, but its helper inferCtrlC('codex') asserts inferInterrupt(...) returns true, and two cases depend on it: "keeps an inferred Codex cancellation across a late root Stop" and its relayed variant. With the new guard, inferInterrupt returns false and both fail. pnpm test src/main/agent-hooks reports 2 failed | 1104 passed, so the focused run quoted in the PR description did not include this suite.
Technical details
# Retarget the Codex cancel-verdict tests
## Affected sites
- `src/main/agent-hooks/server-main-agent-turn-verdicts.test.ts:47-59` — `inferCtrlC(agentType: 'codex')` hard-expects `inferInterrupt({ intent: 'ctrl-c' }) === true`.
- `...:103` ("keeps an inferred Codex cancellation across a late root Stop") and `...:137` (late relayed root Stop) call it; both now fail with `expected false to be true`.
- Root cause: `src/main/agent-hooks/server/server-status-inference.ts:46` now returns `false` for Codex Ctrl+C before the verdict/clock logic the tests target.
## Required outcome
- The scenarios these two tests cover — an inferred Codex cancellation survives a late root `Stop` and a late relayed `Stop`, kept as `mainAgent.outcome: 'cancellation'` and `interrupted` — must still be exercised. That machinery is still reachable for Codex via plain Escape.
## Suggested approach
- Change `inferCtrlC`'s `intent` to `'plain-escape'` (or rename it, e.g. `inferEscape`) so the tests keep driving the cancel-verdict path with an intent Codex still infers. Verify with `pnpm test src/main/agent-hooks/server-main-agent-turn-verdicts.test.ts`.
## Open questions for the human
- The behavior change assumes Codex emits a terminal provider hook when a running turn is cancelled by Ctrl+C; otherwise the row stays "working" indefinitely. The unchecked manual live check and the e2e (which only simulates a `Stop`) do not establish that. Worth confirming against the live CLI before merge.ℹ️ Stale Codex Ctrl+C description in the status-store reference
docs/reference/agent-status-store.md (around lines 316-327) still describes Orca's Ctrl+C inference as applying to Codex — "Codex also keeps the child-evidence guard" — and cites the live-measured Codex 0.156.1 Ctrl+C behavior. After this PR Orca infers nothing from a Codex Ctrl+C, so that paragraph now describes behavior that no longer exists and should be updated in the same change.
Technical details
# Update the Ctrl+C inference paragraph for Codex
## Affected sites
- `docs/reference/agent-status-store.md:316-327` — states the inference is admitted for any row publishing `mainAgent` and that "Codex also keeps the child-evidence guard"; both claims are moot for Codex Ctrl+C now that `shouldIgnoreInterruptIntent` refuses it outright.
## Required outcome
- The doc reflects that Codex (and Droid) Ctrl+C is never inferred, while the cancel verdict still arrives via the provider hook.ℹ️ Nitpicks
- The new
shouldIgnoreInterruptIntentcomment cites only Codex; the rationale deleted fromserver-status-inference.ts— Droid's Ctrl+C exits the CLI and is handled by PTY lifecycle — is now lost. Consider keeping it next to the shared predicate or inline below.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| return intent === 'plain-escape' || intent === 'ctrl-c' | ||
| } | ||
|
|
||
| // Ctrl+C can copy text or leave a Codex side chat without cancelling the main turn. |
There was a problem hiding this comment.
This comment only explains the Codex rationale, but the predicate also now owns Droid's case. The deleted server-side comment documented that Droid's Ctrl+C exits the CLI (handled by the PTY lifecycle) rather than interrupting the turn — worth preserving that half here so the combined rule stays self-explanatory.
| if (!agentId && (eventName === 'UserPromptSubmit' || eventName === 'SessionStart')) { | ||
| const transcript = state.codexSubagentTranscriptByPaneKey.get(paneKey) | ||
| if (transcript) { | ||
| transcript.rootTurn.interrupted = false |
There was a problem hiding this comment.
If a new UserPromptSubmit arrives before the previous turn’s abort record is written, this clears interrupted but keeps the previous turn ID. The next poll can treat that late abort as cancellation of the new turn and show Interrupted while it is working. With no tracked children, polling then stops, so a later start record cannot correct the status. Reset or advance the transcript turn identity at the prompt boundary.
Knowledge Base Used: Agent integrations and hooks
There was a problem hiding this comment.
ℹ️ No critical issues — two minor observations inline.
Reviewed changes
This run re-reviewed the commit that replaced Ctrl+C inference with host-side confirmation from Codex's rollout records.
- Host-confirmed cancellation — new
codex-turn-transcript.tsreconciles Codex root-turn boundaries (task_started/turn_started,turn_abortedwithreason=interrupted,task_complete/turn_complete) into a per-panerootTurn, andcodex-transcript-poll.tsmarks the leaddone/cancellationwhen that flag is set and the lead is still running. - Poll path —
shouldPollHookTranscript/transcriptPollUpdatenow also poll a running Codex turn's parent rollout and publish lead-state changes; the server and relay retry schedulers callpollCodexTranscriptStatusfor Codex instead ofnormalizeHookPayload. - Remote path —
reconcileRemoteCodexStateapplies a relayedmainAgentwhen the event carries nohookEventName, so a remote host's confirmed cancellation reaches the desktop without it reading a remote path. - New-turn reset — a root
UserPromptSubmit/SessionStartclearsrootTurn.interrupted. - Tests — new host and relay interruption suites, a
codex-turn-transcriptunit test, and an extended e2e spec covering the confirmed-cancel, child-hold, and relay-forward paths.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| if ( | ||
| transcript.rootTurn.interrupted && | ||
| state.codexLeadStateByPaneKey.get(original.paneKey)?.state !== 'done' | ||
| ) { | ||
| markCodexLeadTurnInterrupted(state, original.paneKey) |
There was a problem hiding this comment.
This interrupt guard, together with shouldPollHookTranscript clearing the poll once the lead is done, means a cancellation already recorded in the rollout is discarded if a Stop hook is processed first. At Stop time normalizeCodexEvent has already reconciled the transcript and set rootTurn.interrupted, but the Stop branch writes a plain done without consulting it, so the poll is never armed and markCodexLeadTurnInterrupted never runs. If the Codex build you target emits Stop on Ctrl+C, the pane settles on a plain "done" rather than "Interrupted" — worth confirming against the live CLI before merge.
Technical details
# A recorded abort is discarded when a done verdict lands first
## Affected sites
- `src/shared/agent-hook-listener/providers/codex-transcript-poll.ts:21-26` — `markCodexLeadTurnInterrupted` runs only while the lead is not `done`.
- `src/shared/agent-hook-listener/transcript-poll-policy.ts:14-18` — once the lead is `done` and no transcript children remain, the poll is cleared and not re-armed.
- `src/shared/agent-hook-listener/providers/codex-events.ts:191-197,226-246` — `Stop` reconciles the root rollout (setting `rootTurn.interrupted`) but classifies a plain `done` without consulting it; `codexOutcomeRestatedByStop` preserves an outcome only when the previous lead was already `done`.
## Required outcome
- A cancellation recorded in the root rollout surfaces as `interrupted` regardless of whether a `Stop` hook or the transcript poll observes it first.
## Open questions for the human
- Does the targeted Codex build fire `Stop` on Ctrl+C? If it does, the `Stop`-first sequence is reachable and yields a plain "done"; if it only fires a distinct `Interrupt` event (not installed by Orca), the transcript poll is the sole path and this gap is unreachable. The unchecked live check would settle it.| turn.turnId = turnId | ||
| turn.interrupted = false | ||
| } else if (!turnId || !turn.turnId || turnId === turn.turnId) { | ||
| if (payload.type === 'turn_aborted' && payload.reason === 'interrupted') { |
There was a problem hiding this comment.
decodeCodexTurnLifecycle in src/main/native-chat/transcript-turn-lifecycle.ts treats every turn_aborted as interrupted and never reads reason, while this new parser requires reason === 'interrupted'. transcript-turn-markers.ts exists specifically so Codex's boundary consumers cannot disagree about which line is an abort; consider sharing the markers/reason policy here rather than re-deriving them.
Technical details
# Two Codex turn-boundary parsers now disagree on `turn_aborted`
## Affected sites
- `src/shared/codex-turn-transcript.ts:26` — sets `interrupted` only for `turn_aborted` with `reason === 'interrupted'`.
- `src/main/native-chat/transcript-turn-lifecycle.ts:55` (`decodeCodexTurnLifecycle`) — treats any `turn_aborted` as `interrupted` and never reads `reason`.
- `src/main/native-chat/transcript-turn-markers.ts:3-7` — states the markers live in one place so consumers "can never disagree".
## Required outcome
- One source of truth for Codex turn markers/reason handling, or at minimum an aligned reason policy so the chat lane and the status lane cannot render different verdicts for the same record.There was a problem hiding this comment.
ℹ️ No critical issues — one verification question inline.
Reviewed changes
This run re-reviewed the commit that keeps an ephemeral side-session hook from replacing the pane's recorded main Codex turn.
- Side-session filter —
normalizeCodexEventnow returnsnullfor a hook whosetranscript_pathis exactlynull, carries noagent_id, differs insession_idfrom the stored status, and arrives while a main transcript is already recorded, so/sidehooks cannot overwrite the main turn. - Tests — the host and relay interruption suites now post side-session
SessionStart/UserPromptSubmit/Stophooks and assert the main row is byte-identical and the relay does not forward them; the e2e spec posts a side-session hook and asserts the main prompt stays visible.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const currentSessionId = state.lastStatusByPaneKey.get(paneKey)?.providerSession?.id | ||
| // Ephemeral side chats share the pane but must not replace its recorded main turn. | ||
| if ( | ||
| hookPayload.transcript_path === null && |
There was a problem hiding this comment.
Two shapes of side-session hook look like they can slip past this filter, so worth confirming against a real /side interaction. It matches transcript_path === null exactly, so a side-session hook that omits the field rather than sending null would not be filtered; and the guard sits above the SessionStart reset at lines 174-178, so if a new main session's SessionStart also carries transcript_path: null with a new session_id, it would be dropped before that reset runs and the prior session's roster/transcript would stay in place. Are either payload shapes reachable for the Codex version you target?
Technical details
# Ephemeral-session discriminator breadth and ordering
## Affected sites
- `src/shared/agent-hook-listener/providers/codex-events.ts:156-165` — filter keyed on strict `hookPayload.transcript_path === null`, no `agent_id`, and a `session_id` differing from the stored `providerSession.id`.
- `src/shared/agent-hook-listener/providers/codex-events.ts:174-178` — the `SessionStart && !agentId` reset of `codexSubagentRosterByPaneKey` / `codexSubagentTranscriptByPaneKey` runs after the filter, so a filtered `SessionStart` cannot perform it.
- `src/shared/agent-session-resume.ts:202-205` — Codex `providerSession.id` is the hook `session_id`, which is what the comparison uses.
## Required outcome
- Side-session hooks are filtered whenever they cannot be attributed to the pane's main session, without suppressing a genuinely new main session in a reused pane.
## Open questions for the human
- Does Codex send `transcript_path: null` (not an omitted field) for ephemeral side sessions, and can a new main session's `SessionStart` carry `transcript_path: null`? The tests only simulate the `null` shape.There was a problem hiding this comment.
✅ No new issues found in this increment.
Reviewed changes
This run re-reviewed the commit that watches the active Codex rollout and skips unrelated transcript records. Previously flagged blockers remain tracked separately and are not re-raised here.
- Event-driven root polling — new
AgentTranscriptPollSchedulerbacks both the server and relay retry schedulers. A root-only Codex pane now gets onefs.watchon its rollout plus a 5s safety probe instead of a 500ms poll, while child and Muse-session-log panes keep the old cadence. - Shared native watcher —
createTranscriptNativeWatchermoved tosrc/shared/with awatchParentoption; the status lane watches the file itself and the native-chat lane keeps watching the parent directory, so existing native-chat callers are unchanged. - Status-record filter — new
isCodexStatusTranscriptLineletsreadJsonlCursorskipJSON.parsefor message/token records in the parent rollout, child rollouts, and the reviewer cursor. I verified it covers every record type consumed byreconcileCodexTranscriptTurn,readApprovalsReviewer,readActivity,readChildModel, andchildIsComplete. - Change-detection return —
reconcileCodexSubagentTranscriptnow returns whether anything changed, andpollCodexTranscriptStatusreturns the original payload untouched when neither the transcript nor the cancellation flag changed, skipping the payload rebuild.
Verified locally: the new scheduler, status-line, and turn-transcript suites pass, as do the host, relay, and host-inference Codex interruption suites.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
83ce099 to
a3490a4
Compare
Comments Outside DiffThese findings could not be posted inline.
|

ELI5
Ctrl+C should leave the main task working when used to copy text or return from
/side, and show Interrupted when it really cancels that task.What Changed
Previously, Orca inferred a cancelled Codex turn from Ctrl+C after 500 ms. The terminal renderer and status server now skip that guess. Instead, the execution host reads Codex's recorded turn-abort event through the existing transcript reader and publishes the confirmed cancellation to the status store.
Actual cancellations show Interrupted, including over SSH. If subagents still run, their work remains active while the main agent shows its cancellation. Hooks from an ephemeral side session cannot replace the recorded main turn. A new prompt clears the cancellation outcome. Program-exit cleanup and Escape handling continue to work.
Why
Ctrl+C has several meanings inside an agent terminal, and waiting longer cannot distinguish them. The turn record is positive evidence of cancellation. Extending the existing host-side reader preserves one status store, keeps remote filesystem access on the remote host, and avoids interpreting terminal text that could merely quote an interruption message.
Linked Issue
Reported directly; no linked issue.
Visual Proof
Captured with the
visual-proofworkflow through Playwright/CDP in hidden Electron renderers. The controlled reproduction posts a working hook and sends a real terminal Ctrl+C. It also posts an ephemeral side-session hook, then appends a Codex turn-abort record and verifies the rendered cancellation. Clipboard contents and a live/sideconversation were not tested.Testing
/sideinteraction check.On macOS, with
ORCA_BACKGROUND_LAUNCH=1:pnpm tcandpnpm run check:code-quality:changedpass.pnpm typecheck:e2ehas existing errors elsewhere in the suite and missing cloud dependencies.Review
Self-reviewed turn identity checks, unchanged input forwarding, host ownership, and preservation of child work. The transcript poll no longer replays an old prompt or tool hook while reading new records. Confirmed relay cancellations also update the main-turn cache before a later Stop or child event, preserving the cancellation verdict. CI failures were fixed by updating the dependency-boundary import list and replacing obsolete Ctrl+C inference fixtures with recorded/host-confirmed cancellation evidence; the late-Stop checks remain in place.
Agent skill upstream boundary
Notes
The execution host watches the active main rollout file using the existing native watcher, batches file events onto one shared deadline timer, and checks every five seconds if a notification is missed. Failed watches and WSL UNC paths keep the previous polling cadence (one second locally and in the relay); active child rollouts keep their existing cadence. Watches are reused across hooks and disposed when a turn settles, the path changes, or the server stops. The first safety read closes the read-to-watch installation race.
A deterministic 100-pane comparison over 60 seconds counts 6,000 probes before versus 1,200 after at the production one-second cadence: 80% fewer quiet-session reads (the additional 500 ms test case counts 12,000 versus 1,200). A 1,000-event burst produces one read without postponing it indefinitely. Filtering before decoding parses zero of 1,000 message/token records while still decoding a real abort. Unchanged reads skip rebuilding the status payload and child comparison. The incremental cursor, byte limits, and bounded child discovery remain in place; there are no new subprocesses or protocol fields. Unreadable transcripts cannot confirm cancellation; process-exit cleanup still applies.
Reliability contract:
agent-session.provider-ownership— only the execution host confirms a main-turn cancellation, and a side session cannot replace its owner. The reported false red status is the failure source. The oracle is working status after Ctrl+C alone, Interrupted after a matching recorded abort, and continued child work. No matching dedicated entry exists inconfig/reliability-gates.jsonc; this is a documented gate gap, covered here by the focused regression suites and repeated Electron test. Diagnostics are the attached screenshots and test assertions for turn IDs, status outcomes, probe counts, and watch disposal.Coverage: local macOS and relay-to-desktop status forwarding are covered; WSL UNC fallback, failed watches, and replacement are covered with deterministic mocks. Daemon PTY lifecycle and mobile transport are unchanged. Physical WSL, SSH, Linux/Windows filesystem notifications, mobile presentation, and live Codex clipboard/side interaction remain explicit validation gaps.
An older client sending a Ctrl+C inference request to an updated host is refused; an updated client avoids sending it to an older host. A remote host publishes cancellation using the existing main-agent and interrupted fields. The change is independent of Git worktree membership and uses no platform-specific shortcut policy.
Checklist