mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-25 05:21:03 -07:00
Allow for slash commands to opt-out of autocompletion and /help discovery. (#7847)
This commit is contained in:
@@ -223,18 +223,6 @@ describe('useSlashCommandProcessor', () => {
|
||||
expect(fileAction).toHaveBeenCalledTimes(1);
|
||||
expect(builtinAction).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not include hidden commands in the command list', async () => {
|
||||
const visibleCommand = createTestCommand({ name: 'visible' });
|
||||
const hiddenCommand = createTestCommand({ name: 'hidden', hidden: true });
|
||||
const result = setupProcessorHook([visibleCommand, hiddenCommand]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.slashCommands).toHaveLength(1);
|
||||
});
|
||||
|
||||
expect(result.current.slashCommands[0].name).toBe('visible');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Command Execution Logic', () => {
|
||||
|
||||
@@ -347,6 +347,31 @@ describe('useSlashCompletion', () => {
|
||||
|
||||
expect(result.current.suggestions).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('should not suggest hidden commands', async () => {
|
||||
const slashCommands = [
|
||||
createTestCommand({
|
||||
name: 'visible',
|
||||
description: 'A visible command',
|
||||
}),
|
||||
createTestCommand({
|
||||
name: 'hidden',
|
||||
description: 'A hidden command',
|
||||
hidden: true,
|
||||
}),
|
||||
];
|
||||
const { result } = renderHook(() =>
|
||||
useTestHarnessForSlashCompletion(
|
||||
true,
|
||||
'/',
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
),
|
||||
);
|
||||
|
||||
expect(result.current.suggestions.length).toBe(1);
|
||||
expect(result.current.suggestions[0].label).toBe('visible');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Sub-Commands', () => {
|
||||
|
||||
@@ -225,7 +225,7 @@ function useCommandSuggestions(
|
||||
if (partial === '') {
|
||||
// If no partial query, show all available commands
|
||||
potentialSuggestions = commandsToSearch.filter(
|
||||
(cmd) => cmd.description,
|
||||
(cmd) => cmd.description && !cmd.hidden,
|
||||
);
|
||||
} else {
|
||||
// Use fuzzy search for non-empty partial queries with fallback
|
||||
@@ -400,7 +400,7 @@ export function useSlashCompletion(props: UseSlashCompletionProps): {
|
||||
const commandMap = new Map<string, SlashCommand>();
|
||||
|
||||
commands.forEach((cmd) => {
|
||||
if (cmd.description) {
|
||||
if (cmd.description && !cmd.hidden) {
|
||||
commandItems.push(cmd.name);
|
||||
commandMap.set(cmd.name, cmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user