Repository navigation
fix: recover the Control UI promptly after brief network drops - #189141
Conversation
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR accelerates short-outage recovery through the existing page-activation owner and adds benchmark observations for reconnect timing and browser activation. Example: A visible tab has a closed transport when connectivity returns after a five-second outage.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored draft makes a useful, focused recovery improvement; no definite introduced code defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherBrowser lifecycle signals and Gateway connection snapshots enter the page-activation owner, which probes same-origin health and requests client replacement through the application Gateway owner. flowchart TD
A[Browser lifecycle signals] --> B[Page activation owner]
C[Gateway connection snapshot] --> B
B --> D[Same origin health probe]
D --> B
B --> E[Application Gateway connect]
E --> F[Authenticated WebSocket handshake]
Technical reviewBest possible solution: Retain the adaptive cadence and bounded busy-recovery exception in the existing activation owner, with the original transport and lifecycle guards intact. Do we have a high-confidence way to reproduce the issue? Current-main source shows the slower polling interval and inferred-busy exclusion, and the PR reports base-failing regressions; no product execution was performed during this read-only review. Is this the best way to solve the issue? The patch is appropriately placed: it adjusts the existing reachability scheduler, resets its failure budget at recovery boundaries, and keeps application-owned client replacement instead of adding another transport retry loop. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 84a74eb6b1f1. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +20, Tests +80, Docs +31, Other +184. Total +315 across 4 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 31, 2026, 2:54 AM ET / 06:54 UTC. |
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. |
|
Merged via squash auto-merge.
|
…law#189141) * perf(ui): recover short network drops before retry backoff expires * chore: keep reconnect timeline projection lint clean * fix: capture native visibility in the reconnect benchmark
What Problem This Solves
Fixes long Control UI reconnect waits after a brief network interruption: the transport's exponential retry can miss link restoration and sleep for several more seconds.
User Impact
A visible tab checks reachability every 750–1,000 ms during short interruptions. Online and foreground signals cancel the pending check and refresh that recovery window. Sustained failures back off to a 4–5 second health-check interval; failed checks never reset transport backoff or server retry hints.
Why This Change Was Made
The existing page-activation owner already knows whether a transport can be replaced. Reuse it instead of adding a transport retry loop. An upgrade failure whose health check straddles restoration can look like a busy Gateway; prior unreachable evidence now permits one recovery attempt. Another rejected upgrade against a live endpoint retains normal busy behavior. Young in-flight upgrades, pairing, startup retry, restart, hidden-page and suspension guards remain.
The benchmark records actual retry deadlines and native browser activation events through the existing application-context boundary. It retains the same authoritative hello and roster readiness requirement.
Evidence
Commands:
node --import ./scripts/tsx.mjs scripts/bench-control-ui-wire.ts --bundle-dir <head-bundle> --compare-source-dir <base-checkout> --compare-bundle-dir <base-bundle> --profile <local|remote|mobile> --auth token --extended-flows --pairs 20 --output <fresh-output>. Identical-source A/A uses the base checkout and bundle on both sides, with--pairs 10. All browsers were headless; each side used an isolated real Gateway and synthetic 120-message conversations.Cold-load source and wire audit: all 23 declared Chat assets are discovered together and transfer 1,207,282 B using the negotiated Brotli/identity encodings. Shared + Chat bundles contribute 810,374 B. The active boot work on metadata, input controls, presenters, and header subviews owns these cuts; this PR does not duplicate it. The round-trip ledger and timing table are below.
Production activation owner: 153 → 173 lines (+20). Tests: 288 → 368 lines (+80). The harness growth records the previously unlocalized retry schedule and verifies native online/visibility signals; no product diagnostic state or wire protocol is added. All four changed files total 2,797 → 3,126 lines; production growth is 20 lines. No rendering/effect/DOM-query baseline changes.
Reconnect results
20 serial interleaved pairs per profile; milliseconds, median / p95. These are raw distributions; the A/A and CPU qualification follows below.
The mobile median increase remains visible. Its identical-code A/A control moves 1,774 → 1,247 ms at median, with both p95s near four seconds. The 100 ms identical-code control moves 1,062 → 2,055 ms at median and 2,824 → 4,893 ms at p95. These controls are outside the timing band, so the noisy-host rule applies: judge the 20-pair CPU and structural evidence and retain the raw timings. All three before/after cohorts have zero capture errors.
Mobile first-handshake p95 falls 2,200 → 1,073 ms; hello-adopted p95 falls 2,758 → 1,632 ms. Handshake-to-hello medians stay 557 → 558 ms and hello-to-ready medians 330 → 336 ms. Each sample has exactly one post-restoration handshake and no dropped observer events. The timing gain is before hello, where the fix acts. Mobile task CPU median/p95 is 251.2/341.2 → 262.7/278.8 ms; script CPU is 148.1/174.4 → 149.3/165.3 ms. Local and 100 ms reconnect task CPU p95 improve 15.8% and 14.7%.
The transport itself retains 800 ms initial retry, ×1.7 backoff, a 15 s cap, and up to 20% jitter. Its first three waits sum to 4,472–5,366 ms, straddling a five-second outage. The page owner shortens the wait only after fresh reachability evidence. Accepted limit: a genuinely in-flight blackholed upgrade retains the existing eight-second stale-opening guard; this PR does not promise a one-second universal bound or interrupt a slow/busy upgrade repeatedly.
Untouched-flow increases remain disclosed in the full table. Local Settings p95 rises 26.9% while task/script CPU p95 fall 0.7%/3.4%; 100 ms Usage p95 rises 15.1%, with two slow request samples per side and flat median CPU. The matching identical-code Usage control rises 17.5%. Local New Session and 100 ms New Session have small wall/CPU movement. The local identical-code New Session p95 moves 99.9 → 130.1 ms, and its reconnect median moves 276.3 → 382.5 ms; the local control is also outside the timing band. Across the 160 samples for these four audited flow/profile cells there are zero health requests, connect calls, or WebSocket upgrades; connected-flow HTTP counts are unchanged. No additional recovery work reaches these cells.
Native wake correctness
One focused real-Gateway check per stimulus/profile, outside the timing campaign. All six require trusted browser events, a fresh authoritative hello/roster, enabled composer, zero capture errors and zero dropped observer events. Values are single-sample readiness, not performance estimates.
The first visibility attempt correctly failed when normal Playwright launch could not make the document hidden. The harness now reuses the existing native headless launcher and checks real hidden→visible transitions. A resulting viewport API error was caught by typecheck and independent review, corrected, and re-reviewed clean. Silent/online launch and context options are unchanged; their previous evidence is retained.
Cold mobile boot: handoff to W-BOOT-DIET
Ledger delivered to the active owner: #188996 (comment)
The detached baseline at
b8a04d5f03fab0ead756311a9d9f668ec280faa7reaches visible transcript at 6073.4 ms and enabled composer at 6073.5 ms with 250 ms RTT / 3 Mbps. This is one diagnostic at host load 26.2/20.4/19.6; the separate 20-pair comparison is recorded above. Source:base-diagnostic/01-base/01/sample.json. The earlier 7004.8 ms run is excluded because its serving checkout displayed a development branch badge.All declared assets are requested at 704.9–705.9 ms. History arrives at 3256.1 ms, before the final shared bundle at 4611.8 ms. The observed slow branch is HTML → assets → literal resolve → ready: a 3×RTT structural floor, plus transfer, processing and scheduling—not a fitted remote-minus-local equation. Shared + Chat bundles are a subset totaling 810,374 B, 67.1% of declared bodies and 2161.0 ms nominal serialization. Every hashed asset already has immutable caching.
Prioritize the existing W-BOOT-DIET owners: conditional tool presenters; input/control execution; header/appearance subviews; tool identity/detail metadata (#188996); and media/viewer closure (#181062). The menu/catalog partition (#189053) is already included in this baseline; do not count its savings again.
Resolve takes 1170.6 ms but only 1.89 ms of handler work; admission consumes 492.83 ms, with additional proxy scheduling delay. Preserve exact-key/name ambiguity semantics when removing this dependency. Selected-font preload and CSS start together;
font-display: swapapplies. Config requests overlap, and the second completes after readiness. Neither fonts nor duplicate config are proven gates. No acceptance win or target attainment is claimed from this sample.Syntax highlighting and Mermaid are already conditional (
markdown-code-blocks.ts:28,markdown-blocks-owner.ts:164) and absent from this plain-text cold asset wave. The 72,193 B Brotli Markdown runtime supplies visible-history parsing/sanitization; do not count all of it as optional highlighting. Source-map candidates include icon catalogs (36,045 mapped raw B), composer English (17,214 mapped raw B), and link-reader preview/network-policy closure. Those raw attribution values are not compressed savings; visible icons and inline-link safety remain required. The existing catalog partition is already on this baseline.Synthetic screenshots
Before:
After:
Full timing, CPU, retry-phase, A/A, and host-load evidence
Saved measurement evidence
Values are base → candidate in milliseconds; p95 is nearest rank. Ranges retain all samples. Paired % is the median of per-pair ratios, which can differ from the ratio of cohort medians. Incomplete cohorts appear only in the integrity table and make no acceptance claim.
Revision identities (each cohort remains pinned to its own recorded source):
b8a04d5f03fab0ead756311a9d9f668ec280faa7; candidate93d4e4cb057b7bec5c3c24fde9c3965d966dcda0; record errors 0; sourceround3/local-summary.json.b8a04d5f03fab0ead756311a9d9f668ec280faa7; candidate93d4e4cb057b7bec5c3c24fde9c3965d966dcda0; record errors 0; sourceround3/remote-summary.json.b8a04d5f03fab0ead756311a9d9f668ec280faa7; candidatebd6e72dfb4573a80feb4a42a9610721b2f7f89b3; record errors 0; sourceround3/mobile-summary.json.b8a04d5f03fab0ead756311a9d9f668ec280faa7; candidateb8a04d5f03fab0ead756311a9d9f668ec280faa7; record errors 0; sourceround3/aa-local-summary.json.b8a04d5f03fab0ead756311a9d9f668ec280faa7; candidateb8a04d5f03fab0ead756311a9d9f668ec280faa7; record errors 0; sourceround3/aa-remote-summary.json.b8a04d5f03fab0ead756311a9d9f668ec280faa7; candidateb8a04d5f03fab0ead756311a9d9f668ec280faa7; record errors 0; sourceround3/aa-mobile-summary.json.Different candidate revisions were measured across profiles. These rows are not automatically evidence for one final head; source-equivalence or final-head validation must be supplied separately.
Source-equivalence qualification: Mobile candidates were measured at bd6e72d; remote/local at 93d4e4c. The latter only rewrites benchmark event projection with explicit same-field assignments for lint. Final head 22d2815 changes only the visibility-mode harness to reuse the existing native headless launcher; silent/online launch and context options are preserved. Production source is identical, all candidates served the same immutable head UI bundle, and its source map matches the final committed production file byte-for-byte. Both sides of every A/A control use b8a04d5 and the same immutable base bundle.
Layout and bundle-content identities are not exported by these summary files and are not independently certified by this formatter.
Ready latency
Reconnect CPU and observed phases
CPU at ready and settled CPU have different endpoints; the settled window includes the post-ready drain. A pending retry deadline can be retired by a health/wake path, so it is not necessarily the winning attempt. “Hello adopted” is the connected snapshot, not first wire-byte arrival.
Reconnect event counts (unit: events; each cell is median B→H / p95 B→H [range B→H]):
A/A controls
Identical revision is required within each A/A row. Controls qualify their own network profile, not a different profile or host-load window.
Host load
OS load averages sampled at reconnect readiness, not CPU utilization. Each cell is median B→H [range B→H].
Increases requiring interpretation
This is a flag list, not automatic attribution. Compare the matching completed A/A and exact schedule/HTTP evidence before accepting or assigning a cause.
The mobile reconnect cohort-median increase must not be replaced by its negative paired-median number; both describe the same retained samples. Likewise, a flat Usage median does not erase a longer p95. No claim of “no regression” follows from this formatter.