fix(desktop): force-redial half-open gateways after wake - #89092
Conversation
d4eb6d9 to
c6c9f66
Compare
c6c9f66 to
05977a4
Compare
Correct recovery model, and the signal taxonomy is right: power-resume and network-online are strong signals (the OS may have discarded TCP underneath a still-OPEN WebSocket, so the only honest state is to retire and redial), while visibility stays soft — a sensible gradient rather than blanket force. The redundant-backoff cleanup ( No blocking issues found. Nit: every wake event now closes a healthy socket too — a 5-minute lid-close on AC power where TCP survived will still eat a disconnect/reconnect cycle and a transient UI state flip on resume. Acceptable as the safe default, but worth a comment recording that tradeoff ("cheap redial beats a half-open socket we can't cheaply probe"), so a future contributor who adds a lightweight ping-probe knows the behavior change they'd be introducing rather than fighting an unexplained close(). — Reviewed by Hermes AI reviewer (reviewer-f2) |
|
Merged via the consolidated session-recovery PR #93361 — your force-redial commit cherry-picked with authorship preserved (power-resume/online/manual reconnect now treat an apparently-open socket as invalid and redial; fixes the #89083 sleep/wake dead app). Rebase conflicts vs the #93292 reconnect block were resolved keeping both behaviors. Thanks @yu-xin-c! |
What does this PR do?
Hermes Desktop already listens for power-resume, browser-online, and manual reconnect signals, but reconnectNow() skips all work while gateway.connectionState is open. macOS can leave that state stale after sleep even when the underlying TCP connection is gone, so prompts are sent into a half-open socket and the window never recovers.
Treat strong recovery signals as transport invalidation:
This stays at the Desktop orchestration boundary. Browser WebSocket does not expose native ping frames and the gateway has no JSON-RPC ping contract, so adding a timer here would require a new protocol surface for a case where the OS/browser already provides explicit recovery signals.
This is complementary to #90012: that PR adds capability-gated heartbeat detection when paired with #89958, while this PR keeps power-resume, browser-online, and manual recovery working against older backends that advertise no heartbeat capability.
Related Issue
Fixes #89083
Type of Change
Changes Made
How to Test
npm run --prefix apps/desktop test:ui
npm run --prefix apps/desktop typecheck
npm run --prefix apps/desktop lint
npx prettier --check on the four changed TypeScript files.
Local results after rebasing onto current main: 539 UI test files / 5,035 tests passed; typecheck passed; ESLint passed with zero errors; formatting passed.
Checklist
Code
Documentation & Housekeeping
Screenshots / Logs
No visual UI change. The regression tests exercise the stale-open transport state directly.