/** * HealthPanel — Read-only dashboard for all subsystem health status * * Displays: * - Agent Heartbeat engine status (running, config, alerts) * - Connection status (mode, SaaS reachability) * - SaaS device heartbeat status * - Memory pipeline status * - Recent alerts history * * No config editing (that's HeartbeatConfig tab). * Uses useState (not Zustand) — component-scoped state. */ import { useState, useEffect, useCallback, useRef } from 'react'; import { Activity, RefreshCw, Wifi, WifiOff, Cloud, CloudOff, Database, AlertTriangle, CheckCircle, XCircle, Clock, } from 'lucide-react'; import { intelligenceClient, type HeartbeatResult } from '../lib/intelligence-client'; import { useConnectionStore } from '../store/connectionStore'; import { useSaaSStore } from '../store/saasStore'; import { isTauriRuntime } from '../lib/tauri-gateway'; import { safeListen } from '../lib/safe-tauri'; import { createLogger } from '../lib/logger'; const log = createLogger('HealthPanel'); // === Types === interface HealthSnapshotData { timestamp: string; intelligence: { engineRunning: boolean; config: { enabled: boolean; interval_minutes: number; proactivity_level: string; }; lastTick: string | null; alertCount24h: number; totalChecks: number; }; memory: { totalEntries: number; storageSizeBytes: number; lastExtraction: string | null; }; } interface HealthCardProps { title: string; icon: React.ReactNode; status: 'green' | 'yellow' | 'gray' | 'red'; children: React.ReactNode; } const STATUS_COLORS = { green: 'text-green-500', yellow: 'text-yellow-500', gray: 'text-gray-400', red: 'text-red-500', }; const STATUS_BG = { green: 'bg-green-50 dark:bg-green-900/20', yellow: 'bg-yellow-50 dark:bg-yellow-900/20', gray: 'bg-gray-50 dark:bg-gray-800/50', red: 'bg-red-50 dark:bg-red-900/20', }; function HealthCard({ title, icon, status, children }: HealthCardProps) { return (
{alert.content}