From 3dfab0f792095a0ba4811bb969b1d7444fe8c8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Wed, 15 Apr 2026 14:28:57 +0100 Subject: [PATCH] fix(broker): don't broadcast peer_joined/peer_left/peer_returned to same-pubkey sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- apps/broker/src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/broker/src/index.ts b/apps/broker/src/index.ts index 24068aa..d8ef8f3 100644 --- a/apps/broker/src/index.ts +++ b/apps/broker/src/index.ts @@ -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); } }