From c51d6cc9d34bb3ff083f359cdd300502ea901ec8 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 1 Jun 2025 15:48:48 -0700 Subject: fix: Display MCP server count in context summary (#674) --- .../src/ui/components/ContextSummaryDisplay.tsx | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 packages/cli/src/ui/components/ContextSummaryDisplay.tsx (limited to 'packages/cli/src/ui/components/ContextSummaryDisplay.tsx') 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}; +}; -- cgit v1.2.3