fix: re render context usage indicator (#5102)

This commit is contained in:
Pyush Sinha 2025-08-07 11:16:47 -07:00 committed by GitHub
parent a3351bc985
commit 8e6a565adb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 102 additions and 81 deletions

View file

@ -0,0 +1,25 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { Text } from 'ink';
import { Colors } from '../colors.js';
import { tokenLimit } from '@google/gemini-cli-core';
export const ContextUsageDisplay = ({
promptTokenCount,
model,
}: {
promptTokenCount: number;
model: string;
}) => {
const percentage = promptTokenCount / tokenLimit(model);
return (
<Text color={Colors.Gray}>
({((1 - percentage) * 100).toFixed(0)}% context left)
</Text>
);
};