fix(admin-ui): keep sign and precision in CSV, YAML and context labels

CSV export prefixed negative numbers with an apostrophe, which corrupted the data. YAML emitted NaN and Infinity as plain strings. Context windows such as 1500 read as 2k. Numbers now skip the CSV formula guard, non-finite values use YAML float forms, and counts below 10k keep one decimal.
This commit is contained in:
2026-11-08 02:29:28 +00:00
parent e985fded45
commit 0a05dfc035
6 changed files with 42 additions and 4 deletions
+7 -2
View File
@@ -194,8 +194,13 @@ export function formatContextWindow(tokens: number): string {
}
// 999_500+ would round to "1000k"; the M branch renders it as "1M".
if (tokens < 999_500) return `${Math.round(tokens / 1_000)}k`
return `${Math.round(tokens / 1_000_000)}M`
if (tokens < 999_500) return `${roundScaled(tokens / 1_000)}k`
return `${roundScaled(tokens / 1_000_000)}M`
}
/** roundScaled keeps one decimal below 10 ("1.5") so 1500 does not read as 2k, and rounds to whole units from 10 up. */
function roundScaled(value: number): string {
return value < 10 ? String(Math.round(value * 10) / 10) : String(Math.round(value))
}
/** formatUsdPerMTok renders a USD-per-million-tokens float as "$0.19" (2 decimals) — the shared building block for both the visible cost chip and ModelChip's hover detail. */