Repository navigation
fix(whatsapp): harden reconnect and re-pair flow - #1385
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by Qodofix(whatsapp): harden reconnect and re-pair flow
AI Description
Diagram
High-Level Assessment
Files changed (28)
|
Code Review by Qodo
1. macOS reconnection remains unverified
|
9149563 to
e87a800
Compare
…esume health check
…evert unrelated table reformatting
e87a800 to
cdb85d4
Compare
Fixes #1346
Intent
Fix issue #1346 WhatsApp reconnect and re-pair flows on macOS (DMG and Mac App Store builds) and address PR #1385 inline review findings: (1) preserve credential writes across same-tick 515 restartRequired or shutdown and reconnect seamlessly on 515 without a false error banner; (2) return unpaired 408 QR timeouts to disconnected instead of auto-reconnect looping; (3) distinguish reconnecting vs logged_out (401) in backend status and UI across all 24 locales and clear stale error banners when re-pairing; (4) validate socket identity/cancellation in connectWithPairingCode and restore QR mode on failure so QR events are not suppressed; (5) add non-destructive cancelPairing (/api/whatsapp/cancel-pairing) so cancelling QR/pairing does not logout or wipe registered credentials; (6) check socket health and run a bounded presence probe in handleSystemResume after macOS sleep/wake; and (7) document macOS DMG/MAS verification scenarios in docs and tests.
What Changed
creds.updatewrites throughcredentialWriteTailacross515(restartRequired) socket replacements and shutdowns, reconnect immediately on515without setting a disconnect error banner, return unpaired408timeouts todisconnected, and validate socket identity inconnectWithPairingCode()while restoring QR mode if code generation fails.cancelPairing()(POST /api/whatsapp/cancel-pairing) so cancelling an in-progress QR or pairing-code flow closes the pairing socket without callinglogout()or wipingwhatsapp-auth/, and wirehandleSystemResume()intopowerMonitor.on('resume')to reconnect stale sockets or run a boundedsendPresenceUpdate('available')health probe after system sleep/wake.frontend/src/app/(dashboard)/whatsapp/page.tsx) and all 24 locale message bundles to distinguishreconnecting,repair_needed(401logged_out), andstartup_failedstates, clear stale error banners during re-pairing, and document the session lifecycle and API endpoint alongside unit tests intests/whatsapp-service.test.ts.Risk Assessment
✅ Low: The WhatsApp reconnect, pairing cancellation, and sleep/wake recovery changes are well-bounded, properly guarded against race conditions and auth-wipe epochs, localized across all 24 locales, and covered by behavioral regression tests.
Testing
Ran the focused WhatsApp service, shutdown timeout, middleware, authorization permission, and 24-locale translation test suites, and stood up the real FloCafe Express server, SQLite database, and Next.js frontend in an isolated userData environment driven by headless Chromium to exercise all 7 WhatsApp reconnect, re-pair, pairing-code fallback/cancellation, non-destructive cancel-pairing, and macOS sleep/wake resume scenarios end-to-end with 7 screenshots and structured JSON evidence.
Evidence: Live end-to-end WhatsApp scenario verification JSON evidence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run build && npm run build:frontendnpm run test:whatsapp-servicenpm run test:whatsapp-middlewarenpm run test:whatsapp-schemanpm run test:translationsnpm run test:rtl-kds-server-whatsappnpm run test:issue-718-whatsapp-order-statusnpm run i18n:checknode tests/run-electron-node-test.cjs .tmp-live-validation/run-live-whatsapp-scenarios.ts✅ No issues found.
npm run test:whatsapp-servicenpm run test:whatsapp-middlewarenpm run test:translationsnpm run test:authorization-permissionsELECTRON_RUN_AS_NODE=1 "$(node -p "require('electron')")" .tmp-live-validation/run-live-scenarios.cjs✅ **Document** - passed
✅ No issues found.
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.