import { useEffect, useState } from 'react'; import { DocumentSlotView } from '../../editors/DocumentSlotView'; import { useDocumentSlot } from '../../documents/useDocumentSlot'; import { useDocumentTitle } from '../../documents/useDocumentTitle'; import { WorkspaceBarSlot } from '../barSlot'; import type { WorkspaceProps } from '../workspace'; import type { EditorViewSnapshot } from '../../editors/types'; export function ZenWorkspace({ active, openRequestId, openRequest, resolveProvider, onOpenEntry, onActiveDocumentChange, }: WorkspaceProps) { const { state, close } = useDocumentSlot({ openRequestId, openRequest, resolveProvider, accepts: active, }); // Zen shows one document at a time, but opening another and coming back // still remounts the editor — so it keeps a snapshot the same way tiling does. const [viewSnapshot, setViewSnapshot] = useState( null, ); const handle = state.kind === 'open' ? state.handle : null; const title = useDocumentTitle(handle); // Same contract as tiling: report what is shown, derived from slot state. const shownDocument = active && state.kind !== 'empty' ? state.request : null; useEffect(() => { if (!active) return; onActiveDocumentChange?.(shownDocument); }, [active, shownDocument, onActiveDocumentChange]); return ( <>
{state.kind === 'empty' ? 'Zen · no document open' : state.kind === 'open' ? title || state.request.title : state.request.title}
{state.kind !== 'empty' ? ( ) : null}
); }