Skip to content

fix(terminal-wait): unattended launches report Claude's trust dialog instead of timing out or typing into it - #22927

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/blocked-prompt-rendered-screen
Sep 28, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/blocked-prompt-rendered-screen

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​713 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​702
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​376 $\color{#cf222e}{\Huge{\mathbf{−}}}$​298 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78

ELI5

When Orca starts Claude by itself (an orchestration worker, a launch from the CLI or the phone, or an automation) in a folder Claude has never seen, Claude first asks "Do you trust this folder?". Orca waits for Claude to be ready and then types the task in. Before this change, Orca either missed the question and gave up after its whole time budget, or, for people whose shell puts the command name in the terminal title, decided Claude was ready and typed the task straight into the question. Pressing Enter there picks "No, exit" and Claude quits. Now Orca looks at the screen the way the user sees it, reports "this launch is waiting on you" within a few seconds, and never types into the question.

What Changed

Before: an unattended Claude launch into an untrusted folder either waited out its whole budget and failed with timeout, or, for oh-my-zsh and fish users, typed its brief into the trust dialog. oh-my-zsh sets the terminal title to claude when the command starts and fish sets it to claude ~/path; Orca took that bare name as "Claude is idle", and Enter on the dialog's default answer made Claude exit.

After: the launch stops as blocked with agent-trust-workspace within a few seconds and leaves the dialog untouched for the user to answer. Once the user picks "Yes", the same wait reports Claude as ready. A working Claude whose output quotes the dialog's wording on screen is not reported as blocked; the existing line-tail check is unchanged and still applies at every rank.

Mechanism: every place that can settle a tui-idle wait now asks one evaluator (evaluateTuiIdle in src/main/runtime/tui-idle-evidence.ts) for a verdict instead of combining checks itself. The verdicts, in rank order:

  • blocked: the line-by-line record of the terminal (the "tail") shows a prompt waiting on the user.
  • strong ready: the agent says it is ready itself, with its own idle title (Claude's ✳, Codex ready) or a known ready screen. Muse's ready screen after a quiet period keeps this rank.
  • working: a fresh first-party status or a working title. Nothing settles, and the screen is not read.
  • weak ready: a title that is only the agent's name, or a quiet non-shell foreground process. This evidence cannot see a dialog the tail lost.
  • pending: none of the above yet.

The checks that run the moment a wait is registered, and the resolvers that run when a terminal title changes (including the path that restores a title after an exit probe), settle only on blocked or strong ready. The 2-second poll is the only place a weak ready can settle, and only after it reads the runtime's own rendered screen and finds no blocking prompt; if the screen shows one, the wait resolves blocked. When a wait is registered on a pane that already has weak evidence, the poll does this screen read at once rather than a tick later.

A name-only Claude title (claude, claude ~/path) now needs the pane to go quiet first, the same rule Codex and Devin already had, because Claude announces rest with its own ✳ title. This is an extension of the existing "does this agent's bare name need corroboration" rule, not a new check.

Weak ready is a verdict class, not a property of one piece of evidence, so a future readiness signal added as a weak-ready rank can only ever settle on the poll after the screen read. A test injects such a signal that fires over the dialog itself and checks the wait still reports blocked.

The tail still loses Claude's dialog: its cursor-up handling drops the rows below the cursor, and lines ending in \r\r\n come out blank. This PR does not change the tail; the screen read is what sees the dialog.

Timing changes:

  • Claude with its own titles turned off, under a shell that auto-titles, now reports ready about 3 to 5 seconds after it goes quiet (the quiet window plus up to one poll tick) instead of at once.
  • Agents whose only rest signal is their name (Grok, Copilot, Aider and similar) can take up to 2 seconds longer when their name title arrives after the wait started, because the title-change resolver now leaves them to the poll. A wait registered on a pane that already shows the name settles after one screen read.
  • Claude with its ✳ title is still ready at once.

Ordering choice: the agent's own idle title outranks dialog wording on the rendered screen. The blocked-prompt rules are not scoped to a region of the screen, so wording anywhere on a finished agent's screen would otherwise read as blocked. A name-only title does not get this protection: under it, dialog wording on the screen resolves blocked.

Side effects in shared code:

  • Queued-message delivery reads the same ranking without the blocked check (unchanged), so a Claude pane showing only a shell's name title now also waits for the quiet window before a queued message is delivered.
  • A title-change resolver that finds a blocking prompt in the tail now resolves the wait as blocked, matching what the registration check and the poll already did.
  • The poll now also reads the rendered screen for a pane with no verdict yet (no title, a name title still inside its quiet window, or a first-party blocked or waiting status). Before, the poll checked only the tail there, so dialog wording in the bottom rows of such a pane's screen, including one still producing output with no working title or status, now resolves blocked where the wait used to keep going. Agents that report working through a title or first-party status are unaffected.

Why

  • One evaluator instead of four copies. The same pane was ranked at four sites that had drifted: the title-change resolvers checked no blocked evidence at all, and the poll checked readiness before the screen. The shell auto-title bug could settle at any of them. Putting the ranking in one place, and letting sites branch only on the verdict, removes the class of bug instead of patching each site.
  • The screen is what the user sees. The tail is a lossy line record; the runtime already keeps its own terminal emulator for every pane, in the same process, so reading it costs no host round trip, nothing extra over SSH, and nothing on the per-output path.
  • Rejected: match a phrase the tail happens to keep. An earlier revision matched "one you trust" from the opening question. In real 1024-byte reads that line is blanked, a narrow pane wraps the phrase, and the phrase can match ordinary prose.
  • Rejected: make the tail terminal-faithful. That is the root of the loss, but every text rule was tuned against the current tail; trying it broke three Antigravity ready-screen transcript tests. It stays a follow-up.
  • Rejected: the screen check alone. The previous revision read the screen on the poll, but a name-only title settled the wait before the poll ever ran, at registration, in the title-change resolvers, or earlier in the same poll tick. That is how oh-my-zsh and fish users still got their brief typed into the dialog.
  • This does not pre-trust the folder for Claude; whether it should is a separate product decision.

Follow-ups (not in this PR)

  1. Queued-message delivery (isAgentSettledForDelivery) uses the same ranking with no blocked check and then sends Enter, so it can still answer "No, exit" on a trust dialog. It is edge-driven with no poll behind it and cannot do an async screen read; adding the tail check alone would spin its recheck timer on a lingering prompt. Highest priority.
  2. resolveAuthoritativeTerminalWaitPermission lets a title outrank blocked body text.
  3. A start-up grace period, or a "painted after the title" rule, for other name-only agents.
  4. Scope the blocked-prompt rules to a screen region, then revisit the strong-ready-over-screen ordering.
  5. Fix the tail's \r\r\n blanking and its cursor-up row deletion.
  6. Other readers of blocked state: status queries, the sidebar, mobile. Live QA showed the sidebar row reading "Claude Code · Idle" while the trust dialog was up, on main and on this PR alike.
  7. Terminal snapshot restore leaks the normal screen's text style into the full-screen (alternate) screen. Orca's patch to the terminal serialize add-on ends every saved buffer with the live colour/bold pen and then switches to the alternate screen, so a restored full-screen pane can show a wrong background on blank cells and bold text until the program redraws. Evidence: minimal repro ESC[?1049h█ESC[1m at 20x5; a reset before ESC[?1049h takes the answered Claude capture from 13 to 9 round-trip mismatches, less 6→0, nano 2→0, opencode 5→2. The fix changes the add-on patch, so it needs its own PR with the lockfile update.
  8. A full-screen buffer first entered after the pane was shrunk keeps hidden scrollback (the terminal core skips its length shrink while the buffer is empty), and the serializer writes that buffer from its first line, so a restored screen can land a row or more lower. Evidence: 20x6 → 20x5, then ESC[?1049h ESC[5;1H A LF B ESC[H, then back to 20x6; accounts for the other 9 mismatches. This is a terminal-core fix for its own PR.

This PR adds a captured Claude transcript that the serializer round-trip suite also replays; it exposes items 7 and 8. Both diverge identically on main and on the add-on build from before #22586 (13 mismatches on both, 0 regressions), so the suite pins that count the same way it already does for less, nano and opencode.

Linked Issue

No tracking issue. Found during live QA of an unattended Claude launch into a fresh folder.

Visual Proof

Live QA of this revision (ac12fa3c37) against its base on main (acf8e679ea): the Orca desktop app launched hidden on a separate Mac, Claude Code 2.1.283, a fresh untrusted folder per run, and the shell's title set either by a stock oh-my-zsh install (default auto-title) or by a plain zsh. Each build was confirmed from its compiled main bundle before its runs.

Run main this PR
oh-my-zsh shell, orca terminal wait --for tui-idle reported ready in ~3 s with the trust dialog on screen blocked agent-trust-workspace in ~2 s, dialog untouched
oh-my-zsh shell, unattended worker start the task was submitted into the dialog; Claude took "No, exit" and quit to the shell Agent startup blocked: agent-trust-workspace; the dialog is still up, untouched
plain zsh, orca terminal wait --for tui-idle timeout after 60 s blocked agent-trust-workspace in ~2 s, dialog untouched

Unattended worker start under oh-my-zsh — main (Claude has already exited to the shell prompt below the dialog):

before-omz-B.jpg

The same start with this PR (reported blocked; the dialog waits for the user):

after-omz-B.jpg

Readiness-wait screenshots (oh-my-zsh and plain zsh, both builds)

main, oh-my-zsh (wait said ready):

before-omz-A.jpg

This PR, oh-my-zsh (wait said blocked):

after-omz-A.jpg

main, plain zsh (wait timed out):

before-plain-A.jpg

This PR, plain zsh (wait said blocked):

after-plain-A.jpg

fish was not installed on the QA machine, so the fish title is covered by the transcript tests only. Windows, WSL and SSH were not run live; the screen check reads the app's own in-process terminal emulator, which every pane kind feeds.

Testing

  • I manually tested these changes locally (live Electron QA of this revision on a separate Mac; see Visual Proof)
  • Automated tests added/updated, or explained why not below

claude-trust-dialog-transcript.test.ts replays live Claude Code 2.1.280 captures through the real runtime and its tui-idle wait:

  • the dialog in one chunk, in 1024-byte reads, and on a 60-column pane: blocked agent-trust-workspace
  • the dialog answered "Yes": ready, with no blocked reason
  • a working Claude quoting the dialog's wording: not blocked
  • new, with fake timers: the oh-my-zsh title sequence (command line as OSC 2, then claude as OSC 1) followed by the dialog, with the wait registered after the pane went quiet: blocked, never ready
  • new: the oh-my-zsh or fish title arriving before the dialog paints, with a poll tick in between (the fish case goes through the title-change resolver, asserted): blocked, never ready
  • new: the exit-probe restore path offering the name-only title again (asserted): blocked, never ready
  • new: the answered capture under the oh-my-zsh titles: ready at once from Claude's ✳ title
  • new: the answered capture with Claude's own titles stripped: not ready before the quiet window, ready after it

tui-idle-weak-evidence-seam.test.ts (new) replaces the evaluator with one that adds a synthetic weak-ready signal firing over the dialog itself: a wait registered after the dialog, and one offered the signal through a title change before the dialog paints, both resolve blocked; a control case with nothing on screen resolves ready, proving the signal reaches the settle sites.

runtime-terminal-idle-polls.test.ts: Grok, Copilot and Aider name-only titles settle only after the screen read comes back clear; a dialog on screen under a name-only title resolves blocked; an agent's own idle title settles without reading the screen. tui-idle-evidence.test.ts covers the rank order and the corroboration rule, including claude ~/p/repo.

Existing specs changed: in tui-idle-evidence.test.ts the two existing Muse cases now assert verdicts (ready-strong, working) instead of the removed isTuiIdleSatisfied boolean's true/false; same outcomes. The createPolls helper in runtime-terminal-idle-polls.test.ts gained an optional agent argument. No other existing expectation changed.

Ablation (part removed, focused suites run, part restored):

Removed Result
all of this commit (source files at the previous head, new tests kept) 5 of the new transcript tests fail: every shell auto-title case settles ready
registration checks and title resolvers refusing weak ready 3 fail: the quiet-pane oh-my-zsh case and both dialog cases of the seam test
the screen read before a weak ready in the poll 7 fail: the quiet-pane oh-my-zsh case, the four name-only poll tests, both dialog cases of the seam test
the Claude corroboration 6 fail: both title-before-dialog cases, the titles-off case, three evidence unit tests

The title-resolver half of the first guard is caught only by the seam test: with real Claude evidence the title arrives before the pane is quiet, so it is never weak at that moment.

Gates: pnpm tc:node, full-file pnpm exec oxlint on the changed files, and pnpm run check:code-quality:changed -- origin/main pass. 30 related vitest files pass (1634 tests): the tui-idle, terminal-wait, idle-poll, transcript, delivery, automation run observer, orchestration worker-start and federation suites, and the runtime characterization suite orca-runtime.test.ts.

Platforms: macOS unit and transcript tests only. The screen read is the runtime's own in-process emulator, fed by the same output path for local, SSH, WSL and Windows panes, and nothing here depends on git, so folder workspaces are unaffected. A pane whose output never reaches the runtime has no screen model; there a weak ready still settles without a screen read, as before.

AI Disclosure

Review

@brennanb2025 brennanb2025 changed the title fix(terminal-wait): recognise Claude's workspace trust dialog as a blocking prompt fix(terminal-wait): unattended launches report Claude's trust dialog instead of timing out or typing into it Sep 26, 2026
@brennanb2025

brennanb2025 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status

Verdict: ready for a human review; CI is green at 83aa3aa98f. The code was clean on the last review pass, the end-of-review readiness checklist passed with no blocking items, and live QA passed.

What happened during review

  • The original change (match the phrase "one you trust") did not fix the real launch. When Claude's output arrives in real-sized reads (13–1024 bytes), the host's line record blanks the dialog's lines, and a cursor-up deletes the option lines, so a real launch still timed out. The PR's first test passed only because it fed the transcript as one chunk. That change is reverted.
  • The fix was replaced with a check of the rendered screen, which is the app's own in-process terminal emulator and costs no network round trip. It runs on the 2-second readiness poll, and never while the agent reports that it is working.
  • Review then found a second, older way to type into the dialog that main also has. When the shell names the pane after the running command (the oh-my-zsh default and the fish default), a bare claude title counted as "ready" and settled the wait before anything looked at the screen. With the author's approval the PR was widened to fix it. Every place a readiness wait can settle now asks one ranked evaluator. A title that is only the agent's name counts as weak evidence, and weak evidence can settle only on the poll, after the screen shows no dialog.
  • Four review loops ran, plus one separate architecture review after the third loop. Each of the first three loops found a real defect, and each was fixed. The fourth loop found no code problems and only tightened two lines of the body.

Live QA (this revision against main, on a separate Mac, Claude Code 2.1.283)

  • oh-my-zsh shell: main reported ready with the dialog up, and an unattended worker start then pressed Enter on "No, exit", so Claude quit. This PR reports agent-trust-workspace in about 2 s and leaves the dialog untouched.
  • Plain zsh: main timed out after 60 s. This PR reports blocked in about 2 s.
  • Control: a name-only agent (Grok) in a trusted folder still reports ready in about 1 s under both shells, and is never reported blocked.
  • fish was not installed on the QA machine; the transcript tests cover its title. Windows, WSL and SSH were not run live.
  • Screenshots are in the PR body under Visual Proof.

Gates at ac12fa3c37

pnpm tc:node, full-file oxlint on the changed files, and check:code-quality:changed pass. The related runtime, wait, poll, transcript, automation and orchestration suites pass. Four failures in a broad run were in files this PR does not touch: three timeouts while the machine's load average was about 80, and one caused by the reviewer's shell environment. They were not re-run against main.

Ablation: removing each part of the fix makes its tests fail. Numbers in the body.

CI (updated for 83aa3aa98f, rebased onto main 89cf55dfc8)

Every check has concluded: 31 passed, 14 skipped, none failed. That includes all eight test shards, verify and typecheck.

  • Rebase onto main. The only conflict was with fix(runtime): read Codex readiness from the live screen #23475 (read Codex readiness from the live screen), which added a Codex-header screen check as extra "ready" evidence at the same readiness sites this PR reworked. That check now feeds the ready-prompt evidence of this PR's single evaluator, so all six readiness sites and queued-message delivery get it. It still reads the screen only for Codex or unidentified panes. The serializer test keeps main's four Codex 0.157 entries alongside this PR's Claude entry. The typecheck, oxlint, the changed-code quality check and the targeted evaluator, poll, Claude/Codex transcript and serializer suites passed before the push.
  • Serializer round-trip replay. The answered Claude trust capture this PR adds diverges at 13 checkpoints, identically on main and on the add-on build from before fix(terminal): serialize only the visible width after a column shrink #22586, because of two existing serializer gaps (follow-ups 7 and 8 in the PR body). The suite pins that verified count, as it already does for less, nano, opencode and the Codex captures.
  • Not caused by this PR, both since resolved: the hook-order parity test failed on clean main until main re-pinned it (test(terminal): re-pin the pane hook-order parity past #23049 #23090), and worktrees-removal-recovery.test.ts failed once and then passed with no related change.

Findings not caused by this PR (already on main)

  • The sidebar showed "Claude Code · Idle" while the trust dialog was up, on main and on this PR alike. The sidebar and other status readers still use the old evidence. This is follow-up 6 in the body.
  • Queued-message delivery ignores blocked prompts, and can press Enter on a trust dialog. This is follow-up 1 and the highest priority. It should land before or together with the planned "bracketed paste means input-ready" change, because delivery treats weak evidence as ready without reading the screen.
  • The host's line record blanks lines that end in \r\r\n and deletes rows below a cursor-up. This affects orca terminal read and every reader built on it (follow-up 5).
  • Claude's first-use bypass-permissions dialog matches no blocked-prompt rule. This is unverified and needs a recorded transcript.

Known limits introduced here (in the body)

  • Agents whose title is only their name (Grok, Copilot, Aider) can take up to 2 s longer to report ready.
  • Claude with its own titles turned off, under an auto-titling shell, takes about 3–5 s.
  • A pane with no working signal now also has its visible screen checked for dialog wording. Main's line-record check already had nearly the same exposure.
  • The screen read has no time limit of its own. If it ever hung, a weak-evidence wait would run to its timeout. Blocked and strong-ready results are unaffected.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/blocked-prompt-rendered-screen branch from 3a0aad2 to 9248249 Compare September 26, 2026 05:42
@brennanb2025
brennanb2025 marked this pull request as ready for review September 26, 2026 05:43
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

TUI-idle evaluation now returns ranked verdicts for blocked, ready, working, and pending states. Runtime wait resolution and polling use shared leaf and PTY evidence. Polling checks rendered-screen text for blocked prompts before settling weak-ready waits. New Claude trust-dialog captures and tests cover visible and answered dialogs, narrow panes, title changes, and idle readiness.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 83aa3

Unattended launches can still be reported ready while Claude is blocked by a trust prompt or has resumed working. Resolve these readiness paths before merging.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 83aa3

A screen check can begin while a terminal appears ready, then finish after the terminal has become busy or blocked. The wait may still report ready, so the protection against sending a task at the wrong time is not complete.

Retained concerns

  • Medium · security · inferred: An in-flight screen read can settle a wait using a weak-ready verdict captured before the terminal transitioned to working or blocked.
Security review details

Security Blast Radius

  • inferred — The affected boundary is terminal-wait readiness for unattended launches, including PTY waits; the evidence does not establish a new cross-service or privileged-resource boundary.

Security Findings and Attack Paths

  • inferred — If terminal state changes while the screen read is pending, a clear returned snapshot and the stale weak-ready verdict can produce a ready result despite the current working or blocked state. Whether this interleaving reaches task input was not directly verified.

Trust Boundaries and Controls

  • observed — Tail blockers take precedence in the shared evaluator, and a blocker found in an available rendered-screen read settles the wait as blocked. Neither control rechecks readiness after that asynchronous read.

Hardening Proposals

  • proposed — Before settling weak-ready after an asynchronous read, re-evaluate live readiness and blocker evidence, and make the behavior for an unavailable screen explicit rather than equating it with a clear screen.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: preventing unattended Claude launches from mishandling the workspace trust dialog.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, platform scope, limitations, and follow-ups. It does not provide a linked issue and leaves the…
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

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7c74752b-06b7-453d-a155-94f0bc92266c

📥 Commits

Reviewing files that changed from the base of the PR and between f0a3610 and 9248249.

📒 Files selected for processing (19)
  • src/main/daemon/serialize-grid-transcript-replay.test.ts
  • src/main/runtime/__fixtures__/claude-dialog-trust-workspace-answered.meta.json
  • src/main/runtime/__fixtures__/claude-dialog-trust-workspace-answered.txt
  • src/main/runtime/__fixtures__/claude-dialog-trust-workspace-narrow.meta.json
  • src/main/runtime/__fixtures__/claude-dialog-trust-workspace-narrow.txt
  • src/main/runtime/__fixtures__/claude-dialog-trust-workspace.meta.json
  • src/main/runtime/__fixtures__/claude-dialog-trust-workspace.txt
  • src/main/runtime/agent-transcript-pane-test-harness.ts
  • src/main/runtime/claude-trust-dialog-transcript.test.ts
  • src/main/runtime/orca-runtime-apply-tracked-pty-title.ts
  • src/main/runtime/orca-runtime-resolve-exit-waiters.ts
  • src/main/runtime/orca-runtime-runtime-id.ts
  • src/main/runtime/runtime-terminal-idle-polls.test.ts
  • src/main/runtime/runtime-terminal-idle-polls.ts
  • src/main/runtime/runtime-terminal-wait.ts
  • src/main/runtime/terminal-wait-name-only-idle.test.ts
  • src/main/runtime/tui-idle-evidence.test.ts
  • src/main/runtime/tui-idle-evidence.ts
  • src/main/runtime/tui-idle-weak-evidence-seam.test.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.

Comment on lines +143 to +189
private async tick(entry: IdlePollEntry): Promise<void> {
if (!this.entries.has(entry)) {
return
}
const { waiter, pty } = entry
// Why no re-read here: `ptysById` has a single create-once `set` site, so PTY
// records are mutated in place rather than swapped, and a capture stays live.
const agent = this.deps.getPaneAgent(pty.ptyId)
let startedForegroundPoll = false
try {
const waitText = buildTerminalWaitText(pty.tailBuffer, pty.tailPartialLine, pty.preview)
const blockedReason = detectTerminalWaitBlockedReason(waitText)
if (blockedReason) {
this.stop(entry)
this.deps.resolve(
waiter,
buildPtyTerminalWaitBlockedResult(waiter.handle, 'tui-idle', pty, blockedReason)
)
const sample = this.sample(entry)
const { verdict, ptyId } = sample
if (verdict.kind === 'blocked') {
this.settle(entry, sample.blocked(verdict.reason))
return
}
if (
isTuiIdleSatisfied({
record: pty,
readPositiveBodyEvidence: () =>
this.deps.getAdoptedPtyIdleStatus(pty) === 'idle' ||
isKnownReadyPromptPreview(waitText),
readMuseReadyBodyEvidence: () => isMuseReadyPromptPreview(waitText),
agent,
firstPartyStatus: this.deps.getFirstPartyAgentStatus(pty.ptyId),
quiescenceMs: this.deps.quiescenceMs
})
) {
this.stop(entry)
this.deps.resolve(waiter, buildPtyTerminalWaitResult(waiter.handle, 'tui-idle', pty))
// Why strong ready outranks the screen: the detector is not scoped to a region, so dialog
// wording anywhere on a finished agent's screen would otherwise read as blocked.
if (verdict.kind === 'ready-strong') {
this.settle(entry, sample.ready())
return
}
if (
pty.lastAgentStatus === null &&
quietForegroundProcessProvesTuiIdle(agent) &&
!entry.foregroundPollInFlight
) {
const foregroundRead = this.deps.getForegroundProcess(pty.ptyId)
// Why no screen read while working: its output can quote dialog wording (a diff of this
// detector), and the dialogs only the screen shows are start-up ones, painted before any title.
if (verdict.kind === 'working' || entry.screenReadInFlight) {
return
}
const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
// Why await only a real read: a pane with no screen model keeps its tick synchronous.
const screenBlockedReason = screenRead ? await screenRead : null
if (!this.entries.has(entry)) {
return
}
if (screenBlockedReason) {
this.settle(entry, sample.blocked(screenBlockedReason))
return
}
if (verdict.kind === 'ready-weak') {
this.settle(entry, sample.ready())
return
}
if (verdict.quietForeground && ptyId && !entry.foregroundPollInFlight) {
const foregroundRead = this.deps.getForegroundProcess(ptyId)
if (!foregroundRead) {
return
}
entry.foregroundPollInFlight = true
startedForegroundPoll = true
const foreground = await foregroundRead
if (
foreground &&
!isShellProcess(foreground) &&
isQuietForQuiescence(pty.lastOutputAt, this.deps.quiescenceMs)
) {
this.stop(entry)
this.deps.resolve(waiter, buildPtyTerminalWaitResult(waiter.handle, 'tui-idle', pty))
if (foreground && !isShellProcess(foreground) && sample.isQuiet()) {
this.settle(entry, sample.ready())

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:

sed -n '80,225p' src/main/runtime/runtime-terminal-idle-polls.ts
sed -n '190,350p' src/main/runtime/runtime-terminal-idle-polls.test.ts

Repository: stablyai/orca

Length of output: 12209


🏁 Script executed:

set -eu
cat -n src/main/runtime/runtime-terminal-idle-polls.ts | sed -n '1,280p'
rg -n --glob '*.ts' 'evaluateTuiIdle|TuiIdleVerdict|ptyTuiIdleEvidence|leafTuiIdleEvidence|readVisibleScreen|startPty|startLeaf|agent-trust-workspace|blockedReason|tui-idle' src
git diff --unified=35 f0a36109285e7bd90c0e8452c439de12a991a02a 92482496be5d2e50c67d1ac4e89c449e1735652d -- src/main/runtime/runtime-terminal-idle-polls.ts src/main/runtime/runtime-terminal-idle-polls.test.ts | sed -n '1,500p'

Repository: stablyai/orca

Length of output: 41589


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 41060


🏁 Script executed:

set -eu
printf '%s\n' '--- tui-idle-evidence.ts ---'
cat -n src/main/runtime/tui-idle-evidence.ts
printf '%s\n' '--- screen reader bindings ---'
rg -n -C 8 'readVisibleScreen\s*[:=]|readVisibleScreen\(' src/main src/shared
printf '%s\n' '--- idle poll callers ---'
rg -n -C 10 '\.startPty\(|\.startLeaf\(|new RuntimeTerminalIdlePolls|evaluateTuiIdle\(' src/main/runtime src/main
printf '%s\n' '--- contracts and detection ---'
cat -n src/shared/runtime-types.ts | sed -n '320,370p'
cat -n src/main/runtime/terminal-wait-detection.ts | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 42593


🏁 Script executed:

set -eu
cat -n src/main/runtime/tui-idle-evidence.ts
rg -n -C 8 'readVisibleScreen\s*[:=]|readVisibleScreen\(' src/main src/shared
rg -n -C 10 '\.startPty\(|\.startLeaf\(|new RuntimeTerminalIdlePolls|evaluateTuiIdle\(' src/main/runtime src/main
cat -n src/shared/runtime-types.ts | sed -n '320,370p'
cat -n src/main/runtime/terminal-wait-detection.ts | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 42488


🏁 Script executed:

set -eu
printf '%s\n' '--- callers ---'
rg -n -l 'startPty|startLeaf|RuntimeTerminalIdlePolls' src/main --glob '*.ts' | while read -r f; do
  echo "### $f"
  rg -n -C 8 'startPty|startLeaf|RuntimeTerminalIdlePolls' "$f"
done
printf '%s\n' '--- visible-screen bindings ---'
rg -n -l 'readVisibleScreen|visibleScreen|screen\.lines|headless' src/main/runtime --glob '*.ts' | while read -r f; do
  echo "### $f"
  rg -n -C 10 'readVisibleScreen|visibleScreen|screen\.lines|headless' "$f"
done

Repository: stablyai/orca

Length of output: 45652


🏁 Script executed:

set -eu
rg -n -l 'startPty|startLeaf|RuntimeTerminalIdlePolls' src/main --glob '*.ts' | while read -r f; do
  echo "### $f"
  rg -n -C 8 'startPty|startLeaf|RuntimeTerminalIdlePolls' "$f"
done
rg -n -l 'readVisibleScreen|visibleScreen|screen\.lines|headless' src/main/runtime --glob '*.ts' | while read -r f; do
  echo "### $f"
  rg -n -C 10 'readVisibleScreen|visibleScreen|screen\.lines|headless' "$f"
done

Repository: stablyai/orca

Length of output: 45652


Re-sample the verdict after the screen read completes.

A ready-weak tick captures verdict before awaiting readVisibleScreen. The membership check only handles cancellation. If the agent becomes working or the tail gains a blocking prompt while the read is pending, a clear screen result still reaches the old verdict.kind === 'ready-weak' branch and reports readiness. This can report tui-idle while the prompt owns the screen.

Suggested fix
       if (!this.entries.has(entry)) {
         return
       }
+      const currentSample = this.sample(entry)
+      const currentVerdict = currentSample.verdict
+      if (currentVerdict.kind === 'blocked') {
+        this.settle(entry, currentSample.blocked(currentVerdict.reason))
+        return
+      }
+      if (currentVerdict.kind === 'ready-strong') {
+        this.settle(entry, currentSample.ready())
+        return
+      }
+      if (currentVerdict.kind === 'working') {
+        return
+      }
       if (screenBlockedReason) {
-        this.settle(entry, sample.blocked(screenBlockedReason))
+        this.settle(entry, currentSample.blocked(screenBlockedReason))
         return
       }
-      if (verdict.kind === 'ready-weak') {
-        this.settle(entry, sample.ready())
+      if (currentVerdict.kind === 'ready-weak') {
+        this.settle(entry, currentSample.ready())
         return
       }
-      if (verdict.quietForeground && ptyId && !entry.foregroundPollInFlight) {
-        const foregroundRead = this.deps.getForegroundProcess(ptyId)
+      if (currentVerdict.quietForeground && currentSample.ptyId && !entry.foregroundPollInFlight) {
+        const foregroundRead = this.deps.getForegroundProcess(currentSample.ptyId)
         if (!foregroundRead) {
           return
         }
         entry.foregroundPollInFlight = true
         startedForegroundPoll = true
         const foreground = await foregroundRead
-        if (foreground && !isShellProcess(foreground) && sample.isQuiet()) {
-          this.settle(entry, sample.ready())
+        if (foreground && !isShellProcess(foreground) && currentSample.isQuiet()) {
+          this.settle(entry, currentSample.ready())
         }
       }
📝 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 change
private async tick(entry: IdlePollEntry): Promise<void> {
if (!this.entries.has(entry)) {
return
}
const { waiter, pty } = entry
// Why no re-read here: `ptysById` has a single create-once `set` site, so PTY
// records are mutated in place rather than swapped, and a capture stays live.
const agent = this.deps.getPaneAgent(pty.ptyId)
let startedForegroundPoll = false
try {
const waitText = buildTerminalWaitText(pty.tailBuffer, pty.tailPartialLine, pty.preview)
const blockedReason = detectTerminalWaitBlockedReason(waitText)
if (blockedReason) {
this.stop(entry)
this.deps.resolve(
waiter,
buildPtyTerminalWaitBlockedResult(waiter.handle, 'tui-idle', pty, blockedReason)
)
const sample = this.sample(entry)
const { verdict, ptyId } = sample
if (verdict.kind === 'blocked') {
this.settle(entry, sample.blocked(verdict.reason))
return
}
if (
isTuiIdleSatisfied({
record: pty,
readPositiveBodyEvidence: () =>
this.deps.getAdoptedPtyIdleStatus(pty) === 'idle' ||
isKnownReadyPromptPreview(waitText),
readMuseReadyBodyEvidence: () => isMuseReadyPromptPreview(waitText),
agent,
firstPartyStatus: this.deps.getFirstPartyAgentStatus(pty.ptyId),
quiescenceMs: this.deps.quiescenceMs
})
) {
this.stop(entry)
this.deps.resolve(waiter, buildPtyTerminalWaitResult(waiter.handle, 'tui-idle', pty))
// Why strong ready outranks the screen: the detector is not scoped to a region, so dialog
// wording anywhere on a finished agent's screen would otherwise read as blocked.
if (verdict.kind === 'ready-strong') {
this.settle(entry, sample.ready())
return
}
if (
pty.lastAgentStatus === null &&
quietForegroundProcessProvesTuiIdle(agent) &&
!entry.foregroundPollInFlight
) {
const foregroundRead = this.deps.getForegroundProcess(pty.ptyId)
// Why no screen read while working: its output can quote dialog wording (a diff of this
// detector), and the dialogs only the screen shows are start-up ones, painted before any title.
if (verdict.kind === 'working' || entry.screenReadInFlight) {
return
}
const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
// Why await only a real read: a pane with no screen model keeps its tick synchronous.
const screenBlockedReason = screenRead ? await screenRead : null
if (!this.entries.has(entry)) {
return
}
if (screenBlockedReason) {
this.settle(entry, sample.blocked(screenBlockedReason))
return
}
if (verdict.kind === 'ready-weak') {
this.settle(entry, sample.ready())
return
}
if (verdict.quietForeground && ptyId && !entry.foregroundPollInFlight) {
const foregroundRead = this.deps.getForegroundProcess(ptyId)
if (!foregroundRead) {
return
}
entry.foregroundPollInFlight = true
startedForegroundPoll = true
const foreground = await foregroundRead
if (
foreground &&
!isShellProcess(foreground) &&
isQuietForQuiescence(pty.lastOutputAt, this.deps.quiescenceMs)
) {
this.stop(entry)
this.deps.resolve(waiter, buildPtyTerminalWaitResult(waiter.handle, 'tui-idle', pty))
if (foreground && !isShellProcess(foreground) && sample.isQuiet()) {
this.settle(entry, sample.ready())
private async tick(entry: IdlePollEntry): Promise<void> {
if (!this.entries.has(entry)) {
return
}
let startedForegroundPoll = false
try {
const sample = this.sample(entry)
const { verdict, ptyId } = sample
if (verdict.kind === 'blocked') {
this.settle(entry, sample.blocked(verdict.reason))
return
}
// Why strong ready outranks the screen: the detector is not scoped to a region, so dialog
// wording anywhere on a finished agent's screen would otherwise read as blocked.
if (verdict.kind === 'ready-strong') {
this.settle(entry, sample.ready())
return
}
// Why no screen read while working: its output can quote dialog wording (a diff of this
// detector), and the dialogs only the screen shows are start-up ones, painted before any title.
if (verdict.kind === 'working' || entry.screenReadInFlight) {
return
}
const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
// Why await only a real read: a pane with no screen model keeps its tick synchronous.
const screenBlockedReason = screenRead ? await screenRead : null
if (!this.entries.has(entry)) {
return
}
const currentSample = this.sample(entry)
const currentVerdict = currentSample.verdict
if (currentVerdict.kind === 'blocked') {
this.settle(entry, currentSample.blocked(currentVerdict.reason))
return
}
if (currentVerdict.kind === 'ready-strong') {
this.settle(entry, currentSample.ready())
return
}
if (currentVerdict.kind === 'working') {
return
}
if (screenBlockedReason) {
this.settle(entry, currentSample.blocked(screenBlockedReason))
return
}
if (currentVerdict.kind === 'ready-weak') {
this.settle(entry, currentSample.ready())
return
}
if (currentVerdict.quietForeground && currentSample.ptyId && !entry.foregroundPollInFlight) {
const foregroundRead = this.deps.getForegroundProcess(currentSample.ptyId)
if (!foregroundRead) {
return
}
entry.foregroundPollInFlight = true
startedForegroundPoll = true
const foreground = await foregroundRead
if (foreground && !isShellProcess(foreground) && currentSample.isQuiet()) {
this.settle(entry, currentSample.ready())

@pullfrog pullfrog 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.

ℹ️ No critical issues — one rough edge worth a look, plus two small notes.

Reviewed changes

Read the complete 19-file diff (5 commits, +1090/−295). This PR reworks tui-idle readiness so an unattended Claude launch into an untrusted folder reports agent-trust-workspace within a few seconds instead of timing out or typing its brief into the trust dialog.

  • One evaluator for every settle site — isTuiIdleSatisfied (boolean) is replaced by evaluateTuiIdle, returning a TuiIdleVerdict (blocked / ready-strong / ready-weak / working / pending). runtime-terminal-wait.ts, runtime-terminal-idle-polls.ts, and orca-runtime-resolve-exit-waiters.ts now branch only on the verdict, and blocking becomes tier 0 ahead of strong ready.
  • Weak ready settles only on the poll, after a rendered-screen read — RuntimeTerminalIdlePolls gains readVisibleScreen, wired to the runtime's in-process headless emulator; ready-weak/pending verdicts are gated behind detectTerminalWaitBlockedReason(screen). A working verdict skips the read so an agent quoting the dialog's wording in its own output is not misread as blocked, and a ready-weak verdict triggers an immediate tick so sub-interval probes (the automation start probe) still see it.
  • Claude's bare name now needs corroboration — NATIVE_EXPLICIT_IDLE_TITLE_AGENTS adds claude, so a shell auto-title (claude, claude ~/path) waits for the quiescence window the way Codex/Devin already do.
  • Transcript fixtures and tests — three captured Claude trust-dialog fixtures, the new claude-trust-dialog-transcript and tui-idle-weak-evidence-seam suites, additions to the idle-poll and evidence unit specs, and a pinned count in the serializer replay suite.

The ranking, the phy/leaf evidence builders, and the resolver changes are consistent across sites, and the transcript and seam tests genuinely fail under ablation — the core change is well covered.

ℹ️ Nitpicks

  • The class-header claim at src/main/runtime/tui-idle-evidence.ts:36-38 — "ONLY the poll may settle on it" — is broader than the implementation: isAgentSettledForDelivery (orca-runtime-resolve-exit-waiters.ts:207-209) also accepts ready-weak with readTailBlockedReason: () => null and no screen read. The PR body documents this as deliberate delivery behavior, but the absolute wording here invites the next reader to treat it as an invariant. Scoping it to "only the wait path's poll" would match reality.
  • The screen-read await re-checks this.entries.has(entry) at runtime-terminal-idle-polls.ts:169-171; the foreground await at line 187 does not, so settle() can call deps.resolve for an entry the poll already removed. It is currently masked because every cancelIdlePoll caller settles the promise first (making the second resolve a no-op), but it is the same invariant the screen path deliberately enforces.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

return
}
if (verdict.kind === 'ready-weak') {
this.settle(entry, sample.ready())

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.

sample() computes the verdict at line 149, before the await on the screen read, but this ready-weak branch acts on that captured verdict afterwards — guarded only by the entries.has re-check. If the pane starts a new turn (lastAgentStatus/title → working) while the read is pending, the poll still settles satisfied: true over a busy agent.

Technical details
# `ready-weak` settles a verdict captured before the screen-read await

## Affected sites
- `src/main/runtime/runtime-terminal-idle-polls.ts:149` — `const sample = this.sample(entry)` (verdict computed here)
- `src/main/runtime/runtime-terminal-idle-polls.ts:168` — `await screenRead`
- `src/main/runtime/runtime-terminal-idle-polls.ts:169-171` — re-checks only `this.entries.has(entry)`, not the verdict
- `src/main/runtime/runtime-terminal-idle-polls.ts:176-178` — settles `sample.ready()` from the stale verdict

The pty `sample()` closes over `entry.pty`, which is mutated in place, so a title/status change during the read is visible to the record but not to the captured `verdict`. The `resolveTuiIdleWaiters` resolver does not settle a `working` transition, so the entry is not removed by the interim change and this branch fires.

## Required outcome
- Do not settle `ready-weak` on a verdict the pane has since contradicted. Either recompute the sample after the screen read resolves, or re-validate the `ready-weak` verdict (e.g. no `working` status) before `settle()`.

## Suggested approach (optional)
- Compute `ptyId` first, perform the screen read, then evaluate the full verdict/sample from the post-await record — mirroring the `entries.has` re-check already there for cancellation.

## Open questions for the human (optional)
- Window is narrow (`await state.writeChain`); is a fresh sample per pending/weak tick's screen read acceptable, or would you rather gate just the `ready-weak` settle?

…ocking prompt

Claude's first-launch "trust this folder?" dialog parks the cursor above its
options, and the host's line tail drops the lines below it, which are the only
ones the trust matcher knew ("trust this folder", "Enter to confirm"). An
unattended Claude launch into a fresh folder therefore waited out its whole
budget and reported a timeout instead of the blocking prompt. The dialog's
opening question ("... one you trust?") survives in the tail, so it is now
recognised, pinned by a captured transcript of the real dialog.
…he tui-idle poll

Claude's workspace-trust dialog parks the cursor on its highlighted option with a
cursor-up, and the host line tail deletes every retained row below the cursor, so
"Yes, I trust this folder" and "Enter to confirm" never reach the blocked-prompt
detector. In a live launch the dialog also arrives in 1024-byte reads, and the tail's
plain path blanks each line that ends in a carriage return before the newline, so
the opening question does not survive either. An unattended launch waited out its
whole budget and reported a timeout.

The runtime already feeds every PTY chunk into its own headless emulator. The tui-idle
poll now also runs the existing blocked-prompt rules over that emulator's visible
screen (no provider or host round trip), after the tail checks and before the
quiet-foreground idle fallback. The "one you trust" phrase is dropped: it only matched
when the whole dialog arrived in one chunk, wrapped away on narrow panes, and could
match prose.

Replays three live Claude 2.1.280 captures through the runtime: the dialog in one
chunk and in 1024-byte reads, a 60-column pane, and the dialog answered with "Yes",
which must report ready rather than blocked.
…agent reports working

The screen check runs on every tui-idle poll, and the automation observer holds a tui-idle
wait open for a whole agent turn. A working Claude whose screen showed dialog wording (a diff
of the detector, say) was reported blocked where main kept waiting. The dialogs only the
screen reveals are start-up ones painted before any title, so a working title now vetoes it.
…screen read

A shell auto-title (oh-my-zsh's `claude`, fish's `claude <cwd>`) names Claude before
its workspace trust dialog paints, and the line tail loses that dialog. The wait took
the bare name as rest, settled ready, and the launch typed its brief into the dialog.

Every tui-idle settle site now asks one evaluator for a verdict: blocked, strong ready,
working, weak ready or pending. The pre- and post-registration checks and the
title-change resolvers settle only blocked or strong ready; weak ready is left to the
poll, which settles it only once the rendered screen shows no blocker. A name-only
Claude title is held to the same quiet window as Codex and Devin, since Claude
announces rest with its own explicit title.
…ializer divergences

The captured answered-dialog transcript added by this PR is replayed by the
serialize round-trip suite and diverges at 13 checkpoints. It diverges
identically on origin/main and on the pre-#22586 addon build (13 both-fail,
0 regressions): the live SGR pen leaks into the alt buffer, and an alt buffer
first entered after a shrink keeps hidden scrollback. Pin the count like the
other known captures and correct the comment, which called these upstream.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/blocked-prompt-rendered-screen branch from 9248249 to 83aa3aa Compare September 27, 2026 23:49

@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: 1

♻️ Duplicate comments (1)
src/main/runtime/runtime-terminal-idle-polls.ts (1)

166-179: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Re-sample the verdict after the screen read resolves.

tick computes verdict before it awaits screenRead. After the await, the code checks only whether the entry is still registered. The pane can change while the read is pending. For example, lastAgentStatus can become working, or the tail can show a blocking prompt. In that case, a clear screen still reaches the stale ready-weak branch, and the poll settles satisfied: true. resolvePtyTuiIdleWaiters does not settle on a working transition, so nothing retires the entry before this branch runs.

Call this.sample(entry) again after the await. Use the fresh sample to handle blocked, ready-strong, and working before you settle ready-weak.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8c33e93b-73b6-4c1d-bf91-58fd0b3d17a2

📥 Commits

Reviewing files that changed from the base of the PR and between 9248249 and 83aa3aa.

📒 Files selected for processing (8)
  • src/main/daemon/serialize-grid-transcript-replay.test.ts
  • src/main/runtime/orca-runtime-resolve-exit-waiters.ts
  • src/main/runtime/orca-runtime-runtime-id.ts
  • src/main/runtime/runtime-terminal-idle-polls.test.ts
  • src/main/runtime/runtime-terminal-idle-polls.ts
  • src/main/runtime/runtime-terminal-wait.ts
  • src/main/runtime/terminal-wait-name-only-idle.test.ts
  • src/main/runtime/tui-idle-evidence.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines 160 to +179
}
if (
pty.lastAgentStatus === null &&
quietForegroundProcessProvesTuiIdle(agent) &&
!entry.foregroundPollInFlight
) {
const foregroundRead = this.deps.getForegroundProcess(pty.ptyId)
// Why no screen read while working: its output can quote dialog wording (a diff of this
// detector), and the dialogs only the screen shows are start-up ones, painted before any title.
if (verdict.kind === 'working' || entry.screenReadInFlight) {
return
}
const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
// Why await only a real read: a pane with no screen model keeps its tick synchronous.
const screenBlockedReason = screenRead ? await screenRead : null
if (!this.entries.has(entry)) {
return
}
if (screenBlockedReason) {
this.settle(entry, sample.blocked(screenBlockedReason))
return
}
if (verdict.kind === 'ready-weak') {
this.settle(entry, sample.ready())
return
}

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 | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '135,225p' src/main/runtime/runtime-terminal-idle-polls.ts
sed -n '325,365p' src/main/runtime/orca-runtime-runtime-id.ts
rg -n 'readVisibleScreen|headlessTerminal|ready-weak' src/main/runtime/runtime-terminal-idle-polls.ts src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime/runtime-terminal-idle-polls.test.ts

Repository: stablyai/orca

Length of output: 6994


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- changed-file diff ---'
git diff --stat 89cf55dfc8f2af9c2c57f8a977ef6fc769c4a46a 83aa3aa98f2fc5ddbadc0b79d0f9db477bac93e8 -- src/main/runtime/runtime-terminal-idle-polls.ts src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime/runtime-terminal-idle-polls.test.ts
git diff --unified=35 89cf55dfc8f2af9c2c57f8a977ef6fc769c4a46a 83aa3aa98f2fc5ddbadc0b79d0f9db477bac93e8 -- src/main/runtime/runtime-terminal-idle-polls.ts src/main/runtime/orca-runtime-runtime-id.ts | sed -n '1,360p'
printf '%s\n' '--- relevant symbols ---'
rg -n -C 5 'headlessTerminals|readHeadlessVisibleTerminalState|readLiveTerminalScreenLines|startTuiIdleVisibleReadProbe|detectTerminalWaitBlockedReason|workspace trust|trust|headless' src/main/runtime src/main | head -n 320

Repository: stablyai/orca

Length of output: 42371


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/architecture /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 47935


🏁 Script executed:

git diff --stat 89cf55dfc8f2af9c2c57f8a977ef6fc769c4a46a 83aa3aa98f2fc5ddbadc0b79d0f9db477bac93e8 -- src/main/runtime/runtime-terminal-idle-polls.ts src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime/runtime-terminal-idle-polls.test.ts
git diff --unified=35 89cf55dfc8f2af9c2c57f8a977ef6fc769c4a46a 83aa3aa98f2fc5ddbadc0b79d0f9db477bac93e8 -- src/main/runtime/runtime-terminal-idle-polls.ts src/main/runtime/orca-runtime-runtime-id.ts
rg -n -C 5 'headlessTerminals|readHeadlessVisibleTerminalState|readLiveTerminalScreenLines|startTuiIdleVisibleReadProbe|detectTerminalWaitBlockedReason|workspace trust|trust|headless' src/main/runtime src/main

Repository: stablyai/orca

Length of output: 45636


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- idle poll exact source ---'
sed -n '1,260p' src/main/runtime/runtime-terminal-idle-polls.ts
printf '%s\n' '--- wait controller and visible probe bindings ---'
rg -n -C 12 'startTuiIdleVisibleReadProbe|startLeaf\\(|startPty\\(|startVisibleReadProbe|readVisibleScreen|headlessTerminals\\.has' src/main/runtime/runtime-terminal-wait.ts src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime
printf '%s\n' '--- headless lifecycle declarations and mutations ---'
rg -n -C 8 'headlessTerminals' src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime --glob '*.ts' | head -n 260
printf '%s\n' '--- focused idle-poll tests ---'
sed -n '1,390p' src/main/runtime/runtime-terminal-idle-polls.test.ts

Repository: stablyai/orca

Length of output: 10294


🏁 Script executed:

#!/bin/bash
set -eu
sed -n '1,260p' src/main/runtime/runtime-terminal-idle-polls.ts
rg -n -C 12 'startTuiIdleVisibleReadProbe|startLeaf\(|startPty\(|startVisibleReadProbe|readVisibleScreen|headlessTerminals\.has' src/main/runtime/runtime-terminal-wait.ts src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime
rg -n -C 8 'headlessTerminals' src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime --glob '*.ts' | head -n 260
sed -n '1,390p' src/main/runtime/runtime-terminal-idle-polls.test.ts

Repository: stablyai/orca

Length of output: 41576


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- wait controller full relevant ranges ---'
sed -n '1,280p' src/main/runtime/runtime-terminal-wait.ts
printf '%s\n' '--- visible probe implementation and callers ---'
rg -n -F -C 18 'startTuiIdleVisibleReadProbe' src/main/runtime
rg -n -F -C 10 'startVisibleReadProbe' src/main/runtime/runtime-terminal-wait.ts src/main/runtime
printf '%s\n' '--- renderer/headless mode lifecycle ---'
rg -n -F -C 10 'headlessTerminals.has' src/main/runtime --glob '*.ts'
rg -n -F -C 10 'headlessTerminals.set' src/main/runtime --glob '*.ts'

Repository: stablyai/orca

Length of output: 41914


🏁 Script executed:

#!/bin/bash
set -eu
sed -n '1,280p' src/main/runtime/runtime-terminal-wait.ts
rg -n -F -C 18 'startTuiIdleVisibleReadProbe' src/main/runtime
rg -n -F -C 10 'startVisibleReadProbe' src/main/runtime/runtime-terminal-wait.ts src/main/runtime
rg -n -F -C 10 'headlessTerminals.has' src/main/runtime --glob '*.ts'
rg -n -F -C 10 'headlessTerminals.set' src/main/runtime --glob '*.ts'

Repository: stablyai/orca

Length of output: 41775


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- visible probe complete source ---'
sed -n '1,260p' src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
printf '%s\n' '--- renderer and headless PTY creation/attachment ---'
rg -n -F -C 16 'createPtyHeadlessTerminalState' src/main/runtime --glob '*.ts'
rg -n -F -C 16 'disposeHeadlessTerminal' src/main/runtime --glob '*.ts'
rg -n -F -C 16 'attachRenderer' src/main/runtime --glob '*.ts'
rg -n -F -C 16 'serializeBuffer' src/main/runtime --glob '*.ts'

Repository: stablyai/orca

Length of output: 42372


🏁 Script executed:

#!/bin/bash
set -eu
sed -n '1,260p' src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
rg -n -F -C 16 'createPtyHeadlessTerminalState' src/main/runtime --glob '*.ts'
rg -n -F -C 16 'disposeHeadlessTerminal' src/main/runtime --glob '*.ts'
rg -n -F -C 16 'attachRenderer' src/main/runtime --glob '*.ts'
rg -n -F -C 16 'serializeBuffer' src/main/runtime --glob '*.ts'

Repository: stablyai/orca

Length of output: 43051


Keep weak readiness pending when no rendered screen is available.

When readVisibleScreen returns null, the polling path treats the missing screen as clear. A ready-weak bare agent title can therefore settle while a rendered workspace-trust prompt remains visible. The separate visible-read probe starts only after startPty invokes its immediate weak-ready tick, so it cannot prevent this settlement.

Suggested fix
       const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
+      if (!screenRead && verdict.kind === 'ready-weak') {
+        return
+      }
       // Why await only a real read: a pane with no screen model keeps its tick synchronous.
       const screenBlockedReason = screenRead ? await screenRead : null
📝 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 change
}
if (
pty.lastAgentStatus === null &&
quietForegroundProcessProvesTuiIdle(agent) &&
!entry.foregroundPollInFlight
) {
const foregroundRead = this.deps.getForegroundProcess(pty.ptyId)
// Why no screen read while working: its output can quote dialog wording (a diff of this
// detector), and the dialogs only the screen shows are start-up ones, painted before any title.
if (verdict.kind === 'working' || entry.screenReadInFlight) {
return
}
const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
// Why await only a real read: a pane with no screen model keeps its tick synchronous.
const screenBlockedReason = screenRead ? await screenRead : null
if (!this.entries.has(entry)) {
return
}
if (screenBlockedReason) {
this.settle(entry, sample.blocked(screenBlockedReason))
return
}
if (verdict.kind === 'ready-weak') {
this.settle(entry, sample.ready())
return
}
}
// Why no screen read while working: its output can quote dialog wording (a diff of this
// detector), and the dialogs only the screen shows are start-up ones, painted before any title.
if (verdict.kind === 'working' || entry.screenReadInFlight) {
return
}
const screenRead = ptyId ? this.readScreenBlockedReason(entry, ptyId) : null
if (!screenRead && verdict.kind === 'ready-weak') {
return
}
// Why await only a real read: a pane with no screen model keeps its tick synchronous.
const screenBlockedReason = screenRead ? await screenRead : null
if (!this.entries.has(entry)) {
return
}
if (screenBlockedReason) {
this.settle(entry, sample.blocked(screenBlockedReason))
return
}
if (verdict.kind === 'ready-weak') {
this.settle(entry, sample.ready())
return
}

@pullfrog pullfrog 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.

ℹ️ No new issues in the new commits — the change since the prior review is a rebase, and the earlier finding on the poll's screen-read verdict remains open.

Reviewed changes

Re-reviewed the 5 commits at 83aa3aa98f against the previously reviewed 92482496be. The two heads were rebased apart (no common merge base), so the delta was recovered with git range-diff; it is a rebase plus a small test-comment change.

  • Rebased onto current main — main had renamed and expanded the tier-1 body detector to isKnownReadyPromptBody(waitText, agent, readScreenLines) (Codex header readiness, #23475). The two new evidence builders now pass the pane's agent and its live screen lines, matching every other caller.
  • Transcript-harness change dropped — the size / getSize support the captured fixtures need now lives in agent-transcript-pane-test-harness.ts on main, so the PR no longer touches that file.
  • Serializer pin comment corrected — the known-divergence comment now names the two pre-existing serializer limitations; the pinned claude-dialog-trust-workspace-answered: 13 count is unchanged in effect.

Verified on this head: the 5 focused tui-idle/transcript suites (60 tests), the serializer replay suite (27 tests), and pnpm tc:node all pass. No specialist review was needed.

The prior inline finding on the stale screen-read verdict (runtime-terminal-idle-polls.ts, thread PRRT_kwDORpCz1s6mONgc) is unchanged by the rebase, so it remains open rather than being re-raised here.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 merged commit 2119730 into main Sep 28, 2026
45 checks passed
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