[GH-ISSUE #1584] [Issue]: sidebar and lorebook panels load full character collection when they only need a handful of records #819

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

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

Originally assigned to: @Xelvanis on GitHub.

Summary

ChatSidebar and LorebooksPanel call useCharacterSummaries() to load the entire character collection at startup, when in practice each only needs data for a small fixed set of characters. ChatSidebar only displays avatars/names for characters in active recent chats (3–10 records). LorebooksPanel only needs an ID→name map for characters already linked to a lorebook. The fix requires no backend changes.

Expected behavior

Sidebar and lorebook panels load their character data instantly without pulling the full collection.

Actual behavior

  • On app startup, ChatSidebar triggers a full useCharacterSummaries() fetch — after issue #1 is fixed this is 144 KB; today it is 315 MB
  • LorebooksPanel does the same to build a name lookup map for a handful of linked characters
  • These fetches share the React Query cache with pickers, but they cause the cache to be populated immediately on startup rather than on first use

Steps to reproduce

  1. Open the app
  2. DevTools → Network → observe storage_list for characters firing on startup, before any character picker is opened
  3. Check the caller — it originates from ChatSidebar mounting in the shell

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 components

Component File Line Fetches Needs
ChatSidebar src/app/shell/ChatSidebar.tsx 135 All characters Names/avatars for ~3–10 active chat characters
LorebooksPanel src/features/catalog/lorebooks/components/LorebooksPanel.tsx 92 All characters ID→name map for linked characters only
LorebookEditor src/features/catalog/lorebooks/components/LorebookEditor.tsx 311 All characters ID→name map for linked characters only

Fix

ChatSidebar — replace full fetch with byIds:

// before
const { data: allCharacters } = useCharacterSummaries();

// after — only fetch the characters that appear in recent chats
const { data: allCharacters } = useCharacterSummariesByIds(recentChatCharacterIds);

LorebooksPanel / LorebookEditor — same pattern, using the character IDs already present in the lorebook's linked character list.

This means useCharacterSummaries() is no longer called on startup — the full collection is only fetched when a user explicitly opens a picker or the character library.


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

Related issues: #1582 #1583 #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/1584 Originally assigned to: @Xelvanis on GitHub. ## Summary `ChatSidebar` and `LorebooksPanel` call `useCharacterSummaries()` to load the entire character collection at startup, when in practice each only needs data for a small fixed set of characters. `ChatSidebar` only displays avatars/names for characters in active recent chats (3–10 records). `LorebooksPanel` only needs an ID→name map for characters already linked to a lorebook. The fix requires no backend changes. ## Expected behavior Sidebar and lorebook panels load their character data instantly without pulling the full collection. ## Actual behavior - On app startup, `ChatSidebar` triggers a full `useCharacterSummaries()` fetch — after issue #1 is fixed this is 144 KB; today it is 315 MB - `LorebooksPanel` does the same to build a name lookup map for a handful of linked characters - These fetches share the React Query cache with pickers, but they cause the cache to be populated immediately on startup rather than on first use ## Steps to reproduce 1. Open the app 2. DevTools → Network → observe `storage_list` for `characters` firing on startup, before any character picker is opened 3. Check the caller — it originates from `ChatSidebar` mounting in the shell ## 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 components | Component | File | Line | Fetches | Needs | |---|---|---|---|---| | `ChatSidebar` | `src/app/shell/ChatSidebar.tsx` | 135 | All characters | Names/avatars for ~3–10 active chat characters | | `LorebooksPanel` | `src/features/catalog/lorebooks/components/LorebooksPanel.tsx` | 92 | All characters | ID→name map for linked characters only | | `LorebookEditor` | `src/features/catalog/lorebooks/components/LorebookEditor.tsx` | 311 | All characters | ID→name map for linked characters only | ### Fix **ChatSidebar** — replace full fetch with `byIds`: ```ts // before const { data: allCharacters } = useCharacterSummaries(); // after — only fetch the characters that appear in recent chats const { data: allCharacters } = useCharacterSummariesByIds(recentChatCharacterIds); ``` **LorebooksPanel / LorebookEditor** — same pattern, using the character IDs already present in the lorebook's linked character list. This means `useCharacterSummaries()` is no longer called on startup — the full collection is only fetched when a user explicitly opens a picker or the character library. --- > This is part of a series of related performance issues (#3 of 4). > > **Related issues:** #1582 #1583 #1585 ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:21:30 +07:00
Author
Owner

@Promansis commented on GitHub (May 30, 2026):

Fixed with @Xelvanis pr #1598 and #1590

<!-- gh-comment-id:4581754576 --> @Promansis commented on GitHub (May 30, 2026): Fixed with @Xelvanis pr #1598 and #1590
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#819
No description provided.