source dump of claude code
at main 22 lines 617 B view raw
1import { useEffect } from 'react' 2import { formatTotalCost, saveCurrentSessionCosts } from './cost-tracker.js' 3import { hasConsoleBillingAccess } from './utils/billing.js' 4import type { FpsMetrics } from './utils/fpsTracker.js' 5 6export function useCostSummary( 7 getFpsMetrics?: () => FpsMetrics | undefined, 8): void { 9 useEffect(() => { 10 const f = () => { 11 if (hasConsoleBillingAccess()) { 12 process.stdout.write('\n' + formatTotalCost() + '\n') 13 } 14 15 saveCurrentSessionCosts(getFpsMetrics?.()) 16 } 17 process.on('exit', f) 18 return () => { 19 process.off('exit', f) 20 } 21 }, []) 22}