Skip to content

feat(cli): add shortcuts to open @ mentions in editor or file browser - #25060

Closed
Oerum wants to merge 22 commits into
google-gemini:mainfrom
Oerum:open-folder-file
Closed

feat(cli): add shortcuts to open @ mentions in editor or file browser#25060
Oerum wants to merge 22 commits into
google-gemini:mainfrom
Oerum:open-folder-file

Conversation

@Oerum

@Oerum Oerum commented Apr 9, 2026

Copy link
Copy Markdown

Summary

This PR adds keyboard shortcuts to the @ mention completion list, allowing users to directly open the selected file/folder in their editor (Ctrl+X) or file browser (Ctrl+Shift+X). It improves navigation speed and provides clear visual hints in the UI for these new actions.

Details

  • Utility Additions: Introduced an openDirectory function in editorUtils.ts to complement openFileInEditor.
  • Hook Upgrades: Enhanced useAtCompletion to return explicit mentionTargetKind ('file' or 'directory') and absolute mentionTargetPath so the UI knows how to process the selected item.
  • UI Integration:
    • Updated InputPrompt to handle the new Command.OPEN_SELECTED_MENTION and Command.OPEN_SELECTED_MENTION_LOCATION events.
    • Provided visual hints for these shortcuts directly inside the SuggestionsDisplay footer.
    • Added warning hint if the selected target is not a filesystem entity (e.g. agent).
  • Keybindings: Handled the overlap between the legacy Ctrl+X command (which opened the prompt editor) and the new contextual action. When the @ suggestion window is active, it now strictly targets the mention, providing a hint about the legacy action if attempted inappropriately.

Related Issues

Closes #20500

How to Validate

  1. Launch gemini-cli.
  2. Type @ to trigger the mention list, or @src/ to search inside a folder.
  3. Use Up/Down arrows to highlight a file or directory.
  4. Press Ctrl+X to see it open in the configured external editor (for files) or default file explorer (for directories).
  5. Press Ctrl+Shift+X to open the containing folder of the selected file.
  6. Verify that Ctrl+X when the suggestion list is NOT active still correctly opens the external editor for the current prompt.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Implemented suggest.openSelectedMention (Ctrl+X) and suggest.openSelectedMentionLocation (Ctrl+Shift+X) to allow users to quickly open files or directories directly from the @ mention suggestion list.

Key changes:
- Added openDirectory utility in editorUtils.ts.
- Updated useAtCompletion hook to provide path and kind metadata.
- Enhanced InputPrompt to handle the new commands and open the correct targets.
- Added visual hints for these shortcuts in SuggestionsDisplay.
- Updated documentation and unit tests across the CLI package.
@Oerum
Oerum requested review from a team as code owners April 9, 2026 19:50
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces keyboard-based navigation shortcuts for @ mention targets within the CLI. By allowing users to quickly open files or directories directly from the suggestion list, it streamlines the workflow for interacting with project resources. The changes include backend utility updates, UI feedback improvements, and robust keybinding management to handle command overlaps.

Highlights

  • New Keyboard Shortcuts: Added Ctrl+X to open the selected @ mention target in an editor and Ctrl+Shift+X to open its containing folder in the file browser.
  • UI Enhancements: Updated the suggestions display to show visual hints for these new shortcuts when a valid filesystem target is selected.
  • Context-Aware Navigation: Improved @ mention completion logic to distinguish between files and directories, ensuring appropriate opening behavior.
  • Legacy Command Handling: Refined the behavior of the legacy Ctrl+X command to prioritize mention selection when the suggestion list is active, while maintaining its original functionality otherwise.
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.

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.

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

Copy link
Copy Markdown
Contributor

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 new keyboard shortcuts to open file and folder mentions directly from the suggestion list. Users can now use Ctrl+X to open a selected file in their preferred editor (or a folder in the file browser) and Ctrl+Shift+X to open the containing directory. The changes include updates to the InputPrompt and SuggestionsDisplay components to support these actions and display relevant hints, enhancements to the useAtCompletion hook to provide necessary path metadata, and the addition of a new openDirectory utility. Documentation and test suites have been updated to reflect these improvements. I have no feedback to provide.

@gemini-cli gemini-cli Bot added priority/p3 Backlog - a good idea but not currently a priority. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 9, 2026
@spencer426

Copy link
Copy Markdown
Contributor

Thank you for your interest in contributing to the project! We are closing this PR as the associated issue was closed.

@spencer426 spencer426 closed this May 7, 2026
@sripasg sripasg added the size/l A large sized PR label Jun 2, 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 help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p3 Backlog - a good idea but not currently a priority. size/l A large sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): add mention view shortcuts

3 participants