Skip to content

feat(fuzzy-finder): add operation completion and Value/Label fzf support#527

Merged
apstndb merged 2 commits intomainfrom
feat/fuzzy-finder-operation-completion
Feb 26, 2026
Merged

feat(fuzzy-finder): add operation completion and Value/Label fzf support#527
apstndb merged 2 commits intomainfrom
feat/fuzzy-finder-operation-completion

Conversation

@apstndb
Copy link
Owner

@apstndb apstndb commented Feb 26, 2026

Summary

  • Add fuzzy completion for SHOW OPERATION statement — lists DDL operations with multiline display showing DDL statements as labels and operation IDs as insert values
  • Refactor fzf integration to support Value/Label separation (fzfItem type) enabling different display and insert text, with --delimiter/--with-nth for display and extractValue() for result extraction
  • Add multiline rendering support (--read0, --multi-line, --gap) with dynamic height calculation for operation candidates
  • Integrate with existing TTL-based cache (feat(fuzzy-finder): add TTL-based candidate caching for database and table completion #517) — cache type updated from []string to []fzfItem
  • Update README.md to include "database roles" and "operations" in fuzzy finder feature list

Refs #521, #526

Test plan

  • make check passes (test + lint + fmt-check)
  • Manual: SHOW OPERATION + Ctrl+T shows DDL operations with multiline DDL labels
  • Manual: selecting an operation inserts only the operation ID
  • Manual: existing completions (databases, tables, variables, roles) still work
  • Verify cache invalidation works with []fzfItem type

🤖 Generated with Claude Code

Add fuzzy completion for SHOW OPERATION statement, listing DDL operations
with multiline display showing DDL statements as labels and operation IDs
as values. Refactor fzf integration to support Value/Label separation
(fzfItem type) enabling different display and insert text, with multiline
rendering for operation candidates.

Refs #521, #526

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 fuzzy finder capabilities by introducing support for SHOW OPERATION statements, allowing users to easily select DDL operations with rich, multiline displays. It refactors the underlying fzf integration to support distinct display labels and insertable values, enabling a more intuitive user experience while maintaining precise command execution. This update also includes improvements for multiline rendering and dynamic height adjustments for the fzf interface.

Highlights

  • Fuzzy Completion for SHOW OPERATION: Added fuzzy completion for SHOW OPERATION statements, allowing users to select DDL operations with multiline displays showing DDL statements as labels and operation IDs as insert values.
  • Refactored FZF Integration with Value/Label Support: Refactored the fzf integration to support Value/Label separation using a new fzfItem type, enabling different display and insert text with --delimiter/--with-nth for display and extractValue() for result extraction.
  • Multiline Rendering and Dynamic Height for FZF: Implemented multiline rendering support for fzf candidates using --read0, --multi-line, and --gap options, along with dynamic height calculation for operation candidates.
  • Cache Type Update: Integrated with the existing TTL-based cache, updating its type from []string to []fzfItem to accommodate the new Value/Label structure.
  • README.md Update: Updated README.md to include "database roles" and "operations" in the fuzzy finder feature list.
Changelog
  • README.md
    • Updated the fuzzy finder feature list to include "database roles" and "operations".
  • internal/mycli/client_side_statement_def.go
    • Defined a new fuzzyCompleteOperation type.
    • Added completion configuration for SHOW OPERATION statements, linking them to fuzzyCompleteOperation.
  • internal/mycli/fuzzy_finder.go
    • Imported longrunningpb for operation details.
    • Modified fuzzyCacheEntry to store []fzfItem instead of []string.
    • Introduced fzfItem struct for Value/Label separation and toFzfItems conversion helper.
    • Removed statementNameCandidate and related logic, replacing it with an fzfItem based approach.
    • Refactored runFzf to use fzfItems, prepareFzfOptions for argument generation, and extractValue for result processing.
    • Added fzfDelimiter constant.
    • Implemented prepareFzfOptions to dynamically configure fzf arguments, including multiline support (--read0, --multi-line, --gap) and dynamic height calculation.
    • Added extractValue to correctly retrieve the insertable value from fzf output.
    • Introduced runFzfFilter for testing fzf in non-interactive mode.
    • Updated buildStatementNameItems to create fzfItems for statement names.
    • Added fuzzyCompleteOperation to the requiresNetwork check.
    • Adjusted getCachedCandidates and setCachedCandidates to handle []fzfItem.
    • Modified resolveCandidates to return []fzfItem and use statementNameItems.
    • Updated fetchCandidates to return []fzfItem and convert []string results where necessary.
    • Modified fetchDatabaseCandidates, fetchRoleCandidates, and fetchTableCandidates to return []fzfItem.
    • Added fetchOperationCandidates to retrieve DDL operations and format them as fzfItems with DDL statements as labels.
  • internal/mycli/fuzzy_finder_test.go
    • Added fmt and strings imports.
    • Extended TestDetectFuzzyContext with test cases for SHOW OPERATION.
    • Replaced TestBuildStatementNameCandidates with TestBuildStatementNameItems and updated assertions.
    • Added new test functions: TestToFzfItems, TestPrepareFzfOptions, TestPrepareFzfOptions_DynamicHeight, TestPrepareFzfOptions_HeightCap, TestRunFzfFilter_SimpleMatch, TestRunFzfFilter_LabelValueSeparation, TestRunFzfFilter_StatementNames, and TestExtractValue to cover the new fzfItem and fzf integration logic.
    • Updated TestFuzzyCacheEntryValid to use fzfItem in cache entries.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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.

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 fuzzy completion for SHOW OPERATION and significantly refactors the fuzzy finder implementation to support separate display (Label) and insertion (Value) texts. This is achieved by introducing an fzfItem struct and updating the caching, fzf execution, and candidate fetching logic accordingly. The changes also add support for multiline display in the fuzzy finder, improving the user experience for complex items like DDL operations. The test suite has been substantially updated to cover the new functionality and refactoring, including a new test helper to run fzf in filter mode. My review found one high-severity issue related to the choice of delimiter for separating Value and Label, which could lead to incorrect completions if the data contains tab characters. I've suggested using a non-printable control character to resolve this.

@github-actions
Copy link

github-actions bot commented Feb 26, 2026

Code Metrics Report

📊 View detailed coverage report (available for 7 days)

main (71393af) #527 (ecc065f) +/-
Coverage 67.8% 68.0% +0.1%
Code to Test Ratio 1:1.2 1:1.2 +0.0
Test Execution Time 1m11s 1m2s -9s
Details
  |                     | main (71393af) | #527 (ecc065f) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          67.8% |          68.0% | +0.1% |
  |   Files             |             55 |             55 |     0 |
  |   Lines             |           5959 |           6039 |   +80 |
+ |   Covered           |           4046 |           4108 |   +62 |
+ | Code to Test Ratio  |          1:1.2 |          1:1.2 |  +0.0 |
  |   Code              |          13683 |          13819 |  +136 |
+ |   Test              |          17037 |          17235 |  +198 |
+ | Test Execution Time |          1m11s |           1m2s |   -9s |

Code coverage of files in pull request scope (57.1% → 58.9%)

Files Coverage +/- Status
internal/mycli/client_side_statement_def.go 79.1% -0.4% modified
internal/mycli/execute_sql.go 73.6% +0.5% affected
internal/mycli/fuzzy_finder.go 35.1% +12.3% modified
internal/mycli/metrics/execution_metrics.go 11.1% +11.1% affected

Reported by octocov

Replace tab character with \x01 (SOH) as the delimiter between Value
and Label to prevent data corruption if values contain tab characters.

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

apstndb commented Feb 26, 2026

/gemini review

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 a significant and well-executed refactoring of the fuzzy finder to support separate Value and Label items, enabling more descriptive completion candidates. This is nicely demonstrated by the new SHOW OPERATION completion, which displays multiline DDL statements as labels while inserting just the operation ID. The changes also improve testability by isolating fzf option preparation. However, I found a critical issue in the new fetchOperationCandidates function that will prevent the code from compiling.

@apstndb
Copy link
Owner Author

apstndb commented Feb 26, 2026

/gemini summary

@gemini-code-assist
Copy link
Contributor

Summary of Changes

This pull request significantly enhances the fuzzy finder's capabilities by introducing support for SHOW OPERATION statements, allowing users to easily select DDL operations with rich, multiline displays. The underlying fzf integration has been refactored to support distinct display labels and insertable values, providing a more intuitive user experience while maintaining precise command execution. This update also includes improvements for multiline rendering and dynamic height adjustments for the fzf interface, ensuring a better visual presentation of complex completion candidates.

Highlights

  • Fuzzy Completion for SHOW OPERATION: Added fuzzy completion for SHOW OPERATION statements, allowing users to select DDL operations with multiline displays showing DDL statements as labels and operation IDs as insert values.
  • Refactored FZF Integration with Value/Label Support: Refactored the fzf integration to support Value/Label separation using a new fzfItem type, enabling different display and insert text with --delimiter/--with-nth for display and extractValue() for result extraction.
  • Multiline Rendering and Dynamic Height for FZF: Implemented multiline rendering support for fzf candidates using --read0, --multi-line, and --gap options, along with dynamic height calculation for operation candidates.
  • Cache Type Update: Integrated with the existing TTL-based cache, updating its type from []string to []fzfItem to accommodate the new Value/Label structure.
  • README.md Update: Updated README.md to include "database roles" and "operations" in the fuzzy finder feature list.
Changelog
  • README.md
    • Updated the fuzzy finder feature list to include "database roles" and "operations".
  • internal/mycli/client_side_statement_def.go
    • Defined a new fuzzyCompleteOperation type.
    • Added completion configuration for SHOW OPERATION statements, linking them to fuzzyCompleteOperation.
  • internal/mycli/fuzzy_finder.go
    • Imported longrunningpb for operation details.
    • Modified fuzzyCacheEntry to store []fzfItem instead of []string.
    • Introduced fzfItem struct for Value/Label separation and toFzfItems conversion helper.
    • Removed statementNameCandidate and related logic, replacing it with an fzfItem based approach.
    • Refactored runFzf to use fzfItems, prepareFzfOptions for argument generation, and extractValue for result processing.
    • Added fzfDelimiter constant, using a non-printable control character for safety.
    • Implemented prepareFzfOptions to dynamically configure fzf arguments, including multiline support (--read0, --multi-line, --gap) and dynamic height calculation.
    • Added extractValue to correctly retrieve the insertable value from fzf output.
    • Introduced runFzfFilter for testing fzf in non-interactive mode.
    • Updated buildStatementNameItems to create fzfItems for statement names.
    • Added fuzzyCompleteOperation to the requiresNetwork check.
    • Adjusted getCachedCandidates and setCachedCandidates to handle []fzfItem.
    • Modified resolveCandidates to return []fzfItem and use statementNameItems.
    • Updated fetchCandidates to return []fzfItem and convert []string results where necessary.
    • Modified fetchDatabaseCandidates, fetchRoleCandidates, and fetchTableCandidates to return []fzfItem.
    • Added fetchOperationCandidates to retrieve DDL operations and format them as fzfItems with DDL statements as labels.
  • internal/mycli/fuzzy_finder_test.go
    • Added fmt and strings imports.
    • Extended TestDetectFuzzyContext with test cases for SHOW OPERATION.
    • Replaced TestBuildStatementNameCandidates with TestBuildStatementNameItems and updated assertions.
    • Added new test functions: TestToFzfItems, TestPrepareFzfOptions, TestPrepareFzfOptions_DynamicHeight, TestPrepareFzfOptions_HeightCap, TestRunFzfFilter_SimpleMatch, TestRunFzfFilter_LabelValueSeparation, TestRunFzfFilter_StatementNames, and TestExtractValue to cover the new fzfItem and fzf integration logic.
    • Updated TestFuzzyCacheEntryValid to use fzfItem in cache entries.
Activity
  • gemini-code-assist[bot] provided an initial summary of changes and highlights.
  • gemini-code-assist[bot] reported code metrics, showing a slight increase in coverage and a decrease in test execution time.
  • gemini-code-assist[bot] identified a critical issue regarding the use of a tab character as a delimiter in fzf and suggested using a non-printable control character (\x01) to prevent data corruption.
  • apstndb addressed the delimiter issue, changing it from tab to SOH (\x01) and updating tests accordingly, confirming the fix in commit c2495d1.
  • gemini-code-assist[bot] raised a critical concern about the ListOperations().All() method, suggesting it would fail to compile and recommended using Next() in a loop.
  • apstndb clarified that the ListOperationsIterator in the current Google Cloud Go SDK version does indeed have an .All() method returning iter.Seq2, making the for range pattern valid and idiomatic, indicating the bot's concern was a false positive.

@apstndb apstndb merged commit 1955708 into main Feb 26, 2026
2 checks passed
@apstndb apstndb deleted the feat/fuzzy-finder-operation-completion branch February 26, 2026 10:07
@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

fuzzy-finder Fuzzy finder (fzf) completion features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant