Skip to content

[FEATURE]: Search past messages across all sessions in the command palette (v2) #60995

Open

Description

@nguyenngothuong

Problem

On OpenCode v2 (Desktop 2.2.5) the ⌘K command palette finds sessions by title only, and so does the API behind it — session.list({ search }) pushes like(SessionTable.title, …) (packages/core/src/session/store.ts:155). Message content is never searched.

On this machine that is 1,440 sessions in a 12 GB opencode.db. When I remember "we decided X a month ago" I cannot find the session unless its title happens to contain the words. Ctrl+F only searches the session I already have open, which is the opposite problem.

What I measured (stopgap implementation, not a guess)

I scanned the DB once and built a small local digest: user messages capped at 4,000 chars, the first 1,500 chars of each assistant reply, no tool output or reasoning, plus one folded copy per session (lowercase, Vietnamese diacritics stripped so hoa don matches hóa đơn) for substring search. The palette then queries the digest instead of the DB.

direct scan of opencode.db digest
data read per query 12 GB 28 MB
first build — 7.5 s
query latency tens of seconds 30–100 ms (incl. process start)
incremental refresh — under 1 s (only rows whose time_updated changed)

With that, typing in ⌘K finds sessions by what was said, across every project, at typing latency, and a separate "Projects" group can list folders that were never opened as projects.

The stopgap requires patching packages/app and running a sidecar HTTP service, which users should not have to do. This is the part I would like to see upstream.

Proposal (happy to implement whichever you prefer)

  1. Palette source API for plugins. The palette already accepts extra async sources internally — createCommandPaletteSearch({ sources: ((query, signal) => Promise<CommandPaletteEntry[]>)[] }) in packages/app/src/shell/commands/search.ts, used by the session and file sources. Expose the same thing in the GUI plugin SDK (ctx.add(PaletteSource, …) or similar) so a plugin can contribute { id, type, title, description, sessionID, server } rows. Small surface, no new persistence in core.
  2. Built-in content search. Index message text into a small table (or FTS5) and let session.list({ search }) — or a dedicated endpoint — match content as well, newest first, returning a snippet. Diacritic folding matters for non-English users; hoa don → hóa đơn is a real case here.

Either way the index is derived data: local-only, safe to delete and rebuild, never telemetry.

Related

Activity

  1. opencodejr commented on Nov 1, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up, and for measuring a working stopgap, @nguyenngothuong!

    To restate the request: you'd like the v2 ⌘K palette to find sessions by what was said in them, not only by title. That could come from a plugin API for adding palette search sources, or from a built-in local content index (with diacritic folding) behind session.list({ search }) or a dedicated endpoint. You're right that search today only matches session titles. Maintainers will consider it.

    I didn't put together a plugin for this. The GUI plugin SDK can register palette commands and open a separate picker dialog, but it has no way to add results to the palette's own search. Without a server-side content index, a plugin would also have to page through every session's messages, which is far too slow at your scale. Something like ctx.add(PaletteSource, …), feeding the sources that createCommandPaletteSearch already accepts, would close that gap.

    Related issues:

  2. nguyenngothuong commented on Nov 1, 2026

    @nguyenngothuong
    Author

    Thanks for the pointers — #54863 covers the backend half, #57938 the TUI counterpart, and this one is the Desktop palette half.

    If it helps, I can open the Desktop-side PR independently of the storage decision: a palette source registry in the GUI plugin SDK (ctx.add(PaletteSource, …)) that feeds the sources array createCommandPaletteSearch already accepts in packages/app/src/shell/commands/search.ts.

    Scope I'd propose:

    • registry + types next to Command/Panel in packages/plugin/src/gui/registries.ts
    • wiring in both palettes (shell/commands/dialog.tsx, home/start/command-palette.tsx)
    • dedupe and ranking consistent with the existing session/file sources
    • one unit test, plus a docs note

    This stays orthogonal to #54863: a plugin can supply its own index today, and a built-in session.search can register the same source later. If you would rather see #54863 land first and do content search natively, I'm happy to pick that up instead — just say which half you want a PR for.

  3. nguyenngothuong commented on Nov 1, 2026

    @nguyenngothuong
    Author

    Opened the Desktop-side PR discussed above: #61000 — a PaletteSource registry in the GUI plugin SDK, wired into both palettes (⌘K home and the in-session palette).

    It stays orthogonal to #54863: a plugin can supply its own index today, and a built-in session.search can register the same source later. With no source registered the palettes behave exactly as now.

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