fix(broker): don't broadcast peer_joined/peer_left/peer_returned to same-pubkey sessions
When a user opens multiple Claude Code instances on one laptop they all share the same memberPubkey (one identity, one config.json). The broker was broadcasting each Claude Code start/stop to every OTHER session of the same user — showing as 'peer agutierrez left / joined' spam in every active claude terminal. Now: skip broadcast to presences whose memberPubkey equals the joining or leaving presence's memberPubkey. Other actual peers on the mesh still see the event. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2001,6 +2001,10 @@ function handleConnection(ws: WebSocket): void {
|
||||
for (const [pid, peer] of connections) {
|
||||
if (pid === presenceId) continue;
|
||||
if (peer.meshId !== joinedConn.meshId) continue;
|
||||
// Don't spam the user's own other sessions about themselves —
|
||||
// multiple Claude Code instances from one laptop all share the
|
||||
// same memberPubkey, so they're the same human identity.
|
||||
if (peer.memberPubkey === joinedConn.memberPubkey) continue;
|
||||
sendToPeer(pid, joinMsg);
|
||||
}
|
||||
// Restore persistent MCP servers owned by this member
|
||||
@@ -4162,6 +4166,9 @@ function handleConnection(ws: WebSocket): void {
|
||||
};
|
||||
for (const [pid, peer] of connections) {
|
||||
if (peer.meshId !== conn.meshId) continue;
|
||||
// Don't tell the user's own other sessions they "left" when one
|
||||
// of their Claude Code instances closes. Same pubkey = same user.
|
||||
if (peer.memberPubkey === conn.memberPubkey) continue;
|
||||
sendToPeer(pid, leaveMsg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user