/** * useWindow(id) (API ยง10) โ€” one window's live phase + shell `Window` (null id / * unknown id โ†’ a stable "no window"), reactive over the per-shell hub registry. */ import { useMemo, useSyncExternalStore } from 'react' import type { WindowView } from '../hub.js' import { useShell } from '../../session/shell.hook.js' import { getStageHub } from '../hub.js' /** One window's live phase + shell `Window` (null id / unknown id โ†’ no window). */ export function useWindow(windowId: string | null): WindowView { const shell = useShell() const hub = useMemo(() => getStageHub(shell), [shell]) const snapshot = useMemo(() => () => hub.registry.select(windowId), [hub, windowId]) return useSyncExternalStore(hub.registry.subscribe, snapshot, snapshot) }