'use client'; import React from 'react'; import { AlertTriangle, Wifi, WifiOff, Loader2 } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip'; type ConnectionStatus = 'connected' | 'connecting' | 'error' | 'idle'; interface StatusIndicatorProps { /** Current connection status */ status: ConnectionStatus; /** Whether MCP (Model Context Protocol) is connected */ mcpConnected?: boolean; /** Optional custom label to display */ label?: string; } /** * Status configuration for each connection state */ const STATUS_CONFIG: Record< ConnectionStatus, { color: string; bgColor: string; pulseColor?: string; text: string; icon: React.ReactNode; } > = { connected: { color: 'bg-green-500', bgColor: 'bg-green-100', pulseColor: 'bg-green-400', text: 'Connected', icon: , }, connecting: { color: 'bg-yellow-500', bgColor: 'bg-yellow-100', pulseColor: 'bg-yellow-400', text: 'Connecting...', icon: , }, error: { color: 'bg-red-500', bgColor: 'bg-red-100', text: 'Connection Error', icon: , }, idle: { color: 'bg-gray-400', bgColor: 'bg-gray-100', text: 'Idle', icon: , }, }; /** * StatusIndicator - Shows connection status for the Control Center * * Displays a colored dot indicator with tooltip showing detailed status. * Also shows warning if MCP is not connected. */ export const StatusIndicator: React.FC = ({ status, mcpConnected = true, label, }) => { const config = STATUS_CONFIG[status]; const showMcpWarning = !mcpConnected; return ( {/* Main status indicator */} {/* Status dot with pulse animation for active states */} {config.pulseColor && ( )} {/* Status text/label */} {label || config.text} {config.icon} {config.text} {/* MCP Warning indicator */} {showMcpWarning && ( Limited MCP Not Connected Some features may be unavailable. Tool execution will be limited. )} ); }; /** * Compact version of StatusIndicator - just shows the dot */ export const StatusDot: React.FC<{ status: ConnectionStatus; className?: string; }> = ({ status, className }) => { const config = STATUS_CONFIG[status]; return ( {config.pulseColor && ( )} {config.icon} {config.text} ); }; export default StatusIndicator;