"use client"; // One WebSocket for the whole console. Pages refetch when `revision` moves; // the hub stays the source of truth. import { createContext, useContext, type ReactNode } from "react"; import { useHubSocket, type SocketStatus } from "@/lib/useHubSocket"; import type { Frame } from "@/lib/types"; interface LiveValue { status: SocketStatus; revision: number; lastFrame: Frame | null; } const LiveContext = createContext({ status: "connecting", revision: 0, lastFrame: null }); export function LiveProvider({ children }: { children: ReactNode }) { const { status, revision, lastFrame } = useHubSocket(["*.>"]); return {children}; } export function useLive(): LiveValue { return useContext(LiveContext); }