diff options
| author | Taylor Mullen <[email protected]> | 2025-05-09 22:47:18 -0700 |
|---|---|---|
| committer | N. Taylor Mullen <[email protected]> | 2025-05-09 22:49:32 -0700 |
| commit | 090198a7d644f24c617bd35db6a287b930729280 (patch) | |
| tree | bf50e9dfe773a5a42abb32e2fc99ebc51691e1fb /packages/cli/src/ui/hooks/useGeminiStream.ts | |
| parent | 28f9a2adfaab7f92db408575833189a64e2b65de (diff) | |
Make cancel not explode.
- We were console.erroring, throwing and early aborting. Instead we now treat cancels like a normal user message and show an indicator in the UI
Fixes https://b.corp.google.com/issues/416515841
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useGeminiStream.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index de073373..3f8cee40 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -177,8 +177,6 @@ export const useGeminiStream = ( let geminiMessageBuffer = ''; for await (const event of stream) { - if (signal.aborted) break; - if (event.type === ServerGeminiEventType.Content) { if ( pendingHistoryItemRef.current?.type !== 'gemini' && @@ -293,6 +291,18 @@ export const useGeminiStream = ( ); setStreamingState(StreamingState.WaitingForConfirmation); return; // Wait for user confirmation + } else if (event.type === ServerGeminiEventType.UserCancelled) { + // Flush out existing pending history item. + if (pendingHistoryItemRef.current) { + addItem(pendingHistoryItemRef.current, userMessageTimestamp); + setPendingHistoryItem(null); + } + addItem( + { type: 'info', text: 'User cancelled the request.' }, + userMessageTimestamp, + ); + setStreamingState(StreamingState.Idle); + return; // Stop processing the stream } } // End stream loop |
