Repository navigation
Quiet-window Pi/OMP intermediate done so resumed work cancels notification (#6361) - #6558
Conversation
EvidenceBefore / after reasoningBefore: After: the gate is Test command + outputKey new/changed tests (all passing): Codex done-only regression guards (unchanged, still passing): Dispose/leak suite (no regression): Lint + typecheck (scoped to changed files) |
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts (1)
150-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten this rationale comment to the repo’s 1–2 line limit.
The reason is useful, but this new
Whyblock is five lines long. Please trim it to one or two lines and keep only the non-obvious constraint. As per coding guidelines "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 75c0ec20-4db2-4ef5-b604-2410024c65d6
📒 Files selected for processing (2)
src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.tssrc/renderer/src/components/terminal-pane/agent-completion-coordinator.ts
4a90846 to
410b3a2
Compare
Updated — rebased onto
|
|
@coderabbitai the 5-line rationale block has been trimmed to the 1–2 line repo limit (now a 2-line |
|
Tip For best results, initiate chat on the files or code changes.
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
…ation (#6361) Pi (pi.dev) and OMP are goal/mission agents whose normalizePiCompatibleEvent maps milestone agent_end -> hook state 'done' while they are still working. observeHookStatus gated the quiet window on `workingStatusObserved`, so these intermediate 'done' events (workingStatusObserved === false) fell through to an immediate "agent finished" notification while the TUI kept spinning, and a follow-up working event could not cancel it. Route Pi/OMP 'done' through the existing quiet window via a new doneShouldUseQuietWindow() predicate (delegating to a shared isPiCompatibleAgentType on the canonical PiAgentKind), so resumed work cancels the premature notification. Codex and other turn-end-only producers keep their immediate dispatch. Also harden the process-exit backstop: skip the agent-evidence teardown while a quiet-window 'done' is pending, otherwise a poll that finds the agent gone would clear hasAgentRunEvidence and the timer would silently drop the real completion. Co-authored-by: Orca <[email protected]>
410b3a2 to
1fb3b5b
Compare
…ation (stablyai#6361) (stablyai#6558) Pi (pi.dev) and OMP are goal/mission agents whose normalizePiCompatibleEvent maps milestone agent_end -> hook state 'done' while they are still working. observeHookStatus gated the quiet window on `workingStatusObserved`, so these intermediate 'done' events (workingStatusObserved === false) fell through to an immediate "agent finished" notification while the TUI kept spinning, and a follow-up working event could not cancel it. Route Pi/OMP 'done' through the existing quiet window via a new doneShouldUseQuietWindow() predicate (delegating to a shared isPiCompatibleAgentType on the canonical PiAgentKind), so resumed work cancels the premature notification. Codex and other turn-end-only producers keep their immediate dispatch. Also harden the process-exit backstop: skip the agent-evidence teardown while a quiet-window 'done' is pending, otherwise a poll that finds the agent gone would clear hasAgentRunEvidence and the timer would silently drop the real completion. Co-authored-by: Orca <[email protected]>
🧑🤝🧑 Impact & ELI5
1) What's broken today (ELI5). People running Orca with goal/mission-style agents (Pi from pi.dev, and OMP) get a false "your agent is finished!" notification while the agent is actually still working. The agent then looks frozen — it sits there "thinking" and won't reliably wrap up its turn, so the user has to poke it ("are you still working?") to nudge it back to life. This only happens inside Orca (the reporter never saw it using Pi directly), and only for these mission-style agents — but for the people it hits it's a real blocker, because the tool is lying to them about whether their work is done.
2) What this PR does (ELI5). Pi and OMP announce small milestones as they go ("done with step 1!") even though they're still chugging along. Orca was treating the very first "done!" as the whole job being finished and immediately pinging you. The fix makes Orca wait a brief, quiet moment after any "done!" from these specific agents before sounding the alarm — and if the agent starts working again during that pause, the premature "finished" alert is quietly cancelled. So it now says "finished" only when the agent truly stops.
3) Tradeoffs / regressions — honest answer. No regressions. The change is surgical and scoped by agent kind: only Pi and OMP now route their "done" signal through the short quiet-window delay that already existed in the codebase. Agents that only say "done" once at the real end of their turn (like Codex) are explicitly preserved and still notify instantly — a dedicated test guards that. The one honest cost: for Pi/OMP, even the legitimate "really finished" notification is delayed by that quiet-window interval (a brief pause, not a behavior loss) — and that pause is exactly what lets a resumed agent cancel a false alarm. It behaves identically on macOS, Linux, and Windows, and applies to both local and SSH/remote panes since they share the same notification logic.
Summary
Fixes #6361
Pi (pi.dev) and OMP are goal/mission agents whose
normalizePiCompatibleEventmaps milestoneagent_end(andsession_shutdown) to hook statedonewhile they are still working. Orca fired an "agent finished" OS notification at one of these intermediatedoneevents while Pi's TUI was still spinning, and a follow-up working/tool event could not cancel it.Root cause is in
observeHookStatus(agent-completion-coordinator.ts). The quiet-window path (scheduleHookDoneCompletion) — which exists precisely so resumed work can CANCEL an intermediatedone— was gated onpayload.state === 'done' && workingStatusObserved. Pi's intermediatedoneevents haveworkingStatusObserved === false, so control fell through to the IMMEDIATEdispatchCompletion('hook', …)with no quiet window.What changed
Route Pi/OMP
donethrough the quiet window. A newdoneShouldUseQuietWindow(payload)predicate widens the gate toworkingStatusObserved || isPiCompatibleAgentType(agentType). When Pi resumes (emits a tool_call/message mapped toworking), the working branch callsclearPendingHookDone()and the premature notification is suppressed — exactly the milestone-suppression behavior the quiet window was built for. Codex and other turn-end-only producers keep their immediate dispatch.Shared, typed agent-kind predicate. Rather than hardcoding
agent === 'pi' || agent === 'omp'inline (a fourth drift site), the check delegates to a newisPiCompatibleAgentType()exported fromsrc/shared/pi-agent-kind.ts, co-located with the canonicalPiAgentKind = 'pi' | 'omp'type. One source of truth; the compiler keeps it in sync if a third Pi-compatible kind is ever added.Hardened the process-exit backstop (prevents a lost notification). Routing Pi/OMP through the quiet window newly exposed them to a race: a process-inspection poll landing inside the 1.5 s window could find the agent process gone and run
clearAgentRunEvidence(), wipinghasAgentRunEvidence— so when the quiet-window timer fired,dispatchCompletion('hook', …)was blocked by the!hasAgentRunEvidenceguard and the real completion was silently dropped.handleProcessInspectionResultnow skips the agent-evidence teardown while a quiet-windowdoneis pending and reschedules a poll, so the pending hook completion remains authoritative (and process-exit detection resumes after the window). This also closes the same latent silent-drop for Codexworking→done.The change is renderer-side and provider/transport agnostic, so it applies equally to local and SSH/remote panes (both PTY-connection and hook-completion coordinators funnel through
observeHookStatus).Screenshots
No visual change. This affects OS notification timing only; verified at the unit level.
Testing
pnpm test(scoped:agent-completion-coordinator.test.ts— 55 passed;agent-completion-coordinator-dispose-leak.test.ts— 3 passed)tsgo --noEmitacross the node, cli, and web tc configs — clean (exit 0)oxlint+lint:switch-exhaustivenesson the changed/shared files — cleansrc/shared/vitest suite — 1583 passed (no regression from thepi-agent-kind.tsexport)New/updated tests:
defers a %s milestone done without prior working through the quiet window(pi, omp) — assertshasPendingHookDoneCompletion()is true anddispatchCompletionis NOT called beforeHOOK_DONE_QUIET_MS, then is called once after withquietedHookDone: true.suppresses a Pi milestone done when work resumes before the quiet window— aworkingevent before the window cancels the premature "finished".still dispatches a Codex done-without-prior-working immediately— regression guard for Codex's immediate dispatch.still fires a pending Pi done when process inspection sees the agent exit first— regression guard for the lost-notification race fixed in (3).pi/ompfrom the immediate-dispatchrecognizes %s hook agent idsit.each (they now defer); the Codex done-only tests are unchanged and still pass.AI Review Report
Reviewed for correctness, edge cases, and cross-platform behavior; adversarially verified against current
main.normalizePiCompatibleEvent, and several existing tests assert immediate dispatch for Codex/others. Making every provider quiet would add a 1.5 s delay to every completion and break the Codex done-only contract.waiting/blockedandshouldSuppressHookCompletionstill cancel a provisional done; resumed turns re-fire; the new process-exit guard delays (never drops) process-exit completions and has no path that pauses polling forever.Security Audit
No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes. The diff reads an already-parsed
agentTypestring from an existing hook payload and branches on it, and adds a purestring → booleanpredicate. No new external input is trusted, no new surface introduced.Notes
agent_endcontract in the future, add them toPiAgentKind/isPiCompatibleAgentType(or generalize to a capability flag on the agent identity).Made with Orca 🐋