fix(FN-7786): handle mixed zero cost feedback
Fusion-Task-Id: FN-7786
This commit is contained in:
@@ -85,6 +85,7 @@ describe("Command Center cost formatting", () => {
|
||||
expect(formatCost(911.39004125, true)).toBe("$911.39+");
|
||||
expect(formatCost(12.5, false)).toBe("$12.50");
|
||||
expect(formatCost(0, false)).toBe("$0.00");
|
||||
expect(formatCost(0, true)).toBe("—");
|
||||
expect(formatCost(null, true)).toBe("—");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,9 +50,12 @@ export function formatDurationMs(ms: number | null): string {
|
||||
*
|
||||
* FNXC:CommandCenterCost 2026-07-10-23:20:
|
||||
* Cost aggregation deliberately preserves the priced subtotal when some usage has unknown pricing. Overview, Tokens, Team, and Workflows must display that subtotal with a trailing `+`; show `—` only when no usage can be priced, and keep an exact priced zero distinct from unavailable data.
|
||||
*
|
||||
* FNXC:CommandCenterCost 2026-07-10-23:35:
|
||||
* A zero subtotal is exact only when every contribution is priced. Mixed pricing with a zero known subtotal must remain `—`, because `$0.00+` suggests a meaningful lower bound while all positive cost may belong to unpriced usage.
|
||||
*/
|
||||
export function formatCost(usd: number | null, unavailable: boolean): string {
|
||||
if (usd === null || !Number.isFinite(usd)) {
|
||||
if (usd === null || !Number.isFinite(usd) || (unavailable && usd === 0)) {
|
||||
return "—";
|
||||
}
|
||||
const formatted = `$${usd.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
|
||||
Reference in New Issue
Block a user