Repository navigation
fix(tui-idle): probe the visible screen for Codex panes and repeat until the wait settles - #22902
aniruddhaadak80 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Important
pnpm typecheck fails as-is (TS2741 from a TerminalWaiter constructor this PR did not update), and the Codex gate widening can resolve tui-idle on the booting model: loading header until #18019 lands. Both are detailed inline.
Reviewed changes
- Gate widened to Codex —
shouldProbeVisibleScreenis extracted from the inline AGY gate andusesAlternateScreenReadinessnow admitscodex, so a Codex pane whose shell already printed a line starts the visible-screen probe on both the PTY and leaf paths. - Probe repeats —
startVisibleScreenProbechains a 1ssetTimeoutloop until the waiter's deadline, replacing the single bounded look for AGY/Codex; other agents keep the single-shot path. - Waiter plumbing —
TerminalWaitergains a requiredcancelVisibleProbe, retired by the registry's singleremovepath alongside the timeout and idle poll. - New regression suite —
terminal-wait-codex-visible-screen-probe.test.ts(5 tests, passing locally) pins that a Codex pane with shell output is probed, that the probe re-arms, stops at timeout, and is not run for tail-settled panes.
ℹ️ Nitpicks
src/main/runtime/terminal-wait-codex-visible-screen-probe.test.tsfailsoxfmt --check: the import on lines 5-9 collapses to one line and the file is missing a trailing newline. Runpnpm format.src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts:31still documentsstartTuiIdleVisibleReadProbeas "Deliberately single-shot"; that is now false for the AGY/Codex callers this PR routes into it. Worth a follow-up edit even though the file itself was intentionally untouched.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| @@ -191,6 +191,8 @@ export type TerminalWaiter = { | |||
| timeout: NodeJS.Timeout | null | |||
| /** Retires this waiter from the shared idle-poll sweep; null when not polling. */ | |||
| cancelIdlePoll: (() => void) | null | |||
| /** Retires the repeated visible-screen probe armed for this waiter; null when not probing. */ | |||
| cancelVisibleProbe: (() => void) | null | |||
There was a problem hiding this comment.
Adding cancelVisibleProbe as a required field breaks an existing constructor this PR does not update: runtime-terminal-idle-polls.test.ts:42 makeWaiter omits it, so pnpm typecheck (and tc:node) fails with TS2741: Property 'cancelVisibleProbe' is missing. Update that fixture (or make the field optional) before merge. Verified locally with tsc --noEmit -p config/tsconfig.node.json.
| * Agents whose settled readiness is painted to the screen instead of written to scrollback. | ||
| */ | ||
| function usesAlternateScreenReadiness(agent: TuiAgent | null): boolean { | ||
| return agent === 'antigravity' || agent === 'codex' |
There was a problem hiding this comment.
Widening the probe to Codex routes the probe's readiness check through isKnownReadyPromptPreview on the live screen. Open PR #18019 exists precisely because findCodexReadyPromptIndex matches the booting banner (openai codex + model: + directory:) while model: loading / directory: loading are still showing. Until #18019 merges, this change can resolve tui-idle during model load and let worker-start paste onto the splash screen — trading the reported timeout for an early paste.
Technical details
# Codex readiness probe can settle on the booting header
## Affected sites
- `src/main/runtime/runtime-terminal-wait.ts:35` — `usesAlternateScreenReadiness` now routes codex through the repeating probe.
- `src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts:83` — for codex the probe classifies readiness with `isKnownReadyPromptPreview`.
- `src/main/runtime/terminal-wait-detection.ts:143` — `findCodexReadyPromptIndex` matches `openai codex` + `model:` + `directory:` and does not reject `loading` values.
## Required outcome
- A codex `tui-idle` wait must not settle while the banner still reads a loading value for `model:` or `directory:`.
## Suggested approach (optional)
- Land #18019 first, or reject `loading` values in the screen-path readiness check before enabling the repeat for codex.
Overlap with #22891 (noted by the author)@seonghobae posted #22891 for this same issue at 16:04 UTC, roughly 50 minutes after this PR was opened, and it reaches the same conclusion by the same two-part mechanism: start the visible-screen probe for a Codex pane whose retained text is non-empty, and re-read the screen until the wait deadline. My dedup pass against this issue ran at about 15:47 UTC, before that PR existed, which is why it did not turn up in my search. I am flagging the overlap rather than quietly leaving both open, so a reviewer can pick one. This PR is not withdrawn; the differences a reviewer may care about:
Both approaches are legitimate. Whoever merges first, the other should close. Leaving the choice to the maintainers either way. Separately, the same honest caveat as in the body applies here: I have not executed any test. This PR was authored through the GitHub API with no local checkout, so CI is the verification. |
Correction with exact numbers on the
|
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/terminal-wait-codex-visible-screen-probe.test.ts (1)
131-138: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd an early-settlement probe cancellation test.
The timeout test can pass even if
removedoes not callcancelVisibleProbe, because the probe loop stops at its own deadline. Configure the probe mock to settle the waiter before the deadline, then advance past several retry intervals and assert that no further probes run. This also verifies that a later visible read satisfies the Codex wait.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: d18851e7-208c-4d6e-893a-63b984d80c85
📥 Commits
Reviewing files that changed from the base of the PR and between 646e9a5 and 6cf08f8368f7d9f70ca07ccd89ebd698e7745085.
📒 Files selected for processing (4)
src/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/runtime-terminal-wait.tssrc/main/runtime/runtime-terminal-waiter-registry.tssrc/main/runtime/terminal-wait-codex-visible-screen-probe.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const alternateScreen = usesAlternateScreenReadiness(agent) | ||
| return ( | ||
| (alternateScreen || hasAntigravityTerminalHeader(waitText) || lastAgentStatus === null) && | ||
| (waitText.length === 0 || alternateScreen || hasAntigravityTerminalHeader(waitText)) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect getPaneAgent bindings and the metadata they read.
rg -n -C 5 -P '\bgetPaneAgent\s*[:(]' src/main/runtime
rg -n -C 4 -P '\b(foregroundAgent|launchAgent)\s*[:=]' src/main/runtimeRepository: stablyai/orca
Length of output: 41903
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- getter definitions and callers ---'
rg -n -C 12 'getPaneAgentForTuiIdle|shouldProbeVisibleScreen' src/main/runtime
printf '%s\n' '--- waiter registration and probe setup ---'
rg -n -C 18 'register|waitFor|startVisibleScreenProbe|shouldProbeVisibleScreen' src/main/runtime/runtime-terminal-wait.ts
printf '%s\n' '--- foreground agent updates ---'
rg -n -C 18 'foregroundAgent|runtime-pty-foreground-agent|onForeground|setForeground' src/main/runtime --glob '*.ts'
printf '%s\n' '--- Codex launch and terminal-wait call sites ---'
rg -n -C 10 'codex|terminalWait|terminal.wait|waitForTerminal|createTerminal' src/main/runtime --glob '*.ts'Repository: stablyai/orca
Length of output: 45662
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- waitForTerminal call sites in runtime orchestration ---'
rg -n -C 14 'waitForTerminal\(' src/main/runtime --glob '*.ts' | rg -v 'test'
printf '%s\n' '--- worker-start readiness flow ---'
rg -n -C 20 'agent_readiness|wait-for-setup|workerStart|sendTerminalAgentPrompt' src/main/runtime/rpc src/main/runtime --glob '*.ts' | head -n 1200
printf '%s\n' '--- terminal creation and launchAgent storage ---'
rg -n -C 18 'launchAgent.*pty|pty.*launchAgent|createTerminal\(|register.*Pty|pty\.launchAgent' src/main/runtime --glob '*.ts' | head -n 1600Repository: stablyai/orca
Length of output: 45660
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact waitForTerminal calls ---'
rg -n 'waitForTerminal\(' src/main/runtime/orca-runtime-create-agent-prompt-render-gate.ts src/main/runtime/orca-runtime-structured-agent-session-launch-tui.ts src/main/runtime/rpc/methods/agent-launch-terminal-prompt.ts src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts
printf '%s\n' '--- local worker readiness ---'
sed -n '110,225p' src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts
printf '%s\n' '--- structured launch ---'
sed -n '1,105p' src/main/runtime/orca-runtime-structured-agent-session-launch-tui.ts
printf '%s\n' '--- prompt render gate ---'
sed -n '80,150p' src/main/runtime/orca-runtime-create-agent-prompt-render-gate.ts
printf '%s\n' '--- agent session terminal creation ---'
sed -n '170,215p' src/main/runtime/orca-runtime-create-agent-session.ts
printf '%s\n' '--- PTY registration definitions ---'
rg -n -C 20 'registerPty\(|launchAgent:' src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime --glob '*.ts' | head -n 1000Repository: stablyai/orca
Length of output: 42068
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- placeWorkerAgent definition and external terminal branch ---'
rg -n -C 25 'function placeWorkerAgent|const placeWorkerAgent|placeWorkerAgent\s*=' src/main/runtime/rpc/methods/orchestration/worker src/main/runtime --glob '*.ts' | head -n 1400
printf '%s\n' '--- worker terminal parameter and agent propagation ---'
rg -n -C 18 'params\.terminal|terminalHandle|agentLaunchAuthority|launchAgent' src/main/runtime/rpc/methods/orchestration/worker --glob '*.ts' | head -n 1800
printf '%s\n' '--- registerPty implementation ---'
rg -n -C 35 'registerPty\(.*worktree|agentLaunchAuthority' src/main/runtime --glob '*.ts' | rg -v 'node_modules' | head -n 1800
printf '%s\n' '--- Codex worker tests with supplied terminals ---'
rg -n -C 14 'terminal:.*|agent: .codex.|agent.*codex' src/main/runtime/rpc/methods/orchestration/worker --glob '*test.ts' | head -n 1600Repository: stablyai/orca
Length of output: 45667
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- WorkerStartInput schema and agent resolution ---'
rg -n -C 25 'WorkerStartInput|WorkerStartParams|terminal:|agent:' src/main/runtime/rpc/methods/orchestration/worker --glob '*.ts' | head -n 1800
printf '%s\n' '--- local worker setup and resolved agent ---'
sed -n '1,125p' src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts
printf '%s\n' '--- reused-terminal worker tests ---'
rg -n -C 18 'terminal: .term_worker.|terminal:.*agent|startWorker.*terminal|existing.*terminal|reused.*terminal' src/main/runtime/rpc/methods/orchestration/worker --glob '*test.ts' | head -n 1800Repository: stablyai/orca
Length of output: 45667
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- worker start schema ---'
cat -n src/main/runtime/rpc/methods/orchestration/worker/worker-start-schema.ts
printf '%s\n' '--- local worker first 125 lines ---'
cat -n src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts | sed -n '1,125p'
printf '%s\n' '--- explicit terminal validation remainder ---'
cat -n src/main/runtime/rpc/methods/orchestration/worker/explicit-worker-terminal-validation.ts | sed -n '1,180p'
printf '%s\n' '--- worker launch preference guard ---'
cat -n src/main/runtime/rpc/methods/orchestration/worker/worker-launch-preferences.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 15206
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- shared worker-start schema ---'
cat -n shared/rpc-contract/orchestration-worker-start-params.ts
printf '%s\n' '--- prepareLocalWorkerStart ---'
rg -n -C 30 'prepareLocalWorkerStart' src/main/runtime/rpc/methods/orchestration/worker --glob '*.ts'Repository: stablyai/orca
Length of output: 275
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact schema file ---'
rg --files | rg 'orchestration-worker-start-params|worker-start-validation'
printf '%s\n' '--- prepareLocalWorkerStart locations ---'
rg -n -C 20 'prepareLocalWorkerStart' src/main/runtime --glob '*.ts'Repository: stablyai/orca
Length of output: 18227
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- isTerminalRunningAgent ---'
rg -n -C 30 'isTerminalRunningAgent' src/main/runtime --glob '*.ts'
printf '%s\n' '--- getPtyAgent and agent detection ---'
rg -n -C 25 'getPtyAgent\(|foregroundAgent|detect.*Agent|AgentPresence' src/main/runtime --glob '*.ts' | head -n 1800Repository: stablyai/orca
Length of output: 45655
🏁 Script executed:
#!/bin/bash
set -e
files=$(rg -l 'isTerminalRunningAgent' src/main/runtime --glob '*.ts' | rg -v '\.test\.ts$|\.spec\.ts$')
printf '%s\n' "$files"
for f in $files; do
printf '%s\n' "--- $f ---"
rg -n -C 18 'isTerminalRunningAgent|isRunningAgent|getTerminalAgentStatus' "$f"
doneRepository: stablyai/orca
Length of output: 19214
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- terminal agent presence implementation ---'
rg -n -C 30 'class .*TerminalAgentPresence|terminalAgentPresence|isRunning\(' src/main/runtime --glob '*.ts' | rg -v '\.test\.ts|\.spec\.ts' | head -n 1800Repository: stablyai/orca
Length of output: 32702
🏁 Script executed:
#!/bin/bash
set -e
cat -n src/main/runtime/runtime-terminal-agent-presence.ts | sed -n '39,190p'Repository: stablyai/orca
Length of output: 6752
🏁 Script executed:
#!/bin/bash
set -e
cat -n src/main/runtime/runtime-terminal-idle-polls.ts | sed -n '95,225p'Repository: stablyai/orca
Length of output: 6193
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- title presence predicate ---'
rg -n -C 25 'function ptyTitleProvesAgentPresence|ptyTitleProvesAgentPresence[[:space:]]*=' src/main/runtime/runtime-worktree-status-projection.ts
printf '%s\n' '--- PTY launch/foreground initialization ---'
rg -n -C 12 'launchAgent: null|foregroundAgent: null|launchAgent,' src/main/runtime --glob '*.ts' | head -n 1000Repository: stablyai/orca
Length of output: 41487
🏁 Script executed:
#!/bin/bash
set -e
rg -n -C 18 'launchAgent: null|foregroundAgent: null' src/main/runtime/orca-runtime-record-pty-worktree.tsRepository: stablyai/orca
Length of output: 1948
Retry the Codex visible-screen probe after pane identification.
A reused terminal can pass isTerminalRunningAgent from title evidence while both launchAgent and foregroundAgent remain unset. The waiter then receives null from getPaneAgentForTuiIdle.
For a nonempty shell tail, shouldProbeVisibleScreen skips the probe. Later idle polls do not select a visible-screen probe. Codex readiness that exists only on the alternate screen can therefore time out.
Retry the probe when the pane becomes identified as codex, or preserve that identity before registering the waiter.
…til the wait settles codex 0.157 turned on `tui.fullscreen_transcript`, so the session banner is painted into the alternate screen with cursor addressing instead of being written to scrollback as newline-separated lines. `buildTerminalWaitText` only ever reads the stream tail, so `findCodexReadyPromptIndex` can never match such a pane even when the rendered screen already shows the settled prompt. `tui-idle` therefore times out at `agent_readiness` and `worker-start` never injects the task. The visible-screen read that can prove readiness was gated to AGY and an empty tail, so a Codex pane whose shell had already printed something never took that branch. - widen the gate to the agents whose readiness is painted to the screen (AGY, codex), leaving every tail-settled lane on its existing single bounded look - re-read the screen on the provider snapshot retry cadence until the waiter settles, so a slow first paint is not missed; the timer rides on the waiter and the registry's single `remove` path retires it with the wait timeout and the idle poll Refs stablyai#22825
6cf08f8 to
d460d25
Compare
|
Rebased onto main; conflicts resolved (file moved to terminal/wait, probe ported to the typed runtime). |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
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:
7cff3aa7-5e05-419c-9373-5abc193e8a21
📥 Commits
Reviewing files that changed from the base of the PR and between 6cf08f8368f7d9f70ca07ccd89ebd698e7745085 and d460d25.
📒 Files selected for processing: 4
src/main/runtime/runtime-terminal-contracts.tssrc/main/runtime/terminal-wait-codex-visible-screen-probe.test.tssrc/main/runtime/terminal/wait/terminal-wait.tssrc/main/runtime/terminal/wait/terminal-waiter-registry.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| waiter.cancelVisibleProbe = cancel | ||
| probe() |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect the ready-weak path and whether a null screen read lets it settle synchronously.
ast-grep outline src/main/runtime/terminal/wait/terminal-idle-polls.ts \
--match 'start|tick|readScreenBlockedReason' --view expanded
rg -n -C 5 'ready-weak|readScreenBlockedReason|readScreenLines' \
src/main/runtime/terminal/wait/terminal-idle-polls.ts \
src/main/runtime/tui-idle-evidence.tsRepository: stablyai/orca
Length of output: 6447
🏁 Script executed:
set -eu
printf '%s\n' '--- terminal-wait relevant declarations ---'
ast-grep outline src/main/runtime/terminal/wait/terminal-wait.ts --view expanded
printf '%s\n' '--- terminal-wait changed/current blocks ---'
nl -ba src/main/runtime/terminal/wait/terminal-wait.ts | sed -n '1,220p'
printf '%s\n' '--- idle polls relevant blocks ---'
nl -ba src/main/runtime/terminal/wait/terminal-idle-polls.ts | sed -n '90,275p'
printf '%s\n' '--- evidence alternate-screen and readiness conditions ---'
rg -n -C 8 -F -e 'alternate' -e 'antigravity' -e 'codex' -e 'ready-weak' src/main/runtime/tui-idle-evidence.ts src/main/runtime/terminal/wait
printf '%s\n' '--- registry removal and probe references ---'
rg -n -C 8 -F -e 'cancelVisibleProbe' -e 'class RuntimeTerminalWaiterRegistry' -e 'remove(' src/main/runtime/terminal/wait
printf '%s\n' '--- base to head diff for target file ---'
git diff --no-ext-diff 6af21633e995668aa659144e2cb46416643580a0 d460d25ec5aec9f2e1210b7130d02c6d16db438b -- src/main/runtime/terminal/wait/Repository: stablyai/orca
Length of output: 41562
🏁 Script executed:
set -eu
printf '%s\n' '--- readVisibleScreen declarations and bindings ---'
rg -n -C 8 -F 'readVisibleScreen' src
printf '%s\n' '--- TuiIdleEvidenceSource declaration ---'
rg -n -C 12 -F 'export type TuiIdleEvidenceSource' src/main
printf '%s\n' '--- visible probe implementation ---'
rg -n -C 12 -F 'startVisibleReadProbe' src/main
printf '%s\n' '--- focused terminal wait tests ---'
rg -n -C 10 -F -e 'cancelVisibleProbe' -e 'ready-weak' -e 'readVisibleScreen' -e 'antigravity' -e 'codex' src --glob '*test*' --glob '*spec*'Repository: stablyai/orca
Length of output: 45476
🏁 Script executed:
set -eu
printf '%s\n' '--- focused idle-polls tests around alternate agents and null screen reads ---'
nl -ba src/main/runtime/runtime-terminal-idle-polls.test.ts | sed -n '210,430p'
printf '%s\n' '--- terminal-wait tests around visible probe lifecycle ---'
rg -l -F -e 'cancelVisibleProbe' -e 'visible screen' -e 'alternate-screen' src/main/runtime --glob '*test.ts' | while read -r f; do
echo "--- $f"
rg -n -C 8 -F -e 'cancelVisibleProbe' -e 'visible screen' -e 'alternate-screen' "$f"
done
printf '%s\n' '--- headless terminal ownership and population ---'
rg -n -C 6 -F -e 'headlessTerminals' -e 'readHeadlessVisibleTerminalState' src/mainRepository: stablyai/orca
Length of output: 42170
🏁 Script executed:
set -eu
printf '%s\n' '--- focused Codex visible-probe test ---'
nl -ba src/main/runtime/terminal-wait-codex-visible-screen-probe.test.ts | sed -n '1,260p'
printf '%s\n' '--- PTY and headless registration paths ---'
rg -n -C 10 -F -e 'registerPty(' -e 'seedHeadlessTerminal(' -e 'headlessTerminals.set' -e 'providerSnapshotPreferredPtys' src/main/runtime | head -n 500
printf '%s\n' '--- runtime visible-screen and provider mode declarations ---'
nl -ba src/main/runtime/construction/runtime-identity-state.ts | sed -n '350,400p'
rg -n -C 12 -F -e 'providerSnapshotPreferredPtys' -e 'replaceHeadlessTerminal' -e 'createHeadless' src/main/runtime/terminal src/main/runtime/terminal-output src/main/runtime/output src/main/runtime | head -n 600Repository: stablyai/orca
Length of output: 42088
Check waiter membership before starting the repeat probe.
When readVisibleScreen returns null, a ready-weak poll can settle synchronously. The registry removes the waiter before startVisibleScreenProbe installs cancelVisibleProbe, but the helper still starts probe() and can arm retries. This applies to Codex and Antigravity because they always select the visible-screen path.
🐛 Suggested fix
private startVisibleScreenProbe(
waiter: TerminalWaiter,
waiterTimeoutMs: number,
agent: TuiAgent | null
): void {
+ if (!this.waiters.get(waiter.handle)?.has(waiter)) {
+ return
+ }
const deadlineAt = Date.now() + Math.max(0, waiterTimeoutMs)|
Thank you @aniruddhaadak80 for this PR and for rebasing it. The Codex readiness problem it targeted (#22825) was fixed by #23765 and Codex readiness now reads the live screen from rule files in #24375, so I am closing this as superseded. We appreciate the contribution. |

ELI5
Starting a Codex worker can hang until it gives up, saying the agent never became ready, even though Codex is sitting right there at its prompt waiting for the task. Orca decides an agent is "ready" by reading the text the terminal has scrolled past, and newer Codex versions draw their startup banner directly onto the screen instead of scrolling it past. So Orca looks at the wrong place, decides nothing is ready, and eventually times out. This change makes Orca also look at what is actually on screen, and keeps looking until the worker is ready or the wait runs out.
What Changed
Before:
orca orchestration worker-start --agent codexreaches the Codex prompt, then the receipt comes backstate: failed,stage: agent_readiness,lastError: timeout. The task is never injected and the context stays at 0%. The same is true oforca terminal wait --for tui-idleon that pane.After: the wait settles once the rendered screen shows the settled Codex banner (
OpenAI Codex,model:,directory:), the task is injected, and the worker proceeds.Mechanism, in two parts:
The gate.
tui-idlematches the stream tail, but Codex 0.157 turned ontui.fullscreen_transcript, so the session banner is painted into the alternate screen with cursor addressing and never becomes a newline-separated scrollback line.buildTerminalWaitTextonly ever reads the tail, sofindCodexReadyPromptIndexcannot match. The visible-screen read that can prove readiness existed already, butruntime-terminal-wait.tsonly started it for AGY panes, panes carrying an AGY banner, or an empty tail:A Codex pane whose shell had already printed one line matched neither arm, so the probe never ran. The gate is now expressed once as
shouldProbeVisibleScreenand admits the agents whose readiness is painted rather than scrolled: AGY and Codex.The single look. Even with the gate open, a launch registers the waiter while the TUI is still painting, so one bounded ~750 ms look can read a blank screen and hand the wait back to the tail-only sweep that cannot see the banner at all.
startVisibleScreenProbenow re-reads the screen on the provider's existing visible-snapshot retry cadence (1 s) until the waiter settles, so a slow first paint is no longer missed.The repeat timer is carried on the
TerminalWaiterand retired by the registry's singleremovepath, the same place the wait timeout and the idle poll are already cleaned up, so no probe can outlive its waiter.Why
-c tui.fullscreen_transcript=false. The reporter's second comment confirms the config key works as a workaround. Rejected here because it pins Orca's supported behavior to one Codex release's default: the flag disappears in a future version, the setting lives in the user's~/.codex/config.tomlrather than in the pane Orca launches, and Orca would still be unable to read a screen it genuinely cannot see. Reading the screen is the fix that survives the next release. The launch-flag route also leaves every Codex user who has already adopted fullscreen mode broken.Linked Issue
Fixes #22825
The second half of the reporter's finding (the
-c/--enable/--disable/--searchlaunch skipping the shared Codex app server unless it is embedded) is tracked separately as #22873 and is deliberately not addressed here.Visual Proof
N/A - no UI or interaction change, and no pixels change. The observable difference is that
orca terminal wait --for tui-idlestops timing out on a Codex pane whose rendered screen already shows the settled prompt.Testing
I have not run any of these commands. This change was authored entirely through the GitHub API against a remote-only checkout, so there is no local working tree, no
node_modules, and no installed Codex CLI in the environment it was written in. I am not claiming a green run. Verification is CI's job for this PR, and the exact commands CI runs are the four below plus the sharded vitest matrix.pnpm lint pnpm typecheck pnpm test pnpm buildThe focused suite this PR adds, and the neighboring wait suites a reviewer will want alongside it:
pnpm exec vitest run --config config/vitest.config.ts \ src/main/runtime/terminal-wait-codex-visible-screen-probe.test.ts \ src/main/runtime/terminal-wait-name-only-idle.test.ts \ src/main/runtime/antigravity-readiness-transcripts.test.tsNew tests in
src/main/runtime/terminal-wait-codex-visible-screen-probe.test.ts:workingstarts the visible-screen probe, and the probe is asked forcodex. This is the regression lock for the reported bug: before the gate change nothing asks the provider for the screen at all, so this fails without the fix.Platform notes, stated plainly:
ubuntu-latest(Node 24) and the Windows job only on Windows-marked paths, so neither covers a macOS Codex pane. The fix is verified on Linux by construction and by the unit tests; the macOS behavior described in the issue is not machine-verified by anything in this PR.codex_index_heal_contractjob pins a real Codex binary (0.150.1) and is path-filtered, so this diff does not trigger it. The regression it would catch is a different subsystem.AI Disclosure
Written with the OpenCode agent (model
opencode/space-bunny-free) under direction of @aniruddhaadak80, who reviewed the diff and the evidence. The source reading, the fix, and the tests were produced by the agent. Not verified by any human running the suite - see Testing.Author: @aniruddhaadak80. (X handle not supplied by the author; please add it here before merge if you want the shout-out.)
Review
pathusage, no process or shell assumptions. Safe on all three by construction.findCodexReadyPromptIndexagainst a false positive - treating the bootingmodel: loadingheader as readiness. This PR changes which projection is read and how often, and does not touchterminal-wait-detection.tsat all. If it merges, the two compose: this one guarantees the screen is read, that one makes the match stricter. fix(terminal): stop treating the Codex boot header as tui-idle readiness #18019 is open and unmerged, and this diff is branched from currentmain.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
tui-idle-wait-test-harnessfixtures and the samecreateWaitshape used byterminal-wait-name-only-idle.test.ts, but unverified is unverified. If a test fails in CI, the most likely cause is a fixture expectation rather than the production change, and the fix belongs in the test.TerminalWaitergains one internal field, and the only reader outside this feature is the waiter registry's cleanup.max-linesbudget was respected:runtime-terminal-wait.tsgoes from 237 to 268 counted lines against the 300 cap forsrc/main/runtime/**/*.ts.// @ts-nochecksplit moduleorca-runtime-start-tui-idle-visible-read-probe.tswas intentionally not edited, so nots-nocheckratchet movement is involved. The repeat is armed fromruntime-terminal-wait.tsand driven through the existingstartVisibleReadProbedependency, which keeps the single-shot probe implementation byte-identical.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) - left unchecked because there is no local checkout to run them against. CI is the verification for this PR; see Testing.