fix(hub-ui): dismiss toasts when messages are removed - #375
Conversation
◈ PR Lens
Architecture 1 component touched across 2 lanes. Data flow
Drill down
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
🟢 Approval recommended
The change correctly dismisses toasts for removed messages and adds focused regression tests; the only feedback is a minor performance optimization suggestion.
Pull request overview
This PR fixes hub-ui message/toast reconciliation so that when messages are removed (via incremental deltas or full snapshots), any corresponding visible toast is also dismissed, preventing stale toasts from lingering after the message is gone.
Changes:
- Dismiss the toast when a message id is removed from the messages state (including removals inferred during full snapshots).
- Preserve surviving entries during full-snapshot reconciliation to avoid re-notifying and re-incrementing unread counts.
- Add regression tests covering incremental removal, full-snapshot removal, timer cleanup, and full-snapshot retention behavior.
File summaries
| File | Description |
|---|---|
| packages/hub-ui/src/client/state/messages.ts | Updates reconciliation logic to infer removals on full snapshots and dismiss associated toasts while retaining surviving entries. |
| packages/hub-ui/src/client/state/messages.test.ts | Adds state-level tests to ensure toasts/timers are cleaned up on removal and that full snapshots don’t re-toast or bump unread counts for surviving messages. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7ebfd82 to
6df25f3
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The reconciliation change is narrowly scoped, aligns with the stated bug, and is covered by targeted regressions for both delta and full-snapshot scenarios.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
Background (Why)
Dismissing a message through its host handle removes it from the message center, but its toast remains visible. Full-state reconciliation also leaves toasts for removed messages behind.
Changes (What)
Dismiss the corresponding toast when applying message removals, including entries absent from a full snapshot. Retain existing entries during reconciliation so surviving messages do not increment unread counts or create another toast.
Verification (Testing)
Reproduced in the latest hub-ui browser playground using a persistent host message and a command that calls its
dismiss()handle. The toast remained before the fix and disappeared after it. Added regressions for incremental removal, full-state removal, timer cleanup and surviving messages. The six message/toast tests, affected lint and hub-ui type check pass.