From c4c11f1d65233f31751cee65e29aa6ae3f7f2410 Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Tue, 13 May 2025 16:35:11 -0700 Subject: [PATCH] Prevent flickering on confirmation decline. - When larger confirmations were shown and then declined you'd typicaly get large chunks of content flickering upon typing or sending a subsequent request. This was primarily due to us leaving the latest confirmation as "updateable" / pending. This changeset addresses that by flushing any pending confirmation to the static container. Part of https://b.corp.google.com/issues/414196943 --- packages/cli/src/ui/hooks/useGeminiStream.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 6ff41d2f..4fcc503b 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -483,6 +483,10 @@ export const useGeminiStream = ( error: undefined, }; updateFunctionResponseUI(responseInfo, ToolCallStatus.Success); + if (pendingHistoryItemRef.current) { + addItem(pendingHistoryItemRef.current, Date.now()); + setPendingHistoryItem(null); + } setStreamingState(StreamingState.Idle); await submitQuery(functionResponse); } finally { @@ -529,6 +533,10 @@ export const useGeminiStream = ( // Update UI to show cancellation/error updateFunctionResponseUI(responseInfo, status); + if (pendingHistoryItemRef.current) { + addItem(pendingHistoryItemRef.current, Date.now()); + setPendingHistoryItem(null); + } setStreamingState(StreamingState.Idle); } };