@google/gemini-cli 0.28.0-preview.5 → 0.29.0-nightly.20260206.4ffc349c1
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/dist/google-gemini-cli-0.29.0-nightly.20260203.71f46f116.tgz +0 -0
- package/dist/package.json +2 -2
- package/dist/src/commands/extensions/configure.js +6 -79
- package/dist/src/commands/extensions/configure.js.map +1 -1
- package/dist/src/commands/extensions/configure.test.js +14 -24
- package/dist/src/commands/extensions/configure.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/utils.d.ts +14 -4
- package/dist/src/commands/extensions/utils.js +88 -7
- package/dist/src/commands/extensions/utils.js.map +1 -1
- package/dist/src/commands/skills/link.d.ts +14 -0
- package/dist/src/commands/skills/link.js +65 -0
- package/dist/src/commands/skills/link.js.map +1 -0
- package/dist/src/commands/skills/link.test.d.ts +6 -0
- package/dist/src/commands/skills/link.test.js +49 -0
- package/dist/src/commands/skills/link.test.js.map +1 -0
- package/dist/src/commands/skills.js +2 -0
- package/dist/src/commands/skills.js.map +1 -1
- package/dist/src/config/config.d.ts +2 -1
- package/dist/src/config/config.js +38 -3
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +206 -5
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/extensions/consent.d.ts +1 -1
- package/dist/src/config/extensions/consent.js +6 -4
- package/dist/src/config/extensions/consent.js.map +1 -1
- package/dist/src/config/extensions/extensionSettings.js +9 -1
- package/dist/src/config/extensions/extensionSettings.js.map +1 -1
- package/dist/src/config/extensions/extensionSettings.test.js +27 -0
- package/dist/src/config/extensions/extensionSettings.test.js.map +1 -1
- package/dist/src/config/keyBindings.d.ts +0 -1
- package/dist/src/config/keyBindings.js +11 -15
- package/dist/src/config/keyBindings.js.map +1 -1
- package/dist/src/config/policy-engine.integration.test.js +29 -34
- package/dist/src/config/policy-engine.integration.test.js.map +1 -1
- package/dist/src/config/settings.js +4 -1
- package/dist/src/config/settings.js.map +1 -1
- package/dist/src/config/settings.test.js +20 -1
- package/dist/src/config/settings.test.js.map +1 -1
- package/dist/src/config/settingsSchema.d.ts +15 -1
- package/dist/src/config/settingsSchema.js +15 -1
- package/dist/src/config/settingsSchema.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/services/BuiltinCommandLoader.js +4 -2
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/services/BuiltinCommandLoader.test.js +26 -0
- package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
- package/dist/src/ui/AppContainer.js +70 -50
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/AppContainer.test.js +0 -123
- package/dist/src/ui/AppContainer.test.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.js +75 -0
- package/dist/src/ui/commands/extensionsCommand.js.map +1 -1
- package/dist/src/ui/commands/extensionsCommand.test.js +103 -11
- package/dist/src/ui/commands/extensionsCommand.test.js.map +1 -1
- package/dist/src/ui/commands/mcpCommand.test.js +1 -0
- package/dist/src/ui/commands/mcpCommand.test.js.map +1 -1
- package/dist/src/ui/commands/planCommand.d.ts +7 -0
- package/dist/src/ui/commands/planCommand.js +44 -0
- package/dist/src/ui/commands/planCommand.js.map +1 -0
- package/dist/src/ui/commands/planCommand.test.js +87 -0
- package/dist/src/ui/commands/planCommand.test.js.map +1 -0
- package/dist/src/ui/commands/skillsCommand.js +50 -1
- package/dist/src/ui/commands/skillsCommand.js.map +1 -1
- package/dist/src/ui/commands/skillsCommand.test.js +55 -0
- package/dist/src/ui/commands/skillsCommand.test.js.map +1 -1
- package/dist/src/ui/commands/types.d.ts +6 -0
- package/dist/src/ui/commands/types.js.map +1 -1
- package/dist/src/ui/components/BackgroundShellDisplay.js +21 -16
- package/dist/src/ui/components/BackgroundShellDisplay.js.map +1 -1
- package/dist/src/ui/components/BackgroundShellDisplay.test.js +21 -0
- package/dist/src/ui/components/BackgroundShellDisplay.test.js.map +1 -1
- package/dist/src/ui/components/ConfigExtensionDialog.d.ts +19 -0
- package/dist/src/ui/components/ConfigExtensionDialog.js +155 -0
- package/dist/src/ui/components/ConfigExtensionDialog.js.map +1 -0
- package/dist/src/ui/components/InputPrompt.js +83 -34
- package/dist/src/ui/components/InputPrompt.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.test.js +283 -9
- package/dist/src/ui/components/InputPrompt.test.js.map +1 -1
- package/dist/src/ui/components/ShellInputPrompt.js +0 -4
- package/dist/src/ui/components/ShellInputPrompt.js.map +1 -1
- package/dist/src/ui/components/ShellInputPrompt.test.js +0 -22
- package/dist/src/ui/components/ShellInputPrompt.test.js.map +1 -1
- package/dist/src/ui/components/messages/ShellToolMessage.js +12 -0
- package/dist/src/ui/components/messages/ShellToolMessage.js.map +1 -1
- package/dist/src/ui/components/messages/ShellToolMessage.test.js +27 -1
- package/dist/src/ui/components/messages/ShellToolMessage.test.js.map +1 -1
- package/dist/src/ui/components/messages/ToolMessageFocusHint.test.js +3 -3
- package/dist/src/ui/components/messages/ToolShared.js +1 -5
- package/dist/src/ui/components/messages/ToolShared.js.map +1 -1
- package/dist/src/ui/components/shared/TextInput.test.js +20 -4
- package/dist/src/ui/components/shared/TextInput.test.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.d.ts +98 -5
- package/dist/src/ui/components/shared/text-buffer.js +228 -29
- package/dist/src/ui/components/shared/text-buffer.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.test.js +33 -1
- package/dist/src/ui/components/shared/text-buffer.test.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.d.ts +18 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.js +156 -42
- package/dist/src/ui/components/shared/vim-buffer-actions.js.map +1 -1
- package/dist/src/ui/components/shared/vim-buffer-actions.test.js +54 -0
- package/dist/src/ui/components/shared/vim-buffer-actions.test.js.map +1 -1
- package/dist/src/ui/constants/tips.js +2 -2
- package/dist/src/ui/contexts/KeypressContext.js +15 -2
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.test.js +67 -17
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -1
- package/dist/src/ui/editors/editorSettingsManager.js +2 -2
- package/dist/src/ui/editors/editorSettingsManager.js.map +1 -1
- package/dist/src/ui/hooks/shellReducer.js +2 -6
- package/dist/src/ui/hooks/shellReducer.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.js +2 -0
- package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.d.ts +11 -2
- package/dist/src/ui/hooks/useCommandCompletion.js +30 -18
- package/dist/src/ui/hooks/useCommandCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.test.js +50 -9
- package/dist/src/ui/hooks/useCommandCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useCompletion.d.ts +0 -2
- package/dist/src/ui/hooks/useCompletion.js +0 -4
- package/dist/src/ui/hooks/useCompletion.js.map +1 -1
- package/dist/src/ui/hooks/useEditorSettings.js +4 -2
- package/dist/src/ui/hooks/useEditorSettings.js.map +1 -1
- package/dist/src/ui/hooks/useEditorSettings.test.js +5 -5
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.js +1 -1
- package/dist/src/ui/hooks/useFolderTrust.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.test.js +1 -1
- package/dist/src/ui/hooks/useFolderTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +5 -0
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistory.d.ts +3 -2
- package/dist/src/ui/hooks/useInputHistory.js +54 -47
- package/dist/src/ui/hooks/useInputHistory.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistory.test.js +194 -13
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useReverseSearchCompletion.js +2 -3
- package/dist/src/ui/hooks/useReverseSearchCompletion.js.map +1 -1
- package/dist/src/ui/hooks/vim.js +78 -0
- package/dist/src/ui/hooks/vim.js.map +1 -1
- package/dist/src/ui/hooks/vim.test.js +87 -0
- package/dist/src/ui/hooks/vim.test.js.map +1 -1
- package/dist/src/ui/noninteractive/nonInteractiveUi.js +1 -0
- package/dist/src/ui/noninteractive/nonInteractiveUi.js.map +1 -1
- package/dist/src/ui/utils/terminalSetup.js +72 -56
- package/dist/src/ui/utils/terminalSetup.js.map +1 -1
- package/dist/src/ui/utils/terminalSetup.test.js +21 -1
- package/dist/src/ui/utils/terminalSetup.test.js.map +1 -1
- package/dist/src/ui/utils/terminalUtils.js +1 -3
- package/dist/src/ui/utils/terminalUtils.js.map +1 -1
- package/dist/src/ui/utils/terminalUtils.test.js +0 -5
- package/dist/src/ui/utils/terminalUtils.test.js.map +1 -1
- package/dist/src/utils/skillUtils.d.ts +7 -0
- package/dist/src/utils/skillUtils.js +42 -0
- package/dist/src/utils/skillUtils.js.map +1 -1
- package/dist/src/utils/skillUtils.test.js +55 -1
- package/dist/src/utils/skillUtils.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/dist/google-gemini-cli-0.28.0-preview.4.tgz +0 -0
- package/dist/src/ui/utils/keybindingUtils.d.ts +0 -14
- package/dist/src/ui/utils/keybindingUtils.js +0 -54
- package/dist/src/ui/utils/keybindingUtils.js.map +0 -1
- package/dist/src/ui/utils/keybindingUtils.test.js +0 -44
- package/dist/src/ui/utils/keybindingUtils.test.js.map +0 -1
- /package/dist/src/ui/{utils/keybindingUtils.test.d.ts → commands/planCommand.test.d.ts} +0 -0
|
@@ -28,6 +28,7 @@ import chalk from 'chalk';
|
|
|
28
28
|
import { StreamingState } from '../types.js';
|
|
29
29
|
import { terminalCapabilityManager } from '../utils/terminalCapabilityManager.js';
|
|
30
30
|
import { isLowColorDepth } from '../utils/terminalUtils.js';
|
|
31
|
+
import { cpLen } from '../utils/textUtils.js';
|
|
31
32
|
import { keyMatchers, Command } from '../keyMatchers.js';
|
|
32
33
|
vi.mock('../hooks/useShellHistory.js');
|
|
33
34
|
vi.mock('../hooks/useCommandCompletion.js');
|
|
@@ -125,13 +126,24 @@ describe('InputPrompt', () => {
|
|
|
125
126
|
text: '',
|
|
126
127
|
cursor: [0, 0],
|
|
127
128
|
lines: [''],
|
|
128
|
-
setText: vi.fn((newText) => {
|
|
129
|
+
setText: vi.fn((newText, cursorPosition) => {
|
|
129
130
|
mockBuffer.text = newText;
|
|
130
131
|
mockBuffer.lines = [newText];
|
|
131
|
-
|
|
132
|
+
let col = 0;
|
|
133
|
+
if (typeof cursorPosition === 'number') {
|
|
134
|
+
col = cursorPosition;
|
|
135
|
+
}
|
|
136
|
+
else if (cursorPosition === 'start') {
|
|
137
|
+
col = 0;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
col = newText.length;
|
|
141
|
+
}
|
|
142
|
+
mockBuffer.cursor = [0, col];
|
|
132
143
|
mockBuffer.viewportVisualLines = [newText];
|
|
133
144
|
mockBuffer.allVisualLines = [newText];
|
|
134
145
|
mockBuffer.visualToLogicalMap = [[0, 0]];
|
|
146
|
+
mockBuffer.visualCursor = [0, col];
|
|
135
147
|
}),
|
|
136
148
|
replaceRangeByOffset: vi.fn(),
|
|
137
149
|
viewportVisualLines: [''],
|
|
@@ -148,7 +160,15 @@ describe('InputPrompt', () => {
|
|
|
148
160
|
}
|
|
149
161
|
return false;
|
|
150
162
|
}),
|
|
151
|
-
move: vi.fn()
|
|
163
|
+
move: vi.fn((dir) => {
|
|
164
|
+
if (dir === 'home') {
|
|
165
|
+
mockBuffer.visualCursor = [mockBuffer.visualCursor[0], 0];
|
|
166
|
+
}
|
|
167
|
+
else if (dir === 'end') {
|
|
168
|
+
const line = mockBuffer.allVisualLines[mockBuffer.visualCursor[0]] || '';
|
|
169
|
+
mockBuffer.visualCursor = [mockBuffer.visualCursor[0], cpLen(line)];
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
152
172
|
moveToOffset: vi.fn((offset) => {
|
|
153
173
|
mockBuffer.cursor = [0, offset];
|
|
154
174
|
}),
|
|
@@ -192,7 +212,6 @@ describe('InputPrompt', () => {
|
|
|
192
212
|
navigateDown: vi.fn(),
|
|
193
213
|
resetCompletionState: vi.fn(),
|
|
194
214
|
setActiveSuggestionIndex: vi.fn(),
|
|
195
|
-
setShowSuggestions: vi.fn(),
|
|
196
215
|
handleAutocomplete: vi.fn(),
|
|
197
216
|
promptCompletion: {
|
|
198
217
|
text: '',
|
|
@@ -323,11 +342,11 @@ describe('InputPrompt', () => {
|
|
|
323
342
|
uiActions,
|
|
324
343
|
});
|
|
325
344
|
await act(async () => {
|
|
326
|
-
stdin.write('\
|
|
345
|
+
stdin.write('\u0010'); // Ctrl+P
|
|
327
346
|
});
|
|
328
347
|
await waitFor(() => expect(mockInputHistory.navigateUp).toHaveBeenCalled());
|
|
329
348
|
await act(async () => {
|
|
330
|
-
stdin.write('\
|
|
349
|
+
stdin.write('\u000E'); // Ctrl+N
|
|
331
350
|
});
|
|
332
351
|
await waitFor(() => expect(mockInputHistory.navigateDown).toHaveBeenCalled());
|
|
333
352
|
await act(async () => {
|
|
@@ -339,6 +358,72 @@ describe('InputPrompt', () => {
|
|
|
339
358
|
expect(mockShellHistory.addCommandToHistory).not.toHaveBeenCalled();
|
|
340
359
|
unmount();
|
|
341
360
|
});
|
|
361
|
+
describe('arrow key navigation', () => {
|
|
362
|
+
it('should move to start of line on Up arrow if on first line but not at start', async () => {
|
|
363
|
+
mockBuffer.allVisualLines = ['line 1', 'line 2'];
|
|
364
|
+
mockBuffer.visualCursor = [0, 5]; // First line, not at start
|
|
365
|
+
mockBuffer.visualScrollRow = 0;
|
|
366
|
+
const { stdin, unmount } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
367
|
+
uiActions,
|
|
368
|
+
});
|
|
369
|
+
await act(async () => {
|
|
370
|
+
stdin.write('\u001B[A'); // Up arrow
|
|
371
|
+
});
|
|
372
|
+
await waitFor(() => {
|
|
373
|
+
expect(mockBuffer.move).toHaveBeenCalledWith('home');
|
|
374
|
+
expect(mockInputHistory.navigateUp).not.toHaveBeenCalled();
|
|
375
|
+
});
|
|
376
|
+
unmount();
|
|
377
|
+
});
|
|
378
|
+
it('should navigate history on Up arrow if on first line and at start', async () => {
|
|
379
|
+
mockBuffer.allVisualLines = ['line 1', 'line 2'];
|
|
380
|
+
mockBuffer.visualCursor = [0, 0]; // First line, at start
|
|
381
|
+
mockBuffer.visualScrollRow = 0;
|
|
382
|
+
const { stdin, unmount } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
383
|
+
uiActions,
|
|
384
|
+
});
|
|
385
|
+
await act(async () => {
|
|
386
|
+
stdin.write('\u001B[A'); // Up arrow
|
|
387
|
+
});
|
|
388
|
+
await waitFor(() => {
|
|
389
|
+
expect(mockBuffer.move).not.toHaveBeenCalledWith('home');
|
|
390
|
+
expect(mockInputHistory.navigateUp).toHaveBeenCalled();
|
|
391
|
+
});
|
|
392
|
+
unmount();
|
|
393
|
+
});
|
|
394
|
+
it('should move to end of line on Down arrow if on last line but not at end', async () => {
|
|
395
|
+
mockBuffer.allVisualLines = ['line 1', 'line 2'];
|
|
396
|
+
mockBuffer.visualCursor = [1, 0]; // Last line, not at end
|
|
397
|
+
mockBuffer.visualScrollRow = 0;
|
|
398
|
+
const { stdin, unmount } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
399
|
+
uiActions,
|
|
400
|
+
});
|
|
401
|
+
await act(async () => {
|
|
402
|
+
stdin.write('\u001B[B'); // Down arrow
|
|
403
|
+
});
|
|
404
|
+
await waitFor(() => {
|
|
405
|
+
expect(mockBuffer.move).toHaveBeenCalledWith('end');
|
|
406
|
+
expect(mockInputHistory.navigateDown).not.toHaveBeenCalled();
|
|
407
|
+
});
|
|
408
|
+
unmount();
|
|
409
|
+
});
|
|
410
|
+
it('should navigate history on Down arrow if on last line and at end', async () => {
|
|
411
|
+
mockBuffer.allVisualLines = ['line 1', 'line 2'];
|
|
412
|
+
mockBuffer.visualCursor = [1, 6]; // Last line, at end ("line 2" is length 6)
|
|
413
|
+
mockBuffer.visualScrollRow = 0;
|
|
414
|
+
const { stdin, unmount } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
415
|
+
uiActions,
|
|
416
|
+
});
|
|
417
|
+
await act(async () => {
|
|
418
|
+
stdin.write('\u001B[B'); // Down arrow
|
|
419
|
+
});
|
|
420
|
+
await waitFor(() => {
|
|
421
|
+
expect(mockBuffer.move).not.toHaveBeenCalledWith('end');
|
|
422
|
+
expect(mockInputHistory.navigateDown).toHaveBeenCalled();
|
|
423
|
+
});
|
|
424
|
+
unmount();
|
|
425
|
+
});
|
|
426
|
+
});
|
|
342
427
|
it('should call completion.navigateUp for both up arrow and Ctrl+P when suggestions are showing', async () => {
|
|
343
428
|
mockedUseCommandCompletion.mockReturnValue({
|
|
344
429
|
...mockCommandCompletion,
|
|
@@ -399,11 +484,11 @@ describe('InputPrompt', () => {
|
|
|
399
484
|
uiActions,
|
|
400
485
|
});
|
|
401
486
|
await act(async () => {
|
|
402
|
-
stdin.write('\
|
|
487
|
+
stdin.write('\u0010'); // Ctrl+P
|
|
403
488
|
});
|
|
404
489
|
await waitFor(() => expect(mockInputHistory.navigateUp).toHaveBeenCalled());
|
|
405
490
|
await act(async () => {
|
|
406
|
-
stdin.write('\
|
|
491
|
+
stdin.write('\u000E'); // Ctrl+N
|
|
407
492
|
});
|
|
408
493
|
await waitFor(() => expect(mockInputHistory.navigateDown).toHaveBeenCalled());
|
|
409
494
|
await act(async () => {
|
|
@@ -742,6 +827,29 @@ describe('InputPrompt', () => {
|
|
|
742
827
|
await waitFor(() => expect(props.onSubmit).toHaveBeenCalledWith('/clear'));
|
|
743
828
|
unmount();
|
|
744
829
|
});
|
|
830
|
+
it('should NOT submit on Enter when an @-path is a perfect match', async () => {
|
|
831
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
832
|
+
...mockCommandCompletion,
|
|
833
|
+
showSuggestions: true,
|
|
834
|
+
suggestions: [{ label: 'file.txt', value: 'file.txt' }],
|
|
835
|
+
activeSuggestionIndex: 0,
|
|
836
|
+
isPerfectMatch: true,
|
|
837
|
+
completionMode: CompletionMode.AT,
|
|
838
|
+
});
|
|
839
|
+
props.buffer.text = '@file.txt';
|
|
840
|
+
const { stdin, unmount } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
841
|
+
uiActions,
|
|
842
|
+
});
|
|
843
|
+
await act(async () => {
|
|
844
|
+
stdin.write('\r');
|
|
845
|
+
});
|
|
846
|
+
await waitFor(() => {
|
|
847
|
+
// Should handle autocomplete but NOT submit
|
|
848
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
849
|
+
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
850
|
+
});
|
|
851
|
+
unmount();
|
|
852
|
+
});
|
|
745
853
|
it('should auto-execute commands with autoExecute: true on Enter', async () => {
|
|
746
854
|
const aboutCommand = {
|
|
747
855
|
name: 'about',
|
|
@@ -1309,7 +1417,16 @@ describe('InputPrompt', () => {
|
|
|
1309
1417
|
uiActions,
|
|
1310
1418
|
});
|
|
1311
1419
|
await waitFor(() => {
|
|
1312
|
-
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
1420
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith({
|
|
1421
|
+
buffer: mockBuffer,
|
|
1422
|
+
cwd: path.join('test', 'project', 'src'),
|
|
1423
|
+
slashCommands: mockSlashCommands,
|
|
1424
|
+
commandContext: mockCommandContext,
|
|
1425
|
+
reverseSearchActive: false,
|
|
1426
|
+
shellModeActive: false,
|
|
1427
|
+
config: expect.any(Object),
|
|
1428
|
+
active: expect.anything(),
|
|
1429
|
+
});
|
|
1313
1430
|
});
|
|
1314
1431
|
unmount();
|
|
1315
1432
|
});
|
|
@@ -2844,6 +2961,163 @@ describe('InputPrompt', () => {
|
|
|
2844
2961
|
unmount();
|
|
2845
2962
|
});
|
|
2846
2963
|
});
|
|
2964
|
+
describe('History Navigation and Completion Suppression', () => {
|
|
2965
|
+
beforeEach(() => {
|
|
2966
|
+
props.userMessages = ['first message', 'second message'];
|
|
2967
|
+
// Mock useInputHistory to actually call onChange
|
|
2968
|
+
mockedUseInputHistory.mockImplementation(({ onChange }) => ({
|
|
2969
|
+
navigateUp: () => {
|
|
2970
|
+
onChange('second message', 'start');
|
|
2971
|
+
return true;
|
|
2972
|
+
},
|
|
2973
|
+
navigateDown: () => {
|
|
2974
|
+
onChange('first message', 'end');
|
|
2975
|
+
return true;
|
|
2976
|
+
},
|
|
2977
|
+
handleSubmit: vi.fn(),
|
|
2978
|
+
}));
|
|
2979
|
+
});
|
|
2980
|
+
it.each([
|
|
2981
|
+
{ name: 'Up arrow', key: '\u001B[A', position: 'start' },
|
|
2982
|
+
{ name: 'Ctrl+P', key: '\u0010', position: 'start' },
|
|
2983
|
+
])('should move cursor to $position on $name (older history)', async ({ key, position }) => {
|
|
2984
|
+
const { stdin } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
2985
|
+
uiActions,
|
|
2986
|
+
});
|
|
2987
|
+
await act(async () => {
|
|
2988
|
+
stdin.write(key);
|
|
2989
|
+
});
|
|
2990
|
+
await waitFor(() => {
|
|
2991
|
+
expect(mockBuffer.setText).toHaveBeenCalledWith('second message', position);
|
|
2992
|
+
});
|
|
2993
|
+
});
|
|
2994
|
+
it.each([
|
|
2995
|
+
{ name: 'Down arrow', key: '\u001B[B', position: 'end' },
|
|
2996
|
+
{ name: 'Ctrl+N', key: '\u000E', position: 'end' },
|
|
2997
|
+
])('should move cursor to $position on $name (newer history)', async ({ key, position }) => {
|
|
2998
|
+
const { stdin } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
2999
|
+
uiActions,
|
|
3000
|
+
});
|
|
3001
|
+
// First go up
|
|
3002
|
+
await act(async () => {
|
|
3003
|
+
stdin.write('\u001B[A');
|
|
3004
|
+
});
|
|
3005
|
+
// Then go down
|
|
3006
|
+
await act(async () => {
|
|
3007
|
+
stdin.write(key);
|
|
3008
|
+
if (key === '\u001B[B') {
|
|
3009
|
+
// Second press to actually navigate history
|
|
3010
|
+
stdin.write(key);
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
3013
|
+
await waitFor(() => {
|
|
3014
|
+
expect(mockBuffer.setText).toHaveBeenCalledWith('first message', position);
|
|
3015
|
+
});
|
|
3016
|
+
});
|
|
3017
|
+
it('should suppress completion after history navigation', async () => {
|
|
3018
|
+
const { stdin } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
3019
|
+
uiActions,
|
|
3020
|
+
});
|
|
3021
|
+
await act(async () => {
|
|
3022
|
+
stdin.write('\u001B[A'); // Up arrow
|
|
3023
|
+
});
|
|
3024
|
+
await waitFor(() => {
|
|
3025
|
+
expect(mockedUseCommandCompletion).toHaveBeenLastCalledWith({
|
|
3026
|
+
buffer: mockBuffer,
|
|
3027
|
+
cwd: expect.anything(),
|
|
3028
|
+
slashCommands: expect.anything(),
|
|
3029
|
+
commandContext: expect.anything(),
|
|
3030
|
+
reverseSearchActive: expect.anything(),
|
|
3031
|
+
shellModeActive: expect.anything(),
|
|
3032
|
+
config: expect.anything(),
|
|
3033
|
+
active: false,
|
|
3034
|
+
});
|
|
3035
|
+
});
|
|
3036
|
+
});
|
|
3037
|
+
it('should not render suggestions during history navigation', async () => {
|
|
3038
|
+
// 1. Set up a dynamic mock implementation BEFORE rendering
|
|
3039
|
+
mockedUseCommandCompletion.mockImplementation(({ active }) => ({
|
|
3040
|
+
...mockCommandCompletion,
|
|
3041
|
+
showSuggestions: active,
|
|
3042
|
+
suggestions: active
|
|
3043
|
+
? [{ value: 'suggestion', label: 'suggestion' }]
|
|
3044
|
+
: [],
|
|
3045
|
+
}));
|
|
3046
|
+
const { stdout, stdin, unmount } = renderWithProviders(_jsx(InputPrompt, { ...props }), { uiActions });
|
|
3047
|
+
// 2. Verify suggestions ARE showing initially because active is true by default
|
|
3048
|
+
await waitFor(() => {
|
|
3049
|
+
expect(stdout.lastFrame()).toContain('suggestion');
|
|
3050
|
+
});
|
|
3051
|
+
// 3. Trigger history navigation which should set suppressCompletion to true
|
|
3052
|
+
await act(async () => {
|
|
3053
|
+
stdin.write('\u001B[A');
|
|
3054
|
+
});
|
|
3055
|
+
// 4. Verify that suggestions are NOT in the output frame after navigation
|
|
3056
|
+
await waitFor(() => {
|
|
3057
|
+
expect(stdout.lastFrame()).not.toContain('suggestion');
|
|
3058
|
+
});
|
|
3059
|
+
expect(stdout.lastFrame()).toMatchSnapshot();
|
|
3060
|
+
unmount();
|
|
3061
|
+
});
|
|
3062
|
+
it('should continue to suppress completion after manual cursor movement', async () => {
|
|
3063
|
+
const { stdin } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
3064
|
+
uiActions,
|
|
3065
|
+
});
|
|
3066
|
+
// Navigate history (suppresses)
|
|
3067
|
+
await act(async () => {
|
|
3068
|
+
stdin.write('\u001B[A');
|
|
3069
|
+
});
|
|
3070
|
+
// Wait for it to be suppressed
|
|
3071
|
+
await waitFor(() => {
|
|
3072
|
+
expect(mockedUseCommandCompletion).toHaveBeenLastCalledWith({
|
|
3073
|
+
buffer: mockBuffer,
|
|
3074
|
+
cwd: expect.anything(),
|
|
3075
|
+
slashCommands: expect.anything(),
|
|
3076
|
+
commandContext: expect.anything(),
|
|
3077
|
+
reverseSearchActive: expect.anything(),
|
|
3078
|
+
shellModeActive: expect.anything(),
|
|
3079
|
+
config: expect.anything(),
|
|
3080
|
+
active: false,
|
|
3081
|
+
});
|
|
3082
|
+
});
|
|
3083
|
+
// Move cursor manually
|
|
3084
|
+
await act(async () => {
|
|
3085
|
+
stdin.write('\u001B[D'); // Left arrow
|
|
3086
|
+
});
|
|
3087
|
+
await waitFor(() => {
|
|
3088
|
+
expect(mockedUseCommandCompletion).toHaveBeenLastCalledWith({
|
|
3089
|
+
buffer: mockBuffer,
|
|
3090
|
+
cwd: expect.anything(),
|
|
3091
|
+
slashCommands: expect.anything(),
|
|
3092
|
+
commandContext: expect.anything(),
|
|
3093
|
+
reverseSearchActive: expect.anything(),
|
|
3094
|
+
shellModeActive: expect.anything(),
|
|
3095
|
+
config: expect.anything(),
|
|
3096
|
+
active: false,
|
|
3097
|
+
});
|
|
3098
|
+
});
|
|
3099
|
+
});
|
|
3100
|
+
it('should re-enable completion after typing', async () => {
|
|
3101
|
+
const { stdin } = renderWithProviders(_jsx(InputPrompt, { ...props }), {
|
|
3102
|
+
uiActions,
|
|
3103
|
+
});
|
|
3104
|
+
// Navigate history (suppresses)
|
|
3105
|
+
await act(async () => {
|
|
3106
|
+
stdin.write('\u001B[A');
|
|
3107
|
+
});
|
|
3108
|
+
// Wait for it to be suppressed
|
|
3109
|
+
await waitFor(() => {
|
|
3110
|
+
expect(mockedUseCommandCompletion).toHaveBeenLastCalledWith(expect.objectContaining({ active: false }));
|
|
3111
|
+
});
|
|
3112
|
+
// Type a character
|
|
3113
|
+
await act(async () => {
|
|
3114
|
+
stdin.write('a');
|
|
3115
|
+
});
|
|
3116
|
+
await waitFor(() => {
|
|
3117
|
+
expect(mockedUseCommandCompletion).toHaveBeenLastCalledWith(expect.objectContaining({ active: true }));
|
|
3118
|
+
});
|
|
3119
|
+
});
|
|
3120
|
+
});
|
|
2847
3121
|
});
|
|
2848
3122
|
function clean(str) {
|
|
2849
3123
|
if (!str)
|