chore: migrate console.error in useGeminiStream (#12157)

Co-authored-by: Hriday Taneja <hridayt@google.com>
This commit is contained in:
hritan
2025-10-28 19:05:48 +00:00
committed by GitHub
parent 7e987113a2
commit e750da987d
2 changed files with 8 additions and 6 deletions

View File

@@ -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 () => {

View File

@@ -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,
);