@google/gemini-cli 0.12.0-nightly.20251027.cb0947c5 → 0.12.0-preview.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/dist/package.json +2 -2
- package/dist/src/commands/extensions/disable.d.ts +1 -1
- package/dist/src/commands/extensions/disable.js +5 -4
- package/dist/src/commands/extensions/disable.js.map +1 -1
- package/dist/src/commands/extensions/enable.d.ts +1 -1
- package/dist/src/commands/extensions/enable.js +3 -2
- package/dist/src/commands/extensions/enable.js.map +1 -1
- package/dist/src/commands/extensions/install.js +2 -1
- package/dist/src/commands/extensions/install.js.map +1 -1
- package/dist/src/commands/extensions/install.test.js +1 -0
- package/dist/src/commands/extensions/install.test.js.map +1 -1
- package/dist/src/commands/extensions/link.js +2 -1
- package/dist/src/commands/extensions/link.js.map +1 -1
- package/dist/src/commands/extensions/list.js +2 -2
- package/dist/src/commands/extensions/list.js.map +1 -1
- package/dist/src/commands/extensions/uninstall.js +2 -1
- package/dist/src/commands/extensions/uninstall.js.map +1 -1
- package/dist/src/commands/extensions/update.js +2 -2
- package/dist/src/commands/extensions/update.js.map +1 -1
- package/dist/src/commands/mcp/list.js +2 -2
- package/dist/src/commands/mcp/list.js.map +1 -1
- package/dist/src/config/config.d.ts +5 -3
- package/dist/src/config/config.js +43 -10
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +192 -171
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/extension-manager.d.ts +23 -10
- package/dist/src/config/extension-manager.js +89 -62
- package/dist/src/config/extension-manager.js.map +1 -1
- package/dist/src/config/extension.test.js +158 -74
- package/dist/src/config/extension.test.js.map +1 -1
- package/dist/src/config/extensions/extensionSettings.d.ts +3 -3
- package/dist/src/config/extensions/extensionSettings.js +74 -24
- package/dist/src/config/extensions/extensionSettings.js.map +1 -1
- package/dist/src/config/extensions/extensionSettings.test.js +145 -24
- package/dist/src/config/extensions/extensionSettings.test.js.map +1 -1
- package/dist/src/config/extensions/github.js +3 -3
- package/dist/src/config/extensions/github.js.map +1 -1
- package/dist/src/config/extensions/github.test.js +1 -1
- package/dist/src/config/extensions/github.test.js.map +1 -1
- package/dist/src/config/extensions/update.js +7 -6
- package/dist/src/config/extensions/update.js.map +1 -1
- package/dist/src/config/extensions/update.test.js +54 -31
- package/dist/src/config/extensions/update.test.js.map +1 -1
- package/dist/src/config/keyBindings.js +1 -1
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/config/policies/read-only.toml +56 -0
- package/dist/src/config/policies/write.toml +63 -0
- package/dist/src/config/policies/yolo.toml +31 -0
- package/dist/src/config/policy-engine.integration.test.js +41 -38
- package/dist/src/config/policy-engine.integration.test.js.map +1 -1
- package/dist/src/config/policy-toml-loader.d.ts +46 -0
- package/dist/src/config/policy-toml-loader.js +314 -0
- package/dist/src/config/policy-toml-loader.js.map +1 -0
- package/dist/src/config/policy-toml-loader.test.d.ts +6 -0
- package/dist/src/config/policy-toml-loader.test.js +626 -0
- package/dist/src/config/policy-toml-loader.test.js.map +1 -0
- package/dist/src/config/policy.d.ts +9 -2
- package/dist/src/config/policy.js +139 -110
- package/dist/src/config/policy.js.map +1 -1
- package/dist/src/config/policy.test.js +780 -82
- package/dist/src/config/policy.test.js.map +1 -1
- package/dist/src/config/settings.js +1 -1
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settings.test.js +17 -57
- package/dist/src/config/settings.test.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +18 -9
- package/dist/src/config/settingsSchema.js +17 -8
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/config/settingsSchema.test.js +2 -0
- package/dist/src/config/settingsSchema.test.js.map +1 -1
- package/dist/src/gemini.js +6 -17
- package/dist/src/gemini.js.map +1 -1
- package/dist/src/gemini.test.js +1 -0
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/test-utils/render.d.ts +12 -0
- package/dist/src/test-utils/render.js +28 -1
- package/dist/src/test-utils/render.js.map +1 -1
- package/dist/src/test-utils/render.test.d.ts +6 -0
- package/dist/src/test-utils/render.test.js +54 -0
- package/dist/src/test-utils/render.test.js.map +1 -0
- package/dist/src/ui/AppContainer.js +33 -22
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/AppContainer.test.js +30 -1
- package/dist/src/ui/AppContainer.test.js.map +1 -1
- package/dist/src/ui/commands/directoryCommand.js +1 -1
- package/dist/src/ui/commands/directoryCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.js +45 -1
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.test.js +64 -1
- package/dist/src/ui/commands/extensionsCommand.test.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.js +1 -1
- package/dist/src/ui/commands/memoryCommand.js.map +1 -1
- package/dist/src/ui/commands/memoryCommand.test.js +3 -1
- package/dist/src/ui/commands/memoryCommand.test.js.map +1 -1
- package/dist/src/ui/components/ConsoleSummaryDisplay.js +1 -1
- package/dist/src/ui/components/ConsoleSummaryDisplay.js.map +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.js +1 -1
- package/dist/src/ui/components/DetailedMessagesDisplay.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.test.js +4 -5
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/Footer.js +4 -3
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/Footer.test.js +83 -0
- package/dist/src/ui/components/Footer.test.js.map +1 -1
- package/dist/src/ui/components/Help.test.js +0 -1
- package/dist/src/ui/components/Help.test.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.test.js +5 -6
- package/dist/src/ui/components/ModelDialog.test.js.map +1 -1
- package/dist/src/ui/components/Notifications.js +38 -5
- package/dist/src/ui/components/Notifications.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js +11 -13
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +12 -14
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js +11 -13
- package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.test.js +2 -2
- package/dist/src/ui/components/shared/text-buffer.test.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.js +8 -29
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.test.js +90 -73
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -1
- package/dist/src/ui/contexts/SessionContext.test.js +27 -14
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -1
- package/dist/src/ui/hooks/atCommandProcessor.js +2 -2
- package/dist/src/ui/hooks/atCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useAtCompletion.test.js +32 -23
- package/dist/src/ui/hooks/useAtCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +2 -2
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.d.ts +1 -2
- package/dist/src/ui/hooks/useExtensionUpdates.js +2 -1
- package/dist/src/ui/hooks/useExtensionUpdates.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.test.js +14 -20
- package/dist/src/ui/hooks/useExtensionUpdates.test.js.map +1 -1
- package/dist/src/ui/hooks/useFlickerDetector.test.js +9 -6
- package/dist/src/ui/hooks/useFlickerDetector.test.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.test.js +45 -23
- package/dist/src/ui/hooks/useFolderTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +7 -5
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.test.js +42 -41
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -1
- package/dist/src/ui/hooks/useHistoryManager.test.js +2 -2
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistory.test.js +2 -2
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistoryStore.test.js +2 -2
- package/dist/src/ui/hooks/useInputHistoryStore.test.js.map +1 -1
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js +2 -3
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.test.js +83 -111
- package/dist/src/ui/hooks/usePhraseCycler.test.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +2 -2
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.test.js +1 -2
- package/dist/src/ui/hooks/useReactToolScheduler.test.js.map +1 -1
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +2 -2
- package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useShellHistory.test.js +40 -17
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useSlashCompletion.test.js +54 -49
- package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.test.js +48 -42
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
- package/dist/src/ui/keyMatchers.test.js +3 -3
- package/dist/src/ui/keyMatchers.test.js.map +1 -1
- package/dist/src/zed-integration/zedIntegration.d.ts +2 -2
- package/dist/src/zed-integration/zedIntegration.js +4 -6
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
7
|
-
import {
|
|
7
|
+
import { act } from 'react';
|
|
8
|
+
import { renderHook } from '../../test-utils/render.js';
|
|
8
9
|
import { useGeminiStream } from './useGeminiStream.js';
|
|
9
10
|
import { useKeypress } from './useKeypress.js';
|
|
10
11
|
import * as atCommandProcessor from './atCommandProcessor.js';
|
|
11
12
|
import { useReactToolScheduler } from './useReactToolScheduler.js';
|
|
12
|
-
import { ApprovalMode, AuthType, GeminiEventType as ServerGeminiEventType, ToolErrorType, ToolConfirmationOutcome, tokenLimit, } from '@google/gemini-cli-core';
|
|
13
|
+
import { ApprovalMode, AuthType, GeminiEventType as ServerGeminiEventType, ToolErrorType, ToolConfirmationOutcome, tokenLimit, debugLogger, } from '@google/gemini-cli-core';
|
|
13
14
|
import { MessageType, StreamingState } from '../types.js';
|
|
14
15
|
// --- MOCKS ---
|
|
15
16
|
const mockSendMessageStream = vi
|
|
@@ -378,7 +379,7 @@ describe('useGeminiStream', () => {
|
|
|
378
379
|
await capturedOnComplete(completedToolCalls);
|
|
379
380
|
}
|
|
380
381
|
});
|
|
381
|
-
await waitFor(() => {
|
|
382
|
+
await vi.waitFor(() => {
|
|
382
383
|
expect(mockMarkToolsAsSubmitted).toHaveBeenCalledTimes(1);
|
|
383
384
|
expect(mockSendMessageStream).toHaveBeenCalledTimes(1);
|
|
384
385
|
});
|
|
@@ -427,7 +428,7 @@ describe('useGeminiStream', () => {
|
|
|
427
428
|
await capturedOnComplete(cancelledToolCalls);
|
|
428
429
|
}
|
|
429
430
|
});
|
|
430
|
-
await waitFor(() => {
|
|
431
|
+
await vi.waitFor(() => {
|
|
431
432
|
expect(mockMarkToolsAsSubmitted).toHaveBeenCalledWith(['1']);
|
|
432
433
|
expect(client.addHistory).toHaveBeenCalledWith({
|
|
433
434
|
role: 'user',
|
|
@@ -510,7 +511,7 @@ describe('useGeminiStream', () => {
|
|
|
510
511
|
await capturedOnComplete(allCancelledTools);
|
|
511
512
|
}
|
|
512
513
|
});
|
|
513
|
-
await waitFor(() => {
|
|
514
|
+
await vi.waitFor(() => {
|
|
514
515
|
// The tools should be marked as submitted locally
|
|
515
516
|
expect(mockMarkToolsAsSubmitted).toHaveBeenCalledWith([
|
|
516
517
|
'cancel-1',
|
|
@@ -610,7 +611,7 @@ describe('useGeminiStream', () => {
|
|
|
610
611
|
}
|
|
611
612
|
});
|
|
612
613
|
// 5. Wait for submitQuery to be called
|
|
613
|
-
await waitFor(() => {
|
|
614
|
+
await vi.waitFor(() => {
|
|
614
615
|
expect(mockSendMessageStream).toHaveBeenCalledWith(toolCallResponseParts, expect.any(AbortSignal), 'prompt-id-4');
|
|
615
616
|
});
|
|
616
617
|
// 6. After submission, the state should remain Responding until the stream completes.
|
|
@@ -648,13 +649,13 @@ describe('useGeminiStream', () => {
|
|
|
648
649
|
result.current.submitQuery('test query');
|
|
649
650
|
});
|
|
650
651
|
// Wait for the first part of the response
|
|
651
|
-
await waitFor(() => {
|
|
652
|
+
await vi.waitFor(() => {
|
|
652
653
|
expect(result.current.streamingState).toBe(StreamingState.Responding);
|
|
653
654
|
});
|
|
654
655
|
// Simulate escape key press
|
|
655
656
|
simulateEscapeKeyPress();
|
|
656
657
|
// Verify cancellation message is added
|
|
657
|
-
await waitFor(() => {
|
|
658
|
+
await vi.waitFor(() => {
|
|
658
659
|
expect(mockAddItem).toHaveBeenCalledWith({
|
|
659
660
|
type: MessageType.INFO,
|
|
660
661
|
text: 'Request cancelled.',
|
|
@@ -720,7 +721,7 @@ describe('useGeminiStream', () => {
|
|
|
720
721
|
await act(async () => {
|
|
721
722
|
result.current.submitQuery('long running query');
|
|
722
723
|
});
|
|
723
|
-
await waitFor(() => {
|
|
724
|
+
await vi.waitFor(() => {
|
|
724
725
|
expect(result.current.streamingState).toBe(StreamingState.Responding);
|
|
725
726
|
});
|
|
726
727
|
// Cancel the request
|
|
@@ -808,7 +809,7 @@ describe('useGeminiStream', () => {
|
|
|
808
809
|
// The imperative cancel function should be called on the scheduler
|
|
809
810
|
expect(mockCancelAllToolCalls).toHaveBeenCalled();
|
|
810
811
|
// A cancellation message should be added to history
|
|
811
|
-
await waitFor(() => {
|
|
812
|
+
await vi.waitFor(() => {
|
|
812
813
|
expect(mockAddItem).toHaveBeenCalledWith(expect.objectContaining({
|
|
813
814
|
text: 'Request cancelled.',
|
|
814
815
|
}), expect.any(Number));
|
|
@@ -829,7 +830,7 @@ describe('useGeminiStream', () => {
|
|
|
829
830
|
await act(async () => {
|
|
830
831
|
await result.current.submitQuery('/memory add "test fact"');
|
|
831
832
|
});
|
|
832
|
-
await waitFor(() => {
|
|
833
|
+
await vi.waitFor(() => {
|
|
833
834
|
expect(mockScheduleToolCalls).toHaveBeenCalledWith([
|
|
834
835
|
expect.objectContaining({
|
|
835
836
|
name: 'save_memory',
|
|
@@ -849,7 +850,7 @@ describe('useGeminiStream', () => {
|
|
|
849
850
|
await act(async () => {
|
|
850
851
|
await result.current.submitQuery('/help');
|
|
851
852
|
});
|
|
852
|
-
await waitFor(() => {
|
|
853
|
+
await vi.waitFor(() => {
|
|
853
854
|
expect(mockHandleSlashCommand).toHaveBeenCalledWith('/help');
|
|
854
855
|
expect(mockScheduleToolCalls).not.toHaveBeenCalled();
|
|
855
856
|
expect(mockSendMessageStream).not.toHaveBeenCalled(); // No LLM call made
|
|
@@ -865,7 +866,7 @@ describe('useGeminiStream', () => {
|
|
|
865
866
|
await act(async () => {
|
|
866
867
|
await result.current.submitQuery('/my-custom-command');
|
|
867
868
|
});
|
|
868
|
-
await waitFor(() => {
|
|
869
|
+
await vi.waitFor(() => {
|
|
869
870
|
expect(mockHandleSlashCommand).toHaveBeenCalledWith('/my-custom-command');
|
|
870
871
|
expect(localMockSendMessageStream).not.toHaveBeenCalledWith('/my-custom-command', expect.anything(), expect.anything());
|
|
871
872
|
expect(localMockSendMessageStream).toHaveBeenCalledWith('This is the actual prompt from the command file.', expect.any(AbortSignal), expect.any(String));
|
|
@@ -882,7 +883,7 @@ describe('useGeminiStream', () => {
|
|
|
882
883
|
await act(async () => {
|
|
883
884
|
await result.current.submitQuery('/emptycmd');
|
|
884
885
|
});
|
|
885
|
-
await waitFor(() => {
|
|
886
|
+
await vi.waitFor(() => {
|
|
886
887
|
expect(mockHandleSlashCommand).toHaveBeenCalledWith('/emptycmd');
|
|
887
888
|
expect(localMockSendMessageStream).toHaveBeenCalledWith('', expect.any(AbortSignal), expect.any(String));
|
|
888
889
|
});
|
|
@@ -892,7 +893,7 @@ describe('useGeminiStream', () => {
|
|
|
892
893
|
await act(async () => {
|
|
893
894
|
await result.current.submitQuery('// This is a line comment');
|
|
894
895
|
});
|
|
895
|
-
await waitFor(() => {
|
|
896
|
+
await vi.waitFor(() => {
|
|
896
897
|
expect(mockHandleSlashCommand).not.toHaveBeenCalled();
|
|
897
898
|
expect(localMockSendMessageStream).toHaveBeenCalledWith('// This is a line comment', expect.any(AbortSignal), expect.any(String));
|
|
898
899
|
});
|
|
@@ -902,7 +903,7 @@ describe('useGeminiStream', () => {
|
|
|
902
903
|
await act(async () => {
|
|
903
904
|
await result.current.submitQuery('/* This is a block comment */');
|
|
904
905
|
});
|
|
905
|
-
await waitFor(() => {
|
|
906
|
+
await vi.waitFor(() => {
|
|
906
907
|
expect(mockHandleSlashCommand).not.toHaveBeenCalled();
|
|
907
908
|
expect(localMockSendMessageStream).toHaveBeenCalledWith('/* This is a block comment */', expect.any(AbortSignal), expect.any(String));
|
|
908
909
|
});
|
|
@@ -912,7 +913,7 @@ describe('useGeminiStream', () => {
|
|
|
912
913
|
await act(async () => {
|
|
913
914
|
await result.current.submitQuery('/about');
|
|
914
915
|
});
|
|
915
|
-
await waitFor(() => {
|
|
916
|
+
await vi.waitFor(() => {
|
|
916
917
|
expect(mockHandleSlashCommand).not.toHaveBeenCalled();
|
|
917
918
|
});
|
|
918
919
|
});
|
|
@@ -960,7 +961,7 @@ describe('useGeminiStream', () => {
|
|
|
960
961
|
await capturedOnComplete([completedToolCall]);
|
|
961
962
|
}
|
|
962
963
|
});
|
|
963
|
-
await waitFor(() => {
|
|
964
|
+
await vi.waitFor(() => {
|
|
964
965
|
expect(mockPerformMemoryRefresh).toHaveBeenCalledTimes(1);
|
|
965
966
|
});
|
|
966
967
|
});
|
|
@@ -988,7 +989,7 @@ describe('useGeminiStream', () => {
|
|
|
988
989
|
await result.current.submitQuery('test query');
|
|
989
990
|
});
|
|
990
991
|
// 3. Assertion
|
|
991
|
-
await waitFor(() => {
|
|
992
|
+
await vi.waitFor(() => {
|
|
992
993
|
expect(mockParseAndFormatApiError).toHaveBeenCalledWith('Rate limit exceeded', mockAuthType, undefined, 'gemini-2.5-pro', 'gemini-2.5-flash');
|
|
993
994
|
});
|
|
994
995
|
});
|
|
@@ -1209,8 +1210,8 @@ describe('useGeminiStream', () => {
|
|
|
1209
1210
|
expect(mockOnConfirm).not.toHaveBeenCalled();
|
|
1210
1211
|
});
|
|
1211
1212
|
it('should handle errors gracefully when auto-approving tool calls', async () => {
|
|
1212
|
-
const
|
|
1213
|
-
.spyOn(
|
|
1213
|
+
const debuggerSpy = vi
|
|
1214
|
+
.spyOn(debugLogger, 'warn')
|
|
1214
1215
|
.mockImplementation(() => { });
|
|
1215
1216
|
const mockOnConfirmSuccess = vi.fn().mockResolvedValue(undefined);
|
|
1216
1217
|
const mockOnConfirmError = vi
|
|
@@ -1286,8 +1287,8 @@ describe('useGeminiStream', () => {
|
|
|
1286
1287
|
expect(mockOnConfirmSuccess).toHaveBeenCalledTimes(1);
|
|
1287
1288
|
expect(mockOnConfirmError).toHaveBeenCalledTimes(1);
|
|
1288
1289
|
// Error should be logged
|
|
1289
|
-
expect(
|
|
1290
|
-
|
|
1290
|
+
expect(debuggerSpy).toHaveBeenCalledWith('Failed to auto-approve tool call call2:', expect.any(Error));
|
|
1291
|
+
debuggerSpy.mockRestore();
|
|
1291
1292
|
});
|
|
1292
1293
|
it('should skip tool calls without confirmationDetails', async () => {
|
|
1293
1294
|
const awaitingApprovalToolCalls = [
|
|
@@ -1443,7 +1444,7 @@ describe('useGeminiStream', () => {
|
|
|
1443
1444
|
await result.current.submitQuery('Generate long text');
|
|
1444
1445
|
});
|
|
1445
1446
|
// Check that the info message was added
|
|
1446
|
-
await waitFor(() => {
|
|
1447
|
+
await vi.waitFor(() => {
|
|
1447
1448
|
expect(mockAddItem).toHaveBeenCalledWith({
|
|
1448
1449
|
type: 'info',
|
|
1449
1450
|
text: '⚠️ Response truncated due to token limits.',
|
|
@@ -1472,7 +1473,7 @@ describe('useGeminiStream', () => {
|
|
|
1472
1473
|
await result.current.submitQuery('Test overflow');
|
|
1473
1474
|
});
|
|
1474
1475
|
// Check that the message was added without suggestion
|
|
1475
|
-
await waitFor(() => {
|
|
1476
|
+
await vi.waitFor(() => {
|
|
1476
1477
|
expect(mockAddItem).toHaveBeenCalledWith({
|
|
1477
1478
|
type: 'info',
|
|
1478
1479
|
text: `Sending this message (20 tokens) might exceed the remaining context window limit (80 tokens).`,
|
|
@@ -1497,7 +1498,7 @@ describe('useGeminiStream', () => {
|
|
|
1497
1498
|
await result.current.submitQuery('Test overflow');
|
|
1498
1499
|
});
|
|
1499
1500
|
// Check that the message was added with suggestion
|
|
1500
|
-
await waitFor(() => {
|
|
1501
|
+
await vi.waitFor(() => {
|
|
1501
1502
|
expect(mockAddItem).toHaveBeenCalledWith({
|
|
1502
1503
|
type: 'info',
|
|
1503
1504
|
text: `Sending this message (30 tokens) might exceed the remaining context window limit (70 tokens). Please try reducing the size of your message or use the \`/compress\` command to compress the chat history.`,
|
|
@@ -1523,7 +1524,7 @@ describe('useGeminiStream', () => {
|
|
|
1523
1524
|
await result.current.submitQuery('Test overflow');
|
|
1524
1525
|
});
|
|
1525
1526
|
// Check that onCancelSubmit was called
|
|
1526
|
-
await waitFor(() => {
|
|
1527
|
+
await vi.waitFor(() => {
|
|
1527
1528
|
expect(onCancelSubmitSpy).toHaveBeenCalled();
|
|
1528
1529
|
});
|
|
1529
1530
|
});
|
|
@@ -1633,7 +1634,7 @@ describe('useGeminiStream', () => {
|
|
|
1633
1634
|
await act(async () => {
|
|
1634
1635
|
await result.current.submitQuery(`Test ${reason}`);
|
|
1635
1636
|
});
|
|
1636
|
-
await waitFor(() => {
|
|
1637
|
+
await vi.waitFor(() => {
|
|
1637
1638
|
expect(mockAddItem).toHaveBeenCalledWith({
|
|
1638
1639
|
type: 'info',
|
|
1639
1640
|
text: message,
|
|
@@ -1706,7 +1707,7 @@ describe('useGeminiStream', () => {
|
|
|
1706
1707
|
await result.current.submitQuery('First query');
|
|
1707
1708
|
});
|
|
1708
1709
|
// Wait for the first response to complete
|
|
1709
|
-
await waitFor(() => {
|
|
1710
|
+
await vi.waitFor(() => {
|
|
1710
1711
|
expect(mockAddItem).toHaveBeenCalledWith(expect.objectContaining({
|
|
1711
1712
|
type: 'gemini',
|
|
1712
1713
|
text: 'Some response content',
|
|
@@ -1731,7 +1732,7 @@ describe('useGeminiStream', () => {
|
|
|
1731
1732
|
// We can verify this by checking that the LoadingIndicator would not show the previous thought
|
|
1732
1733
|
// The actual thought state is internal to the hook, but we can verify the behavior
|
|
1733
1734
|
// by ensuring the second response doesn't show the previous thought
|
|
1734
|
-
await waitFor(() => {
|
|
1735
|
+
await vi.waitFor(() => {
|
|
1735
1736
|
expect(mockAddItem).toHaveBeenCalledWith(expect.objectContaining({
|
|
1736
1737
|
type: 'gemini',
|
|
1737
1738
|
text: 'New response content',
|
|
@@ -1790,7 +1791,7 @@ describe('useGeminiStream', () => {
|
|
|
1790
1791
|
await result.current.submitQuery('Test query');
|
|
1791
1792
|
});
|
|
1792
1793
|
// Verify cancellation message was added
|
|
1793
|
-
await waitFor(() => {
|
|
1794
|
+
await vi.waitFor(() => {
|
|
1794
1795
|
expect(mockAddItem).toHaveBeenCalledWith(expect.objectContaining({
|
|
1795
1796
|
type: 'info',
|
|
1796
1797
|
text: 'User cancelled the request.',
|
|
@@ -1817,7 +1818,7 @@ describe('useGeminiStream', () => {
|
|
|
1817
1818
|
await result.current.submitQuery('Test query');
|
|
1818
1819
|
});
|
|
1819
1820
|
// Verify error message was added
|
|
1820
|
-
await waitFor(() => {
|
|
1821
|
+
await vi.waitFor(() => {
|
|
1821
1822
|
expect(mockAddItem).toHaveBeenCalledWith(expect.objectContaining({
|
|
1822
1823
|
type: 'error',
|
|
1823
1824
|
}), expect.any(Number));
|
|
@@ -1851,7 +1852,7 @@ describe('useGeminiStream', () => {
|
|
|
1851
1852
|
await act(async () => {
|
|
1852
1853
|
await result.current.submitQuery('test query');
|
|
1853
1854
|
});
|
|
1854
|
-
await waitFor(() => {
|
|
1855
|
+
await vi.waitFor(() => {
|
|
1855
1856
|
expect(result.current.loopDetectionConfirmationRequest).not.toBeNull();
|
|
1856
1857
|
expect(typeof result.current.loopDetectionConfirmationRequest?.onComplete).toBe('function');
|
|
1857
1858
|
});
|
|
@@ -1887,7 +1888,7 @@ describe('useGeminiStream', () => {
|
|
|
1887
1888
|
await result.current.submitQuery('test query');
|
|
1888
1889
|
});
|
|
1889
1890
|
// Wait for confirmation request to be set
|
|
1890
|
-
await waitFor(() => {
|
|
1891
|
+
await vi.waitFor(() => {
|
|
1891
1892
|
expect(result.current.loopDetectionConfirmationRequest).not.toBeNull();
|
|
1892
1893
|
});
|
|
1893
1894
|
// Simulate user selecting "disable"
|
|
@@ -1906,7 +1907,7 @@ describe('useGeminiStream', () => {
|
|
|
1906
1907
|
text: 'Loop detection has been disabled for this session. Retrying request...',
|
|
1907
1908
|
}, expect.any(Number));
|
|
1908
1909
|
// Verify that the request was retried
|
|
1909
|
-
await waitFor(() => {
|
|
1910
|
+
await vi.waitFor(() => {
|
|
1910
1911
|
expect(mockSendMessageStream).toHaveBeenCalledTimes(2);
|
|
1911
1912
|
expect(mockSendMessageStream).toHaveBeenNthCalledWith(2, 'test query', expect.any(AbortSignal), expect.any(String));
|
|
1912
1913
|
});
|
|
@@ -1930,7 +1931,7 @@ describe('useGeminiStream', () => {
|
|
|
1930
1931
|
await result.current.submitQuery('test query');
|
|
1931
1932
|
});
|
|
1932
1933
|
// Wait for confirmation request to be set
|
|
1933
|
-
await waitFor(() => {
|
|
1934
|
+
await vi.waitFor(() => {
|
|
1934
1935
|
expect(result.current.loopDetectionConfirmationRequest).not.toBeNull();
|
|
1935
1936
|
});
|
|
1936
1937
|
// Simulate user selecting "keep"
|
|
@@ -1963,7 +1964,7 @@ describe('useGeminiStream', () => {
|
|
|
1963
1964
|
await act(async () => {
|
|
1964
1965
|
await result.current.submitQuery('first query');
|
|
1965
1966
|
});
|
|
1966
|
-
await waitFor(() => {
|
|
1967
|
+
await vi.waitFor(() => {
|
|
1967
1968
|
expect(result.current.loopDetectionConfirmationRequest).not.toBeNull();
|
|
1968
1969
|
});
|
|
1969
1970
|
// Simulate user selecting "keep" for first request
|
|
@@ -1999,7 +2000,7 @@ describe('useGeminiStream', () => {
|
|
|
1999
2000
|
await act(async () => {
|
|
2000
2001
|
await result.current.submitQuery('second query');
|
|
2001
2002
|
});
|
|
2002
|
-
await waitFor(() => {
|
|
2003
|
+
await vi.waitFor(() => {
|
|
2003
2004
|
expect(result.current.loopDetectionConfirmationRequest).not.toBeNull();
|
|
2004
2005
|
});
|
|
2005
2006
|
// Simulate user selecting "disable" for second request
|
|
@@ -2015,7 +2016,7 @@ describe('useGeminiStream', () => {
|
|
|
2015
2016
|
text: 'Loop detection has been disabled for this session. Retrying request...',
|
|
2016
2017
|
}, expect.any(Number));
|
|
2017
2018
|
// Verify that the request was retried
|
|
2018
|
-
await waitFor(() => {
|
|
2019
|
+
await vi.waitFor(() => {
|
|
2019
2020
|
expect(mockSendMessageStream).toHaveBeenCalledTimes(3); // 1st query, 2nd query, retry of 2nd query
|
|
2020
2021
|
expect(mockSendMessageStream).toHaveBeenNthCalledWith(3, 'second query', expect.any(AbortSignal), expect.any(String));
|
|
2021
2022
|
});
|
|
@@ -2035,14 +2036,14 @@ describe('useGeminiStream', () => {
|
|
|
2035
2036
|
await result.current.submitQuery('test query');
|
|
2036
2037
|
});
|
|
2037
2038
|
// Verify that the content was added to history before the loop detection dialog
|
|
2038
|
-
await waitFor(() => {
|
|
2039
|
+
await vi.waitFor(() => {
|
|
2039
2040
|
expect(mockAddItem).toHaveBeenCalledWith(expect.objectContaining({
|
|
2040
2041
|
type: 'gemini',
|
|
2041
2042
|
text: 'Some response content',
|
|
2042
2043
|
}), expect.any(Number));
|
|
2043
2044
|
});
|
|
2044
2045
|
// Then verify loop detection confirmation request was set
|
|
2045
|
-
await waitFor(() => {
|
|
2046
|
+
await vi.waitFor(() => {
|
|
2046
2047
|
expect(result.current.loopDetectionConfirmationRequest).not.toBeNull();
|
|
2047
2048
|
});
|
|
2048
2049
|
});
|