Skip to content

Conversation

@khaliqgant
Copy link
Collaborator

@khaliqgant khaliqgant commented Jan 7, 2026

Summary

Comprehensive DM routing overhaul replacing modal-based direct messaging with inline DM conversations and agent invites.

Architectural Changes

New Components

  • DirectMessageView.tsx (164 lines) - Inline DM conversation view with agent invite toggles
  • hooks/useDirectMessage.ts (141 lines) - DM logic hook handling participant derivation, message filtering, and deduplication

Removed Components

  • DirectMessageModal.tsx (329 lines deleted) - Replaced by inline DM flow

Major Updates

  • App.tsx (+230 lines) - Integrated inline DM view, agent selection state, DM send handling
  • Sidebar.tsx (+98 lines) - Human/agent channel routing, DM indicators
  • MessageList.tsx (+8 lines) - Skip channel filtering for pre-filtered DM views

New Features

  1. Inline DM Conversations - View DMs directly in main panel instead of modal
  2. Agent Invite System - Toggle agents into DM conversations with sticky header controls
  3. Entity Type Protocol - Distinguish 'user' vs 'agent' entities
  4. DM Channel Naming - dm:alice:bob:agent1 format with sorted participant names
  5. Participant Derivation - Auto-derive agents from message history
  6. Message Deduplication - Filter duplicate messages sent to multiple recipients

Bug Fix (This Session)

Bug: Agent responses misrouted from group DM to private DM

Root Cause: When currentUserName is null (local mode), "Dashboard" was not added to the participants set, causing all messages from/to Dashboard to be filtered out.

Fix: Add Dashboard fallback when currentUserName is null

const effectiveUserName = currentUserName || 'Dashboard';
participants.add(effectiveUserName);

Test Coverage (36 Tests)

Comprehensive test suite in useDirectMessage.test.ts (838 lines):

Category Tests
Basic DM filtering 2
Group DM with agents 5
Participant derivation 3
currentUserName scenarios 2
Edge cases 4
Advanced agent derivation 3
Complex removal scenarios 3
Agent-to-agent communication 3
Human participant scenarios 2
Cloud mode scenarios 6
Boundary conditions 3

Validations

Local Mode: Dashboard fallback activates correctly
Cloud Mode: GitHub username used, Dashboard fallback never triggers
Team Architecture: Current fix is DM-specific and compatible with future team channels

Files Changed (36 files, +2684/-455 lines)

Core DM Changes:

  • src/dashboard/react-components/DirectMessageView.tsx (new)
  • src/dashboard/react-components/DirectMessageModal.tsx (deleted)
  • src/dashboard/react-components/hooks/useDirectMessage.ts (new)
  • src/dashboard/react-components/hooks/useDirectMessage.test.ts (new)
  • src/dashboard/react-components/App.tsx (major updates)
  • src/dashboard/react-components/layout/Sidebar.tsx (updates)
  • src/dashboard/react-components/MessageList.tsx (minor)

Supporting Changes:

  • deploy/workspace/gh-relay (new - auth wrapper)
  • src/dashboard/app/cloud/link/page.tsx (new)
  • src/dashboard/lib/api.ts (updates)
  • Various trajectory files documenting work

Confidence: 90%

  • DM modal → inline migration complete
  • Comprehensive test coverage (36 tests)
  • Both local and cloud modes verified
  • No regressions detected

🤖 Generated with Claude Code

khaliqgant and others added 3 commits January 7, 2026 22:43
- When currentUserName is null (local mode), Dashboard wasn't added to participants
- This caused ALL messages from/to Dashboard to be filtered out
- Fix: Use 'Dashboard' as fallback when currentUserName is null
- Tests: Added 32 tests for multi-recipient DM scenarios
- Coverage: All human+agent combinations covered

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@agent-relay
Copy link
Contributor

agent-relay bot commented Jan 8, 2026

DM Routing Fix - Final Summary

Bug Fix

Issue: When sending DM to human+agent, agent response incorrectly routes to private DM instead of staying in group DM.

Root Cause

When currentUserName is null (local mode without cloud auth), "Dashboard" was not added to the participants set. This caused ALL messages from/to Dashboard to be filtered out in DM views.

Before:

if (currentUserName) participants.add(currentUserName);

After:

const effectiveUserName = currentUserName || 'Dashboard';
participants.add(effectiveUserName);

Solution

Added "Dashboard" as a fallback participant when currentUserName is null. This ensures:

  • Local mode: Dashboard messages are visible ✅
  • Cloud mode: GitHub username used (no change) ✅

Test Coverage (36 tests)

Category Tests
Basic DM filtering 2
Group DM with agents 5
Participant derivation 3
currentUserName scenarios 2
Edge cases 4
Advanced agent derivation 3
Complex removal scenarios 3
Agent-to-agent communication 3
Human participant scenarios 2
Cloud mode scenarios 6
Boundary conditions 3

Validations

Local Mode: Dashboard fallback activates correctly
Cloud Mode: GitHub username used, Dashboard fallback never triggers
Team Architecture: Analyzed - current fix is DM-specific and won't conflict with future team channels

Files Changed

  • src/dashboard/react-components/hooks/useDirectMessage.ts (4 lines)
  • src/dashboard/react-components/hooks/useDirectMessage.test.ts (838 lines, new file)

Confidence Level: 90%

  • Fix is minimal and surgical
  • Comprehensive test coverage
  • Both local and cloud modes verified
  • No regressions detected

🤖 Generated with Claude Code

@khaliqgant khaliqgant merged commit 348f3d0 into main Jan 8, 2026
6 checks passed
@khaliqgant khaliqgant deleted the dm-routing branch January 8, 2026 06:48
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