Skip to content

fix(runtime): report Claude's workspace trust dialog from terminal show's agent wait - #29488

Merged
nwparker merged 1 commit into
mainfrom
nwparker/claude-dialog-interactive-wait
Oct 16, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/claude-dialog-interactive-wait

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​115 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​99

ELI5

When Claude's "Do you trust this folder?" dialog was on screen, orca terminal show reported no agentWait, 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

  • Before: getTerminalInteractiveWait (the agentWait field of orca 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 returned null while the dialog owned the screen. The tui-idle wait path already reads the rendered screen for this reason (see claude-trust-dialog-transcript.test.ts); the interactive-wait query did not.
  • After: for Claude panes the query returns { reason: 'agent-trust-workspace' } while the dialog is up, and null once it's answered.
  • Mechanism (src/main/runtime/terminal/wait/):
    • For a Claude pane with a headless emulator, the query reads the rendered screen and checks it for blocking prompts. The read is bounded by the existing 2 s probe timeout.
    • The query answers "unknown" rather than "no wait" when the pane exits or its generation changes during the read. It does the same when the screen can't be read and nothing else (a hook status, or a live working/explicit idle title) rules a dialog out.
    • A dialog seen on the rendered screen stands unless a newer working or explicit-idle signal clears it. A plain "Claude Code" title is not taken as proof that the dialog was answered.
    • Other agents keep the synchronous path, so concurrent queries still share one hook-status probe.

Why

  • This reuses the rendered-screen reader and the existing dialog detector (detectTerminalWaitBlockedReason) that the tui-idle path already relies on, so both paths agree. It adds no new detector.
  • Reading the screen only for Claude keeps the extra async read off every other agent's query.

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.ts replays 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-visibility and stale-title-display-surfaces pass (81 tests). pnpm tc:node and pnpm run check:code-quality:changed pass.

AI Disclosure

Review

Codex review (gpt-6.1-sol, high) found no issues.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: the runtime owns the pane's emulator for local and SSH panes alike, and the test runs both.
  • Interaction: no keys are sent to the dialog.
  • Wire: no change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…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]>
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The runtime now reads bounded, current screen evidence when resolving interactive waits for Claude headless terminals. It combines screen contents with explicit status and lifecycle evidence. The wait query returns undefined when evidence is unavailable or remains unconfirmed. New tests cover captured workspace-trust dialogs on local and SSH connections, stale reads, newer state, and read timeouts.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to a8ba8

The wait query can miss a workspace-trust dialog, including when a stale working title overrides the current screen. Correct these evidence-handling paths before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed 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 2 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the runtime fix for reporting Claude's workspace-trust dialog through the terminal agent-wait query.
Description check Passed The description is complete and focused. It explains the user-visible problem, implementation, rationale, linked issues, testing, SSH coverage, and the lack of UI changes. Some full checklist commands…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · 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: c84125df-a927-4f4e-8aaf-606e46e249a4
📥 Commits

Reviewing files that changed from the base of the PR and between adce59a and a8ba882.

📒 Files selected for processing: 4
  • src/main/runtime/claude-dialog-interactive-wait.test.ts
  • src/main/runtime/terminal/output/terminal-visible-state.ts
  • src/main/runtime/terminal/wait/terminal-interactive-wait.ts
  • src/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.

Comment on lines +76 to +77
if (this.getPaneAgentForTuiIdle(ptyId) !== 'claude' || !this.headlessTerminals.has(ptyId)) {
return this.buildTerminalInteractiveWaitEvidence(handle, ptyId, 'not-read')

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.

🎯 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/runtime

Repository: 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.ts

Repository: 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

Comment on lines +136 to +138
(!observedOnScreen ||
terminal.titleStatus !== 'idle' ||
detectExplicitIdleStatusFromTitle(terminal.title ?? '') === 'idle') &&

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.

🩺 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/terminal

Repository: 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/terminal

Repository: 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.

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