Repository navigation
fix(runtime): recognize hand-typed native Claude at its startup dialogs - #33826
Conversation
A shell-typed claude emits no title at the trust dialog, so nothing asked which process owned the pane, and native Claude's process name is its version (2.1.310). agentWait now identifies a title-less, unowned pane from its foreground process, confirming an unfamiliar name with one process scan whose verdict is kept while that name stays in the foreground.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 6 minutes. View limit details
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
6276b89b-762d-4393-86fe-6030925a07cc
Files selected for processing: 5-
src/main/runtime/claude-dialog-interactive-wait.test.tssrc/main/runtime/runtime-pty-foreground-agent.tssrc/main/runtime/terminal/input/terminal-agent-prompt-resubmit.tssrc/main/runtime/terminal/output/terminal-title-observation.tssrc/main/runtime/terminal/wait/titleless-pane-agent-identity.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
| agent = recognizeAgentProcess(await this.confirm(result.controller, ptyId))?.agent ?? null | ||
| if (result.controller !== this.deps.getController()) { | ||
| return false | ||
| } | ||
| this.confirmedByPtyId.set(ptyId, { foregroundName, agent }) |
There was a problem hiding this comment.
Do not cache a failed foreground scan.
If confirmForegroundProcess rejects, confirm returns null. Line 168 then caches null for the foreground name. Later checks reuse that result, so a native Claude startup dialog remains unidentified even after the scanner recovers. Distinguish a failed scan from a successful no-agent result, and retry failed scans.
🔎 Supported by static analysis
-
Script executed:
sed -n '1,220p' src/main/runtime/runtime-pty-foreground-agent.ts sed -n '1,100p' src/main/runtime/terminal/wait/titleless-pane-agent-identity.ts
Repository: stablyai/orca
Length of output: 8267
Script executed:
set -o pipefail printf '%s\n' '--- identifyUnowned callers and foreground-agent integration ---' rg -n -F --glob '*.ts' -e 'identifyUnowned(' -e 'ptyForegroundAgent' -e 'foregroundAgent' src/main/runtime src/main | head -240 printf '%s\n' '--- RuntimePtyController contract and implementations ---' rg -n -F --glob '*.ts' -e 'interface RuntimePtyController' -e 'type RuntimePtyController' -e 'confirmForegroundProcess' -e 'getForegroundProcess' src/main | head -240 printf '%s\n' '--- relevant tests ---' rg -n -F --glob '*.{ts,tsx}' -e 'identifyUnowned' -e 'confirmForegroundProcess' -e 'titleless' -e 'foreground process' tests src | head -240
Repository: stablyai/orca
Length of output: 41850
Script executed:
set -o pipefail printf '%s\n' '--- titleless caller and wait flow ---' nl -ba src/main/runtime/terminal/wait/titleless-pane-agent-identity.ts nl -ba src/main/runtime/terminal/wait/terminal-wait-permission.ts | sed -n '250,330p' printf '%s\n' '--- delayed confirmation tests ---' nl -ba src/main/runtime/orca-runtime-tests/agent-status-and-waits-part-02.spec.ts | sed -n '285,545p' printf '%s\n' '--- foreground provider contract and local implementation ---' nl -ba src/main/providers/pty-provider-contract.ts | sed -n '175,210p' nl -ba src/main/providers/local-pty-provider.ts | sed -n '160,205p' nl -ba src/main/providers/local-pty-provider.ts | sed -n '500,540p' printf '%s\n' '--- runtime controller delegation ---' nl -ba src/main/ipc/pty/runtime/controller.ts | sed -n '55,85p' nl -ba src/main/ipc/pty/runtime/operations.ts | sed -n '135,175p'
Repository: stablyai/orca
Length of output: 23803
Script executed:
set -o pipefail printf '%s\n' '--- local confirmation helper ---' rg -n -F --glob '*.ts' -e 'confirmLocalPtyForegroundProcess' -e 'getLocalPtyForegroundProcess' src/main printf '%s\n' '--- titleless and interactive-wait tests ---' rg -n -F --glob '*.spec.ts' --glob '*.test.ts' -e 'titleless' -e 'hand-typed' -e 'startup dialog' -e 'interactive wait' src/main/runtime tests | head -200 printf '%s\n' '--- changed-file history and tests ---' git diff --unified=80 4c9a6a405501fa4d6dee6960a80ad2b33095bad0 c5b417e7850d28517105f39c015302c9906c6934 -- src/main/runtime/runtime-pty-foreground-agent.ts src/main/runtime/terminal/wait/titleless-pane-agent-identity.ts
Repository: stablyai/orca
Length of output: 12532
Script executed:
set -o pipefail printf '%s\n' '--- local foreground inspection ---' nl -ba src/main/providers/local-pty-foreground-inspection.ts | sed -n '80,275p' printf '%s\n' '--- titleless regression test ---' nl -ba src/main/runtime/claude-dialog-interactive-wait.test.ts | sed -n '1,220p' printf '%s\n' '--- wait evidence consumer and agent status selection ---' rg -n -F --glob '*.ts' -e 'readTerminalInteractiveWaitEvidence' -e 'getTerminalInteractiveWait' -e 'foregroundAgent' src/main/runtime/terminal/wait src/main/runtime | head -180
Repository: stablyai/orca
Length of output: 26958
Script executed:
set -o pipefail printf '%s\n' '--- interactive wait and permission evidence ---' nl -ba src/main/runtime/terminal/wait/terminal-interactive-wait.ts | sed -n '45,105p' nl -ba src/main/runtime/terminal/wait/terminal-wait-permission.ts | sed -n '45,115p' nl -ba src/main/runtime/terminal/wait/terminal-wait-permission.ts | sed -n '270,305p' printf '%s\n' '--- title/status snapshot inputs ---' rg -n -F --glob '*.ts' -e 'getTerminalWaitPermissionInputs' -e 'terminalAgent' -e 'agentType' src/main/runtime/terminal/wait src/main/runtime | head -120
Repository: stablyai/orca
Length of output: 22371
Recheck the foreground process before publishing confirmation.
load captures foregroundName before the asynchronous confirmation scan. The scan can observe a different process on the same PTY, but the post-await check compares only the controller. The code can therefore publish an agent for a process that is no longer foreground. The titleless wait path then uses that stale identity to decide whether to read Claude wait evidence.
Re-read the foreground process after confirmation and discard the result when it differs from foregroundName.
Suggested fix
-
--- "a/src/main/runtime/runtime-pty-foreground-agent.ts" +++ "b/src/main/runtime/runtime-pty-foreground-agent.ts" @@ -160,13 +160,22 @@ const confirmed = this.confirmedByPtyId.get(ptyId) if (confirmed?.foregroundName === foregroundName) { agent = confirmed.agent } else if (confirmUnfamiliar) { agent = recognizeAgentProcess(await this.confirm(result.controller, ptyId))?.agent ?? null if (result.controller !== this.deps.getController()) { return false } + const current = await this.read(ptyId, 0) + if ( + !current || + current.controller !== this.deps.getController() || + !current.available || + current.process !== foregroundName + ) { + return false + } this.confirmedByPtyId.set(ptyId, { foregroundName, agent }) } } else { this.confirmedByPtyId.delete(ptyId) }
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.Suggested changeagent = recognizeAgentProcess(await this.confirm(result.controller, ptyId))?.agent ?? null if (result.controller !== this.deps.getController()) { return false } this.confirmedByPtyId.set(ptyId, { foregroundName, agent }) agent = recognizeAgentProcess(await this.confirm(result.controller, ptyId))?.agent ?? null if (result.controller !== this.deps.getController()) { return false } const current = await this.read(ptyId, 0) if ( !current || current.controller !== this.deps.getController() || !current.available || current.process !== foregroundName ) { return false } this.confirmedByPtyId.set(ptyId, { foregroundName, agent })
…en a dialog is on screen Review follow-ups: an untitled, unowned pane earns a foreground read only when its live screen shows a blocked dialog, so plain shells answer without a round-trip; the process scan runs only for a semver-shaped foreground name (native Claude's versions/<semver> binary), never on win32, and only an answered scan is cached.
There was a problem hiding this comment.
Actionable comments posted: 3

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fc8eae18-035c-42d0-ae3a-29f0b0cb48f6
Files selected for processing: 3-
src/main/runtime/claude-dialog-interactive-wait.test.tssrc/main/runtime/runtime-pty-foreground-agent.tssrc/main/runtime/terminal/wait/titleless-pane-agent-identity.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
| }) | ||
| await runtime.refreshPtyForegroundAgentFromController(TRANSCRIPT_PANE_PTY_ID) | ||
| expect(runtime['ptysById'].get(TRANSCRIPT_PANE_PTY_ID)?.foregroundAgent).toBe('claude') | ||
| expect(counts.scans).toBe(1) |
There was a problem hiding this comment.
Make the scan assertion platform-specific.
On win32, RuntimePtyForegroundAgent.load skips confirmation scans. This test still requires counts.scans to equal 1, so it fails on Windows. Skip this positive-scan case on Windows, or assert the Windows behavior separately.
| return withTimeoutResult( | ||
| this.load(ptyId, 0, true), | ||
| TERMINAL_INTERACTIVE_WAIT_PROBE_TIMEOUT_MS | ||
| ).then((result) => result.ok) |
There was a problem hiding this comment.
Treat an unavailable foreground read as unknown.
If getForegroundProcess rejects, read reports available: false and load returns false. The timeout wrapper still reports ok: true, so identifyUnowned sends the pane to the ordinary wait-evidence path instead of returning unknown. Preserve the read’s availability separately from load’s change result, and return false when the read was unavailable.
| const identity = | ||
| terminal.titleStatus === null && | ||
| detectTerminalWaitBlockedReason( | ||
| this.readLiveTerminalScreenLines(ptyId)?.join('\n') ?? terminal.waitText |
There was a problem hiding this comment.
🔎 Supported by static analysis
-
Script executed:
sed -n '1,110p' src/main/runtime/terminal/wait/titleless-pane-agent-identity.ts rg -n 'readLiveTerminalScreenLines|readTerminalWaitEvidence|waitText' src/main/runtime/terminal/wait src/main/runtime/terminal/input/terminal-agent-prompt-resubmit.ts
Repository: stablyai/orca
Length of output: 3252
Script executed:
set -o pipefail printf '%s\n' '--- parent and related declarations ---' rg -n -F --glob '*.ts' \ -e 'readTerminalInteractiveWaitEvidence' \ -e 'identifyUnowned' \ -e 'class OrcaRuntimeWithResolveAuthoritativeTerminalWaitPermission' \ -e 'interface PtyForeground' \ -e 'type PtyForeground' \ src/main/runtime printf '%s\n' '--- parent implementation block ---' sed -n '1,260p' src/main/runtime/terminal/wait/terminal-wait-permission.ts printf '%s\n' '--- foreground identity implementation candidates ---' rg -n -F --glob '*.ts' -e 'identifyUnowned(' -e 'class' src/main/runtime/terminal src/main | head -160 printf '%s\n' '--- directly related tests ---' rg -n -F --glob '*.{ts,tsx}' \ -e 'titleless-pane-agent-identity' \ -e 'identifyUnowned' \ -e 'waitText' \ tests src/main/runtime/terminal | head -240
Repository: stablyai/orca
Length of output: 36251
Script executed:
set -o pipefail printf '%s\n' '--- foreground agent implementation ---' sed -n '1,190p' src/main/runtime/runtime-pty-foreground-agent.ts printf '%s\n' '--- interactive wait consumer ---' sed -n '1,125p' src/main/runtime/terminal/wait/terminal-interactive-wait.ts printf '%s\n' '--- foreground agent references and related timeout constants ---' rg -n -F --glob '*.ts' \ -e 'new RuntimePtyForegroundAgent' \ -e 'PtyForegroundAgent' \ -e 'foregroundProcess' \ -e 'foreground.*timeout' \ -e 'identifyUnowned' \ src/main/runtime src/main | head -220
Repository: stablyai/orca
Length of output: 37460
Require a live screen before starting the foreground probe.
When readLiveTerminalScreenLines returns no screen, retained terminal.waitText can still trigger identifyUnowned. That method wraps the foreground scan in withTimeoutResult, and getTerminalInteractiveWait awaits the returned promise. A stale blocked string can therefore delay the response without current live-screen evidence.
Suggested fix
-
--- "a/src/main/runtime/terminal/wait/titleless-pane-agent-identity.ts" +++ "b/src/main/runtime/terminal/wait/titleless-pane-agent-identity.ts" @@ -12,12 +12,14 @@ ): TerminalInteractiveWaitEvidence | Promise<TerminalInteractiveWaitEvidence | undefined> { const { terminal } = this.getTerminalWaitPermissionInputs(handle, ptyId) // Only dialog-shaped output earns a foreground read; plain shells and editors answer synchronously. + const liveScreen = this.readLiveTerminalScreenLines(ptyId) const identity = terminal.titleStatus === null && + liveScreen !== undefined && detectTerminalWaitBlockedReason( - this.readLiveTerminalScreenLines(ptyId)?.join('\n') ?? terminal.waitText + liveScreen.join('\n') ) !== null && this.ptyForegroundAgent.identifyUnowned(ptyId) if (!identity) { return super.readTerminalInteractiveWaitEvidence(handle, ptyId) }
A hand-typed native Claude identified for an interactive-wait query was stored as the pane's foregroundAgent. If the user declined the trust dialog before Claude set a title, no title transition fired, so the shell stayed labelled Claude until the next inventory refresh. The identity now answers only the current query; the per-pty scan cache (keyed by foreground name) keeps repeat queries cheap. Concurrent queries share one in-flight identify, and the version-name match is anchored.
…or disconnected panes - load() matches main again; only identify() consults the confirm-scan cache - disconnected/unreadable panes answer null so the tail path still answers; only timeout is unknown - check pane ownership before projecting the screen - cache only recognized agents, so a not-an-agent verdict is rescanned Co-Authored-By: Claude <[email protected]>
…m tautological tests
…aude Native Claude's foreground process name is its version binary (2.1.316), so the foreground refresh named no agent and the trust card never showed when claude was typed into a shell. Identify the pane through the existing identifyUnowned scan for this dialog only, without storing the identity on the pty (stablyai#33826), so a declined dialog does not leave the shell labelled Claude. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ELI5
If you typed
claudeinto an Orca shell tab yourself, Orca didn't know Claude was running there until Claude changed the tab title. Claude doesn't change the title while its first "Do you trust this folder?" question is on screen, soorca terminal showreportedagentWait: nonewhile Claude was stuck waiting for an answer. Now, when Orca checks a pane that has no agent title and that nobody has identified, it asks the OS which program is running in it.Root cause
Two gaps on the same path. Neither one is about parsing the typed command line:
cd x && ANTHROPIC_API_KEY=… claude,env VAR=… claude, and plainclaudeall failed the same way on main.launchAgent ?? foregroundAgent ?? launchCommandAgent(runtime-identity-state.tsgetPaneAgentForTuiIdle). For a hand-typed agent onlyforegroundAgentcan apply. It is refreshed only on OSC title status transitions and on inventory refreshes (terminal-title-observation.ts). Claude emits no title at its trust dialog: the tab keeps the shell's cwd title. So the pane stayed unidentified, and the Claude-only rendered-screen dialog check (terminal-wait-permission.tsreadTerminalInteractiveWaitEvidence) never ran.~/.local/bin/claude -> ~/.local/share/claude/versions/2.1.310, so node-pty / the daemon report the foreground as2.1.310. The daemon maps it toclaudeonly through an async argv scan whose result is cached for 1s (foreground-process-tracker.ts). Orca already handles this elsewhere withconfirmForegroundProcess(terminal-pane-mail-routing.ts: "macOS Claude p_comm can be 2.1.258").What changed
OrcaRuntimeWithTitlelessPaneAgentIdentity(new layer,terminal/wait/titleless-pane-agent-identity.ts): before the interactive-wait evidence read, an untitled pane with no launch, foreground, or command owner is identified from its foreground process. The cheap ownership check runs first; only then is the screen projected, and the read happens only when its live screen (synchronous headless grid, else the tail) already shows a blocked dialog. Plain shells, editors, and owned or titled panes keep the existing synchronous path, with no added round-trip and hook probes still shared in the same tick. If the read times out (2s, the existing probe bound), the answer isundefined(unknown), nevernone. A disconnected or exited pane, or an unavailable read, answers null, so the existing output-tail path still decides.RuntimePtyForegroundAgent.identifyUnowned: reads the foreground. Only an exact semver name (native Claude'sversions/<semver>binary) gets oneconfirmForegroundProcessscan. It is skipped on win32, where native Claude isclaude.exe, is recognized by name, and confirm forces a full scan. Only a scan that recognizes an agent is cached per pane, and only while that same name stays in the foreground. "Not an agent", errors, and unavailable results are never cached, so the next dialog rescans. Backgroundrefresh()is unchanged from main: it never consults the cache or scans. The cache is cleared on PTY teardown. The identity answers only the current interactive-wait query and is not stored as the pane'sforegroundAgent: a dialog declined with Ctrl-C before Claude sets a title fires no title transition, so a stored identity would keep labelling the shell as Claude. Concurrent queries share one in-flight read and scan.This reads the process table, not the typed text, so it works the same in bash, zsh, fish, PowerShell, and cmd.
Verification
Real dev Orca (background launch, isolated
ORCA_DEV_USER_DATA_PATH,CLAUDE_CONFIG_DIR,CODEX_HOME, fake API keys only), Claude 2.1.310 native,orca terminal sendinto plain shell tabs, thenorca terminal show:claudeagentWait: noneagent-trust-workspace (via prompt-text)ANTHROPIC_API_KEY=sk-ant-fake claudecd /tmp && cd proj && ANTHROPIC_API_KEY=… FOO='a b' claudeenv ANTHROPIC_API_KEY=… claudevimOPENAI_API_KEY=… codex(trust dialog)orca terminal create --command claude(control)claude-dialog-interactive-wait.test.ts: a hand-typed pane whose foreground is2.1.310and confirms asclaudereports the real trust-dialog fixture. It fails on main with either half of the fix reverted.pnpm tc, and the interactive-wait, worker-wait, dsb, and trust-transcript suites (70 tests).check:code-quality:changedpasses.Other agents
Codex, OpenCode, and Gemini report their own names as the foreground process, and their dialogs are judged from the output tail, which doesn't need pane identity. They didn't share the gap (Codex and Gemini trust dialogs were detected in the same run).
Risk / trade-offs
showTerminal→getTerminalInteractiveWaitis used byterminal show, worker list/fleet status, orchestration, federation, launch-intent resolution, and remote transport. Added cost arises only for an unowned, untitled pane whose screen shows a blocked dialog: one foreground read. A process scan (about 0.4–1.3s on a host with 2.6k processes) runs only for a version-named foreground, at most once per pane per foreground name.unknown (not evaluated). The next query answers.confirmForegroundProcess, so a native Claude hand-typed on a remote host is still identified only through the relay's own foreground reporting. Not a regression.foregroundAgentunchanged (no rescan); a background refresh never scans; a non-version name never scans; a hung foreground read answersundefined; once the shell is back in the foreground the pane is not Claude-owned; a plain shell is never foreground-read.