import { trpc } from '@/lib/trpc';

export type ConnectionState = "connected" | "reconnecting" | "disconnected";

export function useConnectionStatus(): ConnectionState {
  const { status } = trpc.onEvent.useSubscription(undefined);

  if (status === 'pending') return "connected";
  if (status === 'connecting') return "reconnecting";
  return "disconnected"; // 'idle' (stream closed) or 'error' (fatal)
}
