[PR #8920] [MERGED] perf(client): virtualize the Characters panel card list #8882

Closed
opened 2026-11-07 17:40:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8920
Author: @Gunterlie
Created: 11/6/2026
Status: ✅ Merged
Merged: 11/6/2026
Merged by: @Gunterlie

Base: staging ← Head: perf/feel-5-virtual-card-lists


📝 Commits (2)

  • a83ac5d perf(client): virtualize the Characters panel root card list
  • 6038727 fix(client): keep measured card heights when the Characters panel remounts

📊 Changes

3 files changed (+103 additions, -5 deletions)

View changed files

📝 packages/client/package.json (+1 -0)
📝 packages/client/src/components/panels/CharactersPanel.tsx (+82 -5)
📝 pnpm-lock.yaml (+20 -0)

📄 Description

Part of #8904 (slice 5, step 1).

Why

The Characters panel puts every loaded root card into the DOM. After a few pages of scrolling in a large library (2,700 cards), the panel holds hundreds of rows and opening and scrolling it stutters, worst on weak devices. Discord report: 100-card pages, "Load more", and slow large libraries.

What changed

  • Characters panel: the root card list is virtualized with @tanstack/react-virtual. Only the rows near the viewport (+ overscan) are mounted; rows are measured, so tags and metadata of any height work.
  • The list keeps the panel's own scroll container; its offset below the folders is the virtualizer's scrollMargin, remeasured when folders open, close or change height.
  • The next page loads when the last rendered row is within 2 rows of the end. "Load more" stays only as the manual and error fallback (its own auto-load sentinel is off for this list).
  • A dragged card stays mounted (rangeExtractor) so its drag end and touch handlers still run after it scrolls away.
  • Card rows no longer use transition-all (it would animate transform, so moved rows would slide).

Pages stay for now: a full card is 5–20 KB, so one request for 2,700 cards would be 20–50 MB. Step 2 (slim list request, full text on demand) removes the pages. Folders, Lorebooks, Personas and the library view are unchanged.

Measured (dev box, 2,710 seeded cards, 1440×900, headless Chromium)

  • Mounted card rows: 12 at the top, 22 after scrolling (2,710 cards).
  • Auto-load on scroll: 500 → 1,100 of 2,710 without a click; no row overlap; folder expand moves the list down.
  • 3-second wheel scroll, median long tasks: 1×: 5 / 368 ms, 4× CPU: 16 / 2,282 ms. Idle panel: 1×: 113 ms, 4×: 508 ms.
  • The remaining scroll cost is mostly native style/layout/paint plus the 2 Hz accent tick (resolveCssColor probe in App.tsx), which is slice 7 work. A staging baseline with the same script could not be completed (the dev box ran out of disk during the rebuilds), so there is no before/after number for scroll yet.

Validation

  • tsc --noEmit -p packages/client, eslint and prettier on the changed files: pass.
  • Local CodeRabbit CLI auth is broken on this host; review is done by a separate reviewer agent instead.

Manual verification

  • Manually verify scrolling the Characters panel with a large library is smooth and loads more cards near the end.
  • Manually verify drag-and-drop of a card into a folder, including a drag where the card scrolls out of view.
  • Manually verify multi-select and bulk actions still select the right cards.
  • Manually verify the panel scroll position is restored after opening a character and coming back.
  • Manually verify on a phone (touch drag, scroll).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8920 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 11/6/2026 **Status:** ✅ Merged **Merged:** 11/6/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `perf/feel-5-virtual-card-lists` --- ### 📝 Commits (2) - [`a83ac5d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a83ac5dc559ce8e104e04668fa738cd3a83091b9) perf(client): virtualize the Characters panel root card list - [`6038727`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6038727db642c74070fec81f9f60080fe4158611) fix(client): keep measured card heights when the Characters panel remounts ### 📊 Changes **3 files changed** (+103 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/package.json` (+1 -0) 📝 `packages/client/src/components/panels/CharactersPanel.tsx` (+82 -5) 📝 `pnpm-lock.yaml` (+20 -0) </details> ### 📄 Description Part of #8904 (slice 5, step 1). ## Why The Characters panel puts every loaded root card into the DOM. After a few pages of scrolling in a large library (2,700 cards), the panel holds hundreds of rows and opening and scrolling it stutters, worst on weak devices. Discord report: 100-card pages, "Load more", and slow large libraries. ## What changed - Characters panel: the root card list is virtualized with `@tanstack/react-virtual`. Only the rows near the viewport (+ overscan) are mounted; rows are measured, so tags and metadata of any height work. - The list keeps the panel's own scroll container; its offset below the folders is the virtualizer's `scrollMargin`, remeasured when folders open, close or change height. - The next page loads when the last rendered row is within 2 rows of the end. "Load more" stays only as the manual and error fallback (its own auto-load sentinel is off for this list). - A dragged card stays mounted (`rangeExtractor`) so its drag end and touch handlers still run after it scrolls away. - Card rows no longer use `transition-all` (it would animate `transform`, so moved rows would slide). Pages stay for now: a full card is 5–20 KB, so one request for 2,700 cards would be 20–50 MB. Step 2 (slim list request, full text on demand) removes the pages. Folders, Lorebooks, Personas and the library view are unchanged. ## Measured (dev box, 2,710 seeded cards, 1440×900, headless Chromium) - Mounted card rows: 12 at the top, 22 after scrolling (2,710 cards). - Auto-load on scroll: 500 → 1,100 of 2,710 without a click; no row overlap; folder expand moves the list down. - 3-second wheel scroll, median long tasks: 1×: 5 / 368 ms, 4× CPU: 16 / 2,282 ms. Idle panel: 1×: 113 ms, 4×: 508 ms. - The remaining scroll cost is mostly native style/layout/paint plus the 2 Hz accent tick (`resolveCssColor` probe in `App.tsx`), which is slice 7 work. A staging baseline with the same script could not be completed (the dev box ran out of disk during the rebuilds), so there is no before/after number for scroll yet. ## Validation - `tsc --noEmit -p packages/client`, eslint and prettier on the changed files: pass. - Local CodeRabbit CLI auth is broken on this host; review is done by a separate reviewer agent instead. ## Manual verification - [ ] Manually verify scrolling the Characters panel with a large library is smooth and loads more cards near the end. - [ ] Manually verify drag-and-drop of a card into a folder, including a drag where the card scrolls out of view. - [ ] Manually verify multi-select and bulk actions still select the right cards. - [ ] Manually verify the panel scroll position is restored after opening a character and coming back. - [ ] Manually verify on a phone (touch drag, scroll). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:40:27 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8882
No description provided.