Skip to content

Rank prompt library searches in one list - #5148

Merged
ymichael merged 1 commit into
mainfrom
bb/improve-prompt-library-search-thr_s8i4m4sabq
Oct 7, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/improve-prompt-library-search-thr_s8i4m4sabq

Conversation

@ymichael

@ymichael ymichael commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Prompt Library searches kept the browse layout: a Starred section ranked by fuzzy score, then a Recent section ranked by fuzzy score. A starred prompt therefore beat a better match, prompts that start with the query could be buried under weaker substring matches (Deploy later… and deploy the preview… were 6th and 7th of 8 for deploy), and starred prompts appeared twice (once per section). Separately, each search inserted a "Searching prompts…" row above the list, so the list jumped down and back on every keystroke.

What changed

  • plugins/prompt-library/ranking.ts: rankByQuery marks prefix matches (case-insensitive, whitespace-collapsed) and sorts prefix matches first, then fuzzy score, keeping input order (recency) for ties. compareRank is exported for merging.
  • plugins/prompt-library/server.ts: with a query, starred and history matches are merged into one list ranked by prefix, then score, then starred, then recency; history rows whose text is starred are dropped so each prompt appears once. Browsing (empty query) is unchanged: starred, then recent.
  • plugins/prompt-library/contract.ts: search output changed from { starred, recent } to { prompts }, each row with kind: "starred" | "recent". This also changes bb prompts search --json. Text output follows the same order.
  • plugins/prompt-library/app.tsx: while searching, section headers are hidden and rows are keyed by prompt text, so the selection follows a prompt when starring/unstarring moves it. The status row is gone: results stay in place during a search, the search icon becomes a spinner only for searches slower than 300 ms, and the first "Loading prompts…" message renders inside the empty list.
  • CLI help, the skill (SKILL.md) and PLUGIN_OVERVIEW.md describe the ranking and the new output shape.

How you verified

  • pnpm exec turbo run test typecheck lint --filter='...[origin/main]' (prompt library and bundled plugins), plus turbo run test --filter=@bb/web -- src/marketplace.
  • New tests:
    • server.test.ts: one test checks the full order (prefix + starred, prefix + newer, prefix + older, fuzzy + starred, fuzzy + newer, weak fuzzy match), including a capitalised prefix and removal of the duplicate starred row.
    • app.test.tsx: no section headers while searching, and the selection follows an unstarred prompt. This test fails without the text-keyed rows.
    • app.test.tsx: results stay in place with no status row while a search is pending, and the spinner appears only after 300 ms. This test fails against the old status row.
  • Manual QA on a pnpm start:worktree instance with seeded history:
    • Source CLI: bb prompts search checks ranking, project and thread scopes, multi-word queries, extra whitespace, no-match queries, the flag constraint, and star/unstar round trips. Unstarring moves a prompt from [codex] Bundle Claude Code SDK CLI support file #4 to [codex] Update sidebar manager row presentation #6 and re-starring moves it back.
    • Headless Chrome: the popup shows one list without headers. With Ctrl+S, the selection follows the moved row; Tab switches scope; Enter inserts the prompt.
    • A per-frame sampler ran over 166 frames of typing and deleting: the list's top never moved, and the old status text never appeared.

AGENT GENERATED

🤖 Generated with Claude Code

Once a query is typed, the picker shows a single list instead of Starred
and Recent sections. Prompts that start with the query come first, then
fuzzy score, with starred and then newer prompts breaking ties. A starred
prompt appears once, as its starred row. The search RPC and
`bb prompts search --json` now return `{ prompts }` with a `kind` per row.

Searching no longer inserts a status row above the list: results stay in
place, and the search icon becomes a spinner only for searches slower
than 300 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 32f63ea into main Oct 7, 2026
30 checks passed
@ymichael
ymichael deleted the bb/improve-prompt-library-search-thr_s8i4m4sabq branch October 7, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant