From 782686bcf33052309db530ef5fe61c35622f7ba5 Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Tue, 6 May 2025 22:11:29 -0700 Subject: [PATCH] Fix edit confirmation re-submission. - This broke in [this commit](https://github.com/google-gemini/gemini-code/commit/7d13f242887f4204a2c8a0ca719e121621472db9#diff-e257a7e5e02896371ce002da8963abdb91f5c77990d38e3d2f7ea07e5b19e32eR428) --- packages/cli/src/ui/hooks/useGeminiStream.ts | 26 ++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index b7ed771e..611ea3e7 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -424,8 +424,30 @@ export const useGeminiStream = ( updateFunctionResponseUI(responseInfo, ToolCallStatus.Error); setStreamingState(StreamingState.Idle); } else { - // If accepted, set state back to Responding to wait for server execution/response - setStreamingState(StreamingState.Responding); + const tool = toolRegistry.getTool(request.name); + if (!tool) { + throw new Error( + `Tool "${request.name}" not found or is not registered.`, + ); + } + const result = await tool.execute(request.args); + const functionResponse: Part = { + functionResponse: { + name: request.name, + id: request.callId, + response: { output: result.llmContent }, + }, + }; + + const responseInfo: ToolCallResponseInfo = { + callId: request.callId, + responsePart: functionResponse, + resultDisplay: result.returnDisplay, + error: undefined, + }; + updateFunctionResponseUI(responseInfo, ToolCallStatus.Success); + setStreamingState(StreamingState.Idle); + await submitQuery(functionResponse); } };