@@ -518,10 +518,6 @@ export default function Dashboard() {
518518 const [ costAnalysisData , setCostAnalysisData ] = useState < CostReport | null > ( null ) ;
519519 const [ costAnalysisLoading , setCostAnalysisLoading ] = useState ( false ) ;
520520
521- // --- Session Savings Counter ---
522- const sessionSavingsRef = useRef < number > ( 0 ) ;
523- const [ sessionSavingsDisplay , setSessionSavingsDisplay ] = useState < number > ( 0 ) ;
524- const currentCostRef = useRef < { monthlyCost : number ; fixedCost : number } > ( { monthlyCost : 42 , fixedCost : 166 } ) ;
525521
526522 // --- Public Status / Showcase Banner State ---
527523 const [ publicStatus , setPublicStatus ] = useState < PublicStatus | null > ( null ) ;
@@ -983,11 +979,6 @@ export default function Dashboard() {
983979 const data = await res . json ( ) ;
984980
985981 setCurrent ( data ) ;
986- // Keep cost ref in sync so the 1s savings counter uses the latest rate
987- currentCostRef . current = {
988- monthlyCost : data . cost ?. opGethMonthlyCost ?? data . cost ?. monthlyEstimated ?? 42 ,
989- fixedCost : data . cost ?. fixedCost ?? 166 ,
990- } ;
991982
992983 const point = {
993984 name : new Date ( ) . toLocaleTimeString ( [ ] , { hour : '2-digit' , minute : '2-digit' , second : '2-digit' } ) ,
@@ -1127,17 +1118,6 @@ export default function Dashboard() {
11271118 return ( ) => clearInterval ( interval ) ;
11281119 } , [ ] ) ;
11291120
1130- // --- Session Savings Counter: tick every 1s ---
1131- useEffect ( ( ) => {
1132- const ticker = setInterval ( ( ) => {
1133- const { monthlyCost, fixedCost } = currentCostRef . current ;
1134- // hourly savings = (fixedCost - monthlyCost) / 730; per second = / 3600
1135- const savingsPerSecond = ( fixedCost - monthlyCost ) / 730 / 3600 ;
1136- sessionSavingsRef . current += savingsPerSecond ;
1137- setSessionSavingsDisplay ( sessionSavingsRef . current ) ;
1138- } , 1000 ) ;
1139- return ( ) => clearInterval ( ticker ) ;
1140- } , [ ] ) ;
11411121
11421122 if ( isLoading ) return (
11431123 < div className = "flex h-screen w-full items-center justify-center bg-gray-50 text-blue-600" >
@@ -1498,8 +1478,8 @@ export default function Dashboard() {
14981478 : vcpu >= 4 ? { text : 'High Load' , color : 'text-orange-500 bg-orange-50' }
14991479 : vcpu >= 2 ? { text : 'Moderate' , color : 'text-amber-500 bg-amber-50' }
15001480 : { text : 'Optimized' , color : 'text-emerald-600 bg-emerald-50' } ;
1501- const sessionAbs = Math . abs ( sessionSavingsDisplay ) ;
1502- const sessionIsOverspend = sessionSavingsDisplay < - 0.001 ;
1481+ const estMonthlySavings = fixedCost - monthlyCost ;
1482+ const isOverspend = estMonthlySavings < 0 ;
15031483 return (
15041484 < >
15051485 < div data-testid = "monthly-cost" >
@@ -1536,11 +1516,11 @@ export default function Dashboard() {
15361516 < span className = "text-[9px] text-gray-400" > $0</ span >
15371517 < span className = "text-[9px] text-gray-400" > ${ fixedCost . toFixed ( 0 ) } </ span >
15381518 </ div >
1539- { /* Session Savings Counter */ }
1540- < div className = { `mt-2.5 flex items-center justify-between px-2.5 py-1.5 rounded-lg ${ sessionIsOverspend ? 'bg-red-50' : 'bg-emerald-50' } ` } >
1541- < span className = "text-[10px] text-gray-500" > Session { sessionIsOverspend ? 'overspend' : ' savings' } </ span >
1542- < span className = { `text-[11px] font-bold tabular-nums ${ sessionIsOverspend ? 'text-red-600' : 'text-emerald-600' } ` } >
1543- { sessionIsOverspend ? '+ ' : '- ' } ${ sessionAbs . toFixed ( 4 ) }
1519+ { /* Est. Monthly Savings */ }
1520+ < div className = { `mt-2.5 flex items-center justify-between px-2.5 py-1.5 rounded-lg ${ isOverspend ? 'bg-red-50' : 'bg-emerald-50' } ` } >
1521+ < span className = "text-[10px] text-gray-500" > Est. monthly savings</ span >
1522+ < span className = { `text-[11px] font-bold tabular-nums ${ isOverspend ? 'text-red-600' : 'text-emerald-600' } ` } >
1523+ { isOverspend ? '- ' : '+ ' } ${ Math . abs ( estMonthlySavings ) . toFixed ( 0 ) } /mo
15441524 </ span >
15451525 </ div >
15461526 </ div >
0 commit comments