mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 03:30:40 +00:00
fix(status-line): derive remaining_percentage from used and reject empty commands
- Compute remaining_percentage as round(100 - used) to guarantee used + remaining always sums to exactly 100.0 - Reject empty or whitespace-only command strings in config validation
This commit is contained in:
parent
0be4d32cb0
commit
55b1ab174d
1 changed files with 3 additions and 13 deletions
|
|
@ -81,7 +81,8 @@ function getStatusLineConfig(
|
|||
'type' in raw &&
|
||||
raw.type === 'command' &&
|
||||
'command' in raw &&
|
||||
typeof raw.command === 'string'
|
||||
typeof raw.command === 'string' &&
|
||||
raw.command.trim().length > 0
|
||||
) {
|
||||
const config: StatusLineConfig = {
|
||||
type: 'command',
|
||||
|
|
@ -247,18 +248,7 @@ export function useStatusLine(): {
|
|||
context_window: {
|
||||
context_window_size: contextWindowSize,
|
||||
used_percentage: usedPercentage,
|
||||
remaining_percentage:
|
||||
contextWindowSize > 0
|
||||
? Math.min(
|
||||
100,
|
||||
Math.max(
|
||||
0,
|
||||
Math.round(
|
||||
(1 - stats.lastPromptTokenCount / contextWindowSize) * 1000,
|
||||
) / 10,
|
||||
),
|
||||
)
|
||||
: 100,
|
||||
remaining_percentage: Math.round((100 - usedPercentage) * 10) / 10,
|
||||
current_usage: stats.lastPromptTokenCount,
|
||||
total_input_tokens: totalInputTokens,
|
||||
total_output_tokens: totalOutputTokens,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue