Repository navigation
perf(control-ui): load older history in 2 MiB pages - #176480
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 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: 8f87e3c864
ℹ️ 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".
| // larger pages. The Gateway owns the response byte and single-message limits. | ||
| const CHAT_HISTORY_OLDER_PAGE_LIMIT = 1000; | ||
| const CHAT_HISTORY_OLDER_PAGE_MAX_BYTES = 1024 * 1024; | ||
| const CHAT_HISTORY_OLDER_PAGE_MAX_BYTES = 2 * 1024 * 1024; |
There was a problem hiding this comment.
Update the real-Gateway pagination budget assertion
When the real-Gateway performance suite backscrolls, this constant now sends a 2 MiB budget, but ui/src/e2e/chat-loading-performance.real-gateway.e2e.test.ts:765-774 still documents and asserts the previous 1 MiB value. I checked .github/workflows/ci.yml:2654, where that exact test is included, so the suite will deterministically fail before validating the performance behavior. Update that assertion and its adjacent comment together with this owner constant.
AGENTS.md reference: AGENTS.md:L80-L80
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. What this changesThis PR doubles older-history page budgets from 1 MiB to 2 MiB through the existing shared request owner. Example: Page backward through the synthetic 4,240-message conversation.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR: the measured performance improvement has maintainer backing, but one real-Gateway test still asserts the replaced budget. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Control UI history owner sends bounded chat.history requests to the Gateway, then supplies returned pages to transcript projection and rendering. flowchart LR
A[Reader scrolls backward] --> B[History pane]
B --> C[Shared older page request]
C --> D[Gateway history handler]
D --> E[Bounded message page]
E --> F[Transcript projection and render]
Technical reviewBest possible solution: Retain the single-owner budget change and update the real-Gateway assertion and adjacent comment to 2 MiB. Do we have a high-confidence way to reproduce the issue? Source establishes the deterministic 2 MiB request versus 1 MiB assertion mismatch; no target code was executed during this read-only review. Is this the best way to solve the issue? Changing the existing request constant is the smallest complete implementation of the accepted tradeoff, with no additional state, transport, or scheduling machinery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bf9843cf9550. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource 0, Tests +15. Total +15 across 6 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
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 18, 2026, 5:19 PM ET / 21:19 UTC. |
8f87e3c to
e7b1e7e
Compare
|
@clawsweeper re-review The real-Gateway request-budget assertion and adjacent comment are corrected on The PR evidence now records the full 833-file run, repaired WebKit setup, and exact-main comparison of all four test failures. Main reproduces the automation setup failure; #176426, merged during validation, repairs the three media failures. Exact-head CI's remaining red is the inherited absolute bundle ceiling and its aggregate gates. All validation leases are released. No thresholds, assertions, or skips were weakened. |
|
🦞👀 Re-review progress:
|
…law#176480) Reading back through a long session loaded older history in 1 MiB pages, so reaching the beginning of a long agent session took 17-19 page loads. WebSocket permessage-deflate is now live, so larger JSON pages are cheap on the wire, and the Gateway already allows 6 MB per history response. Older-history pages for reader backscroll now request up to 2 MiB. The 1000-message limit and the boot paging policy are unchanged (no automatic boot paging beyond one viewport fill). Seven interleaved AWS c7a.4xlarge pairs per history shape, backscroll to the beginning: normal 17 -> 9 pages, 6.07 -> 3.74 s; tool-heavy 19 -> 10 pages, 6.55 -> 4.25 s; both better in every pair. Tradeoff: worst single page-arrival frame 195 -> 213 ms (normal) and 142 -> 171 ms (tool-heavy); 5 MiB was excluded because frame cost grows with page size. Runtime net 0 LOC. 74 focused tests and native history e2e pass. The only CI red is control-ui-performance's chat boot JS ceiling, which the merge-base build already exceeds (1459.6 KiB > 1455.1 KiB); this change adds 25 B.
Related: #176385
What Problem This Solves
Reaching the beginning of a long conversation requires too many small older-history requests and transcript prepends.
User Impact
Older history loads in 2 MiB pages instead of 1 MiB. In the measured long histories, traversal takes 9 rather than 17 pages (normal) and 10 rather than 19 (tool-heavy), with total time falling from 6.07 to 3.74 seconds and 6.55 to 4.25 seconds. The accepted tradeoff is a higher median worst arrival frame: 195 → 213 ms and 142 → 171 ms. No migration or user action is needed.
Why This Change Was Made
Double the byte budget at the existing history request owner, shared by direct older-page reads and staged prefetch. Keep the 1000-message limit: it does not bind at 2 MiB. Keep the startup budget and one automatic viewport-fill policy unchanged. The 2 MiB setting remains below the server's 6 MiB cap.
The original approximately 120 ms arrival-frame target was invalid because even the 1 MiB baseline exceeds it. The coordinator accepted the 35–38% traversal improvement and +18.6/+29.3 ms worst-arrival tradeoff. 5 MiB is deliberately excluded: larger pages carry more per-arrival work and the message limit can remove their benefit. No new scheduling, caching, configuration, or transport machinery is added.
Evidence
The campaign began with a signed-in reload of a dashboard deep link showing 14 visual states over about 15 seconds. This change addresses deliberate backscroll after reload, not the already-separated startup path. All fixtures and captures used here are synthetic.
Curve
Times are milliseconds, shown as median [Q1, Q3] across seven runs. Arrival is each run's worst completed arrival frame. Fill is each run's median per-page fill. Byte totals cover history responses only.
The tool-heavy 3 and 5 MiB requests return the same pages: the 1,000-message cap binds at about 2.981 MiB. Normal 5 MiB requests bind at about 4.057 MiB. Response envelopes can slightly exceed the message-only budget.
Paired deltas against 1 MiB
Candidate minus baseline, in round order. All values are milliseconds. No slow sample was discarded.
Measurement method, reload controls, and attribution
Environment and method
AWS Crabbox
cbx_4964b2ff9098, fixedc7a.4xlarge, 16 vCPUs (AMD EPYC 9R14), 30 GiB RAM. Node v24.19.0, pnpm v12.11.1, and the repository Playwright Chromium build (Chrome for Testing 156.0.8078.4). One instance and one boot ID served the complete comparison. Pre-run load averages ranged from 0.52 to 2.47. Setup, UI build, and initial attribution succeeded in run_ea1047a451d2147bc40f4b0708f9e31e. The curve continued through the sanctioned SSH transport on that retained lease.The production-bundle Team-scale benchmark retained its canonical shell, Online roster, plugin inventory, and common 240-message tail. The older prefix contains either 4,000 plain-text messages (1,000-character questions and 7,200-character answers) or 6,200 messages in 100 tool-heavy turns (30 call/result pairs per turn, collapsed activity). Full histories contain 4,240 and 6,440 messages respectively. These are long synthetic stress cases, not copies of a private conversation.
Seven rounds per history shape covered 1/2/3/5 MiB, reversing order on even rounds: 56 unprofiled browser runs. All use the same bundle and source, Chromium, 35 ms synthetic inbound latency, and 4 ms minimum reply spacing. The benchmark changes only outgoing older-history
maxBytesafter the reload measurement. The server fixture honors that budget and the unchanged 1,000-message limit. Startup requests remain untouched.Each measured page goes through the native history owner with staging disabled (
loadOlderMessages(false)) to isolate one request and one prepend. The driver moves to older content between pages and reaches the beginning. It validates progress, exactly one history response per step, and a visible transcript viewport. This is a controlled page-through experiment; it does not measure continuous-wheel prefetch effectiveness or a real Gateway network.Page fill is response arrival to the visible-viewport receipt after two paint opportunities. LoAF records are drained after the phase. Arrival-frame statistics include completed frames after response arrival and before that page's filled receipt; the next scroll can begin in the same task as the receipt, so its later-ending frame is attributed to the overall traversal instead. The whole-traversal maximum includes every scroll and the final movement to the beginning. Raw data retains the timestamps and the original overinclusive prototype field;
analyze.pyreconstructs the completed-arrival metric. Frames below the browser's 50 ms LoAF threshold are conservatively reported as at most 50 ms.Bytes below are actual history response JSON bytes. Compression is a separate level-1, fresh-context permessage-deflate estimate, excluding WebSocket/TLS overhead; the mock transport does not negotiate compression. Estimates run outside the measured interval. Profiled setup runs and the two superseded boundary-calibration attempts are excluded from the curve.
Reload control
All 56 reloads issue zero boot
chat.historycalls and one unchanged 38,763-bytechat.startupresponse. This synthetic response does not model the live retained-receipt fast path. No reload timing metric regresses under the campaign's non-overlapping-IQR or ≥6/7 paired-sign-plus-size rule. The occasional slow paints remain in the data. Because the budget override activates after reload, these are unchanged-code controls, not a shipped-candidate reload proof.Attribution and limits
Source-mapped
--cpu-profilecaptures executerequestOlderChatHistoryPage,performOlderMessagesLoad, the pane projection, and the real transcript render path. On the 1 MiB diagnostic runs, Solid flush contains 65.4% of sampled normal-history work and 62.1% of tool-heavy work.maxTranscriptScrollOffsetaccounts for 19.4% and 15.5% self time; its principal chain issyncHistoryObserver→isMaintenanceScroll→ transcript geometry. The supplied live source-mapped frame places the same geometry function at 12.3% of sampled busy time. This demonstrates the relevant hot path at a comparable share, while the synthetic long histories and controlled scroll pattern limit extrapolation to a particular live conversation.The immediate history-apply function accounts for only 0.9–1.5% inclusive time in those diagnostic runs. The evidence points to render/layout work, not a large synchronous history-apply loop. It does not prove that a slicing change at the request owner would remove that cost, and no scheduling, caching, or transport workaround was added. Remaining rendering cost is not claimed to be inherent.
The separate 2 MiB
--cpu-profile-comparecaptures preserve that attribution: Solid flush contains 58.1% (normal) and 54.8% (tool-heavy), direct history application 1.0% and 1.4%, and transcript geometry 15.4% and 12.8%. Median synchronous message dispatch is approximately 11.0 and 10.2 ms. These profiles are diagnostic, not samples in the timing table.Implementation validation
Final head:
e7b1e7e8d8bea1dfe40c71dace29f3b39a726e2d. Autoreview is clean through P2, including the follow-up correction to the real-Gateway request-budget assertion.The native-owner budget regression failed with the original 1 MiB value (expected 2097152, received 1048576), then passed with 2 MiB. All 74 focused unit tests pass on the final head. Five files cover the owner, one automatic viewport fill, startup/history, reply navigation, and scroll-maintenance intent.
Final-head AWS proof on
cbx_887ccab15d09,c7a.4xlarge:chat-pane-history.test.tschat-pane-history-autofill.test.tschat-history.test.tschat-pane-history-reply.test.tschat-pane-history-maintenance.test.tsxchat-history-loading.e2e.test.tschat-history-prepend-anchor.e2e.test.tschat-history-activity-anchor.e2e.test.tschat-loading-performance.real-gateway.e2e.test.tsUnit commands use
node scripts/run-vitest.mjs <file> --maxWorkers=1; native E2E addsrun --config test/vitest/vitest.ui-e2e.config.ts. The native tests preserve every-frame anchoring, reach the first message, exhaust paging, and protect cold/warm reload behavior. The real-Gateway test checks actual response budgets and no older-page reads during its long-session reload. Browser layout and real-Gateway setup require the longer E2E wall times; no new fixture boots were added.The full UI E2E suite completed on the final head in AWS
cbx_794664ca5450, fixedc7a.4xlarge: full-suite run. Original result: 824 files passed, 6 failed, 3 skipped (833); 3,583 tests passed, 4 failed, 7 skipped (3,594), 6,182 seconds wall time. The native history performance file also passed inside this full run. The complete per-file results and original diagnostics are retained with the run evidence.Two files failed before execution because the payload installed Chromium but omitted WebKit. After installing WebKit on the same lease,
tooltip-first-activation.e2e.test.tsandworkboard-native-bundle.e2e.test.tsboth passed in Chromium and WebKit: 4 tests, 40 seconds, with no source changes. The original setup failures remain recorded.The four actual test failures were compared with current main
5a0fb5a7f5791d9a02c3a3c7b322710840af814don a fresh AWSc7a.4xlargelease,cbx_04be84b97255: main comparison. The comparison ran the same four files with one worker: 3 files passed, 1 failed; 5 tests passed, 1 failed; 405 seconds wall time.control-ui-automation-management.real-gateway.e2e.test.tscontrol-ui-media-transcript.real-gateway.e2e.test.tschat-managed-media-order.real-gateway.e2e.test.tschat-tts-supplement.real-gateway.e2e.test.ts#176426 merged at 22:01:55 UTC during this run. Its evidence reproduces the same media failures on earlier main and proves all three repaired. The fix retains the Gateway dispatch source through media finalization and persistence. The image-order failure here is a direct CLI
chat.historyread withlimit: 20, independent of the changed UI older-page budget. No duplicate Gateway fix, test relaxation, or unrelated rebase was added to this lane.The three suite-declared skipped files are
desktop-resize.real-gateway.e2e.test.ts,chat-steer-deferred-custody.real-gateway.e2e.test.ts, anddeepseek-search.real-gateway.e2e.test.ts; no skip was introduced by this PR. Thus the full run is not claimed green: both setup gaps were repaired, one failure reproduces on current main, and the other three are documented upstream defects already repaired on main.The optional standalone
check-changedrun reported max-lines baseline omissions in three untouched files (chat-message.test.tsx,config-page-state.ts,sessions-page-state.ts) and the existing 723/720 core test-root guard, then expanded into all 31 core type graphs. It was stopped after four passing graphs once CI had passed the selected lint/type/test gates, so it is not reported as a clean standalone run. Those subjects and the test inventory are unchanged from branch basebf9843cf955019f65fe7e5855394b659228e063f.CI classification
All final-head checks are terminal: 37 success, 38 skipped, 3 failures. The failures are the inherited absolute chat-boot bundle ceiling and its two propagated CI-gate entries. Selected UI, UI E2E, baseline-ratchet, lint, and test-type jobs passed.
The same-job comparison builds main
a7d517618a103d898baf9e7d4649a8e0d14a01ddat 1,494,544 bytes of chat-boot gzip, already over the 1,490,000-byte ceiling. The candidate merge build is 1,494,586 bytes (+42 bytes), with requests unchanged at 26. The informational classifier calls this new against an older scheduled main run; the actual main-base build in this job demonstrates the inherited ceiling breach. No threshold or baseline was changed.Production LOC: +1 / −1, net 0. The old budget is replaced at its existing owner; no machinery is introduced. Test LOC: +22 / −7, net +15. The requested production-stat filter also includes
.test.tsx; excluding both test suffixes gives the runtime delta above.