From e750da987d7e7a2be5e6e7bf6e4d2302d187a8e2 Mon Sep 17 00:00:00 2001 From: hritan <48129645+hritan@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:05:48 +0000 Subject: [PATCH] chore: migrate console.error in useGeminiStream (#12157) Co-authored-by: Hriday Taneja --- packages/cli/src/ui/hooks/useGeminiStream.test.tsx | 9 +++++---- packages/cli/src/ui/hooks/useGeminiStream.ts | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/ui/hooks/useGeminiStream.test.tsx b/packages/cli/src/ui/hooks/useGeminiStream.test.tsx index ae3566feba..1c7a28e231 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.test.tsx +++ b/packages/cli/src/ui/hooks/useGeminiStream.test.tsx @@ -33,6 +33,7 @@ import { ToolErrorType, ToolConfirmationOutcome, tokenLimit, + debugLogger, } from '@google/gemini-cli-core'; import type { Part, PartListUnion } from '@google/genai'; import type { UseHistoryManagerReturn } from './useHistoryManager.js'; @@ -1708,8 +1709,8 @@ describe('useGeminiStream', () => { }); it('should handle errors gracefully when auto-approving tool calls', async () => { - const consoleSpy = vi - .spyOn(console, 'error') + const debuggerSpy = vi + .spyOn(debugLogger, 'warn') .mockImplementation(() => {}); const mockOnConfirmSuccess = vi.fn().mockResolvedValue(undefined); const mockOnConfirmError = vi @@ -1790,12 +1791,12 @@ describe('useGeminiStream', () => { expect(mockOnConfirmError).toHaveBeenCalledTimes(1); // Error should be logged - expect(consoleSpy).toHaveBeenCalledWith( + expect(debuggerSpy).toHaveBeenCalledWith( 'Failed to auto-approve tool call call2:', expect.any(Error), ); - consoleSpy.mockRestore(); + debuggerSpy.mockRestore(); }); it('should skip tool calls without confirmationDetails', async () => { diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 851ccbc0b1..fce4112735 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -35,6 +35,7 @@ import { promptIdContext, WRITE_FILE_TOOL_NAME, tokenLimit, + debugLogger, runInDevTraceSpan, } from '@google/gemini-cli-core'; import { type Part, type PartListUnion, FinishReason } from '@google/genai'; @@ -162,7 +163,7 @@ export const useGeminiStream = ( completedToolCallsFromScheduler, ); } catch (error) { - console.error( + debugLogger.warn( `Error recording completed tool call information: ${error}`, ); } @@ -1004,7 +1005,7 @@ export const useGeminiStream = ( ToolConfirmationOutcome.ProceedOnce, ); } catch (error) { - console.error( + debugLogger.warn( `Failed to auto-approve tool call ${call.request.callId}:`, error, );