Repository navigation
perf(ui): render less offscreen work when presenting a conversation - #160298
Conversation
Keep the scrolling buffer at six rows per edge. Use two rows for the first committed, nonempty presentation, then restore six on the next animation frame. Hidden/disconnected presentations cancel queued work; retained panes start a fresh initial phase without discarding their measurements. Cached rows widen even while history remains loading. The session-owned presentation controller also owns the existing deferred row-measure frame, keeping cancellation together and the virtualizer host within its lint budget. Scroll compensation and end-anchor reads are unchanged. Schedule link-preview discovery through cancellable idle work and retain mutation-driven scans rather than rescanning on unrelated parent updates. Pre-rebase performance evidence (adaptive commit 1d68520cd3d2): Fast-scroll blank frames out of 60 (up/down); three interleaved rounds: STEP=1.5 before: 9/3, 9/3, 10/3 STEP=1.5 after: 8/3, 8/3, 10/3 STEP=3 before: 31/22, 31/22, 31/22 STEP=3 after: 30/21, 31/21, 31/22 Four interleaved TRACE rounds versus the supplied baseline on port 19511; candidate served unchanged runtime on port 19671. Medians below are ms in visible/style/layout/task/longest-reported-task order: reload: 385/70/33.5/575/81.5 -> 460.5/71.5/35/556/72.5 switch-7: 147.5/62.5/14.5/336/63.5 -> 131.5/67.5/14.5/345/59 switch-3: 101.5/54.5/17/283/77 -> 98.5/62.5/16/277.5/75 switch-5: 116.5/57/19.5/290/92 -> 108.5/62/20/292/86 switch-8: 121.5/61.5/21.5/305.5/96 -> 109/62/19.5/282/85.5 Fast scrolling matches baseline within noise. Switch visibility is modestly better. Reload visibility is worse in this sample; do not claim a reload latency win or a broad total-CPU reduction. The initial buffer shifts some work into a follow-up frame. Host load and first-switch RPC/module work limit timing attribution. Single-pass source-mapped PROFILE inclusive ms (host update; markdown): reload: 13.6/40.7 -> 6.0/25.5 switch-7: 5.7/15.7 -> 4.2/19.8 switch-3: 9.6/0.8 -> 11.0/0.7 switch-5: 10.3/unsampled -> 8.2/0.4 switch-8: 9.0/unsampled -> 10.8/unsampled Validation: 198 selected tests pass, including 16 native end-follow browser cases and 8 focus/disclosure E2E cases. The transition regression failed on the constant-two implementation before the repair. UI typecheck, touched-file CI oxlint, formatting, and git diff checks pass. UI build succeeds; its size report flags startup JS at 363.7 KiB versus the 363.6 KiB budget. No size-budget exception or chunking change was made. Changed transcript test file wall costs, --maxWorkers=1 on the loaded host: geometry 16.89s, controller 20.70s, scroll ownership 20.19s, invalidation 22.21s. The accepted prefetch tests are unchanged; their 18 cases pass again. Per-round TRACE values in the same metric order: reload before: 246/60/37/567/77 473/76/36/625/86 297/78/31/583/104 524/64/27/541/53 reload after: 480/71/32/540/63 338/63/38/568/76 454/95/53/641/72 467/72/31/544/73 switch-7 before: 144/60/14/336/64 154/60/14/336/61 151/65/15/348/64 140/65/15/320/63 switch-7 after: 128/63/14/340/59 127/65/14/331/59 145/72/15/358/59 135/70/15/350/62 switch-3 before: 101/54/17/280/76 102/55/16/273/78 106/57/17/286/82 101/54/17/298/76 switch-3 after: 90/57/16/270/69 99/61/17/276/75 98/64/16/279/75 103/64/16/293/79 switch-5 before: 120/59/20/298/96 109/56/18/283/87 113/58/20/291/88 124/56/19/289/99 switch-5 after: 106/60/20/287/84 106/60/20/285/84 111/64/20/297/88 117/66/20/317/91 switch-8 before: 123/63/23/308/96 120/62/21/303/96 114/61/19/295/90 125/61/22/315/100 switch-8 after: 103/61/18/278/82 109/63/20/286/86 109/61/20/278/85 112/64/19/299/87 Final Codex autoreview: scoped-clean through P2; no actionable findings.
|
🦞👀 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. Reviewed September 28, 2026, 7:31 AM ET / 11:31 UTC (Revision 4). ClawSweeper reviewWhat this changesThe branch reduces offscreen conversation rows for the first presented frame, defers link-preview discovery until browser idle time, and updates Control UI tests and developer docs. Merge readiness✅ Ready for maintainer review Keep open: current main retains the reported performance costs, while the supplied Gateway-backed measurements and focused lifecycle tests support a useful improvement. No introduced blocking defect is established on this head. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI turns conversation messages into virtualized transcript rows after a session is selected. Its presentation controller chooses which rows reach the browser, while link discovery warms previews for visible links. flowchart LR
A[Conversation reload or switch] --> B[Transcript projection]
B --> C[Presentation controller]
C --> D[First visible frame]
D --> E[Full scrolling buffer]
B --> F[Idle link discovery]
F --> G[Link previews]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +121, Tests +220, Docs +9. Total +350 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the presentation phase owned by the session virtualizer and link rescans owned by the existing observer, with navigation targets and fast scrolling retaining their full buffer. Do we have a high-confidence way to reproduce the issue? Yes. Current-main source shows the six-row first render and microtask link scans, and the PR describes a bounded Gateway-backed timing comparison; I did not rerun it in this read-only review. Is this the best way to solve the issue? Yes. A one-frame smaller buffer preserves the normal scrolling behavior afterward, and idle discovery reuses the existing mutation observer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f504ddd345aa. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Reduced first-presentation overscan could omit the folded-work header when reply navigation loaded its source before the widening frame. It also persisted for detached renders or started after their full first commit, hiding retained actions, historical questions, and avatar rows. Use the normal six-row buffer for pending navigation, focus, anchor, or scroll work. Start reduced overscan only for a connected presentation before its first commit, and restore the normal buffer on disconnect. Ordinary presentation keeps its two-to-six-row frame transition. Keep the existing regression tests unchanged, including both grouped and ungrouped reply-source navigation cases. Merge current main without rewriting the published branch history. Validation: - Reproduced the original reply failure on 16cfa0c (8/9 passing). - All 70 focused unit/browser/E2E suites pass: 1,338 tests. - Exact captured CI UI shard 3/3 via the Bun-compatible coordinator: all 8,193 cases pass, including both reply navigation variants. The run exits nonzero for one unrelated 60-second Web Awesome accessibility hook timeout: Chromium cleanup took 67.78 seconds after all four cases passed. Fixture, helpers, and exercised components match main. A standalone Bun probe passes 4/4 with clean teardown; no timeout or assertion was changed, and this replay is not claimed as a fix for the shard-level timeout. - UI typecheck, touched-file CI oxlint, formatting, and diff checks pass. - Codex autoreview is scoped-clean through P2. Optional live fast-scroll comparison was not rerun; the Gateways remain stopped. First-frame buffer and native scrolling regressions remain green.
The navigation repair restored the normal overscan constant as the host's construction default. Initial overscan is now used only by the presentation controller in this module, leaving its named export unused in production. Keep the value private; no tests import it or require changes. Validation: - CI's knip 6.32.2 production invocation exits 0 with no findings. - All 70 focused transcript/reply/navigation/anchor/focus suites pass: 1,338 tests across 54 unit/browser files and 16 E2E files. - UI typecheck, touched-file CI oxlint, formatting, and diff checks pass. - Codex autoreview is scoped-clean through P2. Investigated the separately reported rename-composition CI failure with three interleaved full-file trials on PR head 79de515 and three with main 6aa5242 versions of only the ten PR-touched files. All six runs pass 5/5 cases, including legacy composition Escape: 0/3 failed runs and 15/15 passing cases for each variant. The temporary comparison branch was removed and the original branch restored without stashing or rewriting it. CI failed only the final title reconciliation after the patch request, editor dismissal, and a subsequent sessions.list request had succeeded. That failure remains unreproduced and unattributed; these local results do not prove it unrelated to the PR. Rename code and assertions are unchanged.
…penclaw#160298) * perf(ui): limit transcript work during initial presentation Keep the scrolling buffer at six rows per edge. Use two rows for the first committed, nonempty presentation, then restore six on the next animation frame. Hidden/disconnected presentations cancel queued work; retained panes start a fresh initial phase without discarding their measurements. Cached rows widen even while history remains loading. The session-owned presentation controller also owns the existing deferred row-measure frame, keeping cancellation together and the virtualizer host within its lint budget. Scroll compensation and end-anchor reads are unchanged. Schedule link-preview discovery through cancellable idle work and retain mutation-driven scans rather than rescanning on unrelated parent updates. Pre-rebase performance evidence (adaptive commit 1d68520cd3d2): Fast-scroll blank frames out of 60 (up/down); three interleaved rounds: STEP=1.5 before: 9/3, 9/3, 10/3 STEP=1.5 after: 8/3, 8/3, 10/3 STEP=3 before: 31/22, 31/22, 31/22 STEP=3 after: 30/21, 31/21, 31/22 Four interleaved TRACE rounds versus the supplied baseline on port 19511; candidate served unchanged runtime on port 19671. Medians below are ms in visible/style/layout/task/longest-reported-task order: reload: 385/70/33.5/575/81.5 -> 460.5/71.5/35/556/72.5 switch-7: 147.5/62.5/14.5/336/63.5 -> 131.5/67.5/14.5/345/59 switch-3: 101.5/54.5/17/283/77 -> 98.5/62.5/16/277.5/75 switch-5: 116.5/57/19.5/290/92 -> 108.5/62/20/292/86 switch-8: 121.5/61.5/21.5/305.5/96 -> 109/62/19.5/282/85.5 Fast scrolling matches baseline within noise. Switch visibility is modestly better. Reload visibility is worse in this sample; do not claim a reload latency win or a broad total-CPU reduction. The initial buffer shifts some work into a follow-up frame. Host load and first-switch RPC/module work limit timing attribution. Single-pass source-mapped PROFILE inclusive ms (host update; markdown): reload: 13.6/40.7 -> 6.0/25.5 switch-7: 5.7/15.7 -> 4.2/19.8 switch-3: 9.6/0.8 -> 11.0/0.7 switch-5: 10.3/unsampled -> 8.2/0.4 switch-8: 9.0/unsampled -> 10.8/unsampled Validation: 198 selected tests pass, including 16 native end-follow browser cases and 8 focus/disclosure E2E cases. The transition regression failed on the constant-two implementation before the repair. UI typecheck, touched-file CI oxlint, formatting, and git diff checks pass. UI build succeeds; its size report flags startup JS at 363.7 KiB versus the 363.6 KiB budget. No size-budget exception or chunking change was made. Changed transcript test file wall costs, --maxWorkers=1 on the loaded host: geometry 16.89s, controller 20.70s, scroll ownership 20.19s, invalidation 22.21s. The accepted prefetch tests are unchanged; their 18 cases pass again. Per-round TRACE values in the same metric order: reload before: 246/60/37/567/77 473/76/36/625/86 297/78/31/583/104 524/64/27/541/53 reload after: 480/71/32/540/63 338/63/38/568/76 454/95/53/641/72 467/72/31/544/73 switch-7 before: 144/60/14/336/64 154/60/14/336/61 151/65/15/348/64 140/65/15/320/63 switch-7 after: 128/63/14/340/59 127/65/14/331/59 145/72/15/358/59 135/70/15/350/62 switch-3 before: 101/54/17/280/76 102/55/16/273/78 106/57/17/286/82 101/54/17/298/76 switch-3 after: 90/57/16/270/69 99/61/17/276/75 98/64/16/279/75 103/64/16/293/79 switch-5 before: 120/59/20/298/96 109/56/18/283/87 113/58/20/291/88 124/56/19/289/99 switch-5 after: 106/60/20/287/84 106/60/20/285/84 111/64/20/297/88 117/66/20/317/91 switch-8 before: 123/63/23/308/96 120/62/21/303/96 114/61/19/295/90 125/61/22/315/100 switch-8 after: 103/61/18/278/82 109/63/20/286/86 109/61/20/278/85 112/64/19/299/87 Final Codex autoreview: scoped-clean through P2; no actionable findings. * fix(ui): preserve transcript targets during initial presentation Reduced first-presentation overscan could omit the folded-work header when reply navigation loaded its source before the widening frame. It also persisted for detached renders or started after their full first commit, hiding retained actions, historical questions, and avatar rows. Use the normal six-row buffer for pending navigation, focus, anchor, or scroll work. Start reduced overscan only for a connected presentation before its first commit, and restore the normal buffer on disconnect. Ordinary presentation keeps its two-to-six-row frame transition. Keep the existing regression tests unchanged, including both grouped and ungrouped reply-source navigation cases. Merge current main without rewriting the published branch history. Validation: - Reproduced the original reply failure on 16cfa0c (8/9 passing). - All 70 focused unit/browser/E2E suites pass: 1,338 tests. - Exact captured CI UI shard 3/3 via the Bun-compatible coordinator: all 8,193 cases pass, including both reply navigation variants. The run exits nonzero for one unrelated 60-second Web Awesome accessibility hook timeout: Chromium cleanup took 67.78 seconds after all four cases passed. Fixture, helpers, and exercised components match main. A standalone Bun probe passes 4/4 with clean teardown; no timeout or assertion was changed, and this replay is not claimed as a fix for the shard-level timeout. - UI typecheck, touched-file CI oxlint, formatting, and diff checks pass. - Codex autoreview is scoped-clean through P2. Optional live fast-scroll comparison was not rerun; the Gateways remain stopped. First-frame buffer and native scrolling regressions remain green. * fix(ui): keep initial transcript overscan module-private The navigation repair restored the normal overscan constant as the host's construction default. Initial overscan is now used only by the presentation controller in this module, leaving its named export unused in production. Keep the value private; no tests import it or require changes. Validation: - CI's knip 6.32.2 production invocation exits 0 with no findings. - All 70 focused transcript/reply/navigation/anchor/focus suites pass: 1,338 tests across 54 unit/browser files and 16 E2E files. - UI typecheck, touched-file CI oxlint, formatting, and diff checks pass. - Codex autoreview is scoped-clean through P2. Investigated the separately reported rename-composition CI failure with three interleaved full-file trials on PR head 79de515 and three with main dba4154 versions of only the ten PR-touched files. All six runs pass 5/5 cases, including legacy composition Escape: 0/3 failed runs and 15/15 passing cases for each variant. The temporary comparison branch was removed and the original branch restored without stashing or rewriting it. CI failed only the final title reconciliation after the patch request, editor dismissal, and a subsequent sessions.list request had succeeded. That failure remains unreproduced and unattributed; these local results do not prove it unrelated to the PR. Rename code and assertions are unchanged.
What Problem This Solves
Fixes: presenting a conversation (reload or session switch) rendered six whole offscreen turns beyond each viewport edge on its first frame, and link-preview discovery rescanned the transcript on every pane update. Both added main-thread work before the transcript became visible.
User Impact
Switching to another conversation shows it slightly sooner: median visible time improves by 3–16 ms per target (for example 147.5 → 131.5 ms and 121.5 → 109 ms) in interleaved runs. Fast scrolling afterwards is unchanged (same blank-frame counts as main). Reload visibility was too noisy to show a change, and no reload win is claimed.
Why This Change Was Made
Source-mapped profiles of reload and switch showed the virtualizer rendering whole assistant turns offscreen (overscan 6 rows per edge, where a row is a whole turn), so the first presented frame paid for Markdown and layout of content nobody could see. In the reload profile, virtualizer update was 13.6 ms and Markdown 40.7 ms. Separately,
link-reader-prefetchrescanned the transcript in a microtask on every directive update.Lowering overscan permanently was measured and rejected. A fast-scroll probe (scroll N viewports per frame, count painted frames with no row under the viewport midpoint) showed constant overscan 2 doubling or tripling blank frames. A pixel-bounded overscan (one viewport of buffer, 1–6 rows) also regressed fast scrolling without a reliable back-scroll gain.
TranscriptPresentation(a transcript-sessionReactiveController) renders the first non-empty presented commit with overscan 2 and restores overscan 6 on the next animation frame. Hiding or disconnecting cancels pending frames, and retained panes restart the phase. It also absorbs the existing deferred row-measure frame logic from the virtualizer host.Evidence
fastscroll.mjs), blank frames of 60, up/down, three interleaved rounds: at 1.5 viewports/frame, main 9–10/3 vs this change 8–10/3; at 3 viewports/frame, 31/22 vs 30–31/21–22.TRACE=1harness, four interleaved rounds against a Gateway with seeded synthetic sessions; median visible ms, main → this change: switch-7 147.5 → 131.5, switch-3 101.5 → 98.5, switch-5 116.5 → 108.5, switch-8 121.5 → 109; reload 385 → 460.5, noise-dominated (per-run 246–524 before, 338–480 after). Reload profile: virtualizer update 13.6 → 6.0 ms, Markdown 40.7 → 25.5 ms.Per-file cost (
--maxWorkers=1, local wall on a heavily loaded host; CI seconds will be added from the first run):link-reader-prefetch.test.ts14.9 s,chat-transcript-geometry.test.ts15.2 s,chat-transcript-controller.test.ts16.7 s,chat-transcript-scroll-ownership.test.ts14.3 s,chat-transcript-invalidation.test.ts15.9 s. The build's startup-JS size report is 34 bytes over its limit on this base; no budget exception was added.