fix(cli): treat unknown slash commands as regular input instead of showing error - #17393
Conversation
|
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. |
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
|
I have signed the CLA. @googlebot I signed it. |
|
Looks like your email needs CLA, here's a more detailed scan |
My email is: skyvanguard.ia@gmail.com |
|
Right, i think |
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
a3ae8d6 to
f6e72d0
Compare
…owing error (google-gemini#17393) Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
…owing error (google-gemini#17393) Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
…owing error (google-gemini#17393) Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
…owing error (#17393) Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
…owing error (google-gemini#17393) Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
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
/-prefixed input doesn't match any registered command and MCP servers are fully loaded,handleSlashCommandreturnsfalse, allowing the input to be processed as a normal query by Gemini.MCPDiscoveryState.IN_PROGRESS), a warning is displayed since the command might exist but hasn't been registered yet.addToHistorycall 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).How it works
The routing flow in
prepareQueryForGemini(useGeminiStream.ts:449-451) already handles thefalsereturn:Comparison with #17009
This PR improves upon the approach in #17009:
Test plan
/usr/local/bin) returnfalseand don't add to history/help,/quit) continue to work normally/Helpreturnsfalse)slashCommandProcessor.test.tsxpassuseGeminiStream.test.tspass