mirror of
https://github.com/codeaashu/claude-code.git
synced 2026-04-08 22:28:48 +03:00
24 lines
618 B
TypeScript
24 lines
618 B
TypeScript
import { useEffect } from 'react'
|
|
import { formatTotalCost, saveCurrentSessionCosts } from './cost-tracker.js'
|
|
import { hasConsoleBillingAccess } from './utils/billing.js'
|
|
import type { FpsMetrics } from './utils/fpsTracker.js'
|
|
|
|
export function useCostSummary(
|
|
getFpsMetrics?: () => FpsMetrics | undefined,
|
|
): void {
|
|
useEffect(() => {
|
|
const f = () => {
|
|
if (hasConsoleBillingAccess()) {
|
|
process.stdout.write('\n' + formatTotalCost() + '\n')
|
|
}
|
|
|
|
saveCurrentSessionCosts(getFpsMetrics?.())
|
|
}
|
|
process.on('exit', f)
|
|
return () => {
|
|
process.off('exit', f)
|
|
}
|
|
}, [])
|
|
}
|
|
|