File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,12 +12,24 @@ interface CostDisplayProps {
1212export 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
You can’t perform that action at this time.
0 commit comments