Handle cleaning up the response text in the UI when a response stream retry occurs (#7416)

This commit is contained in:
Victor May
2025-09-03 22:00:16 -04:00
committed by Sandy Tao
parent dfa9dda1dd
commit a2a3c66e28
8 changed files with 371 additions and 140 deletions

View File

@@ -616,6 +616,9 @@ export const useGeminiStream = (
// before we add loop detected message to history
loopDetectedRef.current = true;
break;
case ServerGeminiEventType.Retry:
// Will add the missing logic later
break;
default: {
// enforces exhaustive switch-case
const unreachable: never = event;

View File

@@ -24,6 +24,7 @@ import {
getErrorStatus,
MCPServerConfig,
DiscoveredMCPTool,
StreamEventType,
} from '@google/gemini-cli-core';
import * as acp from './acp.js';
import { AcpFileSystemService } from './fileSystemService.js';
@@ -269,8 +270,12 @@ class Session {
return { stopReason: 'cancelled' };
}
if (resp.candidates && resp.candidates.length > 0) {
const candidate = resp.candidates[0];
if (
resp.type === StreamEventType.CHUNK &&
resp.value.candidates &&
resp.value.candidates.length > 0
) {
const candidate = resp.value.candidates[0];
for (const part of candidate.content?.parts ?? []) {
if (!part.text) {
continue;
@@ -290,8 +295,8 @@ class Session {
}
}
if (resp.functionCalls) {
functionCalls.push(...resp.functionCalls);
if (resp.type === StreamEventType.CHUNK && resp.value.functionCalls) {
functionCalls.push(...resp.value.functionCalls);
}
}
} catch (error) {