"use client"; import { useSyncExternalStore } from "react"; import { marketStream } from "@/lib/stream"; import { cx } from "@/lib/format"; export function StreamIndicator({ className }: { className?: string }) { const state = useSyncExternalStore( (l) => marketStream().listenState(l), () => marketStream().state, () => "idle" as const, ); const label = state === "open" ? "Stream live" : state === "connecting" || state === "reconnecting" ? "Connecting…" : "Stream idle"; return ( {label} ); }