Skip to content

fix(runtime): report Codex's plan menu as blocked after its hook's done - #26492

Closed
Jinwoo-H wants to merge 1 commit into
mainfrom
readiness/screen-blocker-override
Closed

Jinwoo-H wants to merge 1 commit into
mainfrom
readiness/screen-blocker-override

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​23 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​22

ELI5

When Codex finishes a plan, it shows a menu asking "Implement this plan?". Orca was supposed to report "waiting on a menu" there, but said "ready" instead, so the next message picked a menu option. Orca saw the menu but filed that observation where window-backed terminals don't look. Now it records it in both places, and anything reading the status first catches up on a check that hadn't run yet.

What Changed

  • Before: with the plan menu on screen, terminal wait --for tui-idle returned satisfied: true in about 0.1 s, with no blockedReason.
  • After: it returns satisfied: false, blockedReason: agent-interactive-prompt, and settles ready once the menu is answered.

Mechanism (traced by replaying the real Codex 0.160 bytes through the runtime):

  • Codex's Stop hook reports "done" before the menu is drawn. The menu's rule did match. The arbiter compares when blocked text appeared against when the hook said done, and the comparison logic was correct.
  • The scan that stamps "blocked text appeared" runs at most every 50 ms. The menu's last bytes are caught by its delayed follow-up run.
  • That delayed run stamped only the PTY record. Each new chunk of output copies the PTY's stamp to the pane's own record, but the menu was the last chunk, so the pane kept the older stamp. A window-backed terminal reads the pane's stamp, so the hook's "done" looked newer and the wait settled ready.
  • A wait issued inside that 50 ms window also read a stale stamp, even on the PTY record.
  • Fix:
    • the delayed scan also stamps panes that mirror the PTY's output;
    • the status snapshot first runs any scan still pending, so no reader judges against a stale stamp.
  • No agent-specific code, no waits or retries. Agents whose hooks fully decide readiness are untouched.

Why

  • This keeps the existing design, a newer on-screen blocker beating an older hook "done" for agents whose hooks only report turn end, and fixes the stamp that design depends on.
  • Alternative considered: add Codex to the per-agent screen-veto list. Rejected, because the blocker rule already worked and a per-agent veto would hide the real bug for every other turn-end agent.

Linked Issue

Fixes #25912

Visual Proof

N/A: no UI change. This changes a readiness wait's result; evidence is under Testing.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New test (tui-idle-codex-plan-menu.test.ts), replaying the captured Codex 0.160 menu bytes through the runtime:

    • Hook done, then the menu: blocked.
    • Answering 3 returns the composer: ready.
    • Output that only quotes the menu wording before a done stays ready.
    • On the base commit it fails (expected 'ready' to be 'blocked:agent-interactive-prompt'). Stamping the pane copy alone was not enough; the pending-scan flush is needed too.
  • Live run (macOS, isolated background dev runtime, codex 0.161):

    • A /plan turn ended in the menu. The hook store had Codex's Stop, and the wait at the menu was blocked; after answering 3 it was ready.
    • Caveat: headless dev terminals read the PTY record, not the pane copy, so this live run doesn't exercise the pane path where the bug lived. The replay test above covers that path.
  • Checks: pnpm tc and check:code-quality:changed are clean, and 28 related suites pass.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote and wire: host-side only, no wire change.
  • Performance: the flush runs a scan only when one is already pending.
  • Unchanged edge case: the delayed scan stamps the current time rather than the bytes' arrival time, which is the same as main.

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)

…ne's leaf (STA-9655)

The blocked-text scan is throttled, so a dialog whose last bytes arrive within
50 ms of a previous scan is stamped on a trailing-edge timer. That stamp went
only to the PTY record: its mirroring leaves had already copied the old value,
and a pane-backed wait reads the leaf's. The permission arbiter therefore saw
the hook's `done` as the newest event and let tui-idle settle ready over
Codex's "Implement this plan?" menu, which Codex paints after its Stop hook.

The trailing-edge stamp now reaches the leaves that mirror the PTY's tail, and
a status snapshot runs a pending scan first, so a wait issued inside the
throttle window judges the menu too. Replayed against the 0.160.0 capture.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 9491a802-13b4-49f0-9778-a17212198701
📥 Commits

Reviewing files that changed from the base of the PR and between 0eee1ce and 0549925.

📒 Files selected for processing (4)
  • src/main/runtime/orca-runtime-schedule-wait-blocked-check.ts
  • src/main/runtime/orca-runtime-stop-requested-pty-ids.ts
  • src/main/runtime/runtime-terminal-agent-status-query.ts
  • src/main/runtime/tui-idle-codex-plan-menu.test.ts

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


📝 Walkthrough

Walkthrough

The runtime adds an immediate flush for pending blocked checks and stamps matching PTY leaves when it detects a new blocked reason. Terminal status snapshots flush pending stamps before reading terminal state. New tests cover a displayed Codex plan menu and quoted menu text.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 05499

This change makes the TUI-idle wait report the Codex plan menu as blocked instead of ready. No actionable merge-blocking risk was identified in the supplied changes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: reporting Codex's plan menu as blocked after the hook reports done.
Description check ✅ Passed The description follows the required template and explains the user impact, mechanism, rationale, linked issue, testing, scope, and checklist status. It also documents the unchecked broader commands r…
Linked Issues check ✅ Passed Direct issue #25912 requires tui-idle to report blockedReason: "agent-interactive-prompt" while Codex's plan menu is visible and to return ready after the menu is answered. The change stamps PTY-m…
Out of Scope Changes check ✅ Passed The changed runtime methods, dependency wiring, and tests all support the #25912 Codex plan-menu readiness behavior. The changes do not add agent-specific readiness logic, unrelated product behavior, …
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@nwparker

Copy link
Copy Markdown
Contributor

Superseded by #33335 (rebased onto the moved wait-blocked checks, with your co-author credit). Thanks @Jinwoo-H!

nwparker added a commit that referenced this pull request Oct 25, 2026
…r its Stop hook (#33335)

Keep tui-idle blocked when Codex paints its plan menu after the Stop hook.

Fixes #25912
Supersedes #26492

Co-authored-by: Jinwoo Hong <[email protected]>
@nwparker nwparker closed this Oct 25, 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.

[Bug]: tui-idle still reports Codex's 'Implement this plan?' menu as ready on 1.4.221 (hook done short-circuits the #24536 anchor)

2 participants