Skip to content

fix(terminal): stop treating the Codex boot header as tui-idle readiness - #18019

Closed
Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:Tauri-EPO/codex-ready-header-loading
Closed

Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:Tauri-EPO/codex-ready-header-loading

Conversation

@Tauri-EPO

@Tauri-EPO Tauri-EPO commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Codex starts, it prints its banner with model: loading and directory: loading for a few seconds before it can take input. Orca's "is this TUI idle?" check only looked for the words model: and directory:, so it answered "yes" while Codex was still booting. worker-start then pasted the task onto the splash screen. Now the check only says "ready" once both values have actually arrived.

What Changed

  • src/main/runtime/terminal-wait-detection.ts: findCodexReadyPromptIndex reads the value after the last model: and directory: labels in the tail and rejects the header while either is empty or starts with loading. It uses the last occurrence so a stacked repaint of the settled header wins over the booting one above it.
  • src/main/runtime/terminal-wait-codex-ready-header.test.ts (new): tui-idle times out on the booting header, resolves once the values are settled, and times out while the values have not arrived yet.

Why

Measured on 2026-09-01 (Orca 1.4.194, Windows 11, 16 fresh worker-start --agent codex): 3 of 16 dispatches stalled. In the first one the dispatch receipt showed stage=dispatch_input, terminal read showed Codex still at model: loading / directory: loading, and the preamble text was scrambled across the boot screen. worker-start gates the paste on runtime.waitForTerminal(tui-idle), and that gate is satisfied by isKnownReadyPromptPreview, which for Codex only required the two labels to be present. This is the readiness half of the stall family in #15581 (closed, regressed) and #16377; the submit half is handled in a separate PR (agent-prompt composer observation).

Linked Issue

Refs #15581, #16377, #17066. Same boot race as #13439 (paste while Codex loads MCP) and the tui-idle false positive family in #9976, both of which predate this detector.

Visual Proof

N/A — no UI or interaction change. The observable difference is orca terminal wait --for tui-idle no longer resolving while the Codex header still reads loading.

Testing

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

Not tested against a live Codex boot in this session; the header shape in the tests is the one observed in the field report above and in the existing Codex ready prompt preview fixture. Ran on Windows 11:

pnpm test src/main/runtime/terminal-wait-codex-ready-header.test.ts   # 3 passed (2 failed before the fix)
pnpm test src/main/runtime/orca-runtime.test.ts                       # 1221 passed
pnpm tc:node
oxlint + oxfmt on the changed files

AI Disclosure

Written with Claude Code (Claude Fable 5.1) under direction of @Tauri-EPO, who supplied the field measurements and reviewed the diff.

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

Pure string matching on the retained tail; no platform, SSH, mobile or wire impact. A Codex build that never prints loading behaves exactly as before.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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) — tc:node, targeted tests and oxlint on changed files pass locally; full lint/build left to CI

🤖 Generated with Claude Code

Codex paints its `OpenAI Codex` header with `model: loading` and
`directory: loading` before the composer takes input. The ready-prompt
detector only checked that both labels were present, so `terminal wait
--for tui-idle` resolved mid-boot and worker-start pasted its preamble onto
the splash screen, where it landed scrambled or parked unsubmitted
(stablyai#15581, stablyai#16377, stablyai#17066 family).

Only a header whose model and directory values are settled counts now,
reading the last painted row so a stacked repaint of the settled header
wins over the booting one above it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 97b4856a-1ec8-4076-a57d-7c9fbda3fcf5

📥 Commits

Reviewing files that changed from the base of the PR and between cc8e0d7 and c0d1178.

📒 Files selected for processing (3)
  • src/main/runtime/codex-ready-header.ts
  • src/main/runtime/terminal-wait-codex-ready-header.test.ts
  • src/main/runtime/terminal-wait-detection.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Codex readiness detection now reads the latest model: and directory: values from the terminal header. It rejects headers with loading or empty values. The detection logic moved to a dedicated module. New tests verify timeout and resolution behavior through OrcaRuntimeService.waitForTerminal.

Merge Risk: 🟡 Moderate · up to c0d11

The PR tightens Codex startup detection, but the current matching can still mistake a model: token inside a directory value for a settled header, allowing input during boot; because the same readiness result also affects presence, stopping, and read probing, this remains a concrete merge-readiness risk that should be fixed or explicitly accepted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

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 6 functions across 3 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 describes the primary change: preventing Codex boot headers from being treated as terminal readiness.
Description check ✅ Passed The description covers the required sections, explains the problem and solution, links related issues, documents testing, and addresses visual proof and compatibility. Minor gaps include no explicit `…
  • Fix all pre-merge checks with AI

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

Run ID: bad3d751-4295-4cfa-9e12-348335290d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 7314ada and cc8e0d7.

📒 Files selected for processing (2)
  • src/main/runtime/terminal-wait-codex-ready-header.test.ts
  • src/main/runtime/terminal-wait-detection.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 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.

ℹ️ Minor suggestion only — the fix is correct and well-scoped; one coverage gap inline.

Reviewed changes

  • findCodexReadyPromptIndex now reads settled values — the Codex readiness check parses the value after the last model: / directory: label in the retained tail and rejects the header while either is empty or starts with loading, rather than matching on the bare labels.
  • New regression test — terminal-wait-codex-ready-header.test.ts pins three behaviors: a booting header times out tui-idle, a settled header resolves it, and empty values time out.

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

Review follow-up: `lastIndexOf('model:')` matched the label inside a
directory value such as `/tmp/model:settled`, which could pass a booting
header as settled. The fields are now located line-anchored, still taking
the last row painted, and the single-banner stacked repaint that motivated
the last-row rule has its own test. The Codex header detector moves to
codex-ready-header.ts to keep terminal-wait-detection.ts under the
max-lines budget.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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

Reviewed changes

  • Extracted findCodexReadyPromptIndex into codex-ready-header.ts — the Codex readiness matcher now lives in a dedicated module imported by terminal-wait-detection.ts.
  • Line-anchored label matching — findLastCodexHeaderFieldIndex finds the last model: / directory: row (after leading whitespace), so a directory value like /tmp/model:settled is no longer misread as the model row while the last-painted settled row still wins a stacked repaint.
  • Two new regression tests — one pins the single-banner stacked repaint resolving tui-idle; the other pins that a model: inside a directory value does not satisfy readiness.

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

@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Closing as superseded. The function this PR changed (findCodexReadyPromptIndex) no longer exists on main. Codex readiness now reads the live screen (#23475, v1.4.217), holds on the provisional model: loading startup screen (#23745, v1.4.218), and lives in rule files since #24375. The boot-header case this PR targeted is pinned by codex-header-readiness-transcripts.test.ts.

@Tauri-EPO Tauri-EPO closed this Oct 2, 2026
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