mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
chore: migrate console.error in useGeminiStream (#12157)
Co-authored-by: Hriday Taneja <hridayt@google.com>
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user