Uh oh!
There was an error while loading. Please reload this page.
fix: Add cloud infrastructure for user message routing - #213
Conversation
The previous fix (41d7b4f) added daemon-side support for remote users, but the cloud server was missing critical infrastructure: 1. Added PresenceRegistry service - shared module that tracks online users, accessible to both WebSocket handler and API routes 2. Added CloudMessageBus service - event-based pub/sub for delivering messages to cloud users via their WebSocket connections 3. Updated /api/daemons/agents to return allUsers from presence registry so daemons can discover cloud-connected users 4. Updated /api/daemons/message to handle daemonId='cloud' case, delivering messages to users via CloudMessageBus 5. Updated server.ts to register/unregister users with presence registry and subscribe to CloudMessageBus for WebSocket delivery Message flow for cloud users: Agent -> Daemon -> POST /api/daemons/message (daemonId=cloud) -> CloudMessageBus.sendToUser() -> Presence WebSocket -> User Dashboard 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add test coverage for the new cloud infrastructure: - PresenceRegistry tests (17 tests): - User registration and unregistration - Last seen updates - Online status checks - getOnlineUsersForDiscovery() RemoteAgent format - CloudMessageBus tests (6 tests): - Event emission for user messages - Metadata inclusion - Multiple subscribers - Independent user message delivery 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 My Senior Dev — Analysis Complete👤 For @khaliqgant📁 Expert in View your contributor analytics → 📊 7 files reviewed • 3 high risk • 2 need attention 🚨 High Risk:
🚀 Open Interactive Review →The full interface unlocks features not available in GitHub:
💬 Chat here: 📖 View all 12 personas & slash commandsYou can interact with me by mentioning In PR comments or on any line of code:
Slash commands:
AI Personas (mention to get their perspective):
For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews. |
Uh oh!
There was an error while loading. Please reload this page.
Records completed work on cross-machine user message routing. - Added cloud infrastructure (PresenceRegistry, CloudMessageBus) - Created PR #213 with 23 comprehensive tests - Identified as missing feature (not regression) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Records completed work on cross-machine user message routing. - Added cloud infrastructure (PresenceRegistry, CloudMessageBus) - Created PR #213 with 23 comprehensive tests - Identified as missing feature (not regression) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Records completed work on cross-machine user message routing. - Added cloud infrastructure (PresenceRegistry, CloudMessageBus) - Created PR #213 with 23 comprehensive tests - Identified as missing feature (not regression) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Summary
Completes the cross-machine user routing feature by adding missing cloud infrastructure. The previous daemon-side fix (PR #212, commit 41d7b4f) was correct but incomplete - the cloud server lacked the necessary components to actually discover and deliver messages to users.
Root Cause Analysis
Not a Regression - Missing Feature
Investigation via
git logandgit blamerevealed this is not a regression:The original cross-machine routing (commits ba37864, 37996c0) was designed exclusively for agent-to-agent communication. User routing was never implemented:
/api/daemons/agentsreturnedallAgentsbut neverallUsersWhy First Fix (41d7b4f) Didn't Work
The daemon-side code was correct:
isRemoteUser()methodallUsersfrom APIBut the cloud server never returned
allUsersbecause:onlineUsersMap was local to WebSocket handler in server.tsdaemonId: 'cloud'What This Fix Does
New Services
PresenceRegistry (
src/cloud/services/presence-registry.ts)getOnlineUsersForDiscovery()in RemoteAgent formatCloudMessageBus (
src/cloud/services/cloud-message-bus.ts)Updated Components
/api/daemons/agentsendpoint - Now returnsallUsersalongsideallAgents/api/daemons/messageendpoint - Special handling fortargetDaemonId === 'cloud'server.ts - Registers/unregisters users with presence registry, subscribes to message bus
Message Flow
Test Coverage
Added 23 new tests:
Files Changed
src/cloud/services/presence-registry.ts(new)src/cloud/services/cloud-message-bus.ts(new)src/cloud/services/presence-registry.test.ts(new)src/cloud/services/cloud-message-bus.test.ts(new)src/cloud/services/index.ts(exports)src/cloud/api/daemons.ts(allUsers + cloud routing)src/cloud/server.ts(presence registry + message bus)Test Plan
🤖 Generated with Claude Code