Repository navigation
fix: avoid reading unused Control UI asset bodies - #179190
Conversation
Cold bundled asset requests read and cache only the first acceptable available representation. Preserve canonical source checks, conditional responses, and rewritten HTML aliases. Extend the cold-load benchmark to real Gateway HTTP with first-load, waterfall, presentation, and throttling measurements.
|
🦞👀 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 395db5e241
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const terminalEnabled = gatewayUrl | ||
| ? await fetch(new URL("/control-ui-config.json", gatewayUrl)).then(async (response) => { | ||
| if (!response.ok) { | ||
| throw new Error(`Gateway bootstrap returned ${response.status}`); | ||
| } |
There was a problem hiding this comment.
Avoid requiring an unauthenticated bootstrap request
When --gateway-url targets a normal token- or password-authenticated Gateway, this credential-free fetch receives 401 and aborts the benchmark before Chromium starts. Gateway authentication defaults to token mode, and this new mode neither accepts credentials nor needs the real bootstrap payload because the browser route is replaced with a synthetic one later. Derive the terminal policy from an unauthenticated surface or provide an explicit authenticated/configured input so the documented command works without weakening Gateway auth.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesThis PR reads only the negotiated Control UI asset body and extends the cold-load benchmark to measure real Gateway HTTP delivery. Example: A cold browser visit requests a bundled script with Accept-Encoding: br, gzip.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: the asset-reader optimization has demonstrated value, but the new benchmark aborts against normally authenticated Gateways. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway HTTP handler negotiates static representations, delegates safe file preparation to the root-owned worker cache, and sends assets or rewritten HTML to browsers. flowchart LR
Browser --> GatewayHTTP
GatewayHTTP --> EncodingSelection
EncodingSelection --> RootAssetCache
RootAssetCache --> FileWorker
FileWorker --> BundledFiles
RootAssetCache --> HTTPResponse
HTTPResponse --> Browser
Technical reviewBest possible solution: Retain the negotiated-body optimization and derive benchmark terminal policy from the existing public document attribute. Do we have a high-confidence way to reproduce the issue? Current-main source eagerly reads all three asset bodies, and the PR supplies matching before/after Gateway measurements; the benchmark authentication failure is independently traceable from its credential-free fetch to the protected endpoint. Is this the best way to solve the issue? Selecting the first acceptable representation within the existing worker/cache owner is a focused fix that preserves conditional responses and HTML preparation; the benchmark should consume the document's existing terminal-policy contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ec4420b78882. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +25, Tests +34, Docs +33, Other +236. Total +328 across 8 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 21, 2026, 4:40 AM ET / 08:40 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…#179190) Cold bundled asset requests read and cache only the first acceptable available representation. Preserve canonical source checks, conditional responses, and rewritten HTML aliases. Extend the cold-load benchmark to real Gateway HTTP with first-load, waterfall, presentation, and throttling measurements.
What Problem This Solves
A cold Control UI request for a Brotli script or stylesheet read, returned from the file worker, and cached the original, Brotli, and gzip bodies. Only one body was sent to the browser.
User Impact
Cold visits do less file work and retain fewer asset bytes. The rendered UI, lazy boundaries, startup bundle, compression negotiation, custom roots, conditional requests, and HEAD responses keep their existing behavior.
Why This Change Was Made
Parse encoding preferences once, retain the canonical source metadata, and prepare only the first acceptable available body in the existing bounded root cache. Missing sidecars still fall through in preference order; selected errors retain their existing behavior. HTML aliases still obtain source HTML before document rewriting and compression.
The build already emits Brotli/gzip sidecars. Rewritten HTML already uses a bounded compression cache with Brotli quality 4, so this change adds no compression cache. The cold-load benchmark now supports real Gateway HTTP, first navigation without warm-up, network/CPU throttling, a resource waterfall, and DOM presentation milestones. Its bootstrap, RPCs, and media are synthetic; the terminal policy follows the real document to avoid a policy-reconciliation reload.
Evidence
Acceptance recorded before the measured series: five interleaved baseline/candidate pairs per profile; fresh browser/context and disabled HTTP cache; identical production UI bundle and fixed synthetic team-scale fixture; warm Gateway with cold prepared-asset cache; investigate any median/p95 regression above 20%. The profiles are loopback and 35 ms / 10 Mbps / 4× CPU. RPC delay is 35 ms on both. Document compression is warm in the main series. The initial loopback pair, which also includes first HTML compression, is reported separately; a sixth loopback pair preserves five warm-HTML samples per side. Process startup is outside these navigation timings.
The two isolated source Gateways differ at the asset-reader implementation: the baseline pins the original reader from
04e83824bca, while the candidate uses this change. Both use the same handler and production UI build. The normalgateway.controlUi.enabledlifecycle resets the asset cache between samples. Reader source hashes and raw sample artifacts were retained locally. Visibility is a DOM/rAF milestone, not a compositor-paint timestamp; neither side autofocuses the composer.Every measured visit reduced asset body-read attempts 158 → 58 (−63.3%) and body bytes 9,069,965 → 1,647,418 (−81.8%). Browser transfer bytes stayed approximately 1.66 MB. This is a demonstrated file-work reduction; these small samples do not establish a general navigation-latency improvement.
Five samples per side/profile; p95 is the nearest-rank maximum. All raw samples are retained. Host one-minute load ranged 57.5–148.7 during loopback and 58.8–100.9 during throttled runs. The initial, separate first-HTML pair had transcript/composer readiness 1757.7/1251.6 ms before and 1568.5/1032.0 ms after; it is diagnostic, not part of the five-sample cohorts.
The >20% regressions were investigated: loopback candidate p95 TTFB/transcript/composer rose, and throttled median TTFB rose 33.2→42.8 ms. Throttled pre-request time rose 10.4→18.0 ms while median request-to-first-byte remained 18.2→18.1 ms; the candidate also had one 61.4 ms request-to-first-byte outlier. No asset starts before HTML response completion.
/chatperforms the same missing-path and source-HTML reads, and emits the same 6,928-byte compressed document. Five additional interleaved direct HTTP controls, with fresh TCP connections and warm exact/chatcompression, measured header TTFB median/p95 13.2/53.5 ms → 14.9/56.6 ms and identical body hashes. This does not reproduce the browser's >20% median shift, but does not prove all tail-latency movement is host noise; latency remains inconclusive on this loaded host. No negative sample was discarded.Startup is byte-for-byte unchanged: 329,060 B JS gzip, 304,879 B JS Brotli, 990,291 B raw JS, 7 startup JS requests; 40,346 B CSS gzip and 1 startup CSS request. The separate strict check fails on both base and head against the current 325,000 B JS limit; this PR neither raises the budget nor grows startup.
pnpm tsgo:uipnpm ui:buildon baseline and candidateSeparate candidate-only 4× CPU diagnostic (excluded from A/B timings): 21,181 frames mapped and 266 asset frames unmapped. Largest application self-time samples were
chat-pane-header.tsx(307.7 ms),scroll-state-observer.ts(287.0 ms), and chat-details position/measurement (170.6/126.5 ms). These are client rendering owners outside this lane. The waterfall already discovers 34 startup/route assets within approximately 2 ms, and the existing preload generator walks static dependencies while retaining CSS ordering. No additional eager imports or preload expansion was justified. The diagnostic filmstrip independently brackets visible transcript pixels: frame 331 at 7067.6 ms still shows skeletons; frame 332 at 7089.5 ms contains the transcript (expected display time 7095.8 ms), following DOM readiness at 6924.3 ms. These are captured-frame observations, not exact physical-display timing, and this profiled run is excluded from A/B medians.Reproduction command (run against each isolated Gateway; reset its prepared-asset cache between samples):
LOC across touched files against integrated main: 4,308 → 4,636 (+328). Production serving code: 1,551 → 1,576 (+25); tests +34; benchmark +236; docs +33. The added benchmark code makes the serving path and measurement boundary reproducible. No UI feature files or dependencies changed.
The attached before/after captures contain only the synthetic fixture and show the unchanged rendered UI.
Main integration and final CI
Final head
395db5e241a6merges main atd35934e0a02bafter a real benchmark conflict prevented admission. The resolution keeps main’s dashboard-menu selector inside the warmed path and preserves first-load’s warm-up bypass. Fresh independent review is clean through P2; frozen install, UI typecheck, script lint, and formatting pass. Serving files and focused tests are identical to measured commitbf81c02c03c0; the same-bundle startup and timing measurements above belong to that original controlled comparison, not a repeated benchmark after integration.Final full CI 39568696562, attempt 1 completed with one inherited root failure; security-fast, real-Gateway E2E, and every other selected job passed.
Control UI Markdown table interactions > contains content-sized tables after restoring a percentage reading widthfails with the same false-versus-true assertion at line 214 on the latest completed scheduled main run 39563487228. The newer scheduled main run was still queued when qualified.The tested merge
873c3abaa5fchas ordered parents7f6d2b75845eand395db5e241a6, and matches a reconstructed merge tree. Its effective changes are this PR’s eight paths. The entire UI source tree, failing test, and table CSS have identical Git objects in the CI main parent and tested merge. Native inherited-failure recovery retains the red CI result; it does not claim green. No CI rerun was used.