diff options
| author | shishu314 <[email protected]> | 2025-08-06 15:19:10 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-06 19:19:10 +0000 |
| commit | 1f0ad865444c07481385c39b272f9ec2b94d41b9 (patch) | |
| tree | 76d143c9399c16997666183c36903c95ac079e0f /packages/cli/src/ui/App.tsx | |
| parent | 6133bea388a2de69c71a6be6f1450707f2ce4dfb (diff) | |
fix: Restore user input when the user cancels response (#5601)
Co-authored-by: Shi Shu <[email protected]>
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/App.tsx')
| -rw-r--r-- | packages/cli/src/ui/App.tsx | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index 66396c36..f2dcc79e 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -486,6 +486,24 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => { setGeminiMdFileCount, ); + const buffer = useTextBuffer({ + initialText: '', + viewport: { height: 10, width: inputWidth }, + stdin, + setRawMode, + isValidPath, + shellModeActive, + }); + + const [userMessages, setUserMessages] = useState<string[]>([]); + + const handleUserCancel = useCallback(() => { + const lastUserMessage = userMessages.at(-1); + if (lastUserMessage) { + buffer.setText(lastUserMessage); + } + }, [buffer, userMessages]); + const { streamingState, submitQuery, @@ -506,6 +524,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => { modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError, refreshStatic, + handleUserCancel, ); // Input handling @@ -519,15 +538,6 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => { [submitQuery], ); - const buffer = useTextBuffer({ - initialText: '', - viewport: { height: 10, width: inputWidth }, - stdin, - setRawMode, - isValidPath, - shellModeActive, - }); - const { handleInput: vimHandleInput } = useVim(buffer, handleFinalSubmit); const pendingHistoryItems = [...pendingSlashCommandHistoryItems]; pendingHistoryItems.push(...pendingGeminiHistoryItems); @@ -607,7 +617,6 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => { }, [config, config.getGeminiMdFileCount]); const logger = useLogger(); - const [userMessages, setUserMessages] = useState<string[]>([]); useEffect(() => { const fetchUserMessages = async () => { |
