mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Add drawer for active files in IDE mode (#4682)
Co-authored-by: Shreya <shreyakeshive@google.com>
This commit is contained in:
@@ -8,7 +8,6 @@ import React from 'react';
|
||||
import { Text } from 'ink';
|
||||
import { Colors } from '../colors.js';
|
||||
import { type OpenFiles, type MCPServerConfig } from '@google/gemini-cli-core';
|
||||
import path from 'path';
|
||||
|
||||
interface ContextSummaryDisplayProps {
|
||||
geminiMdFileCount: number;
|
||||
@@ -34,16 +33,17 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
|
||||
geminiMdFileCount === 0 &&
|
||||
mcpServerCount === 0 &&
|
||||
blockedMcpServerCount === 0 &&
|
||||
!openFiles?.activeFile
|
||||
(openFiles?.recentOpenFiles?.length ?? 0) === 0
|
||||
) {
|
||||
return <Text> </Text>; // Render an empty space to reserve height
|
||||
}
|
||||
|
||||
const activeFileText = (() => {
|
||||
if (!openFiles?.activeFile) {
|
||||
const recentFilesText = (() => {
|
||||
const count = openFiles?.recentOpenFiles?.length ?? 0;
|
||||
if (count === 0) {
|
||||
return '';
|
||||
}
|
||||
return `Open File (${path.basename(openFiles.activeFile)})`;
|
||||
return `${count} recent file${count > 1 ? 's' : ''} (ctrl+e to view)`;
|
||||
})();
|
||||
|
||||
const geminiMdText = (() => {
|
||||
@@ -51,8 +51,8 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
|
||||
return '';
|
||||
}
|
||||
const allNamesTheSame = new Set(contextFileNames).size < 2;
|
||||
const name = allNamesTheSame ? contextFileNames[0] : 'Context';
|
||||
return `${geminiMdFileCount} ${name} File${
|
||||
const name = allNamesTheSame ? contextFileNames[0] : 'context';
|
||||
return `${geminiMdFileCount} ${name} file${
|
||||
geminiMdFileCount > 1 ? 's' : ''
|
||||
}`;
|
||||
})();
|
||||
@@ -65,14 +65,14 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
|
||||
const parts = [];
|
||||
if (mcpServerCount > 0) {
|
||||
parts.push(
|
||||
`${mcpServerCount} MCP Server${mcpServerCount > 1 ? 's' : ''}`,
|
||||
`${mcpServerCount} MCP server${mcpServerCount > 1 ? 's' : ''}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (blockedMcpServerCount > 0) {
|
||||
let blockedText = `${blockedMcpServerCount} Blocked`;
|
||||
if (mcpServerCount === 0) {
|
||||
blockedText += ` MCP Server${blockedMcpServerCount > 1 ? 's' : ''}`;
|
||||
blockedText += ` MCP server${blockedMcpServerCount > 1 ? 's' : ''}`;
|
||||
}
|
||||
parts.push(blockedText);
|
||||
}
|
||||
@@ -81,8 +81,8 @@ export const ContextSummaryDisplay: React.FC<ContextSummaryDisplayProps> = ({
|
||||
|
||||
let summaryText = 'Using: ';
|
||||
const summaryParts = [];
|
||||
if (activeFileText) {
|
||||
summaryParts.push(activeFileText);
|
||||
if (recentFilesText) {
|
||||
summaryParts.push(recentFilesText);
|
||||
}
|
||||
if (geminiMdText) {
|
||||
summaryParts.push(geminiMdText);
|
||||
|
||||
52
packages/cli/src/ui/components/IDEContextDetailDisplay.tsx
Normal file
52
packages/cli/src/ui/components/IDEContextDetailDisplay.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { Box, Text } from 'ink';
|
||||
import { type OpenFiles } from '@google/gemini-cli-core';
|
||||
import { Colors } from '../colors.js';
|
||||
import path from 'node:path';
|
||||
|
||||
interface IDEContextDetailDisplayProps {
|
||||
openFiles: OpenFiles | undefined;
|
||||
}
|
||||
|
||||
export function IDEContextDetailDisplay({
|
||||
openFiles,
|
||||
}: IDEContextDetailDisplayProps) {
|
||||
if (
|
||||
!openFiles ||
|
||||
!openFiles.recentOpenFiles ||
|
||||
openFiles.recentOpenFiles.length === 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const recentFiles = openFiles.recentOpenFiles || [];
|
||||
|
||||
return (
|
||||
<Box
|
||||
flexDirection="column"
|
||||
marginTop={1}
|
||||
borderStyle="round"
|
||||
borderColor={Colors.AccentCyan}
|
||||
paddingX={1}
|
||||
>
|
||||
<Text color={Colors.AccentCyan} bold>
|
||||
IDE Context (ctrl+e to toggle)
|
||||
</Text>
|
||||
{recentFiles.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>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user