@@ -60,8 +60,9 @@ const DetailsCardComponent = ({
6060 ) . length , [ thinkingSteps ] ) ;
6161
6262 const cacheReadTokens = metadata ?. totalCacheReadTokens ?? 0 ;
63- const cachedInputPercent = metadata ?. totalInputTokens
64- ? Math . round ( ( cacheReadTokens / metadata . totalInputTokens ) * 100 )
63+ const inputTokens = metadata ?. totalInputTokens ?? 0 ;
64+ const cachedInputPercent = inputTokens > 0
65+ ? Math . round ( ( cacheReadTokens / inputTokens ) * 100 )
6566 : 0 ;
6667
6768 const handleExpandedChanged = useCallback ( ( next : boolean ) => {
@@ -132,39 +133,44 @@ const DetailsCardComponent = ({
132133 </ div >
133134 ) }
134135 { metadata ?. totalTokens && (
135- < Tooltip >
136- < TooltipTrigger asChild >
137- < div className = "flex items-center text-xs cursor-help" >
138- < Zap className = "w-3 h-3 mr-1 flex-shrink-0" />
139- { getShortenedNumberDisplayString ( metadata . totalTokens , 0 ) } tokens
140- { cachedInputPercent > 0 && (
141- < span className = "ml-1 text-muted-foreground" > ({ cachedInputPercent } % cached)</ span >
142- ) }
143- </ div >
144- </ TooltipTrigger >
145- < TooltipContent side = "bottom" >
146- < div className = "space-y-1 text-xs" >
147- < div className = "flex justify-between gap-4" >
148- < span className = "text-muted-foreground" > Input</ span >
149- < span > { metadata . totalInputTokens ?. toLocaleString ( ) ?? '—' } </ span >
136+ < div className = "flex items-center gap-1.5 text-xs" >
137+ < Tooltip >
138+ < TooltipTrigger asChild >
139+ < div className = "flex items-center cursor-help" >
140+ < Zap className = "w-3 h-3 mr-1 flex-shrink-0" />
141+ { getShortenedNumberDisplayString ( metadata . totalTokens , 0 ) } tokens
150142 </ div >
151- { cacheReadTokens > 0 && (
152- < div className = "flex justify-between gap-4 pl-3" >
153- < span className = "text-muted-foreground" > ↳ Cached (discounted)</ span >
154- < span > { cacheReadTokens . toLocaleString ( ) } </ span >
143+ </ TooltipTrigger >
144+ < TooltipContent side = "bottom" >
145+ < div className = "space-y-1 text-xs" >
146+ < div className = "flex justify-between gap-4" >
147+ < span className = "text-muted-foreground" > Input</ span >
148+ < span > { metadata . totalInputTokens ?. toLocaleString ( ) ?? '—' } </ span >
149+ </ div >
150+ < div className = "flex justify-between gap-4" >
151+ < span className = "text-muted-foreground" > Output</ span >
152+ < span > { metadata . totalOutputTokens ?. toLocaleString ( ) ?? '—' } </ span >
153+ </ div >
154+ < div className = "flex justify-between gap-4 border-t border-border pt-1" >
155+ < span className = "text-muted-foreground" > Total</ span >
156+ < span > { metadata . totalTokens . toLocaleString ( ) } </ span >
155157 </ div >
156- ) }
157- < div className = "flex justify-between gap-4" >
158- < span className = "text-muted-foreground" > Output</ span >
159- < span > { metadata . totalOutputTokens ?. toLocaleString ( ) ?? '—' } </ span >
160- </ div >
161- < div className = "flex justify-between gap-4 border-t border-border pt-1" >
162- < span className = "text-muted-foreground" > Total</ span >
163- < span > { metadata . totalTokens . toLocaleString ( ) } </ span >
164158 </ div >
165- </ div >
166- </ TooltipContent >
167- </ Tooltip >
159+ </ TooltipContent >
160+ </ Tooltip >
161+ { cachedInputPercent > 0 && (
162+ < Tooltip >
163+ < TooltipTrigger asChild >
164+ < span className = "text-muted-foreground cursor-help" > ({ cachedInputPercent } % cached)</ span >
165+ </ TooltipTrigger >
166+ < TooltipContent side = "bottom" >
167+ < div className = "max-w-xs text-xs" >
168+ { cacheReadTokens . toLocaleString ( ) } of { inputTokens . toLocaleString ( ) } input tokens were read from the model provider prompt cache. Cached tokens are typically billed at a fraction of the cost of regular input tokens, so the real cost is lower than the token count suggests.
169+ </ div >
170+ </ TooltipContent >
171+ </ Tooltip >
172+ ) }
173+ </ div >
168174 ) }
169175 { metadata ?. totalResponseTimeMs && (
170176 < div className = "flex items-center text-xs" >
0 commit comments