Skip to content

feat(search): add fzf engine with frecency tiebreak - #359

Open
luizhcrocha wants to merge 6 commits into
savedra1:mainfrom
luizhcrocha:feat/fzf-search-engine
Open

luizhcrocha wants to merge 6 commits into
savedra1:mainfrom
luizhcrocha:feat/fzf-search-engine

Conversation

@luizhcrocha

@luizhcrocha luizhcrocha commented Apr 14, 2026 •

Copy link
Copy Markdown

Hi, @savedra1

I've made this to give users an option on search engine and search result optimization, so they can get the most out of the search feature, tweaking as they like.

The default is still charmbracelet/bubbles backed by sahilm/fuzzy, but if the user want's he can choose to use junegunn/fzf by adding these to settings:

{
    "search": {
        "engine": "fzf",
        "algo": "v2",
        "caseSensitivity": "smart",
        "normalize": true,
        "tiebreak": ["score", "frecency", "index"]
    }
}

One thing that I think you might not like is that I changed func sanitizedFilter to a high-order function func buildFilter, because I thought that would make the code more concise.

Wrote with Claude Code help, not full on vibecoded (I know some people hate this). Test was all Claude Code though.

feat(search): add fzf engine with frecency tiebreak

chore(Makefile): fix formatting and syntax errors
@luizhcrocha luizhcrocha changed the title ggfeat(search): add fzf engine with frecency tiebreak feat(search): add fzf engine with frecency tiebreak Apr 15, 2026
@luizhcrocha

Copy link
Copy Markdown
Author

After some usage... i think it's not quite there yet. Will mark as draft and try to improve and fix some problems.

@luizhcrocha
luizhcrocha marked this pull request as draft April 15, 2026 13:46
@luizhcrocha
luizhcrocha force-pushed the feat/fzf-search-engine branch 2 times, most recently from 91c7492 to e3fa456 Compare April 15, 2026 16:01
@luizhcrocha

Copy link
Copy Markdown
Author

Now i think it's quite nice. Added a way to quantize better so tiebreaks works more 'loosely', and let other tiebreak steps resolve close calls.

Fixed a bug with unsafe code, a bad usage of fzf Slab, and, I think most importantly, and need review, is that:

  • Added code to strip some chars from copied text so they can appear more cleanly on the view lists
  • Expanded the scope of searchable text from copied text to 4kb, so more text get searched.

@luizhcrocha
luizhcrocha marked this pull request as ready for review April 15, 2026 16:06
@luizhcrocha
luizhcrocha force-pushed the feat/fzf-search-engine branch from e3fa456 to 54b746f Compare April 17, 2026 15:17
@luizhcrocha
luizhcrocha force-pushed the feat/fzf-search-engine branch from 319eedf to 7723b1f Compare May 28, 2026 21:45
log2 score bucketing collapsed all real-world fzf scores into one bucket,
flattening filtered results to chronological order (a consecutive boundary
match could rank below scattered subsequence matches). Add a numeric linear
quantization width to bucketize and default the score tiebreak to width 16
(one fzf scoreMatch unit): genuinely-close scores group so frecency decides,
while clearly-better matches stay ahead.
@luizhcrocha
luizhcrocha force-pushed the feat/fzf-search-engine branch 2 times, most recently from 339749b to 187b8f3 Compare May 28, 2026 22:22
@luizhcrocha
luizhcrocha force-pushed the feat/fzf-search-engine branch from 187b8f3 to 5185128 Compare May 29, 2026 01:50
@luizhcrocha
luizhcrocha force-pushed the feat/fzf-search-engine branch from 5185128 to 9876760 Compare May 29, 2026 15:35
@savedra1

Copy link
Copy Markdown
Owner

Hi @luizhcrocha,

Firstly, apologies for the delay in getting back to you, and thank you for your work here.

Since PR #311 addressed the fzf crash on null byte chars, the Bubbletea fzf engine seems to now be working well (I haven't seen any reports of it crashing since that was released). So, I wonder if this feature is worth the additional complexity... It's a significant amount of code changed, including 15 files, and I'm not sure the benefit is justified.

Maybe I am missing something though, could you maybe add some more information on the value added here?

Thank you

@luizhcrocha

Copy link
Copy Markdown
Author

Hi, @savedra1.

No problem, I fully understand that PRs might take time.
I made these changes to address a use case of mine, and I've been using it since the PR.

I was working on a case analysis tool for law firms and researching and fine-tuning search on file trees, and I wanted to move some findings to my clipse use, particularly the ranking and tolerance, since I got some search results that were not quite what I expected (not a failure, but just the way search is designed).

So, I think the point was to give users flexibility to fiddle with how they want search to behave, have nice defaults, but I agree that this results in complexity. I, myself, never changed settings again after deciding on these:

  "search": {
    "engine": "fzf",
    "algo": "v2",
    "matchMode": "fuzzy",
    "caseSensitivity": "smart",
    "normalize": true,
    "typoTolerance": true,
    "maxScatter": 24,
    "tiebreak": [
      { "key": "score", "bucket": "32" },
      { "key": "frecency" },
      { "key": "length" },
      "index"
    ]
  }

I thought of exposing settings because others might not like typo tolerance, fuzzy matching, case sensitivity, and so on.

Overall, I'm pretty satisfied with the searching experience this provides, but it's a small improvement, and I'm really on board with you deciding the fit.

This branch has not been deployed

No deployments
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.

2 participants