mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-16 04:50:29 -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();
|
expect(lastFrame()).toMatchSnapshot();
|
||||||
unmount();
|
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 { MCPServerStatus } from '@google/gemini-cli-core';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
|
import { MAX_MCP_RESOURCES_TO_SHOW } from '../../constants.js';
|
||||||
import { theme } from '../../semantic-colors.js';
|
import { theme } from '../../semantic-colors.js';
|
||||||
import type {
|
import type {
|
||||||
HistoryItemMcpStatus,
|
HistoryItemMcpStatus,
|
||||||
@@ -251,28 +252,40 @@ export const McpStatus: React.FC<McpStatusProps> = ({
|
|||||||
{serverResources.length > 0 && (
|
{serverResources.length > 0 && (
|
||||||
<Box flexDirection="column" marginLeft={2}>
|
<Box flexDirection="column" marginLeft={2}>
|
||||||
<Text color={theme.text.primary}>Resources:</Text>
|
<Text color={theme.text.primary}>Resources:</Text>
|
||||||
{serverResources.map((resource, index) => {
|
{serverResources
|
||||||
const label = resource.name || resource.uri || 'resource';
|
.slice(0, MAX_MCP_RESOURCES_TO_SHOW)
|
||||||
return (
|
.map((resource, index) => {
|
||||||
<Box
|
const label = resource.name || resource.uri || 'resource';
|
||||||
key={`${resource.serverName}-resource-${index}`}
|
return (
|
||||||
flexDirection="column"
|
<Box
|
||||||
>
|
key={`${resource.serverName}-resource-${index}`}
|
||||||
<Text>
|
flexDirection="column"
|
||||||
- <Text color={theme.text.primary}>{label}</Text>
|
>
|
||||||
{resource.uri ? ` (${resource.uri})` : ''}
|
<Text>
|
||||||
{resource.mimeType ? ` [${resource.mimeType}]` : ''}
|
- <Text color={theme.text.primary}>{label}</Text>
|
||||||
</Text>
|
{resource.uri ? ` (${resource.uri})` : ''}
|
||||||
{showDescriptions && resource.description && (
|
{resource.mimeType ? ` [${resource.mimeType}]` : ''}
|
||||||
<Box marginLeft={2}>
|
</Text>
|
||||||
<Text color={theme.text.secondary}>
|
{showDescriptions && resource.description && (
|
||||||
{resource.description.trim()}
|
<Box marginLeft={2}>
|
||||||
</Text>
|
<Text color={theme.text.secondary}>
|
||||||
</Box>
|
{resource.description.trim()}
|
||||||
)}
|
</Text>
|
||||||
</Box>
|
</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>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -25,3 +25,6 @@ export const TOOL_STATUS = {
|
|||||||
CANCELED: '-',
|
CANCELED: '-',
|
||||||
ERROR: 'x',
|
ERROR: 'x',
|
||||||
} as const;
|
} 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