fix(tui): heartbeat and bounded reconnect for silent WebSocket drops - #89984
Open
100yenadmin wants to merge 1 commit into
Open
fix(tui): heartbeat and bounded reconnect for silent WebSocket drops#89984100yenadmin wants to merge 1 commit into
100yenadmin wants to merge 1 commit into
Conversation
the client half of the gateway.ping heartbeat contract (NousResearch#89958); detects a silently-dropped socket via missed ping-acks and reconnects with bounded backoff; part of the NousResearch#83166 recovery series.
This was referenced Aug 19, 2026
Author
|
Context that turned up after filing: #89083 reports the Desktop version of this symptom (window permanently unresponsive after macOS sleep/wake because a half-open socket is never detected). The ink TUI client drops the same way on laptop sleep, which is what this fixes; #90012 covers the shared/Desktop client and #89958 supplies the ping primitive both use. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds client-side heartbeat and bounded reconnect to the ink TUI's gateway client. The client periodically sends
gateway.pingand, if it stops seeing acks past a deadline, treats the socket as silently dropped and reconnects with bounded exponential backoff. It's the client half of thegateway.pingwire contract in #89958 — it only starts the heartbeat when the server advertisesheartbeatingateway.ready, so against an older backend it's a no-op and behaves exactly as today.Related Issue
Client half of #89958 (heartbeat wire contract); part of #83166.
Also addresses #32997, which names
ui-tui/src/gatewayClient.tsandhandleTransportExit()— the exact file and function this changes — and whose suggested fixes 1 and 2 (a WebSocket ping/pong, and exponential-backoff reconnect at 1s/2s/4s/8s capped at 30s) are what this implements. It does not cover that issue's suggested fix 3 (buffering unsent composer text across a reconnect); this only touches the client transport, so typed text is still lost on reconnect. #60727 is an earlier open PR over the same files — this is that work re-split against current main, not a claim over it.Related: #53374 reports the same keepalive gap on Windows sleep/resume, and #89083 the macOS Desktop version.
Type of Change
Changes Made
ui-tui/src/gatewayClient.ts— heartbeat interval/deadline + bounded-backoff reconnect; adisposedflag sokill()stops reconnecting; a heartbeat-ack short-circuit; all gated on the server's advertisedheartbeatcapability.ui-tui/src/gatewayTypes.ts—heartbeat?ongateway.ready, agateway.reconnectingevent.ui-tui/src/__tests__/gatewayClient.test.ts— heartbeat/reconnect coverage.Constants:
WS_HEARTBEAT_INTERVAL_MS=15000,WS_HEARTBEAT_DEAD_MS=45000,RECONNECT_BASE_MS=1000,RECONNECT_MAX_MS=30000.How to Test
Covers: healthy-idle-with-acks, auto-reconnect-on-missing-ack, older-backend-omits-capability (graceful no-op), no-double-reconnect, no-reconnect-after-
kill().Checklist
Code
Documentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.md/AGENTS.md— N/ASalvage-friendly: single commit on current main (
13ce0c5c67), pairs with #89958 (no hard dependency — capability-gated) — cherry-pick welcome, authorship preservation appreciated but optional.