mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(patch): cherry-pick 2c1d6f8 to release/v0.30.0-preview.4-pr-19369 to patch version v0.30.0-preview.4 and create version 0.30.0-preview.5 (#20086)
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
This commit is contained in:
@@ -93,4 +93,4 @@ backend, these Terms of Service and Privacy Notice documents apply:
|
||||
|
||||
You may opt-out from sending Gemini CLI Usage Statistics to Google by following
|
||||
the instructions available here:
|
||||
[Usage Statistics Configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/configuration.md#usage-statistics).
|
||||
[Usage Statistics Configuration](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/configuration.md#usage-statistics).
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
MessageBusType,
|
||||
IdeClient,
|
||||
CoreToolCallStatus,
|
||||
type SerializableConfirmationDetails,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { type IndividualToolCallDisplay } from '../types.js';
|
||||
|
||||
@@ -182,4 +183,44 @@ describe('ToolActionsContext', () => {
|
||||
|
||||
expect(result.current.isDiffingEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('calls local onConfirm for tools without correlationId', async () => {
|
||||
const mockOnConfirm = vi.fn().mockResolvedValue(undefined);
|
||||
const legacyTool: IndividualToolCallDisplay = {
|
||||
callId: 'legacy-call',
|
||||
name: 'legacy-tool',
|
||||
description: 'desc',
|
||||
status: CoreToolCallStatus.AwaitingApproval,
|
||||
resultDisplay: undefined,
|
||||
confirmationDetails: {
|
||||
type: 'exec',
|
||||
title: 'exec',
|
||||
command: 'ls',
|
||||
rootCommand: 'ls',
|
||||
rootCommands: ['ls'],
|
||||
onConfirm: mockOnConfirm,
|
||||
} as unknown as SerializableConfirmationDetails,
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useToolActions(), {
|
||||
wrapper: ({ children }) => (
|
||||
<ToolActionsProvider config={mockConfig} toolCalls={[legacyTool]}>
|
||||
{children}
|
||||
</ToolActionsProvider>
|
||||
),
|
||||
});
|
||||
|
||||
await act(async () => {
|
||||
await result.current.confirm(
|
||||
'legacy-call',
|
||||
ToolConfirmationOutcome.ProceedOnce,
|
||||
);
|
||||
});
|
||||
|
||||
expect(mockOnConfirm).toHaveBeenCalledWith(
|
||||
ToolConfirmationOutcome.ProceedOnce,
|
||||
undefined,
|
||||
);
|
||||
expect(mockMessageBus.publish).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,10 +18,28 @@ import {
|
||||
MessageBusType,
|
||||
type Config,
|
||||
type ToolConfirmationPayload,
|
||||
type SerializableConfirmationDetails,
|
||||
debugLogger,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { IndividualToolCallDisplay } from '../types.js';
|
||||
|
||||
type LegacyConfirmationDetails = SerializableConfirmationDetails & {
|
||||
onConfirm: (
|
||||
outcome: ToolConfirmationOutcome,
|
||||
payload?: ToolConfirmationPayload,
|
||||
) => Promise<void>;
|
||||
};
|
||||
|
||||
function hasLegacyCallback(
|
||||
details: SerializableConfirmationDetails | undefined,
|
||||
): details is LegacyConfirmationDetails {
|
||||
return (
|
||||
!!details &&
|
||||
'onConfirm' in details &&
|
||||
typeof details.onConfirm === 'function'
|
||||
);
|
||||
}
|
||||
|
||||
interface ToolActionsContextValue {
|
||||
confirm: (
|
||||
callId: string,
|
||||
@@ -125,7 +143,15 @@ export const ToolActionsProvider: React.FC<ToolActionsProviderProps> = (
|
||||
return;
|
||||
}
|
||||
|
||||
debugLogger.warn(`ToolActions: No correlationId for ${callId}`);
|
||||
// 3. Fallback: Legacy Callback
|
||||
if (hasLegacyCallback(details)) {
|
||||
await details.onConfirm(outcome, payload);
|
||||
return;
|
||||
}
|
||||
|
||||
debugLogger.warn(
|
||||
`ToolActions: No correlationId or callback for ${callId}`,
|
||||
);
|
||||
},
|
||||
[config, ideClient, toolCalls, isDiffingEnabled],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user