import { formatLastSeen, useConnectionStore } from '@/live'; import { cn } from '@/lib/utils'; /** * Subtle WS-status indicator. Sits bottom-left of the monitor route. * * Three visible states: * - **Connected** — small green dot + muted "Live" label. * - **Connecting / reconnecting** — amber pulsing dot + status word. * - **Disconnected** — red dot + "Offline · last live HH:MM" so the * operator can see how long the gap has been. * * Designed to be ignorable when everything's fine and unmissable when * it isn't — same posture as the design system's "live" pulse. */ export function ConnectionChip() { const status = useConnectionStore((s) => s.status); const lastConnectedAt = useConnectionStore((s) => s.lastConnectedAt); return (
{status === 'connected' && ( <> Live )} {(status === 'connecting' || status === 'reconnecting') && ( <> {status === 'connecting' ? 'Connecting…' : 'Reconnecting…'} )} {status === 'disconnected' && ( <> Offline {lastConnectedAt ? <> · last live {formatLastSeen(lastConnectedAt)} : null} )}
); }