Repository navigation
Fix Claude's stuck spinner after Escape cancellation - #25846
Conversation
54a37dd to
c67f057
Compare
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe 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 The reviewed cancellation path has no identified issue that needs resolution before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
5a0552e8-1f71-45a7-90ff-cc515c28eeab
📒 Files selected for processing (29)
src/main/agent-hooks/claude-terminal-interrupt-capture.test-fixture.tssrc/main/agent-hooks/server-claude-terminal-interrupt.test.tssrc/main/agent-hooks/server/server-status-inference.tssrc/main/ipc/pty/ipc/write-input-user-input.test.tssrc/main/ipc/pty/ipc/write-input.tssrc/main/ipc/pty/runtime/operations.tssrc/main/orcad/orcad-entry.tssrc/main/runtime/__fixtures__/claude-interrupt-idle-usage-supported.input.jsonsrc/main/runtime/__fixtures__/claude-interrupt-idle-usage-supported.meta.jsonsrc/main/runtime/__fixtures__/claude-interrupt-idle-usage-supported.txtsrc/main/runtime/__fixtures__/claude-interrupt-stream-usage-cancel-orca.input.jsonsrc/main/runtime/__fixtures__/claude-interrupt-stream-usage-cancel-orca.meta.jsonsrc/main/runtime/__fixtures__/claude-interrupt-stream-usage-cancel-orca.txtsrc/main/runtime/__fixtures__/claude-interrupt-tool-cancel-supported.input.jsonsrc/main/runtime/__fixtures__/claude-interrupt-tool-cancel-supported.meta.jsonsrc/main/runtime/__fixtures__/claude-interrupt-tool-cancel-supported.txtsrc/main/runtime/orca-runtime-apply-tracked-pty-title.tssrc/main/runtime/orca-runtime-preserved-branch-cleanup.tssrc/main/runtime/orca-runtime-state-fields.tssrc/main/startup/main-process-runtime-service.tssrc/relay/agent-hook-integration.test.tssrc/relay/agent-hook-interrupt-reconciliation.tssrc/relay/agent-hook-server-claude-owed-notification-expiry.test.tssrc/relay/agent-hook-server.tssrc/relay/claude-terminal-interrupt-status.tssrc/relay/pty-handler.tssrc/relay/relay-agent-hook-runtime.tssrc/shared/claude-terminal-interrupt.test.tssrc/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.
c67f057 to
e09e0b4
Compare
6454b94 to
eb5571c
Compare
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
/usagedismissal 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.
After: pressing Escape cancels the foreground task and clears both spinners.
Testing
On macOS, drove real Claude Code 2.1.291 in a PTY and in a hidden Orca renderer through Playwright CDP. Opened and dismissed
/usageduring 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 commit6685d48c3c09: 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
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