@@ -373,7 +373,30 @@ function RankingItemRow({ rank, name, logoUrl }: RankingItemRowProps) {
373373}
374374
375375function StatsGrid ( { stats } : { stats : OpenCodeStats } ) {
376- const hasZen = stats . hasZenUsage ;
376+ const totalCombinedCost = stats . zenCost + stats . estimatedCost ;
377+ const isEstimated = stats . estimatedCost > 0 ;
378+
379+ const costLabel = isEstimated ? "Est. Cost" : "Total Cost" ;
380+ let costValue : React . ReactNode ;
381+
382+ if ( isEstimated && stats . zenCost > 0 ) {
383+ costValue = (
384+ < div style = { { display : "flex" , flexDirection : "column" , alignItems : "center" , gap : spacing [ 1 ] } } >
385+ < span > { formatCost ( totalCombinedCost ) } </ span >
386+ < span
387+ style = { {
388+ fontSize : typography . size . lg ,
389+ fontWeight : typography . weight . medium ,
390+ color : colors . accent . primary ,
391+ } }
392+ >
393+ { formatCost ( stats . zenCost ) } Zen
394+ </ span >
395+ </ div >
396+ ) ;
397+ } else {
398+ costValue = formatCost ( totalCombinedCost ) ;
399+ }
377400
378401 return (
379402 < div
@@ -384,44 +407,30 @@ function StatsGrid({ stats }: { stats: OpenCodeStats }) {
384407 gap : spacing [ 5 ] ,
385408 } }
386409 >
387- { hasZen ? (
388- < div style = { { display : "flex" , flexDirection : "column" , gap : spacing [ 5 ] } } >
389- < div style = { { display : "flex" , gap : spacing [ 5 ] } } >
390- < StatBox label = "Sessions" value = { formatNumber ( stats . totalSessions ) } />
391- < StatBox label = "Messages" value = { formatNumber ( stats . totalMessages ) } />
392- < StatBox label = "Total Tokens" value = { formatNumber ( stats . totalTokens ) } />
393- </ div >
394-
395- < div style = { { display : "flex" , gap : spacing [ 5 ] } } >
396- < StatBox label = "Projects" value = { formatNumber ( stats . totalProjects ) } />
397- < StatBox label = "Streak" value = { `${ stats . maxStreak } d` } />
398- < StatBox label = "OpenCode Zen Cost" value = { formatCost ( stats . totalCost ) } />
399- </ div >
410+ < div style = { { display : "flex" , flexDirection : "column" , gap : spacing [ 5 ] } } >
411+ < div style = { { display : "flex" , gap : spacing [ 5 ] } } >
412+ < StatBox label = "Sessions" value = { formatNumber ( stats . totalSessions ) } />
413+ < StatBox label = "Messages" value = { formatNumber ( stats . totalMessages ) } />
414+ < StatBox label = "Total Tokens" value = { formatNumber ( stats . totalTokens ) } />
400415 </ div >
401- ) : (
402- < div style = { { display : "flex" , flexDirection : "column" , gap : spacing [ 5 ] } } >
403- < div style = { { display : "flex" , gap : spacing [ 5 ] } } >
404- < StatBox label = "Sessions" value = { formatNumber ( stats . totalSessions ) } />
405- < StatBox label = "Messages" value = { formatNumber ( stats . totalMessages ) } />
406- < StatBox label = "Tokens" value = { formatNumber ( stats . totalTokens ) } />
407- </ div >
408-
409- < div style = { { display : "flex" , gap : spacing [ 5 ] } } >
410- < StatBox label = "Projects" value = { formatNumber ( stats . totalProjects ) } />
411- < StatBox label = "Streak" value = { `${ stats . maxStreak } d` } />
412- </ div >
416+
417+ < div style = { { display : "flex" , gap : spacing [ 5 ] } } >
418+ < StatBox label = "Projects" value = { formatNumber ( stats . totalProjects ) } />
419+ < StatBox label = "Streak" value = { `${ stats . maxStreak } d` } />
420+ < StatBox label = { costLabel } value = { costValue } />
413421 </ div >
414- ) }
422+ </ div >
415423 </ div >
416424 ) ;
417425}
418426
419427interface StatBoxProps {
420428 label : string ;
421- value : string ;
429+ value : string | React . ReactNode ;
430+ subtitle ?: string ;
422431}
423432
424- function StatBox ( { label, value } : StatBoxProps ) {
433+ function StatBox ( { label, value, subtitle } : StatBoxProps ) {
425434 return (
426435 < div
427436 style = { {
@@ -451,16 +460,33 @@ function StatBox({ label, value }: StatBoxProps) {
451460 { label }
452461 </ span >
453462
454- < span
455- style = { {
456- fontSize : typography . size [ "2xl" ] ,
457- fontWeight : typography . weight . bold ,
458- color : colors . text . primary ,
459- lineHeight : typography . lineHeight . none ,
460- } }
461- >
462- { value }
463- </ span >
463+ < div style = { { display : "flex" , flexDirection : "column" , alignItems : "center" } } >
464+ < div
465+ style = { {
466+ fontSize : typography . size [ "2xl" ] ,
467+ fontWeight : typography . weight . bold ,
468+ color : colors . text . primary ,
469+ lineHeight : typography . lineHeight . none ,
470+ display : "flex" ,
471+ flexDirection : "column" ,
472+ alignItems : "center" ,
473+ } }
474+ >
475+ { value }
476+ </ div >
477+ { subtitle && (
478+ < span
479+ style = { {
480+ fontSize : typography . size . sm ,
481+ fontWeight : typography . weight . regular ,
482+ color : colors . text . muted ,
483+ marginTop : spacing [ 1 ] ,
484+ } }
485+ >
486+ { subtitle }
487+ </ span >
488+ ) }
489+ </ div >
464490 </ div >
465491 ) ;
466492}
0 commit comments