mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Adds the user's active file in the IDE to the footer (#4154)
This commit is contained in:
@@ -868,7 +868,7 @@ describe('loadCliConfig ideMode', () => {
|
||||
expect(config.getIdeMode()).toBe(false);
|
||||
});
|
||||
|
||||
it('should add __ide_server when ideMode is true', async () => {
|
||||
it('should add _ide_server when ideMode is true', async () => {
|
||||
process.argv = ['node', 'script.js', '--ide-mode'];
|
||||
const argv = await parseArguments();
|
||||
process.env.TERM_PROGRAM = 'vscode';
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
FileDiscoveryService,
|
||||
TelemetryTarget,
|
||||
MCPServerConfig,
|
||||
IDE_SERVER_NAME,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { Settings } from './settings.js';
|
||||
|
||||
@@ -285,7 +286,7 @@ export async function loadCliConfig(
|
||||
}
|
||||
|
||||
if (ideMode) {
|
||||
mcpServers['_ide_server'] = new MCPServerConfig(
|
||||
mcpServers[IDE_SERVER_NAME] = new MCPServerConfig(
|
||||
undefined, // command
|
||||
undefined, // args
|
||||
undefined, // env
|
||||
|
||||
@@ -4,10 +4,16 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { Colors } from '../colors.js';
|
||||
import { shortenPath, tildeifyPath, tokenLimit } from '@google/gemini-cli-core';
|
||||
import {
|
||||
shortenPath,
|
||||
tildeifyPath,
|
||||
tokenLimit,
|
||||
ideContext,
|
||||
ActiveFile,
|
||||
} from '@google/gemini-cli-core';
|
||||
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
|
||||
import process from 'node:process';
|
||||
import Gradient from 'ink-gradient';
|
||||
@@ -43,6 +49,24 @@ export const Footer: React.FC<FooterProps> = ({
|
||||
const limit = tokenLimit(model);
|
||||
const percentage = promptTokenCount / limit;
|
||||
|
||||
const [activeFile, setActiveFile] = useState<ActiveFile | undefined>(
|
||||
undefined,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const updateActiveFile = () => {
|
||||
const currentActiveFile = ideContext.getActiveFileContext();
|
||||
setActiveFile(currentActiveFile);
|
||||
};
|
||||
|
||||
updateActiveFile();
|
||||
|
||||
const unsubscribe = ideContext.subscribeToActiveFile(setActiveFile);
|
||||
return () => {
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Box marginTop={1} justifyContent="space-between" width="100%">
|
||||
<Box>
|
||||
@@ -59,6 +83,19 @@ export const Footer: React.FC<FooterProps> = ({
|
||||
{branchName && <Text color={Colors.Gray}> ({branchName}*)</Text>}
|
||||
</Text>
|
||||
)}
|
||||
{activeFile && activeFile.filePath && (
|
||||
<Text>
|
||||
<Text color={Colors.Gray}> | </Text>
|
||||
<Text color={Colors.LightBlue}>
|
||||
{shortenPath(tildeifyPath(activeFile.filePath), 70)}
|
||||
</Text>
|
||||
{activeFile.cursor && (
|
||||
<Text color={Colors.Gray}>
|
||||
:{activeFile.cursor.line}:{activeFile.cursor.character}
|
||||
</Text>
|
||||
)}
|
||||
</Text>
|
||||
)}
|
||||
{debugMode && (
|
||||
<Text color={Colors.AccentRed}>
|
||||
{' ' + (debugMessage || '--debug')}
|
||||
|
||||
Reference in New Issue
Block a user