Repository navigation
fix(runtime): report Claude's workspace trust dialog from terminal show's agent wait - #29488
Conversation
…tive-wait query getTerminalInteractiveWait read only the line tail, which drops the rows below the cursor Claude parks inside its dialog, so the query answered "no wait" while the trust dialog owned the screen. For Claude panes it now reads the rendered screen (bounded, discarded if newer output or a pane exit overtakes the read) and lets a dialog seen there stand unless a newer working or explicit idle signal clears it. Other agents keep the synchronous path, so concurrent queries still share one hook probe. Ported from #28187 onto the split runtime modules. Co-authored-by: JMensch <[email protected]>
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
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:
c84125df-a927-4f4e-8aaf-606e46e249a4
📒 Files selected for processing: 4
src/main/runtime/claude-dialog-interactive-wait.test.tssrc/main/runtime/terminal/output/terminal-visible-state.tssrc/main/runtime/terminal/wait/terminal-interactive-wait.tssrc/main/runtime/terminal/wait/terminal-wait-permission.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.
| if (this.getPaneAgentForTuiIdle(ptyId) !== 'claude' || !this.headlessTerminals.has(ptyId)) { | ||
| return this.buildTerminalInteractiveWaitEvidence(handle, ptyId, 'not-read') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect creation, hydration, and removal of headless terminal state.
rg -n -C 5 'headlessTerminals\.(set|delete|has)|headlessHydrationState' src/main/runtimeRepository: stablyai/orca
Length of output: 30706
🏁 Script executed:
set -e
printf '%s\n' '--- terminal-wait-permission.ts ---'
nl -ba src/main/runtime/terminal/wait/terminal-wait-permission.ts | sed -n '1,260p'
printf '%s\n' '--- direct callers ---'
rg -n -C 8 -F -- 'readTerminalInteractiveWaitEvidence' src/main/runtime
printf '%s\n' '--- wait status and headless lifecycle declarations ---'
rg -n -C 6 -e 'buildTerminalInteractiveWaitEvidence' -e 'getPaneAgentForTuiIdle' -e 'getTerminalAgentStatusPtyId' -e 'headlessTerminals =|createPtyHeadlessTerminalState|disposeHeadlessTerminal' src/main/runtime/terminal src/main/runtime | sed -n '1,320p'Repository: stablyai/orca
Length of output: 42225
🏁 Script executed:
set -e
printf '%s\n' '--- terminal-interactive-wait.ts ---'
nl -ba src/main/runtime/terminal/wait/terminal-interactive-wait.ts | sed -n '70,190p'
printf '%s\n' '--- getPaneAgentForTuiIdle binding ---'
rg -n -C 10 -F -- 'getPaneAgentForTuiIdle' src/main/runtime
printf '%s\n' '--- headless creation and renderer hydration callers ---'
rg -n -C 12 -e 'trackHeadlessTerminalData\(' -e 'maybeHydrateHeadlessFromRenderer\(' -e 'createPtyHeadlessTerminalState\(' src/main/runtime/terminal src/main/runtime | sed -n '1,360p'
printf '%s\n' '--- changed files and targeted tests ---'
git diff --name-only b947c24bb792682a20ab5c749fcbf07519742ab9 a8ba8821863cdf8868ec48f9b76f2ac1a2eee49d
rg -n -C 8 -e 'unconfirmed' -e 'without.*headless' -e 'headless.*Claude' src/main/runtime/terminal/wait src/main/runtime/*test.ts | sed -n '1,320p'Repository: stablyai/orca
Length of output: 42090
🏁 Script executed:
set -e
printf '%s\n' '--- output ingestion callers and ordering ---'
rg -n -C 18 -e 'trackHeadlessTerminalData\(' -e 'onPtyData|handlePtyData|pty.*data|emitData' src/main/runtime/terminal src/main/runtime/construction src/main/runtime | sed -n '1,420p'
printf '%s\n' '--- PTY registration and launch ordering ---'
rg -n -C 14 -e 'registerPty|ptysById\.set|launchAgent|foregroundAgent' src/main/runtime/terminal/lifecycle src/main/runtime/terminal/launch src/main/runtime | sed -n '1,420p'
printf '%s\n' '--- PR diff for wait implementation and tests ---'
git diff --unified=30 b947c24bb792682a20ab5c749fcbf07519742ab9 a8ba8821863cdf8868ec48f9b76f2ac1a2eee49d -- src/main/runtime/terminal/wait/terminal-wait-permission.ts src/main/runtime/terminal/wait/terminal-interactive-wait.ts src/main/runtime/terminal/*wait*.test.tsRepository: stablyai/orca
Length of output: 42720
🏁 Script executed:
set -e
printf '%s\n' '--- transient reset owner and callers ---'
nl -ba src/main/runtime/terminal/output/terminal-transient-facts.ts | sed -n '1,100p'
rg -n -C 12 -e 'clearTerminalTransientFacts\(' -e 'resetTerminalTransient' -e 'disposeHeadlessTerminal\(' src/main/runtime/terminal src/main/runtime | sed -n '1,360p'
printf '%s\n' '--- PTY registration and data entrypoints ---'
rg -n -C 20 -e 'registerPty\(' -e 'onPtyData\(' -e 'trackHeadlessTerminalData\(' src/main/runtime | sed -n '1,520p'
printf '%s\n' '--- headless map declaration ---'
rg -n -C 8 -F -- 'headlessTerminals' src/main/runtime/terminal/lifecycle src/main/runtime/construction | sed -n '1,220p'Repository: stablyai/orca
Length of output: 42057
Keep an unread Claude screen unconfirmed.
When the pane agent is Claude but headlessTerminals has no entry, pass null instead of 'not-read'. With no explicit status or live working/idle title, this preserves the unknown result instead of returning null.
🐛 Suggested fix
--- "a/src/main/runtime/terminal/wait/terminal-wait-permission.ts"
+++ "b/src/main/runtime/terminal/wait/terminal-wait-permission.ts"
@@ -73,9 +73,12 @@
handle: string,
ptyId: string
): TerminalInteractiveWaitEvidence | Promise<TerminalInteractiveWaitEvidence | undefined> {
- if (this.getPaneAgentForTuiIdle(ptyId) !== 'claude' || !this.headlessTerminals.has(ptyId)) {
+ if (this.getPaneAgentForTuiIdle(ptyId) !== 'claude') {
return this.buildTerminalInteractiveWaitEvidence(handle, ptyId, 'not-read')
}
+ if (!this.headlessTerminals.has(ptyId)) {
+ return this.buildTerminalInteractiveWaitEvidence(handle, ptyId, null)
+ }
return this.readCurrentTerminalWaitScreen(ptyId).then((screen) =>
this.getTerminalAgentStatusPtyId(handle) !== ptyId || screen === undefined
? undefined| (!observedOnScreen || | ||
| terminal.titleStatus !== 'idle' || | ||
| detectExplicitIdleStatusFromTitle(terminal.title ?? '') === 'idle') && |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect how a title becomes live and whether later output invalidates that state.
rg -n -C 5 'titleStatusIsLive|lastOscTitleEpochMs|waitBlockedAt' \
src/main/runtime/runtime-terminal-agent-status-query.ts \
src/main/runtime/terminalRepository: stablyai/orca
Length of output: 25577
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- terminal-wait-permission.ts ---'
nl -ba src/main/runtime/terminal/wait/terminal-wait-permission.ts | sed -n '1,190p'
printf '%s\n' '--- runtime-terminal-agent-status-query.ts ---'
nl -ba src/main/runtime/runtime-terminal-agent-status-query.ts | sed -n '1,245p'
printf '%s\n' '--- title observation definitions and uses ---'
rg -n -C 8 -F -- 'lastOscTitleEpochMs' src/main/runtime
rg -n -C 8 -F -- 'lastAgentStatusObservedLive' src/main/runtime/terminalRepository: stablyai/orca
Length of output: 42034
Confirm that a working title is newer than the dialog before clearing it.
The screen is read before getTerminalWaitPermissionInputs captures the title snapshot. A retained working title can therefore remain live after the screen shows a trust dialog. When the lifecycle status differs from that title, the condition returns null without comparing observation order.
Require a newer title observation, or an equivalent ordering token, before it clears screen-detected dialog evidence.
ELI5
When Claude's "Do you trust this folder?" dialog was on screen,
orca terminal showreported noagentWait, as if Claude were free for input. An agent driving that terminal could then type into the dialog. Now it reports the dialog.What Changed
getTerminalInteractiveWait(theagentWaitfield oforca terminal show) read the terminal's line tail. Claude parks the cursor on the highlighted option inside its dialog, and the line tail drops every row below the cursor ("Yes, I trust this folder", "Enter to confirm"). So the query returnednullwhile the dialog owned the screen. Thetui-idlewait path already reads the rendered screen for this reason (seeclaude-trust-dialog-transcript.test.ts); the interactive-wait query did not.{ reason: 'agent-trust-workspace' }while the dialog is up, andnullonce it's answered.src/main/runtime/terminal/wait/):Why
detectTerminalWaitBlockedReason) that thetui-idlepath already relies on, so both paths agree. It adds no new detector.This is the dialog part of #28187 by @thebestmensch (credited as co-author), ported onto the runtime modules main has since split. It shipped in that draft beside unrelated permission-wait work.
Linked Issue
Related to the Claude workspace-trust portions of #25854 and #25623. It does not close them: they also cover other providers and Claude's Auto Mode confirmation dialog, which this does not detect.
Visual Proof
N/A: there's no UI change. This is a query result, asserted by replaying the captured dialog bytes.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New
src/main/runtime/claude-dialog-interactive-wait.test.tsreplays the existing raw-PTY captures of Claude's trust dialog (wide, narrow, answered) on local and SSH panes. The wide and narrow cases fail on main (expected null to match { reason: 'agent-trust-workspace' }) and pass here. It also covers the read fences: newer output during the read, a fresh working title, a newer working lifecycle, pane exit, and a read that never answers.claude-trust-dialog-transcript,terminal-interactive-wait-visibilityandstale-title-display-surfacespass (81 tests).pnpm tc:nodeandpnpm run check:code-quality:changedpass.AI Disclosure
Review
Codex review (gpt-6.1-sol, high) found no issues.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)