mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-29 23:41:29 -07:00
Use IdeClient directly instead of config.ideClient (#7627)
This commit is contained in:
committed by
GitHub
parent
45d494a8d8
commit
cb43bb9ca4
@@ -86,8 +86,6 @@ import {
|
||||
SlashCommandStatus,
|
||||
ToolConfirmationOutcome,
|
||||
makeFakeConfig,
|
||||
ToolConfirmationOutcome,
|
||||
type IdeClient,
|
||||
} from '@google/gemini-cli-core';
|
||||
|
||||
function createTestCommand(
|
||||
@@ -111,11 +109,6 @@ describe('useSlashCommandProcessor', () => {
|
||||
const mockSetQuittingMessages = vi.fn();
|
||||
|
||||
const mockConfig = makeFakeConfig({});
|
||||
vi.spyOn(mockConfig, 'getIdeClient').mockReturnValue({
|
||||
addStatusChangeListener: vi.fn(),
|
||||
removeStatusChangeListener: vi.fn(),
|
||||
} as unknown as IdeClient);
|
||||
|
||||
const mockSettings = {} as LoadedSettings;
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
SlashCommandStatus,
|
||||
ToolConfirmationOutcome,
|
||||
Storage,
|
||||
IdeClient,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { useSessionStats } from '../contexts/SessionContext.js';
|
||||
import { runExitCleanup } from '../../utils/cleanup.js';
|
||||
@@ -215,15 +216,20 @@ export const useSlashCommandProcessor = (
|
||||
return;
|
||||
}
|
||||
|
||||
const ideClient = config.getIdeClient();
|
||||
const listener = () => {
|
||||
reloadCommands();
|
||||
};
|
||||
|
||||
ideClient.addStatusChangeListener(listener);
|
||||
(async () => {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
ideClient.addStatusChangeListener(listener);
|
||||
})();
|
||||
|
||||
return () => {
|
||||
ideClient.removeStatusChangeListener(listener);
|
||||
(async () => {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
ideClient.removeStatusChangeListener(listener);
|
||||
})();
|
||||
};
|
||||
}, [config, reloadCommands]);
|
||||
|
||||
|
||||
@@ -5,25 +5,26 @@
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';
|
||||
import type { Config } from '@google/gemini-cli-core';
|
||||
import { ideContext } from '@google/gemini-cli-core';
|
||||
import { IdeClient, ideContext } from '@google/gemini-cli-core';
|
||||
|
||||
/**
|
||||
* This hook listens for trust status updates from the IDE companion extension.
|
||||
* It provides the current trust status from the IDE and a flag indicating
|
||||
* if a restart is needed because the trust state has changed.
|
||||
*/
|
||||
export function useIdeTrustListener(config: Config) {
|
||||
const subscribe = useCallback(
|
||||
(onStoreChange: () => void) => {
|
||||
const ideClient = config.getIdeClient();
|
||||
export function useIdeTrustListener() {
|
||||
const subscribe = useCallback((onStoreChange: () => void) => {
|
||||
(async () => {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
ideClient.addTrustChangeListener(onStoreChange);
|
||||
return () => {
|
||||
})();
|
||||
return () => {
|
||||
(async () => {
|
||||
const ideClient = await IdeClient.getInstance();
|
||||
ideClient.removeTrustChangeListener(onStoreChange);
|
||||
};
|
||||
},
|
||||
[config],
|
||||
);
|
||||
})();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const getSnapshot = () =>
|
||||
ideContext.getIdeContext()?.workspaceState?.isTrusted;
|
||||
|
||||
Reference in New Issue
Block a user