From 3db2a796ec7c3aeba731da7b0f99e41c5c103d2b Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Tue, 22 Apr 2025 09:07:19 -0400 Subject: [PATCH] Fix Tool -> Text -> Confirmation bu that results in disordered history - We weren't reseting the tool group inbetween content which meant we'd start a new group on the first tool call, and if regular textual content followed it'd effectively close that group; however, we weren't updating our state to really close that group. Meaning, any subsequent tool calls or confirmations would get grouped with the original grouping. - When we see textual content from Gemini we now reset the tool call group. Fixes https://b.corp.google.com/issues/412605330 --- packages/cli/src/ui/hooks/useGeminiStream.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 5baebe09..b8d13269 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -217,6 +217,11 @@ export const useGeminiStream = ( // For content events, accumulate the text and update an existing message or create a new one currentGeminiText += event.value; + // Reset group because we're now adding a user message to the history. If we didn't reset the + // group here then any subsequent tool calls would get grouped before this message resulting in + // a misordering of history. + currentToolGroupId = null; + if (!hasInitialGeminiResponse) { // Create a new Gemini message if this is the first content event hasInitialGeminiResponse = true;