summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/ContextUsageDisplay.tsx
blob: 037be33398cbb5210d56184363fe4a844bb170ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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>
  );
};