From b3d89a10758462947546a7d9be43bf617c0787c6 Mon Sep 17 00:00:00 2001 From: Asad Memon Date: Sun, 15 Jun 2025 11:15:53 -0700 Subject: feat: Add token stats in footer (#909) --- packages/cli/src/ui/components/Footer.tsx | 127 +++++++++++++++++------------- 1 file changed, 71 insertions(+), 56 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 d051f2b7..779eefcd 100644 --- a/packages/cli/src/ui/components/Footer.tsx +++ b/packages/cli/src/ui/components/Footer.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { Box, Text } from 'ink'; import { Colors } from '../colors.js'; -import { shortenPath, tildeifyPath } from '@gemini-cli/core'; +import { shortenPath, tildeifyPath, tokenLimit } from '@gemini-cli/core'; import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js'; import process from 'node:process'; import { MemoryUsageDisplay } from './MemoryUsageDisplay.js'; @@ -22,6 +22,9 @@ interface FooterProps { errorCount: number; showErrorDetails: boolean; showMemoryUsage?: boolean; + promptTokenCount: number; + candidatesTokenCount: number; + totalTokenCount: number; } export const Footer: React.FC = ({ @@ -34,63 +37,75 @@ export const Footer: React.FC = ({ errorCount, showErrorDetails, showMemoryUsage, -}) => ( - - - - {shortenPath(tildeifyPath(targetDir), 70)} - {branchName && ({branchName}*)} - - {debugMode && ( - - {' ' + (debugMessage || '--debug')} - - )} - + totalTokenCount, +}) => { + const limit = tokenLimit(model); + const percentage = totalTokenCount / limit; - {/* Middle Section: Centered Sandbox Info */} - - {process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec' ? ( - - {process.env.SANDBOX.replace(/^gemini-(?:cli-)?/, '')} - - ) : process.env.SANDBOX === 'sandbox-exec' ? ( - - MacOS Seatbelt{' '} - ({process.env.SEATBELT_PROFILE}) + return ( + + + + {shortenPath(tildeifyPath(targetDir), 70)} + {branchName && ({branchName}*)} - ) : ( - - no sandbox (see docs) - - )} - + {debugMode && ( + + {' ' + (debugMessage || '--debug')} + + )} + + + {/* Middle Section: Centered Sandbox Info */} + + {process.env.SANDBOX && process.env.SANDBOX !== 'sandbox-exec' ? ( + + {process.env.SANDBOX.replace(/^gemini-(?:cli-)?/, '')} + + ) : process.env.SANDBOX === 'sandbox-exec' ? ( + + MacOS Seatbelt{' '} + ({process.env.SEATBELT_PROFILE}) + + ) : ( + + no sandbox (see docs) + + )} + - {/* Right Section: Gemini Label and Console Summary */} - - {model} - {corgiMode && ( - - | - - - - `) - + {/* Right Section: Gemini Label and Console Summary */} + + + {' '} + {model}{' '} + + ({((1 - percentage) * 100).toFixed(0)}% context left) + - )} - {!showErrorDetails && errorCount > 0 && ( - - | - - - )} - {showMemoryUsage && } + {corgiMode && ( + + | + + + + `) + + + )} + {!showErrorDetails && errorCount > 0 && ( + + | + + + )} + {showMemoryUsage && } + - -); + ); +}; -- cgit v1.2.3