From b09bc6656080d4d12e1d06734aae2ec33af5c1ed Mon Sep 17 00:00:00 2001 From: Shreya Keshive Date: Tue, 15 Jul 2025 10:19:59 -0400 Subject: Adds the user's active file in the IDE to the footer (#4154) --- packages/cli/src/ui/components/Footer.tsx | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'packages/cli/src/ui/components') diff --git a/packages/cli/src/ui/components/Footer.tsx b/packages/cli/src/ui/components/Footer.tsx index 95904cd9..5524114b 100644 --- a/packages/cli/src/ui/components/Footer.tsx +++ b/packages/cli/src/ui/components/Footer.tsx @@ -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 = ({ const limit = tokenLimit(model); const percentage = promptTokenCount / limit; + const [activeFile, setActiveFile] = useState( + undefined, + ); + + useEffect(() => { + const updateActiveFile = () => { + const currentActiveFile = ideContext.getActiveFileContext(); + setActiveFile(currentActiveFile); + }; + + updateActiveFile(); + + const unsubscribe = ideContext.subscribeToActiveFile(setActiveFile); + return () => { + unsubscribe(); + }; + }, []); + return ( @@ -59,6 +83,19 @@ export const Footer: React.FC = ({ {branchName && ({branchName}*)} )} + {activeFile && activeFile.filePath && ( + + | + + {shortenPath(tildeifyPath(activeFile.filePath), 70)} + + {activeFile.cursor && ( + + :{activeFile.cursor.line}:{activeFile.cursor.character} + + )} + + )} {debugMode && ( {' ' + (debugMessage || '--debug')} -- cgit v1.2.3