Skip to content

fix(notifications): do not re-fire task-complete notifications for replayed agent statuses - #12750

Closed
robertnisipeanu wants to merge 2 commits into
stablyai:mainfrom
robertnisipeanu:fix/replayed-status-notifications
Closed

robertnisipeanu wants to merge 2 commits into
stablyai:mainfrom
robertnisipeanu:fix/replayed-status-notifications

Conversation

@robertnisipeanu

Copy link
Copy Markdown
Contributor

Fixes #12747

Reconnect replays re-deliver cached agent statuses with isReplay: true, but the flag was dropped from the agentStatus:set IPC payload, so the renderer treated each replayed done as a fresh completion and fired the task-complete notification again on every reconnect cycle.

  • AgentStatusIpcPayload carries isReplay.
  • The main-process broadcast forwards it alongside the other optional fields.
  • The renderer skips completion-notification observation for replayed statuses, mirroring the existing startup-snapshot replay skip (options.replay). Status UI still updates from the replay.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 85ecb4ae-c18a-45dc-8fde-efcea2c4bf3a

📥 Commits

Reviewing files that changed from the base of the PR and between 90a292e and 7bf6900.

📒 Files selected for processing (5)
  • src/main/index.ts
  • src/renderer/src/hooks/ipc-events-agent-status-store-test-fixtures.ts
  • src/renderer/src/hooks/useIpcEvents-agent-status-snapshot-replay.test.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/shared/agent-status-types.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/shared/agent-status-types.ts
  • src/main/index.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change adds optional isReplay metadata to agent status IPC payloads. Replayed status events receive this flag when forwarded from the main process. The renderer continues to update agent status but skips completion notifications for flagged events. Tests cover replayed terminal events on hydrated panes.

Merge Risk: ⚪ Minimal · up to 7bf69

This localized change prevents replayed task statuses from firing duplicate completion notifications while keeping status updates intact; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, cause, fix, and linked issue, but omits most required template sections and testing details. Complete the required ELI5, What Changed, Why, Visual Proof, Testing, Review, Notes, Checklist, and Author sections.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing duplicate completion notifications for replayed agent statuses.
Linked Issues check ✅ Passed The changes preserve isReplay through IPC, suppress replayed completion notifications, and continue updating the status UI as required by issue #12747.
Out of Scope Changes check ✅ Passed The changes are focused on replayed agent-status notifications and supporting types, forwarding logic, and tests for issue #12747.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/hooks/useIpcEvents.ts (1)

3281-3284: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Keep the added replay comments concise.

  • src/renderer/src/hooks/useIpcEvents.ts#L3281-L3284: Replace the four-line rationale with one concise comment.
  • src/renderer/src/hooks/useIpcEvents.test.ts#L6755-L6756: Remove the redundant explanation or reduce it to one line.

As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through how the code works.”

Proposed fix
-        // Why: local Codex/Claude hooks arrive via this main-process IPC path, not the PTY OSC fallback, so task-complete notifications must observe accepted hook state here too.
-        // Why isReplay is excluded like the startup snapshot: a reconnect replay re-delivers a cached
-        // terminal status the user was already notified about; observing it would fire the
-        // notification again on every reconnect cycle.
+        // Replays refresh status UI but must not repeat completion notifications.
-    // A reconnect replay re-delivers the cached terminal status. It must refresh the status UI
-    // without re-firing the task-complete notification the user already received.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4673a11-0860-4543-8a19-ea79e4e53964

📥 Commits

Reviewing files that changed from the base of the PR and between eea0bb6 and 0bcb0dc45f4edeedbd8b2e23924591a31df90d6a.

📒 Files selected for processing (4)
  • src/main/index.ts
  • src/renderer/src/hooks/useIpcEvents.test.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/shared/agent-status-types.ts

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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.

@robertnisipeanu

Copy link
Copy Markdown
Contributor Author

Superseded by #13974, which ships in v1.4.183: agent status replays now carry an explicit replay flag and task-complete notification observation is gated on it (useIpcEvents.ts, options?.replay !== true), covering the duplicate-notification case this PR addressed.

@robertnisipeanu

Copy link
Copy Markdown
Contributor Author

Reopening: #13974 coalesces agent-status bursts and adds snapshot-path seedOnly handling, but the live reconnect-replay path is untouched — isReplay is still dropped when the status event is built for agentStatus:set (src/main/index.ts), AgentStatusIpcPayload has no such field, and the renderer's onSet listener passes no replay option, so observeAgentHookCompletionForNotification still fires for every replayed status after an SSH reconnect. This PR carries the flag across that boundary. Rebase onto current main coming shortly.

Carries the isReplay flag alongside upstream's observation forwarding in the
main-process statusEvent, layers the isReplay exclusion onto the snapshot
seedOnly notification condition in useIpcEvents (snapshot replays still seed
working states; live reconnect replays are never observed), and ports the
replayed-status suppression test to
useIpcEvents-agent-status-snapshot-replay.test.ts after upstream split
useIpcEvents.test.ts, adding isReplay to the shared AgentStatusSetData fixture.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AqNqAZQTwmAkwGcHj5TYXk
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks, @robertnisipeanu! This was rebuilt on current main and merged in #29410 (your approach was used). Closing as superseded.

@nwparker nwparker closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reconnect replays of cached agent statuses re-fire task-complete notifications

4 participants