fix: preserve prompt text when cancelling streaming #21103
fix: preserve prompt text when cancelling streaming #21103jacob314 merged 2 commits intogoogle-gemini:mainfrom
Conversation
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 improves the user experience by preventing the loss of user-typed prompt text when streaming operations are cancelled. Previously, cancelling a stream would inadvertently clear the input buffer, leading to frustration. The updated logic ensures that the user's input is always retained, giving them full control over their prompt regardless of streaming status. Highlights
Changelog
Activity
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
|
|
You already have 7 pull requests open. Please work on getting existing PRs merged before opening more. |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where user input in the prompt is lost when cancelling a streaming response. The proposed fix correctly modifies the cancellation handler to preserve the text buffer, preventing data loss. The accompanying test changes validate the new behavior and include a regression test to prevent this issue in the future. The implementation is sound and effectively resolves the reported bug.
|
@jacob314 the pr is ready for review, i have tested it the issue is solved by this pr, thanks for re opening! |
|
hey @jacob314 @scidomino could you please rerun the failed job? It looks like a timeout issue unrelated to my changes. thanks! |
|
rerunning |
thanks @scidomino @jacob314 !! |

Summary
Fixes issue #13387 where pressing Escape to cancel streaming would delete any newly entered prompt text. The fix ensures prompts are never removed when cancelling, preserving user-entered text regardless of content.
Details
Previously, when cancelling streaming (
onCancelSubmit(false)), the buffer was always cleared to an empty string, even if the user had typed new text. This was frustrating because users would type a new prompt while waiting for a response, then lose it when pressing Escape.The fix changes the cancellation logic to never modify the buffer when cancelling - it simply returns early, preserving whatever text the user has typed, pasted, or restored. This aligns with the principle that users are in control of their prompts.
Changes:
cancelHandlerRefinAppContainer.tsxto return early whenshouldRestorePrompt=false, never touching the bufferRelated Issues
Fixes #13387
How to Validate
Edge cases to verify:
Pre-Merge Checklist