mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 05:50:47 +00:00
fix(usage): format near-million token counts as millions (#39129)
Co-authored-by: CurryMessi <curry-messi@users.noreply.github.com>
This commit is contained in:
@@ -25,7 +25,12 @@ export function formatTokenCount(value?: number): string {
|
||||
return `${(safe / 1_000_000).toFixed(1)}m`;
|
||||
}
|
||||
if (safe >= 1_000) {
|
||||
return `${(safe / 1_000).toFixed(safe >= 10_000 ? 0 : 1)}k`;
|
||||
const precision = safe >= 10_000 ? 0 : 1;
|
||||
const formattedThousands = (safe / 1_000).toFixed(precision);
|
||||
if (Number(formattedThousands) >= 1_000) {
|
||||
return `${(safe / 1_000_000).toFixed(1)}m`;
|
||||
}
|
||||
return `${formattedThousands}k`;
|
||||
}
|
||||
return String(Math.round(safe));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user