mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-10 08:32:09 +00:00
fix(desktop): handle empty usage analytics totals
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
bf196bb47b
commit
6f2e616d9f
2 changed files with 16 additions and 9 deletions
|
|
@ -1098,6 +1098,10 @@ function formatCost(value: null | number | undefined): string {
|
|||
return `$${num.toFixed(2)}`
|
||||
}
|
||||
|
||||
function formatInteger(value: null | number | undefined): string {
|
||||
return Number(value ?? 0).toLocaleString()
|
||||
}
|
||||
|
||||
interface UsagePanelProps {
|
||||
error: string
|
||||
loading: boolean
|
||||
|
|
@ -1152,9 +1156,12 @@ function UsagePanel({ error, loading, onPeriodChange, onRefresh, period, usage }
|
|||
<OverlayCard className="p-3">
|
||||
{totals ? (
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<UsageStat label="Sessions" value={totals.total_sessions.toLocaleString()} />
|
||||
<UsageStat label="API calls" value={totals.total_api_calls.toLocaleString()} />
|
||||
<UsageStat label="Tokens in/out" value={`${formatTokens(totals.total_input)} / ${formatTokens(totals.total_output)}`} />
|
||||
<UsageStat label="Sessions" value={formatInteger(totals.total_sessions)} />
|
||||
<UsageStat label="API calls" value={formatInteger(totals.total_api_calls)} />
|
||||
<UsageStat
|
||||
label="Tokens in/out"
|
||||
value={`${formatTokens(totals.total_input)} / ${formatTokens(totals.total_output)}`}
|
||||
/>
|
||||
<UsageStat
|
||||
hint={totals.total_actual_cost > 0 ? `actual ${formatCost(totals.total_actual_cost)}` : undefined}
|
||||
label="Est. cost"
|
||||
|
|
@ -1204,7 +1211,7 @@ function UsagePanel({ error, loading, onPeriodChange, onRefresh, period, usage }
|
|||
>
|
||||
<div
|
||||
className="w-full bg-[color:var(--dt-primary)]/50"
|
||||
style={{ height: Math.max(inputH, total > 0 ? 1 : 0) }}
|
||||
style={{ height: Math.max(inputH, entry.input_tokens > 0 ? 1 : 0) }}
|
||||
/>
|
||||
<div
|
||||
className="w-full bg-emerald-500/60"
|
||||
|
|
|
|||
|
|
@ -345,12 +345,12 @@ export interface AnalyticsSkillsSummary {
|
|||
|
||||
export interface AnalyticsTotals {
|
||||
total_actual_cost: number
|
||||
total_api_calls: number
|
||||
total_cache_read: number
|
||||
total_api_calls: null | number
|
||||
total_cache_read: null | number
|
||||
total_estimated_cost: number
|
||||
total_input: number
|
||||
total_output: number
|
||||
total_reasoning: number
|
||||
total_input: null | number
|
||||
total_output: null | number
|
||||
total_reasoning: null | number
|
||||
total_sessions: number
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue