Repository navigation
perf(web): virtualize the Web Apps sidebar list again - #41397
Conversation
langgenius#39739 introduced cursor pagination for installed apps and dropped the `useVirtualizer` rows that guarded this list, so every loaded page now stays in the DOM. The section lives in the main nav, so those rows persist across route changes and are repainted on every navigation. On a workspace with 427 installed apps this is very visible: a Safari timeline of clicking through the top-level menus spends 1067ms of 3.06s in compositing (35%) across 12,112 paint records and renders 23 frames, i.e. 7.5fps. Controlled A/B/A runs on that page (zero baseline drift) put the mask-image icons each row carries as the single largest paint factor at +42% fps when removed, which is what the extra rows multiply. Restore the row model and virtualizer from before langgenius#39739, keeping the existing threshold so short lists stay in plain flow layout. The infinite scroll sentinel is unchanged: the virtual container is sized to the full list, so the sentinel still sits below it and preloads as before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Follow-up to review feedback: drop `virtualizationThreshold` so the section has a single render path instead of branching between flow layout and virtual rows. This removes the branch that langgenius#39739 had to reason about, which is the branch that was lost in the first place. Note that the threshold protected the common case rather than the expensive one: cursor pagination loads 20 rows at a time, so a list only crossed the old threshold of 50 after the user scrolled the sidebar. The reason to drop it is the simpler single path, not the row count. Tests now cover always-on virtualization and pin the separator row's own measurement, which is the part of the row model that is easy to get wrong when the list is virtualized. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks for the analysis — pushed Separator row. Already handled in the first commit, in the form you suggested: Virtualization threshold. Dropped, so there is now a single render path. One correction to the reasoning though: loading 20 at a time means a list only crossed the old threshold of 50 after the user scrolled the sidebar, so the threshold was protecting the common case rather than the expensive one. The good reason to drop it is the simpler single path — one fewer branch to lose next time — which is what I've gone with.
While checking that, I found I'd been imprecise in the description and have corrected it in both the issue and this PR: the per-row
From Claude Code |
|
Thanks! |
Fixes #41396
Summary
web/app/components/main-nav/components/web-apps-section.tsxrendered the installed-app list throughuseVirtualizerwith avirtualizationThresholdof 50 rows. #39739 ("chore: paginate installed apps") moved the section to cursor pagination and dropped the virtualizer along the way, so every loaded page now stays in the DOM. The section lives in the main nav, so those rows survive route changes and are repainted on every navigation.On a workspace with 427 installed apps, a Safari Web Inspector timeline recorded while clicking through the top-level nav entries spends 1067.7ms of 3.06s in
composite(35%) across 12,112paintrecords, and renders 23 frames — about 7.5 fps. All script categories together account for only ~830ms, and navigation RSC payloads are 340 B – 3.2 KB, so the cost is in painting and compositing rather than in JavaScript or loading. Controlled A/B/A measurements on that deployment put CSSmask-imageicons as the largest single paint factor (+42% fps when masks are disabled, withbox-shadow,border-radius,filter,transitionandcontent-visibilityall within noise), and every row here carries one. The un-virtualized rows multiply exactly that cost. Full numbers are in the issue.This change restores the row model and virtualizer that existed before #39739, on top of the current infinite-query data source:
Divideris folded back into aWebAppListRowunion, so the separator is a virtual row with its ownestimateSizerather than something rendered inline between rows.InfiniteScrollSentinelis untouched. The virtual container is sized to the full list, so the sentinel still sits below it and preloads exactly as before.Which icon, precisely
Since it matters for any follow-up: the app icon on each row is an
<em-emoji>or an<img>rendered byAppIcon, not a mask icon. Themask-imageicon on every row is theItemOperationtrigger,i-ri-more-fill, which is mounted per row and kept atopacity-0until the row is hovered. Each un-virtualized row therefore paints a mask icon that is never visible. This PR cuts the row count; not painting a permanently invisible icon per row is a separate improvement and is not attempted here.On the suggestion of moving these icons from
mask-imagetobackground-image: the generated stylesheet already splits the two, 426 monochrome icons onmask-imageand 16 multi-color icons onbackground-image. Themask-imagepath is what lets monochrome icons inheritcurrentColor—i-ri-more-fillis coloured throughtext-*tokens here — so moving them tobackground-imagewould lose theming. The alternative that keeps theming is inline<svg fill="currentColor">, which runs againstweb/CLAUDE.md's instruction not to add generated React icons underapp/components/base/icons/src/. I also have not measuredbackground-imageto be cheaper to paint thanmask-image, so I would not want to assume that without a benchmark. Happy to open a separate issue for it.Screenshots
This change is visually identical — it only affects how many rows are mounted and painted. I have not attached a capture of the reporting workspace because the sidebar shows internal application names. The measurements above and in the issue stand in for a visual diff.
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint godsNotes on the checklist: this is a frontend-only change, so the backend commands do not apply. Two cases were added to
web/app/components/main-nav/__tests__/index.spec.tsx, one covering that the list is virtualized and one pinning the separator row's own measurement, and both were verified to fail without the component change. The file needsvi.mock('@tanstack/react-virtual')— matching the four existing specs that do the same — because the real virtualizer measures a zero-height scroll element under jsdom and renders no rows.app/components/main-navis green at 5 files / 100 tests. Four spec files unrelated to this change are already failing onmain(for examplefeatures/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx); I confirmed they fail identically with this change stashed.From Claude Code