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