mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
35 lines
734 B
TypeScript
35 lines
734 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { Text } from 'ink';
|
|
import { theme } from '../semantic-colors.js';
|
|
import { tokenLimit } from '@qwen-code/qwen-code-core';
|
|
|
|
export const ContextUsageDisplay = ({
|
|
promptTokenCount,
|
|
model,
|
|
terminalWidth,
|
|
}: {
|
|
promptTokenCount: number;
|
|
model: string;
|
|
terminalWidth: number;
|
|
}) => {
|
|
if (promptTokenCount === 0) {
|
|
return null;
|
|
}
|
|
|
|
const percentage = promptTokenCount / tokenLimit(model);
|
|
const percentageUsed = (percentage * 100).toFixed(1);
|
|
|
|
const label = terminalWidth < 100 ? '% used' : '% context used';
|
|
|
|
return (
|
|
<Text color={theme.text.secondary}>
|
|
{percentageUsed}
|
|
{label}
|
|
</Text>
|
|
);
|
|
};
|