// The tab strip above the canvas (issue #249): click to switch, drag to // reorder, a close โœ• per tab (hidden on the last one), a trailing + to add. import { useState } from "react"; import { useStore } from "zustand"; import { leaves } from "../../layout.js"; import type { LayoutStore, LayoutStoreApi } from "../../stores/layoutStore.js"; export interface TabBarProps { store: LayoutStoreApi; } export function TabBar({ store }: TabBarProps) { const layout = useStore(store, (s: LayoutStore) => s.layout); const previewTempTabId = useStore(store, (s: LayoutStore) => s.preview?.tempTabId ?? null); const [draggingId, setDraggingId] = useState(null); const [overId, setOverId] = useState(null); return (
{layout.tabs.map((tab) => { const count = leaves(tab.root).filter((l) => l.sessionId).length; const isActive = tab.id === layout.activeTabId; const isDropTarget = overId === tab.id && draggingId !== null && draggingId !== tab.id; // A preview's throwaway tab is not a place to go โ€” it goes on its // own the moment the preview ends (docs/PREVIEW.md). const isPreviewTab = tab.id === previewTempTabId; return ( ); })}
); }