Updates schema, UX and prompt for IDE context (#5046)

This commit is contained in:
Shreya Keshive
2025-07-28 11:03:22 -04:00
committed by GitHub
parent 16322ed0b2
commit 165b29c3b1
10 changed files with 680 additions and 259 deletions

View File

@@ -7,7 +7,7 @@
import React from 'react';
import { Text } from 'ink';
import { Colors } from '../colors.js';
import { type OpenFiles, type MCPServerConfig } from '@google/gemini-cli-core';
import { type IdeContext, type MCPServerConfig } from '@google/gemini-cli-core';
interface ContextSummaryDisplayProps {
geminiMdFileCount: number;
@@ -15,7 +15,7 @@ interface ContextSummaryDisplayProps {
mcpServers?: Record<string, MCPServerConfig>;
blockedMcpServers?: Array<{ name: string; extensionName: string }>;
showToolDescriptions?: boolean;
openFiles?: OpenFiles;
ideContext?: IdeContext;
}
export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
@@ -24,26 +24,28 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
mcpServers,
blockedMcpServers,
showToolDescriptions,
openFiles,
ideContext,
}) => {
const mcpServerCount = Object.keys(mcpServers || {}).length;
const blockedMcpServerCount = blockedMcpServers?.length || 0;
const openFileCount = ideContext?.workspaceState?.openFiles?.length ?? 0;
if (
geminiMdFileCount === 0 &&
mcpServerCount === 0 &&
blockedMcpServerCount === 0 &&
(openFiles?.recentOpenFiles?.length ?? 0) === 0
openFileCount === 0
) {
return <Text> </Text>; // Render an empty space to reserve height
}
const recentFilesText = (() => {
const count = openFiles?.recentOpenFiles?.length ?? 0;
if (count === 0) {
const openFilesText = (() => {
if (openFileCount === 0) {
return '';
}
return `${count} recent file${count > 1 ? 's' : ''} (ctrl+e to view)`;
return `${openFileCount} open file${
openFileCount > 1 ? 's' : ''
} (ctrl+e to view)`;
})();
const geminiMdText = (() => {
@@ -81,8 +83,8 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
let summaryText = 'Using: ';
const summaryParts = [];
if (recentFilesText) {
summaryParts.push(recentFilesText);
if (openFilesText) {
summaryParts.push(openFilesText);
}
if (geminiMdText) {
summaryParts.push(geminiMdText);

View File

@@ -5,25 +5,21 @@
*/
import { Box, Text } from 'ink';
import { type OpenFiles } from '@google/gemini-cli-core';
import { type File, type IdeContext } from '@google/gemini-cli-core';
import { Colors } from '../colors.js';
import path from 'node:path';
interface IDEContextDetailDisplayProps {
openFiles: OpenFiles | undefined;
ideContext: IdeContext | undefined;
}
export function IDEContextDetailDisplay({
openFiles,
ideContext,
}: IDEContextDetailDisplayProps) {
if (
!openFiles ||
!openFiles.recentOpenFiles ||
openFiles.recentOpenFiles.length === 0
) {
const openFiles = ideContext?.workspaceState?.openFiles;
if (!openFiles || openFiles.length === 0) {
return null;
}
const recentFiles = openFiles.recentOpenFiles || [];
return (
<Box
@@ -36,13 +32,13 @@ export function IDEContextDetailDisplay({
<Text color={Colors.AccentCyan} bold>
IDE Context (ctrl+e to toggle)
</Text>
{recentFiles.length > 0 && (
{openFiles.length > 0 && (
<Box flexDirection="column" marginTop={1}>
<Text bold>Recent files:</Text>
{recentFiles.map((file) => (
<Text key={file.filePath}>
- {path.basename(file.filePath)}
{file.filePath === openFiles.activeFile ? ' (active)' : ''}
<Text bold>Open files:</Text>
{openFiles.map((file: File) => (
<Text key={file.path}>
- {path.basename(file.path)}
{file.isActive ? ' (active)' : ''}
</Text>
))}
</Box>