Repository navigation
Conversation
`terminal wait --for tui-idle` returned satisfied:true in ~0s while an agent TUI was actively working. detectAgentStatusFromTitle defaults a name-only agent title (e.g. "Codex", "Devin", "aider") to 'idle' because the spinner / "esc to interrupt" live in the terminal body, not the OSC title. The tui-idle wait trusted that single instantaneous title sample, bypassing the existing TUI_IDLE_QUIESCENCE_MS debounce (only consulted in the foreground-process fallback, which runs when lastAgentStatus is null). Require *sustained* idle: a title-derived 'idle' satisfies tui-idle only after PTY output has been quiet for TUI_IDLE_QUIESCENCE_MS. Two helpers (isTuiOutputActive, hasSustainedTuiIdle) replace the bare `lastAgentStatus === 'idle'` checks at every title-derived satisfaction site (sync fast paths, in-promise checks, fallback polls, and the working->idle transition resolvers). Body-level ready-prompt detection and adopted/daemon handles with no PTY output stream keep their immediate title signal. Fixes #6011. Co-authored-by: Revofusion <[email protected]>
Verification evidence1. New regression test FAILS without the source fix (proves it catches the bug)Stashed the
2. Focused tui-idle suite PASSES with the fix (15 = 14 prior + 1 new)
3. Full test file PASSES — no regressions
Includes the previously-cited adopted-title, Codex/Antigravity ready-prompt, and quiet-background-agent tests — all green. 4. Lint + typecheck cleanBefore / after reasoning
|
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
|
Follow-up pushed in What changed:
Tradeoff status: zero added latency for explicit idle signals and ready-prompt body detection. The only remaining latency is for ambiguous name-only titles, where resolving immediately would reintroduce the original false-positive bug. Validation:
|
…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]>
…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]>
…ilence (#20155) `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]>
|
Closing this — superseded by e9065dd, which fixes #6011. You are a co-author on that commit. This PR drew the line the landed fix rests on. Two things here turned out to be structurally important:
The remaining gap, which applies to every quiescence-gated approach including ours: a real idle Also mechanical: this branch shares no git history with |
🧑🤝🧑 Impact & ELI5
1) What's broken today (ELI5). Orca lets you script your AI coding agents — for example, "wait until the agent finishes working, then do the next thing." The command for that is
orca terminal wait --for tui-idle. The bug: this "are you done yet?" check answers "yes, done!" instantly — even while the agent is still actively typing, thinking, and streaming output. So any automation built on top of it fires too early and steps on the agent mid-task. This hits anyone using Orca to orchestrate or chain agent steps (especially agents like Codex, Devin, or aider whose terminal title is just their name). It's not a crash, but for orchestration it's a real blocker: the one signal you'd rely on to know a task is finished is unreliable.2) What this PR does (ELI5). The old check trusted the terminal's title bar to decide if the agent was done. But some agents keep a plain title like
Codexwhile their spinner andesc to interruptlive in the terminal body, so a busy terminal could look idle. The fix now separates strong idle evidence from weak idle evidence: known ready prompts and explicit done/idle OSC titles still resolve immediately, while ambiguous name-only titles must also prove the terminal has gone quiet. So Orca still moves fast when the agent gives a real completion signal, but it no longer cuts in just because a weak title sample looked idle.3) Tradeoffs / regressions — honest answer. Current status: zero added latency for explicit completion signals. Body-level ready prompts and explicit idle/done OSC titles (for example
Codex done, Claude✳ ..., Gemini/Pi idle markers) satisfytui-idleimmediately. The remaining quiet wait applies only to ambiguous, non-explicit idle evidence — titles like plainCodex,Devin, oraiderwhere Orca's shared title classifier defaults toidleeven though the agent may still be working. For that weak signal, theTUI_IDLE_QUIESCENCE_MSquiet window is the necessary correctness guard: resolving immediately would reintroduce #6011. The follow-up also schedules that quiet check directly, so the ambiguous-title path resolves at the quiet deadline instead of waiting for the next 2s fallback poll. No setting, new user step, UI change, platform-specific behavior, SSH caveat, or Git-provider behavior changes.Summary
orca terminal wait --terminal <h> --for tui-idle --timeout-ms 30000 --jsonreturned in ~0s with{satisfied: true, status: running}even while the target agent TUI was actively working (spinner animating, output streaming,esc to interruptvisible). That madetui-idleuseless as a "task done" signal — it fired mid-work.Fixes #6011.
This PR supersedes community PR #6012 (I have taken over the change; the code is now maintained here). #6012 is left open for the author. Original author credited via
Co-authored-by:.Root cause
Two compounding defects:
detectAgentStatusFromTitledefaults agent titles toidle(src/shared/agent-detection.ts, final fallthroughreturn 'idle'). A title with a recognized agent name but no explicit working marker (no braille spinner, noworking|thinking|running, no Claude.prefix, noaction required|permission|waiting) falls through to idle. Agents render their spinner /esc to interruptin the terminal body, not the OSC title, so a busy agent with a name-only title (Devin,Codex,aider, …) is classifiedidle.src/main/runtime/orca-runtime.ts,waitForTerminal). It returned satisfied the momentlastAgentStatus === 'idle', with no sustained-idle requirement. The existingTUI_IDLE_QUIESCENCE_MS = 3000debounce was only consulted in the foreground-process fallback (which runs only whenlastAgentStatus === null), so a title-derivedidlebypassed it entirely.Fix
Use the strongest idle evidence first:
isKnownReadyPromptPreview) satisfy immediately because they directly detect the cursor at the input prompt.ready,idle,done, Claude✳, Gemini/Pi idle markers).idle— especially name-only titles that reachdetectAgentStatusFromTitle's broad default-to-idle fallback — satisfies only after PTY output has been quiet forTUI_IDLE_QUIESCENCE_MS.hasSatisfiedTuiIdlenow centralizes that distinction across the synchronous fast paths, in-promise registration checks, fallback polls, and transition resolvers. Ambiguous idle waits use a one-shot quiet timer, so they resolve at the quiet-window deadline rather than waiting for the next fallback poll. Push-on-idle orchestration message delivery uses the same confirmed-idle boundary, so queued text is not injected into a terminal that is still streaming output behind a name-only idle-looking title.Defect (1)'s broad default-to-idle is intentionally left in place (it's a renderer-shared classifier driving badges/indicators);
tui-idlenow neutralizes that weak signal locally without changing UI semantics. Tightening the shared classifier could be a follow-up.Screenshots
No visual change. This is a main-process timing fix; no renderer/UI surface is touched.
Testing
./node_modules/.bin/vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts -t "tui-idle|push-on-idle|already-idle agent|Cursor Agent without auto-submitting"— 20 passed./node_modules/.bin/vitest run --config config/vitest.config.ts src/main/runtime/orca-runtime.test.ts— 490 passed./node_modules/.bin/oxfmt --check src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.ts— clean./node_modules/.bin/oxlint src/main/runtime/orca-runtime.ts src/main/runtime/orca-runtime.test.ts— clean./node_modules/.bin/tsgo --noEmit -p config/tsconfig.node.json— cleanpnpm build— not run (no build-affecting change; main-process logic only)AI Review Report
Reviewed adversarially (review-until-clean) treating the original community author as potentially malicious, since this is an adopted PR:
detectExplicitIdleStatusFromTitle; the broad default-to-idle name-only path cannot use that fast path. Ambiguousidlestill depends onlastOutputAtandTUI_IDLE_QUIESCENCE_MS, and the one-shot quiet timer re-checks live state before resolving.hasSatisfiedTuiIdleor the existing explicit renderer-title/ready-prompt checks. Waiter cleanup clears the new quiet timer alongside timeout, poll interval, and abort cleanup.lastOutputAtis set from PTY data regardless of local vs remote runtime, so the ambiguous-title guard behaves identically over SSH.Security Audit
No security-relevant surface changed. No new dependencies, no
eval, no command execution, no path handling, no auth/secret access, and no network or IPC changes. The diff only adjusts in-memory title/readiness checks, timers, and the existing push-on-idle delivery gate. Re-audited the adopted community change for exfiltration / injection / traversal / suspicious deps: none found. No follow-up needed.Notes
Co-authored-by:).detectAgentStatusFromTitle's broad default-to-idle so name-only agent titles don't classify as idle in the first place. Left alone here because it's a renderer-shared classifier driving status badges and could shift UI semantics; the confirmed-idle guard neutralizes itstui-idleimpact without that risk.Made with Orca 🐋