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.tsx41
-rw-r--r--packages/cli/src/ui/App.tsx18
-rw-r--r--packages/cli/src/ui/components/ContextSummaryDisplay.tsx51
3 files changed, 101 insertions, 9 deletions
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(
+ <App
+ config={mockConfig as unknown as ServerConfig}
+ settings={mockSettings}
+ cliVersion="1.0.0"
+ />,
+ );
+ 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(
+ <App
+ config={mockConfig as unknown as ServerConfig}
+ settings={mockSettings}
+ cliVersion="1.0.0"
+ />,
+ );
+ 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 = ({
<Text color={Colors.AccentYellow}>
Press Ctrl+C again to exit.
</Text>
- ) : geminiMdFileCount > 0 ? (
- <Text color={Colors.SubtleComment}>
- Using {geminiMdFileCount}{' '}
- {settings.merged.contextFileName ||
- getCurrentGeminiMdFilename()}{' '}
- file
- {geminiMdFileCount > 1 ? 's' : ''}
- </Text>
) : (
- <Text> </Text> // Render an empty space to reserve height
+ <ContextSummaryDisplay
+ geminiMdFileCount={geminiMdFileCount}
+ contextFileName={
+ settings.merged.contextFileName ||
+ getCurrentGeminiMdFilename()
+ }
+ mcpServers={config.getMcpServers()}
+ />
)}
</Box>
<Box>
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<string, MCPServerConfig>;
+}
+
+export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
+ geminiMdFileCount,
+ contextFileName,
+ mcpServers,
+}) => {
+ const mcpServerCount = Object.keys(mcpServers || {}).length;
+
+ if (geminiMdFileCount === 0 && mcpServerCount === 0) {
+ return <Text> </Text>; // 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 <Text color={Colors.SubtleComment}>{summaryText}</Text>;
+};