[GH-ISSUE #1585] [Issue]: character search is client-side only — full collection must download before the user can type #822

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

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

Originally assigned to: @Xelvanis on GitHub.

Summary

All character search and filtering (by name, tags, creator) is done client-side via Array.filter() after the full collection has been fetched. The Rust storage backend supports only exact-match filters, not substring search. This means the user cannot search until the entire payload has arrived and been parsed — at 180 characters with the avatar fix in place that is ~144 KB; at 1000+ characters it becomes a bottleneck again. Adding a search parameter to the backend list endpoint enables search-as-you-type with no full-dataset download.

Expected behavior

Typing in a character search box returns results immediately, without requiring the full collection to be in memory first. Works at any collection size.

Actual behavior

  • Opening a picker with 180+ characters: the full collection downloads, then useMemo filters it client-side
  • Searching is fast once data is cached, but the first load always blocks on the full fetch
  • At 1000+ characters the in-memory filter pass itself becomes noticeable

Steps to reproduce

  1. Have 500+ characters
  2. Open the character picker in ChatSetupWizard
  3. Type a search term immediately — results are blocked until the full list loads
  4. After the first load, search is fast (React Query cache)

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

Current backend capability

src-tauri/src/commands/storage/commands/entities.rs line 61:

// Only supports exact-match filters (AND-ed together)
(_, Some(filters)) if !filters.is_empty() => state.storage.list_where(&entity, filters)?,

No substring match, no full-text search.

Proposed backend change

Add a search field to the options object in storage_list. Implement as a case-insensitive substring match on data.name (SQLite LIKE '%term%'). Optionally extend to tags and creator. SQLite LIKE on an indexed column handles <10k records without FTS5.

// entities.rs — additive, optional param
if let Some(search) = options.get("search").and_then(Value::as_str) {
    rows.retain(|row| {
        row.get("data")
            .and_then(|d| d.get("name"))
            .and_then(Value::as_str)
            .map(|name| name.to_lowercase().contains(&search.to_lowercase()))
            .unwrap_or(false)
    });
}

Frontend change

Pass the debounced search term as a query param. React Query includes it in the query key so each distinct search has its own cache entry:

useQuery({
  queryKey: ["characters", "summaries", { q: searchTerm }],
  queryFn: () => storageApi.list("characters", {
    ...CHARACTER_SUMMARY_OPTIONS,
    search: searchTerm,
  }),
  enabled: searchTerm.length > 0,
})

Empty search (browse all) continues to use the existing cached full list — no change to that path.

Constraint: local Tauri install keeps working

The search param goes through the same storageApi / invoke abstraction. No HTTP-only assumptions. Callers that omit search get current behavior unchanged.

Dependency

This issue is independent of issues #1–#3 but is most useful after #1 (avatar payload) is fixed, since before that the per-query network cost dominates regardless of search.


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

Related issues: #1582 #1583 #1584

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/1585 Originally assigned to: @Xelvanis on GitHub. ## Summary All character search and filtering (by name, tags, creator) is done client-side via `Array.filter()` after the full collection has been fetched. The Rust storage backend supports only exact-match filters, not substring search. This means the user cannot search until the entire payload has arrived and been parsed — at 180 characters with the avatar fix in place that is ~144 KB; at 1000+ characters it becomes a bottleneck again. Adding a `search` parameter to the backend list endpoint enables search-as-you-type with no full-dataset download. ## Expected behavior Typing in a character search box returns results immediately, without requiring the full collection to be in memory first. Works at any collection size. ## Actual behavior - Opening a picker with 180+ characters: the full collection downloads, then `useMemo` filters it client-side - Searching is fast once data is cached, but the first load always blocks on the full fetch - At 1000+ characters the in-memory filter pass itself becomes noticeable ## Steps to reproduce 1. Have 500+ characters 2. Open the character picker in ChatSetupWizard 3. Type a search term immediately — results are blocked until the full list loads 4. After the first load, search is fast (React Query cache) ## 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 ### Current backend capability `src-tauri/src/commands/storage/commands/entities.rs` line 61: ```rust // Only supports exact-match filters (AND-ed together) (_, Some(filters)) if !filters.is_empty() => state.storage.list_where(&entity, filters)?, ``` No substring match, no full-text search. ### Proposed backend change Add a `search` field to the options object in `storage_list`. Implement as a case-insensitive substring match on `data.name` (SQLite `LIKE '%term%'`). Optionally extend to tags and creator. SQLite LIKE on an indexed column handles <10k records without FTS5. ```rust // entities.rs — additive, optional param if let Some(search) = options.get("search").and_then(Value::as_str) { rows.retain(|row| { row.get("data") .and_then(|d| d.get("name")) .and_then(Value::as_str) .map(|name| name.to_lowercase().contains(&search.to_lowercase())) .unwrap_or(false) }); } ``` ### Frontend change Pass the debounced search term as a query param. React Query includes it in the query key so each distinct search has its own cache entry: ```ts useQuery({ queryKey: ["characters", "summaries", { q: searchTerm }], queryFn: () => storageApi.list("characters", { ...CHARACTER_SUMMARY_OPTIONS, search: searchTerm, }), enabled: searchTerm.length > 0, }) ``` Empty search (browse all) continues to use the existing cached full list — no change to that path. ### Constraint: local Tauri install keeps working The `search` param goes through the same `storageApi` / `invoke` abstraction. No HTTP-only assumptions. Callers that omit `search` get current behavior unchanged. ### Dependency This issue is independent of issues #1–#3 but is most useful after #1 (avatar payload) is fixed, since before that the per-query network cost dominates regardless of search. --- > This is part of a series of related performance issues (#4 of 4). > > **Related issues:** #1582 #1583 #1584 ## Template check - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@cha1latte commented on GitHub (May 29, 2026):

Triage note: labeling this as scope-risk because moving character search server-side changes the list endpoint contract, search semantics, and client filtering expectations.

A good next step is to define searchable fields plus pagination and empty-state behavior before implementing the API slice.

<!-- gh-comment-id:4578274013 --> @cha1latte commented on GitHub (May 29, 2026): Triage note: labeling this as `scope-risk` because moving character search server-side changes the list endpoint contract, search semantics, and client filtering expectations. A good next step is to define searchable fields plus pagination and empty-state behavior before implementing the API slice.
Author
Owner

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

Fixed with #1598

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