Skip to content

fix: skip client-side fuse re-filtering for async search results#13

Merged
fabkho merged 3 commits into
mainfrom
fix/skip-fuse-for-async-results
Mar 23, 2026
Merged

fix: skip client-side fuse re-filtering for async search results#13
fabkho merged 3 commits into
mainfrom
fix/skip-fuse-for-async-results

Conversation

@fabkho

@fabkho fabkho commented Mar 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug: Groups with an async search() function already perform server-side filtering, but their results were being re-filtered through Fuse.js (which defaults to keys: ['label']). This caused valid results to be dropped when the search query matched non-label fields (e.g. email, booking number, invoice recipient).
  • Fix: Only run fuzzySearch() on sync commands (local/static groups). Async results are concatenated directly into the final result set without client-side re-filtering.

The Problem

In useCmdBarState.ts, the search() function:

  1. Splits groups into async (has search() fn) and sync (static commands)
  2. Calls group.search!(query) for async groups → gets server-filtered results ✅
  3. Merges async + sync results together
  4. Passes everything through fuzzySearch() → Fuse.js with keys: ['label']

Step 4 is wrong for async results. Example: searching p.enis@gmail.com for customers — the API correctly returns "Peter Enis", but Fuse.js tries to match p.enis@gmail.com against the label "Peter Enis" and drops it.

The Fix

- let commandsToSearch = syncGroups.flatMap(...)
- if (Array.isArray(asyncResults) && asyncResults.length > 0) {
-   commandsToSearch = commandsToSearch.concat(asyncResults)
- }
- return fuzzySearch(query, commandsToSearch)
+ const syncCommands = syncGroups.flatMap(...)
+ const fusedResults = fuzzySearch(query, syncCommands)
+ if (Array.isArray(asyncResults) && asyncResults.length > 0) {
+   return fusedResults.concat(asyncResults)
+ }
+ return fusedResults

Sync groups still get full Fuse.js fuzzy matching. Async groups trust their server-side search.

Summary by CodeRabbit

  • Bug Fixes
    • Improved command/search behavior so synchronous fuzzy results are kept separate from asynchronous results, yielding clearer and more consistent search results.
  • Chores
    • Updated CI build environment to a newer Node.js runtime (22.x).

Groups with an async search() function have already performed server-side filtering. Re-running their results through Fuse.js (which defaults to matching only on 'label') incorrectly drops valid results when the search query matches non-label fields like email, booking number, or invoice recipient.
@coderabbitai

coderabbitai Bot commented Mar 23, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a650ccad-0a57-48bf-a111-8d2b61b621b5

📥 Commits

Reviewing files that changed from the base of the PR and between 7dceadc and 4980811.

📒 Files selected for processing (1)
  • .github/workflows/main.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/main.yml

📝 Walkthrough

Walkthrough

Updated the command bar search flow to run fuzzy-search only over sync commands derived from non-group.search groups, compute async results separately, and append async results to the fuzzy results when present.

Changes

Cohort / File(s) Summary
Search Control Flow
src/composables/useCmdBarState.ts
Refactored search(query) to remove a combined commandsToSearch array; derive syncCommands from non-group.search groups, run fuzzySearch on those to produce fusedResults, and append asyncResults only after fuzzy results.
CI Node Version
.github/workflows/main.yml
Updated actions/setup-node@v3 node-version from 18.x to 22.x (no other workflow logic changed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudged the search, gave sync the lead,
Async waits patient, then hops to the feed.
Fuzzy hops first, then the others arrive—
Neat stacks of results keep the bar alive. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: skipping client-side Fuse.js re-filtering for async search results, which is the core change in useCmdBarState.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/skip-fuse-for-async-results

Comment @coderabbitai help to get the list of available commands and usage tips.

@clack/core@1.1.0 (pulled by Nuxt examples) requires node:util.styleText which was added in Node 22.
@fabkho fabkho self-assigned this Mar 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/main.yml:
- Around line 11-12: The YAML steps list has incorrect indentation for the line
containing "uses: actions/checkout@v3" (it's over-indented by one space), which
breaks parsing; fix by aligning that entry with the other items in the same
steps list so all list entries (including "uses: actions/checkout@v3" and "uses:
pnpm/action-setup@v2") share the same indentation level under the steps key.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 581fb9bf-0b68-4221-a5ce-559fcdd783ee

📥 Commits

Reviewing files that changed from the base of the PR and between 84a4fb2 and 7dceadc.

📒 Files selected for processing (1)
  • .github/workflows/main.yml

Comment thread .github/workflows/main.yml Outdated
@fabkho fabkho merged commit 6680819 into main Mar 23, 2026
2 checks passed
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