feat(ui): show session cost in VS Code context usage readout (#2991)

Share the desktop session-card currency formatter (lib/money.ts) and surface
the current session's cost in the extension chat-header context usage tooltip.
This commit is contained in:
Yun Feng
2026-08-19 00:34:23 +03:00
committed by GitHub
parent 47525c0cf5
commit 36ce73f753
16 changed files with 58 additions and 11 deletions
+19
View File
@@ -0,0 +1,19 @@
import { getCurrentIntlLocale } from './i18n';
export const formatMoney = (value: number): string => {
if (!Number.isFinite(value) || value <= 0) {
return new Intl.NumberFormat(getCurrentIntlLocale(), {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}).format(0);
}
return new Intl.NumberFormat(getCurrentIntlLocale(), {
style: 'currency',
currency: 'USD',
minimumFractionDigits: value < 0.01 ? 4 : 2,
maximumFractionDigits: value < 0.01 ? 4 : 2,
}).format(value);
};