feat(cli): Suppress slash command execution and suggestions in shell … (#11380)

This commit is contained in:
Jainam M
2025-10-17 23:00:27 +05:30
committed by GitHub
parent 795e5134c7
commit 659b0557be
6 changed files with 154 additions and 36 deletions
@@ -121,6 +121,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -146,6 +147,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { completion, textBuffer };
@@ -179,6 +181,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -207,6 +210,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -233,6 +237,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -246,6 +251,56 @@ describe('useCommandCompletion', () => {
);
});
});
it.each([
{
shellModeActive: false,
expectedSuggestions: 1,
expectedShowSuggestions: true,
description:
'should show slash command suggestions when shellModeActive is false',
},
{
shellModeActive: true,
expectedSuggestions: 0,
expectedShowSuggestions: false,
description:
'should not show slash command suggestions when shellModeActive is true',
},
])(
'$description',
async ({
shellModeActive,
expectedSuggestions,
expectedShowSuggestions,
}) => {
setupMocks({
slashSuggestions: [{ label: 'clear', value: 'clear' }],
});
const { result } = renderHook(() => {
const textBuffer = useTextBufferForTest('/');
const completion = useCommandCompletion(
textBuffer,
testDirs,
testRootDir,
[],
mockCommandContext,
false,
shellModeActive, // Parameterized shellModeActive
mockConfig,
);
return { ...completion, textBuffer };
});
await waitFor(() => {
expect(result.current.suggestions.length).toBe(expectedSuggestions);
expect(result.current.showSuggestions).toBe(
expectedShowSuggestions,
);
});
},
);
});
describe('Navigation', () => {
@@ -272,6 +327,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -293,6 +349,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -313,6 +370,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -339,6 +397,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -368,6 +427,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -405,6 +465,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
),
);
@@ -435,6 +496,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -465,6 +527,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -498,6 +561,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -530,6 +594,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -562,6 +627,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -594,6 +660,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -619,6 +686,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };
@@ -644,6 +712,7 @@ describe('useCommandCompletion', () => {
[],
mockCommandContext,
false,
false,
mockConfig,
);
return { ...completion, textBuffer };