[Extension Reloading]: Update custom commands, add enable/disable command (#12547)

This commit is contained in:
Jacob MacDonald
2025-11-05 11:36:07 -08:00
committed by GitHub
parent ca6cfaaf4e
commit fa93b56243
24 changed files with 664 additions and 187 deletions

View File

@@ -26,6 +26,7 @@ import {
ToolConfirmationOutcome,
makeFakeConfig,
} from '@google/gemini-cli-core';
import { appEvents } from '../../utils/events.js';
const { logSlashCommand } = vi.hoisted(() => ({
logSlashCommand: vi.fn(),
@@ -1076,4 +1077,26 @@ describe('useSlashCommandProcessor', () => {
expect(logSlashCommand).not.toHaveBeenCalled();
});
});
it('should reload commands on extension events', async () => {
const result = await setupProcessorHook();
await waitFor(() => expect(result.current.slashCommands).toEqual([]));
// Create a new command and make that the result of the fileLoadCommands
// (which is where extension commands come from)
const newCommand = createTestCommand({
name: 'someNewCommand',
action: vi.fn(),
});
mockFileLoadCommands.mockResolvedValue([newCommand]);
// We should not see a change until we fire an event.
await waitFor(() => expect(result.current.slashCommands).toEqual([]));
await act(() => {
appEvents.emit('extensionsStarting');
});
await waitFor(() =>
expect(result.current.slashCommands).toEqual([newCommand]),
);
});
});