feat(ui): wire CPU anomaly indicator to dashboard

Connect anomaly data to the EnhancedCPUBar component in GuestRow.
When a VM/container's CPU is significantly above its learned baseline,
a pulsing indicator (e.g., '2.5x') appears directly on the CPU bar.

This provides real-time baseline deviation feedback without any LLM
involvement - purely deterministic statistical analysis.

Memory and disk anomaly hooks are prepared but not yet wired to their
respective bar components (TODO for follow-up).
This commit is contained in:
rcourtman 2025-12-21 11:06:23 +00:00
parent 24e072f6b5
commit 9aad21169d

View file

@ -21,6 +21,8 @@ import { useBreakpoint } from '@/hooks/useBreakpoint';
import { useMetricsViewMode } from '@/stores/metricsViewMode';
import { aiChatStore } from '@/stores/aiChat';
import { useAlertsActivation } from '@/stores/alertsActivation';
import { useAnomalyForMetric } from '@/hooks/useAnomalies';
type Guest = VM | Container;
@ -516,6 +518,13 @@ export function GuestRow(props: GuestRowProps) {
return buildMetricKey(kind, guestId());
});
// Get anomalies for this guest's metrics (deterministic, no LLM)
const cpuAnomaly = useAnomalyForMetric(() => props.guest.id, () => 'cpu');
const memoryAnomaly = useAnomalyForMetric(() => props.guest.id, () => 'memory');
const diskAnomaly = useAnomalyForMetric(() => props.guest.id, () => 'disk');
// TODO: Wire memoryAnomaly and diskAnomaly to StackedMemoryBar and StackedDiskBar
void memoryAnomaly; // Prepared for future use
void diskAnomaly; // Prepared for future use
const [customUrl, setCustomUrl] = createSignal<string | undefined>(props.customUrl);
const [shouldAnimateIcon, setShouldAnimateIcon] = createSignal(false);
@ -918,6 +927,7 @@ export function GuestRow(props: GuestRowProps) {
usage={cpuPercent()}
cores={props.guest.cpus}
resourceId={metricsKey()}
anomaly={cpuAnomaly()}
/>
</div>
</td>