Repository navigation
fix(ui): recover quickly when spotty connections return - #186325
Conversation
A blackholed opening WebSocket could hold recovery for its 30-second timer and transport backoff even after the link returned. Airplane Wi-Fi often never emits an online event. Unanswered sends also waited about 27 seconds before showing reconnecting state. Use fresh same-origin reachability evidence in the page-activation owner and recover through the existing application connect operation. Keep probes sequential, visible-only, and jittered every 2-3 seconds, including fetch time in that interval. Only replace backoff waits or upgrades at least eight seconds old. Preserve opened sockets, pairing, startup retry spreading, and announced restart/suspension waits; do not accelerate busy Gateway retries. Exempt marked probes from service-worker auth recovery. Probe unanswered sends after five seconds at one-second granularity while retaining the ten-second response window, idle heartbeat policy, and hidden tab behavior. Move the existing Talk catalog retry loop into its own module to keep the browser client within its lint limit; connection cancellation still owns its lifetime. Node clients and protocol contracts are unchanged. Proof: owning regressions failed before repair; browser Gateway tests passed 220/220 across 12 files on the final publication rerun. Both foreground and composer reconnect E2E specs passed. UI build, UI TypeScript, touched-file lint/format, diff checks, and independent Codex review through P2 passed. Full lint reported unrelated source/test rule violations; touched violations were fixed and focused lint is clean. The build's report-only CSS check reports 29 bytes above its existing ceiling. The final isolated 2,000-session airplane rig used 700ms RTT, 150ms jitter, and 190/50 KB/s bandwidth. Restore-to-connected improved from 31.5s to 3.471s for blackout/send and 33.8s to 3.714s for a 90s blackout. Send-to- visible-reconnecting was 15.250s. Offline reload recovered in 3.857s; stall and flap scenarios passed. The queued message persisted exactly once and the Gateway logged zero closed-before-connect events. A repeat exposed a 6.5s completion-based probe interval; the fetch-inclusive cadence fixes it. Publication simplification pass: no supported deletions. The existing page-activation owner, transport timing facts, and distinct failure tests remain necessary. Production and tests are unchanged; reuse the final rig and independent scoped-clean review. Overall delta remains +404/-75. Accepted edge: a single response frame taking over 15 seconds after an unanswered request can force one reconnect (about 600 KB at 40 KB/s). Campaign warm reloads measured at most 44 KB and reconnect about 18 KB. Visible-only 2-3 second jitter reduces herd synchronization; announced restart, suspension, startup, and busy states do not probe, preserving startup retry-after spreading. Young openings and failed health probes keep their existing recovery paths. Release-note context: Control UI recovers faster after silent network outages and shows queued sends sooner on spotty connections.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR accelerates Control UI recovery after silent network outages and detects unanswered sends sooner. Example: A visible Control UI tab sends a message during a 30-second network blackout.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses current-main reconnect delays through existing owners, and review found no actionable introduced defect. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe browser Gateway client owns WebSocket liveness and handshake state; page activation consumes those facts and fresh same-origin health responses to invoke the existing application reconnect operation. flowchart TD
A[Visible Control UI tab] --> B[Page activation recovery]
B --> C[Same origin health endpoint]
C --> B
B --> D[Application Gateway owner]
D --> E[Browser Gateway client]
E --> F[Gateway WebSocket]
D --> G[Existing outbox recovery]
Technical reviewBest possible solution: Retain the focused recovery change and complete the existing exact-head CI gates before landing. Do we have a high-confidence way to reproduce the issue? Current-main source shows the thirty-second opening timeout and slower unanswered-request detection; the author reports matching browser fault-proxy reproductions, but this read-only review ran no target code. Is this the best way to solve the issue? The change uses the existing health probe, application reconnect operation, and liveness owner while preserving admission and outbox contracts; the catalog extraction is a behavior-preserving move. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2e628e80c294. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +106, Tests +210, Docs +13. Total +329 across 11 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 27, 2026, 5:44 PM ET / 21:44 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
|
Landed as 00096a1 through the native authorized pre-existing-failure exception for CI run 40587013659, attempt 1, tested at head The two inherited root failures were:
|
A blackholed opening WebSocket could hold recovery for its 30-second timer and transport backoff even after the link returned. Airplane Wi-Fi often never emits an online event. Unanswered sends also waited about 27 seconds before showing reconnecting state. Use fresh same-origin reachability evidence in the page-activation owner and recover through the existing application connect operation. Keep probes sequential, visible-only, and jittered every 2-3 seconds, including fetch time in that interval. Only replace backoff waits or upgrades at least eight seconds old. Preserve opened sockets, pairing, startup retry spreading, and announced restart/suspension waits; do not accelerate busy Gateway retries. Exempt marked probes from service-worker auth recovery. Probe unanswered sends after five seconds at one-second granularity while retaining the ten-second response window, idle heartbeat policy, and hidden tab behavior. Move the existing Talk catalog retry loop into its own module to keep the browser client within its lint limit; connection cancellation still owns its lifetime. Node clients and protocol contracts are unchanged. Proof: owning regressions failed before repair; browser Gateway tests passed 220/220 across 12 files on the final publication rerun. Both foreground and composer reconnect E2E specs passed. UI build, UI TypeScript, touched-file lint/format, diff checks, and independent Codex review through P2 passed. Full lint reported unrelated source/test rule violations; touched violations were fixed and focused lint is clean. The build's report-only CSS check reports 29 bytes above its existing ceiling. The final isolated 2,000-session airplane rig used 700ms RTT, 150ms jitter, and 190/50 KB/s bandwidth. Restore-to-connected improved from 31.5s to 3.471s for blackout/send and 33.8s to 3.714s for a 90s blackout. Send-to- visible-reconnecting was 15.250s. Offline reload recovered in 3.857s; stall and flap scenarios passed. The queued message persisted exactly once and the Gateway logged zero closed-before-connect events. A repeat exposed a 6.5s completion-based probe interval; the fetch-inclusive cadence fixes it. Publication simplification pass: no supported deletions. The existing page-activation owner, transport timing facts, and distinct failure tests remain necessary. Production and tests are unchanged; reuse the final rig and independent scoped-clean review. Overall delta remains +404/-75. Accepted edge: a single response frame taking over 15 seconds after an unanswered request can force one reconnect (about 600 KB at 40 KB/s). Campaign warm reloads measured at most 44 KB and reconnect about 18 KB. Visible-only 2-3 second jitter reduces herd synchronization; announced restart, suspension, startup, and busy states do not probe, preserving startup retry-after spreading. Young openings and failed health probes keep their existing recovery paths. Release-note context: Control UI recovers faster after silent network outages and shows queued sends sooner on spotty connections.
What Problem This Solves
Fixes: the Control UI stays disconnected for tens of seconds after an airplane or spotty network connection returns, and a send into a dead connection appears connected for too long.
User Impact
User impact: the Control UI reconnects within a few seconds in the measured blackout scenarios, and unanswered sends show the existing reconnecting and queued state sooner, preserving exactly-once outbox delivery.
Accepted tradeoff: with the 5-second unanswered-request trigger and 10-second probe window, a single response frame that takes more than 15 seconds to arrive can force one reconnect (approximately 600 KB at 40 KB/s). Campaign measurements found warm reloads totaled at most 44 KB and a reconnect approximately 18 KB on the airplane profile. Any inbound frame proves liveness, including traffic unrelated to the pending request.
Release-note context: Control UI recovers faster after silent network outages and shows queued sends sooner on spotty connections.
Why This Change Was Made
A silently dead opening WebSocket could hold recovery until its 30-second timeout, followed by reconnect backoff. Airplane Wi-Fi often stays logically online throughout the outage, so the existing page-activation recovery never runs.
The existing page-activation owner now uses a fresh same-origin health request as recovery evidence, then calls the existing application reconnect operation. It can shorten a backoff wait or replace an opening attempt at least eight seconds old. Opened sockets and young attempts remain intact. Probe failures are excluded from service-worker HTTP-failure notifications so an outage cannot repeatedly trigger authentication recovery.
Only visible, disconnected tabs probe, independently jittered every 2–3 seconds, including fetch time. Announced restart, suspension, startup, and busy states do not probe; the existing startup retry-after spreading remains in charge. Each tab has at most one probe in flight, and slow or failed health requests do not cause extra WebSocket upgrades. This reduces synchronization between tabs without introducing another reconnect owner.
Unanswered requests start the existing liveness probe after five seconds, checked every second, while retaining its ten-second response window. Idle heartbeat and hidden-tab behavior remain unchanged. The existing catalog retry loop moves into a small module to keep the browser client within its file-size limit; Node clients and protocol contracts are unchanged.
Accepted recovery limits: a young opening attempt must reach the eight-second threshold before evidence can replace it, and hidden tabs or failed/slow health probes keep their existing recovery paths. The few-second measurements below apply to the tested scenarios, not every possible outage timing. Jitter reduces restart herds; it does not impose a cross-tab connection limit.
Evidence
Measured with an isolated local Gateway with synthetic Team-shaped state behind a TCP fault proxy: 700 ms RTT, jitter, ~190 KB/s, silent blackouts / refused connections. Upload bandwidth was approximately 50 KB/s and jitter was 150 ms. The candidate used the built UI from this branch.
The 20-second stall preserved the connection, and the flap scenario ended connected. The queued synthetic message appeared exactly once in the Gateway transcript, and the Gateway logged zero closed-before-connect events.
Focused proof:
Change size against the merge base: production code +165/−59 lines (net +106), documentation +13, tests +226/−16 (net +210). Before versus after the simplification pass: unchanged at +404/−75 overall. The added probe lifecycle and browser timing facts are necessary to recover old attempts without replacing live sockets; there is no new configuration, protocol change, or visual layout change.