mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 01:51:20 -07:00
[Extension Reloading]: Update custom commands, add enable/disable command (#12547)
This commit is contained in:
@@ -8,7 +8,11 @@ import { useCallback, useMemo, useEffect, useState } from 'react';
|
||||
import { type PartListUnion } from '@google/genai';
|
||||
import process from 'node:process';
|
||||
import type { UseHistoryManagerReturn } from './useHistoryManager.js';
|
||||
import type { Config } from '@google/gemini-cli-core';
|
||||
import type {
|
||||
Config,
|
||||
ExtensionsStartingEvent,
|
||||
ExtensionsStoppingEvent,
|
||||
} from '@google/gemini-cli-core';
|
||||
import {
|
||||
GitService,
|
||||
Logger,
|
||||
@@ -39,6 +43,7 @@ import {
|
||||
type ExtensionUpdateAction,
|
||||
type ExtensionUpdateStatus,
|
||||
} from '../state/extensions.js';
|
||||
import { appEvents } from '../../utils/events.js';
|
||||
|
||||
interface SlashCommandProcessorActions {
|
||||
openAuthDialog: () => void;
|
||||
@@ -249,11 +254,27 @@ export const useSlashCommandProcessor = (
|
||||
ideClient.addStatusChangeListener(listener);
|
||||
})();
|
||||
|
||||
// TODO: Ideally this would happen more directly inside the ExtensionLoader,
|
||||
// but the CommandService today is not conducive to that since it isn't a
|
||||
// long lived service but instead gets fully re-created based on reload
|
||||
// events within this hook.
|
||||
const extensionEventListener = (
|
||||
_event: ExtensionsStartingEvent | ExtensionsStoppingEvent,
|
||||
) => {
|
||||
// We only care once at least one extension has completed
|
||||
// starting/stopping
|
||||
reloadCommands();
|
||||
};
|
||||
appEvents.on('extensionsStarting', extensionEventListener);
|
||||
appEvents.on('extensionsStopping', extensionEventListener);
|
||||
|
||||
return () => {
|
||||
(async () => {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
ideClient.removeStatusChangeListener(listener);
|
||||
})();
|
||||
appEvents.off('extensionsStarting', extensionEventListener);
|
||||
appEvents.off('extensionsStopping', extensionEventListener);
|
||||
};
|
||||
}, [config, reloadCommands]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user