Skip to content

Keep sidebar content search off the main thread and out of the transcript hydration cache #1122

Closed

Description

@currentbits

Priority: P1. Performance defect verified at 6c7a6fb on 2026-09-08.

Evidence

After 250 ms of typing a query of at least two characters, Sidebar calls threads.search. Store.searchThreads synchronously loops over every thread, including archived ones. For each title/notes miss it calls getMessages, which reads/parses its shard and retains the entire transcript in _messagesHydrated. A search that finds nothing therefore defeats lazy transcript loading for the entire history. Clearing search does not release those arrays. Limiting output to 50 results happens only after the full scan.

A disposable on-disk fixture with 100 archived threads and approximately 100 MB of transcript data, using the real Store implementation and a warm OS file cache, measured:

  • 0 hydrated transcripts before search, 100 afterward.
  • 75 ms synchronous search duration.
  • 100 MiB additional retained JS heap after forced GC.

This is a synthetic scaling measurement, not a live-store size claim or end-to-end desktop profile. Both cold reads and larger histories can cost more. Moving only disk writes async (#225) or initial hydration lazy (#639) does not address this call path.

Smallest useful fix

Search persisted shards through a bounded background path that does not populate the main process's transcript cache. Include current unsaved messages in the result so active turns remain searchable. Preserve title/notes matching, archived results, case-insensitive substring semantics, descending updatedAt order and the 50-result cap. Coalesce or cancel superseded searches; renderer generation guards alone do not prevent obsolete backend scans. Avoid a new search service unless a measured workload requires it.

Acceptance

Repeat the fixture and show that search does not hydrate all archived transcripts in the main Store or retain history-sized heap after completion. Keep the main loop responsive (target no task over 50 ms) while searching. Cover rapid query replacement, no-match, archived matches, current unsaved content, deleted threads and restart persistence. Report search response time, main-loop p95/p99 and retained heap separately. A corrupt shard must not be rewritten by a read-only search.

Runnable evidence in the audit checkout: node --expose-gc docs/issue-drafts/2026-09-08-search-performance-evidence.cjs (exit 0). It builds disposable shards, asserts hydration growth, and deletes the fixture.

Sources: sidebar debounce, full scan, retained hydration, IPC handler.

Separate from #486 find-in-current-transcript UI and #939 saved sidebar filters. Preserve the already-shipped per-thread storage and lazy boot.

Activity

  1. added
    plan:todo
    plan:doing
    plan:done
    and removed
    plan:todo
    plan:doing
    on Sep 8, 2026
  2. currentbits commented on Sep 8, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "Keep sidebar content search off the main thread and out of t". Closed on merge.

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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions