Spaces:
Sleeping

TheYuchen commited on
Commit
fbeb1e8
·
1 Parent(s): 9f73172

History lineage: always-visible legend key

Browse files

The lineage view fronts five visual channels but its only decoding
aids were hover tooltips, a footer line below the scroll and a
skippable tour slide — even the project owner had to ask what the
circles and lines mean.

- LineageLegend (marker class `lineage-legend`): compact wrap-row key
pinned at the TOP of the History tab body, above the demo banner.
Six items, each a mini SVG replica of the real mark (accent-toned,
no specific config hue implied) + 2-4 word label: color =
configuration, size = shots, ring = pinned seed, band = replicates,
curve = forked from, strip = results + mean. Full explanations in
per-item tooltips.
- Dismissable (x at row end), persisted in localStorage
`quda.lineageLegendDismissed`; unlike RibbonLegend, a small "key"
chip remains in the same top strip to bring it back.
- Footer legend removed — fully folded into the key: radius floor/cap
into the size tooltip, slash=error into the color tooltip, funnel
per-group scale into the band tooltip. One source of truth.
- Seed glyph row tooltip now decodes the glyph per mode (pinned vs
fresh); stopped-early tooltip verified descriptive as-is.
- Standalone hosting mode shares the body so it gets the key too
(currently unmounted; ResultsPane History tab is the only usage).

tsc + build + VITE_ANON=1 build clean; backend 86 tests green.

docs/EVIDENCE_WORKBENCH.md CHANGED
@@ -938,3 +938,41 @@ provenance-backed (scenario key + pinned seed + trace_position) and
938
  bit-exactly regenerable from the live app, so re-export is a replay,
939
  not a re-measurement. Data, seeds, traces, and every number in the
940
  F0/F3 recipes are untouched.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
938
  bit-exactly regenerable from the live app, so re-export is a replay,
939
  not a re-measurement. Data, seeds, traces, and every number in the
940
  F0/F3 recipes are untouched.
941
+
942
+ ## History lineage: always-visible legend key (SHIPPED 2026-07-10)
943
+
944
+ The lineage view fronts five visual channels (dot hue = configuration,
945
+ dot area = shots of evidence, ring = pinned seed, band = replicate
946
+ group, curved edge = fork lineage — plus the distribution strip and
947
+ the certainty funnel), but its only decoding aids were hover tooltips,
948
+ a one-line footer legend below the scroll, and a skippable tour slide.
949
+ That failed the owner test: even the project owner had to ask what the
950
+ circles and lines mean.
951
+
952
+ Now (`LineageLegend` in RunHistory.tsx, marker class
953
+ `lineage-legend`): a compact, always-visible key pinned at the TOP of
954
+ the History tab body, above the demo banner — one wrap-row of six
955
+ items, each a mini SVG replica of the real mark (24×14, accent-toned
956
+ so no specific configuration hue is implied) beside a 2–4 word label:
957
+ color = configuration · size = shots · ring = pinned seed · band =
958
+ replicates · curve = forked from · strip = results + mean. Same
959
+ pattern as the canvas RibbonLegend (teach by resemblance, localStorage
960
+ dismissal — `quda.lineageLegendDismissed`) plus the affordance that
961
+ one lacks: after dismissal a small "key" chip stays in the same top
962
+ strip and brings the legend back — a key you can lose forever is
963
+ barely better than none.
964
+
965
+ The old one-line footer legend is deleted — one source of truth. Its
966
+ disclosure clauses moved into the key items' tooltips: the
967
+ evidence-radius floor/cap (≤69 shots read as the 3px floor, ≥2048 as
968
+ the cap) on the size item, hollow+slash = error on the color item,
969
+ and the funnel's per-group normalization (compare widths within a
970
+ band, not across bands) on the band item. The ⚲/∿ seed-glyph row
971
+ tooltip now also decodes the glyph per mode (⚲ pinned = deterministic
972
+ replay; ∿ fresh = drawn at random and recorded); the ⏹ stopped-early
973
+ tooltip was verified descriptive as-is. The standalone (collapsible)
974
+ RunHistory hosting mode shares the same body, so it gets the key for
975
+ free — though it is currently unmounted (ResultsPane's History tab is
976
+ the only usage). Since the key renders inside the panel body it is
977
+ captured by figure export while visible — figure-makers keep it,
978
+ daily users dismiss it once (the RibbonLegend contract).
frontend/src/components/RunHistory.tsx CHANGED
@@ -45,9 +45,18 @@
45
  // collapsible header. Hovering a row (or its dot) highlights the full
46
  // lineage chain — ancestors via forked_from plus every descendant —
47
  // by dimming unrelated rows, nodes and edges.
 
 
 
 
 
 
 
 
 
48
 
49
- import { useEffect, useMemo, useState } from "react";
50
- import { GitCompareArrows, History, Play, RotateCcw, Trash2 } from "lucide-react";
51
  import { useApp } from "../lib/store";
52
  import { deleteRun, listRuns, type RunRecord } from "../lib/runStore";
53
  import { hashHue, hueCss } from "../lib/hues";
@@ -323,6 +332,147 @@ function lineageOf(
323
  return chain;
324
  }
325
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326
  /** Provenance lineage panel.
327
  *
328
  * Hosting modes:
@@ -403,6 +553,7 @@ export function RunHistory({ embedded = false }: { embedded?: boolean } = {}) {
403
  )}
404
  {(embedded || open) && (
405
  <>
 
406
  {records.some((r) => r.demo) && <DemoArchiveBanner />}
407
  {/* Compare needs TWO runs, but nothing used to acknowledge the
408
  first checkbox beyond a "1" on a tab the user may never
@@ -547,7 +698,9 @@ export function RunHistory({ embedded = false }: { embedded?: boolean } = {}) {
547
  className={`shrink-0 ${r.seed_mode === "pinned" ? "text-accent" : "text-mute"}`}
548
  title={
549
  r.root_seed != null
550
- ? `${r.seed_mode} seed — root ${r.root_seed}. Replay reproduces this draw exactly.`
 
 
551
  : "no seed recorded (pre-provenance run or cached response)"
552
  }
553
  >
@@ -773,24 +926,6 @@ cumulative Wilson CI half-width of this configuration's pooled counts, widest (o
773
  </svg>
774
  </div>
775
  </div>
776
- {/* legend: one line, doubles as the figure caption key */}
777
- <div className="px-3 py-1 border-t border-edge/60 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[9px] text-mute">
778
- <span>hue = configuration</span>
779
- {/* floor/cap disclosure: evidenceRadius clamps to
780
- [R_MIN, R_MAX], i.e. ≤69 shots all read as the 3px
781
- floor and ≥2048 as the cap (audit MINOR — the clamp
782
- was silent). */}
783
- <span>area = shots of evidence (floor ≤69, cap 2048)</span>
784
- <span>ring = pinned seed</span>
785
- <span>slash = error</span>
786
- <span>curve = forked from</span>
787
- <span>strip = replicate metrics (0–1)</span>
788
- {/* per-group scale disclosure: each band's funnel is
789
- normalized to its own widest row, so funnel widths are
790
- comparable WITHIN a band, not across bands (audit
791
- MINOR). */}
792
- <span>funnel = pooled CI narrowing (per-group scale)</span>
793
- </div>
794
  </>
795
  )}
796
  </div>
 
45
  // collapsible header. Hovering a row (or its dot) highlights the full
46
  // lineage chain — ancestors via forked_from plus every descendant —
47
  // by dimming unrelated rows, nodes and edges.
48
+ //
49
+ // Decoding aid: LineageLegend -- an always-visible, dismissable key
50
+ // pinned at the TOP of the panel, one mini SVG replica of each real
51
+ // mark + a 2-4 word label. Its tooltips carry the encoding
52
+ // disclosures the old one-line footer legend held (evidence-radius
53
+ // floor/cap, funnel per-group scale, hollow+slash = error), so the
54
+ // footer is gone -- one source of truth. Dismissal persists in
55
+ // localStorage (quda.lineageLegendDismissed); a small "key" chip in
56
+ // the same top strip brings it back.
57
 
58
+ import { useEffect, useMemo, useState, type ReactNode } from "react";
59
+ import { GitCompareArrows, History, KeyRound, Play, RotateCcw, Trash2, X } from "lucide-react";
60
  import { useApp } from "../lib/store";
61
  import { deleteRun, listRuns, type RunRecord } from "../lib/runStore";
62
  import { hashHue, hueCss } from "../lib/hues";
 
332
  return chain;
333
  }
334
 
335
+ // --- lineage legend (encoding key) ----------------------------------------
336
+
337
+ const LINEAGE_LEGEND_LS_KEY = "quda.lineageLegendDismissed";
338
+
339
+ /** One item of the lineage key: a mini SVG replica of the real mark
340
+ * (24x14 box, accent-toned so no specific configuration color is
341
+ * implied) beside a 2-4 word label. The full explanation -- including
342
+ * the disclosures the removed footer line carried -- lives in the
343
+ * native tooltip. */
344
+ function KeyItem({
345
+ label,
346
+ hint,
347
+ children,
348
+ }: {
349
+ label: string;
350
+ hint: string;
351
+ children: ReactNode;
352
+ }) {
353
+ return (
354
+ <span className="flex items-center gap-1 cursor-help" title={hint}>
355
+ <svg width={24} height={14} viewBox="0 0 24 14" aria-hidden className="shrink-0">
356
+ {children}
357
+ </svg>
358
+ <span>{label}</span>
359
+ </span>
360
+ );
361
+ }
362
+
363
+ /** Always-visible encoding key pinned at the top of the History tab.
364
+ * The lineage view fronts five visual channels, and tooltips + a
365
+ * skippable tour slide proved discoverable-once at best. Same
366
+ * pattern as the canvas RibbonLegend (mini replicas of the real
367
+ * marks, localStorage dismissal) plus the affordance that one lacks:
368
+ * a compact "key" chip in the same top strip that brings the legend
369
+ * back -- a key you can lose forever is barely better than none. */
370
+ function LineageLegend() {
371
+ const [dismissed, setDismissed] = useState<boolean>(() => {
372
+ try {
373
+ return localStorage.getItem(LINEAGE_LEGEND_LS_KEY) === "1";
374
+ } catch {
375
+ return false;
376
+ }
377
+ });
378
+ const ACC = "rgb(var(--color-accent))";
379
+ if (dismissed)
380
+ return (
381
+ <div className="lineage-legend flex justify-end border-b border-edge/40 px-1.5 py-0.5">
382
+ <button
383
+ type="button"
384
+ className="flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-mute hover:text-ink hover:bg-surfaceAlt"
385
+ title="Show the encoding key for this view (what the dots, rings, bands, curves and strips mean)"
386
+ aria-label="Show lineage encoding key"
387
+ onClick={() => {
388
+ setDismissed(false);
389
+ try {
390
+ localStorage.removeItem(LINEAGE_LEGEND_LS_KEY);
391
+ } catch {
392
+ /* private mode -- reopening is session-scoped anyway */
393
+ }
394
+ }}
395
+ >
396
+ <KeyRound className="w-3 h-3" />
397
+ key
398
+ </button>
399
+ </div>
400
+ );
401
+ return (
402
+ <div
403
+ className="lineage-legend flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-edge/60 bg-surfaceAlt/40 px-2.5 py-1.5 text-[10px] text-mute"
404
+ role="note"
405
+ aria-label="Lineage encoding key"
406
+ >
407
+ <KeyItem
408
+ label="color = configuration"
409
+ hint="Every dot is one archived run; its hue is derived from the configuration hash, so replicates of the same experiment share a color across panels, sessions and screenshots. Errored runs draw hollow with a red slash."
410
+ >
411
+ <circle cx={12} cy={7} r={4} fill={ACC} fillOpacity={0.95} />
412
+ </KeyItem>
413
+ <KeyItem
414
+ label="size = shots"
415
+ hint="Dot area grows with the shots of evidence the run actually executed (area proportional to sqrt(shots) against a fixed 2048-shot reference). Clamped: 69 shots or fewer all read as the 3px floor, 2048 or more as the cap; runs with no sampled step keep the floor."
416
+ >
417
+ <circle cx={6.5} cy={7} r={2} fill={ACC} fillOpacity={0.95} />
418
+ <circle cx={16.5} cy={7} r={4.5} fill={ACC} fillOpacity={0.95} />
419
+ </KeyItem>
420
+ <KeyItem
421
+ label="ring = pinned seed"
422
+ hint="A ring around a dot marks a pinned (replayed) seed -- the run is deterministic and reproduces its numbers exactly. Bare dots are fresh random draws."
423
+ >
424
+ <circle cx={12} cy={7} r={3} fill={ACC} fillOpacity={0.95} />
425
+ <circle cx={12} cy={7} r={5.5} fill="none" stroke={ACC} strokeWidth={1.2} />
426
+ </KeyItem>
427
+ <KeyItem
428
+ label="band = replicates"
429
+ hint="A translucent band + spine groups a contiguous block of replicate runs of one configuration (what the xN runner produces). The two thin lines flaring around a band are its certainty funnel: the pooled 95% CI half-width narrowing as replicates accumulate -- scaled per group, so compare funnel widths within a band, not across bands."
430
+ >
431
+ <rect x={1} y={2.5} width={22} height={9} rx={4.5} fill={ACC} fillOpacity={0.15} />
432
+ <line x1={5} y1={7} x2={19} y2={7} stroke={ACC} strokeOpacity={0.4} strokeWidth={1.5} />
433
+ <circle cx={7.5} cy={7} r={2.6} fill={ACC} fillOpacity={0.95} />
434
+ <circle cx={16.5} cy={7} r={2.6} fill={ACC} fillOpacity={0.95} />
435
+ </KeyItem>
436
+ <KeyItem
437
+ label="curve = forked from"
438
+ hint="A curved edge links a run to the ancestor it was forked from (restore or replay), drawn in the child's hue -- follow a color upward through time to trace where a configuration came from. A short dashed stub means the ancestor was deleted or lies outside the 50-run window."
439
+ >
440
+ <circle cx={4.5} cy={3.5} r={2.2} fill={ACC} fillOpacity={0.95} />
441
+ <circle cx={19.5} cy={10.5} r={2.2} fill={ACC} fillOpacity={0.55} />
442
+ <path d="M 6 5 C 10 9.5 14 4.5 18 9.5" fill="none" stroke={ACC} strokeOpacity={0.7} strokeWidth={1.2} />
443
+ </KeyItem>
444
+ <KeyItem
445
+ label="strip = results + mean"
446
+ hint="The mini strip above a replicate block plots the headline values (0-1 scale) of every run of that configuration archived up to that moment: bright dots = the block below, faint dots = older replicates, tick = the running mean."
447
+ >
448
+ <line x1={2} y1={7} x2={22} y2={7} stroke="rgb(var(--color-edge))" strokeWidth={1} />
449
+ <line x1={2} y1={4.5} x2={2} y2={9.5} stroke="rgb(var(--color-edge))" strokeWidth={1} />
450
+ <line x1={22} y1={4.5} x2={22} y2={9.5} stroke="rgb(var(--color-edge))" strokeWidth={1} />
451
+ <line x1={13} y1={3} x2={13} y2={11} stroke="rgb(var(--color-ink))" strokeOpacity={0.6} strokeWidth={1} />
452
+ <circle cx={7} cy={7} r={1.8} fill={ACC} fillOpacity={0.95} />
453
+ <circle cx={10.5} cy={7} r={1.8} fill={ACC} fillOpacity={0.4} />
454
+ <circle cx={17} cy={7} r={1.8} fill={ACC} fillOpacity={0.95} />
455
+ </KeyItem>
456
+ <button
457
+ type="button"
458
+ className="ml-auto shrink-0 self-start text-mute hover:text-ink transition-colors"
459
+ title="Dismiss (remembered on this device -- the small 'key' button brings it back)"
460
+ aria-label="Dismiss lineage encoding key"
461
+ onClick={() => {
462
+ setDismissed(true);
463
+ try {
464
+ localStorage.setItem(LINEAGE_LEGEND_LS_KEY, "1");
465
+ } catch {
466
+ /* private mode etc. -- the key just reappears next visit */
467
+ }
468
+ }}
469
+ >
470
+ <X className="w-3 h-3" />
471
+ </button>
472
+ </div>
473
+ );
474
+ }
475
+
476
  /** Provenance lineage panel.
477
  *
478
  * Hosting modes:
 
553
  )}
554
  {(embedded || open) && (
555
  <>
556
+ <LineageLegend />
557
  {records.some((r) => r.demo) && <DemoArchiveBanner />}
558
  {/* Compare needs TWO runs, but nothing used to acknowledge the
559
  first checkbox beyond a "1" on a tab the user may never
 
698
  className={`shrink-0 ${r.seed_mode === "pinned" ? "text-accent" : "text-mute"}`}
699
  title={
700
  r.root_seed != null
701
+ ? r.seed_mode === "pinned"
702
+ ? `⚲ pinned seed — root ${r.root_seed}. This run was replayed deterministically; replaying it again reproduces the same numbers.`
703
+ : `∿ fresh seed — root ${r.root_seed}, drawn at random and recorded. Replay pins it to reproduce these exact numbers.`
704
  : "no seed recorded (pre-provenance run or cached response)"
705
  }
706
  >
 
926
  </svg>
927
  </div>
928
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
  </>
930
  )}
931
  </div>