Repository navigation
fix(agent-status): announce Claude turn complete while background work runs - #14580
Conversation
…k runs Lead Stop/StopFailure already ends the turn, but resolveClaudePaneState keeps the pane working for subagents, background shells, and session crons. That erases the working→done edge that mints the completion banner: subagent turns notify late with a stale body, and shells/crons never notify at all. Stamp turnCompletedAt on the gated lead Stop, announce immediately from that row, and pair the later all-clear done to the same end time so it cannot double-fire or collapse consecutive turns onto the pinned stateStartedAt. Fixes #13245
|
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
… ordering The stored row inherited the helper's default codex agentType while the event named claude, so agentSnapshotMatchesExplicitTitle dropped it and freshStoredAgentStatus was undefined — the assertion held under either side of the `??`. Name the stored row's agent so the pinned working row survives and the snapshot-first precedence is what the test actually pins.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
31394-31418: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winConsolidate the repeated hook-row lookup for
paneKey.
getHookAgentRowForPane(getHookRowsForPane(paneKey))can run up to three times for the same pane inside this method: once forhookAgentStatus(whentab.agentStatusis set), once insidebuildPtyMobileAgentStatus, and again here as theturnCompletedAtfallback.getHookRowsForPanecaches the raw rows, butgetHookAgentRowForPanere-scans those rows each call.This method runs on every tab during every graph sync. Compute the hook agent row once per pane and pass it into
buildPtyMobileAgentStatusand theturnCompletedAtfallback, instead of gatinghookAgentStatusontab.agentStatusand re-deriving it later.♻️ Proposed consolidation
- const hookAgentStatus = tab.agentStatus - ? this.getHookAgentRowForPane(getHookRowsForPane(paneKey)) - : null + const hookAgentStatus = this.getHookAgentRowForPane(getHookRowsForPane(paneKey))Then reuse
hookAgentStatusdirectly in therawTurnCompletedAtfallback instead of callinggetHookAgentRowForPanea second time, and pass the already-computed row intobuildPtyMobileAgentStatusso it stops recomputing it internally.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4e83f9a1-fe14-47b4-8437-6a6c9626e0c3
📒 Files selected for processing (7)
src/main/runtime/orca-runtime-hook-agent-status-projection.test.tssrc/main/runtime/orca-runtime.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/runtime/web-session-tabs-agent-completion-notifications.test.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/shared/runtime-types.ts
Final-head QA — #13245 /
|
…245-turn-notification-supersede # Conflicts: # src/main/agent-hooks/server.test.ts # src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.ts # src/renderer/src/hooks/useIpcEvents.test.ts # src/renderer/src/runtime/web-session-tabs-sync.test.ts # src/renderer/src/runtime/web-session-tabs-sync.ts # src/shared/agent-hook-listener.test.ts
…245-turn-notification-supersede
…245-turn-notification-supersede
Final-head QA — #13245 /
|
|
The description says insights from #13251 and #13295 are credited below, but I can't find that section — was it dropped before merge? The two-failure analysis under "Why" — the sticky boolean swallowing turn N+1, and |
|
@brennanb2025 — flagging the above in case it got buried. No urgency. |
…k runs (stablyai#14580) * fix(agent-status): announce Claude turn complete while background work runs Lead Stop/StopFailure already ends the turn, but resolveClaudePaneState keeps the pane working for subagents, background shells, and session crons. That erases the working→done edge that mints the completion banner: subagent turns notify late with a stale body, and shells/crons never notify at all. Stamp turnCompletedAt on the gated lead Stop, announce immediately from that row, and pair the later all-clear done to the same end time so it cannot double-fire or collapse consecutive turns onto the pinned stateStartedAt. Fixes stablyai#13245 * fix(agent-status): suppress stamped turn replays * fix(agent-status): notify paired clients at turn end * Fix late-paired completion notification arming * test(agent-status): make the notification-id test fail on the pre-fix ordering The stored row inherited the helper's default codex agentType while the event named claude, so agentSnapshotMatchesExplicitTitle dropped it and freshStoredAgentStatus was undefined — the assertion held under either side of the `??`. Name the stored row's agent so the pinned working row survives and the snapshot-first precedence is what the test actually pins. * Suppress stamped completion tail replays * Prevent cross-coordinator title replays * Preserve stamped tails across fallback signals * Keep remount replay state while sibling lives * Scope OSC turn stamp preservation * Forward paired host completion stamps * Deduplicate paired completion tails * Bind paired completion tails to their turn * Preserve paired completion tail ownership * Keep paired tail replay state across remounts * Seed paired recovery without replaying completions * Seed startup replay and release stale fallback dedupe * fix(notifications): preserve stamped OSC repaints * fix(notifications): retain paired client turn boundary * fix notifications module import safety * chore: keep main integration focused * fix: preserve completion re-enable boundary
…k runs (stablyai#14580) * fix(agent-status): announce Claude turn complete while background work runs Lead Stop/StopFailure already ends the turn, but resolveClaudePaneState keeps the pane working for subagents, background shells, and session crons. That erases the working→done edge that mints the completion banner: subagent turns notify late with a stale body, and shells/crons never notify at all. Stamp turnCompletedAt on the gated lead Stop, announce immediately from that row, and pair the later all-clear done to the same end time so it cannot double-fire or collapse consecutive turns onto the pinned stateStartedAt. Fixes stablyai#13245 * fix(agent-status): suppress stamped turn replays * fix(agent-status): notify paired clients at turn end * Fix late-paired completion notification arming * test(agent-status): make the notification-id test fail on the pre-fix ordering The stored row inherited the helper's default codex agentType while the event named claude, so agentSnapshotMatchesExplicitTitle dropped it and freshStoredAgentStatus was undefined — the assertion held under either side of the `??`. Name the stored row's agent so the pinned working row survives and the snapshot-first precedence is what the test actually pins. * Suppress stamped completion tail replays * Prevent cross-coordinator title replays * Preserve stamped tails across fallback signals * Keep remount replay state while sibling lives * Scope OSC turn stamp preservation * Forward paired host completion stamps * Deduplicate paired completion tails * Bind paired completion tails to their turn * Preserve paired completion tail ownership * Keep paired tail replay state across remounts * Seed paired recovery without replaying completions * Seed startup replay and release stale fallback dedupe * fix(notifications): preserve stamped OSC repaints * fix(notifications): retain paired client turn boundary * fix notifications module import safety * chore: keep main integration focused * fix: preserve completion re-enable boundary














ELI5
When Claude finishes a turn but still has a background subagent, shell, or session cron running, Orca kept the pane marked
working. That is right for the sidebar spinner. It was wrong for the completion banner: the turn was already over, and the user was not told. This PR announces the finished turn immediately, while the pane can stayworkingfor the leftover background work.What Changed
Independently implemented from current
main(not a merge of #13251 or #13295).turnCompletedAton a Claude leadStop/StopFailurethatresolveClaudePaneStategates up toworking.done.donelifecycle while the pane is still genuinely working.turnCompletedAtwhen present, becausestateStartedAtis pinned for the whole working run.#13251 and #13295 are left open. Useful insights from both are credited below; this branch replaces them wholesale against current main.
Why
resolveClaudePaneStateis correct for pane lifecycle: leftover background work should keep the sidebar spinning. It must not gate the turn-complete announcement.Replayed the issue sequences through the real
normalizeHookPayload→observeAgentHookCompletionForNotificationpath, withstateStartedAtpinned the way the hook server pins it:Stop, that turn's own textA boolean "already notified" flag (the #13251 approach) stays sticky until a later
done. Background shells and crons never emit thatdonefor turn N, so the flag swallows turn N+1. Deriving identity fromstateStartedAt + 1also collapses every turn in one working-run onto one OS notification id. Keying both the announcement and the suppression on the turn's own end time removes both failures.Related Windows report of the same suppression: #14253 / STA-4119.
Linked Issue
Fixes #13245
Visual Proof
N/A. No layout, styling, or sidebar-state change. The pane still reports
workingfor the background lifetime; only the completion-notification timing and identity change. Proof is the hook-sequence replay inagent-hook-completion-background-turn-notifications.test.ts.Testing
Replayed on current main first: gated
Stopstaysworking, so the coordinator never sees aworking → doneedge (subagent: delayed untilSubagentStop; shell/cron: nodoneat all).Also
tsc --noEmitfor web + node, andoxlinton the touched production files.Cross-platform: no shell, path, shortcut, or platform-branch changes. The only platform-adjacent surface is OS notification identity, which still goes through
buildAgentNotificationId. New optionalturnCompletedAtis wire-safe (unknown keys ignored); old hosts simply do not stamp it.AI Disclosure
Internal.
Review
turnCompletedAtis accepted only as a finite number onworking/done. It is never interpolated into a path or command. It is not written ontoAgentStatusEntry.pickParsedAgentStatusPayloadforwards the optional field; stored pane entries still omit it.Checklist
N/Awith reasonpnpm lint/pnpm test/pnpm buildleft to CI)Author