Skip to content

fix(terminal): reconcile status after escape interrupt - #12345

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/fix-codex-escape-status
Aug 4, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/fix-codex-escape-status

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • capture the exact terminal agent-status generation, including absence, before asynchronous PTY input acknowledgment
  • infer interruption only after Escape or Ctrl+C is accepted, while main still strictly revalidates the captured turn
  • fence stale and out-of-order acknowledgments so they cannot replace a newer pending inference, including after renderer row cleanup
  • prevent late acknowledged input from rearming inference after pane disposal
  • preserve OpenCode/Copilot double-Escape semantics and keep native-chat behavior unchanged

Reliability contract

  • Invariant — terminal-input.interrupt-turn-identity: only an accepted Escape or Ctrl+C may reconcile the exact captured active turn to interrupted Done; delayed input must never affect a newer turn or a disposed pane.
  • Failure source: PTY acknowledgment may resolve after command-exit cleanup, after another turn starts, or after the newer renderer row disappears.
  • Oracle: deterministic renderer tests cover captured absence, stale/out-of-order acknowledgments, row cleanup, disposal, command-exit flushing, rejected writes, and same-generation double Escape; main tests prove exact timestamp/prompt/type/state authority; Electron proves the visible Working to interrupted Done transition with a real Codex turn.
  • Gate: no matching entry currently exists in config/reliability-gates.jsonc; this remains an explicit accepted manifest gap, covered in this PR by the targeted deterministic suites and Electron artifact.
  • Provider/platform coverage: local/daemon PTY is covered by tests and macOS Electron. SSH fire-and-forget, mobile/relay, WSL, and native-chat do not use the changed acknowledged-input branch and are unaffected. Linux and Windows runtime UI were not exercised; the code adds no platform-dependent behavior.
  • Performance budget: one constant-time status snapshot and generation comparison per accepted interrupt; no polling, broad scans, subprocesses, subscriptions, render fanout, or unbounded retained state.
  • Diagnostics: existing [agent-interrupt] failure logs plus captured baseline fields and status history identify rejected or applied inference.
  • Residual gaps: no live Linux/Windows UI run and no dedicated reliability-manifest gate; SSH/WSL/mobile transport paths remain unchanged rather than directly exercised.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts src/main/agent-hooks/server.test.ts src/main/ipc/agent-hooks.test.ts — 844 passed
  • pnpm run typecheck:web
  • pnpm run check:max-lines-ratchet
  • git diff --check origin/main...HEAD
  • three sequential same-model review passes; first two fixed meaningful acknowledgment races, final fresh pass returned CLEAN

Electron QA

AI review report

  • fixed an absent-baseline ambiguity that could interrupt a turn created after input
  • fixed stale acknowledgment replacement of a newer pending inference
  • added generation ordering so stale callbacks cannot cancel newer inference after row cleanup while same-turn double Escape remains valid
  • final independent pass found no actionable correctness, regression, scope, or performance issue

Security audit

  • no new IPC surface, permissions, shell commands, persisted data, or external input handling
  • main-process inference remains authoritative and requires an exact captured turn match

Notes

No mobile emulator run: the PR changes only the desktop renderer acknowledged terminal-input path.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review 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
📝 Walkthrough

Walkthrough

The change adds disposal guards to interrupt inference. It captures the pane’s agent-status entry before asynchronous acknowledged Escape or Ctrl-C input is sent. The captured entry is passed to inference after the write succeeds. Tests cover disposed trackers, null baselines, stale acknowledgments, plain Escape inference, and status cleanup after command exit.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 summarizes the terminal status reconciliation after Escape interrupts.
Description check ✅ Passed The description covers the change, testing, review, security, platform scope, and notes, with Electron evidence; it omits the required Screenshots section heading.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA — Escape interrupt

Validated commit 6edcd3651a in an isolated Electron dev profile attached to the intended jaeger @ brennanb2025/fix-codex-escape-status instance.

Scenario:

  • enabled Chat UI and launched a real Codex native-chat session
  • asked Codex to run sleep 30
  • confirmed the rendered app showed the turn as Working with the Stop control
  • pressed Escape through the focused native-chat surface
  • confirmed the rendered conversation changed to “Conversation interrupted” and workspace status changed to Done
  • confirmed backing pane state was state: "done", interrupted: true

Before — live turn working

Native chat working

After — Escape reconciled the interrupted status

Native chat interrupted

No mobile emulator run: the PR changes only desktop renderer/native-chat behavior.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-codex-escape-status branch from 6edcd36 to 03d483e Compare August 3, 2026 22:41
@brennanb2025 brennanb2025 changed the title fix(native-chat): reconcile status after escape interrupt fix(terminal): reconcile status after escape interrupt Aug 3, 2026
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fix-codex-escape-status branch from 03d483e to f03a8ff Compare August 3, 2026 22:41
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron terminal validation

Fresh validation against commit f03a8ff6f1 in the Jaeger dev build.

Before — Codex is working in the terminal

Terminal session working before Escape

After — Escape interrupts Codex and Orca clears Working

Terminal session done after Escape

Observed after Escape: the transcript reports Conversation interrupted, the tab state becomes Done, the worktree no longer shows Working, and the Agent Dashboard reports done-only. This exercises terminal mode; native-chat Escape behavior is unchanged by this PR.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18750193-c068-4985-ab83-77ea1033a7df

📥 Commits

Reviewing files that changed from the base of the PR and between f03a8ff and 28a7c14.

📒 Files selected for processing (3)
  • 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.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final Electron QA — reviewed HEAD 43e84da

Validated the exact jaeger @ brennanb2025/fix-codex-escape-status dev instance in an isolated Electron profile.

Scenario:

  • launched a real Codex terminal turn and asked it to run sleep 30
  • confirmed the rendered terminal, sidebar, and worktree showed Working; backing status was working with tool Bash and input sleep 30
  • pressed Escape through the focused terminal input
  • confirmed the transcript rendered Conversation interrupted, the worktree and tab rendered Done, and the agent row rendered Interrupted by user
  • confirmed backing status became state: done, interrupted: true, with the prior Working state retained in history

Before — real Codex turn working

Real Codex terminal turn showing Working

After — Escape reconciles interrupted Done

Terminal, worktree, and agent row showing interrupted Done

Review/verification:

  • three sequential same-model review passes; the first two fixed captured-absence and out-of-order acknowledgment races, and the fresh third pass returned CLEAN
  • 844 targeted renderer/main authority tests passed on the final HEAD
  • pnpm run typecheck:web, max-lines ratchet, and git diff --check passed
  • perf shape remains constant-time per accepted interrupt: no polling, scans, subprocesses, subscriptions, or unbounded retained state were added

No mobile emulator run: this PR changes only the desktop renderer terminal path; SSH fire-and-forget and native-chat paths are unchanged.

@brennanb2025
brennanb2025 merged commit 98e8d1c into main Aug 4, 2026
42 checks passed
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