Skip to content

Fix Claude's stuck spinner after Escape cancellation - #25846

Merged
nwparker merged 3 commits into
mainfrom
nwparker/claude-interrupt
Oct 6, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/claude-interrupt

Conversation

@nwparker

@nwparker nwparker commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​789 $\color{#cf222e}{\Huge{\mathbf{−}}}$​41 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​748
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​356 $\color{#cf222e}{\Huge{\mathbf{−}}}$​35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​321

ELI5

Cancelling Claude now clears Orca's spinner when Claude returns to its prompt. Escape still leaves Orca working when it only dismisses a dialog such as /usage.

What Changed

The execution host correlates an accepted Escape with Claude's live terminal title changing from its busy glyph to ✳. This updates the existing agent-status store and preserves background work. Both local terminals and SSH relays use the same evidence tracker; the relay reuses its existing cancellation handler and notification-expiry timer. It accepts legacy Escape and the CSI-u encoding observed from Orca's actual keyboard input.

Another busy title, new input, a newer hook, PTY replacement, or a five-second timeout invalidates the pending Escape. The relay checks the current launch token and status age before applying cancellation. Restored rows, synthetic title clears, and desktop observations of remote terminals cannot confirm cancellation.

Why

The previous fix stopped treating Escape alone as cancellation, which prevented false stops but left real cancellations spinning. Claude's Stop hook does not run on interruption, and live foreground-tool cancellation emitted no failure hook. Progress clears also occurred when dismissing an idle dialog.

Captured PTY transcripts distinguish genuine cancellation from /usage dismissal through native title glyphs. This avoids parsing English messages or conversation titles. Missing or disabled native titles provide no confirmation; background work can also keep the title busy.

Linked Issue

Follow-up to #19932.

Visual Proof

Before: Claude shows Interrupted while Orca's sidebar and tab keep spinning.

Interrupted Claude with Orca still spinning

After: pressing Escape cancels the foreground task and clears both spinners.

Interrupted Claude with the sidebar and tab settled

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

On macOS, drove real Claude Code 2.1.291 in a PTY and in a hidden Orca renderer through Playwright CDP. Opened and dismissed /usage during a running turn, cancelled streaming output and a foreground tool, verified the cancelled process exited, and completed a follow-up prompt. The physical-key test confirmed CSI-u Escape input and native idle confirmation 7 ms after the accepted write.

Targeted interruption, captured-transcript replay, relay forwarding, write-acceptance, background-task notification, and host-turn tests pass locally. All 21 mobile turn-disclosure tests pass with the upstream fix for the oversized inherited test file. pnpm tc, full-repository Oxlint, the changed-code quality gate, mobile typecheck, and the mobile test typecheck ratchet pass. The CLI and Electron development builds were also verified during the live test. All CI checks passed on the reviewed commit 6685d48c3c09: 44 successful and 14 intentionally skipped, including the full test shards, packaging, Linux runtime compatibility, and macOS/Windows SSH host checks. All 79 focused tests, pnpm tc, and the changed-code quality gate pass locally. CI required retries after runner shutdowns and an unrelated terminal-history test failure; the final checks are green on this exact commit.

Live Claude validation was on macOS. Linux, Windows, and SSH host behavior also passed CI; relay behavior has integration coverage.

Review

Reviewed the accepted-input boundary, stale-row guards, child-work preservation, and relay ownership. Reproduced and fixed two review findings: a post-Escape busy title must invalidate pending cancellation, and remote terminal replacement or stale status must prevent cancellation. Regression tests failed before both fixes and pass afterward. Raw transcript fixtures are scrubbed; screenshots are attachments rather than committed assets.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer material copied or translated.

Notes

CI cleanup updates stale host-turn test inputs. The inherited mobile line-limit failure is fixed on the rebased main branch. No wire fields or stream opcodes change. SSH hosts make the decision and publish through the existing status envelope; older relays retain the previous behavior. Folder workspaces are covered. No platform-specific keyboard shortcut or path behavior changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • CI lint, typecheck, tests, and packaging pass

@nwparker
nwparker force-pushed the nwparker/claude-interrupt branch from 54a37dd to c67f057 Compare October 6, 2026 09:05
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in 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

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: 9f641f96-59c3-43dc-a11a-86ca4cba96fb
📥 Commits

Reviewing files that changed from the base of the PR and between eb5571c and 6685d48.

📒 Files selected for processing (4)
  • src/main/agent-hooks/server-claude-terminal-interrupt.test.ts
  • src/relay/agent-hook-interrupt-reconciliation.test.ts
  • src/relay/claude-terminal-interrupt-status.ts
  • src/shared/claude-terminal-interrupt.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/relay/claude-terminal-interrupt-status.ts
  • src/main/agent-hooks/server-claude-terminal-interrupt.test.ts
  • src/shared/claude-terminal-interrupt.ts

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


📝 Walkthrough

Walkthrough

The change adds a tracker that correlates accepted Escape input with subsequent Claude terminal-title evidence. Local and relay PTY paths forward input, title, and reset evidence to interruption handling. Local inference now allows navigation-Escape requests when Claude native-title confirmation applies. New captured-session fixtures and tests cover cancellation, usage dismissal, tool activity, and evidence eligibility.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 6685d

The reviewed cancellation path has no identified issue that needs resolution before merge.

🚥 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 26 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 describes the main change: fixing Claude’s stuck spinner after Escape cancellation.
Description check ✅ Passed The description covers the change, user impact, rationale, linked issue, visual proof, testing, review, compatibility notes, and checklist. It is complete enough to meet the repository template.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

❤️ 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a0552e8-1f71-45a7-90ff-cc515c28eeab
📥 Commits

Reviewing files that changed from the base of the PR and between 4de9f9f and c67f057.

📒 Files selected for processing (29)
  • src/main/agent-hooks/claude-terminal-interrupt-capture.test-fixture.ts
  • src/main/agent-hooks/server-claude-terminal-interrupt.test.ts
  • src/main/agent-hooks/server/server-status-inference.ts
  • src/main/ipc/pty/ipc/write-input-user-input.test.ts
  • src/main/ipc/pty/ipc/write-input.ts
  • src/main/ipc/pty/runtime/operations.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/runtime/__fixtures__/claude-interrupt-idle-usage-supported.input.json
  • src/main/runtime/__fixtures__/claude-interrupt-idle-usage-supported.meta.json
  • src/main/runtime/__fixtures__/claude-interrupt-idle-usage-supported.txt
  • src/main/runtime/__fixtures__/claude-interrupt-stream-usage-cancel-orca.input.json
  • src/main/runtime/__fixtures__/claude-interrupt-stream-usage-cancel-orca.meta.json
  • src/main/runtime/__fixtures__/claude-interrupt-stream-usage-cancel-orca.txt
  • src/main/runtime/__fixtures__/claude-interrupt-tool-cancel-supported.input.json
  • src/main/runtime/__fixtures__/claude-interrupt-tool-cancel-supported.meta.json
  • src/main/runtime/__fixtures__/claude-interrupt-tool-cancel-supported.txt
  • src/main/runtime/orca-runtime-apply-tracked-pty-title.ts
  • src/main/runtime/orca-runtime-preserved-branch-cleanup.ts
  • src/main/runtime/orca-runtime-state-fields.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/relay/agent-hook-integration.test.ts
  • src/relay/agent-hook-interrupt-reconciliation.ts
  • src/relay/agent-hook-server-claude-owed-notification-expiry.test.ts
  • src/relay/agent-hook-server.ts
  • src/relay/claude-terminal-interrupt-status.ts
  • src/relay/pty-handler.ts
  • src/relay/relay-agent-hook-runtime.ts
  • src/shared/claude-terminal-interrupt.test.ts
  • src/shared/claude-terminal-interrupt.ts

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

Comment thread src/shared/claude-terminal-interrupt.ts Resolved
@nwparker
nwparker force-pushed the nwparker/claude-interrupt branch from c67f057 to e09e0b4 Compare October 6, 2026 18:47
@nwparker
nwparker force-pushed the nwparker/claude-interrupt branch from 6454b94 to eb5571c Compare October 6, 2026 19:04
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