Skip to content

Commit 4366a1e

Browse files
gcmsgclaude
andcommitted
fix: add nullish coalescing for dashboard stats to prevent TypeError
Dashboard page crashed with 'Cannot read properties of undefined (reading toLocaleString)' when agent stats fields were undefined. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f248d36 commit 4366a1e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

web/app/src/pages/ProviderDashboardPage.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ export function ProviderDashboardPage() {
6565
/>
6666
<AgentStatsCard
6767
title={t('provider.totalCalls')}
68-
value={data.total_calls.toLocaleString()}
68+
value={(data.total_calls ?? 0).toLocaleString()}
6969
icon={PhoneCall}
7070
/>
7171
<AgentStatsCard
7272
title={t('provider.successRate')}
73-
value={`${data.success_rate.toFixed(1)}%`}
73+
value={`${(data.success_rate ?? 0).toFixed(1)}%`}
7474
icon={CheckCircle}
7575
/>
7676
<AgentStatsCard
7777
title={t('provider.avgLatency')}
78-
value={`${data.avg_latency_ms.toFixed(0)}ms`}
78+
value={`${(data.avg_latency_ms ?? 0).toFixed(0)}ms`}
7979
icon={Timer}
8080
/>
8181
</div>
@@ -128,13 +128,13 @@ export function ProviderDashboardPage() {
128128
</Badge>
129129
</TableCell>
130130
<TableCell className="text-muted-foreground">
131-
{agent.total_calls.toLocaleString()}
131+
{(agent.total_calls ?? 0).toLocaleString()}
132132
</TableCell>
133133
<TableCell className="text-muted-foreground">
134-
{agent.success_rate.toFixed(1)}%
134+
{(agent.success_rate ?? 0).toFixed(1)}%
135135
</TableCell>
136136
<TableCell className="text-muted-foreground">
137-
{agent.avg_latency_ms.toFixed(0)}ms
137+
{(agent.avg_latency_ms ?? 0).toFixed(0)}ms
138138
</TableCell>
139139
</TableRow>
140140
))}

0 commit comments

Comments
 (0)