Skip to content

Fix duplicate agent completion notifications after worktree switch - #5572

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/notification-issue
Jun 17, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/notification-issue

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • persist per-pane completion identity across agent completion coordinator remounts so stale completion replays after worktree switches do not notify twice
  • dedupe exact repeated hook snapshots and mixed hook-to-title Codex/Claude-style stale replays, while clearing the guard on fresh working evidence
  • add regression coverage for remount title replay, hook-to-title replay, and hook snapshot replay after activation

Regression

The user-visible regression was exposed by 36277801e (June 13, 2026, Make remote hosts first class: concurrent multi-host workbench (#5071)). That change correctly allowed inactive-worktree hook completions to remain live during worktree switches, but it exposed an older coordinator-local dedupe gap: pane remounts lost the prior completion state, so stale hook/title completion replay could look like a new Codex finished event.

Validation

  • pnpm vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.ts
  • pnpm vitest run --config config/vitest.config.ts src/renderer/src/hooks/agent-hook-completion-notifications.test.ts
  • pnpm oxlint src/renderer/src/components/terminal-pane/agent-completion-coordinator.ts src/renderer/src/components/terminal-pane/agent-completion-coordinator.test.ts src/renderer/src/hooks/agent-hook-completion-notifications.test.ts
  • pnpm run typecheck:web
  • git diff --check

Note: local pnpm prints a Node engine warning because this shell is Node 26 while the repo requests Node 24; commands completed successfully.

Made with Orca 🐋


Open in Stage

@ghost

ghost commented Jun 17, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Define completion identity types and persistence
2 Implement identity extraction and deduplication logic
3 Integrate identity tracking into completion flows
4 Add test utilities and regression coverage
Open in Stage

Chapters generated by Stage for commit 0a935e3 on Jun 17, 2026 6:19am UTC.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

The changes introduce completion "identity" tracking in agent-completion-coordinator.ts to prevent duplicate or stale completion notifications during pane remounts and hook/title replay. Two new structures are added: a LastCompletionIdentity record (holding source, identity, and optional agentIdentity) and a per-pane lastCompletionIdentityByPaneKey map. The dispatchCompletion function gains a guard that short-circuits when the same identity has already been notified for a pane. Hook-done and title completion dispatch paths now compute and attach completionIdentity; working-state transitions clear cached identity entries to re-enable notifications. observeHookStatus gains an early-return path for already-processed hook snapshots. A test utility resetAgentCompletionCoordinatorIdentitiesForTest is exported for test isolation. Tests are extended with new scenarios covering replay suppression, remount behavior, and a regression case in agent-hook-completion-notifications.test.ts.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes most required sections (Summary, Regression context, and Validation details), but lacks Screenshots, AI Review Report, and Security Audit sections specified in the template. Add the missing template sections: Screenshots (noting 'No visual change' if applicable), AI Review Report (including cross-platform compatibility checks), and Security Audit summary.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change—fixing duplicate agent completion notifications after worktree switches, which matches the primary issue and solution in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@Jinwoo-H
Jinwoo-H merged commit 89acb8d into main Jun 17, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/notification-issue branch June 17, 2026 06:47
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 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.

1 participant