Repository navigation
Conversation
…cape gets The chat's Stop writes Escape straight to the runtime, so it never passes through xterm, where a typed Escape arms the interrupt inference. For a TUI that fires no hook on interrupt, the sidebar row kept showing "Working" after a chat Stop, while the same Escape typed into the terminal cleared it. The single-Escape Stop now runs that inference with the same per-agent rules and settle window. Main still re-checks the status baseline, so a real hook that lands first wins. Claude, Codex and OMP are unchanged because their Escape also closes views; OpenCode's paced double Escape is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6ad8ce91-36f2-4f86-9539-fcb0b1bccb95
📒 Files selected for processing: 3
src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.tssrc/renderer/src/components/terminal-pane/agent-interrupt-inference.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.
| if (targetPtyId && sendRuntimePtyInput(targetPtyId, ESC, 'driving')) { | ||
| // Why: this Escape bypasses xterm.onData, so a TUI that fires no hook on interrupt stays working. | ||
| inferInterruptFromDirectInput( | ||
| { | ||
| paneKey, | ||
| getStatusEntry: () => useAppStore.getState().agentStatusByPaneKey[paneKey], | ||
| inferInterrupt: (request) => | ||
| window.api.agentStatus.inferInterrupt(request).catch((err) => { | ||
| console.warn('[agent-interrupt] native-chat inference failed:', err) | ||
| return false | ||
| }) | ||
| }, | ||
| 'plain-escape' | ||
| ) | ||
| } | ||
| }, [agent, cancelInFlight, paneKey, targetPtyId]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '125,195p' src/renderer/src/runtime/runtime-terminal-inspection.ts
sed -n '175,205p' src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
sed -n '45,285p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
rg -n 'inferInterrupt|terminal.send|sendRuntimePtyInput' src/main src/renderer/src/runtime | head -100Repository: stablyai/orca
Length of output: 22655
🏁 Script executed:
set -o pipefail
sed -n '80,135p' src/renderer/src/runtime/runtime-terminal-inspection.test.ts
sed -n '285,425p' src/renderer/src/runtime/runtime-terminal-inspection.test.ts
sed -n '270,360p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
sed -n '1,110p' src/main/agent-hooks/server/server-status-inference.ts
rg -n -F --glob '*.ts' -e 'inferInterruptFromDirectInput' -e 'observeInputIntent(' -e 'accepted: false' -e 'declined remote terminal sends' src/renderer/src src/main | head -160Repository: stablyai/orca
Length of output: 32188
🏁 Script executed:
set -o pipefail
sed -n '90,230p' src/main/agent-hooks/server/server-status-inference.ts
sed -n '100,175p' src/renderer/src/components/terminal-pane/pty-connection/pty-input-forward.ts
sed -n '1,180p' src/renderer/src/components/terminal-pane/pty-connection/interrupt-input-intent.ts
sed -n '1,150p' src/renderer/src/runtime/runtime-terminal-verified-input.ts
rg -n -F --glob '*.test.ts*' -e 'inferInterrupt' -e 'accepted: false' -e 'sendRuntimePtyInput(' src/renderer/src/components/native-chat src/renderer/src/components/terminal-pane src/main/agent-hooks | head -220Repository: stablyai/orca
Length of output: 44038
🏁 Script executed:
set -o pipefail
nl -ba src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts | sed -n '175,202p'
nl -ba src/renderer/src/runtime/runtime-terminal-inspection.ts | sed -n '131,185p'
nl -ba src/renderer/src/runtime/runtime-terminal-verified-input.ts | sed -n '1,88p'
nl -ba src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts | sed -n '245,292p'
nl -ba src/main/agent-hooks/server/server-status-inference.ts | sed -n '100,205p'Repository: stablyai/orca
Length of output: 14655
Infer the interrupt only after remote PTY acceptance.
sendRuntimePtyInput returns true before a remote terminal.send completes. A rejected or failed remote send therefore still starts inferInterruptFromDirectInput. The inference can then settle the row as interrupted while the TUI continues running.
Use sendRuntimePtyInputVerified for this path. Its remote contract waits for acceptance and returns false for refusal.
Suggested fix
- import { sendRuntimePtyInput } from '../../runtime/runtime-terminal-inspection'
+ import { sendRuntimePtyInputVerified } from '../../runtime/runtime-terminal-verified-input'
- if (targetPtyId && sendRuntimePtyInput(targetPtyId, ESC, 'driving')) {
- // Why: this Escape bypasses xterm.onData, so a TUI that fires no hook on interrupt stays working.
- inferInterruptFromDirectInput(
- {
- paneKey,
- getStatusEntry: () => useAppStore.getState().agentStatusByPaneKey[paneKey],
- inferInterrupt: (request) =>
- window.api.agentStatus.inferInterrupt(request).catch((err) => {
- console.warn('[agent-interrupt] native-chat inference failed:', err)
- return false
- })
- },
- 'plain-escape'
- )
+ if (targetPtyId) {
+ void sendRuntimePtyInputVerified(targetPtyId, ESC, 'driving')
+ .then((accepted) => {
+ if (!accepted) return
+ // Why: this Escape bypasses xterm.onData, so a TUI that fires no hook on interrupt stays working.
+ inferInterruptFromDirectInput(
+ {
+ paneKey,
+ getStatusEntry: () => useAppStore.getState().agentStatusByPaneKey[paneKey],
+ inferInterrupt: (request) =>
+ window.api.agentStatus.inferInterrupt(request).catch((err) => {
+ console.warn('[agent-interrupt] native-chat inference failed:', err)
+ return false
+ })
+ },
+ 'plain-escape'
+ )
+ })
+ .catch(() => {})
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (targetPtyId && sendRuntimePtyInput(targetPtyId, ESC, 'driving')) { | |
| // Why: this Escape bypasses xterm.onData, so a TUI that fires no hook on interrupt stays working. | |
| inferInterruptFromDirectInput( | |
| { | |
| paneKey, | |
| getStatusEntry: () => useAppStore.getState().agentStatusByPaneKey[paneKey], | |
| inferInterrupt: (request) => | |
| window.api.agentStatus.inferInterrupt(request).catch((err) => { | |
| console.warn('[agent-interrupt] native-chat inference failed:', err) | |
| return false | |
| }) | |
| }, | |
| 'plain-escape' | |
| ) | |
| } | |
| }, [agent, cancelInFlight, paneKey, targetPtyId]) | |
| if (targetPtyId) { | |
| void sendRuntimePtyInputVerified(targetPtyId, ESC, 'driving') | |
| .then((accepted) => { | |
| if (!accepted) return | |
| // Why: this Escape bypasses xterm.onData, so a TUI that fires no hook on interrupt stays working. | |
| inferInterruptFromDirectInput( | |
| { | |
| paneKey, | |
| getStatusEntry: () => useAppStore.getState().agentStatusByPaneKey[paneKey], | |
| inferInterrupt: (request) => | |
| window.api.agentStatus.inferInterrupt(request).catch((err) => { | |
| console.warn('[agent-interrupt] native-chat inference failed:', err) | |
| return false | |
| }) | |
| }, | |
| 'plain-escape' | |
| ) | |
| }) | |
| .catch(() => {}) | |
| } | |
| }, [agent, cancelInFlight, paneKey, targetPtyId]) |
… is accepted The chat's Stop sent Escape fire-and-forget and armed the interrupt inference at once. On a remote runtime the send can still be refused or fail, and the inference could then settle the row as interrupted while the TUI kept running. Stop now sends through the verified path and infers only when the write is accepted, from the pane status captured before the write. A typed Escape already works this way, and it keeps a slow acceptance from settling a turn that began after the Stop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7ce93fd1-a9b5-4a08-b5ed-6a4bfb6fdacd
📒 Files selected for processing: 3
src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.tssrc/renderer/src/components/terminal-pane/agent-interrupt-inference.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.
| /** A typed key's interrupt inference, for surfaces that write the key straight to the runtime. | ||
| * `capturedEntry` is the pane status from before the write, as for an acknowledged typed key. */ | ||
| export function inferInterruptFromDirectInput( | ||
| deps: AgentInterruptInferenceDeps, | ||
| intent: AgentInterruptInputIntent, | ||
| capturedEntry: AgentStatusEntry | null | ||
| ): void { | ||
| void createAgentInterruptInference(deps).observeInputIntent(intent, capturedEntry) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '105,280p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
sed -n '35,165p' src/renderer/src/components/terminal-pane/pty-connection/interrupt-input-intent.ts
rg -n 'AGENT_INTERRUPT_SETTLE_MS|qoder|plain-escape' src/renderer/src/components/terminal-pane/agent-interrupt-inference* | head -100Repository: stablyai/orca
Length of output: 15016
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- agent interrupt inference definitions ---'
sed -n '1,115p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
sed -n '175,315p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
printf '%s\n' '--- direct wrapper and callers ---'
sed -n '315,360p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'inferInterruptFromDirectInput' -e 'observeSentTerminalInputIntent' -e 'observeAcceptedTerminalInput' src/renderer/src/components
printf '%s\n' '--- Qoder and double-Escape rules ---'
rg -n -i -C 4 --glob '*.ts' -e 'qoder' -e 'requiresDoubleEscapeInterrupt' -e 'shouldIgnoreInterruptIntent' -e 'canInferInterrupt' src/renderer/src/components/terminal-pane src/shared
printf '%s\n' '--- native-chat Stop path ---'
sed -n '150,225p' src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
printf '%s\n' '--- main validation ---'
sed -n '95,195p' src/main/agent-hooks/server/server-status-inference.ts
printf '%s\n' '--- PR diff for the focused file ---'
git diff --unified=30 75e1f1c0f439d52579a3882ff1d80d38d4ba587e 8689f38d9313743d4b95e88d9758e141f212a913 -- src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts src/renderer/src/components/native-chat/use-native-chat-interactive-send.tsRepository: stablyai/orca
Length of output: 42507
🏁 Script executed:
set -o pipefail
sed -n '1,115p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
sed -n '175,315p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
sed -n '315,360p' src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts
rg -n -i -C 4 --glob '*.ts' -e 'qoder' -e 'requiresDoubleEscapeInterrupt' -e 'shouldIgnoreInterruptIntent' -e 'canInferInterrupt' src/renderer/src/components/terminal-pane src/shared
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'inferInterruptFromDirectInput' -e 'observeSentTerminalInputIntent' src/renderer/src/components
sed -n '180,210p' src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
sed -n '110,190p' src/main/agent-hooks/server/server-status-inference.ts
git diff --unified=20 75e1f1c0f439d52579a3882ff1d80d38d4ba587e 8689f38d9313743d4b95e88d9758e141f212a913 -- src/renderer/src/components/terminal-pane/agent-interrupt-inference.ts src/renderer/src/components/native-chat/use-native-chat-interactive-send.tsRepository: stablyai/orca
Length of output: 42139
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- shared interrupt rules ---'
sed -n '1,90p' src/shared/agent-interrupt-intent.ts
printf '%s\n' '--- persistent observer ownership and native-chat hook signature ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'interruptInference =' -e 'session.interruptInference' -e 'useNativeChatInteractiveSend(' -e 'useNativeChatInteractiveSend<' src/renderer/src
sed -n '1,130p' src/renderer/src/components/terminal-pane/pty-connection/interrupt-input-intent.ts
sed -n '1,125p' src/renderer/src/components/native-chat/use-native-chat-interactive-send.tsRepository: stablyai/orca
Length of output: 18438
🏁 Script executed:
sed -n '1,85p' src/shared/agent-interrupt-intent.ts
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'interruptInference =' -e 'session.interruptInference' -e 'useNativeChatInteractiveSend(' src/renderer/srcRepository: stablyai/orca
Length of output: 7181
Use the pane’s existing interrupt observer for chat Stop.
Qoder is not a double-Escape or navigation agent, so its typed Escape follows the normal branch. That branch clears and replaces the observer’s pending timer. However, inferInterruptFromDirectInput creates a separate observer, so the typed Escape cannot replace the chat Stop timer.
If the hook status remains unchanged, the detached timer can still pass renderer and main validation after 500 ms and mark the Qoder turn done with interrupted: true before the typed Escape’s settle window completes. Pass the pane’s existing session.interruptInference into this helper instead of creating a second observer.
Suggested fix
export function inferInterruptFromDirectInput(
- deps: AgentInterruptInferenceDeps,
+ inference: AgentInterruptInference,
intent: AgentInterruptInputIntent,
capturedEntry: AgentStatusEntry | null
): void {
- void createAgentInterruptInference(deps).observeInputIntent(intent, capturedEntry)
+ void inference.observeInputIntent(intent, capturedEntry)
}Thread the existing pane observer into the native-chat Stop caller.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** A typed key's interrupt inference, for surfaces that write the key straight to the runtime. | |
| * `capturedEntry` is the pane status from before the write, as for an acknowledged typed key. */ | |
| export function inferInterruptFromDirectInput( | |
| deps: AgentInterruptInferenceDeps, | |
| intent: AgentInterruptInputIntent, | |
| capturedEntry: AgentStatusEntry | null | |
| ): void { | |
| void createAgentInterruptInference(deps).observeInputIntent(intent, capturedEntry) | |
| /** A typed key's interrupt inference, for surfaces that write the key straight to the runtime. | |
| * `capturedEntry` is the pane status from before the write, as for an acknowledged typed key. */ | |
| export function inferInterruptFromDirectInput( | |
| inference: AgentInterruptInference, | |
| intent: AgentInterruptInputIntent, | |
| capturedEntry: AgentStatusEntry | null | |
| ): void { | |
| void inference.observeInputIntent(intent, capturedEntry) |
ELI5
Pressing Stop in the chat did stop the agent, but Orca's sidebar kept saying the agent was still working, because Orca never noticed the Stop happened. Now Stop in the chat is noticed the same way as pressing Escape in the terminal.
What Changed
Before: after Stop in a terminal-backed chat, an agent whose TUI fires no hook on interrupt kept its sidebar row and tab on "Working". Pressing Escape in the terminal view cleared it.
After: Stop in the chat settles the row the same way a typed Escape does.
Mechanism: a typed Escape reaches the PTY through xterm's
onData. That path armscreateAgentInterruptInference, which asks main to mark the row interrupted when no hook settles it within the settle window. The chat's Stop (useNativeChatInteractiveSend().cancel) wrote the Escape straight to the runtime withsendRuntimePtyInput, so the inference never ran.The single-Escape Stop now runs the same inference through a new
inferInterruptFromDirectInputhelper. It uses the same per-agent rules and settle window, and main still re-checks the status baseline, so a real hook that lands first wins. Like an acknowledged typed Escape, Stop sends throughsendRuntimePtyInputVerifiedand runs the inference only once the write is accepted, from the status captured before the write.Why
Linked Issue
Fixes #31786
Visual Proof
Seen with Qoder CLI in Chat UI, which fires no hook on Escape (see #31796). Each screenshot is taken after clicking Stop during
sleep 60. These shots use Orca's Chinese UI: 主要 is "primary", and the row's prompt asks Qoder to runsleep 60with bash.Testing
Manual: macOS dev build, Qoder CLI 1.1.75 chat. Send a long
sleep, click Stop, and watch the sidebar: before the fix it stayed "Working", after it the row settles within the window. A follow-up prompt runs normally.Automated (
use-native-chat-interactive-send.test.tsx), with fake timers:agentStatus.inferInterruptwith the row's baseline once the settle window passes. This case fails without the change.Local runs:
pnpm tc:web,pnpm tc:node,oxlint,pnpm run check:code-quality:changed.Vitest over
src/renderer/src/components/native-chat,src/renderer/src/components/terminal-paneandsrc/renderer/src/runtime: 1258 files passed.With fix(native-chat): keep transcript rows that share a timestamp in file order #31794 and feat(native-chat): open Qoder CLI sessions in the chat view #31796 merged on top:
pnpm tc:node,pnpm tc:web, and Vitest oversrc/main/native-chat,src/main/ai-vault,src/sharedand the renderer native-chat and terminal-pane suites (2693 files passed).I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Implemented with Claude Code (Claude Opus 5.5) under my direction. I reviewed the diff and the test runs.
Review
AI agent review of this change:
agentStatus.inferInterruptIPC, which main validates. On a remote runtime, Stop now infers only afterterminal.sendaccepts the Escape, so a refused or failed send infers nothing. No new wire.Agent skill upstream boundary
Notes
terminal.sendand likely has the same gap. It's left for a follow-up.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)🤖 Generated with Claude Code