Skip to content

fix(terminal): ignore navigation Escape for OMP and Pi - #9289

Closed
rodboev wants to merge 1 commit into
stablyai:mainfrom
rodboev:pr/ignore-omp-navigation-escape
Closed

rodboev wants to merge 1 commit into
stablyai:mainfrom
rodboev:pr/ignore-omp-navigation-escape

Conversation

@rodboev

@rodboev rodboev commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Stop plain Escape used for OMP and Pi navigation from being inferred as a turn interruption.
  • Keep terminal input, unread clearing, hook-driven completion, Ctrl+C handling, and other agents' interrupt policies unchanged.
  • Recheck the exclusion in main so direct or stale-renderer inference requests cannot synthesize a false stopped result.

Closes #9208.

Screenshots

No visual change

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation run after the rebase onto current main:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts src/main/agent-hooks/server.test.ts - passed, 303 tests passed
  • pnpm run typecheck:web - passed
  • pnpm run typecheck:node - passed
  • pnpm exec oxlint src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts src/main/agent-hooks/server.ts src/main/agent-hooks/server.test.ts && pnpm exec oxfmt --check src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts src/main/agent-hooks/server.ts src/main/agent-hooks/server.test.ts - passed

A server-level test also asserts that after an ignored plain-Escape inference for OMP and Pi, a subsequent agent_end hook still transitions the row to done, so hook-driven completion is verified end to end rather than only in isolation.

AI Review Report

Reviewed against the touched renderer and main interrupt-inference paths. The diff is limited to a plain-Escape ignore guard for OMP and Pi plus regression coverage that proves those agents no longer infer interrupts from navigation Escape, while Ctrl+C for OMP and Pi, Droid's Ctrl+C exclusion, and OpenCode/Copilot double-Escape behavior remain intact. Cross-platform review stays clean on macOS, Linux, and Windows because the change only adjusts shared interrupt-intent policy, without changing shortcuts beyond the existing plain-Escape classification, labels, paths, shell behavior, or Electron-only code paths.

Security Audit

Reviewed for bypass risk. Main keeps the authoritative plain-Escape exclusion, so a direct or stale renderer inference request still cannot synthesize a false stop for OMP or Pi. The change adds no command execution, path handling, credential flow, dependency, or new IPC/API surface.

Notes

The guard is intentionally limited to plain Escape for OMP and Pi. It does not declare Escape globally non-interrupting and does not suppress genuine hook-reported completion.

ELI5

Pressing Escape while navigating in OMP or Pi was treated as interrupting the agent turn. Plain Escape for those agents is ignored for interrupt inference so navigation keys do not fake a stop.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 19250088-f8f0-4f7d-a04a-94d88f28685b

📥 Commits

Reviewing files that changed from the base of the PR and between f713739 and e89e42b.

📒 Files selected for processing (4)
  • src/main/agent-hooks/server.test.ts
  • src/main/agent-hooks/server.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
  • src/main/agent-hooks/server.ts
  • src/main/agent-hooks/server.test.ts
  • src/renderer/src/components/terminal-pane/agent-interrupt-inference.test.ts

📝 Walkthrough

Walkthrough

Interrupt inference now ignores plain-escape for OMP and Pi agents in both renderer and server paths. ctrl-c continues to trigger interruption inference and updates the cached pane status to done with interrupted: true. Tests cover both intents, both agent types, and completion after a rejected navigation Escape.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: ignoring navigation Escape for OMP and Pi terminal agents.
Description check ✅ Passed The description includes all required sections, focused test results, AI review details, security audit, and platform notes.
Linked Issues check ✅ Passed The changes satisfy issue #9208 by excluding OMP and Pi plain-Escape inference while preserving hook completion, Ctrl+C, and other agent behavior.
Out of Scope Changes check ✅ Passed The renderer, main-process guard, and regression tests are directly related to the linked issue and stated pull request objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@mmarabel

mmarabel commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

I reproduced this exact false interruption on Pi in Orca 1.4.174. The sanitized recording and Pi-specific steps are now on #9208: #9208 (comment)

The two-layer change here is the right shape for Pi: the renderer drops Pi/OMP plain Escape before the settle timer, and the main-process guard rejects direct or stale inference requests. Ctrl+C and hook-driven completion remain unchanged.

The current review blocker is branch freshness, not the design. GitHub reports this PR as conflicting; it is 1,294 commits behind main. A current-main merge check finds one content conflict, in src/main/agent-hooks/server.ts. When rebasing, retain current main's restored-status, Claude question/cron, active-child, and Codex reconciliation guards, then place the Pi/OMP plain-Escape exclusion immediately after the existing Droid Ctrl+C exclusion and before the OpenCode/Copilot double-Escape check. The other three touched files auto-merge.

After rebasing, rerun the focused Vitest files, node/web typechecks, oxlint, and oxfmt already listed in the PR description and update the counts. For extra reviewer confidence, it would be useful to mention or assert that Pi agent_end still transitions the row to done after an ignored navigation Escape; current Pi extension coverage already verifies that agent_end is emitted.

With that rebase and fresh validation, I do not see a need to broaden or redesign this patch. @brennanb2025

@rodboev
rodboev force-pushed the pr/ignore-omp-navigation-escape branch from 9b639aa to e89e42b Compare August 6, 2026 13:36
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@rodboev

rodboev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed rebase guidance, that matched what the conflict turned out to be exactly.

Rebased onto current main as head e89e42b0f. The only content conflict was in src/main/agent-hooks/server.ts, resolved per your instructions: current main's restored-status, Claude question/cron, active-child, and Codex reconciliation guards are all retained, and the OMP/Pi plain-Escape exclusion sits between the Droid Ctrl+C check and the OpenCode/Copilot double-Escape check. The other three files rebased cleanly.

Also added the assertion you suggested: a new test proves that after an ignored plain-Escape inference for OMP and Pi, a subsequent agent_end hook still transitions the row to done in src/main/agent-hooks/server.test.ts (the sequence now covers rejected Escape, then hook-driven completion, for both agent types).

Validation rerun after the rebase is in the Testing section of the description.

@nwparker

Copy link
Copy Markdown
Contributor

Thank you for this, and sorry it sat so long.

You got here first for OMP and Pi, and the rule that just merged is yours. #20149 landed as fe4237c, and you are a co-author on the commit.

Two things you did that we adopted directly:

The rule itself — a plain Escape for OMP and Pi is navigation, not an interrupt, so it must never synthesise a stopped row. That is what shipped.

The two-sided placement, which was better than ours. Our first revision guarded only in the main process. You did both: a renderer-side skip and a main-side recheck, so a stale or direct inference request cannot route around the renderer. We took your shape. The merged version does need one adjustment — the renderer skip is scoped to state === 'working', because Claude's AskUserQuestion dismissal is also a plain Escape but on a waiting row, and an unscoped skip swallows it.

Your instinct also caught something we only found later. Because the renderer skip and the existing droid Ctrl+C skip shared a clearPending(), widening that predicate made a previously near-unreachable branch common: Ctrl+C followed by an Escape inside the 500 ms settle window silently dropped the real interrupt. We split the two skips so droid keeps its exact prior behaviour and a navigation Escape never revokes a pending Ctrl+C. Escape is not a retraction.

The merged change combines your half with @brennanb2025's Claude half (#15674), adds Prime Agent, and brings wire-level and in-app verification. The design is yours and theirs.

Closing as superseded by the merged change.

@nwparker nwparker closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Plain Escape used for OMP view navigation is inferred as a turn interrupt (false "stopped")

4 participants