Skip to content

Commit edc3c35

Browse files
TANG, shixiangCopilot
andauthored
Update src/components/agent/cost-display.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 10496e5 commit edc3c35

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

‎src/components/agent/cost-display.tsx‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@ interface CostDisplayProps {
1212
export function CostDisplay({ snapshot }: CostDisplayProps) {
1313
const [expanded, setExpanded] = useState(false);
1414

15-
if (!snapshot || snapshot.totalCostUsd === 0) return null;
15+
if (!snapshot) return null;
1616

17-
const costStr = snapshot.totalCostUsd < 0.01
18-
? "<$0.01"
19-
: `$${snapshot.totalCostUsd.toFixed(2)}`;
17+
const hasTokenUsage =
18+
snapshot.totalInputTokens > 0 || snapshot.totalOutputTokens > 0;
19+
const hasUnknownPricing = Object.values(snapshot.modelUsage).some(
20+
(usage) => !usage.pricingKnown
21+
);
22+
23+
if (snapshot.totalCostUsd === 0 && !hasTokenUsage) return null;
2024

25+
const costStr =
26+
snapshot.totalCostUsd === 0
27+
? hasUnknownPricing && hasTokenUsage
28+
? "~est"
29+
: "$0.00"
30+
: snapshot.totalCostUsd < 0.01
31+
? "<$0.01"
32+
: `$${snapshot.totalCostUsd.toFixed(2)}`;
2133
return (
2234
<div className="relative">
2335
<button

0 commit comments

Comments
 (0)