fix(ui): Clear input prompt on Escape key press (#13335)

This commit is contained in:
Sandy Tao
2025-11-19 11:11:36 +08:00
committed by GitHub
parent c5498bbb07
commit b644f037a3
4 changed files with 138 additions and 122 deletions

View File

@@ -1050,7 +1050,7 @@ describe('useGeminiStream', () => {
simulateEscapeKeyPress();
expect(cancelSubmitSpy).toHaveBeenCalled();
expect(cancelSubmitSpy).toHaveBeenCalledWith(false);
});
it('should call setShellInputFocused(false) when escape is pressed', async () => {
@@ -1968,7 +1968,7 @@ describe('useGeminiStream', () => {
// Check that onCancelSubmit was called
await waitFor(() => {
expect(onCancelSubmitSpy).toHaveBeenCalled();
expect(onCancelSubmitSpy).toHaveBeenCalledWith(true);
});
});

View File

@@ -105,7 +105,7 @@ export const useGeminiStream = (
modelSwitchedFromQuotaError: boolean,
setModelSwitchedFromQuotaError: React.Dispatch<React.SetStateAction<boolean>>,
onEditorClose: () => void,
onCancelSubmit: () => void,
onCancelSubmit: (shouldRestorePrompt?: boolean) => void,
setShellInputFocused: (value: boolean) => void,
terminalWidth: number,
terminalHeight: number,
@@ -324,7 +324,7 @@ export const useGeminiStream = (
setIsResponding(false);
}
onCancelSubmit();
onCancelSubmit(false);
setShellInputFocused(false);
}, [
streamingState,
@@ -690,7 +690,7 @@ export const useGeminiStream = (
const handleContextWindowWillOverflowEvent = useCallback(
(estimatedRequestTokenCount: number, remainingTokenCount: number) => {
onCancelSubmit();
onCancelSubmit(true);
const limit = tokenLimit(config.getModel());