Repository navigation
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:
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: 📥 CommitsReviewing files that changed from the base of the PR and between 2b10767 and 3c4b206aed32d557a955937b94e43192defc4f86. 📒 Files selected for processing (12)
🚧 Files skipped from review as they are similar to previous changes (12)
📝 WalkthroughWalkthroughThe change adds optional 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.ts (1)
1195-1210: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThis test proves suppression through the local
lastCompletionIdentity, not the pane-scoped record.
observeTitleWorkingcallsrecordTitleWorking, which deletes the pane entry fromlastCompletionIdentityByPaneKey. The test advances 2000 ms first, so the replay guard has expired and the delete runs.turnCompletedAtAlreadyNotifiedtherefore returns false for thedoneat Line 1201, and the suppression comes from the identity comparison at Lines 931-941 ofagent-completion-coordinator.tsinstead.The comment at Lines 1195-1197 states the all-clear is recognized by the repeated turn end time. That is accurate for the identity string, but the pane-scoped all-clear path is not the mechanism here. Add a second assertion that no lifecycle-only drain path was skipped, or add a case without the title blip so the
turnCompletedAtAlreadyNotifiedbranch is covered directly.src/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.ts (1)
38-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueImport
HOOK_DONE_QUIET_MSfrom the source instead of redeclaring it.Line 38 hardcodes
1_500. If the coordinator changes its quiet window, these tests advance the wrong amount and can pass without exercising the quiet-window flush. Import the exported constant if one exists, or export it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7267674e-294d-4cd7-b6e7-8d8669ed0157
📥 Commits
Reviewing files that changed from the base of the PR and between e172a51 and 940e5bc7f1c9d2ba46a0e59069b65cb0865b97c6.
📒 Files selected for processing (12)
src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.tssrc/renderer/src/components/terminal-pane/agent-completion-coordinator.tssrc/renderer/src/components/terminal-pane/use-notification-dispatch.test.tssrc/renderer/src/components/terminal-pane/use-notification-dispatch.tssrc/renderer/src/hooks/agent-hook-completion-background-turn-notifications.test.tssrc/renderer/src/hooks/useIpcEvents.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-status-field-normalization.tssrc/shared/agent-status-types.test.tssrc/shared/agent-status-types.ts
940e5bc to
6e32897
Compare
|
Checked all three against running code. F1 is real. Of the vetoes listed, only Fixing it surfaced a second issue in the same code: recognizing the all-clear through the local mirror skipped F2 is correct. Mutating that check to F3 declined. The sibling test file already redeclares the same constant; exporting it purely for tests isn't worth the widened surface. |
d0f9960 to
23c803a
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
a0ad3b6 to
66dfdc4
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
… own end time A Claude lead turn that ends while unrelated background work is still registered — a subagent, a background shell, a session cron — has its pane gated up to `working` by resolveClaudePaneState. That gate is right for the sidebar, but it also erases the `working -> done` edge that mints the completion notification: a turn that ends by asking the user a question stays silent for the whole background lifetime, and a background shell emits no all-clear of its own, so the edge is lost outright. Stamp `turnCompletedAt` on the gated lead Stop/StopFailure, hold it on the lead-turn record, and repeat it on that turn's later all-clear `done`. The completion coordinator announces the turn as soon as the stamped row arrives and recognizes the all-clear as that same turn's tail rather than a second completion; pane lifecycle keeps following the reported `working` state, so the sidebar still shows the background work. The identity has to come from the turn's own end time and not from `stateStartedAt`. The hook server pins `stateStartedAt` for as long as the reported state does not change, and this bug is precisely "the pane never leaves `working`", so every turn in one working-run would share a single identity: turns 2..N would be dropped as replays, and their banners would close each other because the OS notification id is built from the same value. Keying the suppression on that end time rather than on a one-shot marker also means a turn whose all-clear never arrives cannot silence the next turn. Fixes stablyai#13245
…it announces Review caught the gated Stop mirroring its completion identity into the coordinator-local record before `dispatchCompletion` ran. That dispatch can be vetoed — the pane is not live, or the pane-scoped record already names this agent from an earlier title or process-exit completion — and a vetoed dispatch announces nothing and writes no pane-scoped record. The turn's later all-clear `done` then built the same identity string, matched the mirrored value, and was dropped as that turn's tail, so the turn produced no banner at all. `dispatchCompletion` now reports whether it committed, and the identity is mirrored only on a committed announcement. The reproduction is a title-driven completion for the same agent followed by a gated Stop: the cross-source dedupe vetoes the Stop, and before this change the all-clear was swallowed too. The all-clear check now reads both records that can carry the turn end time. The pane-scoped one outlives a remount; the coordinator-local one outlives a working title, which drops the pane-scoped one. Recognizing the all-clear through either of them keeps it on the drain path that still runs pane lifecycle, instead of falling into the replay dedupe that returns silently. Also closes coverage the mutation matrix surfaced: an interrupted Stop is not stamped even while a child still gates the pane to `working`, a non-finite stamp names no turn at either layer, a stamped `working` row alone does not mint a banner for a turn this coordinator never saw start, and the two-turn background-shell ledger now pins two distinct notification ids rather than two distinct bodies.
3c4b206 to
ea1fcd8
Compare
|
Rebased onto Production code is unchanged by the rebase; the ledger and the mutation matrix (23/27, same four survivors) reproduce exactly, and the #13245 sequences still misbehave on current main (cron case 0 of 3, background-shell case 1 of 2). |
Three seams the notes pass flagged as weak were assertions that no production mutation could break. The next-turn case only read the following Stop's emitted payload, whose stamp is computed fresh and is absent either way; merging the previous lead record so a stale stamp survived passed the whole suite. It now reads the lead record itself after the new prompt lands. The two-turn background-shell ledger ended its second turn with the shell already finished, so its two notification ids came from an ordinary `working -> done` transition — the weaker seam the session-cron case already pins for real. Both turns are now gated by a running shell, so both ids come from the turns' own end times. The rest closes coverage the mutation matrix still listed as missing: the turn-boundary conjunct of the stamp (a manual PostCompact reports `done` without ending a turn, and a running shell supplies the gate), the turn end time on the row that restores a lead displaced by a child's permission pause, the `done` scoping that decides whether a completion snapshot outranks the stored row for the notification id, and the completion identity built from the turn end time, which is what lets a replayed gated row pair with the banner its own all-clear raised. Two conjuncts of the stamp cannot be covered without changing production: `eventAgentId === undefined` and `reportedStateName === 'done'` are both implied by the conjuncts beside them, so dropping either is behaviour-preserving.
|
Went over the turn-identity tests twice: first trimming four comments that claimed more than their assertions reached, then fixing the assertions themselves. Three were unfalsifiable — the next-turn case only read a payload whose stamp is recomputed anyway, and the two-turn shell ledger got its second id from a plain A 27-mutation matrix over the production diff goes from 20 to 25 killed. The two remaining survivors are equivalent mutants — |
Summary
Fixes #13245.
Also reported independently on Windows as #14253 (v1.4.180, long-lived
npm run devbackground shell) — sameSubagentStop/state: workingshape, confirmed as the same defect in #13245.When a Claude lead turn ends while unrelated background work is still registered — a subagent, a
background shell, a session cron —
resolveClaudePaneStategates the pane up toworking. That isright for the sidebar (work really is still running), but it also erases the
working → doneedgethat mints the completion banner. A turn that ends by asking the user a question therefore stays
silent for the whole background lifetime, and for a background shell (which emits no all-clear of
its own) the edge is lost outright.
This teaches the lead turn to carry its own end time.
normalizeClaudeEventstampsturnCompletedAton a leadStop/StopFailurethat the backgroundinventory gates up to
working, holds it on the lead-turn record, and repeats it on that turn'slater all-clear
done. The two rows pair by equality.the all-clear as that same turn's tail rather than a second completion. The pane's own lifecycle
keeps following the reported
workingstate, so the sidebar still shows live background work.turnCompletedAtwhen present. Thismatters because the hook server pins
stateStartedAtfor as long as the reported state does notchange, and this bug is precisely "the pane never leaves
working" — every turn in one working-runwould otherwise share a single identity, so turns 2..N would be dropped as replays and their
banners would close each other in
notifications.ts.Measured end to end through the real
normalizeHookPayload→observeAgentHookCompletionForNotificationpath (completion banners; time is measured from the start of the sequence, and the turn ends at 1.0 s):
Relationship to #13251: that PR takes the same seam and fixes the subagent case (1 immediate banner
with fresh text). The measured gaps are the other two rows — it produces 1 banner for the
background-shell case and 1 for the three-turn cron case. Its suppression marker is a bare boolean
cleared only by a later
done, so where no suchdoneever arrives for turn N it survives into turnN+1 and swallows it; and its synthetic identity is derived from
stateStartedAt + 1, which is thepinned value, so every turn in one working-run collapses onto one identity. This branch keys both the
suppression and the identity on the turn's own end time instead, which removes both. It is also
scoped to Claude: the meta-carrying dispatch branch is gated to this one path, so no other agent's
behaviour or existing tests change.
Screenshots
No visual change. The sidebar keeps showing
workingfor the whole background lifetime exactly asbefore; only the completion notification timing changes.
Testing
pnpm lint—oxlint0 errors / 9 warnings (all pre-existing,WorktreeJumpPalette.tsx);audit:code-quality:native,audit:code-quality:type-aware,check:reliability-gates(73gates),
check:max-lines-ratchet(352 grandfathered, no new bypasses),check:zustand-selector-fanout, and the threeverify:localization-*gates all pass.check:code-quality:changedandcheck:react-doctor:changedagainst the PR base report 0 newfindings across the changed files.
oxfmt --checkclean on every touched file.pnpm typecheck(node + cli + web)pnpm test— full vitest run: 4521 files / 48465 tests pass. The only failures are 5 tests inconfig/scripts/check-root-directory-entries.test.mjsandsrc/relay/agent-exec-handler.test.ts,which fail identically on the PR base in this environment (they assert on the sandbox's
root-directory listing and inherited
GIT_CONFIG_*env).pnpm build— not run; this change is pure renderer/shared logic with no packaging surface.New suite
agent-hook-completion-background-turn-notifications.test.tsreplays real Claude hooksequences through the real listener and the real coordinator, stamping
stateStartedAtthe way thehook server does (pinned across same-state events), and pins:
donesnapshot (the pane row still saysworking, so nothing else can supply the turn's text);stateStartedAtvalues, so their notification ids cannot collide;the turn;
Stopand the all-clear does not double-fire.Plus unit pins: the listener stamps only on a gated turn boundary and drops the stamp when the next
turn starts; the coordinator pairs an all-clear with the turn it announced even after a working-title
blip resets the pane's identity record; the field is clamped to
working/doneand survives theclient payload projection; the IPC field whitelist forwards it; and the notification id is built from
the completion snapshot rather than the pinned working row.
Every production change was reverted in turn and the corresponding test confirmed failing (11
mutations, each one caught, on a 413-test baseline).
One existing assertion moved:
restores the stashed lead state for an answered child questionnowexpects the restored lead record to keep
turnCompletedAt. That carry is deliberate — a backgroundchild pausing for a human answer displaces the finished lead turn, and without it the drain that
follows reads as a second completion. The test's original intent (the lead restores to
done, notworking) is unchanged, and the case is now covered by a behavioural test too.AI Review Report
Reviewed for: turn-identity correctness across pinned
stateStartedAt; suppression lifetime (does aturn whose all-clear never arrives silence the next turn?); coordinator remount and the module-scoped
identity map's eviction rules; blast radius onto non-Claude agents; and whether the new field can
leak into persisted pane state.
Flagged and addressed:
identity map as
lastTurnCompletedAtNotifiedand only matches an exactturnCompletedAt, so astale mark cannot swallow a later turn. Living in that map is also what makes the remount case
work, since
dispose()already preserves it while the pane is live.stateBeforeWait;the stamp is carried through that stash, otherwise the later drain double-fires. Covered by a test.
was ignoring banners dispatched without a snapshot (so a duplicate could hide), and the identity
derivation had no failing case. Both are now pinned, verified by mutation.
donemust not run pane lifecycle effects while the pane is genuinely still working;it is dispatched with
notifyWithoutLifecycle, and the lifecycle keeps following the reportedworkingrow.turnCompletedAtis clamped toworking/doneon parse and is never written intoAgentStatusEntry(that entry is built field-by-field), so nothing reacheslast-status.json.Cross-platform: the change is platform-agnostic — no shell invocation, no path handling, no
keyboard/shortcut or label surface, no Electron platform branches. The only platform-adjacent
behaviour is OS notification identity, which flows through the existing shared
buildAgentNotificationIdand the existingnotifications.tsreplacement rule on all threeplatforms; the change makes those ids more distinct, never less.
Security Audit
turnCompletedAtarrives from an agent hook payload, so it is treated asuntrusted. It is accepted only as a finite
numberand only onworking/done; every other typeor state normalizes to
undefined, matching howinterrupted/sessionBoundaryare clamped. It isnever parsed, formatted into a path, or interpolated into a command.
through; no widening of the IPC surface, no new channel, no new privilege.
could at worst change grouping of that pane's own notifications; it cannot cross panes (the map is
keyed by
paneKey) and cannot suppress another agent's notifications.Notes
normalizeClaudeEventemits the field, so every other agenttakes byte-identical paths.
cover the dispatch decision, the snapshot carried, and the id inputs, but not the OS presentation
itself.