import { useState, useEffect } from 'react'; import { useQuery } from '@tanstack/react-query'; import { motion } from 'framer-motion'; import { Activity, Server, Database, Zap, Eye, RefreshCw, CheckCircle2, XCircle, AlertCircle, Cpu, MemoryStick } from 'lucide-react'; import axios from 'axios'; interface Service { name: string; type: string; port: number | null; running: boolean; status: string; pid: number | null; cpu: number; memory: number; description: string; } interface ServicesResponse { services: Service[]; summary: { total: number; running: number; stopped: number; health: 'healthy' | 'degraded' | 'critical'; }; timestamp: number; } const SERVICE_ICONS: Record = { mcp_server: Server, frontend: Activity, redis: Database, rq_worker: Zap, ollama: Cpu, file_watcher: Eye }; const STATUS_COLORS = { running: { bg: 'bg-green-500/20', border: 'border-green-500', text: 'text-green-400', icon: CheckCircle2 }, stopped: { bg: 'bg-gray-500/20', border: 'border-gray-500', text: 'text-gray-400', icon: XCircle }, unknown: { bg: 'bg-yellow-500/20', border: 'border-yellow-500', text: 'text-yellow-400', icon: AlertCircle } }; export default function ServiceDashboard() { const [autoRefresh, setAutoRefresh] = useState(true); // Fetch services status const { data: servicesData, isLoading, refetch } = useQuery({ queryKey: ['services-status'], queryFn: async () => { const response = await axios.get('/api/services/status'); return response.data; }, refetchInterval: autoRefresh ? 5000 : false, // Refresh every 5 seconds if enabled }); const services = servicesData?.services || []; const summary = servicesData?.summary; const getHealthColor = (health?: string) => { switch (health) { case 'healthy': return 'text-green-400'; case 'degraded': return 'text-yellow-400'; case 'critical': return 'text-red-400'; default: return 'text-gray-400'; } }; return (
{/* Header */}

Service Dashboard

Real-time monitoring of Claude OS services

{/* Auto-refresh toggle */} {/* Manual refresh */}
{/* Summary Cards */} {summary && (
Total Services
{summary.total}
Running
{summary.running}
Stopped
{summary.stopped}
System Health
{summary.health}
)} {/* Services Grid */}
{services.map((service, index) => { const Icon = SERVICE_ICONS[service.type] || Server; const statusConfig = STATUS_COLORS[service.status] || STATUS_COLORS.unknown; const StatusIcon = statusConfig.icon; return ( {/* Service Header */}

{service.name}

{service.description}

{/* Status Badge */}
{service.status}
{/* Service Details */}
{service.port && (
Port: {service.port}
)} {service.pid && (
PID: {service.pid}
)} {service.running && service.cpu !== undefined && (
CPU: {service.cpu.toFixed(1)}%
)} {service.running && service.memory !== undefined && (
Memory: {service.memory.toFixed(1)}%
)}
{/* Service URL (if applicable) */} {service.port && service.running && ( )}
); })}
{/* Help Text */}

Service Management

To start/stop services, use the management scripts:

./start_all_services.sh ./stop_all_services.sh ./restart_services.sh
{/* Last Updated */} {servicesData && (
Last updated: {new Date(servicesData.timestamp * 1000).toLocaleTimeString()}
)}
); }