Skip to content

feat(fuzzy-finder): migrate from go-fuzzyfinder to fzf library#511

Merged
apstndb merged 1 commit intomainfrom
feat/fzf-migration
Feb 24, 2026
Merged

feat(fuzzy-finder): migrate from go-fuzzyfinder to fzf library#511
apstndb merged 1 commit intomainfrom
feat/fzf-migration

Conversation

@apstndb
Copy link
Owner

@apstndb apstndb commented Feb 24, 2026

Summary

Migrate the fuzzy finder backend from go-fuzzyfinder to junegunn/fzf library for better UX: partial-screen inline rendering, visual borders, and context-aware headers.

Also consolidate CLI_ENABLE_FUZZY_FINDER + CLI_FUZZY_FINDER_KEY into just CLI_FUZZY_FINDER_KEY — set to empty string to disable.

Key Changes

  • go.mod/go.sum: Replace ktr0731/go-fuzzyfinder with junegunn/fzf
  • fuzzy_finder.go: New runFzf() using fzf's ParseOptions/Run/Printer API (string-based selection instead of index-based). Added --height=~20 (partial-screen), --border=rounded, --info=inline-right, and context-aware --header. Added statementNameInsertMap for display-to-insert text lookup. No-arg statements get auto-appended ; for immediate submit.
  • cli_readline.go: Replace EnableFuzzyFinder bool check with FuzzyFinderKey != ""
  • system_variables.go: Remove EnableFuzzyFinder field; empty FuzzyFinderKey means disabled
  • var_registry.go: Remove CLI_ENABLE_FUZZY_FINDER registration; update description
  • fuzzy_finder_test.go: Add TestStatementNameInsertText
  • main_test.go: Remove EnableFuzzyFinder from all test fixtures
  • README.md: Document fuzzy finder feature and CLI_FUZZY_FINDER_KEY in system variables table

Future Directions

  • --tmux popup: fzf natively supports --tmux for rendering in a tmux popup. Could be exposed via a system variable.
  • Multi-select: fzf's --multi could enable batch operations (e.g., selecting multiple tables).
  • Preview pane: fzf's --preview could show table schemas, variable descriptions, or statement help alongside candidates.
  • Custom key bindings in fzf: --bind could enable richer in-finder interactions.

Test Plan

  • make check passes
  • Manual testing: all completion types show header and partial-screen fzf
  • Terminal state restores correctly after cancel/select

🤖 Generated with Claude Code

Replace go-fuzzyfinder with junegunn/fzf as the fuzzy finder backend.
fzf provides better UX with partial-screen rendering, bordered UI, and
context-aware headers showing what type of completion is active.

Key changes:
- Replace go-fuzzyfinder with fzf library (string-based selection via
  Printer callback instead of index-based)
- Add --height=~20, --border=rounded, --info=inline-right for better UX
- Add context-aware --header (Databases, Tables, System Variables, etc.)
- Remove unnecessary goroutine for buffered channel fill
- Remove CLI_ENABLE_FUZZY_FINDER variable; use empty CLI_FUZZY_FINDER_KEY
  to disable instead
- Add statementNameInsertMap for display-to-insert text lookup
- Update README with fuzzy finder feature and system variable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @apstndb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the fuzzy finder functionality by replacing the underlying go-fuzzyfinder library with junegunn/fzf. This change brings a more modern and user-friendly interface to the fuzzy finder, including improved visual presentation and more intelligent statement completion. Additionally, the configuration for the fuzzy finder has been simplified, making it easier to enable or disable the feature through a single system variable.

Highlights

  • Fuzzy Finder Backend Migration: The fuzzy finder backend has been migrated from go-fuzzyfinder to the junegunn/fzf library, enhancing the user experience with features like partial-screen inline rendering, visual borders, and context-aware headers.
  • Configuration Simplification: The fuzzy finder configuration has been streamlined by consolidating CLI_ENABLE_FUZZY_FINDER and CLI_FUZZY_FINDER_KEY into a single CLI_FUZZY_FINDER_KEY. Setting this key to an empty string now disables the feature.
  • Enhanced Statement Completion: Statement name completion now uses a display-to-insert text lookup map, and no-argument statements are automatically appended with a semicolon for immediate submission.
  • Dependency Updates: The project dependencies were updated to reflect the new fzf library and remove the old go-fuzzyfinder dependency, along with other related indirect dependencies.
Changelog
  • README.md
    • Updated documentation to reflect the new fuzzy finder features and the CLI_FUZZY_FINDER_KEY system variable.
  • go.mod
    • Replaced github.com/ktr0731/go-fuzzyfinder with github.com/junegunn/fzf as a direct dependency.
    • Added github.com/junegunn/go-shellwords and github.com/charlievieth/fastwalk as indirect dependencies.
    • Updated github.com/gdamore/tcell/v2 to a newer version.
    • Removed several indirect dependencies related to the old fuzzy finder library.
  • go.sum
    • Updated checksums to reflect the changes in go.mod, including the addition and removal of various module entries.
  • internal/mycli/cli_readline.go
    • Modified the fuzzy finder activation logic to check if c.SystemVariables.FuzzyFinderKey is non-empty instead of relying on c.SystemVariables.EnableFuzzyFinder.
  • internal/mycli/fuzzy_finder.go
    • Replaced the import of github.com/ktr0731/go-fuzzyfinder with github.com/junegunn/fzf/src.
    • Refactored the fuzzy finder execution logic to use a new runFzf function, replacing the fuzzyfinder.Find call.
    • Implemented statementNameInsertMap to map display text to insert text for statement name completion.
    • Added logic to automatically append a semicolon to no-argument statements selected via fuzzy finder.
    • Introduced completionHeader function to provide dynamic headers for the fzf interface based on completion type.
    • Implemented runFzf function to configure and execute the fzf command-line tool with specific options for improved UX (e.g., --height, --border, --info, --header).
  • internal/mycli/fuzzy_finder_test.go
    • Added TestStatementNameInsertText to verify the correct mapping of display text to insert text for statement names.
  • internal/mycli/main_test.go
    • Removed the EnableFuzzyFinder field from various test fixtures in Test_initializeSystemVariables.
  • internal/mycli/system_variables.go
    • Removed the EnableFuzzyFinder boolean field from the systemVariables struct.
    • Updated the comment for FuzzyFinderKey to indicate that an empty string disables the fuzzy finder.
    • Adjusted newSystemVariablesWithDefaults to no longer set EnableFuzzyFinder.
  • internal/mycli/var_registry.go
    • Removed the registration for the CLI_ENABLE_FUZZY_FINDER system variable.
    • Updated the description for CLI_FUZZY_FINDER_KEY to clarify that an empty string disables the feature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@apstndb apstndb added the enhancement New feature or request label Feb 24, 2026
@github-actions
Copy link

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (8c65601) #511 (58532ff) +/-
Coverage 68.5% 68.3% -0.2%
Code to Test Ratio 1:1.2 1:1.2 -0.1
Test Execution Time 1m5s 2m14s +1m9s
Details
  |                     | main (8c65601) | #511 (58532ff) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          68.5% |          68.3% | -0.2% |
  |   Files             |             55 |             55 |     0 |
  |   Lines             |           5879 |           5912 |   +33 |
+ |   Covered           |           4031 |           4043 |   +12 |
- | Code to Test Ratio  |          1:1.2 |          1:1.2 |  -0.1 |
  |   Code              |          13514 |          13570 |   +56 |
+ |   Test              |          16900 |          16914 |   +14 |
- | Test Execution Time |           1m5s |          2m14s | +1m9s |

Code coverage of files in pull request scope (66.9% → 66.0%)

Files Coverage +/- Status
internal/mycli/cli_readline.go 52.2% 0.0% modified
internal/mycli/execute_sql.go 73.7% +0.5% affected
internal/mycli/fuzzy_finder.go 24.1% -1.6% modified
internal/mycli/metrics/execution_metrics.go 11.1% +11.1% affected
internal/mycli/system_variables.go 95.0% 0.0% modified
internal/mycli/var_registry.go 90.2% -0.1% modified

Reported by octocov

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully migrates the fuzzy finder backend from go-fuzzyfinder to the junegunn/fzf library, providing a significantly improved user experience with partial-screen rendering and context-aware headers. The consolidation of configuration variables into CLI_FUZZY_FINDER_KEY simplifies the system settings. The implementation correctly leverages the fzf library's modern API. I have identified one high-severity issue regarding the buffer deletion logic that could lead to accidental data loss when triggering the fuzzy finder in the middle of a multiline buffer or when multiple statements are present.

@apstndb apstndb merged commit 3b1195d into main Feb 24, 2026
2 checks passed
@apstndb apstndb deleted the feat/fzf-migration branch February 24, 2026 15:28
@apstndb apstndb added the fuzzy-finder Fuzzy finder (fzf) completion features label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fuzzy-finder Fuzzy finder (fzf) completion features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant