Skip to content

fix(ui): recover quickly when spotty connections return - #186325

Merged
steipete merged 1 commit into
mainfrom
steipete/air-recovery
Oct 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/air-recovery

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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.

Measurement Base Candidate
Restore → connected, 30-second blackout with a send 31.5 s 3.471 s
Restore → connected, 90-second blackout 33.8 s 3.714 s
Send → visible reconnecting ~27 s 15.250 s
Offline reload → connected after restore — 3.857 s

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:

  • The owning regressions failed before the fix. The final focused rerun passed 220 tests across 12 files: browser Gateway suites, page activation through the real browser client, socket behavior, and service-worker recovery. Distinct cases cover old openings, backoff, young/open sockets, hidden tabs, restart/startup/suspension/busy guards, stale probe results, deadlines, single-flight probes, cadence, and the new unanswered-request threshold.
  • Browser E2E: gateway-foreground-recovery and chat-composer-reconnect passed; warm-boot (one connect per warm reload), gateway-status, session-reconnect-existence, session-management.sidebar-reconnect and sidebar-outbox passed (5 files, 20/20) on this production code.
  • UI build, targeted UI typecheck, touched-file lint/format, and diff checks passed. Full repository lint still reports unrelated source/test violations. The build's report-only CSS budget reports an existing 29-byte excess; no CSS changed.
  • Independent review through P2 found no actionable issues. The publication simplification pass retained the single recovery owner and tests for distinct failures; it found no supported code deletions. Production behavior is unchanged by that pass, so the final rig proof was reused.

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.

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.
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 27, 2026 21:27
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M labels Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T21:29:46.103614Z 27f0282 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@steipete
steipete enabled auto-merge (squash) October 27, 2026 21:41
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The author's production-browser campaign measured 31.5 seconds from network restoration to reconnection.
  • After: The same campaign measured 3.471 seconds, with the queued message recorded once.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-supported; production measurements are reported in detail, while directly inspectable execution evidence is limited to test structure and unfinished CI.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; its body reports a built Control UI against an isolated Gateway and TCP fault proxy, including blackout recovery, queued-message uniqueness, stall preservation, and offline reload, without attached raw traces.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The Control UI can remain disconnected long after connectivity returns and can present unanswered sends as connected for too long.
Reason: The supplied maintainer-authored direction addresses measured recovery delays, accepts the narrower liveness window, and adds no user configuration or persistent format.

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
Reviewed head: 27f0282085507c641445486ba59e8e99bb70ffbf

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Browser unanswered-request liveness changes intended behavior with a stated reason (0d45e40: Detect silent dead links without treating delayed application ticks alone as disconnection.)
  • Pending WebSocket upgrade preservation changes intended behavior with a stated reason (1f862d1: Tab activation must not repeatedly abandon upgrades waiting behind a busy Gateway.)
  • Terminal and suspended page recovery keeps the original intent (1fd8014: Page restoration must preserve stopped authentication, pairing, and build-recovery states.)
  • Talk catalog warming retries keeps the original intent (4b0eb92: Retry the specific catalog-warming response within a bounded connection-owned deadline.)
  • Service-worker HTTP failure notifications keeps the original intent (e074991: Report failed application reads to their originating tab so expired access can recover without losing the conversation.)
  • Startup retry pacing keeps the original intent (8d58ad4: Retry startup handshakes before surfacing failures; the existing retry-after path remains authoritative.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0d45e40 adds ui/src/api/gateway-browser-socket.ts:96 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0d45e4056e1e; files: ui/src/api/gateway-browser-socket.ts)
  • Alix-007: Raw commit deccdb5 adds ui/src/api/gateway-browser-socket.ts:40 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: deccdb5e57af; files: ui/src/api/gateway-browser-socket.ts)

PR surface

Source +106, Tests +210, Docs +13. Total +329 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 165 59 +106
Tests 5 226 16 +210
Docs 1 13 0 +13
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 404 75 +329

Review metrics

Metric Value Why it matters
Production versus test changes Production +165/−59; tests +226/−16 Growth supports the bounded probe lifecycle and distinct recovery regressions; the catalog extraction moves existing behavior without retaining a second implementation.

Labels

Label changes:

  • add P2: Improves recovery from intermittent connectivity while existing automatic recovery remains available.
  • add merge-risk: 🚨 availability: The shorter silence trigger can reconnect a live connection when a complete response frame takes over fifteen seconds; the maintainer explicitly accepts this tradeoff in the PR body.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Improves recovery from intermittent connectivity while existing automatic recovery remains available.
  • merge-risk: 🚨 availability: The shorter silence trigger can reconnect a live connection when a complete response frame takes over fifteen seconds; the maintainer explicitly accepts this tradeoff in the PR body.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted browser or transport trace from the reported blackout campaign to make the recovery measurements independently inspectable.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 27, 2026, 5:44 PM ET / 21:44 UTC.

@steipete
steipete disabled auto-merge October 27, 2026 22:13
@steipete
steipete merged commit 00096a1 into main Oct 27, 2026
141 of 148 checks passed
@steipete
steipete deleted the steipete/air-recovery branch October 27, 2026 22:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

@steipete

Copy link
Copy Markdown
Contributor Author

Landed as 00096a1 through the native authorized pre-existing-failure exception for CI run 40587013659, attempt 1, tested at head 27f0282085507c641445486ba59e8e99bb70ffbf.

The two inherited root failures were:

openclaw/ci-gate failed downstream of these two roots. The failed attempt remains recorded as failed; applicable UI, UI E2E, performance, i18n, and independent security-fast jobs passed. No CI rerun, branch update, or push to the PR branch was used.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant