mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-12 23:21:27 -07:00
chore: limit MCP resources display to 10 by default (#15489)
This commit is contained in:
@@ -184,4 +184,18 @@ describe('McpStatus', () => {
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('truncates resources when exceeding limit', () => {
|
||||
const manyResources = Array.from({ length: 25 }, (_, i) => ({
|
||||
serverName: 'server-1',
|
||||
name: `resource-${i + 1}`,
|
||||
uri: `file:///tmp/resource-${i + 1}.txt`,
|
||||
}));
|
||||
|
||||
const { lastFrame, unmount } = render(
|
||||
<McpStatus {...baseProps} resources={manyResources} />,
|
||||
);
|
||||
expect(lastFrame()).toContain('15 resources hidden');
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { MCPServerConfig } from '@google/gemini-cli-core';
|
||||
import { MCPServerStatus } from '@google/gemini-cli-core';
|
||||
import { Box, Text } from 'ink';
|
||||
import type React from 'react';
|
||||
import { MAX_MCP_RESOURCES_TO_SHOW } from '../../constants.js';
|
||||
import { theme } from '../../semantic-colors.js';
|
||||
import type {
|
||||
HistoryItemMcpStatus,
|
||||
@@ -251,28 +252,40 @@ export const McpStatus: React.FC<McpStatusProps> = ({
|
||||
{serverResources.length > 0 && (
|
||||
<Box flexDirection="column" marginLeft={2}>
|
||||
<Text color={theme.text.primary}>Resources:</Text>
|
||||
{serverResources.map((resource, index) => {
|
||||
const label = resource.name || resource.uri || 'resource';
|
||||
return (
|
||||
<Box
|
||||
key={`${resource.serverName}-resource-${index}`}
|
||||
flexDirection="column"
|
||||
>
|
||||
<Text>
|
||||
- <Text color={theme.text.primary}>{label}</Text>
|
||||
{resource.uri ? ` (${resource.uri})` : ''}
|
||||
{resource.mimeType ? ` [${resource.mimeType}]` : ''}
|
||||
</Text>
|
||||
{showDescriptions && resource.description && (
|
||||
<Box marginLeft={2}>
|
||||
<Text color={theme.text.secondary}>
|
||||
{resource.description.trim()}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
{serverResources
|
||||
.slice(0, MAX_MCP_RESOURCES_TO_SHOW)
|
||||
.map((resource, index) => {
|
||||
const label = resource.name || resource.uri || 'resource';
|
||||
return (
|
||||
<Box
|
||||
key={`${resource.serverName}-resource-${index}`}
|
||||
flexDirection="column"
|
||||
>
|
||||
<Text>
|
||||
- <Text color={theme.text.primary}>{label}</Text>
|
||||
{resource.uri ? ` (${resource.uri})` : ''}
|
||||
{resource.mimeType ? ` [${resource.mimeType}]` : ''}
|
||||
</Text>
|
||||
{showDescriptions && resource.description && (
|
||||
<Box marginLeft={2}>
|
||||
<Text color={theme.text.secondary}>
|
||||
{resource.description.trim()}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
{serverResources.length > MAX_MCP_RESOURCES_TO_SHOW && (
|
||||
<Text color={theme.text.secondary}>
|
||||
{' '}...{' '}
|
||||
{serverResources.length - MAX_MCP_RESOURCES_TO_SHOW}{' '}
|
||||
{serverResources.length - MAX_MCP_RESOURCES_TO_SHOW === 1
|
||||
? 'resource'
|
||||
: 'resources'}{' '}
|
||||
hidden
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -25,3 +25,6 @@ export const TOOL_STATUS = {
|
||||
CANCELED: '-',
|
||||
ERROR: 'x',
|
||||
} as const;
|
||||
|
||||
// Maximum number of MCP resources to display per server before truncating
|
||||
export const MAX_MCP_RESOURCES_TO_SHOW = 10;
|
||||
|
||||
Reference in New Issue
Block a user