Repository navigation
perf(ui): speed up large slash-command menus - #190398
Conversation
Render always-present command and argument icons directly, eliminating 253 optional-content spans from a full menu. Preserve grouping, keyboard selection, mask styling and lazy boundaries. Retained-bundle pairs cut script CPU about 6% in both viewports; twenty-pair confirmation supports about 8%. Accept 452 B of chat gzip growth and preserve its existing 811 B budget headroom. Startup and CSS budgets stay unchanged.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR removes unnecessary slash-menu icon wrappers, records their count in the benchmark, and adjusts the chat bundle budget. Example: Open a slash menu containing 253 commands and filter to /compact.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a measured, focused performance improvement that current main does not contain; no actionable patch defect was found, but the failed UI check remains unclassified. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI composer passes filtered command and argument choices from its existing menu state owner to lazy option renderers, which produce accessible selectable rows. flowchart LR
A[Composer input] --> B[Slash menu state]
B --> C[Grouping and lazy menu shell]
C --> D[Command and argument options]
D --> E[Shared option renderer]
E --> F[Accessible menu DOM]
Technical reviewBest possible solution: Render unconditional icons directly within the existing option renderer while preserving menu semantics and the documented bundle tradeoff. Do we have a high-confidence way to reproduce the issue? Current main visibly creates an optional-content owner and span for every unconditional icon; the supplied production-browser measurements exercise the resulting large-menu workload, although no target code was executed during this read-only review. Is this the best way to solve the issue? The unnecessary work is optional-content handling around guaranteed icon elements; removing those two wrappers is the smallest complete fix and preserves the existing state, rendering, and lifecycle owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 47cb40a3b3f0. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -5, Other +10. Total +5 across 3 files. Added test files: 0. View PR surface stats
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, 9:33 AM ET / 14:33 UTC. |
Merge current main for the named CI failure. Its three-line mobile composer cap made the prior resize draft fill the cap at both widths. Keep the same growth, shrink and observer assertions with a shorter draft. Refresh the slash-menu chat budget to the new same-host measured head plus its existing headroom.
|
Merged via explicitly authorized admin squash with prior CI and scoped validation.
|
* perf(ui): reduce slash-menu icon rendering work Render always-present command and argument icons directly, eliminating 253 optional-content spans from a full menu. Preserve grouping, keyboard selection, mask styling and lazy boundaries. Retained-bundle pairs cut script CPU about 6% in both viewports; twenty-pair confirmation supports about 8%. Accept 452 B of chat gzip growth and preserve its existing 811 B budget headroom. Startup and CSS budgets stay unchanged. * test(ui): await live sidebar before counting deletion writes
What Problem This Solves
Large slash-command menus spend unnecessary CPU on every opening and filter update.
User Impact
Slash-command menus use less script CPU while preserving their appearance and keyboard behavior. The 1.3× WebKit/Chromium ratio target remains unmet; absolute application times improve in both engines.
Why This Change Was Made
Slash-menu openings wrapped every always-present icon in optional-content machinery. Remove those wrappers while retaining option IDs, icon classes/masks, grouping, filtering and keyboard handlers. A full 253-option opening now creates 253 fewer spans. The shared optional-content helper remains for its other callers.
This is the retained win from the WebKit chat-action investigation. No transcript-row, focus, dependency, or lazy-boundary changes are included.
Evidence
Performance proof
Built production assets, synthetic Gateway, headless Chromium/WebKit, desktop/mobile, localhost, 1× CPU. The committed engines harness measures first recorded native input through the last DOM/native-value commit; compound actions include delivery and intervening driver gaps. It is not CPU or paint time. Acceptance: interleaved base/head pairs plus A/A, median regression ≤5% with no worse p95 or further pairs; under host noise, use 20-pair CPU/work evidence. WebKit Timeline/source maps were collected separately from untraced timing.
The pre-integration retained-renderer cohort below has 120/120 passing observations, ten base/head/base-control triplets per engine/view. Values are median / p95 in ms.
An additional ten slash triplets used identical slash code plus a subsequently rejected terminal-focus experiment. Across both cohorts, Chromium script CPU medians fall 122.90→112.83 ms desktop and 135.48→123.78 ms mobile (about 8%); script p95 also improves. WebKit application medians fall 669→635 and 791.5→758 ms. Every head opens 253 options with zero icon wrappers versus 253 on both baseline slots; all perform the same 68 native inputs.
The second mobile cohort was noisy: 1-minute host load reached 22.28, and unchanged A/A WebKit p95 reached 1,723 ms. Do not treat its wall-time tail as a product verdict. The 20-pair Chromium task CPU median is 435.95→414.86 ms desktop and 444.57→441.78 ms mobile; mobile task p95 moves 488.13→508.09 ms (+4.1%, A/A 513.88). Layout is a disclosed subphase limitation: mobile layout CPU median/p95 moves 49.57/54.07→50.67/58.22 ms, while total script CPU, frame-gap medians and the clean retained-bundle application cohort improve.
Reproduce with
scripts/bench-control-ui-engines.ts --bundle-dir <base> --compare-bundle-dir <head> --control-bundle-dir <base> --pairs 10 --viewport both --steps chat-actions-slashusingnode --import ./scripts/tsx.mjsandNODE_DISABLE_COMPILE_CACHE=1.Census and remaining gaps
Initial confirmation: 960/960 passed, 20 pairs plus an identical-build A/A slot for each action/view. Baseline
d43ab9c516e6dd1effeee8cb50ea479be550232e.Discard was profiled first. Desktop input→click is 26.48–27.03 ms in WebKit versus 2.17–2.23 ms in Chromium. Click→last commit is 22.97–23.52 versus 31.63–34.37 ms. Mobile input→click is 18.09–18.37 versus 3.56–3.86 ms; post-click spans are comparable. Its durable failed-send deletion emits one queue update. Preserve native activation semantics and the existing transcript geometry owners.
Slash baseline style/layout union is ~340 ms desktop and ~490 ms mobile, predominantly native rendering. The retained-bundle W/C ratios remain about 1.38× / 1.64×: the 1.3× target is not met. Group-aware virtualization is a further avenue; this PR does not claim the residual is irreducible.
contain: layout styleon the popup passed 240/240 observations but brought no useful gain and was removed.Terminal desktop has ~294–300 ms style/layout, including active-tab geometry, Ghostty focus and driver visibility checks. A focus guard was tested in 120 terminal observations and separately traced, then removed: focus had actually moved in the real desktop flow, so the guard still invoked the same ~34 ms native focus flush. It removed no work there. Preserve the required active-tab/close-button reveal and legitimate terminal focus.
Validation and size
ci:fullrun 41318501711: 45 jobs passed, 24 skippedAfter integrating main at
99c1b1a76a9c9edbddc31f2aafc4ad2c2205ecb4, a fresh same-host base/head strict comparison passes. Startup JS 90,551→90,547 B gzip (3 requests); startup CSS stays 34,946 B / 1 request. Chat boot grows 1,276,902→1,277,076 B (+174); New boot grows 783,484→783,503 B (+19); CSS and request counts are unchanged. Accept the small gzip change for the measured renderer CPU win; the chat cap is its current measured 1,277,076 B plus the existing 811 B headroom (1,277,887 B). Startup limits and baseline are unchanged.CI repair
The initial full CI run
41315426335passed 43 jobs and failed onlyChat responsive app behavior > remeasures a populated composer when the viewport width changesin UI E2E 4/7. Its checkout merged this PR into newer main. That main introduced a three-line mobile editing cap (c5827f7b61f), while the old test draft already occupied three lines at desktop width. Narrowing could not grow beyond the cap. Production replay confirms the original baseline and wrapper-only candidate both resize 75→117→75 px; updated main and candidate both stay 75→75→75 with that overlong fixture.Integrate main and shorten the fixture below the cap, preserving all height-change and ResizeObserver assertions. The exact previously failing test passes headlessly against the updated production bundle (1 passed, 4 unrelated cases excluded). Its normal preflight, shared browser, fixture and cleanup remain in use through the provided prebuilt-assets contract; Node is used for the Playwright config. Full CI run
41317147005passed the repaired resize case but found a sidebar deletion write-count failure (3 versus at most 1). The old setup acceptedsaved=truewhile cached rows were still displayed, allowing initial cached-to-live handoff writes into the deletion measurement. Wait for both live and saved before resetting counters, following existing sibling E2E readiness checks. All deletion, write-count, churn and reload assertions remain. The full two-case file passes against the exact newer-main production bundle (normal writes[1, 0]; subagent writes[1, 1]). The CI failure did not reproduce in isolated runs on either baseline, so this is a source-backed readiness repair, not a claim of deterministic red/green reproduction. Final full CI run 41318501711 passed onf7da89a635d: 45 jobs succeeded, 24 skipped. Both previously failing E2E areas passed. The old auto request was retired before replacing its head.Production component LOC 95→90 (−5); benchmark helper 406→416 (+10) for the work counter. The checker changes one documented cap; the responsive test fixture is 573→572 lines while retaining every assertion. The sidebar readiness change adds 3 lines. Whole five-file LOC is 2,118→2,125 (+7). Solid refactor census remains zero for effects, untrack, manual listeners/queries, flush, owner APIs, cleanup and render effects in the touched component. No new owner, cache or abstraction.
Visual proof
Synthetic-only WebKit captures, identical open/filtered menu bounds before/after on desktop/mobile. The visual-only harness warms the menu and is excluded from timing evidence.