Skip to content

Conversation

@agent-relay
Copy link
Contributor

@agent-relay agent-relay bot commented Jan 8, 2026

Summary

  • Fix broadcast message duplication in #general channel
  • Messages sent to * now appear once instead of once per recipient
  • TDD approach: 14 tests covering all edge cases

Problem

When a broadcast is sent to *, the backend delivers it to each recipient separately. Each delivery gets a unique ID and is stored separately, causing the same message to appear multiple times in #general (once per recipient).

Solution

Frontend deduplication that groups broadcasts by:

  • Sender (from)
  • Content (content)
  • Timestamp bucket (1-second window)

Only the first occurrence of each broadcast is shown.

Changes

  • useBroadcastDedup.ts: Deduplication utility with getBroadcastKey() and deduplicateBroadcasts()
  • useBroadcastDedup.test.ts: 14 comprehensive TDD tests
  • MessageList.tsx: Integration for #general channel only (10 lines)

Test plan

  • Broadcasts show once in #general (not N times for N recipients)
  • Different broadcasts from same sender preserved
  • Direct messages unaffected
  • Message order maintained
  • Mixed broadcast/DM messages handled correctly
  • All 14 new tests pass
  • All 118 dashboard tests pass

🤖 Generated with Claude Code

When broadcasts are sent to '*', the backend delivers them to each
recipient separately, causing duplicates in the #general channel view.

Changes:
- Add useBroadcastDedup.ts with deduplication logic
- Group broadcasts by sender + content + timestamp (1-second window)
- Integrate into MessageList.tsx for #general channel only
- Add 14 TDD tests covering all edge cases

Broadcasts now appear once per channel instead of once per recipient.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes broadcast message duplication in the #general channel by implementing frontend deduplication logic. When a broadcast is sent to *, the backend delivers it to each recipient separately with unique IDs, causing the same message to appear multiple times in #general. The solution groups broadcasts by sender, content, and timestamp (1-second window) to show each unique broadcast only once.

Key Changes

  • Comprehensive deduplication utilities with 14 TDD tests covering all edge cases
  • Clean integration in MessageList that only affects #general channel
  • Preserves message order and handles mixed broadcast/direct message scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/dashboard/react-components/hooks/useBroadcastDedup.ts New utility module with deduplication logic and React hook wrapper
src/dashboard/react-components/hooks/useBroadcastDedup.test.ts Comprehensive test suite with 14 tests covering all deduplication scenarios
src/dashboard/react-components/MessageList.tsx Integration that applies deduplication only to #general channel messages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Agent Relay and others added 2 commits January 8, 2026 23:42
Wrap deduplication call in useMemo with messages as dependency to prevent
unnecessary recalculations when the messages array hasn't changed. This
follows the same pattern used by other hooks in the codebase.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@khaliqgant khaliqgant merged commit 2c01845 into main Jan 8, 2026
6 checks passed
@khaliqgant khaliqgant deleted the fix/broadcast-dedup branch January 8, 2026 23:45
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.

2 participants