fix(cli): delay welcome notification for MCP init handshake
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

Welcome was silently dropped when sent before Claude Code's
notifications/initialized. Add 2s delay after WS connects to
ensure the MCP handshake is complete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-09 01:25:10 +01:00
parent 3226493e6d
commit d263fe0f26

View File

@@ -1899,9 +1899,11 @@ Your message mode is "${messageMode}".
}
// Welcome notification: give Claude immediate context on connect.
// No delay needed — WS is already connected at this point.
const welcomeClient = allClients()[0];
if (welcomeClient && welcomeClient.status === "open") {
// Delay slightly to ensure Claude Code has completed MCP initialization
// handshake (notifications/initialized) before we push channel messages.
setTimeout(async () => {
const welcomeClient = allClients()[0];
if (!welcomeClient || welcomeClient.status !== "open") return;
try {
const peers = await welcomeClient.listPeers();
const peerNames = peers
@@ -1916,7 +1918,7 @@ Your message mode is "${messageMode}".
},
});
} catch { /* best effort */ }
}
}, 2_000);
} // end wirePushHandlers
// Event loop keepalive: Node.js stdout to a pipe is buffered. Without