feat(cli): implement interactive shell autocompletion (#20082)

This commit is contained in:
MD. MOHIBUR RAHMAN
2026-02-26 13:49:11 +06:00
committed by GitHub
parent ef247e220d
commit 8380f0a3b1
12 changed files with 1656 additions and 70 deletions

View File

@@ -40,6 +40,16 @@ vi.mock('./useSlashCompletion', () => ({
})),
}));
vi.mock('./useShellCompletion', async () => {
const actual = await vi.importActual<
typeof import('./useShellCompletion.js')
>('./useShellCompletion');
return {
...actual,
useShellCompletion: vi.fn(),
};
});
// Helper to set up mocks in a consistent way for both child hooks
const setupMocks = ({
atSuggestions = [],
@@ -94,6 +104,7 @@ const setupMocks = ({
describe('useCommandCompletion', () => {
const mockCommandContext = {} as CommandContext;
const mockConfig = {
getEnablePromptCompletion: () => false,
getGeminiClient: vi.fn(),
} as unknown as Config;
const testRootDir = '/';
@@ -498,6 +509,7 @@ describe('useCommandCompletion', () => {
describe('prompt completion filtering', () => {
it('should not trigger prompt completion for line comments', async () => {
const mockConfig = {
getEnablePromptCompletion: () => true,
getGeminiClient: vi.fn(),
} as unknown as Config;
@@ -530,6 +542,7 @@ describe('useCommandCompletion', () => {
it('should not trigger prompt completion for block comments', async () => {
const mockConfig = {
getEnablePromptCompletion: () => true,
getGeminiClient: vi.fn(),
} as unknown as Config;
@@ -564,6 +577,7 @@ describe('useCommandCompletion', () => {
it('should trigger prompt completion for regular text when enabled', async () => {
const mockConfig = {
getEnablePromptCompletion: () => true,
getGeminiClient: vi.fn(),
} as unknown as Config;