Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
fix(dashboard): show a per-card load error instead of a banner over lying zeros
Sergey Kozyrenkob54c09954c2d
diff --git a/frontend/src/components/dashboard/chart-card.tsx b/frontend/src/components/dashboard/chart-card.tsxindex 12cec260..a1f122a7 100644--- a/frontend/src/components/dashboard/chart-card.tsx+++ b/frontend/src/components/dashboard/chart-card.tsx@@ -1,6 +1,6 @@import type { ReactNode } from 'react';-import { BarChart2 } from 'lucide-react';+import { AlertCircle, BarChart2 } from 'lucide-react';import { ResponsiveContainer } from 'recharts';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';@@ -11,6 +11,7 @@ export function ChartCard({className,description,empty,+ error,height = 300,loading,title,@@ -19,6 +20,7 @@ export function ChartCard({className?: string;description?: ReactNode;empty?: boolean;+ error?: boolean;height?: number;loading?: boolean;title: ReactNode;@@ -40,6 +42,14 @@ export function ChartCard({variant="circle"/></div>+ ) : error ? (+ <div+ className="flex flex-col items-center justify-center gap-2"+ style={{ height }}+ >+ <AlertCircle className="text-muted-foreground/40 size-10" />+ <p className="text-muted-foreground text-sm">Couldn't load</p>+ </div>) : empty ? (<divclassName="flex flex-col items-center justify-center gap-2"diff --git a/frontend/src/components/dashboard/metric-card.tsx b/frontend/src/components/dashboard/metric-card.tsxindex a1260856..687065fd 100644--- a/frontend/src/components/dashboard/metric-card.tsx+++ b/frontend/src/components/dashboard/metric-card.tsx@@ -1,11 +1,14 @@import type { ReactNode } from 'react';+import { AlertCircle } from 'lucide-react';+import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';import { Skeleton } from '@/components/ui/skeleton';export function MetricCard({className,description,+ error,icon,loading,title,@@ -13,6 +16,7 @@ export function MetricCard({}: {className?: string;description?: ReactNode;+ error?: boolean;icon?: ReactNode;loading?: boolean;title: ReactNode;@@ -24,15 +28,27 @@ export function MetricCard({<CardTitle className="text-sm font-medium">{loading ? <Skeleton className="h-5 w-24" /> : title}</CardTitle>- {loading ? <Skeleton className="size-4 shrink-0 rounded" /> : icon}+ {loading ? (+ <Skeleton className="size-4 shrink-0 rounded" />+ ) : error ? (+ <AlertCircle className="text-muted-foreground/60 size-4 shrink-0" />+ ) : (+ icon+ )}</CardHeader><CardContent className="flex flex-col gap-1">- {loading ? <Skeleton className="h-8 w-24" /> : <div className="text-2xl font-bold">{value}</div>}- {description &&+ {loading ? (+ <Skeleton className="h-8 w-24" />+ ) : error ? (+ <div className="text-muted-foreground/60 text-2xl font-bold">—</div>+ ) : (+ <div className="text-2xl font-bold">{value}</div>+ )}+ {(description || error) &&(loading ? (<Skeleton className="mt-1 h-3 w-32" />) : (- <p className="text-muted-foreground text-xs">{description}</p>+ <p className="text-muted-foreground text-xs">{error ? "Couldn't load" : description}</p>))}</CardContent></Card>diff --git a/frontend/src/pages/dashboard/dashboard-analytics.tsx b/frontend/src/pages/dashboard/dashboard-analytics.tsxindex 2be77f68..9512b910 100644--- a/frontend/src/pages/dashboard/dashboard-analytics.tsx+++ b/frontend/src/pages/dashboard/dashboard-analytics.tsx@@ -1,6 +1,6 @@import { useQuery } from '@apollo/client/react';import { format } from 'date-fns';-import { ChevronRight, Clock, Wrench } from 'lucide-react';+import { AlertCircle, ChevronRight, Clock, Wrench } from 'lucide-react';import { memo, useDeferredValue, useMemo, useRef, useState } from 'react';import { Area, AreaChart, Bar, BarChart, CartesianGrid, Tooltip, XAxis, YAxis } from 'recharts';@@ -8,7 +8,6 @@ import type { FlowFragmentFragment, UsageStatsPeriod } from '@/graphql/types';import { ChartCard, ChartTooltip } from '@/components/dashboard';import { FlowStatusBadge } from '@/components/icons/flow-status-badge';-import { ErrorAlert } from '@/components/shared/error-alert';import { Badge } from '@/components/ui/badge';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';@@ -90,10 +89,7 @@ export function DashboardAnalytics({ period }: { period: UsageStatsPeriod }) {} = useQuery(FlowsExecutionStatsByPeriodDocument, {variables: { period },});- const { data: flowsData, error: flowsError } = useQuery(FlowsDocument);-- const loadError =- usageByPeriodError ?? toolcallsByPeriodError ?? flowsByPeriodError ?? executionStatsError ?? flowsError;+ const { data: flowsData } = useQuery(FlowsDocument);const flowsTooltip = useChartTooltipAnimation();const toolcallsTooltip = useChartTooltipAnimation();@@ -154,15 +150,10 @@ export function DashboardAnalytics({ period }: { period: UsageStatsPeriod }) {return (<div className="flex flex-col gap-6">- {loadError ? (- <ErrorAlert- message={loadError.message}- title="Error loading dashboard data"- />- ) : null}<ChartCarddescription="Flows, tasks, and subtasks created per day"empty={!flowsByPeriodLoading && flowsChartData.length === 0}+ error={!!flowsByPeriodError}height={320}loading={flowsByPeriodLoading}title="Flows Activity Over Time"@@ -222,6 +213,7 @@ export function DashboardAnalytics({ period }: { period: UsageStatsPeriod }) {<ChartCarddescription="Number of tool executions per day"empty={!toolcallsByPeriodLoading && toolcallsChartData.length === 0}+ error={!!toolcallsByPeriodError}loading={toolcallsByPeriodLoading}title="Tool Calls Over Time">@@ -267,6 +259,7 @@ export function DashboardAnalytics({ period }: { period: UsageStatsPeriod }) {<ChartCarddescription="Input and output tokens processed daily"empty={!usageByPeriodLoading && usageChartData.length === 0}+ error={!!usageByPeriodError}loading={usageByPeriodLoading}title="Token Usage Over Time">@@ -324,6 +317,7 @@ export function DashboardAnalytics({ period }: { period: UsageStatsPeriod }) {<ChartCarddescription="LLM spending per day. May stay near zero when using local engines — this is expected."empty={!usageByPeriodLoading && usageChartData.length === 0}+ error={!!usageByPeriodError}height={240}loading={usageByPeriodLoading}title="Cost Over Time"@@ -391,6 +385,11 @@ export function DashboardAnalytics({ period }: { period: UsageStatsPeriod }) {variant="circle"/></div>+ ) : executionStatsError ? (+ <div className="text-muted-foreground flex flex-col items-center justify-center gap-2 py-8">+ <AlertCircle className="text-muted-foreground/40 size-6" />+ <p className="text-sm">Couldn't load</p>+ </div>) : !deferredExecutionStats.length ? (<p className="text-muted-foreground py-8 text-center text-sm">No flow executions in this perioddiff --git a/frontend/src/pages/dashboard/dashboard-overview.tsx b/frontend/src/pages/dashboard/dashboard-overview.tsxindex 0a98bd9d..3ebdaaba 100644--- a/frontend/src/pages/dashboard/dashboard-overview.tsx+++ b/frontend/src/pages/dashboard/dashboard-overview.tsx@@ -1,10 +1,9 @@import { useQuery } from '@apollo/client/react';-import { Activity, CircleDollarSign, Cpu, GitFork } from 'lucide-react';+import { Activity, AlertCircle, CircleDollarSign, Cpu, GitFork } from 'lucide-react';import type { UsageStatsFragmentFragment } from '@/graphql/types';import { MetricCard } from '@/components/dashboard';-import { ErrorAlert } from '@/components/shared/error-alert';import { Badge } from '@/components/ui/badge';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';import { Spinner } from '@/components/ui/spinner';@@ -57,15 +56,6 @@ export function DashboardOverview() {loading: flowsTotalLoading,} = useQuery(FlowsStatsTotalDocument);- const loadError =- usageTotalError ??- usageByProviderError ??- usageByModelError ??- usageByAgentTypeError ??- toolcallsTotalError ??- toolcallsByFunctionError ??- flowsTotalError;-const usageTotal = usageTotalData?.usageStatsTotal;const toolcallsTotal = toolcallsTotalData?.toolcallsStatsTotal;const flowsTotal = flowsTotalData?.flowsStatsTotal;@@ -92,15 +82,10 @@ export function DashboardOverview() {return (<div className="flex flex-col gap-6">- {loadError ? (- <ErrorAlert- message={loadError.message}- title="Error loading dashboard data"- />- ) : null}<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4"><MetricCarddescription={`Tasks: ${flowsTotal?.totalTasksCount ?? 0} · Subtasks: ${flowsTotal?.totalSubtasksCount ?? 0} · Assistants: ${flowsTotal?.totalAssistantsCount ?? 0}`}+ error={!!flowsTotalError}icon={<GitFork className="text-muted-foreground size-4" />}loading={flowsTotalLoading}title="Total Flows"@@ -108,6 +93,7 @@ export function DashboardOverview() {/><MetricCarddescription={`Total duration: ${toolcallsTotal ? formatDuration(toolcallsTotal.totalDurationSeconds) : '—'}`}+ error={!!toolcallsTotalError}icon={<Activity className="text-muted-foreground size-4" />}loading={toolcallsTotalLoading}title="Tool Calls"@@ -115,6 +101,7 @@ export function DashboardOverview() {/><MetricCarddescription="Input + Output tokens processed"+ error={!!usageTotalError}icon={<Cpu className="text-muted-foreground size-4" />}loading={usageTotalLoading}title="Total Tokens"@@ -122,6 +109,7 @@ export function DashboardOverview() {/><MetricCarddescription="Total LLM spending across all providers"+ error={!!usageTotalError}icon={<CircleDollarSign className="text-muted-foreground size-4" />}loading={usageTotalLoading}title="Total Cost"@@ -135,7 +123,13 @@ export function DashboardOverview() {<CardDescription>LLM token usage and costs grouped by provider</CardDescription></CardHeader><CardContent>- {usageByProviderLoading ? <LoadingTable /> : <UsageStatsTable rows={providerRows} />}+ {usageByProviderLoading ? (+ <LoadingTable />+ ) : usageByProviderError ? (+ <ErrorTable />+ ) : (+ <UsageStatsTable rows={providerRows} />+ )}</CardContent></Card>@@ -145,7 +139,13 @@ export function DashboardOverview() {<CardDescription>LLM token usage and costs grouped by model</CardDescription></CardHeader><CardContent>- {usageByModelLoading ? <LoadingTable /> : <UsageStatsTable rows={modelRows} />}+ {usageByModelLoading ? (+ <LoadingTable />+ ) : usageByModelError ? (+ <ErrorTable />+ ) : (+ <UsageStatsTable rows={modelRows} />+ )}</CardContent></Card>@@ -155,7 +155,13 @@ export function DashboardOverview() {<CardDescription>LLM token usage and costs grouped by agent type</CardDescription></CardHeader><CardContent>- {usageByAgentTypeLoading ? <LoadingTable /> : <UsageStatsTable rows={agentTypeRows} />}+ {usageByAgentTypeLoading ? (+ <LoadingTable />+ ) : usageByAgentTypeError ? (+ <ErrorTable />+ ) : (+ <UsageStatsTable rows={agentTypeRows} />+ )}</CardContent></Card>@@ -167,6 +173,8 @@ export function DashboardOverview() {<CardContent>{toolcallsByFunctionLoading ? (<LoadingTable />+ ) : toolcallsByFunctionError ? (+ <ErrorTable />) : (<Table><TableHeader>@@ -205,6 +213,15 @@ export function DashboardOverview() {);}+function ErrorTable() {+ return (+ <div className="text-muted-foreground flex flex-col items-center justify-center gap-2 py-8">+ <AlertCircle className="text-muted-foreground/40 size-6" />+ <p className="text-sm">Couldn't load</p>+ </div>+ );+}+function LoadingTable() {return (<div className="flex items-center justify-center py-8">