mirror of
https://github.com/codeaashu/claude-code.git
synced 2026-04-08 22:28:48 +03:00
claude-code
This commit is contained in:
23
src/costHook.ts
Normal file
23
src/costHook.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
}, [])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user