import { useEffect, useState } from 'react'; interface HealthStatus { status: string; role: string; redis: boolean; timestamp: string; } interface ScanStatus { status: string; scanning: boolean; lastScan: number; fileCount: number; } interface ServiceInfo { name: string; api: string; capabilities: string[]; timestamp: number; } const cardStyle: React.CSSProperties = { background: '#16213e', borderRadius: '8px', padding: '1.5rem', marginBottom: '1rem', }; const gridStyle: React.CSSProperties = { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '1rem', }; const statStyle: React.CSSProperties = { fontSize: '2rem', fontWeight: 'bold', color: '#4ade80', }; export default function Dashboard() { const [health, setHealth] = useState(null); const [scanStatus, setScanStatus] = useState(null); const [services, setServices] = useState([]); const [error, setError] = useState(null); useEffect(() => { const fetchData = async () => { try { // Fetch health const healthRes = await fetch('/health'); if (healthRes.ok) { setHealth(await healthRes.json()); } // Fetch scan status const scanRes = await fetch('/api/scan/status'); if (scanRes.ok) { setScanStatus(await scanRes.json()); } // Fetch services const servicesRes = await fetch('/services'); if (servicesRes.ok) { const data = await servicesRes.json(); setServices(data.services || []); } setError(null); } catch (err) { setError(String(err)); } }; fetchData(); const interval = setInterval(fetchData, 5000); return () => clearInterval(interval); }, []); const handleTriggerScan = async () => { try { await fetch('/api/scan/trigger', { method: 'POST' }); } catch (err) { console.error('Failed to trigger scan:', err); } }; return (

meta-core Dashboard

{error && (
Error: {error}
)}
{/* Health Card */}

Service Health

{health ? ( <>
{health.status === 'ok' ? 'Healthy' : health.status}

Role: {health.role}

Redis: {health.redis ? 'Connected' : 'Disconnected'}

) : (

Loading...

)}
{/* Scan Status Card */}

File Watcher

{scanStatus ? ( <>
{scanStatus.fileCount}

Files discovered

Status: {scanStatus.scanning ? 'Scanning...' : scanStatus.status}

{scanStatus.lastScan > 0 && (

Last scan: {new Date(scanStatus.lastScan).toLocaleString()}

)} ) : (

Loading...

)}
{/* Services Card */}

Connected Services

{services.length}

Services registered

{services.length > 0 && (
    {services.map((svc) => (
  • {svc.name}
    {svc.capabilities?.join(', ') || 'No capabilities'}
  • ))}
)}
); }