Skip to content

fix(runtime): stop a busy Codex 0.150-0.157 pane reading as tui-idle - #23805

Merged
Jinwoo-H merged 6 commits into
mainfrom
jinwoo/codex-header-busy-reads-idle
Sep 30, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
jinwoo/codex-header-busy-reads-idle

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​188 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34

ELI5

Codex 0.150 to 0.157 prints a welcome box at the top of its screen (OpenAI Codex, model:, directory:). Orca treated that box as proof that Codex was waiting for input. But the box stays on screen, and in Orca's saved terminal text, for the whole session, including while Codex is busy. So asking Orca "is this Codex idle?" in the middle of a task got "yes" in well under a second. Orca now treats the box as "Codex has started", and only believes Codex is idle once its screen has also been quiet for 3 seconds, which is the same rule it already uses for Codex 0.158.

What Changed

Before: on Codex 0.150–0.157, orca terminal wait --for tui-idle on a busy Codex pane returned "satisfied" in about 0.2–0.4 s while Codex was showing Working (… esc to interrupt). This happened in fullscreen mode (the 0.157 default) and in inline mode (-c tui.fullscreen_transcript=false, --no-alt-screen). Anything built on that wait could fire mid-turn: scripts that wait for a worker to finish, a new task handed to a busy worker's terminal (worker-start --terminal), and automations checking whether a run has started. Mailbox delivery uses the same check before it types into a pane.

After: a busy 0.150–0.157 pane stays "not idle" until the turn ends and the screen goes quiet. Codex 0.158 behaves exactly as before.

Mechanism: Orca ranks the evidence a tui-idle wait may settle on (tui-idle-evidence.ts). Tier 1 ("the agent says it is ready") settles immediately and outranks the agent's own "working" status. Tier 1b ("quiet ready screen", added for Muse and extended to Codex's empty input box in #23765) only counts once the pane has had no output for TUI_IDLE_QUIESCENCE_MS (3 s).

Why

  • Why the quiet lane, not a new busy detector: while Codex works it repaints its spinner title and status timer about every 100 ms, so a pane that has been silent for 3 s is not mid-turn. That lane already settles 0.158 and a scrolled-away 0.157 header, so every version now follows one rule.
  • Why keep the header at all: it is the only rest evidence when Orca has no trustworthy screen grid for the pane (readScreenLines returns null), so dropping it would make some idle panes never settle.
  • Agent-unknown panes keep today's answer. A pane Orca cannot name (no launch record, foreground agent not detected) still reads the header as tier 1. The quiet lane needs an output clock, and an adopted pane restored from saved output has none, so moving the header there would leave those panes pending until timeout. Every Orca-launched Codex worker carries launchAgent: codex, and a Codex a user starts by hand is named by foreground detection, so the reported cases are covered.
  • Alternatives considered:
    • Add a "no busy status row" check to the header rule: the text form of the rule reads Orca's saved terminal text, where Codex's in-place repaints garble lines (the dirctory: case from fix(runtime): read Codex readiness from the live screen #23475), so that check would be unreliable exactly where it's needed. The quiet lane already solves this.
    • Only look at the last part of the saved text: the header is on the visible screen for the whole session in fullscreen mode, so this doesn't help.

Linked Issue

Pre-existing since #2462. Related: #23475, #23765, STA-8834.

Visual Proof

N/A: no UI change. The observable difference is orca terminal wait --for tui-idle timing out on a busy Codex pane instead of returning (see Testing).

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Automated:

  • New scrubbed recording codex-0-157-1-timed-sleep-turn (0.157.1 fullscreen, one sleep 25 turn, real chunk timing). With the real timing, for it and the existing 0.155.1 timed turn, the full ranking never settles from prompt submit to the last busy frame, even at the latest moment each frame is on screen. The final frame is still pending the moment it lands and settles 3 s later. A presence check makes sure the header really is in the saved text mid-turn.
  • A unit test pins the agent-unknown decision: the header is tier 1 for an unknown pane and not for a Codex pane.
  • The fix(runtime): read Codex readiness from the live screen #23475 header tests now check the quiet lane: same frames, same sizes, same answers. Its runtime waits allow for the 3 s quiet period.
  • Red without the fix: with terminal-wait-detection.ts / codex-terminal-readiness.ts at main, the two timed tests and the unit test fail, along with the moved header tests.
  • Suites: src/main/runtime + src/main/daemon: 11,832 passed, 58 skipped, 2 failed. Both failures are in repro-13767-shell-ready-marker-lost-to-exec, which fails the same way on main locally on macOS.
  • The serializer round trip suite reads every fixture. The new recording shows the same known header-border attribute difference as the other Codex fixtures (6 checkpoints), so it's added to KNOWN_PREEXISTING_I2_FAILURES.
  • pnpm tc, oxlint, oxfmt and check:code-quality:changed are clean.

Replay (every frame of the recordings from STA-8834, codex 0.150.1–0.158.0, same inputs before and after):

Recording Mid-turn frames that settle, before → after
0.157.1 fullscreen, 3 timed turns 1,173 → 0
0.157.1 inline (120 / 80 cols), 3 timed turns 2,018 → 0 / 1,869 → 0
0.157.1 --no-alt-screen, 3 timed turns 1,371 → 0
0.157.1 timed tool turn 4,416 → 0
0.155.1 timed tool turn 807 → 0
Untimed turns 0.150.1 / 0.153.4 / 0.155.1 / 0.156.1 / 0.157.1 282 / 476 / 523 / 168 / 841 → all 0
0.158.0, 7 recordings 0 → 0, and no verdict differs on any frame

Every finished turn with at least 3 s of quiet in the recording still settles. Startup readiness on 0.157 moves from 0.3–0.5 s to 4.3–4.6 s after launch (0.158 on main: 4.2–4.8 s). Settling after a turn moves from immediate (it was already "idle" throughout) to 3.1–7.6 s after the last busy frame, the same range as 0.158.

Live (isolated headless dev runtime built from this branch, macOS, each Codex version installed separately; 0.156+ run with --no-daemon):

Run on 92b3042c5df (before the restored-pane fix, which only changes panes with no output yet; that case is covered by the runtime test above):

Codex Case Result Time to ready
0.157.1 fullscreen (default) worker-start --agent codex ready, task completed 7.8 s
0.157.1 fullscreen takeover of an idle pane (worker-start --terminal) ready, task completed 1.7 s
0.157.1 fullscreen busy safety: sleep 30 task, 15 s tui-idle wait while it runs wait timed out while busy; satisfied 12 s after the task completed, once Codex finished its reply 7.7 s
0.157.1 inline (-c tui.fullscreen_transcript=false) plain ready, completed 7.8 s
0.157.1 inline --model gpt-6-sol --effort high ready, completed, gpt-6-sol / high applied 7.8 s
0.157.1 inline busy safety timed out while busy; satisfied 4.2 s after completion 7.7 s
0.157.1 --no-alt-screen busy safety timed out while busy; satisfied 8.2 s after completion 7.7 s
0.155.1 plain ready, completed 8.1 s
0.155.1 busy safety timed out while busy. Codex kept working for 21 s after it recorded worker_done; the wait was satisfied 3 s after its status row cleared 7.8 s
0.150.1 --model gpt-5.6-sol ready, completed 7.8 s
0.150.1 busy safety (--model gpt-5.6-sol) timed out while busy; satisfied 2.3 s after completion 5.7 s
0.158.0 plain ready, completed 8.0 s
0.158.0 busy safety timed out while busy; satisfied once idle. The follow-up reply failed on "Selected model is at capacity", which has nothing to do with Orca 7.8 s
Claude (control) plain blocked on Claude's own folder-trust dialog (agent-trust-workspace), as on main 2.2 s

On main (same runtime and profile, only the two source files reverted): 0.157.1 fullscreen busy safety fails. The 15 s wait returned satisfied after 0.17 s while sleep 30 was running. Time to ready was 3.8 s there, against 7.7 s on this branch.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cost: Orca-launched Codex 0.150–0.157 workers reach "ready" about 3 s later than before, because the header no longer short-cuts the quiet period. 0.158 is unchanged.
  • Known gap (unchanged from fix(runtime): settle a quiet Codex composer as ready on every version #23765): with tui.animations=false (turned on automatically by a screen reader), tui.effects.progress=false, or a tui.terminal_title without the spinner, Codex can be silent mid-turn for more than 3 s, and the quiet lane can then settle early. That is still better than before, when the header settled immediately.
  • Not changed: the one-shot visible-screen probe for adopted panes with no saved output (startTuiIdleVisibleReadProbe) still reads the header through isKnownReadyPromptSettled (fix(runtime): wait out Codex 0.157's startup screen, and stop at Codex's startup dialogs, before typing a worker brief #23745). It only runs when Orca has no saved text for the pane at all.
  • SSH / remote: the check runs wherever the wait runs, on data that runtime already has. No wire or protocol change.

Checklist

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

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Fixes idle detection logic for a busy Codex pane.

The PR appears safe to merge; no new actionable issue remains.

Summary

The PR moves clocked Codex 0.150–0.157 panes from immediate header-based readiness to the existing three-second quiet-screen check. Clockless restored panes retain the header path. The changes since the previous review only clarify test descriptions.

  • Adds timed transcript coverage for busy and finished turns.
  • Updates header and startup-dialog tests for the quiet-screen path.

Reviews (5) · Last reviewed commit: "test(runtime): name the screen-readiness..."

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 50fa7399-d92f-4a5c-8f61-2f17139f190a

📥 Commits

Reviewing files that changed from the base of the PR and between e68620a and dd061f6.

📒 Files selected for processing (1)
  • src/main/runtime/codex-quiet-ready-screen.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/codex-quiet-ready-screen.test.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.


📝 Walkthrough

Walkthrough

Codex readiness checks now distinguish quiet-screen evidence from known-agent prompt-body evidence. They use output-clock state when evaluating prompt-body evidence and reject provisional startup text. Tests cover screen states, pane types, restored panes, and quiescence timing. A Codex 0.157.1 timed-turn fixture and a replay failure-count entry were added.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to dd061

The change clarifies test naming while preserving assertions. Codex header readiness requires quiet output for clocked panes, and blocking dialogs still prevent readiness. No merge-blocking issue was identified.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e6862

The change reduces premature input into busy terminals and appears contained. Restored sessions and delayed delivery still rely on assumptions that were not fully verified, so some uncertainty remains.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated propagation reaches terminal waits, worker task delivery, and mailbox pointer submission within the existing runtime. The readiness change affects when those operations proceed, not the capability contents shown in worker delivery. Complete tenant, environment, and remote-host exposure was not established.

Trust Boundaries and Controls

  • observed — Terminal text and screen contents provide readiness evidence, while worker authority is obtained separately before task delivery. Blocking-tail evidence precedes readiness in the general evaluator; mailbox settlement deliberately omits that tail check and retains its delivery-specific interpretation of the shared ranking.

Resilience and Maintainability Implications

  • observed — Mailbox delivery serializes flights per PTY, releases them on synchronous and delayed-submit terminal paths, and checks current PTY identity and writability before delayed Enter. Worker-start failure produces a failure receipt; created PTY cleanup remains explicitly owned by later worker release rather than automatic teardown.

Hardening Proposals

  • proposed — Future hardening could require fresh live evidence before authorizing input into clockless restored sessions and exercise busy restoration and concurrent delivery recovery. This addresses an inherited assurance limitation, not an established PR-introduced vulnerability.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely identifies the main change: preventing busy Codex 0.150–0.157 panes from being detected as tui-idle.
Description check ✅ Passed The description is complete and directly addresses the required sections. It explains the user impact, mechanism, rationale, linked issues, testing, platform considerations, known limitations, and che…
  • 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.

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

Important

Reattached/adopted Codex 0.150–0.157 panes can no longer settle tui-idle. On main the Codex header settled them synchronously at tier 1 (the text check ran before the agent gate); after this change tier 1 returns false for a named Codex pane and tier 1b/tier 3 both need a non-null output clock, which a restored record deliberately lacks. See the inline comment for the reachable path and a suggested fix.

Reviewed changes

  • Codex header demoted to the quiet lane — isKnownReadyPromptBody returns false for agent === 'codex'; isQuietReadyScreenBody now accepts both the screen (isCodexScreenHeaderReady) and text (isCodexReadyPromptPreview) header forms behind the 3 s quiescence gate. Agent-unknown panes keep the header at tier 1.
  • Tests — new codex-0-157-1-timed-sleep-turn recording (fullscreen, one sleep 25 turn) plus a timed assertion that no frame from prompt-submit to the last busy frame settles; header tests repointed at the quiet lane; the agent-unknown tier-1 decision pinned. Wait timeouts bumped for the added quiescence window.

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

The startup header box (OpenAI Codex / model: / directory:) stays on
screen and in the tail for the whole session, so as tier-1 evidence it
settled tui-idle mid-turn. For a codex pane it now counts only in the
quiet lane, held to the same quiescence as the composer.
@Jinwoo-H
Jinwoo-H force-pushed the jinwoo/codex-header-busy-reads-idle branch from 92b3042 to 5a887aa Compare September 29, 2026 22:40

@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 prior review's open concern is unchanged and still unaddressed, so this is not an approval.

Reviewed changes

  • Quiet-lane provisional veto — the Codex header-text rule (renamed isCodexReadyPromptSettled) now also rejects Codex's model: loading startup header, matching the grid (findCodexScreenReadyPromptIndex) and composer rules.
  • Tier-1 text rule realigned — isKnownReadyPromptSettled (with the provisional veto) is back in isKnownReadyPromptBody, and the header/startup-dialog tests now assert against the quiet lane.
  • Tests — the new codex-0-157-1-timed-sleep-turn recording pins that no mid-turn frame of a busy 0.150–0.157 pane settles; the provisional-startup timeout test now runs past the 3 s quiescence window; the agent-unknown tier-1 decision is pinned.

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

A restored or reattached pane has no lastOutputAt, so the quiet lane that
now holds a Codex header can never fire and the wait sat pending until
timeout, where main settled it. Gate the Codex tier-1 veto on the output
clock rather than the agent name, and share one settled-prompt helper.

@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: 54f9f2c8-8fff-4fa4-8385-42fbaa6e169b

📥 Commits

Reviewing files that changed from the base of the PR and between 5a887aa and 147a470.

📒 Files selected for processing (6)
  • src/main/runtime/codex-header-readiness-transcripts.test.ts
  • src/main/runtime/codex-quiet-ready-screen.test.ts
  • src/main/runtime/codex-startup-dialog-transcripts.test.ts
  • src/main/runtime/terminal-wait-detection.ts
  • src/main/runtime/tui-idle-evidence.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.

@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 found. The prior review's open concern is resolved in this delta.

Reviewed changes

Reviewed the commits since the prior pullfrog review (5a887aa → 147a470), which close out the restored-pane gap flagged earlier.

  • Codex tier-1 veto now gated on the output clock — isKnownReadyPromptBody gained a hasOutputClock parameter; it returns false for a codex pane only when an output clock exists, so a restored or reattached pane with lastOutputAt === null settles from its header again, exactly as on main.
  • Clock threaded from both wait sites — leafTuiIdleEvidence and ptyTuiIdleEvidence pass leaf.lastOutputAt !== null / pty.lastOutputAt !== null.
  • One shared settled-prompt rule — isReadyPromptSettled now backs both isKnownReadyPromptSettled and the quiet-lane codex text path, and the redundant isCodexReadyPromptSettled helper is gone; behavior is unchanged.
  • Regression coverage — a runtime test seeds a restored codex tail and mocks the terminal read to screen-unavailable, asserting the wait still settles inside 2.5 s (i.e. via tier 1, before the 3 s quiet window); evaluateTuiIdle cases pin clockless (null, settles), epoch (0, settles via the quiet lane), and future (pending) clocks; the previous thread is resolved.

Verified locally: the four changed test files pass (213 tests), including the new restored-pane test and the timed busy-turn tests.

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

@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 found. The prior open concern is resolved, and the only commit since the last review is a test-only determinism fix.

Reviewed changes

Reviewed the commit since the prior pullfrog review (147a470 → e68620a): test-only changes to codex-quiet-ready-screen.test.ts.

  • Pinned the system clock in the codex header readiness cases — the it.each cases for lastOutputAt null / 0 / recent now call vi.useFakeTimers() and vi.setSystemTime(NOW), and the enclosing describe restores real timers in afterEach, so the assertions no longer depend on wall-clock drift between module load and test run.
  • Replaced the future-clock case with a realistic recent one — the third case changed from Date.now() + 60_000 to NOW - 1_000, so it asserts "output 1 s ago, inside the 3 s quiet window → pending" instead of a clock ahead of the test. The null and 0 cases still pin the quiet-lane settle (ready-strong).

No production behavior changed. Verified codex-quiet-ready-screen.test.ts passes locally (53 tests).

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

@Jinwoo-H
Jinwoo-H merged commit fb67d5d into main Sep 30, 2026
45 checks passed
Jinwoo-H added a commit that referenced this pull request Sep 30, 2026
…23805)

* fix(runtime): stop a busy Codex 0.150-0.157 pane reading as tui-idle

The startup header box (OpenAI Codex / model: / directory:) stays on
screen and in the tail for the whole session, so as tier-1 evidence it
settled tui-idle mid-turn. For a codex pane it now counts only in the
quiet lane, held to the same quiescence as the composer.

* fix(runtime): keep a restored Codex pane's header as tier-1 readiness

A restored or reattached pane has no lastOutputAt, so the quiet lane that
now holds a Codex header can never fire and the wait sat pending until
timeout, where main settled it. Gate the Codex tier-1 veto on the output
clock rather than the agent name, and share one settled-prompt helper.

* test(runtime): read no screen in the restored Codex pane test

* test(runtime): pin the clock in the clockless Codex header cases

* test(runtime): name the screen-readiness comparison for what it proves

(cherry picked from commit fb67d5d)
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