Repository navigation
perf(ui): defer closed agent selector work - #189725
Conversation
Mount the menu through its existing lazy owner and resolve trigger and menu avatars only when their regions consume them. Keep menu rows and their image leases stable after the first open, without rebuilding the roster avatar map on selection changes.
|
🦞👀 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 changesDefer agent-menu rows and unselected avatars until first opening while retaining their identity afterward. Example: Visit Settings with 300 configured agents and Main selected.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses measurable unnecessary selector work still present on main; no definite introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherAgentSelect receives roster options, selection, and identities from Settings and scope controls, then delegates interaction to Menu and authenticated image resources to the existing avatar cache. flowchart LR
A[Roster and selection owners] --> B[AgentSelect]
B --> C[Trigger avatar]
B --> D[Lazy Menu]
D --> E[Retained option rows]
C --> F[Shared avatar cache]
E --> F
Technical reviewBest possible solution: Use the existing lazy Menu lifecycle with separate trigger and roster avatar leases sharing the current image cache. Do we have a high-confidence way to reproduce the issue? Current-main source eagerly derives roster avatars and mounts Menu content; the supplied 300-agent production-browser measurements support that unnecessary work, but this review executed no target code. Is this the best way to solve the issue? The patch uses the smallest supported boundary: defer through Menu, retain live option fields for its captured renderers, and reuse authenticated image ownership rather than adding route cleanup machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 193232cc1e89. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +12, Tests +43, Other +42. Total +97 across 7 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 31, 2026, 4:10 PM ET / 20:10 UTC. |
|
/refresh-security-review e8fe9b7 |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
|
Coordinator acceptance for #189725: the slower standalone first menu opening is accepted because navigation through first opening improves and every measured combined-flow p95 improves. Round 2 will investigate the remaining 56 ms (1×) and 327 ms (4×) route tasks and whether idle preparation can improve first opening without regressing navigation. |
* perf(ui): defer closed agent selector content Mount the menu through its existing lazy owner and resolve trigger and menu avatars only when their regions consume them. Keep menu rows and their image leases stable after the first open, without rebuilding the roster avatar map on selection changes. * perf(ui): avoid duplicate selector row projection * test(ui): measure agent selector visit through first open
What Problem This Solves
First visits to Settings construct 300 agent-menu rows and avatars while the selector is closed. Leaving New Session also disposes that unused tree in the same task as the destination mount. This adds shared work to every measured page.
User Impact
The selector now builds its options on first opening and retains them afterward, including across Settings navigation, roster updates, and selection changes. Route visits and the complete visit-through-first-open flow improve on all measured browser/viewport profiles. Standalone first opening is slower because it now pays for row construction; that intentional tradeoff is reported below.
Why This Change Was Made
Use the existing lazy Menu lifecycle. Separate lazy trigger/menu avatar projections have independent view leases and share the existing authenticated image cache. Keep the keyed option-row projection for live captured row properties, but replace the redundant menu-item projection with a lazy memo.
The selector already persists across Settings routes. Source-mapped 4× traces show selector/avatar/menu work disappearing from closed-route visits and sampled bridge disposal falling from roughly 30–37 to 9–13 ms. Mixed teardown/mount tasks are about 194 ms on Advanced and 129–133 ms on Plugin Settings. Advanced desktop's later 212 ms traced task is config-form construction. No new route-disposal scheduler is justified or introduced.
Validation
Acceptance uses the requested seven representative pages, Chromium 1× and 4×, WebKit, desktop/mobile, twenty interleaved base/head/base triplets per cell, and same-machine frozen production bundles. A/A controls and Chromium renderer CPU qualify noisy elapsed timing. WebKit reports elapsed time only. The committed combined scenario starts in New Session and measures navigation through hydrated opening in the same document; native click timing alone would omit baseline eager work.
Performance evidence
54/54 complete cells, 3,240/3,240 observations passed. Twenty serial base/head/base triplets per cell, production bundles, synthetic Gateway, localhost, headless. The per-page route table is included below; local artifacts retain full distributions, paired deltas, counts, and provenance.
Ranges below are the minimum and maximum per-page deltas across completed cells, not pooled observations. CPU is Chromium renderer main-thread threadTicks TaskDuration; WebKit has no CPU claim. Positive deltas mean slower/larger.
Standalone first-open includes deliberately deferred menu construction. The combined measurement includes the same-document route visit through the completed first open; these are separate workloads and are never added together. B/H/C is the passed sample count.
Production selector LOC: 209 → 221. Zero new effects or signals; one redundant projection removed. The retained keyed option-row projection preserves custom renderer identity. Full report retains all statuses, failure/error counts, head/control comparisons, host load, requests, CLS, and closed/open menu structure.
The requested lazy-first-open tradeoff is accepted because all six combined-flow cells improve median and p95, with Chromium whole-flow CPU also lower. It is not a claim that standalone opening improved: at 4×, its whole-run wall median rises about 20–21% and CPU about 19–22%; native WebKit input-to-commit rises from 70/72 to 91/98 ms desktop and 72/77 to 90/94 ms mobile (median/p95). Closed menus have zero option rows instead of 300. Every opening finishes with 300 rows, 300 avatars, and selected-row focus. The combined flow performs the same 299 identity reads in every base/head/control group, and opening adds zero. Chromium CLS remains zero.
One small combined-flow subphase tradeoff remains explicit: 4× desktop layout p95 is 118.793 → 127.143 ms (+7.0% versus base, +3.9% versus control), while its median is +0.7% versus base/−0.8% versus control and A/A p95 moves +3.0%. This is accepted alongside lower total CPU p95 (−6.9%) and longest-task p95 (368 → 314 ms); it is not described as every subphase improving.
The absolute long-task goal is not fully reached: the maximum observed route task is 56 ms at 1×, 327 ms at desktop 4×, and 256 ms at mobile 4×. These are residual targets, not regressions; every measured route improves CPU median/p95 or, for WebKit, elapsed median/p95. The shared teardown trace no longer identifies a worthwhile route-lifecycle change. Page-specific remaining work belongs to its rendering owner.
Ten additional serial base/head/base triplets requalified the two flagged 4× layout tails (60 more observations, all passed), using the same frozen bundles. No pooling with the original runs:
Channels' earlier tail increase does not repeat. About's initial +23.3% layout p95 does not repeat; the repeat is +3.5% versus base and +8.1% versus control (1.469/3.281 ms), with median +2.9%/+3.1% and A/A p95 −4.3%. That small layout-subphase cost is accepted with the ~42% whole-CPU reduction and faster route readiness; it is disclosed rather than described as no movement.
Production builds on the same Mac: startup JS 89,334 → 89,366 B gzip (+32 B); startup CSS 33,947 B, one request, unchanged. Strict base comparison passes. The base already exceeds the total-CSS cap; this PR changes no CSS. Chat/New boot changes remain within their existing caps.
Focused checks passed: 13 selector unit tests; 36 Settings-sidebar/Chromium opening tests; UI and scripts typechecks; changed-file lint/format; production Knip. Existing row assertions remain and now open the lazy menu first. Independent full-range Codex review and hosted reviews found no actionable findings. CI used
ci:fulland its Control UI performance check passed.CI attribution
PR run 41236263289, attempt 1, tested merge
5e13c947bbb07ec72496e7523d6fbe927763594awith parents mainc0b741764fee65c1faf1c53b152882dc425f81e9and PR heade8fe9b72f6c805a8bf6b6d79a2c946d5792c062d. Its failed CI result is preserved. All failed cases are inherited; landing uses the documented native inherited-failure route.session pull request chips > keeps every PR visible and actionable at 1440 in light;session pull request chips > offers a compact publication row while rate limited on desktopDetails Environment changes > shares read-only Uncommitted demand between Environment and Review and recovers retained countsaria-busyfalse/true assertion (line 209). These are distinct observations of the same obsolete shared-read expectation; summary/full request separation predates the base. Main already fixes and renames the stale test in #189730.Quiet automation real Gateway boundary > keeps checks quiet while preserving meaningful status, freshness, visible results and run evidenceNamed test/render/style inputs are unchanged between the CI main parent and tested merge. The isolated Details replay uses Node because its config exercises Playwright E2E; ordinary focused tests used the pinned default runtime. No full local suite or local Docker was run.
Size and ownership
AgentSelect 209 → 221 lines (+12); directly coupled tests 1,694 → 1,737 (+43); existing benchmark module 1,230 → 1,272 (+42). Seven files, +134/−37. No new signals, effects, listeners, DOM queries, flush calls, owner-capture calls, dependencies, CSS, or route cleanup scheduling. Memos 4 → 5; keyed projections 2 → 1; lifecycle setup callsite 1 → 1.
All seven route cells per browser and viewport
B/H/C = passed base/head/control samples. Δ columns are head/base. A/A is control/base. A noisy A/A flag never waives a regression; use the three comparisons and CPU/counts together.
Before and after (synthetic fixtures)
Desktop Plugin Settings before:

Desktop Plugin Settings after:

Mobile Advanced before:

Mobile Advanced after:

Agent selector open before:

Agent selector open after:
