mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-14 08:01:02 -07:00
Refactor IdeContextStore (#8278)
This commit is contained in:
committed by
GitHub
parent
538e6cd19a
commit
d892cde0b0
@@ -29,7 +29,7 @@ import {
|
||||
type UserTierId,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
IdeClient,
|
||||
ideContext,
|
||||
ideContextStore,
|
||||
getErrorMessage,
|
||||
getAllGeminiMdFilenames,
|
||||
AuthType,
|
||||
@@ -707,8 +707,8 @@ Logging in with Google... Please restart Gemini CLI to continue.
|
||||
}, [terminalWidth, refreshStatic]);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = ideContext.subscribeToIdeContext(setIdeContextState);
|
||||
setIdeContextState(ideContext.getIdeContext());
|
||||
const unsubscribe = ideContextStore.subscribe(setIdeContextState);
|
||||
setIdeContextState(ideContextStore.get());
|
||||
return unsubscribe;
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
import {
|
||||
getIdeInstaller,
|
||||
IDEConnectionStatus,
|
||||
ideContext,
|
||||
ideContextStore,
|
||||
GEMINI_CLI_COMPANION_EXTENSION_NAME,
|
||||
} from '@google/gemini-cli-core';
|
||||
import path from 'node:path';
|
||||
@@ -90,7 +90,7 @@ async function getIdeStatusMessageWithFiles(ideClient: IdeClient): Promise<{
|
||||
switch (connection.status) {
|
||||
case IDEConnectionStatus.Connected: {
|
||||
let content = `🟢 Connected to ${ideClient.getDetectedIdeDisplayName()}`;
|
||||
const context = ideContext.getIdeContext();
|
||||
const context = ideContextStore.get();
|
||||
const openFiles = context?.workspaceState?.openFiles;
|
||||
if (openFiles && openFiles.length > 0) {
|
||||
content += formatFileList(openFiles);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';
|
||||
import { IdeClient, ideContext } from '@google/gemini-cli-core';
|
||||
import { IdeClient, ideContextStore } from '@google/gemini-cli-core';
|
||||
|
||||
/**
|
||||
* This hook listens for trust status updates from the IDE companion extension.
|
||||
@@ -26,8 +26,7 @@ export function useIdeTrustListener() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const getSnapshot = () =>
|
||||
ideContext.getIdeContext()?.workspaceState?.isTrusted;
|
||||
const getSnapshot = () => ideContextStore.get()?.workspaceState?.isTrusted;
|
||||
|
||||
const isIdeTrusted = useSyncExternalStore(subscribe, getSnapshot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user