Skip to content

Comments

feat(ui): add source indicators to slash commands#18839

Merged
ehedlund merged 6 commits intogoogle-gemini:mainfrom
ehedlund:security
Feb 20, 2026
Merged

feat(ui): add source indicators to slash commands#18839
ehedlund merged 6 commits intogoogle-gemini:mainfrom
ehedlund:security

Conversation

@ehedlund
Copy link
Contributor

@ehedlund ehedlund commented Feb 11, 2026

Summary

This PR adds namespaces indicating a slash command's source (user, workspace, or extension). This removes ambiguity due to silent command fallthrough by clearly identifying the origin of each command.

Related Issues

Fixes https://github.com/google-gemini/maintainers-gemini-cli/issues/1218

How to Validate

  1. Start the Gemini CLI.
  2. Type / to view slash command suggestions.
  3. Observe that commands now have a namespace indicating their origin (e.g., user:...).
  4. Verify that built-in commands do not display any source label.

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

@ehedlund ehedlund requested a review from a team as a code owner February 11, 2026 19:35
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ehedlund, 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 user experience and security of slash commands by visually indicating their origin (user, project, or extension) directly within the suggestion list. This change provides critical context to users, helping them understand where commands come from and mitigating potential confusion or security concerns. Additionally, the PR includes improvements to how IDE connection files are discovered and prioritized, making the system more resilient and intelligent in complex development environments.

Highlights

  • UI Source Indicators for Slash Commands: Introduced explicit UI source indicators ([USER], [PROJECT], [EXT]) to the slash command suggestion list to enhance user awareness of command origins and prevent security risks from silent command fallthrough.
  • Command Source Definition and Propagation: Defined a CommandSource enum (user, project, extension) and added an optional source property to the SlashCommand interface. This source property is now discovered by FileCommandLoader.ts and propagated through useSlashCompletion.ts to Suggestion objects.
  • Dynamic Display of Source Tags: Implemented COMMAND_SOURCE_SUFFIX mapping and added corresponding <Text> elements to SuggestionsDisplay.tsx to visually indicate the command source in the UI.
  • Comprehensive Unit Testing: Added extensive unit tests for FileCommandLoader, useSlashCompletion, and SuggestionsDisplay to ensure correct assignment, mapping, and rendering of command sources.
  • IDE Connection File Prioritization Logic: Refined the logic for getConnectionConfigFromFile to prioritize IDE connection files based on the target PID, process aliveness, and recency (largest PID), improving robustness in multi-IDE scenarios.
Changelog
  • packages/cli/src/services/FileCommandLoader.test.ts
    • Added new test suite 'CommandSource Assignment' to verify correct assignment of CommandSource.USER, CommandSource.PROJECT, and CommandSource.EXTENSION to respective commands.
  • packages/cli/src/services/FileCommandLoader.ts
    • Imported CommandSource enum.
    • Added source: CommandSource property to the CommandDirectory interface.
    • Updated parseAndAdaptFile method signature to accept source as an argument.
    • Assigned CommandSource.USER to user command directories.
    • Assigned CommandSource.PROJECT to project command directories.
    • Assigned CommandSource.EXTENSION to extension command directories.
    • Included source when creating SlashCommand objects in parseAndAdaptFile.
  • packages/cli/src/ui/commands/types.ts
    • Defined CommandSource enum with USER, PROJECT, and EXTENSION values.
    • Added an optional source?: CommandSource property to the SlashCommand interface.
  • packages/cli/src/ui/components/SuggestionsDisplay.test.tsx
    • Imported CommandSource enum.
    • Added a new test case to verify that source tags are correctly rendered for file commands from different sources.
  • packages/cli/src/ui/components/SuggestionsDisplay.tsx
    • Imported CommandSource enum.
    • Added an optional source?: CommandSource property to the Suggestion interface.
    • Defined COMMAND_SOURCE_SUFFIX mapping for CommandSource values to their display strings.
    • Modified getFullLabel function to append the command source suffix if available.
    • Added conditional rendering for Text elements to display the command source suffix next to suggestions.
  • packages/cli/src/ui/components/snapshots/SuggestionsDisplay.test.tsx.snap
    • Updated snapshot to include rendering of source tags for file commands.
  • packages/cli/src/ui/hooks/useSlashCompletion.test.ts
    • Added a new test suite 'Command Source Information' to verify that command source is included in suggestions for user, project, and extension commands, including filtered and sub-commands.
  • packages/cli/src/ui/hooks/useSlashCompletion.ts
    • Mapped the cmd.source property from SlashCommand to the source property of the Suggestion object.
  • packages/core/src/ide/ide-connection-utils.test.ts
    • Added mocks for os.platform and process.kill in setup.
    • Added tests for getConnectionConfigFromFile to ensure fallback to different PIDs, prioritization of target PID, prioritization of alive processes, and prioritization of the newest (largest) PID among alive processes.
  • packages/core/src/ide/ide-connection-utils.ts
    • Imported isNodeError utility.
    • Defined IDE_SERVER_FILE_REGEX for parsing connection file names.
    • Refactored getConnectionConfigFromFile to use IDE_SERVER_FILE_REGEX for filtering and to call sortConnectionFiles for prioritization.
    • Added sortConnectionFiles function to sort connection files based on target PID, process aliveness, and PID value (newest first).
    • Added isPidAlive function to check if a given PID corresponds to an active process, with platform-specific handling.
Activity
  • The pull request author, ehedlund, has implemented the changes as described in the summary and details.
  • Unit tests have been added and updated to cover the new functionality and ensure correctness.
  • The author has validated the changes on MacOS using npm run.
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 successfully introduces source indicators for slash commands, enhancing user awareness of command origins. The changes are well-implemented across the file loader, UI types, and display components. I've identified one high-severity issue in SuggestionsDisplay.tsx where an inconsistency in using suggestion.label for layout calculation versus suggestion.value for rendering can lead to UI layout problems, which violates our guidelines on layout consistency. A code suggestion is provided to resolve this. The rest of the changes, including comprehensive tests, look good.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 11, 2026
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.

lgtm

@ehedlund ehedlund added this pull request to the merge queue Feb 20, 2026
Merged via the queue into google-gemini:main with commit d08b1ef Feb 20, 2026
27 of 28 checks passed
@ehedlund ehedlund deleted the security branch February 20, 2026 16:19
@jackwotherspoon
Copy link
Contributor

This is a breaking change. It breaks my non interactive (headless) mode usage of slash commands.

i.e. slash command capital.toml

prompt="""What is the capital city of {{args}}

Return just the name of city and nothing else.
"""

I previously could do the following:

gemini -p "/capital Canada"

Any automation or scripts with headless mode will break with new naming schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants