[GH-ISSUE #1583] [Issue]: character library and panel render all cards as DOM nodes simultaneously — no virtualization #821

Closed
opened 2026-10-21 05:21:30 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Gunterlie on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1583

Originally assigned to: @Xelvanis on GitHub.

Summary

CharacterLibraryView and CharactersPanel map every character directly to DOM nodes with no windowing. At 200 characters there are 200 full card elements in the DOM at once. Additionally, both components call useCharacters() (full records) instead of useCharacterSummaries(), fetching fields like description, personality, and scenario that are never displayed in a list card. Neither issue requires backend changes.

Expected behavior

The library grid and sidebar panel scroll smoothly at any collection size. Only visible cards exist in the DOM.

Actual behavior

  • Scrolling through a large character library is sluggish — layout and paint time grows linearly with collection size
  • Initial render blocks the main thread while 200+ card components mount simultaneously
  • useCharacters() fetches description, personality, scenario, first_mes, and alternate_greetings (~10 KB per character) that are unused in list context

Steps to reproduce

  1. Have 150+ characters
  2. Navigate to the Character Library tab
  3. Open DevTools → Performance → record
  4. Scroll through the list
  5. Observe long tasks in the scripting lane on mount and during scroll

Environment

  • Marinara Engine version: Refactor
  • Install type: MacOS App from Source <---> HTTP Docker Backend on Ubuntu
  • OS + version: macOS (Tauri) + Linux server (Docker/web)

Additional context

Affected files

File Line Issue
src/features/catalog/characters/components/CharacterLibraryView.tsx 201 useCharacters() — full records
src/features/catalog/characters/components/CharacterLibraryView.tsx 400 sortedCharacters.map(...) — no windowing
src/features/catalog/characters/components/CharactersPanel.tsx 115 useCharacters() — full records

@tanstack/react-virtual is not currently installed. No virtualization library is present in package.json.

Fix

Part A — Switch to summaries

// CharacterLibraryView.tsx line 201 — before
const { data: characters } = useCharacters();

// after
const { data: characters } = useCharacterSummaries();

Same change in CharactersPanel.tsx line 115. Full record data is only needed in the detail/editor view, not the list.

Part B — Virtualize the grid and list

Install @tanstack/react-virtual and wrap the sortedCharacters.map(...) in CharacterLibraryView and the list in CharactersPanel with a virtualizer. Only ~30 DOM nodes exist at any time regardless of collection size.

Note: after issue #1 (avatar payload fix) is merged, avatar images will be real URLs and loading="lazy" will apply — virtualization then means only visible cards ever request their avatar image.


This is part of a series of related performance issues (#2 of 4).

Related issues: #1582 #1584 #1585

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Gunterlie on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1583 Originally assigned to: @Xelvanis on GitHub. ## Summary `CharacterLibraryView` and `CharactersPanel` map every character directly to DOM nodes with no windowing. At 200 characters there are 200 full card elements in the DOM at once. Additionally, both components call `useCharacters()` (full records) instead of `useCharacterSummaries()`, fetching fields like `description`, `personality`, and `scenario` that are never displayed in a list card. Neither issue requires backend changes. ## Expected behavior The library grid and sidebar panel scroll smoothly at any collection size. Only visible cards exist in the DOM. ## Actual behavior - Scrolling through a large character library is sluggish — layout and paint time grows linearly with collection size - Initial render blocks the main thread while 200+ card components mount simultaneously - `useCharacters()` fetches `description`, `personality`, `scenario`, `first_mes`, and `alternate_greetings` (~10 KB per character) that are unused in list context ## Steps to reproduce 1. Have 150+ characters 2. Navigate to the Character Library tab 3. Open DevTools → Performance → record 4. Scroll through the list 5. Observe long tasks in the scripting lane on mount and during scroll ## Environment - Marinara Engine version: Refactor - Install type: MacOS App from Source <---> HTTP Docker Backend on Ubuntu - OS + version: macOS (Tauri) + Linux server (Docker/web) ## Additional context ### Affected files | File | Line | Issue | |---|---|---| | `src/features/catalog/characters/components/CharacterLibraryView.tsx` | 201 | `useCharacters()` — full records | | `src/features/catalog/characters/components/CharacterLibraryView.tsx` | 400 | `sortedCharacters.map(...)` — no windowing | | `src/features/catalog/characters/components/CharactersPanel.tsx` | 115 | `useCharacters()` — full records | `@tanstack/react-virtual` is not currently installed. No virtualization library is present in `package.json`. ### Fix **Part A — Switch to summaries** ```ts // CharacterLibraryView.tsx line 201 — before const { data: characters } = useCharacters(); // after const { data: characters } = useCharacterSummaries(); ``` Same change in `CharactersPanel.tsx` line 115. Full record data is only needed in the detail/editor view, not the list. **Part B — Virtualize the grid and list** Install `@tanstack/react-virtual` and wrap the `sortedCharacters.map(...)` in `CharacterLibraryView` and the list in `CharactersPanel` with a virtualizer. Only ~30 DOM nodes exist at any time regardless of collection size. Note: after issue #1 (avatar payload fix) is merged, avatar images will be real URLs and `loading="lazy"` will apply — virtualization then means only visible cards ever request their avatar image. --- > This is part of a series of related performance issues (#2 of 4). > > **Related issues:** #1582 #1584 #1585 ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:21:30 +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#821
No description provided.