Repository navigation
fix(runtime): stop a name-only agent title from satisfying tui-idle - #20155
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe change adds shared TUI-idle evidence ranking. It records explicit agent status on PTY records and uses pane-agent identity, first-party status, body evidence, foreground-process state, and quiescence. Terminal wait polling and runtime waiter resolution now use the shared predicate. Tests cover streaming output, explicit idle titles, quiet processes, permission states, name-only titles, and real PTY behavior. Priority: ⬆️ High Merge Risk: 🟡 Moderate · up to TUI-idle can remain blocked after a PTY replacement or report idle while first-party work is active. Resolve these evidence-refresh gaps before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Name-only idle provenance —
detectAgentStatusFromTitlenow emits a paralleldetectAgentTitleIdleEvidencethat tags eachidleverdict asexplicitorname-only, without changing the verdict itself (sidebar,worktree ps, and mobile spinner-clearing semantics are preserved). - Write-time evidence stamp — a new optional
lastAgentIdleEvidencefield is stamped on pty/leaf records inapplyTrackedPtyTitle, the headless-seed path (applySeededAgentStatus), and the done-hook exit recovery;stored-agent-idle-evidence.tsis the only reader. - Settlement gating — all four
terminal wait --for tui-idlesatisfaction sites (the immediate paths inruntime-terminal-wait.tsand the sweep ticks inruntime-terminal-idle-polls.ts) now require positive evidence, parking name-only idles on a quiescence + live-foreground corroboration poll. - Scoped demotion —
nameOnlyIdleNeedsCorroborationgates demotion ongetSyntheticAgentTerminalTitle(agent, 'done'), so churning name-only agents (Grok) keep their prior immediate-settle behavior instead of losingtui-idleto a perpetual timeout. - Tests — poll-lane unit coverage, an OSC-title-pipeline E2E test, a demotion-scope test, and a real-PTY integration test driving a genuine
node-ptyfixture that emits real\033]0;…\007control bytes.
The core reasoning is sound and the fix is tight: the detector keeps its display meaning while the settlement decision moves to a provenance stamp that only the wait path reads. I traced the transition edge (explicitIdle && !prevExplicitIdle), the exit-recovery provenance (confirmedStatus === 'idle' ? 'explicit' : …), the headless-seed stamp, and all resolve*TuiIdleWaiters call sites — the evidence gate is consistently applied and the unstamped-reads-positive fallback is safe because RuntimeSyncedLeaf never carried lastAgentStatus, so no new wire surface and no mirroring hazard. The Grok/OpenCode "no explicit idle channel" carve-outs match the enumerated provider table, and the residual risk (repainting TUIs with synthetic titles still depend on their hook) is explicitly documented rather than papered over.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
d880dc9 to
c3b1161
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e9bfdfb6-a257-4ddb-9979-23aa191d5a44
📒 Files selected for processing (13)
src/main/runtime/orca-runtime-apply-tracked-pty-title.tssrc/main/runtime/orca-runtime-on-pty-data.tssrc/main/runtime/orca-runtime-resolve-exit-waiters.tssrc/main/runtime/orca-runtime-runtime-id.tssrc/main/runtime/runtime-terminal-idle-polls.test.tssrc/main/runtime/runtime-terminal-idle-polls.tssrc/main/runtime/runtime-terminal-state-records.tssrc/main/runtime/runtime-terminal-wait.tssrc/main/runtime/terminal-wait-name-only-idle.test.tssrc/main/runtime/tui-idle-agent-fixture.mjssrc/main/runtime/tui-idle-evidence.tssrc/main/runtime/tui-idle-name-only-real-pty.integration.test.tssrc/shared/pane-agent-identity-inventory.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
There was a problem hiding this comment.
Important
Two issues in the new evidence-ranking code: the first-party veto is ordered after the tier-1 positive return, so it can never veto an explicit idle title despite the documented contract; and the new lastExplicitAgentStatus field is never cleared when a PTY id is reused, so a stale non-done status suppresses tui-idle for up to 30 minutes after a daemon respawn.
Reviewed changes
- Read-time evidence ranking — replaced the prior write-time provenance stamp with
src/main/runtime/tui-idle-evidence.ts, deriving the rank fromlastOscTitle/lastOutputAtso asyncWindowGraphleaf rebuild cannot drop it and re-open #6011. - First-party OSC 9999 veto — added
lastExplicitAgentStatustoRuntimePtyWorktreeRecordandhasFreshWorkingFirstPartyStatus, intended to let the agent's own status stream override inferred idle. - Tier-3 corroboration —
hasSustainedTitleIdledemandsTUI_IDLE_QUIESCENCE_MSof quiet for agents that announce rest explicitly, andquietForegroundProcessProvesTuiIdlerestricts the quiet-foreground lane to panes Orca did not launch a known agent on (#9976). - Live leaf re-read — the idle poll re-reads the current leaf every tick instead of the registration-time capture, fixing the frozen
lastOutputAtfalse settle. - Unified settlement sites —
ptySatisfied/leafSatisfiedand the resolve-exit-waiters re-rank guards route every wait site throughisTuiIdleSatisfied; the idle transition guard relaxed toprevStatus !== 'permission'. - Tests — new
terminal-wait-name-only-idle.test.ts, a real-node-ptyintegration test with a control-byte fixture, and poll-lane/identity-inventory updates.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
|
||
| /** The one place the three tiers are combined; every satisfaction site routes here. */ | ||
| export function isTuiIdleSatisfied(input: TuiIdleSatisfactionInput): boolean { | ||
| if (input.positiveBodyEvidence || hasExplicitIdleTitle(input.record, input.rendererTitle)) { |
There was a problem hiding this comment.
The tier-2 veto can never veto tier 1: this returns true on an explicit idle title (or ready-prompt body) before hasFreshWorkingFirstPartyStatus is consulted, yet the doc directly above says the agent's own OSC 9999 status "outranks anything inferred" and the PR body says a fresh working/blocked/waiting status "vetoes — never idle". For synthesizeWorkingTitle: false agents (codex/pi/omp) a new turn's hook status does not repaint the lingering Codex ready/Pi ready title, so a pure OSC 9999 working chunk leaves both signals present and terminal wait --for tui-idle settles immediately.
Technical details
# Tier-1 positive short-circuits before the first-party veto
## Affected sites
- `src/main/runtime/tui-idle-evidence.ts:121-128` — `isTuiIdleSatisfied` returns at the `positiveBodyEvidence || hasExplicitIdleTitle` check before `hasFreshWorkingFirstPartyStatus`.
- `src/main/runtime/terminal-wait-name-only-idle.test.ts:146-183` — the only veto case uses a name-only title; no case pairs an explicit idle title with a fresh `working` first-party status.
## Required outcome
- A fresh non-`done` first-party status must be able to prevent settlement when an explicit idle title is present, per the documented contract — or the contract must be corrected.
## Open questions for the human
- Is the intended precedence "explicit title wins" or "first-party status wins"? The file comment and PR body say the latter; the code implements the former.| if (latestAgentStatus) { | ||
| const ptyRecord = this.ptysById.get(ptyId) | ||
| if (ptyRecord) { | ||
| ptyRecord.lastExplicitAgentStatus = { |
There was a problem hiding this comment.
lastExplicitAgentStatus is written here but never cleared. resetTrackedTerminalStateForProviderGeneration nulls lastOscTitle, lastAgentStatus and the other sibling fields precisely because prior-process state must not bleed into a reused PTY id, and onPtyExit likewise leaves it — so a stale working/blocked/waiting value survives a same-id respawn and vetoes tier 3 for AGENT_STATUS_STALE_AFTER_MS (30 min).
Technical details
# New PTY-record field survives provider-generation reset / exit
## Affected sites
- `src/main/runtime/orca-runtime-on-pty-data.ts:221-229` — sole write of `lastExplicitAgentStatus`.
- `src/main/runtime/orca-runtime-apply-tracked-pty-title.ts:147-184` — `resetTrackedTerminalStateForProviderGeneration` clears `lastOscTitle`/`lastAgentStatus`/`lastAgentStatusObservedLive` but not the new field.
- `src/main/runtime/orca-runtime-on-pty-exit.ts:218` — exit path resets `lastAgentStatusObservedLive` but not the new field.
- `src/main/runtime/tui-idle-evidence.ts:57-59` — `isFreshNonDoneAgentStatus` treats any non-`done` state as fresh for 30 min.
## Required outcome
- A reused PTY id must not inherit a prior process's first-party status, so a name-only idle can still settle at `TUI_IDLE_QUIESCENCE_MS` after respawn.
## Suggested approach
- Null `pty.lastExplicitAgentStatus` in `resetTrackedTerminalStateForProviderGeneration` alongside `lastAgentStatus`, and on PTY exit; add a reset-then-settle regression test.4090c4f to
81a4206
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 69b2414a-ca8c-4974-92a2-72b3f7e6078b
📥 Commits
Reviewing files that changed from the base of the PR and between 4090c4f and 81a4206627d691f4318ff2f88536086d70cd0dc0.
📒 Files selected for processing (3)
src/main/runtime/terminal-wait-name-only-idle.test.tssrc/main/runtime/tui-idle-name-only-real-pty.integration.test.tssrc/main/runtime/tui-idle-wait-test-harness.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
b7525f9 to
23b38f6
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 47857ebb-cc65-409c-be35-0cf1603d1f5a
📥 Commits
Reviewing files that changed from the base of the PR and between 81a4206627d691f4318ff2f88536086d70cd0dc0 and b7525f979cfebe9b2a1b81aafafee9530e80c6f9.
📒 Files selected for processing (5)
src/main/runtime/orca-runtime-apply-tracked-pty-title.tssrc/main/runtime/orca-runtime-resolve-exit-waiters.tssrc/main/runtime/runtime-terminal-idle-polls.tssrc/main/runtime/runtime-terminal-wait.tssrc/main/runtime/tui-idle-evidence.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| pty.lastOscTitleAt = null | ||
| pty.lastOscTitleEpochMs = null | ||
| pty.lastAgentStatus = null | ||
| // Why: the prior process's first-party status would otherwise veto idle for its | ||
| // replacement — a stale `working` keeps tui-idle unresolved on the new generation. | ||
| pty.lastExplicitAgentStatus = null | ||
| // Why: the prior process's live frames say nothing about the replacement, | ||
| // so the seed a same-id restore applies must not inherit its authority. | ||
| pty.lastAgentStatusObservedLive = false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clear stale first-party status on every provider-generation replacement.
When postSpawnSequence > 0, the replacement path skips resetTrackedTerminalStateForProviderGeneration. The prior process's fresh working, blocked, or waiting status remains available to tui-idle evaluation and can keep the replacement unresolved.
Clear lastExplicitAgentStatus on this replacement path, while preserving the current-generation snapshot state required by the snapshot-preference path.
| const live = this.deps.getLiveLeaf(entry.leaf) | ||
| if ( | ||
| foreground && | ||
| !isShellProcess(foreground) && | ||
| (leaf.lastOutputAt ? Date.now() - leaf.lastOutputAt : 0) >= this.deps.quiescenceMs | ||
| (live.lastOutputAt ? Date.now() - live.lastOutputAt : 0) >= this.deps.quiescenceMs | ||
| ) { | ||
| this.stop(entry) | ||
| this.deps.resolve(waiter, buildTerminalWaitResult(waiter.handle, 'tui-idle', leaf)) | ||
| this.deps.resolve(waiter, buildTerminalWaitResult(waiter.handle, 'tui-idle', live)) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Re-apply the active-state veto after getForegroundProcess resolves.
Both continuations capture active-state evidence before the await. They then check only the foreground process and output age. A pane can gain an agent identity or a fresh non-done first-party status while the read is pending, so the continuation can resolve tui-idle for a busy TUI. Re-check this.entries.has(entry), lastAgentStatus, getPaneAgent(...), and the fresh first-party status before resolving.
The title callbacks re-rank current evidence, but RuntimeTerminalWaiterRegistry.remove only removes the poll entry. It does not cancel the suspended continuation.
This is a functional-correctness failure because callers can treat a busy TUI as ready and send work at the wrong time.
| export type TuiIdleSatisfactionInput = { | ||
| record: TuiIdleEvidenceRecord | ||
| /** Renderer-synced pane/tab title, when one exists. */ | ||
| rendererTitle?: string | null | ||
| /** Tier 1 body evidence: a known ready prompt, or an adopted pane's explicit title. | ||
| * A thunk because producing it means building the pane's wait text and lowercasing it | ||
| * (~11us and a multi-KB string on a full tail); the title check below usually answers | ||
| * first, and then none of that has to happen at all. */ | ||
| readPositiveBodyEvidence: () => boolean | ||
| agent: TuiAgent | null | undefined | ||
| firstPartyStatus: FirstPartyAgentStatus | ||
| quiescenceMs: number | ||
| } | ||
|
|
||
| /** The one place the three tiers are combined; every satisfaction site routes here. */ | ||
| export function isTuiIdleSatisfied(input: TuiIdleSatisfactionInput): boolean { | ||
| // Why the title before the body: both are tier 1, so either settles, but the title is a | ||
| // memoized lookup and the body is a fresh multi-KB scan. Same verdict, cheaper order. | ||
| if (hasExplicitIdleTitle(input.record, input.rendererTitle) || input.readPositiveBodyEvidence()) { | ||
| return true | ||
| } | ||
| if (hasFreshWorkingFirstPartyStatus(input.firstPartyStatus)) { | ||
| return false | ||
| } | ||
| return hasSustainedTitleIdle(input.record, input.agent, input.quiescenceMs) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Evaluate fresh first-party status before positive idle evidence.
isTuiIdleSatisfied returns true for an explicit idle title or known ready-prompt body before it calls hasFreshWorkingFirstPartyStatus. The runtime stores the latest OSC 9999 working or blocked state and passes it to this helper. A visible prompt or idle title can therefore resolve tui-idle during active or blocked work, violating the #9905 contract. Evaluate the first-party status veto before the title/body checks.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor coverage suggestion inline.
Reviewed changes
- Cleared
lastExplicitAgentStatuson provider-generation reset, so a replaced daemon session cannot inherit the prior process's first-party status. - Gated the idle re-rank on both PTY and leaf title application to skip unchanged idle repaints; waiters stay covered by the poll, which re-checks each tick.
- Held tier-3 corroboration for agents that announce rest explicitly when the pane has no local output clock (
lastOutputAt === nullnow refuses instead of settling). - Made tier-1 body evidence lazy (
readPositiveBodyEvidencethunk) and checked the title first — same verdict, cheaper.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // no local output clock, so for an agent that WILL announce rest explicitly there is no | ||
| // corroboration available at all. Settling here let a busy Codex/Devin satisfy the wait | ||
| // from a name-only title (#6011); hold out for tier 1/2 or the caller's timeout instead. | ||
| if (record.lastOutputAt === null) { |
There was a problem hiding this comment.
lastOutputAt === null is the new guard that stops an adopted/daemon-backed pane from settling on a name-only title (#6011), but nothing pins it: makeTuiIdlePty/makeTuiIdleLeaf default lastOutputAt to Date.now(), and the lastOutputAt: null fixtures in runtime-terminal-idle-polls.test.ts pass agent: null, so they exit through nameOnlyIdleNeedsCorroboration before reaching this line. A case with agent: 'codex', lastAgentStatus: 'idle', lastOscTitle: 'Codex', lastOutputAt: null that asserts a timeout would lock the fix in.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
src/main/runtime/orca-runtime-on-pty-data.ts (1)
225-228: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winClear
lastExplicitAgentStatuswhenrecordPtyWorktreereplaces an incarnation.An SSH reattach can omit
providerSequence, so provider-generation reset does not run.recordPtyWorktreethen updatesincarnationIdbut retains the previous status.resolveExitWaiterspasses that status toisTuiIdleSatisfied, where a freshworkingstatus can block name-only idle evidence.Clear the status in the existing-record incarnation-change branch in
src/main/runtime/orca-runtime-record-pty-worktree.ts. This is the lifecycle boundary shared by SSH registration and controller inventory.pty.agentSessionOwners = [] + pty.lastExplicitAgentStatus = null
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f8486ab8-75cb-4cd7-88ec-96bd70c74a70
📥 Commits
Reviewing files that changed from the base of the PR and between b7525f979cfebe9b2a1b81aafafee9530e80c6f9 and 23b38f6b6a5bf1572e0f7da1d2b3fb4a8b216b0c.
📒 Files selected for processing (1)
src/main/runtime/tui-idle-name-only-real-pty.integration.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
…ilence `terminal wait --for tui-idle` returned satisfied in ~0s while an agent was mid-turn. The shared title detector defaults a name-only agent title to `idle` so the sidebar can clear a stale spinner, and the wait accepted that stored value as completion. Rank the evidence instead. An explicit idle marker in the agent's own title or a known ready prompt settles the wait; a fresh first-party OSC 9999 status saying working/blocked/waiting vetoes it; a name-only title is a last resort that settles only once the stream has also gone quiet. The rank is derived at read time from `lastOscTitle` rather than stamped onto the record, because `syncWindowGraph` rebuilds leaves from an explicit field list and would drop a bespoke provenance field on any renderer publish. Two things the ranking alone gets wrong are handled here too. A quiet non-shell foreground process no longer proves idle on a pane where Orca launched a known agent — that is an agent still booting, and resolving on it is what let `dispatch --inject` lose the prompt (#9976). And the idle poll re-reads the live leaf each tick, because a record captured at registration stops advancing and its frozen `lastOutputAt` makes the quiescence gate pass while the pane streams. The demotion is scoped to agents that go on to announce rest explicitly. Grok, Copilot, Aider, Mimo, agy and OpenCode emit their name and nothing more at rest: a real idle Grok pane repaints its banner about four times a second forever, so demanding quiescence from it left no settle signal at all and the wait ran to timeout. The design is Brennan Benson's, from #14642, which won a cross-review against #6012, #6555 and this branch's earlier approach; it is ported here only because that branch shares no git history with main and cannot be merged. Neil's #6555 first drew the explicit-vs-ambiguous line the ranking rests on, and Revofusion's #6012 first identified that a single title sample cannot prove completion. Fixes #6011 Co-authored-by: Brennan Benson <[email protected]> Co-authored-by: Neil <[email protected]> Co-authored-by: Revofusion <[email protected]>
23b38f6 to
3475735
Compare
D-007's two predicted ratchet conflicts landed exactly as described and were recomputed per its recipe. Upstream stablyai#20155 tightened tui-idle ranking without changing the wait reply shape, so the delivery needs no change — but the readiness timings measured on device came from the old semantics and should be re-measured. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ddyy32VYir3LAeFDHv71UT

Credit
The design in this PR is @brennanb2025's, from #14642. It won a cross-review against every other open fix for #6011 — including the approach this branch previously carried — and it is reproduced here rather than merged only because #14642 shares no git history with
main(different root commit;git mergerefuses unrelated histories, and the same is true of #6012, #6555 and #9929). Nobody can merge that branch as it stands. This is not us taking the work: if that branch can be rebased, we will close this PR in favour of it.Specifically theirs, and named so the merged commit does not obscure it:
lastOscTitlerather than stamping provenance onto the record. This is the part that fixes a real defect in our earlier approach:syncWindowGraphrebuilds every leaf from an explicit field list, so our bespoke field was dropped on any renderer publish and terminal wait --for tui-idle returns satisfied:true in ~0s while an agent TUI is actively working #6011 came straight back — measured: wait correctly refused before a graph sync,satisfied=truein 0ms after it.quietForegroundProcessProvesTuiIdle— a quiet non-shell foreground process must not prove idle on a pane where Orca launched a known agent, because that is an agent still booting. Our earlier approach leaned on exactly that signal and so likely reintroduced thedispatch --injectprompt-loss bug in [Bug]: slow Claude startup lets tui-idle false-positive and loses injected dispatch (v1.4.149) #9976.lastOutputAtfreezes, and the quiescence gate then passes while the pane is still streaming: measured, settled at 4005ms during 12s of uninterrupted output.We verified their branch standalone before adopting it, rather than taking the design on faith. It passed.
@nwparker's #6555 first drew the explicit-vs-ambiguous line the whole ranking rests on, and derived it from
lastOscTitlerather than a stored field — the structural choice that makes it robust. @revofusion's #6012 was first to the root cause: a single OSC-title sample cannot prove completion, becausedetectAgentStatusFromTitledefaults a name-only title toidle.Two things here are ours: the Grok scoping below, and a small tier-1 fix — tier 1 read only the renderer-synced pane title, so a daemon-hosted or background pane dropped an explicit
Codex readyto the quiescence lane and waited the whole window for a result it already had (4005ms → 0ms, rows D/E below).Fixes #6011
In plain terms
Scripts and automations can ask Orca to "wait until this coding agent has finished". Orca was answering "it's already finished" the instant it was asked, while the agent was still busy working — because it was reading the agent's terminal title, and a title showing nothing but the agent's own name (just "Codex") was being treated as a finished signal. But agents show that same bare-name title while they're mid-task, so anything chained onto that wait would charge ahead and act on half-done work.
Now a bare name on its own is no longer accepted as proof. Orca waits for the agent to actually say it's done — an explicit "ready"/"done" marker in its title, its own finished-signal, or its familiar ready prompt on screen — and if the agent reports that it is still working, that overrides everything else. For agents that never say anything more than their name, Orca falls back to checking that the pane has genuinely stopped producing output. If no such proof arrives, the wait runs out its clock and reports a timeout instead of claiming a success it cannot back up.
Evidence ladder
✳, Gemini◇, Pi/OMPπ -, OpenCodeOC | …,ready/idle/done,*prefix), read from either the renderer-synced pane title orlastOscTitle; or a known ready-prompt body (Codex, Cursor, Antigravity); or an adopted pane's explicit titleTUI_IDLE_QUIESCENCE_MSclaude)Why the Grok scoping
Every approach in this set demanded output quiescence before accepting a name-only title. Driving the real
grokbinary through a real PTY shows that cannot work:grokOSC title at rest, so it lands in tier 3;isKnownReadyPromptPreviewdoes not match its banner, and it has no synthetic idle title.So a genuinely idle Grok pane had no path to tier 1 or 2 and could never clear tier 3. Measured against a real idle Grok pane through the real
terminal.waitRPC:Performance
The ranking is derived at read time rather than stamped at write time, so the fair question is whether reads now pay what writes used to. Measured, not asserted.
Where it runs. Three production call sites —
terminal.wait(per RPC call), the idle poll (per tick per waiter, 2s), andresolveTuiIdleWaiterson the PTY-data path, which is guarded by "a waiter exists on this handle". No status-read,worktree ps, mobile-projection or render path calls it.How often. Instrumented, 12 panes x 400 chunks, one pane under a wait:
The re-rank is gated on the status or title actually changing, so a repainted identical title costs nothing. That is the same cadence the stamped-at-write design had — once per title change, on waited panes only.
Cost per call.
isTuiIdleSatisfied, explicit title (tier 1)isTuiIdleSatisfied, name-only (tier 3)detectExplicitIdleStatusFromTitlebefore memobuildTerminalWaitText(200-line tail)isKnownReadyPromptPreview(7.3 KB)lastAgentStatus === 'idle'(previous behaviour)getLiveLeafRecord(40-leaf map)The title scan was never the expensive part — the body evidence was, at ~11us and a fresh multi-KB string, computed eagerly as an argument even when the cheaper title check answers first. Three fixes: a lazy
readPositiveBodyEvidencethunk with the title checked first (11,243 -> 52 ns, 216x); the change-gate above; and memoisingdetectExplicitIdleStatusFromTitleon the title string, matching the existing memo ondetectAgentStatusFromTitlein the same family (72.5 -> 7.4 ns).Under load, interleaved against the parent commit, 7 runs each:
+3.3% and +1.2% on medians, inside a ~1000 ns run-to-run spread, with byte-identical allocation. An earlier pass showed +4.9% on the no-waiter row; that was ordering bias (HEAD ran first in every pair), and reversing the order made HEAD faster. Before the change-gate the with-waiter row was +50% per chunk — though part of that was never overhead, since the parent resolves the waiter on chunk 1 (that is the bug) and stops paying, while this branch correctly keeps it alive.
Verification matrix
Real-PTY transcript
src/main/runtime/tui-idle-name-only-real-pty.integration.test.tsdrives a realnode-pty, a real long-running process emitting real\033]0;Codex\007control bytes (verified withod -c, not literal text), a realpsforeground read through the samegetForegroundProcessNamethe relay serves, and the realterminal.waitRPC handler.Before (parent commit) — the process is actively streaming under a name-only title:
After:
Why no screenshots. The evidence here is timing: the bug is a call that returned in ~0ms instead of waiting. A still image cannot distinguish a correct wait from a broken one, so the transcripts above are the proof and a screenshot would only be decoration.
Prior art — the other four PRs for #6011
main.Verification
src/main/runtime/ src/shared/— 15,655 passed, 148 skipped, 0 failedoxlintclean,oxfmt --checkclean on changed files, typecheck cleansrc/shared/pane-agent-identity-inventory.test.tsupdated for the new identity call siteResidual risk
A hookless Codex pane sitting at a bare
Codextitle now has only tier 3, so if Codex repaints at rest it will time out rather than falsely report completion. I could not drive that case end-to-end — the localcodexbinary never gets past its directory-trust prompt, where it emits no OSC title at all and the wait correctly reports blocked. Treat it as a known exposure, not a measured hang. The trade is deliberate:terminal waithas a caller-supplied timeout, and a timeout is a reportable outcome, whereas a falsesatisfiedsilently corrupts an orchestration loop.SSH and relay paths were not exercised.
pty.getForegroundProcessis pre-existing relay/SSH infrastructure and no wire surface changed here.