Repository navigation
perf(control-ui): paint cached context usage with the composer - #190824
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: blocked before merge. What this changesThis PR restores cached context usage in the composer during warm reloads and removes the ring’s mount fade. Example: Reload a chat whose saved usage is 14,000 of 100,000 tokens.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open as an explicitly paused maintainer experiment; current main still lacks cached context-ring restoration, and no concrete introduced defect was found. Priority: P3 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Control UI projects Gateway session usage into its existing scoped browser snapshot and supplies cached display inputs to the composer until complete live usage is available. flowchart LR
A[Gateway session usage] --> B[Session snapshot projection]
B --> C[Scoped browser snapshot]
C --> D[Chat pane]
A --> E[Composer context model]
D --> E
E --> F[Context usage ring]
Technical reviewBest possible solution: Retain this focused implementation only if the declared experiment demonstrates earlier ring paint without worsening reload performance. Do we have a high-confidence way to reproduce the issue? Current main derives the ring only from live usage and applies a mount fade; the prior experiment independently records its late arrival on active chat and dashboard reloads. Is this the best way to solve the issue? The patch uses the existing scoped snapshot and live usage resolver, preserves live precedence, and removes only decorative motion; no smaller complete repair or unnecessary production machinery was identified. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ac6af4df2972. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +34, Tests +52, Docs +7, Other +80. Total +173 across 16 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 November 1, 2026, 10:33 PM ET / November 2, 2026, 03:33 UTC. |
cfc7425 to
ebdda71
Compare
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: ebdda712b8
ℹ️ 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".
ebdda71 to
d60a894
Compare
d60a894 to
cd37220
Compare
cd37220 to
696d0bd
Compare
696d0bd to
3be1382
Compare
Preserve the Gateway unavailable-usage fact through row admission, clear the existing display snapshot, and restrict the renderer fallback to omitted usage enrichment. Prove the restored warning disappears before snapshot replacement and stays absent on later partial rows.
3be1382 to
82193f6
Compare
|
Landed as ee3d681 with a pinned-head admin merge at 82193f6. Exact-head CI was red only on suites this PR does not touch or import:
The PR adds no source modules, and none of those suites import the changed files. |
…law#190824) On a warm reload the composer's context ring now paints its final value in the first composer frame instead of fading in after live usage arrives. The existing scoped session snapshot retains four display inputs (used tokens, resolved limit, approximate flag, last-prompt-budget flag). Partial roster rows keep the last admitted display; complete live usage replaces it in the same ring element. An explicit Gateway "usage unavailable" fact (absent totalTokens with totalTokensFresh:false) is no longer erased by the UI row sanitizer, so withdrawn usage clears the cached ring and a later partial row cannot restore it. The ring's 200 ms mount fade and the context-budget helper's obsolete forced deferred-chunk assignment are removed. No new store, config, protocol or Gateway change. Native 11-pair proof (AWS c7a.4xlarge, Team-scale synthetic fixture, 80 ms RTT): ring final at the first composer frame 0/11 -> 11/11 on Chat and Dashboard; snapshot +86 B; no secondary crosses the regression rule (Chat CLS +0.002 paired, IQRs overlap). Budget: parallel campaign landings left main at 1,278,887 B chat boot JS gzip, over the 1,277,887 B cap. Rebased onto current main, this PR measures 1,278,732 B (-155 B; new-session boot -170 B), and the cap is set to exactly that value with the existing 64 B build variance (lead-approved exact raise, 2026-11-02). CI red on unrelated suites (checks-ui 1/3 Bun: plugins-page action lookups and Details subagent preview; checks-ui-e2e 4/7: config-form-integrity 120 s timeout). None import touched modules; CI=true single-file controls pass on candidate and main.
What Problem This Solves
A signed-in warm reload of an active chat or dashboard deep link omits the composer's context-usage ring until live usage arrives, then replays a 200ms mount fade. This is one late visible change in the campaign's measured 14-state dashboard reload waterfall.
The ring needs admitted
totalTokens, freshness and the existing resolved context limit (last-prompt budget before reserve, otherwisecontextTokens). Boot roster/transcript projections and the prior composer snapshot omit used tokens. The Gateway already validates the durable token-version stamp; the UI receives admitted totals/freshness, not that raw stamp.Why This Change Was Made
Retain four display inputs in the existing scoped session snapshot: used tokens, resolved limit, approximate flag and last-prompt-budget flag. Partial roster rows preserve the last admitted display; explicit live unavailability clears it; complete live usage replaces it in the same ring element. Snapshot equality includes usage-only changes. Delete only the ring's mount fade and the context-budget helper's obsolete forced deferred-chunk assignment.
Data-model compatibility: optional
sessionState.contextUsagestays within projection 14, following the optional nested-field pattern in #189769. Old records omit it and use live rendering; old readers ignore it inside the non-strict session-state object. Existing account/connection/session/incarnation invalidation and retention stay with the snapshot owner. Cached display inputs never seed the authority-bearing selected-session row. No new store, server schema, Gateway protocol or configuration option.User Impact
Once usage has been admitted and saved, warm reload shows its final ring with the cached composer. Live changes update that control in place; an explicitly withdrawn measurement removes it and its high-context warning. Older snapshots acquire the optional field after live admission; cold loads still obtain usage live, with the decorative mount fade removed. Hover, color and popover motion remain.
Evidence
Exact chat boot budget, lead-approved 2026-11-02: CI's controlled build procedure on Node 24.22.1 measures current main at 1,278,887 B and the rebased candidate at 1,278,732 B (−155 B). The chat boot cap is set to exactly 1,278,732 B, with no added headroom; the existing 64 B build variance remains. Parallel campaign landings put main over the old 1,277,887 B cap; the original +500 B delta became −155 B after rebasing through #190925. No other budget is changed, and the comparison passes every budget.
Accepted performance comparison head
d60a894a90f4718ae0102a9e836b0609b75a2256; pinned main baselinec9cd215bf94ffdb466ca32674ea3f305edfc1de3. One quiet AWS c7a.4xlarge, leasecbx_1752559ed9e8, runrun_93479035d7a3c896cc1ca5bea183382d. Chromium 156.0.8078.4 from repo Playwright; native active-session/plugin fixture, 3,000 sessions, involving-me/category/created preferences, 97 groups/102 section-order entries, 5 collapsed groups, empty groups always, preview off and pinned sessions. Eleven interleaved AB/BA pairs plus eleven A/A pairs per route, unprofiled, 80 ms CDP latency; additional Team-scale live-fast eleven pairs per route. No local-host timings are performance results.Primary gate passes: first-composer-rAF final value/opacity improves 0/11 → 11/11 on both routes. The first inspected FCP-correlated captured surface improves 1/11 → 11/11 on Chat and 0/11 → 11/11 on Dashboard: 10/11 and 11/11 paired improvements. All 22 candidate first ring crops are pixel-identical to their final crops; every first-rAF label is
Session context usage: 1.8k of 96k (2%), opacity 1. All selected composer crops and all 88 first FCP-correlated full surfaces in A/B+A/A were inspected. Synthetic-only captures follow below.No secondary crosses the campaign regression rule: all IQRs overlap and no adverse metric is worse in 9/11 pairs above the threshold. Chat CLS is higher in 7/11 pairs and is reported explicitly. This removes a visible state change; no overall timing win is claimed. Team-scale FCP medians are unchanged at 88 ms Chat / 92 ms Dashboard. The separate Team-scale run disables owner probes; native measurements own LoAF.
First-composer ring result
Primary captured surface: first inspected composer capture selected by the rig at/after loader-matched FCP. The independent first-rAF observation compares the aria label, SVG dial and opacity with the final value. Pixel comparison uses the unmodified ring crop against the final surface; every selected capture is inspected separately.
A/A captured-surface control (both arms run baseline code):
Capture-method qualification: the ring's first visible-composer rAF and the first inspected FCP-correlated captured surface are separate boundaries. Screencast frames carry no navigation loader ID. Earlier raw surfaces support the result but do not establish first actual new-document presentation.
Chromium 156.0.8078.4 builds screencast timestamps from the frame's expected-display reference (source); FCP uses compositor presentation feedback (source). Root personally inspected both source paths. The rig's FCP-correlated marker is conservative: an earlier captured surface can already contain the composer. Neither sparse captures nor DOM sampling prove every OS display vsync.
Native active-session reloads
11 interleaved pairs per route; fixed AWS c7a.4xlarge; 80 ms CDP latency profile; unprofiled; 91.7% CPU idle before capture. Values are medians [Q1, Q3], milliseconds except CLS. All IQRs overlap; no secondary meets the campaign regression rule. Chat CLS is higher in 7/11 pairs with overlapping IQRs; this does not cross the campaign regression rule. No overall timing win is claimed.
A/B per-pair deltas (second arm minus first)
chat
dashboard
A/A per-pair deltas (second arm minus first)
chat
dashboard
*FCP-correlated surface means the first inspected capture whose expected-display reference timestamp is at/after loader-matched FCP presentation feedback. Those timestamp semantics differ; captures lack loader identity and do not establish every actual displayed frame. Independent first-rAF value/opacity and captured pixels support the before-paint claim. Element Timing first painted rows is reported independently above.
Additional Team-scale live-fast metrics and per-pair deltas
Team-scale live-fast secondary control
Same final baseline/candidate bundles on the same AWS c7a.4xlarge; 11 alternating pairs per route. Native plugin measurements above own the primary ring gate. All times are milliseconds. Each cell is median [Q1, Q3]; Δ is candidate minus baseline.
Chat
Dashboard
Validation
Current head:
82193f676d2921dc021c6933128fa236de79018c, based ond6ea7bc29785656feb9e3c35e45919110880d84e(includes #190925). The rebase was conflict-free and preserves every added/deleted lane line outside the approved budget edit. Only the chat cap and its two-line approval comment change in the checker; no runtime changes or other budget changes were required. The prior P2 review stands under the lead's cap-only review instruction.Accepted P2: live usage withdrawal
The row contract distinguishes unavailable usage (
totalTokensabsent,totalTokensFresh: false) from omitted enrichment (both absent).resolveTranscriptUsageFallbacksandpresentSessionRowproject the former, including unavailable usage without a report. Sidebar/dashboard allowlists and boot roster persistence omit both; the lifecycle producer stripstotalTokens,totalTokensFreshandcontextTokenstogether when usage is not fresh. The UI sanitizer's special case erasing the false marker is deleted. Snapshot projection clearscontextUsagefor explicit unavailability and retains it on true omission.ContextNoticeonly uses cache when neither live usage field is present, in one predicate without new state/store/config. Numeric stale totals remain approximate; measured zero remains valid. Projection 14 compatibility is unchanged.The new regression restores a cached 95% ring/warning, admits the normalized unavailable row while the old cache prop remains, verifies immediate disappearance before snapshot write, then proves a partial row cannot restore it. This fails on unchanged pre-fix owner code and passes after repair. Existing tree full/reference equivalence retains the false fact with its identity/no-refetch assertions. The original review thread is resolved.
Final-head candidate proof
AWS c7a.4xlarge lease
cbx_bf36e9fc7979, Node 24.22.1. 65 focused tests pass: composer 1 / 27.52 s wall, context meter 1 / 21.39 s, snapshot 47 / 4.97 s, retention 2 / 4.52 s, tree 14 / 4.11 s. Costs usepnpm test <file> --maxWorkers=1; they are validation costs, not performance comparisons. The changed-file gate passes with exit 0, including format, exact allocation, all typechecks, all dead-export scans and lint. CI's performance comparison procedure also passes on the final head and re-confirms 1,278,887 → 1,278,732 B (−155 B); every non-chat budget passes. The original measurement leasecbx_3b4ba22bec79and final proof/control leasecbx_bf36e9fc7979are released.Exact-head CI classification
The exact-SHA PR dispatch 41444757561 is terminal failure. control-ui-performance passes, as do every selected UI e2e shard and both real-Gateway e2e shards. The catalog reconnect case does not fail, so the conditional candidate CI-profile replay is not needed. Three failed jobs plus the aggregate gate are retained without a CI rerun:
chat-transcript-replies.test.ts, loaded explicit reply target, missing input. Unreproduced: the pinned-Bun single-file controls pass 24/24 on candidate (6.44 s) and main (8.68 s). A main control with the exact 2,224-file include selection, shard 3/3, three workers, four-CPU affinity and dual-runtime policy passes all 737 files / 8,306 tests in its Bun phase. Its Node phase fails a different menu-focus test. This does not prove an inherited reply failure or a fix.android-all-instrumentedartifact fetch ends withSocketException: Connection resetbeforePhotoPermissionsTestinitializes. No Android source or dependency changes in this PR.The normal ready-event exact-head CI run 41451247788 is also terminal failure. control-ui-performance is green. The catalog reconnect shard passes again; no conditional catalog replay is required. Two jobs and the aggregate gate fail:
config-form-integrity.e2e.test.ts: Agent List model-override round-trip exceeds its existing 120 s test timeout. Unreproduced: CI=true source and bundled projects pass 3/3 each on both candidate (53.32 s wall) and main (53.65 s), using the same four-CPU affinity and one worker. This is a bounded file control, not a shard replay.These are separate signatures from the manual dispatch above. The UI assertions remain recorded for follow-up; passing replays do not prove an inherited failure or a fix. Neither test nor runtime was changed and no CI job was rerun to chase green. The PR is ready, open and unmerged; the complete CI run is not green.
Per the lead's 2026-11-02 instruction, the completed full UI run at
cd37220512ec0c82606a206a3f0cc9b905f9cfc3plus final exact-head CI's selected UI e2e shards stand in for the stopped full-suite rerun. The full suite is not restarted. That completed run had 892 passed / 1 failed / 3 skipped files (896); 3,388 passed / 1 failed / 4 skipped tests (3,393), 4,872.25 s. Its sole outbox migration initial-roster timeout reproduced on pinned maind9627ecb437b2a0fdaa2215137b291dbbc806137(34.43 s single-file wall). It is not described as a full-suite green result.The catalog virtual-clock budget flake remains lead-owned; neither its test nor reconnect helper changes here. No CI rerun or timeout increase. Do not merge; the lead owns landing.
Production size and deleted machinery
UI renderer/runtime delta +35 net LOC; generated boot inventory (+1) and deleting the obsolete chunk override (−1) net to zero, so shipping UI/config is also +35. Required growth retains four inputs, extends the existing parser/equality and carries them to the meter; no second store or meter implementation. The superseded 200 ms mount animation and forced deferred helper assignment are deleted. The projector imports narrow data helpers rather than the deferred composer view-model.
The accepted comparison builds retain Chat20 / New Session15 boot JS requests. Chat gzip 1,278,480→1,278,881 bytes (+401); New Session 784,714→784,992 (+278). Those accepted-comparison builds had advisory CSS/Chat JS warnings on baseline too. The sole later budget change is the explicitly approved exact chat cap described above.
Prescribed non-test stat (
git diff --stat origin/main...HEAD -- ':!*.test.ts' ':!*test-support*' ':!docs/*'): 18 files, +184/−21 lines (net +163). The prescribed pattern also includes41 new.test.tsxlines; another87 net lines are non-shipping diagnostics/docs/allocation; shipping UI/config is the +35 above. Tests add exactly102 net lines: the prior53 plus49 for the withdrawal regression and retained-row facts. The existing allocation raises53→102 without slack; the shared scalar is unchanged. There is no new boot harness.