Skip to content

Conversation

@Clarity-89
Copy link
Contributor

@Clarity-89 Clarity-89 commented Jul 30, 2025

What is this feature?

Seeing as timc1/kbar#255 has been fixed (and we're using the kbar version with the fix), we can switch back to using useMatches hook from kbar.

@Clarity-89 Clarity-89 requested a review from leeoniya July 30, 2025 06:19
@Clarity-89 Clarity-89 requested a review from a team as a code owner July 30, 2025 06:19
@Clarity-89 Clarity-89 self-assigned this Jul 30, 2025
@Clarity-89 Clarity-89 added the no-changelog Skip including change in changelog/release notes label Jul 30, 2025
@Clarity-89 Clarity-89 added add to changelog and removed no-changelog Skip including change in changelog/release notes labels Jul 30, 2025
@Clarity-89 Clarity-89 changed the title CommandPalette: Use fuzzySearch util from grafana/data CommandPalette: Use useMatches from kbar Jul 30, 2025
@Clarity-89 Clarity-89 requested a review from joshhunt July 30, 2025 06:48
Copy link
Member

@aocenas aocenas left a comment

Choose a reason for hiding this comment

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

I assume this should not actually change any behaviour right?

@tomratcliffe
Copy link
Contributor

Are there any existing tests that cover the expected behaviour of the old hook?

@Clarity-89
Copy link
Contributor Author

This restores the behavior we had earlier until the bug in kbar library was discovered: #61278.

@leeoniya
Copy link
Contributor

leeoniya commented Jul 30, 2025

it looks like they swapped out for fuse.js as the fix? not ideal 😅. it's slow for many items :(

https://leeoniya.github.io/uFuzzy/demos/compare.html?libs=uFuzzy,fuzzysort,QuickScore,Fuse&search=super%20ma

hopefully they have the correct fuse.js settings that don't return nonsense results, too.

https://github.com/leeoniya/uFuzzy?tab=readme-ov-file#search-quality

@leeoniya
Copy link
Contributor

btw, if you're looking to simplify, we now have a fuzzySearch function that implements all the necessary conditions: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/utils/fuzzySearch.ts

@Clarity-89
Copy link
Contributor Author

btw, if you're looking to simplify, we now have a fuzzySearch function that implements all the necessary conditions: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/utils/fuzzySearch.ts

Yeah, that was my original commit, but then I saw a TODO in useMatchers, so decided to revert that change instead.

@leeoniya
Copy link
Contributor

leeoniya commented Jul 30, 2025

the reason i wrote uFuzzy was because of my frustration with Fuse (both startup/indexing time and mem/cpu perf and result quality). ufuzzy also has typo tolerance, which i dont think fuse supports. maybe you can see why i'm not thrilled about the change 😅. your call, tho. i'd suggest at least testing it with 10k-20k items and compare results/ordering.

/0.02

@Clarity-89 Clarity-89 force-pushed the command-palette/fuzzy branch from ea82004 to 07e37f5 Compare July 31, 2025 13:11
@Clarity-89
Copy link
Contributor Author

the reason i wrote uFuzzy was because of my frustration with Fuse (both startup/indexing time and mem/cpu perf and result quality). ufuzzy also has typo tolerance, which i dont think fuse supports. maybe you can see why i'm not thrilled about the change 😅. your call, tho. i'd suggest at least testing it with 10k-20k items and compare results/ordering.

/0.02

I did some quick tests and it seems like the fuzzySearch function is way faster, so let's use that.

@Clarity-89 Clarity-89 changed the title CommandPalette: Use useMatches from kbar CommandPalette: Use fuzzySearch util from grafana/data Jul 31, 2025
@Clarity-89 Clarity-89 merged commit 2f4166e into main Aug 19, 2025
90 checks passed
@Clarity-89 Clarity-89 deleted the command-palette/fuzzy branch August 19, 2025 05:22
gelicia pushed a commit that referenced this pull request Aug 19, 2025
* CommandPalette: Use fuzzySearch util from grafana/data

* Comment
leeoniya pushed a commit that referenced this pull request Aug 19, 2025
* CommandPalette: Use fuzzySearch util from grafana/data

* Comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants