diff --git a/apps/bot/src/ipc/pair-handler.ts b/apps/bot/src/ipc/pair-handler.ts index 48240e7..885ed5f 100644 --- a/apps/bot/src/ipc/pair-handler.ts +++ b/apps/bot/src/ipc/pair-handler.ts @@ -169,6 +169,15 @@ export async function handleStartPairing(accountId: string): Promise { // session-manager will reopen it with the new credentials — // the next `open` event finishes the pairing. Keep the // listener attached and don't surface a timeout to the UI. + // + // Re-arm the warming-up flag: the session-manager schedules a + // cleanup `stop().then(start())` to kick off the reconnect. + // That stop emits another close event that lands on this + // listener BEFORE the new open arrives — without warming-up, + // we'd treat it as a timeout and detach right when the user + // actually paired successfully. Cleared again on the next + // qr / open from the freshly-reopened session. + pairingWarmingUp.add(id); logger.info( { accountId: id }, "pair: restart-required close (post-pair reconnect) — keeping listener alive",