Board/theater/export: overlay stacking, figure honesty, export text metrics
Browse files- boot "Connecting" overlay at z-50 (painted under board/theater/header)
- band run-start effect skips the band Evidence overlay when the theater
will auto-open (no double overlay)
- DemoArchiveBanner + board hint strips carry data-export-strip (F2 figures
drop guidance chrome); scenario force-reimport after "Clear demo data"
says so in the banner, and the Clear tooltip drops its "never" claim
- shared svgPaper.estimateTextW(chars, fontSize, bumped) budgets the x1.25
PAPER_FONT_BUMP in theater layout math: stop-label flip/intrusion,
panel title-dx, and the cost-anchor line (splits into two tspans when
the bumped width would clip; svg gets bottom pad for the second line)
- DifferenceFunnel viewBox width is two-tier: pane tier derives from the
container (labels stay >=9px effective; legend wraps to two lines),
export tier keeps the documented 760px geometry via a hidden twin
- F6/F8 pair picker excludes scenario-tagged records (F7's guard verified
already in place) and prefers demo-flagged records so documented figure
numbers reproduce on used browsers
- qshot preset ships with its output sink (lints clean)
- frontend/src/App.tsx +12 -3
- frontend/src/components/DemoArchiveBanner.tsx +11 -5
- frontend/src/components/DifferenceFunnel.tsx +91 -15
- frontend/src/components/EvidenceTheater.tsx +59 -31
- frontend/src/components/MultiverseBoard.tsx +2 -0
- frontend/src/lib/demoArchive.ts +15 -1
- frontend/src/lib/presets.ts +8 -1
- frontend/src/lib/scenarios.ts +11 -1
- frontend/src/lib/svgPaper.ts +16 -0
|
@@ -4,7 +4,7 @@ import "@xyflow/react/dist/style.css";
|
|
| 4 |
import { PanelLeft, PanelRight } from "lucide-react";
|
| 5 |
import { api } from "./lib/api";
|
| 6 |
import { getUserId } from "./lib/userId";
|
| 7 |
-
import { useApp } from "./lib/store";
|
| 8 |
import { ensureDemoArchive } from "./lib/demoArchive";
|
| 9 |
import { useIsDesktop, useMediaQuery } from "./lib/useMediaQuery";
|
| 10 |
import { TopBar } from "./components/TopBar";
|
|
@@ -216,7 +216,12 @@ export default function App() {
|
|
| 216 |
} else if (band) {
|
| 217 |
// Band: surface progress as the overlay — the in-flow pane
|
| 218 |
// must not take layout width here (RESPONSIVE CONTRACT).
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
} else if (rightCollapsed) {
|
| 221 |
setRightCollapsed(false);
|
| 222 |
}
|
|
@@ -515,7 +520,11 @@ export default function App() {
|
|
| 515 |
)}
|
| 516 |
<WelcomeTour open={tourOpen} onClose={() => setTourOpen(false)} />
|
| 517 |
{!ready && (
|
| 518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
<div className="text-mute text-sm">Connecting to compute backend…</div>
|
| 520 |
</div>
|
| 521 |
)}
|
|
|
|
| 4 |
import { PanelLeft, PanelRight } from "lucide-react";
|
| 5 |
import { api } from "./lib/api";
|
| 6 |
import { getUserId } from "./lib/userId";
|
| 7 |
+
import { theaterAutoOpenEnabled, useApp } from "./lib/store";
|
| 8 |
import { ensureDemoArchive } from "./lib/demoArchive";
|
| 9 |
import { useIsDesktop, useMediaQuery } from "./lib/useMediaQuery";
|
| 10 |
import { TopBar } from "./components/TopBar";
|
|
|
|
| 216 |
} else if (band) {
|
| 217 |
// Band: surface progress as the overlay — the in-flow pane
|
| 218 |
// must not take layout width here (RESPONSIVE CONTRACT).
|
| 219 |
+
// UNLESS the Evidence theater will auto-open on this run's
|
| 220 |
+
// first streaming frame: stacking both overlays buried the
|
| 221 |
+
// board under two layers (audit S2). With theater auto-open
|
| 222 |
+
// disabled, this overlay stays the band's only progress
|
| 223 |
+
// surface and still opens.
|
| 224 |
+
if (!theaterAutoOpenEnabled()) setBandEvidenceOpen(true);
|
| 225 |
} else if (rightCollapsed) {
|
| 226 |
setRightCollapsed(false);
|
| 227 |
}
|
|
|
|
| 520 |
)}
|
| 521 |
<WelcomeTour open={tourOpen} onClose={() => setTourOpen(false)} />
|
| 522 |
{!ready && (
|
| 523 |
+
// z-50: the boot overlay must paint over EVERYTHING (board
|
| 524 |
+
// z-20, theater z-30, header z-40) — without it the connecting
|
| 525 |
+
// state showed through whichever surface stacked higher
|
| 526 |
+
// (audit S2).
|
| 527 |
+
<div className="absolute inset-0 z-50 bg-canvas/80 flex items-center justify-center backdrop-blur">
|
| 528 |
<div className="text-mute text-sm">Connecting to compute backend…</div>
|
| 529 |
</div>
|
| 530 |
)}
|
|
@@ -8,16 +8,22 @@
|
|
| 8 |
|
| 9 |
import { useState } from "react";
|
| 10 |
import { FlaskConical } from "lucide-react";
|
| 11 |
-
import { clearDemoRuns } from "../lib/demoArchive";
|
| 12 |
|
| 13 |
export function DemoArchiveBanner() {
|
| 14 |
const [busy, setBusy] = useState(false);
|
| 15 |
return (
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
<FlaskConical className="w-3 h-3 text-accent shrink-0" />
|
| 18 |
<span className="min-w-0">
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
</span>
|
| 22 |
<button
|
| 23 |
type="button"
|
|
@@ -27,7 +33,7 @@ export function DemoArchiveBanner() {
|
|
| 27 |
setBusy(true);
|
| 28 |
void clearDemoRuns();
|
| 29 |
}}
|
| 30 |
-
title="Delete every demo record from this browser's archive. Your own runs are untouched, and the demo
|
| 31 |
>
|
| 32 |
{busy ? "Clearing…" : "Clear demo data"}
|
| 33 |
</button>
|
|
|
|
| 8 |
|
| 9 |
import { useState } from "react";
|
| 10 |
import { FlaskConical } from "lucide-react";
|
| 11 |
+
import { clearDemoRuns, demoReimportedForScenario } from "../lib/demoArchive";
|
| 12 |
|
| 13 |
export function DemoArchiveBanner() {
|
| 14 |
const [busy, setBusy] = useState(false);
|
| 15 |
return (
|
| 16 |
+
// data-export-strip: guidance chrome, not evidence — figure
|
| 17 |
+
// exports (F2 board/history figures) drop this strip (audit S2).
|
| 18 |
+
<div
|
| 19 |
+
data-export-strip
|
| 20 |
+
className="shrink-0 border-b border-accent/25 bg-accent/5 px-3 py-1.5 flex items-center gap-2 text-[11px] text-mute"
|
| 21 |
+
>
|
| 22 |
<FlaskConical className="w-3 h-3 text-accent shrink-0" />
|
| 23 |
<span className="min-w-0">
|
| 24 |
+
{demoReimportedForScenario()
|
| 25 |
+
? "Demo archive re-imported for this figure scenario — Clear demo data again to remove it."
|
| 26 |
+
: "Showing a bundled demo archive of real seeded runs — run any pipeline to start your own evidence."}
|
| 27 |
</span>
|
| 28 |
<button
|
| 29 |
type="button"
|
|
|
|
| 33 |
setBusy(true);
|
| 34 |
void clearDemoRuns();
|
| 35 |
}}
|
| 36 |
+
title="Delete every demo record from this browser's archive. Your own runs are untouched, and the demo won't auto-reload — though opening a documented ?scenario= figure link re-imports it for that figure."
|
| 37 |
>
|
| 38 |
{busy ? "Clearing…" : "Clear demo data"}
|
| 39 |
</button>
|
|
@@ -76,6 +76,7 @@ import {
|
|
| 76 |
} from "../lib/stats";
|
| 77 |
import { hashHue, hueCss } from "../lib/hues";
|
| 78 |
import { GLOSSARY } from "../lib/glossary";
|
|
|
|
| 79 |
import { FigureExportButton } from "./FigureExportButton";
|
| 80 |
import { TipIcon } from "./TipIcon";
|
| 81 |
|
|
@@ -264,17 +265,24 @@ function ppTickStep(span: number): number {
|
|
| 264 |
// the chart
|
| 265 |
// ---------------------------------------------------------------------------
|
| 266 |
|
| 267 |
-
|
|
|
|
|
|
|
|
|
|
| 268 |
const H = 312;
|
| 269 |
const M = { l: 58, r: 168, t: 62, b: 56 };
|
| 270 |
|
| 271 |
function Chart({
|
| 272 |
data,
|
|
|
|
| 273 |
}: {
|
| 274 |
data: Extract<NonNullable<DifferenceData>, { status: "ready" }>;
|
|
|
|
|
|
|
|
|
|
| 275 |
}) {
|
| 276 |
const { steps, verdict, a, b } = data;
|
| 277 |
-
const plotW =
|
| 278 |
const plotH = H - M.t - M.b;
|
| 279 |
const axisY = M.t + plotH;
|
| 280 |
const final = verdict.final;
|
|
@@ -321,7 +329,7 @@ function Chart({
|
|
| 321 |
// would run into the right readout column (same flip rule as the
|
| 322 |
// theater's stop annotation).
|
| 323 |
const EST_TEXT_W = 340;
|
| 324 |
-
const estFlip = est != null && x(est.shots) + 8 + EST_TEXT_W >
|
| 325 |
const LOST_TEXT_W = 350;
|
| 326 |
const lostFlip = lost != null && x(lost.shots) - 8 - LOST_TEXT_W < M.l;
|
| 327 |
|
|
@@ -361,7 +369,7 @@ function Chart({
|
|
| 361 |
|
| 362 |
return (
|
| 363 |
<svg
|
| 364 |
-
viewBox={`0 0 ${
|
| 365 |
width="100%"
|
| 366 |
style={{ maxWidth: 900, display: "block" }}
|
| 367 |
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -374,13 +382,38 @@ function Chart({
|
|
| 374 |
Δ(B−A) fidelity, all archived replicates
|
| 375 |
<title>{GLOSSARY.differenceInterval}</title>
|
| 376 |
</text>
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
{/* Δ gridlines */}
|
| 386 |
{gridVals.map((v) => (
|
|
@@ -525,10 +558,10 @@ function Chart({
|
|
| 525 |
)}
|
| 526 |
|
| 527 |
{/* final readout, right margin */}
|
| 528 |
-
<text x={
|
| 529 |
-
<tspan x={
|
| 530 |
{readout.lines.map((l, i) => (
|
| 531 |
-
<tspan key={i} x={
|
| 532 |
{l}
|
| 533 |
</tspan>
|
| 534 |
))}
|
|
@@ -563,6 +596,12 @@ function Chart({
|
|
| 563 |
export function DifferenceFunnel({ data }: { data: DifferenceData }) {
|
| 564 |
const setDifferenceRunIds = useApp((s) => s.setDifferenceRunIds);
|
| 565 |
const svgHost = useRef<HTMLDivElement | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
const ready = data != null && data.status === "ready" ? data : null;
|
| 567 |
const runIdsKey = ready ? ready.runIds.join(",") : null;
|
| 568 |
|
|
@@ -579,6 +618,19 @@ export function DifferenceFunnel({ data }: { data: DifferenceData }) {
|
|
| 579 |
[data],
|
| 580 |
);
|
| 581 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 582 |
if (data == null || data.status === "same-config") return null;
|
| 583 |
|
| 584 |
if (data.status === "different-circuit") {
|
|
@@ -622,6 +674,10 @@ export function DifferenceFunnel({ data }: { data: DifferenceData }) {
|
|
| 622 |
}
|
| 623 |
|
| 624 |
if (!ready) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 625 |
return (
|
| 626 |
<div className="space-y-1">
|
| 627 |
<div className="flex items-center gap-1.5">
|
|
@@ -632,7 +688,7 @@ export function DifferenceFunnel({ data }: { data: DifferenceData }) {
|
|
| 632 |
<span className="ml-auto">
|
| 633 |
<FigureExportButton
|
| 634 |
getTarget={() =>
|
| 635 |
-
|
| 636 |
}
|
| 637 |
name="difference-funnel"
|
| 638 |
view="evidence-compare"
|
|
@@ -640,6 +696,26 @@ export function DifferenceFunnel({ data }: { data: DifferenceData }) {
|
|
| 640 |
</span>
|
| 641 |
</div>
|
| 642 |
<div ref={svgHost}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
<Chart data={ready} />
|
| 644 |
</div>
|
| 645 |
{/* legend line (HTML so it stays legible at pane scale) */}
|
|
|
|
| 76 |
} from "../lib/stats";
|
| 77 |
import { hashHue, hueCss } from "../lib/hues";
|
| 78 |
import { GLOSSARY } from "../lib/glossary";
|
| 79 |
+
import { estimateTextW } from "../lib/svgPaper";
|
| 80 |
import { FigureExportButton } from "./FigureExportButton";
|
| 81 |
import { TipIcon } from "./TipIcon";
|
| 82 |
|
|
|
|
| 265 |
// the chart
|
| 266 |
// ---------------------------------------------------------------------------
|
| 267 |
|
| 268 |
+
/** Export-path viewBox width — the documented F8 figure geometry.
|
| 269 |
+
* The pane render passes a container-derived width instead (two-tier,
|
| 270 |
+
* audit S2) so labels keep ≥9px effective size in narrow panes. */
|
| 271 |
+
const EXPORT_W = 760;
|
| 272 |
const H = 312;
|
| 273 |
const M = { l: 58, r: 168, t: 62, b: 56 };
|
| 274 |
|
| 275 |
function Chart({
|
| 276 |
data,
|
| 277 |
+
w = EXPORT_W,
|
| 278 |
}: {
|
| 279 |
data: Extract<NonNullable<DifferenceData>, { status: "ready" }>;
|
| 280 |
+
/** viewBox width. Pane renders derive it from the container; the
|
| 281 |
+
* hidden export twin keeps the documented EXPORT_W geometry. */
|
| 282 |
+
w?: number;
|
| 283 |
}) {
|
| 284 |
const { steps, verdict, a, b } = data;
|
| 285 |
+
const plotW = w - M.l - M.r;
|
| 286 |
const plotH = H - M.t - M.b;
|
| 287 |
const axisY = M.t + plotH;
|
| 288 |
const final = verdict.final;
|
|
|
|
| 329 |
// would run into the right readout column (same flip rule as the
|
| 330 |
// theater's stop annotation).
|
| 331 |
const EST_TEXT_W = 340;
|
| 332 |
+
const estFlip = est != null && x(est.shots) + 8 + EST_TEXT_W > w - M.r;
|
| 333 |
const LOST_TEXT_W = 350;
|
| 334 |
const lostFlip = lost != null && x(lost.shots) - 8 - LOST_TEXT_W < M.l;
|
| 335 |
|
|
|
|
| 369 |
|
| 370 |
return (
|
| 371 |
<svg
|
| 372 |
+
viewBox={`0 0 ${w} ${H}`}
|
| 373 |
width="100%"
|
| 374 |
style={{ maxWidth: 900, display: "block" }}
|
| 375 |
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
| 382 |
Δ(B−A) fidelity, all archived replicates
|
| 383 |
<title>{GLOSSARY.differenceInterval}</title>
|
| 384 |
</text>
|
| 385 |
+
{(() => {
|
| 386 |
+
const la = legendSide("A", a);
|
| 387 |
+
const lb = legendSide("B", b);
|
| 388 |
+
// One line only when both sides fit the current width (the
|
| 389 |
+
// estimate budgets the export font bump); otherwise stack —
|
| 390 |
+
// at pane-tier widths a single line clipped B entirely.
|
| 391 |
+
const oneLine =
|
| 392 |
+
estimateTextW(la.length + lb.length + 6, 10.5) + 24 <=
|
| 393 |
+
w - M.l - 8;
|
| 394 |
+
return oneLine ? (
|
| 395 |
+
<text x={M.l} y={36} fontSize={10.5} fontFamily="ui-monospace, monospace">
|
| 396 |
+
<tspan fill={hueCss(hashHue(a.configHash), 0.95)}>●</tspan>
|
| 397 |
+
<tspan dx={4} fill="rgb(var(--color-mute))">{la}</tspan>
|
| 398 |
+
<tspan dx={16} fill={hueCss(hashHue(b.configHash), 0.95)}>●</tspan>
|
| 399 |
+
<tspan dx={4} fill="rgb(var(--color-mute))">{lb}</tspan>
|
| 400 |
+
<title>{GLOSSARY.configuration}</title>
|
| 401 |
+
</text>
|
| 402 |
+
) : (
|
| 403 |
+
<>
|
| 404 |
+
<text x={M.l} y={34} fontSize={10.5} fontFamily="ui-monospace, monospace">
|
| 405 |
+
<tspan fill={hueCss(hashHue(a.configHash), 0.95)}>●</tspan>
|
| 406 |
+
<tspan dx={4} fill="rgb(var(--color-mute))">{la}</tspan>
|
| 407 |
+
<title>{GLOSSARY.configuration}</title>
|
| 408 |
+
</text>
|
| 409 |
+
<text x={M.l} y={47} fontSize={10.5} fontFamily="ui-monospace, monospace">
|
| 410 |
+
<tspan fill={hueCss(hashHue(b.configHash), 0.95)}>●</tspan>
|
| 411 |
+
<tspan dx={4} fill="rgb(var(--color-mute))">{lb}</tspan>
|
| 412 |
+
<title>{GLOSSARY.configuration}</title>
|
| 413 |
+
</text>
|
| 414 |
+
</>
|
| 415 |
+
);
|
| 416 |
+
})()}
|
| 417 |
|
| 418 |
{/* Δ gridlines */}
|
| 419 |
{gridVals.map((v) => (
|
|
|
|
| 558 |
)}
|
| 559 |
|
| 560 |
{/* final readout, right margin */}
|
| 561 |
+
<text x={w - M.r + 10} y={readoutY} fontSize={11} fontWeight={600} fill={readout.headFill}>
|
| 562 |
+
<tspan x={w - M.r + 10}>{readout.head}</tspan>
|
| 563 |
{readout.lines.map((l, i) => (
|
| 564 |
+
<tspan key={i} x={w - M.r + 10} dy={13} fontWeight={400} fill="rgb(var(--color-mute))">
|
| 565 |
{l}
|
| 566 |
</tspan>
|
| 567 |
))}
|
|
|
|
| 596 |
export function DifferenceFunnel({ data }: { data: DifferenceData }) {
|
| 597 |
const setDifferenceRunIds = useApp((s) => s.setDifferenceRunIds);
|
| 598 |
const svgHost = useRef<HTMLDivElement | null>(null);
|
| 599 |
+
const exportHost = useRef<HTMLDivElement | null>(null);
|
| 600 |
+
// Pane tier of the two-tier viewBox width (audit S2): track the host
|
| 601 |
+
// width so the visible chart's viewBox ≈ container width and its
|
| 602 |
+
// 9.5-12.5px labels render at (near-)native size instead of being
|
| 603 |
+
// scaled to ~5px in a narrow Evidence pane.
|
| 604 |
+
const [hostW, setHostW] = useState<number | null>(null);
|
| 605 |
const ready = data != null && data.status === "ready" ? data : null;
|
| 606 |
const runIdsKey = ready ? ready.runIds.join(",") : null;
|
| 607 |
|
|
|
|
| 618 |
[data],
|
| 619 |
);
|
| 620 |
|
| 621 |
+
const hasChart = ready != null;
|
| 622 |
+
useEffect(() => {
|
| 623 |
+
const el = svgHost.current;
|
| 624 |
+
if (!hasChart || el == null || typeof ResizeObserver === "undefined")
|
| 625 |
+
return;
|
| 626 |
+
const ro = new ResizeObserver((entries) => {
|
| 627 |
+
const cw = entries[0]?.contentRect.width;
|
| 628 |
+
if (cw) setHostW(Math.round(cw));
|
| 629 |
+
});
|
| 630 |
+
ro.observe(el);
|
| 631 |
+
return () => ro.disconnect();
|
| 632 |
+
}, [hasChart]);
|
| 633 |
+
|
| 634 |
if (data == null || data.status === "same-config") return null;
|
| 635 |
|
| 636 |
if (data.status === "different-circuit") {
|
|
|
|
| 674 |
}
|
| 675 |
|
| 676 |
if (!ready) return null;
|
| 677 |
+
// Pane tier: viewBox ≈ container (floored at 420 so the readout
|
| 678 |
+
// column can't crush the plot); export tier stays EXPORT_W.
|
| 679 |
+
const chartW =
|
| 680 |
+
hostW == null ? EXPORT_W : Math.min(EXPORT_W, Math.max(420, hostW));
|
| 681 |
return (
|
| 682 |
<div className="space-y-1">
|
| 683 |
<div className="flex items-center gap-1.5">
|
|
|
|
| 688 |
<span className="ml-auto">
|
| 689 |
<FigureExportButton
|
| 690 |
getTarget={() =>
|
| 691 |
+
exportHost.current?.querySelector("svg") as SVGSVGElement | null
|
| 692 |
}
|
| 693 |
name="difference-funnel"
|
| 694 |
view="evidence-compare"
|
|
|
|
| 696 |
</span>
|
| 697 |
</div>
|
| 698 |
<div ref={svgHost}>
|
| 699 |
+
<Chart data={ready} w={chartW} />
|
| 700 |
+
</div>
|
| 701 |
+
{/* Hidden export twin at the documented EXPORT_W geometry (audit
|
| 702 |
+
S2: pane scaling must not change exported figures). Offscreen
|
| 703 |
+
but rendered, so computed styles resolve for the true-SVG
|
| 704 |
+
serializer; data-export-strip keeps it out of whole-pane
|
| 705 |
+
exports (the funnel's own export button above targets it
|
| 706 |
+
directly). */}
|
| 707 |
+
<div
|
| 708 |
+
ref={exportHost}
|
| 709 |
+
data-export-strip
|
| 710 |
+
aria-hidden
|
| 711 |
+
style={{
|
| 712 |
+
position: "absolute",
|
| 713 |
+
left: -99999,
|
| 714 |
+
top: 0,
|
| 715 |
+
width: EXPORT_W,
|
| 716 |
+
pointerEvents: "none",
|
| 717 |
+
}}
|
| 718 |
+
>
|
| 719 |
<Chart data={ready} />
|
| 720 |
</div>
|
| 721 |
{/* legend line (HTML so it stays legible at pane scale) */}
|
|
@@ -99,6 +99,7 @@ import {
|
|
| 99 |
} from "../lib/stats";
|
| 100 |
import { hashHue, hueCss } from "../lib/hues";
|
| 101 |
import { costAnchor } from "../lib/costModel";
|
|
|
|
| 102 |
import { GLOSSARY } from "../lib/glossary";
|
| 103 |
import { FigureExportButton } from "./FigureExportButton";
|
| 104 |
import { TipIcon } from "./TipIcon";
|
|
@@ -408,19 +409,23 @@ function Panel({
|
|
| 408 |
: 0;
|
| 409 |
|
| 410 |
// Which side of the stop line the "⏹ stopped here" label sits on.
|
| 411 |
-
//
|
| 412 |
-
//
|
| 413 |
-
//
|
| 414 |
-
//
|
| 415 |
-
//
|
| 416 |
-
//
|
|
|
|
|
|
|
| 417 |
// → always flipped). A non-flipped label can still legitimately
|
| 418 |
-
// extend past the plot edge into the right-margin readout column
|
| 419 |
-
//
|
| 420 |
-
//
|
| 421 |
-
//
|
| 422 |
-
|
| 423 |
-
|
|
|
|
|
|
|
| 424 |
const stopLabelFlip = stopX != null && stopX + 8 + stopTextW > W - 4;
|
| 425 |
|
| 426 |
// Right-margin readout placement — the panel's LAYOUT CONTRACT:
|
|
@@ -501,7 +506,10 @@ function Panel({
|
|
| 501 |
{s.label}
|
| 502 |
<title>{GLOSSARY.fidelity}</title>
|
| 503 |
</text>
|
| 504 |
-
|
|
|
|
|
|
|
|
|
|
| 505 |
{titleBits}
|
| 506 |
</text>
|
| 507 |
|
|
@@ -554,7 +562,7 @@ function Panel({
|
|
| 554 |
<rect x={stopX} y={M.t} width={M.l + plotW - stopX} height={plotH} fill="rgb(var(--color-mute))" opacity={0.05} />
|
| 555 |
<line x1={stopX} x2={stopX} y1={M.t - 4} y2={axisY} stroke="rgb(var(--color-warn))" strokeWidth={1.5} strokeDasharray="5 3" />
|
| 556 |
<text x={stopLabelFlip ? stopX - 8 : stopX + 8} textAnchor={stopLabelFlip ? "end" : "start"} y={M.t + 12} fontSize={11} fontWeight={600} fill="rgb(var(--color-warn))">
|
| 557 |
-
|
| 558 |
<title>{GLOSSARY.precisionTarget}</title>
|
| 559 |
</text>
|
| 560 |
<text x={stopLabelFlip ? stopX - 8 : stopX + 8} textAnchor={stopLabelFlip ? "end" : "start"} y={M.t + 26} fontSize={10} fill="rgb(var(--color-mute))">
|
|
@@ -692,21 +700,37 @@ function Panel({
|
|
| 692 |
— hardware timing differs. Rendered only when a duration is
|
| 693 |
actually known, so archived traces without timing show no
|
| 694 |
made-up price. */}
|
| 695 |
-
{anchor != null &&
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 710 |
</g>
|
| 711 |
);
|
| 712 |
}
|
|
@@ -920,7 +944,7 @@ function OverlayPanel({
|
|
| 920 |
{a.label}
|
| 921 |
<title>{GLOSSARY.fidelity}</title>
|
| 922 |
</text>
|
| 923 |
-
<text x={M.l} y={22} dx={
|
| 924 |
overlay — A {fmtPct(lastA.point, 2)} ±{fmtPp((lastA.hi - lastA.lo) / 2, 2)} · B {fmtPct(lastB.point, 2)} ±{fmtPp((lastB.hi - lastB.lo) / 2, 2)}
|
| 925 |
</text>
|
| 926 |
|
|
@@ -1183,7 +1207,11 @@ export function EvidenceTheater() {
|
|
| 1183 |
const panelH = overlayActive ? 460 : series.length > 1 ? 250 : 460;
|
| 1184 |
// Overlay header carries a second line (the per-run A/B legend).
|
| 1185 |
const headH = overlayActive ? 52 : 34;
|
| 1186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1187 |
const circuitLabel = overlayActive
|
| 1188 |
? overlayRecs?.[0].sample_key ?? overlayRecs?.[0].circuit_name ?? "circuit"
|
| 1189 |
: sampleKey ?? circuit?.name ?? "circuit";
|
|
|
|
| 99 |
} from "../lib/stats";
|
| 100 |
import { hashHue, hueCss } from "../lib/hues";
|
| 101 |
import { costAnchor } from "../lib/costModel";
|
| 102 |
+
import { estimateTextW } from "../lib/svgPaper";
|
| 103 |
import { GLOSSARY } from "../lib/glossary";
|
| 104 |
import { FigureExportButton } from "./FigureExportButton";
|
| 105 |
import { TipIcon } from "./TipIcon";
|
|
|
|
| 409 |
: 0;
|
| 410 |
|
| 411 |
// Which side of the stop line the "⏹ stopped here" label sits on.
|
| 412 |
+
// stopTextW is the label's EXPORT width — estimateTextW folds in the
|
| 413 |
+
// ×1.25 PAPER_FONT_BUMP the export pipeline applies to font sizes
|
| 414 |
+
// while positions stay fixed, so the flip/intrude decisions below
|
| 415 |
+
// must budget the bumped text or exported SVGs clip/collide (audit
|
| 416 |
+
// S2; the old hardcoded 330 was the unbumped width). A stop late in
|
| 417 |
+
// the budget would run the text past the 1000px viewBox and clip it
|
| 418 |
+
// — flip to the left of the line when the right side would clip
|
| 419 |
+
// (a stop at the FINAL batch puts the line at the plot's right edge
|
| 420 |
// → always flipped). A non-flipped label can still legitimately
|
| 421 |
+
// extend past the plot edge into the right-margin readout column;
|
| 422 |
+
// that overlap is resolved VERTICALLY by stopIntrudes below, not by
|
| 423 |
+
// flipping earlier — the label reads best pointing into the unspent
|
| 424 |
+
// region it annotates.
|
| 425 |
+
const stopLabel = `⏹ stopped here — target reached at ${fmtShots(
|
| 426 |
+
s.shotsExecuted ?? 0,
|
| 427 |
+
)} of ${fmtShots(s.shotsRequested)} shots`;
|
| 428 |
+
const stopTextW = estimateTextW(stopLabel.length, 11);
|
| 429 |
const stopLabelFlip = stopX != null && stopX + 8 + stopTextW > W - 4;
|
| 430 |
|
| 431 |
// Right-margin readout placement — the panel's LAYOUT CONTRACT:
|
|
|
|
| 506 |
{s.label}
|
| 507 |
<title>{GLOSSARY.fidelity}</title>
|
| 508 |
</text>
|
| 509 |
+
{/* dx budgets the EXPORT width of the 14px title to its left —
|
| 510 |
+
estimateTextW folds in PAPER_FONT_BUMP so the bumped title
|
| 511 |
+
can't overprint this subtitle in figures (audit S2). */}
|
| 512 |
+
<text x={M.l} y={22} dx={estimateTextW(s.label.length, 14) + 14} fontSize={11} fill="rgb(var(--color-mute))">
|
| 513 |
{titleBits}
|
| 514 |
</text>
|
| 515 |
|
|
|
|
| 562 |
<rect x={stopX} y={M.t} width={M.l + plotW - stopX} height={plotH} fill="rgb(var(--color-mute))" opacity={0.05} />
|
| 563 |
<line x1={stopX} x2={stopX} y1={M.t - 4} y2={axisY} stroke="rgb(var(--color-warn))" strokeWidth={1.5} strokeDasharray="5 3" />
|
| 564 |
<text x={stopLabelFlip ? stopX - 8 : stopX + 8} textAnchor={stopLabelFlip ? "end" : "start"} y={M.t + 12} fontSize={11} fontWeight={600} fill="rgb(var(--color-warn))">
|
| 565 |
+
{stopLabel}
|
| 566 |
<title>{GLOSSARY.precisionTarget}</title>
|
| 567 |
</text>
|
| 568 |
<text x={stopLabelFlip ? stopX - 8 : stopX + 8} textAnchor={stopLabelFlip ? "end" : "start"} y={M.t + 26} fontSize={10} fill="rgb(var(--color-mute))">
|
|
|
|
| 700 |
— hardware timing differs. Rendered only when a duration is
|
| 701 |
actually known, so archived traces without timing show no
|
| 702 |
made-up price. */}
|
| 703 |
+
{anchor != null &&
|
| 704 |
+
(() => {
|
| 705 |
+
const l1 = `on IBM pay-as-you-go this evidence ≈ ${anchor.usd} (est. at $1.60/s hardware time)`;
|
| 706 |
+
const l2 = `· ≈${anchor.freeTierPct} of a free-tier month (10 min/28d) — simulator wall-time as proxy; hardware timing differs`;
|
| 707 |
+
const oneLine = `${l1} ${l2}`;
|
| 708 |
+
// Split into two tspans when the EXPORT-bumped width would
|
| 709 |
+
// run past the panel edge (audit S2: the single line clipped
|
| 710 |
+
// in exported SVGs once PAPER_FONT_BUMP grew it ×1.25).
|
| 711 |
+
const split = estimateTextW(oneLine.length, 9) > W - M.l - 8;
|
| 712 |
+
return (
|
| 713 |
+
<text
|
| 714 |
+
data-marker="cost-anchor"
|
| 715 |
+
x={M.l}
|
| 716 |
+
y={axisY + (gaps.length > 0 ? 73 : 58)}
|
| 717 |
+
fontSize={9}
|
| 718 |
+
fill="rgb(var(--color-mute))"
|
| 719 |
+
opacity={0.9}
|
| 720 |
+
>
|
| 721 |
+
{split ? (
|
| 722 |
+
<>
|
| 723 |
+
<tspan x={M.l}>{l1}</tspan>
|
| 724 |
+
<tspan x={M.l} dy={11}>
|
| 725 |
+
{l2}
|
| 726 |
+
</tspan>
|
| 727 |
+
</>
|
| 728 |
+
) : (
|
| 729 |
+
oneLine
|
| 730 |
+
)}
|
| 731 |
+
</text>
|
| 732 |
+
);
|
| 733 |
+
})()}
|
| 734 |
</g>
|
| 735 |
);
|
| 736 |
}
|
|
|
|
| 944 |
{a.label}
|
| 945 |
<title>{GLOSSARY.fidelity}</title>
|
| 946 |
</text>
|
| 947 |
+
<text x={M.l} y={22} dx={estimateTextW(a.label.length, 14) + 14} fontSize={11} fill="rgb(var(--color-mute))">
|
| 948 |
overlay — A {fmtPct(lastA.point, 2)} ±{fmtPp((lastA.hi - lastA.lo) / 2, 2)} · B {fmtPct(lastB.point, 2)} ±{fmtPp((lastB.hi - lastB.lo) / 2, 2)}
|
| 949 |
</text>
|
| 950 |
|
|
|
|
| 1207 |
const panelH = overlayActive ? 460 : series.length > 1 ? 250 : 460;
|
| 1208 |
// Overlay header carries a second line (the per-run A/B legend).
|
| 1209 |
const headH = overlayActive ? 52 : 34;
|
| 1210 |
+
// +14 bottom pad: a split cost-anchor line (see FunnelPanel) adds an
|
| 1211 |
+
// 11px second line below the last panel's baseline — without the pad
|
| 1212 |
+
// it would clip at the svg edge in the last panel.
|
| 1213 |
+
const svgH =
|
| 1214 |
+
headH + (overlayActive ? 1 : Math.max(1, series.length)) * panelH + 14;
|
| 1215 |
const circuitLabel = overlayActive
|
| 1216 |
? overlayRecs?.[0].sample_key ?? overlayRecs?.[0].circuit_name ?? "circuit"
|
| 1217 |
: sampleKey ?? circuit?.name ?? "circuit";
|
|
@@ -781,6 +781,7 @@ export function MultiverseBoard() {
|
|
| 781 |
{!hintVisible && (
|
| 782 |
<button
|
| 783 |
type="button"
|
|
|
|
| 784 |
className="shrink-0 p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
|
| 785 |
title="Show the board orientation hint (what a card is and what Open / A/B do)"
|
| 786 |
aria-label="Show board orientation hint"
|
|
@@ -826,6 +827,7 @@ export function MultiverseBoard() {
|
|
| 826 |
<div
|
| 827 |
className="multiverse-hint flex items-center gap-2 border-b border-edge/60 bg-surfaceAlt/40 px-3 py-1.5 text-[11px] text-mute"
|
| 828 |
role="note"
|
|
|
|
| 829 |
data-marker="multiverse-hint"
|
| 830 |
aria-label="Board orientation hint"
|
| 831 |
>
|
|
|
|
| 781 |
{!hintVisible && (
|
| 782 |
<button
|
| 783 |
type="button"
|
| 784 |
+
data-export-strip
|
| 785 |
className="shrink-0 p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
|
| 786 |
title="Show the board orientation hint (what a card is and what Open / A/B do)"
|
| 787 |
aria-label="Show board orientation hint"
|
|
|
|
| 827 |
<div
|
| 828 |
className="multiverse-hint flex items-center gap-2 border-b border-edge/60 bg-surfaceAlt/40 px-3 py-1.5 text-[11px] text-mute"
|
| 829 |
role="note"
|
| 830 |
+
data-export-strip
|
| 831 |
data-marker="multiverse-hint"
|
| 832 |
aria-label="Board orientation hint"
|
| 833 |
>
|
|
@@ -40,6 +40,17 @@ import { useApp } from "./store";
|
|
| 40 |
* because they clicked "Clear demo data". Never auto-import again. */
|
| 41 |
const DECIDED_FLAG = "quda-demo-decided";
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
/** Shape of one entry in src/data/demoArchive.json (produced by the
|
| 44 |
* archive-generation script; see docs/EVIDENCE_WORKBENCH.md). */
|
| 45 |
interface DemoEntry {
|
|
@@ -92,7 +103,8 @@ export async function ensureDemoArchive(
|
|
| 92 |
} = {},
|
| 93 |
): Promise<boolean> {
|
| 94 |
const { force = false } = opts;
|
| 95 |
-
|
|
|
|
| 96 |
try {
|
| 97 |
if (force) {
|
| 98 |
const existing = await listRuns(1000);
|
|
@@ -135,6 +147,7 @@ export async function ensureDemoArchive(
|
|
| 135 |
rec.demo = true;
|
| 136 |
await saveRun(rec);
|
| 137 |
}
|
|
|
|
| 138 |
markDecided();
|
| 139 |
useApp.getState().bumpHistoryVersion();
|
| 140 |
return true;
|
|
@@ -149,6 +162,7 @@ export async function ensureDemoArchive(
|
|
| 149 |
* clearing is permanent for this browser (no auto re-import). */
|
| 150 |
export async function clearDemoRuns(): Promise<void> {
|
| 151 |
markDecided();
|
|
|
|
| 152 |
try {
|
| 153 |
const all = await listRuns(1000);
|
| 154 |
for (const r of all) {
|
|
|
|
| 40 |
* because they clicked "Clear demo data". Never auto-import again. */
|
| 41 |
const DECIDED_FLAG = "quda-demo-decided";
|
| 42 |
|
| 43 |
+
/** Honesty flag (audit S2): true when the demo archive was re-imported
|
| 44 |
+
* by a scenario boot's `force` on a browser that had already decided
|
| 45 |
+
* (typically: the user CLEARED demo data, then opened a documented
|
| 46 |
+
* ?scenario= figure link). The demo banner turns this into an explicit
|
| 47 |
+
* "re-imported for this figure" notice instead of pretending the
|
| 48 |
+
* archive was there all along. Session-scoped by design. */
|
| 49 |
+
let scenarioReimported = false;
|
| 50 |
+
export function demoReimportedForScenario(): boolean {
|
| 51 |
+
return scenarioReimported;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
/** Shape of one entry in src/data/demoArchive.json (produced by the
|
| 55 |
* archive-generation script; see docs/EVIDENCE_WORKBENCH.md). */
|
| 56 |
interface DemoEntry {
|
|
|
|
| 103 |
} = {},
|
| 104 |
): Promise<boolean> {
|
| 105 |
const { force = false } = opts;
|
| 106 |
+
const decidedBefore = isDecided();
|
| 107 |
+
if (!force && decidedBefore) return false;
|
| 108 |
try {
|
| 109 |
if (force) {
|
| 110 |
const existing = await listRuns(1000);
|
|
|
|
| 147 |
rec.demo = true;
|
| 148 |
await saveRun(rec);
|
| 149 |
}
|
| 150 |
+
if (force && decidedBefore) scenarioReimported = true;
|
| 151 |
markDecided();
|
| 152 |
useApp.getState().bumpHistoryVersion();
|
| 153 |
return true;
|
|
|
|
| 162 |
* clearing is permanent for this browser (no auto re-import). */
|
| 163 |
export async function clearDemoRuns(): Promise<void> {
|
| 164 |
markDecided();
|
| 165 |
+
scenarioReimported = false;
|
| 166 |
try {
|
| 167 |
const all = await listRuns(1000);
|
| 168 |
for (const r of all) {
|
|
@@ -102,8 +102,15 @@ export const PIPELINE_PRESETS: PipelinePreset[] = [
|
|
| 102 |
nodes: [
|
| 103 |
{ id: "n1", kind: "input_circuit" },
|
| 104 |
{ id: "n2", kind: "qshot" },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
],
|
| 106 |
-
edges: [{ source: "n1", target: "n2" }],
|
| 107 |
defaultCircuit: "ry_chain_6q",
|
| 108 |
},
|
| 109 |
{
|
|
|
|
| 102 |
nodes: [
|
| 103 |
{ id: "n1", kind: "input_circuit" },
|
| 104 |
{ id: "n2", kind: "qshot" },
|
| 105 |
+
// First-party presets must pass their own preflight: without an
|
| 106 |
+
// output sink this one shipped with a standing lint warning
|
| 107 |
+
// (audit S2).
|
| 108 |
+
{ id: "n3", kind: "output" },
|
| 109 |
+
],
|
| 110 |
+
edges: [
|
| 111 |
+
{ source: "n1", target: "n2" },
|
| 112 |
+
{ source: "n2", target: "n3" },
|
| 113 |
],
|
|
|
|
| 114 |
defaultCircuit: "ry_chain_6q",
|
| 115 |
},
|
| 116 |
{
|
|
@@ -379,7 +379,17 @@ export function activeScenarioKey(): string | null {
|
|
| 379 |
/** Pick the latest successful run of each of the two most-replicated
|
| 380 |
* configurations — deterministic over the bundled archive. */
|
| 381 |
async function pickTopTwoRunIds(): Promise<string[]> {
|
| 382 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
const byHash = new Map<string, typeof runs>();
|
| 384 |
for (const r of runs) {
|
| 385 |
const arr = byHash.get(r.config_hash) ?? [];
|
|
|
|
| 379 |
/** Pick the latest successful run of each of the two most-replicated
|
| 380 |
* configurations — deterministic over the bundled archive. */
|
| 381 |
async function pickTopTwoRunIds(): Promise<string[]> {
|
| 382 |
+
const all = await listRuns(500);
|
| 383 |
+
// Scenario-boot records are scripted figure states, not evidence —
|
| 384 |
+
// the same exclusion pickOverlayPairRunIds (F7) applies. And when
|
| 385 |
+
// demo-flagged records exist, prefer them EXCLUSIVELY: on a well-used
|
| 386 |
+
// browser the user's own configurations can out-replicate the bundled
|
| 387 |
+
// groups and silently swap which pair F6/F8 select — the documented
|
| 388 |
+
// figure numbers must reproduce wherever the demo archive is present
|
| 389 |
+
// (audit S2).
|
| 390 |
+
const pool = all.filter((r) => r.scenario == null);
|
| 391 |
+
const demo = pool.filter((r) => r.demo === true);
|
| 392 |
+
const runs = demo.length > 0 ? demo : pool;
|
| 393 |
const byHash = new Map<string, typeof runs>();
|
| 394 |
for (const r of runs) {
|
| 395 |
const arr = byHash.get(r.config_hash) ?? [];
|
|
@@ -26,6 +26,22 @@
|
|
| 26 |
* hybrid path applies via cloned cssText — keep the two in sync). */
|
| 27 |
export const PAPER_FONT_BUMP = 1.25;
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
/** Whitelisted presentation attributes the inliner may write. */
|
| 30 |
export const SVG_PRESENTATION_WHITELIST = [
|
| 31 |
"fill",
|
|
|
|
| 26 |
* hybrid path applies via cloned cssText — keep the two in sync). */
|
| 27 |
export const PAPER_FONT_BUMP = 1.25;
|
| 28 |
|
| 29 |
+
/** Shared text-width estimate for SVG layout math (label flip /
|
| 30 |
+
* intrusion rules). Average glyph width ≈ 0.6em for the
|
| 31 |
+
* Helvetica/Arial stack the exporter writes. `bumped` (default true)
|
| 32 |
+
* folds in PAPER_FONT_BUMP: the export pipeline scales every
|
| 33 |
+
* font-size ×1.25 while POSITIONS stay fixed, so layout decisions
|
| 34 |
+
* must reserve the EXPORTED width or bumped labels collide/clip in
|
| 35 |
+
* figures (audit S2). Pass bumped=false only for text that never
|
| 36 |
+
* reaches the export path. */
|
| 37 |
+
export function estimateTextW(
|
| 38 |
+
chars: number,
|
| 39 |
+
fontSize: number,
|
| 40 |
+
bumped = true,
|
| 41 |
+
): number {
|
| 42 |
+
return chars * fontSize * 0.6 * (bumped ? PAPER_FONT_BUMP : 1);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
/** Whitelisted presentation attributes the inliner may write. */
|
| 46 |
export const SVG_PRESENTATION_WHITELIST = [
|
| 47 |
"fill",
|