fix(cli): Polish shell autocomplete rendering to be a little more shell native feeling.#20931
fix(cli): Polish shell autocomplete rendering to be a little more shell native feeling.#20931
Conversation
Update the shell completion behavior to align with standard shell practices. Show common prefix as ghost text. Pressing tab once autocompletes the ghost text. Pressing tab again explicitly shows the suggestion list.
…ing space Immediately clear suggestions during render if the token range has changed, ensuring stale ghost text (e.g. 'ls ls') is never rendered.
Summary of ChangesHello, 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 for shell completion within the CLI. It addresses issues related to the visibility and interaction of suggestions, particularly when using the tab key. By introducing more precise control over when suggestions and ghost text are displayed, and by preventing stale completion data from appearing, the changes aim to make the shell prompt more intuitive and robust for users. Highlights
Changelog
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 introduces significant improvements to the shell completion experience by adding an inline 'ghost text' feature for command completions and changing the behavior of shell suggestions to be hidden by default, appearing only on Tab. It also addresses potential race conditions and UI flickering with stale suggestions by introducing a mechanism to track the validity of completion data (activeStart). However, a high-severity command injection vulnerability was identified on Windows due to missing shell escaping for file paths containing metacharacters; it is recommended to implement proper quoting for Windows paths in the escapeShellPath function to mitigate this. Additionally, one issue was found in useCommandCompletion.tsx where a condition appears to be unreachable.
| if (textToInsert === query) { | ||
| return basePromptCompletion; | ||
| } |
There was a problem hiding this comment.
This if condition appears to be unreachable. The preceding if statement on line 258 ensures that commonPrefix.length > query.length. Since textToInsert is derived from commonPrefix (it's either commonPrefix or commonPrefix + ' '), its length will always be greater than query.length. Therefore, textToInsert === query can never be true. This block of code and its preceding comment can be safely removed to improve clarity.
There was a problem hiding this comment.
if true, we should fix?
|
Size Change: +3.38 kB (+0.01%) Total Size: 25.9 MB
ℹ️ View Unchanged
|
3ca1ea4 to
49c165e
Compare
|
Cleaned up dead code and did some minor refactors using /review-frontend to de-slop the code a bit. |
…ll native feeling. (google-gemini#20931)
…ll native feeling. (google-gemini#20931)
…ll native feeling. (google-gemini#20931)
…ll native feeling. (google-gemini#20931)
…ll native feeling. (google-gemini#20931)
…ll native feeling. (google-gemini#20931)
Summary
Render shell completions as ghost text
Fixes #20930