fix: preserve prompt text when cancelling streaming (#21103)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
nityam
2026-03-11 04:05:04 +05:30
committed by GitHub
parent d63053cb59
commit e22d9917b7
2 changed files with 49 additions and 4 deletions
+9 -2
View File
@@ -1220,8 +1220,15 @@ Logging in with Google... Restarting Gemini CLI to continue.
return;
}
// If cancelling (shouldRestorePrompt=false), never modify the buffer
// User is in control - preserve whatever text they typed, pasted, or restored
if (!shouldRestorePrompt) {
return;
}
// Restore the last message when shouldRestorePrompt=true
const lastUserMessage = inputHistory.at(-1);
let textToSet = shouldRestorePrompt ? lastUserMessage || '' : '';
let textToSet = lastUserMessage || '';
const queuedText = getQueuedMessagesText();
if (queuedText) {
@@ -1229,7 +1236,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
clearQueue();
}
if (textToSet || !shouldRestorePrompt) {
if (textToSet) {
buffer.setText(textToSet);
}
},