Skip to content

fix(agent-status): show Claude/Codex panes waiting on the folder-trust dialog - #33804

Merged
nwparker merged 17 commits into
mainfrom
nwparker/agint-25854-trust-sidebar
Oct 26, 2026
Merged

nwparker merged 17 commits into
mainfrom
nwparker/agint-25854-trust-sidebar

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​169 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​169
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​263 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251

ELI5

When Claude Code or Codex opens in a folder it doesn't trust yet, it stops and asks "do you trust this folder?". Orca's CLI already noticed this (agentWait: agent-trust-workspace), but the sidebar didn't: the pane had no agent row (Claude) or showed Codex - Idle. Now the sidebar shows Waiting for input while the dialog is up, and the row clears within about a second of the dialog leaving the screen.

Root cause

Agents only run hooks after the folder is trusted, so no hook can report the dialog. Claude reads hasTrustDialogAccepted before it loads hooks. Codex (codex-rs/hooks) has no hook event for the trust screen. The existing blocked-text detector (findTerminalWaitBlockedSignal) found the dialog, but only getTerminalInteractiveWait read it, so nothing turned it into a status row.

What changed

  • One module, trust-dialog-status-observer.ts: one class with per-ptyId state, run from the same per-chunk screen-observer loop as the Freebuff and Codex-capacity screen statuses (!pty.connectionId gate). It reuses findTerminalWaitBlockedSignal, readLaunchedAgentForeground and ptyForegroundAgent.
  • Untracked pane: a cheap keyword check (trust, carried across reads; Ink paints words apart with cursor moves) opens a 4 KB paint budget. Only then is the screen read and confirmed by the detector, and only when the dialog's key footer is the last line with the trust choice just above it (quoted wording in a reply doesn't match). It then publishes waiting for Claude/Codex unless a live hook row exists. An agent typed into a shell refreshes the foreground probe first.
  • Ownership: we record the receivedAt of the row our publish produced, the same write identity the hook-silence recheck uses (row.receivedAt === yieldedTo). No display field is used as a tag.
  • Tracked pane, each chunk: if the current row is no longer ours (a hook or anything else replaced it), tracking stops at once with no screen read. Otherwise a screen read is scheduled, at most one per 400 ms.
  • Clearing: the row settles to done + sessionBoundary once two consecutive debounced reads no longer show the dialog (a resize clear read before Claude's redraw is one miss, not a clear), or once the shell is proven to be the foreground (readLaunchedAgentForeground; on Windows confirmShellForeground). A working agent's spinner no longer holds the row.
  • Reads go to the PTY's current emulator, so a mobile renderer-snapshot recovery that swaps the emulator no longer loses tracking (previously a stuck "Waiting for input" until Codex's first turn).
  • Tracking is dropped on PTY exit and on pruned PTY records.
  • The row doesn't feed back into agent state: it skips the prompt lifecycle (recordsPromptLifecycle flag on emitTerminalAgentStatusEvents) and lastExplicitAgentStatus, so agentWait and tui-idle are unchanged. The payload is a plain waiting/done row, so older clients render it as-is.
  • Mailbox delivery holds on the dialog: while a Claude trust dialog is up, isPtyAwaitingUserInput is now true for the pane, so orchestration mailbox delivery waits instead of typing into the dialog. This is intended.
  • Notifications: a waiting row behaves like a permission prompt (needs-input alert; desktop skips it when that workspace is focused, phones are notified).

Verification

Screenshots below are from the earlier revision of this PR; appearance is unchanged, only the clear timing and bookkeeping changed.

Before (main): Codex shows Idle while the CLI reports agentWait: agent-trust-workspace. The Claude pane had no row at all.
before codex
before claude

After: both panes show Waiting for input, with the tab marked as action required.
after codex
after claude

After you trust the folder, the Codex row settles (no waiting badge). Pressing Esc on Claude's dialog exits Claude, and its row is removed.
after trust

  • Tests (trust-dialog-status-observer.test.ts, fake timers, through the real runtime):
    • Fixture replays: claude-dialog-trust-workspace{,-narrow} and codex-0-158-0-trustprompt in 1-byte chunks show one waiting; claude-dialog-trust-workspace-answered goes waiting then done.
    • Dialog wording quoted in ordinary output: no row.
    • A resize repaint split across reads: one waiting, no flip; then an erase clears it.
    • Renderer-snapshot recovery swaps the emulator: the row still clears.
    • A hook row replacing ours: left untouched, no done.
    • A killed agent's leftover frame: clears only once the shell is proven foreground.
  • pnpm tc ✅, check:code-quality:changed ✅, codex-notice-terminal-status.test.ts passes.

Trade-offs / risk

  • Clearing needs two reads ~400 ms apart, so the row clears ~0.5-1 s after the dialog leaves, instead of instantly. That's the price of not flipping on a resize repaint.
  • While the dialog is still showing and output arrives, each debounced read also probes the foreground process (at most one per 400 ms). The dialog is normally static, so this is rare.
  • Ownership uses receivedAt: if something republished an identical waiting row for the pane, we'd treat the row as no longer ours and leave it.
  • In panes narrower than about 34 columns the dialog footer wraps, so no row is shown there (accepted false negative; agentWait still reports it).
  • A stale hook row left from an earlier session in a reused pane suppresses the badge, as today.
  • Remote runtimes publish their own row; plain SSH relay panes get none, same as other screen statuses.
  • Claude typed into a plain shell is still not identified (its process title is its version). Panes launched through Orca are identified.

Refs #25854. Plain-text end-of-turn questions (the other open item on #25854) are not addressed: Codex's Stop/notify payloads carry only last_assistant_message, and request_user_input is Plan-mode only.

…t dialog

Hooks only start after a folder is trusted, so a pane parked on Claude's or
Codex's trust dialog had no sidebar row (or an idle one) even though
agentWait already reported agent-trust-workspace. Main's headless-screen
observer now runs the same blocked-text detector on the screen and projects
a waiting row while the dialog shows, settling it with a session-boundary
done once the dialog leaves. The row is not first-party evidence: it skips
the prompt lifecycle and lastExplicitAgentStatus.

Refs #25854

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

The runtime now detects Claude and Codex workspace-trust dialogs in PTY output and the visible terminal screen. It publishes waiting statuses and settles them when the dialog is absent or the launched-agent foreground is confirmed as the shell. Hydration supplies agent, foreground, emulator, status-row, and status-publication access. PTY cleanup removes observer state. Status event emission can also skip prompt lifecycle recording when its new parameter is false.

Priority: Normal

Merge Risk: Low · up to 50ffb

Trust-dialog status can be missed after snapshot restoration or remain stale if a foreground check never completes. These are bounded status-display risks; the line-limit build concern is resolved. Merge is reasonable with owner awareness and follow-up.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description is detailed and covers the user impact, root cause, implementation, testing, visual proof, risks, and limitations. However, it does not follow the required Linked Issue format: it uses… Update the Linked Issue section with the actual issue link in the required format, preferably "Fixes #25854". Add or explicitly complete the remaining template sections, including AI Disclosure when applicable, Review, Notes, and Checklist …
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: showing Claude and Codex panes as waiting during folder-trust dialogs.
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.
Full details: Description check

Explanation

The description is detailed and covers the user impact, root cause, implementation, testing, visual proof, risks, and limitations. However, it does not follow the required Linked Issue format: it uses "Refs #25854" instead of the required issue-closing link such as "Fixes #25854". Several template sections, including AI Disclosure, Review, Notes, and Checklist, are also absent.

Resolution

Update the Linked Issue section with the actual issue link in the required format, preferably "Fixes #25854". Add or explicitly complete the remaining template sections, including AI Disclosure when applicable, Review, Notes, and Checklist items. Mark the relevant testing checkboxes or state why they are not applicable.

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


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: c9057453-3311-4604-838d-4fe5066efb44
Commits

Reviewing files that changed from the base of the PR and between 35af10d and 1856236.

Files selected for processing: 4
  • src/main/runtime/startup-dialog-terminal-status.test.ts
  • src/main/runtime/startup-dialog-terminal-status.ts
  • src/main/runtime/terminal/output/headless-terminal-hydration.ts
  • src/main/runtime/terminal/output/terminal-derived-agent-facts.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 +190 to +191
// Runs every chunk: its scan tracks when the dialog leaves the screen.
this.observeTrustDialogStatus(ptyId, pty, state, chunk, readStatus)

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.

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

sed -n 60,200p src/main/runtime/terminal/output/headless-terminal-hydration.ts
cat src/main/runtime/startup-dialog-terminal-status.ts
rg -n "maybeHydrateHeadlessFromRenderer|seedHeadless|hydrateHeadless" src/main/runtime | head -30

Repository: stablyai/orca

Length of output: 14396


Script executed:

set -o pipefail
printf '%s\n' '--- hydration declaration and seed block ---'
nl -ba src/main/runtime/terminal/output/headless-terminal-hydration.ts | sed -n '1,150p'
printf '%s\n' '--- observer call and status publication ---'
nl -ba src/main/runtime/terminal/output/headless-terminal-hydration.ts | sed -n '150,280p'
printf '%s\n' '--- hydration call sites ---'
rg -n -F --glob '*.ts' -e 'maybeHydrateHeadlessFromRenderer' -e 'serializeBuffer' -e 'headlessHydrationState' src/main src/renderer || test "$?" -eq 1
printf '%s\n' '--- surrounding caller definitions ---'
rg -n -F --glob '*.ts' -e 'hydrateHeadlessFromRenderer' -e 'renderer hydration' -e 'serializeBuffer!' src/main/runtime src/main | head -120

Repository: stablyai/orca

Length of output: 41741


Script executed:

set -o pipefail
printf '%s\n' '--- direct hydration callers ---'
rg -n -F --glob '*.ts' -- 'maybeHydrateHeadlessFromRenderer' src || test "$?" -eq 1
printf '%s\n' '--- surrounding ingestion callers ---'
rg -n -F --glob '*.ts' -e 'trackHeadlessTerminalData(' -e 'hasRendererSerializer(' -e 'registerSerializer' src/main src/renderer | head -160
printf '%s\n' '--- serializer implementation ---'
nl -ba src/main/ipc/pty/runtime/controller.ts | sed -n '60,115p'
nl -ba src/main/ipc/pty/ipc/serialize-buffer.ts | sed -n '80,125p'
printf '%s\n' '--- relevant caller context ---'
python3 - <<'PY'
from pathlib import Path
for p in Path('src').rglob('*.ts'):
    text = p.read_text(errors='replace')
    needle = 'maybeHydrateHeadlessFromRenderer'
    if needle in text:
        lines = text.splitlines()
        for i, line in enumerate(lines):
            if needle in line:
                print(f'--- {p}:{i+1} ---')
                for n in range(max(0, i-8), min(len(lines), i+14)):
                    print(f'{n+1}: {lines[n]}')
PY

Repository: stablyai/orca

Length of output: 11271


Observe trust dialogs restored from renderer snapshots.

If hydration restores a snapshot that already shows a trust dialog, the seed write bypasses observeTrustDialogStatus. A later chunk without trust also does not detect the dialog because the scan is not marked as shown. The sidebar can therefore miss the waiting row.

Run the trust-dialog observer after the seed completes. Keep this projection separate from prompt-lifecycle evidence.

nwparker and others added 2 commits October 26, 2026 00:08
… on agent exit

Require the dialog's key footer and trust choice so quoted wording in a reply
cannot raise a waiting row, settle the row once a killed agent's pane is back
at a shell, and cover dismissal with a Codex 0.164 recording.

Co-Authored-By: Claude <[email protected]>

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Publish trust-dialog projections per mounted leaf. · headless-terminal-hydration.ts:221-240

src/main/runtime/terminal/output/headless-terminal-hydration.ts:221-240
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Publish trust-dialog projections per mounted leaf.

readPtyAgentStatusRow reads only the first leaf’s row, while emitTerminalAgentStatusEvents sends the projection to every mounted leaf. The receiver resolves each event by its target pane key, but this projection does not carry the fields required by the hook-precedence guards. A trust-dialog update can overwrite a live hook-owned row on another leaf or use the first leaf’s row to omit that leaf’s waiting or settlement update.

Select the row and publish the projection for the same target leaf instead of using one PTY-wide decision.


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: c79d32fe-742e-4b7a-8b0d-c84a239114e1
Commits

Reviewing files that changed from the base of the PR and between 1856236 and 610f24f.

Files selected for processing: 5
  • src/main/runtime/__fixtures__/codex-0-164-0-trustprompt-answered.meta.json
  • src/main/runtime/__fixtures__/codex-0-164-0-trustprompt-answered.txt
  • src/main/runtime/startup-dialog-terminal-status.test.ts
  • src/main/runtime/startup-dialog-terminal-status.ts
  • src/main/runtime/terminal/output/headless-terminal-hydration.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.

nwparker and others added 2 commits October 26, 2026 01:56
ASCII-escape the dialog regexes for the orcad build, settle only after a quiet
settled screen without the dialog or a proven shell foreground (readLaunchedAgentForeground,
which is the only shell-alone proof on Windows), so a resize repaint split across
reads no longer flips the row and re-notifies.

Co-Authored-By: Claude <[email protected]>

@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
  • 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: be87a91e-1a15-4836-99c3-54b1a159824d
Commits

Reviewing files that changed from the base of the PR and between 610f24f and e7cd281.

Files selected for processing: 3
  • src/main/runtime/startup-dialog-terminal-status.test.ts
  • src/main/runtime/startup-dialog-terminal-status.ts
  • src/main/runtime/terminal/output/headless-terminal-hydration.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 +108 to +110
if (row && row.observation?.origin === 'hook' && !row.providerSessionOnly) {
return null
}

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.

Minor · Functional Correctness · Quick win

🔎 Supported by static analysis

Script executed:

#!/bin/bash
# Check how hook-origin rows are cleared when an agent exits or a new agent launches in the same pane.
rg -nP --type=ts -C3 'getAgentStatusSnapshotForPane|clearAgentStatus|retireAgentStatus|removeAgentStatus' src/main -g '!**/*.test.ts' | head -120
rg -nP --type=ts -C3 "origin:\s*'hook'" src/main src/shared -g '!**/*.test.ts' | head -80

Repository: stablyai/orca

Length of output: 8193


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- trust status module ---'
nl -ba src/main/runtime/startup-dialog-terminal-status.ts | sed -n '1,190p'
printf '%s\n' '--- snapshot implementation and status lifecycle symbols ---'
rg -n -F --glob '*.ts' \
  -e 'getStatusSnapshotForPane' \
  -e 'getStatusSnapshot()' \
  -e 'setAgentStatus' \
  -e 'clearAgentStatus' \
  -e 'retireAgentStatus' \
  -e 'removeAgentStatus' \
  -e 'statusByPane' \
  -e 'statusRows' \
  -e 'origin: '\''hook'\''' \
  src/main/agent-hooks src/shared src/main/runtime
printf '%s\n' '--- candidate server declarations ---'
rg -l -F --glob '*.ts' 'getStatusSnapshotForPane' src/main/agent-hooks src/shared src/main/runtime | while read -r f; do
  printf '\n### %s\n' "$f"
  nl -ba "$f" | sed -n '1,260p'
done

Repository: stablyai/orca

Length of output: 45665


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- non-test definitions ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' \
  -e 'getStatusSnapshotForPane' \
  -e 'getStatusSnapshot()' \
  -e 'clearPaneState' \
  -e 'clearStatus' \
  -e 'statusByPane' \
  -e 'rowsByPane' \
  -e 'Map<string, AgentStatus' \
  src/main/agent-hooks
printf '%s\n' '--- server files ---'
rg --files src/main/agent-hooks | rg '/server($|/)|server\.ts$|status'
printf '%s\n' '--- likely implementation excerpts ---'
for f in src/main/agent-hooks/server.ts src/main/agent-hooks/server/index.ts src/main/agent-hooks/server/status-store.ts src/main/agent-hooks/server/agent-status-store.ts; do
  if [ -f "$f" ]; then
    printf '\n### %s\n' "$f"
    nl -ba "$f" | sed -n '1,280p'
  fi
done

Repository: stablyai/orca

Length of output: 9624


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- snapshot methods ---'
nl -ba src/main/agent-hooks/server/server-listeners.ts | sed -n '180,245p'
printf '%s\n' '--- server state declarations and snapshot-related helpers ---'
nl -ba src/main/agent-hooks/server/server-state.ts | sed -n '1,180p'
nl -ba src/main/agent-hooks/server/server-state.ts | sed -n '240,330p'
printf '%s\n' '--- terminal status ingestion ---'
nl -ba src/main/agent-hooks/server/server-ingest-terminal.ts | sed -n '1,300p'
printf '%s\n' '--- terminal status update/application ---'
nl -ba src/main/agent-hooks/server/server-status-update.ts | sed -n '1,320p'
printf '%s\n' '--- pane cleanup ---'
nl -ba src/main/agent-hooks/server/server-tab-cleanup.ts | sed -n '110,205p'
nl -ba src/main/agent-hooks/server/server-cleanup.ts | sed -n '1,190p'

Repository: stablyai/orca

Length of output: 43481


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- launch identity implementation and callers ---'
rg -n -F --glob '*.ts' \
  -e 'recordLaunchResumeIdentity' \
  -e 'trustDialogWaitingStatus' \
  -e 'lastStatusByPaneKey' \
  src/main src/shared
printf '%s\n' '--- launch identity body ---'
nl -ba src/main/agent-hooks/server/server-ingest-terminal.ts | sed -n '20,115p'
printf '%s\n' '--- launch identity callers ---'
rg -l -F --glob '*.ts' 'recordLaunchResumeIdentity' src/main src/shared | while read -r f; do
  printf '\n### %s\n' "$f"
  rg -n -F -C8 'recordLaunchResumeIdentity' "$f"
done
printf '%s\n' '--- trust status callers ---'
rg -l -F --glob '*.ts' 'trustDialogWaitingStatus' src/main src/shared | while read -r f; do
  printf '\n### %s\n' "$f"
  rg -n -F -C14 'trustDialogWaitingStatus' "$f"
done

Repository: stablyai/orca

Length of output: 39483


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- resume identity launch helper ---'
nl -ba src/main/ipc/pty/pane/resume-launch-identity.ts | sed -n '1,85p'
printf '%s\n' '--- callers of the launch helper ---'
rg -n -F -C12 --glob '*.ts' 'seedResumeLaunchIdentityFromSpawn' src/main
printf '%s\n' '--- production clearPaneState callers in launch/runtime scopes ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' 'clearPaneState(' src/main/ipc src/main/runtime src/main/pty src/main | head -160

Repository: stablyai/orca

Length of output: 13859


Do not let a completed hook row suppress the trust-dialog row.

When a pane starts a fresh launch without a resumable provider session, its previous done hook row can remain in the pane snapshot. The current guard then returns null, so the trust-dialog row is not published.

🐛 Suggested fix
--- "a/src/main/runtime/startup-dialog-terminal-status.ts"
+++ "b/src/main/runtime/startup-dialog-terminal-status.ts"
@@ -105,9 +105,14 @@
   if (agent !== 'claude' && agent !== 'codex') {
     return null
   }
-  if (row && row.observation?.origin === 'hook' && !row.providerSessionOnly) {
+  if (
+    row &&
+    row.state !== 'done' &&
+    row.observation?.origin === 'hook' &&
+    !row.providerSessionOnly
+  ) {
     return null
   }
   return { state: 'waiting', agentType: agent, prompt: '', toolInput: TRUST_DIALOG_TOOL_INPUT }
 }
 
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 (row && row.observation?.origin === 'hook' && !row.providerSessionOnly) {
return null
}
if (
row &&
row.state !== 'done' &&
row.observation?.origin === 'hook' &&
!row.providerSessionOnly
) {
return null
}

Comment on lines +259 to +372
private readPtyAgentStatusRow(
ptyId: string,
pty: RuntimePtyWorktreeRecord
): AgentStatusIpcPayload | undefined {
const paneKey =
this.getLeavesForPty(ptyId).map((leaf) => this.makeRuntimePaneKey(leaf))[0] ??
this.paneOfPty(pty).paneKey
return paneKey ? this.getAgentStatusSnapshotForPaneFn?.(paneKey)[0] : undefined
}

/** A sidebar projection of the blocked text agentWait already reads, never first-party agent evidence. */
private publishTrustDialogStatus(ptyId: string, payload: ParsedAgentStatusPayload): void {
this.emitTerminalAgentStatusEvents(
ptyId,
{ cleanData: '', payloads: [payload], lastPayloadCleanOffset: null },
undefined,
false
)
}

private observeTrustDialogStatus(
ptyId: string,
pty: RuntimePtyWorktreeRecord,
state: RuntimeHeadlessTerminal,
chunk: string,
readStatus: () => AgentStatusIpcPayload | undefined
): void {
const read = observeTrustDialogScreenChange(state.emulator, chunk)
if (read === null) {
return
}
if (read !== 'appeared') {
this.scheduleTrustDialogSettleCheck(ptyId, pty, state)
return
}
const agent = this.getPaneAgentForTuiIdle(ptyId)
if (agent) {
const waiting = trustDialogWaitingStatus(agent, readStatus())
if (waiting) {
this.publishTrustDialogStatus(ptyId, waiting)
}
return
}
// An agent typed into a shell paints its dialog before the foreground-process probe names it.
void this.ptyForegroundAgent.refresh(ptyId).then(() => {
if (!this.isTrustDialogStillShown(ptyId, pty, state)) {
return
}
const waiting = trustDialogWaitingStatus(
this.getPaneAgentForTuiIdle(ptyId),
this.readPtyAgentStatusRow(ptyId, pty)
)
if (waiting) {
this.publishTrustDialogStatus(ptyId, waiting)
}
})
}

private isTrustDialogStillShown(
ptyId: string,
pty: RuntimePtyWorktreeRecord,
state: RuntimeHeadlessTerminal
): boolean {
return (
this.ptysById.get(ptyId) === pty &&
this.headlessTerminals.get(ptyId) === state &&
isTrustDialogShown(state.emulator)
)
}

/** Settles only on positive evidence once output goes quiet, so a repaint split across reads never re-notifies. */
private scheduleTrustDialogSettleCheck(
ptyId: string,
pty: RuntimePtyWorktreeRecord,
state: RuntimeHeadlessTerminal
): void {
clearTimeout(this.trustDialogSettleTimers.get(ptyId))
const timer = setTimeout(() => {
this.trustDialogSettleTimers.delete(ptyId)
void this.settleTrustDialog(ptyId, pty, state)
}, TUI_IDLE_QUIESCENCE_MS)
timer.unref?.()
this.trustDialogSettleTimers.set(ptyId, timer)
}

private async settleTrustDialog(
ptyId: string,
pty: RuntimePtyWorktreeRecord,
state: RuntimeHeadlessTerminal
): Promise<void> {
if (!this.isTrustDialogStillShown(ptyId, pty, state)) {
return
}
const settled = trustDialogSettledStatus(this.readPtyAgentStatusRow(ptyId, pty))
const agent =
settled?.agentType === 'claude' ? 'claude' : settled?.agentType === 'codex' ? 'codex' : null
// A hook that reported since owns the pane: stop tracking without touching its row.
if (!agent) {
forgetTrustDialog(state.emulator)
return
}
if (!confirmTrustDialogGone(state.emulator)) {
// A killed agent can leave its frame painted above the shell prompt; only a proven shell foreground settles it.
const foreground = await this.readLaunchedAgentForeground(ptyId, agent)
if (foreground !== 'shell' || !this.isTrustDialogStillShown(ptyId, pty, state)) {
return
}
forgetTrustDialog(state.emulator)
}
const stillOurs = trustDialogSettledStatus(this.readPtyAgentStatusRow(ptyId, pty))
if (stillOurs) {
this.publishTrustDialogStatus(ptyId, stillOurs)
}
}

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.

Major · Maintainability & Code Quality · Heavy lift

Fix the CI failure: the file exceeds the line limit.

The pipeline reports that node node_modules/oxlint/bin/oxlint fails with a "too many lines" error for this file. The error reports 323 lines against the limit. The new trust-dialog methods add about 115 lines, which pushes the file over the limit. This blocks the static analysis job.

Move the trust-dialog state (trustDialogSettleTimers) and the methods observeTrustDialogStatus, isTrustDialogStillShown, scheduleTrustDialogSettleCheck, settleTrustDialog and publishTrustDialogStatus into a separate module. For example, use a small controller class in startup-dialog-terminal-status-controller.ts that takes the runtime hooks it needs: the ptysById and headlessTerminals lookups, getPaneAgentForTuiIdle, ptyForegroundAgent.refresh, readLaunchedAgentForeground, readPtyAgentStatusRow and the emit function. The hydration class then only calls controller.observe(...) at Line 230.

Do not raise the lint limit. The repository has max-lines ratchets (check:max-lines-ratchet).

Source: Pipeline failures

nwparker and others added 10 commits October 26, 2026 02:16
…adless hydration

Keeps headless-terminal-hydration.ts under the max-lines lint limit.

Co-Authored-By: Claude <[email protected]>
…uzz rejects

Its replay trips known serialize I2 diffs; cover Codex dismissal with a composer
repaint over the existing 0.158 capture, and compare only appearance/absence.

Co-Authored-By: Claude <[email protected]>
…debounced screen reads

Keys state by ptyId so an emulator swap no longer strands the row, owns the
row by its receipt stamp instead of a toolInput tag, drops tracking as soon as
another writer replaces the row, and clears after two debounced reads without
the dialog instead of 3 s of total quiet.

@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
  • 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: 20c7bec6-d52f-496a-bbf3-265f3da805df
Commits

Reviewing files that changed from the base of the PR and between 4d2513a and 50ffb29.

Files selected for processing: 5
  • src/main/runtime/terminal/lifecycle/floating-session-liveness.ts
  • src/main/runtime/terminal/lifecycle/pty-exit-lifecycle.ts
  • src/main/runtime/terminal/output/headless-terminal-hydration.ts
  • src/main/runtime/trust-dialog-status-observer.test.ts
  • src/main/runtime/trust-dialog-status-observer.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.

Comment on lines +148 to +154
pane.readTimer = setTimeout(() => {
void this.read(ptyId, pane).then((again) => {
pane.readTimer = undefined
if (again && this.panes.get(ptyId) === pane) {
this.scheduleRead(ptyId, pane)
}
})

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.

Minor · Stability & Availability · Quick win

🔎 Supported by static analysis

Script executed:

#!/bin/bash
# Check whether readLaunchedAgentForeground can reject or hang.
rg -nP -C8 '\breadLaunchedAgentForeground\s*\(' src/main/runtime --glob '!**/*.test.ts'

Repository: stablyai/orca

Length of output: 11117


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- observer ---'
nl -ba src/main/runtime/trust-dialog-status-observer.ts | sed -n '1,235p'
printf '%s\n' '--- foreground implementation ---'
nl -ba src/main/runtime/launched-agent-foreground.ts | sed -n '1,220p'
printf '%s\n' '--- dependency wiring and status helpers ---'
nl -ba src/main/runtime/terminal/output/headless-terminal-hydration.ts | sed -n '25,75p'
printf '%s\n' '--- observer tests and foreground-related fixtures ---'
rg -n -F -e 'foregroundProbeHangs' -e 'readLaunchedAgentForeground' -e 'TrustDialogStatusObserver' src/main/runtime --glob '*.test.ts' --glob '*.ts' || test "$?" -eq 1

Repository: stablyai/orca

Length of output: 23416


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- foreground process group helper ---'
nl -ba src/main/runtime/terminal-foreground-group.ts | sed -n '1,260p'
printf '%s\n' '--- controller method declarations and implementations ---'
rg -n -F -e 'listProcesses' -e 'inspectProcess' -e 'getForegroundProcess' -e 'confirmShellForeground' src/main/runtime --glob '*.ts' --glob '!**/*.test.ts' | head -n 160
printf '%s\n' '--- observer tests ---'
nl -ba src/main/runtime/trust-dialog-status-observer.test.ts | sed -n '1,280p'
printf '%s\n' '--- hanging fixture ---'
nl -ba src/main/runtime/agent-transcript-pane-test-harness.ts | sed -n '1,125p'

Repository: stablyai/orca

Length of output: 37469


Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- controller contract ---'
nl -ba src/main/runtime/runtime-pty-controller-contract.ts | sed -n '1,260p'
printf '%s\n' '--- foreground-related provider definitions ---'
rg -n -F -e 'confirmShellForeground' -e 'getForegroundProcess' -e 'inspectProcess' src/main --glob '*.ts' --glob '!**/*.test.ts' --glob '!**/*.spec.ts' | head -n 220
printf '%s\n' '--- runtime controller construction ---'
rg -n -F -e 'setPtyController' -e 'ptyController:' src/main/runtime/construction src/main/runtime --glob '*.ts' --glob '!**/*.test.ts' --glob '!**/*.spec.ts' | head -n 180

Repository: stablyai/orca

Length of output: 33192


Prevent a pending foreground probe from blocking status checks.

The rejection concern does not apply to the production binding. readLaunchedAgentForeground catches controller errors and returns 'unknown'.

A pending foreground probe remains a valid failure path. When the dialog remains visible, read() awaits the probe. The scheduled callback clears pane.readTimer only after read() fulfills. A pending probe can therefore prevent later debounced reads.

Bound the foreground probe with a timeout and clear pane.readTimer in a finally block. Treat a timeout as 'unknown'.

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