summaryrefslogtreecommitdiff
path: root/packages/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src')
-rw-r--r--packages/cli/src/ui/App.test.tsx26
-rw-r--r--packages/cli/src/ui/App.tsx10
-rw-r--r--packages/cli/src/ui/components/ContextSummaryDisplay.tsx12
3 files changed, 22 insertions, 26 deletions
diff --git a/packages/cli/src/ui/App.test.tsx b/packages/cli/src/ui/App.test.tsx
index ceab46b1..0712d810 100644
--- a/packages/cli/src/ui/App.test.tsx
+++ b/packages/cli/src/ui/App.test.tsx
@@ -151,8 +151,8 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
});
const ideContextMock = {
- getActiveFileContext: vi.fn(),
- subscribeToActiveFile: vi.fn(() => vi.fn()), // subscribe returns an unsubscribe function
+ getOpenFilesContext: vi.fn(),
+ subscribeToOpenFiles: vi.fn(() => vi.fn()), // subscribe returns an unsubscribe function
};
return {
@@ -267,7 +267,7 @@ describe('App UI', () => {
// Ensure a theme is set so the theme dialog does not appear.
mockSettings = createMockSettings({ workspace: { theme: 'Default' } });
- vi.mocked(ideContext.getActiveFileContext).mockReturnValue(undefined);
+ vi.mocked(ideContext.getOpenFilesContext).mockReturnValue(undefined);
});
afterEach(() => {
@@ -279,10 +279,9 @@ describe('App UI', () => {
});
it('should display active file when available', async () => {
- vi.mocked(ideContext.getActiveFileContext).mockReturnValue({
- filePath: '/path/to/my-file.ts',
- content: 'const a = 1;',
- cursor: 0,
+ vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
+ activeFile: '/path/to/my-file.ts',
+ selectedText: 'hello',
});
const { lastFrame, unmount } = render(
@@ -298,10 +297,8 @@ describe('App UI', () => {
});
it('should not display active file when not available', async () => {
- vi.mocked(ideContext.getActiveFileContext).mockReturnValue({
- filePath: '',
- content: '',
- cursor: 0,
+ vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
+ activeFile: '',
});
const { lastFrame, unmount } = render(
@@ -317,10 +314,9 @@ describe('App UI', () => {
});
it('should display active file and other context', async () => {
- vi.mocked(ideContext.getActiveFileContext).mockReturnValue({
- filePath: '/path/to/my-file.ts',
- content: 'const a = 1;',
- cursor: 0,
+ vi.mocked(ideContext.getOpenFilesContext).mockReturnValue({
+ activeFile: '/path/to/my-file.ts',
+ selectedText: 'hello',
});
mockConfig.getGeminiMdFileCount.mockReturnValue(1);
diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx
index c6e6bd43..12838710 100644
--- a/packages/cli/src/ui/App.tsx
+++ b/packages/cli/src/ui/App.tsx
@@ -58,7 +58,7 @@ import {
FlashFallbackEvent,
logFlashFallback,
AuthType,
- type ActiveFile,
+ type OpenFiles,
ideContext,
} from '@google/gemini-cli-core';
import { validateAuthMethod } from '../config/auth.js';
@@ -160,12 +160,12 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
const [modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError] =
useState<boolean>(false);
const [userTier, setUserTier] = useState<UserTierId | undefined>(undefined);
- const [activeFile, setActiveFile] = useState<ActiveFile | undefined>();
+ const [openFiles, setOpenFiles] = useState<OpenFiles | undefined>();
useEffect(() => {
- const unsubscribe = ideContext.subscribeToActiveFile(setActiveFile);
+ const unsubscribe = ideContext.subscribeToOpenFiles(setOpenFiles);
// Set the initial value
- setActiveFile(ideContext.getActiveFileContext());
+ setOpenFiles(ideContext.getOpenFilesContext());
return unsubscribe;
}, []);
@@ -880,7 +880,7 @@ const App = ({ config, settings, startupWarnings = [], version }: AppProps) => {
</Text>
) : (
<ContextSummaryDisplay
- activeFile={activeFile}
+ openFiles={openFiles}
geminiMdFileCount={geminiMdFileCount}
contextFileNames={contextFileNames}
mcpServers={config.getMcpServers()}
diff --git a/packages/cli/src/ui/components/ContextSummaryDisplay.tsx b/packages/cli/src/ui/components/ContextSummaryDisplay.tsx
index d1ef8135..626a2fa5 100644
--- a/packages/cli/src/ui/components/ContextSummaryDisplay.tsx
+++ b/packages/cli/src/ui/components/ContextSummaryDisplay.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { Text } from 'ink';
import { Colors } from '../colors.js';
-import { type ActiveFile, type MCPServerConfig } from '@google/gemini-cli-core';
+import { type OpenFiles, type MCPServerConfig } from '@google/gemini-cli-core';
import path from 'path';
interface ContextSummaryDisplayProps {
@@ -16,7 +16,7 @@ interface ContextSummaryDisplayProps {
mcpServers?: Record<string, MCPServerConfig>;
blockedMcpServers?: Array<{ name: string; extensionName: string }>;
showToolDescriptions?: boolean;
- activeFile?: ActiveFile;
+ openFiles?: OpenFiles;
}
export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
@@ -25,7 +25,7 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
mcpServers,
blockedMcpServers,
showToolDescriptions,
- activeFile,
+ openFiles,
}) => {
const mcpServerCount = Object.keys(mcpServers || {}).length;
const blockedMcpServerCount = blockedMcpServers?.length || 0;
@@ -34,16 +34,16 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
geminiMdFileCount === 0 &&
mcpServerCount === 0 &&
blockedMcpServerCount === 0 &&
- !activeFile?.filePath
+ !openFiles?.activeFile
) {
return <Text> </Text>; // Render an empty space to reserve height
}
const activeFileText = (() => {
- if (!activeFile?.filePath) {
+ if (!openFiles?.activeFile) {
return '';
}
- return `Open File (${path.basename(activeFile.filePath)})`;
+ return `Open File (${path.basename(openFiles.activeFile)})`;
})();
const geminiMdText = (() => {