Skip to content

Perf: sidebar search lowercases every message of every thread per keystroke #144

Closed

Description

@currentbits

Problem

electron/store.js:1021-1057 (searchThreads) does String(m.text).toLowerCase().includes(needle) across all threads' full message lists, with no index and no early cap on scan cost. The renderer fires it after a 250ms debounce (src/components/Sidebar.tsx:52,1203-1205).

Impact

Each keystroke burst allocates a lowercased copy of the entire store's message text on the main thread. With capped-but-large transcripts (1,000 messages x N threads) that is MBs of allocation and a full scan per query: a GC and latency spike while the user is typing.

Fix direction

Cache lowercased text per message (invalidate on append), or build a lightweight inverted index; also consider a max-results early exit.

Activity

  1. currentbits commented on Aug 21, 2026

    @currentbits
    OwnerAuthor

    Stale as of the sidebar redesign: search now matches only thread.title (src/components/Sidebar.tsx:1758, thread.title.toLowerCase().includes(queryLower)) — the per-keystroke scan over every message of every thread no longer exists. Verified by grep in perf research round 31b (2026-08-21): no message-body search remains in the renderer. Transcript search is now the separate feature request #486.

  2. added and removed
    enhancementNew feature or request
    on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions