Skip to content

fix(desktop): rank topbar channel results by relevance, not alphabetically#2405

Open
tlongwell-block wants to merge 1 commit into
mainfrom
eva/topbar-channel-fuzzy-search
Open

fix(desktop): rank topbar channel results by relevance, not alphabetically#2405
tlongwell-block wants to merge 1 commit into
mainfrom
eva/topbar-channel-fuzzy-search

Conversation

@tlongwell-block

Copy link
Copy Markdown
Collaborator

Problem

The ⌘K topbar channel section had two compounding limiters (surfaced while investigating the buzz-security discovery incident — the incident itself was the deployed relay image missing #2181; this is the separate, real client defect found along the way):

  1. Alphabetical ranking under a hard cap of 5. Naive substring matches were sorted alphabetically, then slice(0, 5). Replayed against the live channel list: query buzz has 61 matches and buzz-security ranks 49th alphabetically — it could never appear.
  2. No separator tolerance. buzz security (space for hyphen) or buzzsec matched nothing at all.

The Channel Browser (⌘⇧O) already solves both with its banded fuzzy scorer (channelSearchScore.ts); the topbar just wasn't using it.

Fix

New pure helper features/search/lib/channelResultRanking.ts reusing scoreChannelMatch:

  • Relevance-ordered (score band ascending, alphabetical tiebreak), cap of 5 unchanged — a relevance-ranked cap is correct typeahead UX.
  • Visibility rules preserved exactly: archived only for members; otherwise open-or-member.
  • Channel labels (DM display names) scored as the display name, with the raw channel name kept searchable when a label overrides it.
  • Description matches stay in the lowest band, below any name match (same contract as the browser).

useSearchResults.ts channel memo now delegates to the helper.

Testing

  • 8 new unit tests in channelResultRanking.test.mjs covering the two original failure modes (buzz burying an exact match, buzz security/buzzsec finding buzz-security), visibility filtering, label override + raw-name fallback, description band, and the cap.
  • Full desktop suite: 3379 pass / 0 fail at this head; pnpm typecheck and pnpm check clean.

…cally

The ⌘K topbar channel section used naive substring matching sorted
alphabetically, then capped at 5 — so a query like "buzz" over 61
buzz-* channels could never surface buzz-security (49th alphabetically),
and separator-tolerant queries ("buzz security", "buzzsec") matched
nothing at all. The channel browser already solved both with its banded
fuzzy scorer.

Reuse scoreChannelMatch for the topbar section via a small pure ranking
helper: relevance-ordered (score band, alphabetical tiebreak), same
visibility rules (archived only for members; open or member), label
overrides scored as the display name with the raw channel name kept
searchable, cap of 5 unchanged.

Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
@tlongwell-block
tlongwell-block requested a review from a team as a code owner July 22, 2026 18:09
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