Skip to content

Comments

feat(interactive): add fzf-style fuzzy finder for USE statement#506

Merged
apstndb merged 2 commits intomainfrom
feat/fuzzy-finder
Feb 22, 2026
Merged

feat(interactive): add fzf-style fuzzy finder for USE statement#506
apstndb merged 2 commits intomainfrom
feat/fuzzy-finder

Conversation

@apstndb
Copy link
Owner

@apstndb apstndb commented Feb 22, 2026

Summary

  • Add interactive fuzzy finder (fzf-style) triggered by configurable key binding (default: Ctrl+T)
  • MVP: USE <database> context — lists databases from current instance, pre-fills query with typed prefix, replaces argument on selection
  • Upgrade go-multiline-ny v0.21.0 → v0.22.4, go-readline-ny v1.9.1 → v1.14.1

New system variables

Variable Default Description
CLI_ENABLE_FUZZY_FINDER true Enable/disable fuzzy finder
CLI_FUZZY_FINDER_KEY C_T Key binding (uses go-readline-ny key names)

Behavior

USE apst<Ctrl+T>
# → fzf opens with "apst" as initial query
# → select apstndb-sampledb-with-data-idx
USE apstndb-sampledb-with-data-idx

TODO (future phases)

  • Metadata caching with TTL
  • Extend to SHOW TABLES, SHOW COLUMNS FROM, SHOW INDEX FROM
  • Preview window with DDL/column info
  • System variable completion for SET

Test plan

  • make check passes (test + lint + fmt-check)
  • TestDetectFuzzyContext covers USE context detection with various inputs
  • Manual verification with real Spanner instance

🤖 Generated with Claude Code

Add an interactive fuzzy finder triggered by a configurable key binding
(default: Ctrl+T) that provides completion-style selection for client-side
statement arguments. MVP supports USE <database> context.

- Add ktr0731/go-fuzzyfinder dependency (pure Go, tcell-based)
- Upgrade go-multiline-ny v0.21.0 -> v0.22.4, go-readline-ny v1.9.1 -> v1.14.1
- Add CLI_ENABLE_FUZZY_FINDER (default: true) and CLI_FUZZY_FINDER_KEY
  (default: C_T) system variables for user configuration
- Implement fuzzyFinderCommand with terminal handoff pattern
  (GotoEndLine/rewind) and completion-style argument replacement
- Detect USE context, pre-fill fzf query with typed prefix, replace
  argument portion on selection

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 enhances the interactive command-line interface by integrating a fuzzy finder. This feature streamlines the process of selecting database names when issuing USE statements, improving user efficiency and overall experience. The implementation includes flexible configuration options through new system variables and updated core dependencies to support the new interactive capabilities.

Highlights

  • Interactive Fuzzy Finder: Introduced an fzf-style fuzzy finder for USE <database> statements, allowing users to quickly select database names from the current instance.
  • Configurable Key Binding: The fuzzy finder is triggered by a configurable key binding, defaulting to Ctrl+T, and uses go-readline-ny key names.
  • New System Variables: Added two new system variables: CLI_ENABLE_FUZZY_FINDER (default true) to enable/disable the feature, and CLI_FUZZY_FINDER_KEY (default C_T) to customize the key binding.
  • Dependency Updates: Upgraded go-multiline-ny from v0.21.0 to v0.22.4 and go-readline-ny from v1.9.1 to v1.14.1, and added go-fuzzyfinder along with related terminal UI dependencies.
Changelog
  • go.mod
    • Upgraded github.com/hymkor/go-multiline-ny to v0.22.4.
    • Added github.com/ktr0731/go-fuzzyfinder at v0.9.0.
    • Updated github.com/mattn/go-runewidth to v0.0.19.
    • Upgraded github.com/nyaosorg/go-readline-ny to v1.14.1.
    • Added indirect dependencies for terminal UI components, including github.com/clipperhouse/uax29/v2, github.com/gdamore/encoding, github.com/gdamore/tcell/v2, github.com/ktr0731/go-ansisgr, github.com/lucasb-eyer/go-colorful, github.com/nsf/termbox-go, and github.com/nyaosorg/go-ttyadapter.
  • go.sum
    • Added and updated checksums for new and upgraded Go module dependencies.
  • internal/mycli/cli_readline.go
    • Integrated the fuzzy finder command into the interactive readline editor.
    • Added logic to bind the fuzzy finder to a configurable key (CLI_FUZZY_FINDER_KEY) if the feature is enabled (CLI_ENABLE_FUZZY_FINDER).
    • Included logging for instances where an unknown key name is provided for the fuzzy finder binding.
  • internal/mycli/fuzzy_finder.go
    • Added a new file implementing the core logic for the fuzzyFinderCommand.
    • Implemented detectFuzzyContext to analyze the current input buffer and identify USE statement contexts.
    • Provided fetchCandidates and fetchDatabaseCandidates functions to retrieve available database names from the current Spanner instance.
    • Managed terminal handoff for the fuzzy finder UI and replaced the input buffer with the user's selection.
  • internal/mycli/fuzzy_finder_test.go
    • Added a new file containing unit tests for the detectFuzzyContext function, covering various USE statement inputs.
  • internal/mycli/main_test.go
    • Updated existing test cases within Test_initializeSystemVariables to reflect the default values of the newly introduced EnableFuzzyFinder and FuzzyFinderKey system variables.
  • internal/mycli/system_variables.go
    • Defined new boolean field EnableFuzzyFinder and string field FuzzyFinderKey within the systemVariables struct.
    • Set default values for EnableFuzzyFinder to true and FuzzyFinderKey to C_T in newSystemVariablesWithDefaults.
  • internal/mycli/var_registry.go
    • Registered the new system variables CLI_ENABLE_FUZZY_FINDER and CLI_FUZZY_FINDER_KEY with their respective types and descriptions in the variable registry.
Activity
  • The make check command passed, indicating successful execution of tests, linting, and format checks.
  • The TestDetectFuzzyContext function was added to cover various inputs for USE context detection.
  • Manual verification of the fuzzy finder functionality was performed with a real Spanner instance.
  • The pull request was generated with Claude Code.
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.

@github-actions
Copy link

github-actions bot commented Feb 22, 2026

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (124c9ea) #506 (8610f06) +/-
Coverage 70.0% 69.4% -0.6%
Code to Test Ratio 1:1.2 1:1.2 -0.1
Test Execution Time 1m4s 1m13s +9s
Details
  |                     | main (124c9ea) | #506 (8610f06) |  +/-  |
  |---------------------|----------------|----------------|-------|
- | Coverage            |          70.0% |          69.4% | -0.6% |
  |   Files             |             54 |             55 |    +1 |
  |   Lines             |           5704 |           5762 |   +58 |
+ |   Covered           |           3997 |           4004 |    +7 |
- | Code to Test Ratio  |          1:1.2 |          1:1.2 |  -0.1 |
  |   Code              |          13118 |          13244 |  +126 |
+ |   Test              |          16510 |          16622 |  +112 |
- | Test Execution Time |           1m4s |          1m13s |   +9s |

Code coverage of files in pull request scope (82.3% → 74.6%)

Files Coverage +/- Status
internal/mycli/cli_readline.go 52.2% -2.9% modified
internal/mycli/fuzzy_finder.go 10.2% +10.2% added
internal/mycli/system_variables.go 95.0% 0.0% modified
internal/mycli/var_registry.go 90.6% +0.0% 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 introduces an interactive fuzzy finder for the USE statement. While the feature significantly improves the interactive experience, there are critical logic errors in how the input context is detected and how the buffer is manipulated in multiline scenarios. Specifically, the context detection logic currently assumes the USE statement is at the very beginning of the entire multiline buffer, and the buffer replacement logic uses absolute offsets that will cause incorrect behavior or panics when the cursor is not on the first line. Additionally, a missing regular expression reference (extractDatabaseRe) will lead to compilation or runtime failures. These issues must be addressed to ensure the feature works reliably in a multiline editor environment.

…text

detectFuzzyContext now operates on B.String() (current line buffer)
instead of joining all editor lines. This fixes incorrect argStartPos
when the cursor is not on the first line of a multiline input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@apstndb
Copy link
Owner Author

apstndb commented Feb 22, 2026

/gemini summary

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request introduces a significant enhancement to the interactive command-line interface by adding a fuzzy finder. This feature aims to improve user experience and efficiency by providing an intuitive way to select database names, reducing manual typing and potential errors. The changes involve integrating new libraries, updating existing ones, and implementing the core logic for context detection and candidate presentation, all while maintaining configurability for the end-user.

Highlights

  • Interactive Fuzzy Finder for USE statements: An fzf-style fuzzy finder has been integrated, allowing users to interactively select database names when typing USE <database> commands. This feature is triggered by a configurable key binding, defaulting to Ctrl+T.
  • Configurable System Variables: Two new system variables, CLI_ENABLE_FUZZY_FINDER (default true) and CLI_FUZZY_FINDER_KEY (default C_T), have been introduced to control the fuzzy finder's activation and key binding.
  • Dependency Updates and Additions: Key dependencies go-multiline-ny and go-readline-ny were upgraded, and go-fuzzyfinder along with several terminal UI-related indirect dependencies were added to support the new interactive functionality.
  • Context-Aware Database Selection: The fuzzy finder intelligently detects the USE statement context, pre-fills the query with any typed prefix, and replaces the argument with the selected database name.
Changelog
  • go.mod
    • Upgraded github.com/hymkor/go-multiline-ny from v0.21.0 to v0.22.4.
    • Added github.com/ktr0731/go-fuzzyfinder at v0.9.0.
    • Updated github.com/mattn/go-runewidth from v0.0.16 to v0.0.19.
    • Upgraded github.com/nyaosorg/go-readline-ny from v1.9.1 to v1.14.1.
    • Removed golang.org/x/exp as a direct dependency, now an indirect dependency.
    • Added new indirect dependencies for terminal UI components, including github.com/clipperhouse/uax29/v2, github.com/gdamore/encoding, github.com/gdamore/tcell/v2, github.com/ktr0731/go-ansisgr, github.com/lucasb-eyer/go-colorful, github.com/nsf/termbox-go, and github.com/nyaosorg/go-ttyadapter.
  • go.sum
    • Updated checksums for all modified and newly added Go module dependencies.
  • internal/mycli/cli_readline.go
    • Integrated the fuzzyFinderCommand into the interactive readline editor.
    • Added logic to bind the fuzzy finder to the CLI_FUZZY_FINDER_KEY if CLI_ENABLE_FUZZY_FINDER is enabled.
    • Included a warning log for unknown key names configured for the fuzzy finder binding.
  • internal/mycli/fuzzy_finder.go
    • Added a new file implementing the core logic for the fuzzyFinderCommand.
    • Implemented detectFuzzyContext to analyze the current input buffer and identify USE statement contexts.
    • Provided fetchCandidates and fetchDatabaseCandidates functions to retrieve available database names from the current Spanner instance.
    • Managed terminal handoff for the fuzzy finder UI and replaced the input buffer with the user's selection.
  • internal/mycli/fuzzy_finder_test.go
    • Added a new file containing unit tests for the detectFuzzyContext function, covering various USE statement inputs.
  • internal/mycli/main_test.go
    • Updated existing test cases within Test_initializeSystemVariables to reflect the default values of the newly introduced EnableFuzzyFinder and FuzzyFinderKey system variables.
  • internal/mycli/system_variables.go
    • Defined new boolean field EnableFuzzyFinder and string field FuzzyFinderKey within the systemVariables struct.
    • Set default values for EnableFuzzyFinder to true and FuzzyFinderKey to C_T in newSystemVariablesWithDefaults.
  • internal/mycli/var_registry.go
    • Registered the new system variables CLI_ENABLE_FUZZY_FINDER and CLI_FUZZY_FINDER_KEY with their respective types and descriptions in the variable registry.
Activity
  • Gemini Code Assist provided an initial summary of changes.
  • Gemini Code Assist reported code metrics, noting a slight decrease in overall coverage but an increase in covered lines and files.
  • Gemini Code Assist provided critical feedback regarding context detection and extractDatabaseRe definition in fuzzy_finder.go.
  • The author, apstndb, acknowledged and fixed the issues raised by Gemini Code Assist in commit 4a451f4.

@apstndb apstndb merged commit 1292e55 into main Feb 22, 2026
2 checks passed
@apstndb apstndb deleted the feat/fuzzy-finder branch February 22, 2026 14:35
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