fix: re render context usage indicator (#5102)
This commit is contained in:
parent
a3351bc985
commit
8e6a565adb
|
@ -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>
|
||||||
|
);
|
||||||
|
};
|
|
@ -7,12 +7,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import { Colors } from '../colors.js';
|
import { Colors } from '../colors.js';
|
||||||
import { shortenPath, tildeifyPath, tokenLimit } from '@google/gemini-cli-core';
|
import { shortenPath, tildeifyPath } from '@google/gemini-cli-core';
|
||||||
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
|
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
|
||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import Gradient from 'ink-gradient';
|
import Gradient from 'ink-gradient';
|
||||||
import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
|
import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
|
||||||
|
import { ContextUsageDisplay } from './ContextUsageDisplay.js';
|
||||||
import { DebugProfiler } from './DebugProfiler.js';
|
import { DebugProfiler } from './DebugProfiler.js';
|
||||||
|
|
||||||
interface FooterProps {
|
interface FooterProps {
|
||||||
|
@ -43,11 +43,7 @@ export const Footer: React.FC<FooterProps> = ({
|
||||||
promptTokenCount,
|
promptTokenCount,
|
||||||
nightly,
|
nightly,
|
||||||
vimMode,
|
vimMode,
|
||||||
}) => {
|
}) => (
|
||||||
const limit = tokenLimit(model);
|
|
||||||
const percentage = promptTokenCount / limit;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box justifyContent="space-between" width="100%">
|
<Box justifyContent="space-between" width="100%">
|
||||||
<Box>
|
<Box>
|
||||||
{debugMode && <DebugProfiler />}
|
{debugMode && <DebugProfiler />}
|
||||||
|
@ -100,9 +96,10 @@ export const Footer: React.FC<FooterProps> = ({
|
||||||
<Text color={Colors.AccentBlue}>
|
<Text color={Colors.AccentBlue}>
|
||||||
{' '}
|
{' '}
|
||||||
{model}{' '}
|
{model}{' '}
|
||||||
<Text color={Colors.Gray}>
|
<ContextUsageDisplay
|
||||||
({((1 - percentage) * 100).toFixed(0)}% context left)
|
promptTokenCount={promptTokenCount}
|
||||||
</Text>
|
model={model}
|
||||||
|
/>
|
||||||
</Text>
|
</Text>
|
||||||
{corgiMode && (
|
{corgiMode && (
|
||||||
<Text>
|
<Text>
|
||||||
|
@ -124,4 +121,3 @@ export const Footer: React.FC<FooterProps> = ({
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue