File size: 21,112 Bytes
46d70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0cf2f43
46d70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0cf2f43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46d70d9
0cf2f43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46d70d9
 
 
 
 
 
 
 
0cf2f43
46d70d9
0cf2f43
 
 
 
 
 
 
 
 
 
 
46d70d9
0cf2f43
 
 
 
 
 
 
 
 
 
 
 
 
46d70d9
 
 
 
 
 
 
 
 
 
0cf2f43
 
46d70d9
 
 
 
 
0cf2f43
46d70d9
 
 
 
 
 
 
 
 
 
 
0cf2f43
46d70d9
 
 
0cf2f43
46d70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0cf2f43
46d70d9
 
 
 
 
 
 
 
0cf2f43
46d70d9
0cf2f43
46d70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
0cf2f43
46d70d9
0cf2f43
46d70d9
 
0cf2f43
46d70d9
 
 
 
 
 
 
0cf2f43
46d70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0cf2f43
46d70d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
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 (
    <div className="flex-1 h-full paper-canvas flex items-center justify-center gap-2 text-[#334155] font-mono text-xs">
      <Loader2 className="w-4 h-4 animate-spin text-sky-600" />
      <span>{label}</span>
    </div>
  );
}

const XRAY_TABS: { id: XRayTab; label: string; icon: React.ReactNode }[] = [
  {
    id: "diagnosis",
    label: "Diagnosis & Results",
    icon: <Stethoscope className="w-3.5 h-3.5" />,
  },
  {
    id: "forensic",
    label: "Forensic Diff (A vs B)",
    icon: <GitCompare className="w-3.5 h-3.5" />,
  },
  {
    id: "cliff",
    label: "Confidence & Abstention",
    icon: <Activity className="w-3.5 h-3.5" />,
  },
];

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: <Stethoscope className="w-4 h-4 shrink-0" />,
  },
  {
    id: "overview",
    label: "Overview",
    subtitle: "Health & next step",
    icon: <LayoutDashboard className="w-4 h-4 shrink-0" />,
  },
  {
    id: "suite",
    label: "Eval Suite",
    subtitle: "Questions, triage & gate",
    icon: <ListChecks className="w-4 h-4 shrink-0" />,
  },
  {
    id: "optimize",
    label: "Optimize",
    subtitle: "Verified fix labs",
    icon: <FlaskConical className="w-4 h-4 shrink-0" />,
  },
  {
    id: "atlas",
    label: "Full Atlas",
    subtitle: "2D map & facets",
    icon: <Compass className="w-4 h-4 shrink-0" />,
  },
  {
    id: "compare",
    label: "Compare",
    subtitle: "Model & run bakeoff",
    icon: <GitCompare className="w-4 h-4 shrink-0" />,
  },
];

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 (
    <div className="h-screen w-screen flex flex-col bg-[#f7f8fa] text-[#0f172a] overflow-hidden">
      <CorpusHealthBar />

      {loadingRun ? (
        <div className="flex-1 paper-canvas flex items-center justify-center gap-2 text-[#334155] font-mono text-xs">
          <Loader2 className="w-4 h-4 animate-spin text-sky-600" />
          <span>Loading binary Atlas &amp; sparse BM25 index…</span>
        </div>
      ) : !activeRun ? (
        <div className="flex-1 paper-canvas flex flex-col items-center justify-center p-8">
          <div className="paper-card max-w-md w-full p-6 text-center space-y-4">
            <span className="paper-legend">Ostra Workbench</span>
            <div className="mx-auto w-12 h-12 bg-[#f1f4f8] border-[1.5px] border-[#0f172a] flex items-center justify-center relative">
              <Database className="w-6 h-6 text-sky-700" />
              <span className="absolute -top-1 -right-1 w-2.5 h-2.5 bg-emerald-500 border border-[#0f172a]" />
            </div>
            <div className="space-y-1.5">
              <h1 className="text-base font-mono font-bold text-[#0f172a] tracking-tight">
                Visual Debugger for Embedding &amp; Hybrid Search
              </h1>
              <p className="text-xs text-[#475569] leading-relaxed">
                Select any public Hugging Face text dataset &amp; embedding model,
                diagnose why vector or hybrid search fails, optimize fusion and
                reranking against an eval suite, and export verified configs.
              </p>
            </div>
            <button
              type="button"
              onClick={() => setWizardOpen(true)}
              className="paper-btn-ink px-4 py-2 text-xs font-semibold cursor-pointer inline-flex items-center gap-1.5"
            >
              <span>Select Hugging Face Dataset →</span>
            </button>
          </div>
        </div>
      ) : (
        <div className="flex-1 flex min-h-0 overflow-hidden">
          {/* Primary Collapsible Left Navigation Sidebar (fully collapses to reclaim 100% width) */}
          {!sidebarCollapsed && (
            <nav className="w-[184px] shrink-0 border-r-[1.5px] border-[#0f172a] bg-[#f1f4f8] flex flex-col justify-between select-none">
              <div className="p-2 flex flex-col gap-1 overflow-y-auto">
                {NAV_ITEMS.map((item) => {
                  const active = page === item.id;
                  const badge =
                    item.id === "suite" && suiteItems.length > 0
                      ? {
                          text: String(suiteItems.length),
                          tone:
                            baselineCheck?.verdict === "FAIL_REGRESSION"
                              ? "bg-red-600 text-white"
                              : "bg-[#0f172a] text-white",
                        }
                      : item.id === "atlas" && facets?.selection_active
                      ? {
                          text: String(facets.filtered_count),
                          tone: "bg-sky-600 text-white",
                        }
                      : item.id === "compare" && runs.length >= 2
                      ? {
                          text: String(runs.length),
                          tone: "bg-[#e8edf3] text-[#0f172a] border border-[#0f172a]",
                        }
                      : null;

                  return (
                    <button
                      key={item.id}
                      type="button"
                      title={item.subtitle}
                      onClick={() => navigate(item.id)}
                      className={`relative flex items-center justify-between px-2.5 py-2 border-[1.5px] cursor-pointer transition-colors text-left ${
                        active
                          ? "bg-white border-[#0f172a] text-[#0f172a] shadow-[2px_2px_0_rgba(15,23,42,0.18)]"
                          : "border-transparent text-[#475569] hover:bg-white/80 hover:border-[#94a3b8] hover:text-[#0f172a]"
                      }`}
                    >
                      <div className="flex items-center gap-2 min-w-0">
                        <span
                          className={active ? "text-[#0f172a]" : "text-[#64748b]"}
                        >
                          {item.icon}
                        </span>
                        <div className="min-w-0">
                          <div className="font-mono text-[11px] font-bold leading-tight truncate">
                            {item.label}
                          </div>
                          <div className="text-[10px] text-[#64748b] leading-tight truncate">
                            {item.subtitle}
                          </div>
                        </div>
                      </div>

                      {badge && (
                        <span
                          className={`px-1.5 py-0.5 font-mono text-[9px] font-bold tabular-nums shrink-0 ${badge.tone}`}
                        >
                          {badge.text}
                        </span>
                      )}
                    </button>
                  );
                })}
              </div>

              <div className="p-2 border-t border-[#cbd5e1] flex items-center justify-end">
                <button
                  type="button"
                  onClick={() => setSidebarCollapsed(true)}
                  title="Collapse navigation sidebar"
                  className="w-full py-1 px-2 bg-white hover:bg-[#e8edf3] border border-[#94a3b8] hover:border-[#0f172a] text-[#475569] hover:text-[#0f172a] font-mono text-[10px] inline-flex items-center justify-center gap-1 cursor-pointer"
                >
                  <ChevronLeft className="w-3.5 h-3.5" />
                  <span>Collapse Sidebar</span>
                </button>
              </div>
            </nav>
          )}

          {/* Main Full-Width Page Canvas */}
          <main className="flex-1 min-w-0 relative paper-canvas overflow-hidden flex flex-col">
            {page === "overview" && <OverviewPage />}

            {page === "debug" && (
              <div className="flex-1 flex flex-col min-h-0 bg-[#f7f8fa]">
                <QueryBarAnatomy />

                {/* X-Ray View Tabs (Clean 3-tab Folder Strip) */}
                <div className="h-9 shrink-0 border-b-[1.5px] border-[#0f172a] bg-[#f1f4f8] px-3 flex items-end justify-between gap-2 overflow-x-auto">
                  <div className="flex items-end gap-1 shrink-0">
                    {XRAY_TABS.map((t) => (
                      <button
                        key={t.id}
                        type="button"
                        onClick={() => setXRayTab(t.id)}
                        className={`inline-flex items-center gap-1.5 px-2.5 py-1.5 font-mono text-[11px] whitespace-nowrap shrink-0 transition-colors cursor-pointer border-[1.5px] -mb-[1.5px] ${
                          xrayTab === t.id
                            ? "bg-[#f7f8fa] text-[#0f172a] border-[#0f172a] border-b-[#f7f8fa] font-semibold"
                            : "bg-[#e8edf3] text-[#475569] border-[#94a3b8] border-b-[#0f172a] hover:text-[#0f172a] hover:bg-white/70"
                        }`}
                      >
                        {t.icon}
                        <span>{t.label}</span>
                      </button>
                    ))}
                  </div>

                  <div className="self-center flex items-center gap-1.5 shrink-0">
                    <button
                      type="button"
                      onClick={() => setSplitMapVisible((v) => !v)}
                      className={`h-6 px-2 text-[10px] font-mono font-semibold whitespace-nowrap inline-flex items-center gap-1 border cursor-pointer transition-colors ${
                        splitMapVisible
                          ? "bg-[#0f172a] text-white border-[#0f172a]"
                          : "bg-white text-[#0f172a] border-[#0f172a] hover:bg-sky-50"
                      }`}
                      title={
                        splitMapVisible
                          ? "Hide live 2D Map split pane"
                          : "Show live 2D Map alongside Debug results"
                      }
                    >
                      {splitMapVisible ? (
                        <>
                          <PanelRightClose className="w-3 h-3 text-sky-400" />
                          <span>Hide 2D Map</span>
                        </>
                      ) : (
                        <>
                          <PanelRightOpen className="w-3 h-3 text-sky-700" />
                          <span>Show 2D Map</span>
                        </>
                      )}
                    </button>
                    <button
                      type="button"
                      onClick={() => openAtlas(activeLens)}
                      className="paper-btn h-6 px-2 text-[10px] font-semibold whitespace-nowrap inline-flex items-center gap-1 cursor-pointer"
                      title="Expand 2D Corpus Atlas with full Facets & Cross-Filter sidebar"
                    >
                      <Maximize2 className="w-3 h-3 text-sky-700" />
                      <span>Full Map &amp; Facets</span>
                    </button>
                  </div>
                </div>

                {/* Immersive Split Home Workspace: Debug X-Ray (Left 60%) + Live 2D Corpus Map (Right 40% of screen) */}
                <div className="flex-1 min-h-0 flex overflow-hidden paper-canvas">
                  <div className="flex-1 min-w-0 min-h-0 overflow-hidden @container">
                    {xrayTab === "diagnosis" && <DiagnosisAndResultsView />}
                    {xrayTab === "forensic" && (
                      <Suspense fallback={<LazyViewFallback label="Loading Forensic Diff…" />}>
                        <ForensicDiffPanel />
                      </Suspense>
                    )}
                    {xrayTab === "cliff" && (
                      <Suspense fallback={<LazyViewFallback label="Loading Confidence & Cliff…" />}>
                        <QuadrantAndCliffView />
                      </Suspense>
                    )}
                  </div>

                  {splitMapVisible && (
                    <section className="hidden md:flex w-[40vw] min-w-[340px] max-w-[55%] shrink-0 border-l-[1.5px] border-[#0f172a] bg-[#f7f8fa] flex-col min-h-0 overflow-hidden">
                      <div className="h-9 shrink-0 border-b border-[#cbd5e1] bg-[#f1f4f8] px-2.5 flex items-center justify-between gap-2 overflow-x-auto">
                        <div className="inline-flex items-center gap-1.5 font-mono text-[10px] font-bold text-[#0f172a] shrink-0">
                          <Compass className="w-3.5 h-3.5 text-sky-600" />
                          <span>2D Map</span>
                          <HelpInfo topic="atlasLens" />
                        </div>
                        <div className="flex items-center gap-1 shrink-0">
                          {SPLIT_MAP_LENSES.map((l) => (
                            <button
                              key={l.id}
                              type="button"
                              onClick={() => setActiveLens(l.id)}
                              className={`px-1.5 py-0.5 font-mono text-[10px] whitespace-nowrap border cursor-pointer transition-colors ${
                                activeLens === l.id
                                  ? "bg-[#0f172a] text-white border-[#0f172a] font-semibold"
                                  : "bg-white text-[#475569] border-[#cbd5e1] hover:border-[#0f172a] hover:text-[#0f172a]"
                              }`}
                            >
                              {l.label}
                            </button>
                          ))}
                        </div>
                      </div>
                      <div className="flex-1 relative min-h-0">
                        {loadingAtlas && !atlasBinary ? (
                          <LazyViewFallback label="Loading 2D Map coordinates…" />
                        ) : (
                          <Suspense fallback={<LazyViewFallback label="Initializing 2D Map…" />}>
                            <EmbeddingAtlasCanvas showLensBar={false} compact />
                          </Suspense>
                        )}
                      </div>
                    </section>
                  )}
                </div>
              </div>
            )}

            {page === "suite" && (
              <Suspense fallback={<LazyViewFallback label="Loading Eval Suite…" />}>
                <SampleSuitePanel />
              </Suspense>
            )}
            {page === "optimize" && (
              <Suspense fallback={<LazyViewFallback label="Loading Optimization Labs…" />}>
                <LabsPage />
              </Suspense>
            )}
            {page === "atlas" && (
              <Suspense fallback={<LazyViewFallback label="Loading 2D Corpus Atlas…" />}>
                <AtlasPage />
              </Suspense>
            )}
            {page === "compare" && (
              <Suspense fallback={<LazyViewFallback label="Loading Run Bakeoff…" />}>
                <CompareRunsPage />
              </Suspense>
            )}

            <DocInspectorDrawer />
          </main>

          {/* Optional On-Demand Right Drawer: Live Engine Controls (collapsed by default!) */}
          {mixingDrawerOpen && (
            <aside className="w-[332px] shrink-0 border-l-[1.5px] border-[#0f172a] bg-[#f7f8fa] flex flex-col overflow-hidden">
              <div className="h-10 shrink-0 border-b-[1.5px] border-[#0f172a] bg-[#f1f4f8] px-3 flex items-center justify-between gap-2">
                <div className="inline-flex items-center gap-1.5 font-mono text-[11px] font-bold text-[#0f172a]">
                  <Sliders className="w-3.5 h-3.5 text-emerald-700" />
                  <span>Engine Controls</span>
                </div>
                <button
                  type="button"
                  onClick={() => setMixingDrawerOpen(false)}
                  title="Close Engine Controls drawer"
                  className="p-1 bg-white hover:bg-[#e8edf3] border border-[#0f172a] text-[#0f172a] cursor-pointer"
                >
                  <X className="w-3.5 h-3.5" />
                </button>
              </div>
              <Suspense fallback={<LazyViewFallback label="Loading controls…" />}>
                <HybridMixingBoard />
              </Suspense>
            </aside>
          )}
        </div>
      )}

      {/* Modals (mounted strictly on demand) */}
      {wizardOpen && (
        <Suspense fallback={null}>
          <DatasetWizardModal />
        </Suspense>
      )}
      {exportModalOpen && (
        <Suspense fallback={null}>
          <ExportRecipeModal />
        </Suspense>
      )}
    </div>
  );
}