Skip to content

Conversation

@ManojINaik
Copy link

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

  • Added STASH_PROMPT and POP_STASH commands to the Command enum in keyBindings.ts
  • Created usePromptStash hook to manage stashed prompt state with stash(), pop(), hasStash, and clear() methods
  • Integrated the hook in Composer.tsx and passed it to InputPrompt.tsx
  • Added key handlers in InputPrompt.tsx for the new commands
  • Added visual indicator (📌) in the prompt prefix when something is stashed

Design decisions

  • Single stash slot: Only one prompt can be stashed at a time (overwrites previous)
  • Swap behavior: If you press Ctrl+Y while there's text in the input, it swaps with the stashed text
  • Empty input handling: Empty or whitespace-only input is not stashed

Related Issues

Related to improving user input workflow and productivity.

How to Validate

  1. Run the CLI: npm run start
  2. Type some text (e.g., "explain how React hooks work")
  3. Press Ctrl+Z - observe:
    • Input field clears
    • 📌 indicator appears before the > prompt
  4. Type something else and submit it
  5. Press Ctrl+Y - observe:
    • Original text is restored
    • 📌 indicator disappears

Edge cases to test:

  • Stashing empty input (should do nothing)
  • Stashing whitespace-only input (should do nothing)
  • Pressing Ctrl+Y when nothing is stashed (should do nothing)
  • Pressing Ctrl+Y with current text (should swap)

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any) - None
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

- 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
@ManojINaik ManojINaik requested a review from a team as a code owner December 25, 2025 19:44
@google-cla
Copy link

google-cla bot commented Dec 25, 2025

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
Contributor

Summary of Changes

Hello @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: Prompt Stashing: Introduces the ability to temporarily save the current input, send a different prompt, and then restore the stashed text. This is useful for interrupting complex prompts with quick questions.
  • Key Bindings: Ctrl+Z stashes the current input (saves and clears), and Ctrl+Y pops the stashed input (restores it, with swap functionality).
  • Visual Indicator: A 📌 emoji now appears before the prompt when there is stashed input, providing a clear visual cue.
  • Implementation Details: A new usePromptStash React hook manages the stashed prompt state. New STASH_PROMPT and POP_STASH commands were added to keyBindings.ts and integrated into Composer.tsx and InputPrompt.tsx.
  • Design Decisions: The feature supports a single stash slot (overwriting previous stashes), includes swap behavior when popping with existing input, and ignores empty or whitespace-only input for stashing.

🧠 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 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 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.

| 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` |
Copy link

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.

Copy link
Author

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
Copy link

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.

Copy link
Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants