export interface ChannelStatus { id: string; name: string; isActive: boolean; lastCheckedAt: string | null; recording: boolean; activeSessionId: string | null; lastPollError: string | null; } const API_DAEMON_URL = process.env.API_DAEMON_URL ?? "http://localhost:4001"; /** * lastPollError only exists in api-daemon's in-memory map (not persisted to * the DB), so the panel fetches it live over HTTP rather than via Prisma. * Failures here (api-daemon down, network hiccup) shouldn't break the page — * they just mean live-status fields fall back to unknown. */ export async function fetchChannelStatuses(): Promise> { try { const res = await fetch(`${API_DAEMON_URL}/status`, { cache: "no-store" }); if (!res.ok) return new Map(); const data = (await res.json()) as { channels: ChannelStatus[] }; return new Map(data.channels.map((c) => [c.id, c])); } catch { return new Map(); } }