diff --git a/packages/cli/src/ui/App.test.tsx b/packages/cli/src/ui/App.test.tsx index a7811f6a..17d9b459 100644 --- a/packages/cli/src/ui/App.test.tsx +++ b/packages/cli/src/ui/App.test.tsx @@ -286,4 +286,45 @@ describe('App UI', () => { await Promise.resolve(); expect(lastFrame()).not.toContain('ANY_FILE.MD'); }); + + it('should display GEMINI.md and MCP server count when both are present', async () => { + mockConfig.getGeminiMdFileCount.mockReturnValue(2); + mockConfig.getMcpServers.mockReturnValue({ + server1: {} as MCPServerConfig, + }); + mockConfig.getDebugMode.mockReturnValue(false); + mockConfig.getShowMemoryUsage.mockReturnValue(false); + + const { lastFrame, unmount } = render( + , + ); + currentUnmount = unmount; + await Promise.resolve(); + expect(lastFrame()).toContain('server'); + }); + + it('should display only MCP server count when GEMINI.md count is 0', async () => { + mockConfig.getGeminiMdFileCount.mockReturnValue(0); + mockConfig.getMcpServers.mockReturnValue({ + server1: {} as MCPServerConfig, + server2: {} as MCPServerConfig, + }); + mockConfig.getDebugMode.mockReturnValue(false); + mockConfig.getShowMemoryUsage.mockReturnValue(false); + + const { lastFrame, unmount } = render( + , + ); + currentUnmount = unmount; + await Promise.resolve(); + expect(lastFrame()).toContain('Using 2 MCP servers'); + }); }); diff --git a/packages/cli/src/ui/App.tsx b/packages/cli/src/ui/App.tsx index baab7fcc..73643bd5 100644 --- a/packages/cli/src/ui/App.tsx +++ b/packages/cli/src/ui/App.tsx @@ -37,6 +37,7 @@ import { Tips } from './components/Tips.js'; import { useConsolePatcher } from './components/ConsolePatcher.js'; import { DetailedMessagesDisplay } from './components/DetailedMessagesDisplay.js'; import { HistoryItemDisplay } from './components/HistoryItemDisplay.js'; +import { ContextSummaryDisplay } from './components/ContextSummaryDisplay.js'; import { useHistory } from './hooks/useHistoryManager.js'; import process from 'node:process'; import { @@ -399,16 +400,15 @@ export const App = ({ Press Ctrl+C again to exit. - ) : geminiMdFileCount > 0 ? ( - - Using {geminiMdFileCount}{' '} - {settings.merged.contextFileName || - getCurrentGeminiMdFilename()}{' '} - file - {geminiMdFileCount > 1 ? 's' : ''} - ) : ( - // Render an empty space to reserve height + )} diff --git a/packages/cli/src/ui/components/ContextSummaryDisplay.tsx b/packages/cli/src/ui/components/ContextSummaryDisplay.tsx new file mode 100644 index 00000000..3cfb4d8d --- /dev/null +++ b/packages/cli/src/ui/components/ContextSummaryDisplay.tsx @@ -0,0 +1,51 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { Text } from 'ink'; +import { Colors } from '../colors.js'; +import { type MCPServerConfig } from '@gemini-code/core'; + +interface ContextSummaryDisplayProps { + geminiMdFileCount: number; + contextFileName: string; + mcpServers?: Record; +} + +export const ContextSummaryDisplay: React.FC = ({ + geminiMdFileCount, + contextFileName, + mcpServers, +}) => { + const mcpServerCount = Object.keys(mcpServers || {}).length; + + if (geminiMdFileCount === 0 && mcpServerCount === 0) { + return ; // Render an empty space to reserve height + } + + const geminiMdText = + geminiMdFileCount > 0 + ? `${geminiMdFileCount} ${contextFileName} file${geminiMdFileCount > 1 ? 's' : ''}` + : ''; + + const mcpText = + mcpServerCount > 0 + ? `${mcpServerCount} MCP server${mcpServerCount > 1 ? 's' : ''}` + : ''; + + let summaryText = 'Using '; + if (geminiMdText) { + summaryText += geminiMdText; + } + if (geminiMdText && mcpText) { + summaryText += ' and '; + } + if (mcpText) { + summaryText += mcpText; + } + + return {summaryText}; +};