Skip to content

Comments

ux(polish) autocomplete in the input prompt#18181

Merged
jacob314 merged 4 commits intomainfrom
fix_history_navigation_4
Feb 5, 2026
Merged

ux(polish) autocomplete in the input prompt#18181
jacob314 merged 4 commits intomainfrom
fix_history_navigation_4

Conversation

@jacob314
Copy link
Contributor

@jacob314 jacob314 commented Feb 3, 2026

Summary

Autocomplete in the input prompt popped up too aggressively. This change makes it only pop up as you type or delete characters. This allows you to navigate the input prompt in peace without getting nagged by autocompletes you don't care about.
Navigating back in the history was also annoying as we didn't pick the correct line causing you to frequently need to go through multiple lines of a prompt when you were just trying to navigate to a previous prompt.
Also fixed navigation so we only navigate up out of the current prompt after first navigating to the very first character of the prompt and only navigate down out of the current prompt after first navigating to the very last character of the prompt. This simplifies navigation within the prompt as well as making navigation to the next prompt less surprising.

Details

  • Enhanced History Navigation: The input prompt's history navigation has been significantly improved to handle cursor positioning more intelligently. When navigating through past commands, the cursor will now be placed at the 'start' or 'end' of the recalled command, or even at a specific offset if returning to an immediately previous edited state.
  • Intelligent Autocomplete Suppression: Autocomplete suggestions are now dynamically suppressed during history navigation and manual cursor movements. This prevents visual flickering and ensures suggestions only appear when the user is actively typing or expecting completion, leading to a smoother user experience.
  • Refactored Completion Hooks: The core completion hooks (useCommandCompletion, useCompletion, useReverseSearchCompletion) have been refactored. The showSuggestions state is now derived rather than explicitly managed, and an active flag has been introduced to conditionally enable or disable completion logic, providing more granular control.
  • Improved TextBuffer Functionality: The TextBuffer component now supports an optional cursorPosition parameter when setting text. This allows for precise control over where the cursor is placed after programmatically updating the input field, which is crucial for the enhanced history navigation.

Related Issues

Fixes: #16796

@jacob314 jacob314 requested a review from a team as a code owner February 3, 2026 08:22
@gemini-cli
Copy link
Contributor

gemini-cli bot commented Feb 3, 2026

Hi @jacob314, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jacob314, 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 focuses on refining the user experience of the input prompt by addressing key areas related to command history and autocomplete. The changes aim to provide a more fluid and less distracting interaction, particularly by eliminating suggestion flickering and ensuring consistent, intuitive cursor behavior during history recall and text manipulation. The underlying completion logic has been made more robust and controllable.

Highlights

  • Enhanced History Navigation: The input prompt's history navigation has been significantly improved to handle cursor positioning more intelligently. When navigating through past commands, the cursor will now be placed at the 'start' or 'end' of the recalled command, or even at a specific offset if returning to an immediately previous edited state.
  • Intelligent Autocomplete Suppression: Autocomplete suggestions are now dynamically suppressed during history navigation and manual cursor movements. This prevents visual flickering and ensures suggestions only appear when the user is actively typing or expecting completion, leading to a smoother user experience.
  • Refactored Completion Hooks: The core completion hooks (useCommandCompletion, useCompletion, useReverseSearchCompletion) have been refactored. The showSuggestions state is now derived rather than explicitly managed, and an active flag has been introduced to conditionally enable or disable completion logic, providing more granular control.
  • Improved TextBuffer Functionality: The TextBuffer component now supports an optional cursorPosition parameter when setting text. This allows for precise control over where the cursor is placed after programmatically updating the input field, which is crucial for the enhanced history navigation.
Changelog
  • packages/cli/src/ui/components/InputPrompt.test.tsx
    • Updated setText mock to accept cursorPosition for comprehensive testing of input state.
    • Removed setShowSuggestions from mock as its functionality is now derived.
    • Refactored useCommandCompletion mock to accept an object with an active property.
    • Added new test suite for 'History Navigation and Completion Suppression' covering various scenarios like cursor movement, suppression, and re-enabling completion.
  • packages/cli/src/ui/components/InputPrompt.tsx
    • Renamed justNavigatedHistory state to suppressCompletion for improved clarity.
    • Modified useCommandCompletion to accept an options object, including an active flag derived from suppressCompletion.
    • Updated customSetTextAndResetCompletionSignal to accept cursorPosition and set suppressCompletion to true.
    • Adjusted useEffect to reset completion states based on suppressCompletion and added currentCursorOffset to useInputHistory props.
    • Integrated setSuppressCompletion into mouse click and paste event handlers.
    • Implemented logic within handleInput to determine and set suppressCompletion based on key presses (history navigation, cursor movement, escape) while allowing suggestion navigation to proceed.
  • packages/cli/src/ui/components/shared/TextInput.test.tsx
    • Modified setText mocks to correctly handle the new optional cursorPosition parameter.
  • packages/cli/src/ui/components/shared/text-buffer.ts
    • Extended TextBufferAction type for set_text to include an optional cursorPosition.
    • Updated textBufferReducerLogic to process and apply the cursorPosition when setting new text.
    • Modified the setText function in useTextBuffer and its interface to accept the optional cursorPosition.
  • packages/cli/src/ui/hooks/useCommandCompletion.test.tsx
    • Updated useCommandCompletion test utility to accept an active parameter within its options object.
    • Removed setShowSuggestions from test mocks and adjusted test calls to match the new object-based parameter structure.
    • Added waitFor to assertions for asynchronous completion logic.
  • packages/cli/src/ui/hooks/useCommandCompletion.tsx
    • Removed setShowSuggestions from UseCommandCompletionReturn interface and internal state management.
    • Refactored useCommandCompletion to accept an options object with an active flag.
    • Modified useAtCompletion, useSlashCompletion, and usePromptCompletion to respect the new active flag.
    • Made showSuggestions a derived property based on the active state and other completion conditions.
  • packages/cli/src/ui/hooks/useCompletion.ts
    • Removed showSuggestions and setShowSuggestions from the UseCompletionReturn interface and internal state.
  • packages/cli/src/ui/hooks/useInputHistory.test.ts
    • Added currentCursorOffset to useInputHistory props in tests.
    • Updated mockOnChange assertions to expect cursorPosition arguments.
    • Added new tests to verify intelligent cursor offset restoration during history navigation, including handling of edited history items and immediate back-and-forth navigation.
  • packages/cli/src/ui/hooks/useInputHistory.ts
    • Added currentCursorOffset to UseInputHistoryProps and cursorPosition to the onChange callback.
    • Introduced previousHistoryIndexRef and historyCacheRef to manage history state and associated cursor positions.
    • Implemented a navigateTo helper function to centralize history navigation logic, including caching and restoring text and cursor offsets intelligently.
    • Updated navigateUp and navigateDown to utilize the new navigateTo function for consistent behavior.
  • packages/cli/src/ui/hooks/useReverseSearchCompletion.tsx
    • Removed showSuggestions and setShowSuggestions from internal state and return interface.
    • Made showSuggestions a derived property based on reverseSearchActive and suggestion availability.
Activity
  • The pull request was created by jacob314.
  • The author indicated that the PR aims to fix history navigation and eliminate flicker when loading suggestions.
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 significant user experience improvements to the input prompt, focusing on history navigation and autocomplete behavior. The refactoring of the useInputHistory hook to use a caching mechanism is a major enhancement, providing robust handling of edits and intelligent cursor position restoration during history navigation. Additionally, the changes to useCommandCompletion to eliminate suggestion flickering and to conditionally suppress autocomplete during navigation or cursor movement are well-implemented. The new logic is clear, the state management is simplified, and the added tests are comprehensive. Overall, this is an excellent polish that greatly improves the interactivity and feel of the input prompt.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Size Change: +3.14 kB (+0.01%)

Total Size: 23.7 MB

Filename Size Change
./bundle/gemini.js 23.7 MB +3.14 kB (+0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Feb 3, 2026
@jacob314 jacob314 force-pushed the fix_history_navigation_4 branch from b33224c to f148f5d Compare February 5, 2026 09:50
@jacob314 jacob314 requested a review from galz10 February 5, 2026 17:26
@jacob314 jacob314 added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit 8efae71 Feb 5, 2026
27 checks passed
@jacob314 jacob314 deleted the fix_history_navigation_4 branch February 5, 2026 20:48
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
aswinashok44 pushed a commit to aswinashok44/gemini-cli that referenced this pull request Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ and / completion feels wonky when autocomplete/navigation

3 participants