fix(ui): Clear input prompt on Escape key press#13335
Conversation
Summary of ChangesHello @SandyTao520, 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 resolves a user experience issue in the CLI where pressing the Escape key during an active request would inadvertently repopulate the input field with the last prompt. The changes introduce a more granular control over prompt restoration upon cancellation, ensuring that user-initiated cancellations clear the input while system-initiated cancellations continue to restore the prompt for user convenience. This improves the intuitiveness of the UI's cancellation behavior. 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 addresses a UX regression where pressing the Escape key would restore the previous prompt instead of clearing it. The fix introduces a shouldRestorePrompt flag to the onCancelSubmit handler, allowing differentiation between user-initiated cancellations (like pressing Escape) and system-initiated cancellations (like context window overflows). The changes in AppContainer.tsx and useGeminiStream.ts correctly implement this logic, ensuring that the Escape key now clears the input field while preserving the prompt restoration behavior for system events. The implementation is sound and effectively resolves the issue.
|
Size Change: +196 B (0%) Total Size: 20.6 MB ℹ️ View Unchanged
|
|
I'm seeing this restoring the wrong prompt when the prompt is rejected. |
|
From Gemini CLI: I have reviewed the functional changes to However, I've identified a few issues with the tests:
The default Overall, the approach is sound, but addressing the test issues will significantly improve stability and adherence to best practices. |
Removes fixed waits and improves test stability per review feedback. Also fixes waitFor usage inside act and abstracts positional argument access.
|
@SandyTao520 thank you this works! |

TLDR
This PR fixes a UX regression where pressing the Escape key to cancel a request would inadvertently restore the previous user prompt to the input buffer. This change ensures that pressing Escape clears the input field, while retaining the behavior of restoring the prompt for system-initiated cancellations like context window overflows.
Dive Deeper
The regression was introduced in #10719 ("feat(sessions): add resuming to geminiChat").
That PR updated the
cancelHandlerRefinAppContainer.tsxto automatically populate the input buffer with the last user message whenever a request was cancelled. The intention was to help users recover their prompt if a request failed or was cancelled due to system limits (like context overflow). However, this logic was applied unconditionally to all cancellation events, including when the user explicitly pressed the Escape key, leading to the frustrating experience of having to clear the prompt manually.This PR refactors the
onCancelSubmithandler to accept ashouldRestorePromptflag:onCancelSubmit(false), ensuring the input is cleared.onCancelSubmit(true)(or defaults to true), preserving the user's prompt for editing.Reviewer Test Plan
Escape Key:
Escape.Context Overflow:
Testing Matrix
Linked issues / bugs
Resolves #13306