Skip to content

perf(web): Command Palette thread search misses all WeakMap caches on every keystroke #42338

Done

Description

@AymanKhan9

In apps/web/src/components/CommandPalette.logic.ts, buildThreadActionItems constructs a new wrapper object ({ ...thread, latestUserMessageAt: thread.latestUserMessageAt ?? null, opens: thread.opens ?? null }) before calling threadSearchSubject(...).

Because threadSearchSubject (packages/client-runtime/src/state/threadSearch.ts) memoizes each thread's ThreadSearchSubject in a WeakMap keyed by thread object identity — and packages/shared/src/paletteSearch.ts caches WeightedSearchField[] and folded/tokenized SearchField instances per ThreadSearchSubject — passing a newly spread object causes all three cache layers to miss on 100% of threads on every keystroke in CommandPaletteThreadItems.tsx.

Making latestUserMessageAt, latestUserAuthoredMessageAt, and opens optional on ThreadSearchShell (their consumers already handle undefined) and passing thread directly restores the WeakMap cache hits on every keystroke.

Activity

  1. juliusmarminge commented on Nov 25, 2026

    @juliusmarminge
    Member

    Fixed by #42988, now on main: With unchanged threads, typing successive characters in the command palette now reuses the same thread items and search subjects, so the weighted-field and tokenization caches survive keystrokes instead of missing for every thread.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions