import { lazy, Suspense, useState } from "react"; import { Activity, ChevronLeft, Compass, Database, FlaskConical, GitCompare, LayoutDashboard, ListChecks, Loader2, Maximize2, PanelRightClose, PanelRightOpen, Sliders, Stethoscope, X, } from "lucide-react"; import { useShallow } from "zustand/react/shallow"; import { useOstraStore, type Page, type XRayTab, } from "../../store/useOstraStore"; import type { DiagnosticLens } from "../../types/ostra"; import { DocInspectorDrawer } from "../atlas/DocInspectorDrawer"; import { HelpInfo } from "../common/HelpInfo"; import { OverviewPage } from "../overview/OverviewPage"; import { DiagnosisAndResultsView } from "../xray/DiagnosisAndResultsView"; import { QueryBarAnatomy } from "../xray/QueryBarAnatomy"; import { CorpusHealthBar } from "./CorpusHealthBar"; // Code-split heavy views (especially Deck.gl WebGL Atlas, Labs, Compare, and Modals) // so initial HTML + Query Bar + results paint immediately without blocking the main thread. const AtlasPage = lazy(() => import("../atlas/AtlasPage").then((m) => ({ default: m.AtlasPage })) ); const EmbeddingAtlasCanvas = lazy(() => import("../atlas/EmbeddingAtlasCanvas").then((m) => ({ default: m.EmbeddingAtlasCanvas, })) ); const CompareRunsPage = lazy(() => import("../compare/CompareRunsPage").then((m) => ({ default: m.CompareRunsPage, })) ); const LabsPage = lazy(() => import("../suite/LabsPage").then((m) => ({ default: m.LabsPage })) ); const SampleSuitePanel = lazy(() => import("../suite/SampleSuitePanel").then((m) => ({ default: m.SampleSuitePanel, })) ); const ForensicDiffPanel = lazy(() => import("../xray/ForensicDiffPanel").then((m) => ({ default: m.ForensicDiffPanel, })) ); const QuadrantAndCliffView = lazy(() => import("../xray/QuadrantAndCliffView").then((m) => ({ default: m.QuadrantAndCliffView, })) ); const HybridMixingBoard = lazy(() => import("../tuners/HybridMixingBoard").then((m) => ({ default: m.HybridMixingBoard, })) ); const DatasetWizardModal = lazy(() => import("../ingest/DatasetWizardModal").then((m) => ({ default: m.DatasetWizardModal, })) ); const ExportRecipeModal = lazy(() => import("../suite/ExportRecipeModal").then((m) => ({ default: m.ExportRecipeModal, })) ); function LazyViewFallback({ label = "Loading view…" }: { label?: string }) { return (
{label}
); } const XRAY_TABS: { id: XRayTab; label: string; icon: React.ReactNode }[] = [ { id: "diagnosis", label: "Diagnosis & Results", icon: , }, { id: "forensic", label: "Forensic Diff (A vs B)", icon: , }, { id: "cliff", label: "Confidence & Abstention", icon: , }, ]; const SPLIT_MAP_LENSES: { id: DiagnosticLens; label: string }[] = [ { id: "clusters", label: "Clusters" }, { id: "hubness", label: "Hubs" }, { id: "antihubs", label: "Hidden" }, { id: "truncation", label: "Cut-Off" }, { id: "purity", label: "Purity" }, ]; const NAV_ITEMS: { id: Page; label: string; subtitle: string; icon: React.ReactNode; }[] = [ { id: "debug", label: "Debug & Map", subtitle: "Live X-ray + 2D Atlas", icon: , }, { id: "overview", label: "Overview", subtitle: "Health & next step", icon: , }, { id: "suite", label: "Eval Suite", subtitle: "Questions, triage & gate", icon: , }, { id: "optimize", label: "Optimize", subtitle: "Verified fix labs", icon: , }, { id: "atlas", label: "Full Atlas", subtitle: "2D map & facets", icon: , }, { id: "compare", label: "Compare", subtitle: "Model & run bakeoff", icon: , }, ]; export function WorkbenchShell() { const { activeRun, runs, loadingRun, page, lab, xrayTab, sidebarCollapsed, setSidebarCollapsed, mixingDrawerOpen, setMixingDrawerOpen, openOverview, setXRayTab, openSuite, openLab, openAtlas, openCompare, setWizardOpen, wizardOpen, exportModalOpen, activeLens, setActiveLens, atlasBinary, loadingAtlas, suiteItems, baselineCheck, facets, } = useOstraStore( useShallow((s) => ({ activeRun: s.activeRun, runs: s.runs, loadingRun: s.loadingRun, page: s.page, lab: s.lab, xrayTab: s.xrayTab, sidebarCollapsed: s.sidebarCollapsed, setSidebarCollapsed: s.setSidebarCollapsed, mixingDrawerOpen: s.mixingDrawerOpen, setMixingDrawerOpen: s.setMixingDrawerOpen, openOverview: s.openOverview, setXRayTab: s.setXRayTab, openSuite: s.openSuite, openLab: s.openLab, openAtlas: s.openAtlas, openCompare: s.openCompare, setWizardOpen: s.setWizardOpen, wizardOpen: s.wizardOpen, exportModalOpen: s.exportModalOpen, activeLens: s.activeLens, setActiveLens: s.setActiveLens, atlasBinary: s.atlasBinary, loadingAtlas: s.loadingAtlas, suiteItems: s.suiteItems, baselineCheck: s.baselineCheck, facets: s.facets, })) ); const [splitMapVisible, setSplitMapVisible] = useState(true); const navigate = (target: Page) => { if (target === "overview") openOverview(); else if (target === "debug") setXRayTab(xrayTab); else if (target === "suite") openSuite(); else if (target === "optimize") openLab(lab); else if (target === "atlas") openAtlas(); else openCompare(); }; return (
{loadingRun ? (
Loading binary Atlas & sparse BM25 index…
) : !activeRun ? (
Ostra Workbench

Visual Debugger for Embedding & Hybrid Search

Select any public Hugging Face text dataset & embedding model, diagnose why vector or hybrid search fails, optimize fusion and reranking against an eval suite, and export verified configs.

) : (
{/* Primary Collapsible Left Navigation Sidebar (fully collapses to reclaim 100% width) */} {!sidebarCollapsed && ( )} {/* Main Full-Width Page Canvas */}
{page === "overview" && } {page === "debug" && (
{/* X-Ray View Tabs (Clean 3-tab Folder Strip) */}
{XRAY_TABS.map((t) => ( ))}
{/* Immersive Split Home Workspace: Debug X-Ray (Left 60%) + Live 2D Corpus Map (Right 40% of screen) */}
{xrayTab === "diagnosis" && } {xrayTab === "forensic" && ( }> )} {xrayTab === "cliff" && ( }> )}
{splitMapVisible && (
2D Map
{SPLIT_MAP_LENSES.map((l) => ( ))}
{loadingAtlas && !atlasBinary ? ( ) : ( }> )}
)}
)} {page === "suite" && ( }> )} {page === "optimize" && ( }> )} {page === "atlas" && ( }> )} {page === "compare" && ( }> )}
{/* Optional On-Demand Right Drawer: Live Engine Controls (collapsed by default!) */} {mixingDrawerOpen && ( )}
)} {/* Modals (mounted strictly on demand) */} {wizardOpen && ( )} {exportModalOpen && ( )}
); }