Skip to content

Improve altName completion behavior in slash commands#4227

Merged
scottdensmore merged 8 commits intogoogle-gemini:mainfrom
Lee-WonJun:feature/issue-4201
Jul 15, 2025
Merged

Improve altName completion behavior in slash commands#4227
scottdensmore merged 8 commits intogoogle-gemini:mainfrom
Lee-WonJun:feature/issue-4201

Conversation

@Lee-WonJun
Copy link
Contributor

TLDR

Fix altName commands (like /?) to execute immediately instead of showing autocomplete suggestions. When users type a complete altName like /? or /usage and press Enter, the command now executes directly rather than requiring a second Enter keypress.

Dive Deeper

Previously, typing /? (an altName for /help) would show an autocomplete suggestion for /help instead of executing the command immediately. This created a confusing UX where users had to press Enter twice: /? → Enter → /help → Enter.

The fix involves two key changes:

  • If a user partially types an altName (e.g. /usag), suggestions should continue to appear — this is intentional.
  • However, if a full altName is typed (like /? or /usage), it should behave exactly the same as typing a full command name and execute immediately without suggestions.

This change ensures consistency between full name matches and full altName matches.

1. Perfect Match Logic

The completion logic was updated to treat full altName matches the same as full command name matches.
Previously, the perfect match logic only checked s.name === partial. Now, it also checks s.altName === partial.
This simple expansion ensures that full altName inputs (like /?) are recognized as exact matches and trigger immediate command execution without further interaction.

2. Test Coverage for altName Behavior

Test cases were added and updated to cover this new behavior:

  • Full altNames like /? and /usage execute immediately and do not show suggestions.
  • Partial altNames like /usag still show autocomplete suggestions as intended.

Testing Matrix

🍏 🪟 🐧
npm run ✅(WSL)
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Fixes #4201

Video Explanation

31.mp4

The left shows the original behavior, the right shows the fix.

  1. First, when partially typing an altName (like /usa), suggestions appear as expected.
  2. Second and third, when fully typing /usage or /?, the original behavior doesn't execute the command on Enter — it turns into a suggestion instead.

This feels unintended because:
Typing "/?" + Enter changes it to a suggestion,
but typing "/? " + Enter runs the command directly.
That inconsistency seems wrong to me.

@Lee-WonJun Lee-WonJun requested a review from a team as a code owner July 15, 2025 14:47
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.

Summary of Changes

Hello @Lee-WonJun, 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 refines the behavior of slash command completion by ensuring that exact matches for alternative command names (altNames) trigger immediate command execution, aligning their behavior with primary command names. This change significantly improves the user experience by eliminating an unnecessary second Enter keypress for known altNames.

Highlights

  • Improved AltName Behavior: The core logic for command completion has been updated to treat fully typed alternative command names (altNames) as perfect matches. This means that when a user types a complete altName like /usage or /? and presses Enter, the command will now execute immediately instead of displaying autocomplete suggestions, streamlining the user experience.
  • Enhanced Test Coverage: New integration and unit tests have been added and existing ones modified to thoroughly validate the new altName behavior. Tests now explicitly confirm that full altName inputs result in no suggestions, while partial altName inputs continue to correctly provide relevant autocomplete suggestions.
  • Bug Fix: This pull request directly addresses and fixes the issue where users previously had to press Enter twice to execute a command when typing a complete altName, resolving a confusing user experience inconsistency.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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 correctly implements the desired behavior for altName command completion, ensuring that full altName matches execute immediately. The core logic change is sound. My review focuses on improving the test suite's maintainability and correctness. I've identified duplicated test logic that could be refactored using it.each for better maintainability, and a test assertion that needs to be updated to reflect the addition of a new mock command. Addressing these points will make the tests more robust and easier to manage in the future.

@gemini-cli gemini-cli bot added kind/bug priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality labels Jul 15, 2025
@Lee-WonJun Lee-WonJun force-pushed the feature/issue-4201 branch from 2c89281 to 1da8267 Compare July 15, 2025 14:58
@gemini-cli gemini-cli bot added area/ux priority/p2 Important but can be addressed in a future release. and removed area/core Issues related to User Interface, OS Support, Core Functionality priority/p1 Important and should be addressed in the near term. labels Jul 15, 2025
Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

Thank you for this polish! The previous behavior was annoying and this is the sort of pull request that is really nicely self contained and easy for us to review and approve.
lgtm

Copy link
Contributor

@scottdensmore scottdensmore left a comment

Choose a reason for hiding this comment

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

Approved

@scottdensmore scottdensmore added this pull request to the merge queue Jul 15, 2025
Merged via the queue into google-gemini:main with commit ec5e9d1 Jul 15, 2025
10 checks passed
thacio added a commit to thacio/auditaria that referenced this pull request Jul 20, 2025
galz10 pushed a commit that referenced this pull request Jul 22, 2025
JunYang-tes pushed a commit to JunYang-tes/gemini-cli.nvim that referenced this pull request Aug 9, 2025
involvex pushed a commit to involvex/gemini-cli that referenced this pull request Sep 11, 2025
reconsumeralization pushed a commit to reconsumeralization/gemini-cli that referenced this pull request Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/? does not execute /help as expected

3 participants