Skip to content

fix(cli): treat unknown slash commands as regular input instead of showing error - #17393

Merged
scidomino merged 2 commits into
google-gemini:mainfrom
skyvanguard:fix/slash-command-file-paths
Feb 18, 2026
Merged

fix(cli): treat unknown slash commands as regular input instead of showing error#17393
scidomino merged 2 commits into
google-gemini:mainfrom
skyvanguard:fix/slash-command-file-paths

Conversation

@skyvanguard

Copy link
Copy Markdown
Contributor

Summary

Fixes #17003

File paths starting with / (e.g., /usr/local/bin, /etc/config) are incorrectly parsed as slash commands, showing an "Unknown command" error instead of being sent to Gemini as regular text input.

Changes

  • Unknown commands now fall through as regular input: When a /-prefixed input doesn't match any registered command and MCP servers are fully loaded, handleSlashCommand returns false, allowing the input to be processed as a normal query by Gemini.
  • MCP loading edge case handled: If MCP servers are still discovering commands (MCPDiscoveryState.IN_PROGRESS), a warning is displayed since the command might exist but hasn't been registered yet.
  • History duplication fix: Moved addToHistory call to after command parsing, preventing the input from being added to history when it's going to be treated as regular text (the caller handles history in that case).
  • Dead code removal: Removed unreachable "Unknown command" error block at the end of the try block.

How it works

The routing flow in prepareQueryForGemini (useGeminiStream.ts:449-451) already handles the false return:

if (isSlashCommand(query)) {
  const result = await handleSlashCommand(query);
  if (result !== false) return; // Command was handled
}
// Falls through to send as regular Gemini query

Comparison with #17009

This PR improves upon the approach in #17009:

  • Properly handles the MCP loading state instead of removing the check entirely
  • Avoids history duplication by restructuring the flow
  • All existing tests pass with no CI failures

Test plan

  • Unknown commands (e.g., /usr/local/bin) return false and don't add to history
  • Unknown commands during MCP loading show appropriate warning
  • Known commands (e.g., /help, /quit) continue to work normally
  • Case-sensitive matching preserved (/Help returns false)
  • All 36 tests in slashCommandProcessor.test.tsx pass
  • All 70 tests in useGeminiStream.test.ts pass
  • TypeScript compilation: 0 errors

@skyvanguard
skyvanguard requested a review from a team as a code owner January 23, 2026 17:11
@google-cla

google-cla Bot commented Jan 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @skyvanguard, 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 command-line interface's behavior when encountering inputs that resemble slash commands but are not recognized. The primary goal is to correctly interpret file paths and similar inputs as regular text for the Gemini model, rather than displaying an error. It also introduces better handling for cases where commands might be pending discovery by MCP servers, providing a more informative user experience.

Highlights

  • Improved Unknown Command Handling: Unknown slash commands (e.g., file paths) are now treated as regular text input for Gemini if MCP servers are fully loaded, preventing erroneous 'Unknown command' messages.
  • MCP Loading State Awareness: If an unknown command is entered while MCP servers are still discovering commands, a warning is displayed, indicating that the command might exist but hasn't been registered yet.
  • History Duplication Prevention: The logic for adding input to history has been refactored to occur after command parsing, ensuring that inputs treated as regular text are not duplicated in the history.
  • Dead Code Removal: An unreachable 'Unknown command' error block has been removed, streamlining the command processing logic.
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.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. 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 Jan 23, 2026

@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 effectively addresses the issue of file paths being misinterpreted as slash commands. The core change to treat unknown commands as regular input by returning false from handleSlashCommand is correct and well-implemented. I appreciate the thoughtful handling of the edge case where MCP servers are still loading, providing a helpful warning to the user instead of silently failing. The accompanying fixes for history duplication and removal of dead code improve the overall quality and robustness of the command processor. The test suite has been updated comprehensively to cover the new logic. Overall, this is a solid improvement.

@skyvanguard skyvanguard reopened this Jan 23, 2026
@skyvanguard

Copy link
Copy Markdown
Contributor Author

I have signed the CLA. @googlebot I signed it.

@Adib234

Adib234 commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Looks like your email needs CLA, here's a more detailed scan

-- | -- | --
skyvanguard |   | Ok: 🇨
  | skyvanguard@gmail.com | Need CLA
  | noreply@anthropic.com | Need CLA

@skyvanguard

Copy link
Copy Markdown
Contributor Author

Looks like your email needs CLA, here's a more detailed scan

-- | -- | --
skyvanguard |   | Ok: 🇨
  | skyvanguard@gmail.com | Need CLA
  | noreply@anthropic.com | Need CLA

My email is: skyvanguard.ia@gmail.com

@Adib234

Adib234 commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

Right, i think skyvanguard@gmail.com | Need CLA means that you need to get CLA for your email

File paths starting with '/' (e.g., /usr/local/bin) were incorrectly
parsed as slash commands, showing an error instead of being sent to
Gemini as regular text.

Now, when a command is not found in the registry:
- If MCP servers are still loading: show a warning (command might exist)
- Otherwise: return false so the input is processed as regular text

This also fixes a potential history duplication issue by moving
addToHistory after command parsing, and removes unreachable dead code.

Fixes #17003
@skyvanguard
skyvanguard force-pushed the fix/slash-command-file-paths branch from a3ae8d6 to f6e72d0 Compare January 29, 2026 22:36
@scidomino
scidomino enabled auto-merge February 18, 2026 21:18
@scidomino
scidomino added this pull request to the merge queue Feb 18, 2026
Merged via the queue into google-gemini:main with commit 178388d Feb 18, 2026
27 checks passed
@skyvanguard
skyvanguard deleted the fix/slash-command-file-paths branch February 18, 2026 22:30
tripleyoung pushed a commit to tripleyoung/gemini-cli that referenced this pull request Feb 27, 2026
…owing error (google-gemini#17393)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
tripleyoung pushed a commit to tripleyoung/gemini-cli that referenced this pull request Feb 27, 2026
…owing error (google-gemini#17393)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…owing error (google-gemini#17393)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
cocosheng-g pushed a commit that referenced this pull request May 6, 2026
…owing error (#17393)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
software-0ficial pushed a commit to software-0ficial/gemini-cli that referenced this pull request Jul 9, 2026
…owing error (google-gemini#17393)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
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/p2 Important but can be addressed in a future release. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Absolute file paths at the start of input are incorrectly parsed as slash commands

4 participants