-
Notifications
You must be signed in to change notification settings - Fork 10.2k
feat(cli): add prompt stashing with Ctrl+Z/Ctrl+Y key bindings #15561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add STASH_PROMPT and POP_STASH commands to keyBindings - Create usePromptStash hook for state management - Integrate stash functionality in InputPrompt component - Add visual indicator when prompt is stashed - Add unit tests for usePromptStash hook - Update keyMatchers tests for new commands
|
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 @ManojINaik, 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 enhances the CLI's user experience by introducing a prompt stashing mechanism. Users can now temporarily save their current input, execute other commands, and then seamlessly retrieve their original prompt, significantly improving workflow efficiency for complex interactions. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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.
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 a useful prompt stashing feature with Ctrl+Z and Ctrl+Y keybindings. While the implementation is well-structured with a new usePromptStash hook and includes updated documentation and tests, it introduces a high-severity prompt injection vulnerability. User input is stashed and restored without proper sanitization, which could allow malicious prompts to be submitted to the backend LLM. Furthermore, there's a high-severity issue in the usePromptStash hook related to potential stale state, which could lead to future bugs.
docs/cli/keyboard-shortcuts.md
Outdated
| | Delete from the cursor to the start of the line. | `Ctrl + U` | | ||
| | Clear all text in the input field. | `Ctrl + C` | | ||
| | Delete the previous word. | `Ctrl + Backspace`<br />`Cmd + Backspace` | | ||
| | Stash the current input to restore later. | `Ctrl + Z` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ctrl+Z is usually expected to be undo, not stash. This will confuse users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which would be better any suggestion please?
| if (keyMatchers[Command.POP_STASH](key)) { | ||
| const stashed = promptStash.pop(); | ||
| if (stashed) { | ||
| // If there's current input, swap it with the stash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to ask user confirmation if currentText is not empty? In this case, user is typing and Ctrl-Y might be mis-typing. Another option is to show "Swapped with stash" hint for user notice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense.
Address reviewer feedback: - Changed stash keybinding from Ctrl+Z to Ctrl+Shift+S to avoid conflict with undo - Changed pop keybinding from Ctrl+Y to Ctrl+Shift+R to be consistent - Added swap notification message when content is swapped with stash - Updated documentation
Summary
Adds a prompt stashing feature that allows users to temporarily save their current unsubmitted input, send a different prompt, and later restore the stashed text. This is useful when you're typing a complex prompt but need to quickly ask something else first.
Key bindings:
Ctrl+Z- Stash current input (saves and clears the input field)Ctrl+Y- Pop stashed input (restores it, with swap functionality)Visual indicator: A 📌 emoji appears before the prompt when something is stashed.
Details
Implementation
STASH_PROMPTandPOP_STASHcommands to the Command enum in keyBindings.tsstash(),pop(),hasStash, andclear()methodsDesign decisions
Related Issues
Related to improving user input workflow and productivity.
How to Validate
npm run startCtrl+Z- observe:>promptCtrl+Y- observe:Edge cases to test:
Pre-Merge Checklist