'use client'; import { BarChart3, MonitorPlay, Pause, Play, Search, Unplug } from 'lucide-react'; import type { RefObject } from 'react'; import type { ConnectionStatus, Poll } from '@shared/chat'; import type { StreamState } from '../lib/useEvents'; type Props = { status: ConnectionStatus; stream: StreamState; poll: Poll | null; counts: { chat: number; super: number; members: number }; search: string; searchRef: RefObject; onSearch: (value: string) => void; paused: boolean; onTogglePause: () => void; onOverlaySettings: () => void; onDisconnect: () => void; }; function statusLabel(status: ConnectionStatus, stream: StreamState): { text: string; tone: string } { if (stream === 'error') return { text: 'Backend unreachable', tone: 'danger' }; if (stream === 'connecting') return { text: 'Connecting to backend', tone: 'muted' }; switch (status.state) { case 'live': return { text: 'Live', tone: 'live' }; case 'connecting': return { text: 'Connecting', tone: 'warn' }; case 'reconnecting': return { text: 'Reconnecting', tone: 'warn' }; default: return { text: status.error ? `Disconnected: ${status.error}` : 'Disconnected', tone: 'danger' }; } } export function TopBar({ status, stream, poll, counts, search, searchRef, onSearch, paused, onTogglePause, onOverlaySettings, onDisconnect }: Props) { const label = statusLabel(status, stream); return (
{status.title || status.liveId || 'No stream'} {label.text} {poll?.active && ( Poll )}
{counts.chat} chat {counts.super} super {counts.members} members
); }