diff options
Diffstat (limited to 'packages/cli/src/ui/components')
| -rw-r--r-- | packages/cli/src/ui/components/ContextSummaryDisplay.tsx | 22 | ||||
| -rw-r--r-- | packages/cli/src/ui/components/IDEContextDetailDisplay.tsx | 52 |
2 files changed, 63 insertions, 11 deletions
diff --git a/packages/cli/src/ui/components/ContextSummaryDisplay.tsx b/packages/cli/src/ui/components/ContextSummaryDisplay.tsx index 626a2fa5..b166056a 100644 --- a/packages/cli/src/ui/components/ContextSummaryDisplay.tsx +++ b/packages/cli/src/ui/components/ContextSummaryDisplay.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { Text } from 'ink'; import { Colors } from '../colors.js'; import { type OpenFiles, type MCPServerConfig } from '@google/gemini-cli-core'; -import path from 'path'; interface ContextSummaryDisplayProps { geminiMdFileCount: number; @@ -34,16 +33,17 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({ geminiMdFileCount === 0 && mcpServerCount === 0 && blockedMcpServerCount === 0 && - !openFiles?.activeFile + (openFiles?.recentOpenFiles?.length ?? 0) === 0 ) { return <Text> </Text>; // Render an empty space to reserve height } - const activeFileText = (() => { - if (!openFiles?.activeFile) { + const recentFilesText = (() => { + const count = openFiles?.recentOpenFiles?.length ?? 0; + if (count === 0) { return ''; } - return `Open File (${path.basename(openFiles.activeFile)})`; + return `${count} recent file${count > 1 ? 's' : ''} (ctrl+e to view)`; })(); const geminiMdText = (() => { @@ -51,8 +51,8 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({ return ''; } const allNamesTheSame = new Set(contextFileNames).size < 2; - const name = allNamesTheSame ? contextFileNames[0] : 'Context'; - return `${geminiMdFileCount} ${name} File${ + const name = allNamesTheSame ? contextFileNames[0] : 'context'; + return `${geminiMdFileCount} ${name} file${ geminiMdFileCount > 1 ? 's' : '' }`; })(); @@ -65,14 +65,14 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({ const parts = []; if (mcpServerCount > 0) { parts.push( - `${mcpServerCount} MCP Server${mcpServerCount > 1 ? 's' : ''}`, + `${mcpServerCount} MCP server${mcpServerCount > 1 ? 's' : ''}`, ); } if (blockedMcpServerCount > 0) { let blockedText = `${blockedMcpServerCount} Blocked`; if (mcpServerCount === 0) { - blockedText += ` MCP Server${blockedMcpServerCount > 1 ? 's' : ''}`; + blockedText += ` MCP server${blockedMcpServerCount > 1 ? 's' : ''}`; } parts.push(blockedText); } @@ -81,8 +81,8 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({ let summaryText = 'Using: '; const summaryParts = []; - if (activeFileText) { - summaryParts.push(activeFileText); + if (recentFilesText) { + summaryParts.push(recentFilesText); } if (geminiMdText) { summaryParts.push(geminiMdText); diff --git a/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx b/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx new file mode 100644 index 00000000..8d4fb2c9 --- /dev/null +++ b/packages/cli/src/ui/components/IDEContextDetailDisplay.tsx @@ -0,0 +1,52 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { Box, Text } from 'ink'; +import { type OpenFiles } from '@google/gemini-cli-core'; +import { Colors } from '../colors.js'; +import path from 'node:path'; + +interface IDEContextDetailDisplayProps { + openFiles: OpenFiles | undefined; +} + +export function IDEContextDetailDisplay({ + openFiles, +}: IDEContextDetailDisplayProps) { + if ( + !openFiles || + !openFiles.recentOpenFiles || + openFiles.recentOpenFiles.length === 0 + ) { + return null; + } + const recentFiles = openFiles.recentOpenFiles || []; + + return ( + <Box + flexDirection="column" + marginTop={1} + borderStyle="round" + borderColor={Colors.AccentCyan} + paddingX={1} + > + <Text color={Colors.AccentCyan} bold> + IDE Context (ctrl+e to toggle) + </Text> + {recentFiles.length > 0 && ( + <Box flexDirection="column" marginTop={1}> + <Text bold>Recent files:</Text> + {recentFiles.map((file) => ( + <Text key={file.filePath}> + - {path.basename(file.filePath)} + {file.filePath === openFiles.activeFile ? ' (active)' : ''} + </Text> + ))} + </Box> + )} + </Box> + ); +} |
