Skip to content

Rank thread search by title match, then recency - #5003

Merged
brsbl merged 3 commits into
mainfrom
bb/thread-search-speed-thr_tm8utsbqpb
Oct 6, 2026
Merged

brsbl merged 3 commits into
mainfrom
bb/thread-search-speed-thr_tm8utsbqpb

Conversation

@brsbl

@brsbl brsbl commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Thread search ranked threads by the best bm25 score of any segment, so chatty threads outranked exact titles. On a real workspace, "moss plugins" returned three message-only threads before the thread titled "Moss plugins". This order reaches bb thread search, the SDK, and ⌘K's archived results.

What changed

  • Threads whose displayed title contains every query word rank first.
  • Remaining matches are ordered by most recent activity.
  • A fallback title from the first prompt counts only for threads without a title.
  • Matching still requires every word somewhere in the thread.
  • Each thread's excerpt is its earliest matching message, preferring ones with every word.
  • The all-words search runs once per query and serves both title matching and excerpt choice.
  • The API, response shape, limits and highlighting are unchanged.

How you verified

  • Remote CI passed on 02c4742. Run
  • Real-data evals on be02de8: the new query passed 13 of 13 cases; the old one passed none.
  • Both queries found the same number of matching threads in every case.
  • Speed stayed about the same, within ±15% in both directions.
  • New unit tests cover title-first order, recency, the fallback-title rule, partial titles, and excerpt choice.
  • Slop Cop (security, architecture, code quality, performance) on be02de8: no blockers. A synthetic benchmark measured it 30–50% faster than the old query; sharing the all-words search saved up to another 15–20% with identical rows.
Eval details: 4,714 threads, 229,718 segments, median of 7 alternating runs

The expected results were written before any run. Old is base e710dbd88f. Both used the server's SQLite settings and the app's limit of 20 per group.

Query Old: first result Old New: first result New Old ms New ms
"moss plugins" 💰 Google Ads spike fail Moss plugins pass 70 66
"quick switcher" Quick switcher in palette fail Quick switcher in palette pass 7 14
"coordinator mode" Moss plugins fail Coordinator Mode pass 35 38
"google ads" 📆 Content strategy and calendar fail 💰 Google Ads spike pass 9 10
"plugins blog" ⏳ Plugins blog post fail ⏳ Plugins blog post pass 31 40
"info panel" Rename child threads to subthreads fail Redesign info panel pass 29 36
"thread title" Quick switcher in palette fail Thread title fixes pass 96 88
"moss" Moss plugins fail Moss plugins pass 48 50
"iphone promotional" (archived) iPhone promotional screenshot fail iPhone promotional screenshot pass 3 4
"regression test" Quick switcher in palette fail Dismiss git shelf in session above pass 100 87
"mo" 📆 Content strategy and calendar fail Moss plugins pass 95 104
"in" Pinned Files: marketplace listing fail Dismiss git shelf in session above pass 177 165
"the" 🌱 Multi-persona website fail Test Video Markup with the iPhone pass 268 222

BB-Thread: ⌘K improvements

🤖 Generated with Claude Code

AGENT GENERATED

Searching "moss plugins" ranked three message-only threads above the
thread titled "Moss plugins", because threads were ordered by the best
bm25 score of any segment. Threads whose title contains every query word
now come first, then the rest by most recent activity. Without bm25 the
query no longer scores every matching segment twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

A titled thread's fallback text (taken from its first prompt) could match
the query and rank it as a title match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@brsbl brsbl changed the title Rank thread search title matches first and drop bm25 scoring Rank thread search by title match, then recency Oct 6, 2026
@brsbl
brsbl merged commit b29683b into main Oct 6, 2026
41 checks passed
@brsbl
brsbl deleted the bb/thread-search-speed-thr_tm8utsbqpb branch October 6, 2026 12:04
brsbl added a commit that referenced this pull request Oct 6, 2026
## Human comments

## What was wrong

Server thread search kept `_` inside a query word, so `foo_bar` became
the full-text phrase "foo" then "bar". ⌘K's title check, and the search
index itself, treat `_` as a word break. As a result, ⌘K could move a
thread into its title-match section when the server had ranked it as a
message-only match, and a title with both words apart, like "Search the
thread list" for `thread_search`, wasn't found at all.

## What changed

- Thread search now splits queries on `_` the same way it splits on
spaces and hyphens.
- `thread_search` finds threads containing both "thread" and "search",
ranking titles with both words first.
- Highlights cover each word separately.
- Underscored queries no longer require the words to be next to each
other, matching how hyphenated queries already behave.

## How you verified

- Remote CI: passed on 44e1c7a, including the new db test. Two
unrelated Windows server timeouts passed on rerun.
[Run](https://github.com/get-bb/bb/actions/runs/37511624334)
- New db test: `thread_search` ranks "Search the thread list" first and
highlights both words. Today's code doesn't find that title at all.
- New ⌘K unit case: `thread_search` treats "Search the thread list" as a
title match, the same as the server.

Follows #5003 and #4962.

BB-Thread: [⌘K
improvements](https://brsbl.getbb.app/projects/proj_khiw2za95v/threads/thr_tm8utsbqpb)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Opus 5.5 <[email protected]>
brsbl added a commit that referenced this pull request Oct 6, 2026
## Human comments

## What was wrong

The search ranking evals behind #5003 ran only once, by hand, against a
copy of a real workspace. Nothing kept checking them, so a later change
could quietly bring back the old ordering.

## What changed

- A new db test runs those evals against a built-in synthetic workspace.
- The workspace uses the eval titles plus newer distractor threads whose
messages repeat the query words.
- For each of 14 queries, the test checks the expected title matches in
order and that the rest follow by most recent activity.
- It also checks the results are exactly the threads containing every
word, and that every highlight covers a query word.
- New cases cover accents ("cafe" → "Café sync"), a hyphenated query
whose words appear in separate messages ("plugin-sdk"), a fallback-only
title, and a titled thread's fallback.
- The timing cases are left out because they would be flaky in CI.

## How you verified

- Remote CI: passed on ca442c6, including all 14 ranking cases. One
unrelated Windows provider-parity flake passed on rerun.
[Run](https://github.com/get-bb/bb/actions/runs/37506173950)
- Slop Cop on 62c0256: no blockers. The old bm25 query fails 9 of the
14 cases; three test-tightening follow-ups were fixed in ca442c6.

Follows #5003.

BB-Thread: [⌘K
improvements](https://brsbl.getbb.app/projects/proj_khiw2za95v/threads/thr_tm8utsbqpb)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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