You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vscode: terminal reconnect budget exhausts during laptop sleep — permanent 'unable to reconnect' banner while Tower is healthy #1681
After a laptop sleep, VS Code terminal tabs show [Codev: Connection lost. unable to reconnect after 6 attempts. Click here to reconnect] and stay dead until manually reconnected — while Tower is perfectly healthy.
Field specimen 2026-09-14 ~9:41 PM: tab died with the 6/6 banner; diagnosis showed Tower up continuously for 5 days (uptime 433,612s at check, healthy, 39 terminals). The disconnect was purely client-side: the machine slept, and the extension's reconnect attempts fired against a suspended network stack — each fails instantly, so the whole 6×30s budget burns before full wake. The agent itself (detached shellper) was unaffected throughout; only the view died.
Defect
The reconnect policy is a fixed, exhaustible budget with no awareness of why attempts fail. Sleep/wake — the single most common disconnect cause on a laptop — reliably consumes it, converting a transient OS event into a permanent-looking failure banner across every open terminal tab.
Fix shape (lane's judgment)
Reset the retry budget on wake signals: window focus, online network event, or visibility change — any of these arriving should re-arm a parked client.
And/or replace the hard 6-attempt death with capped exponential backoff (e.g. 30s → 5m cap) that never fully terminates while the tab is visible; the "Click here" affordance stays as the immediate manual path.
Cheap discriminator worth adding: on final failure, probe /health once and word the banner honestly — "Tower unreachable" vs "reconnect failed (Tower is up — click to retry)". Tonight's specimen shows the second case wearing the first case's message.
Related: #1052 (window-reactivation terminal corruption — same wake window, different layer); the #1047 resume machinery already makes reattach cheap, so aggressive auto-reconnect is safe.
History for the fix lane (traced via git -S MAX_RECONNECT_ATTEMPTS): this is long-standing designed behavior, not a regression. The finite budget shipped 2026-06-02 in PIR #936, which fixed the OPPOSITE defect - a tight retry loop with no backoff/no give-up spamming '[Connection lost, reconnecting...]' dozens of times per second, typically against a stale terminal id Tower no longer had. #939 added the manual reconnect link for the parked state. The #936 threat model was 'session is gone, stop hammering' - correct for that case - and never covered 'session is fine, laptop slept', where a finite budget burns entirely inside the wake window. Constraint for this fix: keep #936's protections intact (the 4xx fast-give-up already discriminates Tower-says-no from network-says-nothing; wake-re-arm must not resurrect the stale-id spam loop). The synthesis: re-arm on wake/focus/online signals for network-class failures only, finite give-up stays for 4xx/session-gone.
Before wording the exhausted-budget banner, the adapter probes Tower's health once (via the sdk's existing getHealth), so the banner distinguishes "Tower unreachable" from "reconnect failed, Tower is up, click to retry". A generation token stops a stale probe from overwriting a banner after a successful reconnect.
Found in human testing at the gate: the old banner left a remnant on the composer line after automatic recovery. It is now wiped in place.
Process
BUGFIX lane; pr gate approved by the owner 2026-09-16T23:52Z on head 79a6c29; merged by the main architect on the green post-gate head b2ad48f.
Three consultation rounds: round 1 raised a stale-probe race and test coverage (fixed); round 3, after the recovery-render fix, was two approvals and one comment on the throttle follow-up.
CI green throughout. A physical sleep-and-wake is the real end-to-end confirmation and cannot run in CI.
Follow-ups, not filed yet
No throttle on the re-arm when the window is refocused repeatedly.
Refocus is the only wake signal available; there is no online or visibility event in the extension host.
The web dashboard's terminal component may have the same sleep gap; unaudited.
Activity
amrmelsayed commentedon Sep 14, 2026
History for the fix lane (traced via git -S MAX_RECONNECT_ATTEMPTS): this is long-standing designed behavior, not a regression. The finite budget shipped 2026-06-02 in PIR #936, which fixed the OPPOSITE defect - a tight retry loop with no backoff/no give-up spamming '[Connection lost, reconnecting...]' dozens of times per second, typically against a stale terminal id Tower no longer had. #939 added the manual reconnect link for the parked state. The #936 threat model was 'session is gone, stop hammering' - correct for that case - and never covered 'session is fine, laptop slept', where a finite budget burns entirely inside the wake window. Constraint for this fix: keep #936's protections intact (the 4xx fast-give-up already discriminates Tower-says-no from network-says-nothing; wake-re-arm must not resurrect the stale-id spam loop). The synthesis: re-arm on wake/focus/online signals for network-class failures only, finite give-up stays for 4xx/session-gone.
amrmelsayed commentedon Sep 14, 2026
On it! Working on a fix now.
Fix #1681: re-arm terminal reconnect budget on wake + honest give-up …
Fix #1681: guard stale /health probe against a permanent give-up (CMAP)
[Bugfix #1681] Thread: investigate + fix + CMAP outcome
Fix #1681: address PR CMAP — probe timeout race, pre-open guard, wiri…
[Bugfix #1681] Thread: PR #1682 CMAP rounds + gate handoff
Fix #1681: wipe the stale give-up banner on recovery (no composer rem…
[Bugfix #1681] Thread: recovery-render glitch fix + CMAP round 3
Fix #1681: minor CMAP round-3 polish (unknown-health wording, clear p…
[Bugfix #1681] Thread: PR CMAP round 3 outcome + minors folded
Merge pull request #1682 from cluesmith/builder/bugfix-1681
docs(changelog): terminal reconnect re-arm on wake (#1681, PR #1682)
docs(changelog): move the #1681 reconnect fix under Unreleased; add r…
amrmelsayed commentedon Sep 16, 2026
Outcome
Shipped in PR #1682, merged to main 2026-09-16T23:57Z as 58abd2b. Rides the next VS Code extension release, not the npm 3.3.4 release.
What changed (
apps/vscode/src/terminal-adapter.ts,terminal-manager.ts,extension.ts)getHealth), so the banner distinguishes "Tower unreachable" from "reconnect failed, Tower is up, click to retry". A generation token stops a stale probe from overwriting a banner after a successful reconnect.Process
Follow-ups, not filed yet