Skip to content

Fix Codex status after Ctrl+C copy and side-chat navigation - #24339

Merged
nwparker merged 5 commits into
mainfrom
nwparker/side-chat-codex
Oct 2, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/side-chat-codex

Conversation

@nwparker

@nwparker nwparker commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​705 $\color{#cf222e}{\Huge{\mathbf{−}}}$​98 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​607
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​415 $\color{#cf222e}{\Huge{\mathbf{−}}}$​123 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​292

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-proof workflow 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 /side conversation were not tested.

Before: false interruption After: Ctrl+C alone preserves work After: confirmed cancellation
Before Ctrl+C status After Ctrl+C status Confirmed cancellation

Testing

  • Automated tests added/updated.
  • Manual live Codex copying, cancellation, and /side interaction check.

On macOS, with ORCA_BACKGROUND_LAUNCH=1:

  • 311 tests pass across 35 suites after rebasing onto main. Coverage includes key inference guards, terminal input delivery, command and PTY exit cleanup, watcher failure/replacement/cleanup, native-chat watcher regressions, actual recorded cancellation, stale-turn rejection, ephemeral side-session isolation, active subagents, and local/SSH status rows for folder workspaces.
  • The new Electron regression passed three consecutive runs: Ctrl+C alone remains working; a recorded abort shows Interrupted; the next turn resumes and completes normally. The earlier version reproduced the false Interrupted row.
  • A relay-to-desktop test confirms the execution host forwards a cancellation without the desktop reading a remote path.
  • pnpm tc and pnpm run check:code-quality:changed pass.
  • Electron build in E2E mode and bundled CLI build pass.
  • pnpm typecheck:e2e has existing errors elsewhere in the suite and missing cloud dependencies.
  • Full lint, full test suite, and release build left to CI. Live SSH, Windows, and Linux checks were not run.

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

  • Not applicable.

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 in config/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

  • Focused on Codex Ctrl+C status correctness.
  • Explained the user-facing before/after, changed mechanism, and why this approach.
  • Before/after and confirmed-cancellation screenshots attached.
  • Self-reviewed for correctness, security, and performance.
  • Cross-platform, SSH/remote, and shortcut impact considered.
  • Full lint, test suite, and release build pass locally; CI will cover.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 871bea4f-a6d3-4585-abdf-e89c91dd78b3

📥 Commits

Reviewing files that changed from the base of the PR and between b87a51b and 83ce099.

📒 Files selected for processing (21)
  • src/main/agent-hooks/server-codex-turn-interruption.test.ts
  • src/main/agent-hooks/server/server-status-retries.ts
  • src/main/native-chat/transcript-native-watcher.ts
  • src/relay/agent-hook-result-retry-scheduler.ts
  • src/relay/agent-hook-server-codex-turn-interruption.test.ts
  • src/shared/agent-hook-listener/providers/codex-events.ts
  • src/shared/agent-hook-listener/providers/codex-state.ts
  • src/shared/agent-hook-listener/providers/codex-transcript-poll.ts
  • src/shared/agent-hook-listener/transcript-poll-policy.ts
  • src/shared/agent-transcript-poll-scheduler.test.ts
  • src/shared/agent-transcript-poll-scheduler.ts
  • src/shared/codex-status-transcript-line.test.ts
  • src/shared/codex-status-transcript-line.ts
  • src/shared/codex-subagent-poll-scheduler.ts
  • src/shared/codex-subagent-reviewer.ts
  • src/shared/codex-subagent-transcript.ts
  • src/shared/codex-turn-transcript.test.ts
  • src/shared/codex-turn-transcript.ts
  • src/shared/transcript-native-watcher.ts
  • tests/e2e/codex-ctrl-c-status.spec.ts
  • tests/e2e/helpers/agent-hook-endpoint.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The 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 83ce0

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 Review

Security architecture risk: 🔵 Low · up to 83ce0

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

  • Low · architecture · inferred: The new cancellation publication path is order-dependent. If a root Stop is handled while the lead is working, it can reconcile an abort record but then mark the lead done without transferring the transcript cancellation outcome. Subsequent polling only marks cancellation while the lead is not done, and root-only polling can cease. This splits terminal-outcome ownership between hooks and transcript polling and can leave a recorded interruption unpublished. Production occurrence is unresolved; cancellation-first execution is supported by the tests.
Security review details

Security Blast Radius

  • inferred — The inspected exposure is execution-host filesystem reads and pane-status mutation. An accepted forged hook requires loopback reachability and the listener token; the token check is listener-wide rather than per-pane. Transcript reads use the host process’s filesystem authority. The evidence does not establish a wider tenant, service, or cloud-environment boundary.

Trust Boundaries and Controls

  • observed — Both inspected listeners authenticate before body processing. Transcript validation accepts an absolute .jsonl path without proving directory ownership. Reads require a regular file and impose byte and line limits. These controls constrain processing, but do not authenticate transcript contents or establish writer isolation.

Resilience and Maintainability Implications

  • observed — Incremental reads retain incomplete lines and avoid replaying unchanged bytes. Cursor reset detects shrinking files, but does not track file generation, so same-path replacement is not explicitly distinguished. That limitation existed in the available historical reader; its relevance to the new cancellation authority depends on unsupported replacement and writer guarantees.

Hardening Proposals

  • proposed — Define one terminal-outcome precedence rule for hook completion and transcript cancellation, then preserve the verdict idempotently in both arrival orders while retaining active children. Separately document the trusted transcript-writer and legacy identity assumptions rather than treating path shape or optional IDs as proof of ownership.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 28 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 and concisely describes the primary change: correcting Codex status after Ctrl+C copy actions and side-chat navigation.
Description check ✅ Passed The description is comprehensive and follows the template. It explains the user impact, implementation, rationale, testing, visual proof, performance, compatibility considerations, and known validatio…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

Comment @coderabbitai help to get the list of available commands.

@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.

🧹 Nitpick comments (1)
tests/e2e/codex-ctrl-c-status.spec.ts (1)

37-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace 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 that interrupted stays at count 0 for a set window, for example with expect.poll or toHaveCount(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

📥 Commits

Reviewing files that changed from the base of the PR and between ddd4927 and b87a51b.

📒 Files selected for processing (8)
  • src/main/agent-hooks/server-codex-ctrl-c-inference.test.ts
  • src/main/agent-hooks/server/server-status-inference.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
  • src/renderer/src/components/terminal-pane/pty-connection-command-finished-cleanup.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-interrupt-inference.test.ts
  • src/shared/agent-interrupt-intent.ts
  • tests/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.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[Medium risk] Fixes agent status tracking after interrupts and navigation.

The PR does not appear safe to merge while late cancellation evidence can still mark a newer Codex turn Interrupted.

Findings

  1. P1 Late abort cancels new turn ▶

Summary

The PR replaces Ctrl+C-based Codex cancellation inference with host-owned transcript evidence, preserves child work, and forwards confirmed status from remote hosts.

  • It also adds side-session isolation and native-watch-assisted transcript polling.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Codex hook] --> B[Execution-host status]
  C[Root transcript abort] --> D[Host transcript reader]
  D --> B
  B --> E[Local status store or SSH relay]
  E --> F[Desktop status row]
Loading

Reviews (5) · Last reviewed commit: "fix: retain confirmed Codex cancellation..."

Comment thread src/shared/agent-interrupt-intent.ts Resolved

@pullfrog pullfrog 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.

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 shouldIgnoreInterruptIntent guard — new predicate in src/shared/agent-interrupt-intent.ts that suppresses Ctrl+C interrupt inference for codex in addition to the existing droid, consumed by both the renderer and the host.
  • Renderer inference — agent-interrupt-inference.ts deletes 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.ts replaces 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 codex to custom-agent to 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 shouldIgnoreInterruptIntent comment cites only Codex; the rationale deleted from server-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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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.

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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Late abort cancels new turn

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

@pullfrog pullfrog 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.

ℹ️ 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.ts reconciles Codex root-turn boundaries (task_started/turn_started, turn_aborted with reason=interrupted, task_complete/turn_complete) into a per-pane rootTurn, and codex-transcript-poll.ts marks the lead done/cancellation when that flag is set and the lead is still running.
  • Poll path — shouldPollHookTranscript/transcriptPollUpdate now also poll a running Codex turn's parent rollout and publish lead-state changes; the server and relay retry schedulers call pollCodexTranscriptStatus for Codex instead of normalizeHookPayload.
  • Remote path — reconcileRemoteCodexState applies a relayed mainAgent when the event carries no hookEventName, so a remote host's confirmed cancellation reaches the desktop without it reading a remote path.
  • New-turn reset — a root UserPromptSubmit/SessionStart clears rootTurn.interrupted.
  • Tests — new host and relay interruption suites, a codex-turn-transcript unit test, and an extended e2e spec covering the confirmed-cancel, child-hold, and relay-forward paths.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +21 to +25
if (
transcript.rootTurn.interrupted &&
state.codexLeadStateByPaneKey.get(original.paneKey)?.state !== 'done'
) {
markCodexLeadTurnInterrupted(state, original.paneKey)

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.

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') {

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.

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.

@pullfrog pullfrog 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.

ℹ️ 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 — normalizeCodexEvent now returns null for a hook whose transcript_path is exactly null, carries no agent_id, differs in session_id from the stored status, and arrives while a main transcript is already recorded, so /side hooks cannot overwrite the main turn.
  • Tests — the host and relay interruption suites now post side-session SessionStart/UserPromptSubmit/Stop hooks 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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 &&

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.

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.

@pullfrog pullfrog 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.

✅ 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 AgentTranscriptPollScheduler backs both the server and relay retry schedulers. A root-only Codex pane now gets one fs.watch on 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 — createTranscriptNativeWatcher moved to src/shared/ with a watchParent option; 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 isCodexStatusTranscriptLine lets readJsonlCursor skip JSON.parse for message/token records in the parent rollout, child rollouts, and the reviewer cursor. I verified it covers every record type consumed by reconcileCodexTranscriptTurn, readApprovalsReviewer, readActivity, readChildModel, and childIsComplete.
  • Change-detection return — reconcileCodexSubagentTranscript now returns whether anything changed, and pollCodexTranscriptStatus returns 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/side-chat-codex branch from 83ce099 to a3490a4 Compare October 2, 2026 00:33
@nwparker
nwparker merged commit 02790c5 into main Oct 2, 2026
27 of 29 checks passed
@greptile-apps

greptile-apps Bot commented Oct 2, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Late Interrupt Cancels New Turn src/shared/agent-hook-listener/providers/codex-events.ts:179 ▶

    If Codex delivers an Interrupt hook for an earlier turn after a new UserPromptSubmit, this code marks the new turn done and cancelled without checking the hook’s turn_id. The active task then incorrectly appears Interrupted.

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