IA inversion 1/4: the Evidence board is home
Browse filesStore default workspaceMode = "multiverse"; the last mode is persisted
per device (quda.workspaceMode) and read synchronously at store
creation, so returning users boot straight into their mode and a
first-ever visit (no stored value) paints the board from the first
frame. That unifies the two landing paths: App.tsx's demo-import
branch that used to force the board landing is removed. Scenario boots
write the store field directly (useApp.setState) so scripted figure
states never overwrite the preference.
Labels renamed, internal ids FROZEN ("compose"/"multiverse" stay in
scenario uiState, localStorage and provenance): WorkspaceToggle now
reads "Evidence board" (home — every configuration and its evidence)
and "Pipeline editor" (define or modify one configuration), board
segment first; the label<->id mapping is pinned in the toggle + store
comments. Store also gains the editorContext / newConfigRequest
bridges the definition-view bar and the board's New-configuration
button consume (wired in the follow-up commits).
- frontend/src/App.tsx +12 -6
- frontend/src/components/WorkspaceToggle.tsx +27 -20
- frontend/src/lib/demoArchive.ts +6 -5
- frontend/src/lib/scenarios.ts +4 -1
- frontend/src/lib/store.ts +72 -7
|
@@ -249,16 +249,22 @@ export default function App() {
|
|
| 249 |
|
| 250 |
// Boot sequencing: (1) first visit seeds the browser's empty run
|
| 251 |
// archive with the bundled demo evidence (real seeded runs; see
|
| 252 |
-
// lib/demoArchive.ts)
|
| 253 |
-
//
|
| 254 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
useEffect(() => {
|
| 256 |
const scenarioKey = new URLSearchParams(window.location.search).get(
|
| 257 |
"scenario",
|
| 258 |
);
|
| 259 |
-
void ensureDemoArchive().then(async (
|
| 260 |
-
if (scenarioKey
|
| 261 |
-
if (imported) useApp.getState().setWorkspaceMode("multiverse");
|
| 262 |
});
|
| 263 |
}, []);
|
| 264 |
|
|
|
|
| 249 |
|
| 250 |
// Boot sequencing: (1) first visit seeds the browser's empty run
|
| 251 |
// archive with the bundled demo evidence (real seeded runs; see
|
| 252 |
+
// lib/demoArchive.ts); (2) a ?scenario=Fn URL (Wave P figure
|
| 253 |
+
// states) takes over the whole UI state afterwards. IA inversion
|
| 254 |
+
// (board = home): the Evidence board is the STORE's default
|
| 255 |
+
// workspace — a first visit has no quda.workspaceMode preference
|
| 256 |
+
// and the mode is read synchronously at store creation, so the
|
| 257 |
+
// board paints from the very first frame and the demo import no
|
| 258 |
+
// longer forces a landing (the fresh-import path and the plain
|
| 259 |
+
// first-visit path are the same path). Returning users boot into
|
| 260 |
+
// their persisted mode the same way. A scenario's mode write lands
|
| 261 |
+
// after this effect resolves, so scenario still wins over both.
|
| 262 |
useEffect(() => {
|
| 263 |
const scenarioKey = new URLSearchParams(window.location.search).get(
|
| 264 |
"scenario",
|
| 265 |
);
|
| 266 |
+
void ensureDemoArchive().then(async () => {
|
| 267 |
+
if (scenarioKey) await activateScenario(scenarioKey);
|
|
|
|
| 268 |
});
|
| 269 |
}, []);
|
| 270 |
|
|
@@ -1,13 +1,20 @@
|
|
| 1 |
-
// Segmented
|
| 2 |
//
|
| 3 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
// MultiverseBoard header) so the user can always flip back — when the
|
| 5 |
// board covers the canvas, the canvas toolbar's copy of this control
|
| 6 |
// is unreachable.
|
| 7 |
-
//
|
| 8 |
-
// "Compose" = the React Flow editor (one pipeline at a time).
|
| 9 |
-
// "Multiverse" = the set of all configurations ever tried, as small
|
| 10 |
-
// multiples — the archive promoted from a side panel to a workspace.
|
| 11 |
|
| 12 |
import { LayoutGrid, Workflow } from "lucide-react";
|
| 13 |
import { useApp } from "../lib/store";
|
|
@@ -30,26 +37,26 @@ export function WorkspaceToggle({ className = "" }: { className?: string }) {
|
|
| 30 |
<button
|
| 31 |
type="button"
|
| 32 |
role="tab"
|
| 33 |
-
aria-selected={mode === "
|
| 34 |
-
title="
|
| 35 |
-
className={seg(mode === "
|
| 36 |
-
onClick={() => setMode("
|
| 37 |
>
|
| 38 |
-
<
|
| 39 |
-
<span className="hidden sm:inline">
|
| 40 |
-
<span className="sr-only sm:hidden">
|
| 41 |
</button>
|
| 42 |
<button
|
| 43 |
type="button"
|
| 44 |
role="tab"
|
| 45 |
-
aria-selected={mode === "
|
| 46 |
-
title="
|
| 47 |
-
className={seg(mode === "
|
| 48 |
-
onClick={() => setMode("
|
| 49 |
>
|
| 50 |
-
<
|
| 51 |
-
<span className="hidden sm:inline">
|
| 52 |
-
<span className="sr-only sm:hidden">
|
| 53 |
</button>
|
| 54 |
</div>
|
| 55 |
);
|
|
|
|
| 1 |
+
// Segmented workspace switch — the IA-inversion control (board = home).
|
| 2 |
//
|
| 3 |
+
// Label ↔ internal-id mapping (ids FROZEN — scenario uiState, the
|
| 4 |
+
// persisted quda.workspaceMode preference and figure provenance key
|
| 5 |
+
// on them; only the user-visible language changed):
|
| 6 |
+
//
|
| 7 |
+
// id "multiverse" → label "Evidence board" — HOME: every
|
| 8 |
+
// configuration ever tried and its evidence.
|
| 9 |
+
// id "compose" → label "Pipeline editor" — the subordinate
|
| 10 |
+
// definition view of ONE configuration.
|
| 11 |
+
//
|
| 12 |
+
// Board segment renders first: home leads, the editor is entered.
|
| 13 |
+
//
|
| 14 |
+
// Lives in BOTH workspace headers (FlowCanvas toolbar and the
|
| 15 |
// MultiverseBoard header) so the user can always flip back — when the
|
| 16 |
// board covers the canvas, the canvas toolbar's copy of this control
|
| 17 |
// is unreachable.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
import { LayoutGrid, Workflow } from "lucide-react";
|
| 20 |
import { useApp } from "../lib/store";
|
|
|
|
| 37 |
<button
|
| 38 |
type="button"
|
| 39 |
role="tab"
|
| 40 |
+
aria-selected={mode === "multiverse"}
|
| 41 |
+
title="Evidence board: home — every configuration and its evidence"
|
| 42 |
+
className={seg(mode === "multiverse")}
|
| 43 |
+
onClick={() => setMode("multiverse")}
|
| 44 |
>
|
| 45 |
+
<LayoutGrid className="w-3 h-3" aria-hidden="true" />
|
| 46 |
+
<span className="hidden sm:inline">Evidence board</span>
|
| 47 |
+
<span className="sr-only sm:hidden">Evidence board</span>
|
| 48 |
</button>
|
| 49 |
<button
|
| 50 |
type="button"
|
| 51 |
role="tab"
|
| 52 |
+
aria-selected={mode === "compose"}
|
| 53 |
+
title="Pipeline editor: define or modify one configuration"
|
| 54 |
+
className={seg(mode === "compose")}
|
| 55 |
+
onClick={() => setMode("compose")}
|
| 56 |
>
|
| 57 |
+
<Workflow className="w-3 h-3" aria-hidden="true" />
|
| 58 |
+
<span className="hidden sm:inline">Pipeline editor</span>
|
| 59 |
+
<span className="sr-only sm:hidden">Pipeline editor</span>
|
| 60 |
</button>
|
| 61 |
</div>
|
| 62 |
);
|
|
@@ -5,9 +5,9 @@
|
|
| 5 |
// browser's IndexedDB run archive — which is empty on a first visit,
|
| 6 |
// so a new visitor would see none of it until they had run several
|
| 7 |
// pipelines themselves. Instead, the first visit imports a small
|
| 8 |
-
// curated archive of REAL runs recorded against the live backend
|
| 9 |
-
//
|
| 10 |
-
// within the first seconds.
|
| 11 |
//
|
| 12 |
// What the data is (and is not): every record is a genuine
|
| 13 |
// RunResponse produced by the deployed API — real noisy-simulator
|
|
@@ -76,8 +76,9 @@ function markDecided(): void {
|
|
| 76 |
/**
|
| 77 |
* First-visit hook: if this browser has never decided about demo data
|
| 78 |
* AND its run archive is empty, import the bundled archive.
|
| 79 |
-
* Returns true iff records were imported this call
|
| 80 |
-
*
|
|
|
|
| 81 |
*/
|
| 82 |
export async function ensureDemoArchive(
|
| 83 |
opts: {
|
|
|
|
| 5 |
// browser's IndexedDB run archive — which is empty on a first visit,
|
| 6 |
// so a new visitor would see none of it until they had run several
|
| 7 |
// pipelines themselves. Instead, the first visit imports a small
|
| 8 |
+
// curated archive of REAL runs recorded against the live backend, so
|
| 9 |
+
// the Evidence board — home since the IA inversion, and the store's
|
| 10 |
+
// default workspace — paints populated within the first seconds.
|
| 11 |
//
|
| 12 |
// What the data is (and is not): every record is a genuine
|
| 13 |
// RunResponse produced by the deployed API — real noisy-simulator
|
|
|
|
| 76 |
/**
|
| 77 |
* First-visit hook: if this browser has never decided about demo data
|
| 78 |
* AND its run archive is empty, import the bundled archive.
|
| 79 |
+
* Returns true iff records were imported this call. (The IA inversion
|
| 80 |
+
* made the board the default workspace, so the import no longer needs
|
| 81 |
+
* to force a landing — the return value is informational.)
|
| 82 |
*/
|
| 83 |
export async function ensureDemoArchive(
|
| 84 |
opts: {
|
|
@@ -454,7 +454,10 @@ export async function activateScenario(rawKey: string): Promise<boolean> {
|
|
| 454 |
if (sc.needsArchive) await ensureDemoArchive({ force: true });
|
| 455 |
if (sc.openGateDiff) app.setGateDiffDefaultOpen(true);
|
| 456 |
if (sc.openTheater) app.setTheaterOpen(true);
|
| 457 |
-
|
|
|
|
|
|
|
|
|
|
| 458 |
|
| 459 |
if (sc.graph) {
|
| 460 |
app.requestRestore({
|
|
|
|
| 454 |
if (sc.needsArchive) await ensureDemoArchive({ force: true });
|
| 455 |
if (sc.openGateDiff) app.setGateDiffDefaultOpen(true);
|
| 456 |
if (sc.openTheater) app.setTheaterOpen(true);
|
| 457 |
+
// Scripted figure state, not a user preference: write the mode
|
| 458 |
+
// directly so a scenario boot never overwrites the persisted
|
| 459 |
+
// quda.workspaceMode (setWorkspaceMode would persist it).
|
| 460 |
+
useApp.setState({ workspaceMode: sc.workspaceMode });
|
| 461 |
|
| 462 |
if (sc.graph) {
|
| 463 |
app.requestRestore({
|
|
@@ -14,6 +14,23 @@ import type { SharePayload } from "./share";
|
|
| 14 |
|
| 15 |
const LS_USE_LIVE_IBM = "quda.useLiveIbm";
|
| 16 |
const LS_THEATER_AUTO_OPEN = "quda.theaterAutoOpen";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
/** Evidence-theater auto-open preference (default ON). Read lazily on
|
| 19 |
* every progress frame instead of cached in the store so a toggle in
|
|
@@ -54,15 +71,48 @@ function loadUseLiveIbm(): boolean {
|
|
| 54 |
|
| 55 |
interface AppState {
|
| 56 |
/**
|
| 57 |
-
* Which workspace fills the center column.
|
| 58 |
-
*
|
| 59 |
-
*
|
| 60 |
-
*
|
| 61 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
*/
|
| 63 |
workspaceMode: "compose" | "multiverse";
|
| 64 |
setWorkspaceMode: (m: "compose" | "multiverse") => void;
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
circuit: CircuitInfo | null;
|
| 67 |
setCircuit: (c: CircuitInfo | null) => void;
|
| 68 |
|
|
@@ -307,8 +357,23 @@ interface AppState {
|
|
| 307 |
}
|
| 308 |
|
| 309 |
export const useApp = create<AppState>((set) => ({
|
| 310 |
-
workspaceMode:
|
| 311 |
-
setWorkspaceMode: (m) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
circuit: null,
|
| 313 |
setCircuit: (c) => set({ circuit: c }),
|
| 314 |
sampleKey: null,
|
|
|
|
| 14 |
|
| 15 |
const LS_USE_LIVE_IBM = "quda.useLiveIbm";
|
| 16 |
const LS_THEATER_AUTO_OPEN = "quda.theaterAutoOpen";
|
| 17 |
+
const LS_WORKSPACE_MODE = "quda.workspaceMode";
|
| 18 |
+
|
| 19 |
+
/** IA inversion (board = home): the persisted workspace-mode
|
| 20 |
+
* preference. A first-ever visit has no stored value and falls to
|
| 21 |
+
* the "multiverse" default — the Evidence board, which the
|
| 22 |
+
* demo-archive import populates — so first-visit landing and the
|
| 23 |
+
* demo-import landing are one path. Returning users keep whatever
|
| 24 |
+
* mode they last chose (setWorkspaceMode persists it). */
|
| 25 |
+
function loadWorkspaceMode(): "compose" | "multiverse" {
|
| 26 |
+
if (typeof window === "undefined") return "multiverse";
|
| 27 |
+
try {
|
| 28 |
+
const v = window.localStorage.getItem(LS_WORKSPACE_MODE);
|
| 29 |
+
return v === "compose" || v === "multiverse" ? v : "multiverse";
|
| 30 |
+
} catch {
|
| 31 |
+
return "multiverse";
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
|
| 35 |
/** Evidence-theater auto-open preference (default ON). Read lazily on
|
| 36 |
* every progress frame instead of cached in the store so a toggle in
|
|
|
|
| 71 |
|
| 72 |
interface AppState {
|
| 73 |
/**
|
| 74 |
+
* Which workspace fills the center column. IA inversion (board =
|
| 75 |
+
* home) — label ↔ id mapping, ids FROZEN:
|
| 76 |
+
*
|
| 77 |
+
* "multiverse" = MultiverseBoard, user-visible "Evidence board":
|
| 78 |
+
* HOME — every configuration and its evidence.
|
| 79 |
+
* "compose" = the React Flow canvas, user-visible "Pipeline
|
| 80 |
+
* editor": the definition view of ONE configuration.
|
| 81 |
+
*
|
| 82 |
+
* Scenario uiState values, the localStorage preference and figure
|
| 83 |
+
* provenance key on the ids, so the rename touched labels only.
|
| 84 |
+
* Persisted (quda.workspaceMode): returning users boot into their
|
| 85 |
+
* last mode; a first visit has no stored value and lands on the
|
| 86 |
+
* board default. setWorkspaceMode persists; scenario boots write
|
| 87 |
+
* the field directly (useApp.setState) so scripted figure states
|
| 88 |
+
* never overwrite the preference.
|
| 89 |
*/
|
| 90 |
workspaceMode: "compose" | "multiverse";
|
| 91 |
setWorkspaceMode: (m: "compose" | "multiverse") => void;
|
| 92 |
|
| 93 |
+
/**
|
| 94 |
+
* Editor framing (marker: config-context). Non-null when the
|
| 95 |
+
* Pipeline editor was entered as the definition view of a
|
| 96 |
+
* configuration — from an Evidence-board card ("card", carrying
|
| 97 |
+
* the source card's identity) or via the board's "New
|
| 98 |
+
* configuration" button ("new"). null = editor entered some other
|
| 99 |
+
* way (plain toggle, scenario boot, first paint): the context bar
|
| 100 |
+
* stays hidden, which keeps scripted figure states pixel-identical.
|
| 101 |
+
*/
|
| 102 |
+
editorContext:
|
| 103 |
+
| { source: "card"; hash: string; circuitTag: string; runCount: number }
|
| 104 |
+
| { source: "new" }
|
| 105 |
+
| null;
|
| 106 |
+
setEditorContext: (c: AppState["editorContext"]) => void;
|
| 107 |
+
|
| 108 |
+
/** Counter bridge for the board's "New configuration" button.
|
| 109 |
+
* FlowCanvas consumes a bump by clearing the canvas plus the
|
| 110 |
+
* pinned seed / fork parentage, so the editor opens on a truly
|
| 111 |
+
* blank definition. Counter (not boolean) so consecutive clicks
|
| 112 |
+
* re-fire. */
|
| 113 |
+
newConfigRequest: number;
|
| 114 |
+
requestNewConfig: () => void;
|
| 115 |
+
|
| 116 |
circuit: CircuitInfo | null;
|
| 117 |
setCircuit: (c: CircuitInfo | null) => void;
|
| 118 |
|
|
|
|
| 357 |
}
|
| 358 |
|
| 359 |
export const useApp = create<AppState>((set) => ({
|
| 360 |
+
workspaceMode: loadWorkspaceMode(),
|
| 361 |
+
setWorkspaceMode: (m) => {
|
| 362 |
+
try {
|
| 363 |
+
window.localStorage.setItem(LS_WORKSPACE_MODE, m);
|
| 364 |
+
} catch {
|
| 365 |
+
/* private mode — the board default simply applies next visit */
|
| 366 |
+
}
|
| 367 |
+
set({ workspaceMode: m });
|
| 368 |
+
},
|
| 369 |
+
editorContext: null,
|
| 370 |
+
setEditorContext: (c) => set({ editorContext: c }),
|
| 371 |
+
newConfigRequest: 0,
|
| 372 |
+
requestNewConfig: () =>
|
| 373 |
+
set((s) => ({
|
| 374 |
+
newConfigRequest: s.newConfigRequest + 1,
|
| 375 |
+
editorContext: { source: "new" },
|
| 376 |
+
})),
|
| 377 |
circuit: null,
|
| 378 |
setCircuit: (c) => set({ circuit: c }),
|
| 379 |
sampleKey: null,
|