// Live data-source pill — shows status + per-config progress bars. const { useState: useStateDS, useEffect: useEffectDS, useRef: useRefDS } = React; function DataSource() { const [s, setS] = useStateDS(window.AtlasLoader.state); const [expanded, setExpanded] = useStateDS(false); const [panelPos, setPanelPos] = useStateDS({ top: 0, right: 0 }); const pillRef = useRefDS(null); useEffectDS(() => window.AtlasLoader.subscribe(setS), []); useEffectDS(() => { if (!expanded || !pillRef.current) return; const r = pillRef.current.getBoundingClientRect(); setPanelPos({ top: r.bottom + 10, right: window.innerWidth - r.right }); }, [expanded]); const dot = { idle: { c: 'var(--cream-dim)', label: 'idle' }, loading: { c: 'var(--gold)', label: 'streaming' }, live: { c: 'var(--sage)', label: 'live' }, error: { c: 'var(--coral)', label: 'offline' }, }[s.status] || { c: 'var(--cream-dim)', label: s.status }; // pill label let pillLabel = `data · ${dot.label}`; if (s.status === 'loading') { const totalLoaded = (s.progress.perHead + s.progress.bouncer + s.progress.prompts) / 3; pillLabel = `streaming · ${Math.round(totalLoaded * 100)}%`; } else if (s.status === 'live') { pillLabel = 'live · juiceb0xc0de'; } const panel = expanded && ReactDOM.createPortal(