Skip to content

Official Codebase of 3DCodeVerse

Python

portability: python floor 3.10 (proven on a clean 3.10.21 venv, 2413 offline tests) via one _compat module; node floor 20.6.0 — fixes a real defect where resolve_three used node 22.15+ registerHooks, so three.js export/render silently required node >= 22.15 (93 node tests now pass on node 20.19.5); CI matrix = the two ends of the supported range

gaoypeng4d951079df7b
diff --git a/harness/codeverse/gallery/__init__.py b/harness/codeverse/gallery/__init__.py
index 54d85b3e..fec68d15 100644
--- a/harness/codeverse/gallery/__init__.py
+++ b/harness/codeverse/gallery/__init__.py
@@ -2,7 +2,10 @@
* ``index`` ``build_index(roots)`` · ``default_roots()`` — record.json → typed entries
* ``model`` ``RunEntry`` / ``RootSection`` / ``GalleryIndex`` / ``summarize`` / ``match``
-* ``page`` the index page (summary strip, filters, cards + table)
+* ``labels`` view-name humanisation + the four disjoint verdict buckets
+* ``page`` the index page (status rail, filters, cards + table)
+* ``cards`` one run as a card / a table row / a compare column
+* ``compare`` ``/compare`` side-by-side + ``/export.csv`` (read-only projections)
* ``detail`` ``/run/<battery>/<slug>`` — rounds, judge, measurement, renders, cost, code
* ``code`` directory listings + the file viewer
* ``viewer`` optional GLB viewer on the vendored three.js (no CDN)
@@ -10,8 +13,17 @@
* ``static_site`` ``build_static(roots, out.html, embed=…)``
"""
+from codeverse.gallery.compare import export_csv, render_compare
from codeverse.gallery.index import build_index, default_roots
-from codeverse.gallery.model import GalleryIndex, RootSection, RunEntry, Summary, summarize
+from codeverse.gallery.labels import VERDICTS, humanize_view
+from codeverse.gallery.model import (
+ GalleryIndex,
+ RootSection,
+ RunEntry,
+ Summary,
+ summarize,
+ verdict_breakdown,
+)
from codeverse.gallery.server import (
DEFAULT_HOST,
DEFAULT_PORT,
@@ -23,7 +35,8 @@ from codeverse.gallery.server import (
from codeverse.gallery.static_site import build_static, render_static
__all__ = [
- "DEFAULT_HOST", "DEFAULT_PORT", "GalleryApp", "GalleryError", "GalleryIndex", "RootSection",
- "RunEntry", "Summary", "build_index", "build_static", "default_roots", "render_static",
- "resolve_host", "serve", "summarize",
+ "DEFAULT_HOST", "DEFAULT_PORT", "VERDICTS", "GalleryApp", "GalleryError", "GalleryIndex",
+ "RootSection", "RunEntry", "Summary", "build_index", "build_static", "default_roots",
+ "export_csv", "humanize_view", "render_compare", "render_static", "resolve_host", "serve",
+ "summarize", "verdict_breakdown",
]
diff --git a/harness/codeverse/gallery/cards.py b/harness/codeverse/gallery/cards.py
index 04dc2701..e1f4a819 100644
--- a/harness/codeverse/gallery/cards.py
+++ b/harness/codeverse/gallery/cards.py
@@ -127,7 +127,8 @@ def render_card(entry: RunEntry, urls: UrlMaker, *, hidden: bool = False) -> str
redundant = not entry.status or (entry.passed and entry.status == "passed")
status = "" if redundant else f"<span class='tag'>{esc(entry.status)}</span>"
caption = f"<p class='xs faint clamp1'>{esc(entry.caption)}</p>" if entry.caption else ""
- err = f"<div class='err'>{esc(entry.error[:300])}</div>" if entry.error else ""
+ err = f"<div class='err clamp2' title='{esc(entry.error)}'>{esc(entry.error[:300])}</div>" \
+ if entry.error else ""
return (
f"<article class='card {VERDICT_META[entry.verdict][1]}{hide}' data-run='{esc(entry.key)}'"
f" data-verdict='{esc(entry.verdict)}'>{select_box(entry)}{card_shot(entry, urls)}"
@@ -140,20 +141,21 @@ def render_card(entry: RunEntry, urls: UrlMaker, *, hidden: bool = False) -> str
TABLE_HEAD = ("<tr><th class='pickcol'><span class='sr'>select</span></th><th class='thumbcol'></th>"
- "<th>run</th><th>verdict</th><th>track</th><th>lang</th><th>backend</th><th>tier</th>"
- "<th class='n'>base</th><th class='n'>best</th><th class='n'>Δ</th><th class='n'>gates</th>"
- "<th class='n'>$</th><th class='n'>min</th><th class='n'>sec</th><th>links</th></tr>")
+ "<th class='runcol'>run</th><th>verdict</th><th class='track'>track</th>"
+ "<th class='lang'>lang</th><th class='backend'>backend</th><th class='tier'>tier</th>"
+ "<th class='n base'>base</th><th class='n'>best</th><th class='n delta'>Δ</th>"
+ "<th class='n'>gates</th><th class='n'>$</th><th class='n min'>min</th>"
+ "<th class='rowlinks'>links</th></tr>")
def render_row(entry: RunEntry, urls: UrlMaker, *, hidden: bool = False) -> str:
delta = (entry.score - entry.baseline_score
if entry.score is not None and entry.baseline_score is not None else None)
links = " ".join(f"<a href='{esc(urls.link(entry, link))}'>{esc(link.label)}</a>"
- for link in entry.links if link.label in ("workspace", "src/", "sheet", "glb"))
+ for link in entry.links if link.label in ("src/", "glb"))
image = entry.card_image
thumb = (f"<a href='{esc(urls.detail(entry))}'><img class='rowthumb' loading='lazy' decoding='async'"
f" src='{esc(urls.img(entry, image))}' alt=''></a>" if image else "")
- seconds = "—" if entry.minutes is None else f"{entry.minutes * 60:.0f}"
return (
f"<tr class='{'is-hidden ' if hidden else ''}{VERDICT_META[entry.verdict][1]}'"
f" data-run='{esc(entry.key)}' data-verdict='{esc(entry.verdict)}'>"
@@ -161,12 +163,13 @@ def render_row(entry: RunEntry, urls: UrlMaker, *, hidden: bool = False) -> str:
f"<td class='wide'><a href='{esc(urls.detail(entry))}'>{esc(entry.title or entry.slug)}</a>"
f"<div class='xs faint'>{esc(entry.slug)}</div></td>"
f"<td>{verdict_tag(entry)}</td>"
- f"<td>{esc(entry.track)}</td><td>{esc(entry.language)}</td><td>{esc(entry.generator)}</td>"
- f"<td>{tier_tag(entry)}</td>"
- f"<td class='n'>{fmt(entry.baseline_score)}</td><td class='n'>{fmt(entry.score)}</td>"
- f"<td class='n'>{'—' if delta is None else format(delta, '+.3f')}</td>"
+ f"<td class='track'>{esc(entry.track)}</td><td class='lang'>{esc(entry.language)}</td>"
+ f"<td class='backend' title='{esc(entry.generator)}'>{esc(entry.generator)}</td>"
+ f"<td class='tier'>{tier_tag(entry)}</td>"
+ f"<td class='n base'>{fmt(entry.baseline_score)}</td><td class='n'>{fmt(entry.score)}</td>"
+ f"<td class='n delta'>{'—' if delta is None else format(delta, '+.3f')}</td>"
f"<td class='n'>{entry.gate_errors}</td><td class='n'>{entry.cost_usd:.2f}</td>"
- f"<td class='n'>{fmt(entry.minutes, 1)}</td><td class='n'>{seconds}</td>"
+ f"<td class='n min'>{fmt(entry.minutes, 1)}</td>"
f"<td class='rowlinks'>{links}</td></tr>"
)
diff --git a/harness/codeverse/gallery/compare.py b/harness/codeverse/gallery/compare.py
new file mode 100644
index 00000000..3e193174
--- /dev/null
+++ b/harness/codeverse/gallery/compare.py
@@ -0,0 +1,175 @@
+"""Bulk triage: the side-by-side compare page and the CSV export.
+
+Both are **read-only projections of the index** — ``/compare?runs=a/b,c/d`` and
+``/export.csv?runs=…`` (or any index filter). Nothing here writes, queues or
+re-runs anything: the gallery deliberately exposes no mutation endpoint, so the
+bulk bar offers *compare*, *export* and *copy paths* and stops there.
+
+The compare page is a metric-per-row table so the eye travels along one row and
+compares like with like; a per-run column of stacked cards does not do that.
+"""
+
+from __future__ import annotations
+
+import csv
+import io
+
+from codeverse.gallery.cards import fmt, tier_tag, verdict_tag
+from codeverse.gallery.labels import VERDICT_META
+from codeverse.gallery.model import RunEntry
+from codeverse.gallery.theme import esc, footer, page_shell, top_bar
+from codeverse.gallery.urls import UrlMaker
+
+#: how many runs a compare page will lay out before it says "too many"
+MAX_COMPARE = 8
+
+COMPARE_CSS = """
+.cmpwrap{overflow-x:auto;border:1px solid var(--line);border-radius:var(--r-2);background:var(--surface)}
+table.cmp{border-collapse:collapse;width:max-content;min-width:100%;font-size:var(--fs-sm)}
+table.cmp th.rowk{text-align:left;width:132px;min-width:132px;color:var(--fg-3);font-weight:600;
+ position:sticky;left:0;background:var(--surface);z-index:1;text-transform:none;letter-spacing:0}
+table.cmp td{vertical-align:top;min-width:200px;max-width:320px;white-space:normal;
+ border-left:1px solid var(--line);overflow-wrap:anywhere}
+table.cmp td code{word-break:break-all}
+table.cmp tr:nth-child(even){background:color-mix(in srgb,var(--sunken) 55%,transparent)}
+table.cmp tr:nth-child(even) th.rowk{background:color-mix(in srgb,var(--surface) 60%,var(--sunken))}
+table.cmp img.cmpshot{width:100%;max-width:300px;border-radius:var(--r-2);background:var(--sunken);
+ display:block;border:1px solid var(--line)}
+table.cmp td.head{font-weight:650;font-size:var(--fs-md)}
+.cmp .spark{display:flex;gap:3px;align-items:flex-end;height:26px}
+.cmp .spark i{display:block;width:9px;background:var(--accent-soft);border-radius:2px 2px 0 0}
+.cmp .spark i.best{background:var(--accent)}
+table.cmp td a{margin-right:2px}
+@media (max-width:640px){
+ table.cmp th.rowk{width:80px;min-width:80px;font-size:var(--fs-xs);padding:7px 6px}
+ table.cmp td{min-width:172px;max-width:210px;font-size:var(--fs-xs);padding:7px 8px}
+ table.cmp img.cmpshot{max-width:156px}
+ table.cmp td.head{font-size:var(--fs-sm)}
+}
+.swipehint{display:none}
+@media (max-width:640px){.swipehint{display:block;margin-bottom:6px}}
+"""
+
+
+def parse_keys(value: str) -> list[str]:
+ """``"a/b, c/d"`` → ``["a/b", "c/d"]`` (order kept, duplicates dropped)."""
+ out: list[str] = []
+ for chunk in (value or "").replace("\n", ",").split(","):
+ key = chunk.strip()
+ if key and key not in out:
+ out.append(key)
+ return out
+
+
+def _spark(entry: RunEntry) -> str:
+ rows = [r for r in entry.round_rows if r.score is not None]
+ if len(rows) < 2:
+ return "—"
+ top = max(r.score or 0.0 for r in rows) or 1.0
+ bars = "".join(
+ f"<i style='height:{max(3, round(26 * (r.score or 0.0) / top))}px'"
+ f"{' class=best' if r.index == entry.best_round else ''}"
+ f" title='r{r.index} {r.score:.3f}'></i>" for r in rows)
+ return f"<div class='spark'>{bars}</div>"
+
+
+def _row(label: str, entries: list[RunEntry], render, *, cls: str = "") -> str:
+ attr = f" class='{cls}'" if cls else ""
+ body = "".join(f"<td{attr}>{render(e)}</td>" for e in entries)
+ return f"<tr><th class='rowk'>{esc(label)}</th>{body}</tr>"
+
+
+def _delta(entry: RunEntry) -> str:
+ if entry.score is None or entry.baseline_score is None:
+ return "—"
+ d = entry.score - entry.baseline_score
+ return f"<span class='{'up' if d >= 0 else 'down'}'>{d:+.3f}</span>"
+
+
+def render_compare(entries: list[RunEntry], urls: UrlMaker, *, note: str = "") -> str:
+ """``n`` runs as columns, one metric per row."""
+ if not entries:
+ inner = ("<div class='panel'><h2>nothing to compare</h2><p class='muted'>Tick two or more "
+ "runs on the index and press <b>compare</b>.</p></div>")
+ body = (top_bar("3dcv gallery", crumbs="<a href='/'>gallery</a> <span class='faint'>/</span> "
+ "<b>compare</b>") + f"<main class='wrap'>{inner}</main>" + footer("3dcv gallery"))
+ return page_shell("compare — 3dcv gallery", body, extra_css=COMPARE_CSS)
+
+ def shot(e: RunEntry) -> str:
+ image = e.card_image
+ if not image:
+ return "<span class='faint'>no render</span>"
+ return (f"<a href='{esc(urls.detail(e))}'><img class='cmpshot' loading='lazy' "
+ f"src='{esc(urls.img(e, image))}' alt='{esc(e.slug)}'></a>")
+
+ def head(e: RunEntry) -> str:
+ return (f"<a href='{esc(urls.detail(e))}'>{esc(e.title or e.slug)}</a>"
+ f"<div class='xs faint'>{esc(e.battery)} / {esc(e.slug)}</div>")
+
+ def links(e: RunEntry) -> str:
+ keep = ("src/", "sheet", "glb", "record.json")
+ return " · ".join(f"<a href='{esc(urls.link(e, ln))}'>{esc(ln.label)}</a>"
+ for ln in e.links if ln.label in keep) or "—"
+
+ rows = "".join([
+ _row("run", entries, head, cls="head"),
+ _row("render", entries, shot),
+ _row("verdict", entries, lambda e: verdict_tag(e) + " " + tier_tag(e)),
+ _row("score", entries, lambda e: f"<b class='num'>{fmt(e.score)}</b>"),
+ _row("baseline", entries, lambda e: f"<span class='num'>{fmt(e.baseline_score)}</span>"),
+ _row("Δ vs baseline", entries, _delta),
+ _row("per round", entries, _spark),
+ _row("gate errors", entries, lambda e: str(e.gate_errors) + (
+ " <span class='xs faint'>" + esc(", ".join(f"{k}:{v}" for k, v in e.gate_summary.items()))
+ + "</span>" if e.gate_summary else "")),
+ _row("rounds", entries, lambda e: f"{e.rounds} · best r{e.best_round if e.best_round is not None else '–'}"),
+ _row("cost", entries, lambda e: f"${e.cost_usd:.3f}"),
+ _row("wall clock", entries, lambda e: "—" if e.minutes is None else f"{e.minutes:.1f} min"),
+ _row("track", entries, lambda e: esc(e.track)),
+ _row("language", entries, lambda e: esc(e.language)),
+ _row("generator", entries, lambda e: esc(e.generator)),
+ _row("judge", entries, lambda e: esc(e.judge)),
+ _row("prompt", entries, lambda e: f"<span class='small'>{esc(e.prompt)}</span>"),
+ _row("workspace", entries, lambda e: f"<code class='xs'>{esc(e.path)}</code>"),
+ _row("links", entries, links),
+ ])
+ counts = {k: sum(1 for e in entries if e.verdict == k) for k, _ in VERDICT_META.items()}
+ tally = " · ".join(f"{v} {k}" for k, v in counts.items() if v)
+ body = (
+ top_bar("3dcv gallery", f"{len(entries)} runs · {tally}",
+ crumbs="<a href='/'>gallery</a> <span class='faint'>/</span> <b>compare</b>",
+ right=f"<a class='btn' href='/export.csv?runs={esc(','.join(e.key for e in entries))}'>"
+ f"export csv</a>")
+ + "<main class='wrap'>"
+ + (f"<p class='small muted'>{esc(note)}</p>" if note else "")
+ + "<p class='swipehint xs faint'>swipe sideways to reach the other runs — "
+ "the metric names stay pinned on the left</p>"
+ + f"<div class='cmpwrap cmp'><table class='cmp'><tbody>{rows}</tbody></table></div>"
+ + "<p class='small faint' style='margin-top:var(--s-3)'>read-only view — the gallery never "
+ "starts, resumes or deletes a run.</p>"
+ + "</main>" + footer("compare · 3dcv gallery"))
+ return page_shell("compare — 3dcv gallery", body, extra_css=COMPARE_CSS)
+
+
+CSV_COLUMNS = ("battery", "slug", "title", "verdict", "tier", "track", "language", "generator",
+ "judge", "score", "baseline_score", "delta", "gate_errors", "cost_usd", "minutes",
+ "rounds", "best_round", "status", "state", "path", "prompt")
+
+
+def export_csv(entries: list[RunEntry]) -> str:
+ """The selected runs as CSV — the one export a read-only tool owes a spreadsheet."""
+ buf = io.StringIO()
+ writer = csv.writer(buf, lineterminator="\n")
+ writer.writerow(CSV_COLUMNS)
+ for e in entries:
+ delta = (e.score - e.baseline_score
+ if e.score is not None and e.baseline_score is not None else None)
+ writer.writerow([
+ e.battery, e.slug, e.title, e.verdict, e.tier, e.track, e.language, e.generator,
+ e.judge, "" if e.score is None else f"{e.score:.4f}",
+ "" if e.baseline_score is None else f"{e.baseline_score:.4f}",
+ "" if delta is None else f"{delta:+.4f}", e.gate_errors, f"{e.cost_usd:.4f}",
+ "" if e.minutes is None else f"{e.minutes:.2f}", e.rounds,
+ "" if e.best_round is None else e.best_round, e.status, e.state, e.path, e.prompt,
+ ])
+ return buf.getvalue()
diff --git a/harness/codeverse/gallery/detail.py b/harness/codeverse/gallery/detail.py
index 4719084c..40dc08ab 100644
--- a/harness/codeverse/gallery/detail.py
+++ b/harness/codeverse/gallery/detail.py
@@ -14,28 +14,54 @@ from pathlib import Path
from codeverse.contracts.common import ENTRY_FILE
from codeverse.contracts.run import RunRecord
from codeverse.flywheel.record import effective_judgment
+from codeverse.gallery.cards import gallery_figure, tier_tag, verdict_tag
from codeverse.gallery.code import CODE_CSS, numbered, read_text, src_files
-from codeverse.gallery.index import best_sheet
+from codeverse.gallery.index import best_sheet, hero_view
from codeverse.gallery.model import RunEntry
from codeverse.gallery.theme import esc, footer, page_shell, top_bar
from codeverse.gallery.urls import UrlMaker
from codeverse.workspace import Workspace
DETAIL_CSS = CODE_CSS + """
-.hero{display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);gap:var(--s-4);align-items:start}
+.hero{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.05fr);gap:var(--s-4);align-items:start}
@media (max-width:900px){.hero{grid-template-columns:1fr}}
-.hero .shotbox{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-3);
- overflow:hidden;box-shadow:var(--shadow)}
-.hero .shotbox img{width:100%;display:block;background:var(--sunken)}
+.hero .shotbox{position:relative;background-color:var(--shot-bg);
+ background-image:repeating-conic-gradient(var(--shot-check) 0% 25%,transparent 0% 50%);
+ background-size:22px 22px;border-radius:var(--r-3);overflow:hidden;
+ box-shadow:var(--shadow),inset 0 0 0 1px var(--shot-ring)}
+.hero .shotbox img{width:100%;display:block;aspect-ratio:4/3;max-height:min(44vh,430px);
+ object-fit:contain}
+.hero .shotbox figcaption{position:absolute;inset:auto 0 0 0;color:#fff;font-size:var(--fs-sm);
+ font-weight:550;padding:26px 12px 8px;background:linear-gradient(to top,var(--overlay),transparent);
+ text-shadow:0 1px 2px rgba(0,0,0,.55)}
.linkrow{display:flex;flex-wrap:wrap;gap:6px 10px;margin-top:var(--s-3);font-size:var(--fs-sm);
overflow-wrap:anywhere}
-.badges{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:var(--s-3)}
+.badges{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:var(--s-3);align-items:center}
.best{background:var(--accent-soft)}
+.best td:first-child{box-shadow:inset 3px 0 0 var(--accent)}
details.round{border-top:1px solid var(--line);padding:var(--s-2) 0}
details.round summary{cursor:pointer;font-size:var(--fs-sm)}
+.jump{display:flex;flex-wrap:wrap;gap:6px;margin:var(--s-4) 0 0;position:sticky;top:52px;z-index:10;
+ padding:6px 0;background:color-mix(in srgb,var(--bg) 92%,transparent)}
+.jump a{font-size:var(--fs-sm);padding:3px 10px;border-radius:999px;background:var(--chip);
+ color:var(--chip-fg);font-weight:550}
+.jump a:hover{text-decoration:none;background:var(--accent-soft);color:var(--accent)}
+.neighbours{display:flex;gap:6px;align-items:center}
+.neighbours .btn.dead{opacity:.4;pointer-events:none}
+ul.plain li{display:list-item}
+#judge ul.plain li{margin:5px 0;line-height:1.55}
+.footnav{display:flex;gap:var(--s-2);justify-content:space-between;margin:var(--s-5) 0 0}
+.panel table{width:auto;min-width:min(100%,560px)}
+.panel .tablewrap{width:fit-content;max-width:100%}
"""
+#: judge severities, worst first — a triage reader must see "critical" before "minor"
+SEVERITY_ORDER = {"critical": 0, "blocker": 0, "major": 1, "moderate": 2, "minor": 3, "nit": 4}
+SEVERITY_CLASS = {"critical": "pill-fail", "blocker": "pill-fail", "major": "pill-fail",
+ "moderate": "pill-warn", "minor": "pill-warn"}
+
+
def _fmt(v: float | None, d: int = 3) -> str:
return "—" if v is None else format(v, f".{d}f")
@@ -44,9 +70,9 @@ def _kv(key: str, value: str) -> str:
return f"<div class='kv'><span class='k'>{esc(key)}</span><span class='v'>{value}</span></div>"
-def _panel(title: str, inner: str, *, anchor: str = "") -> str:
+def _panel(title: str, inner: str, *, anchor: str = "", extra_head: str = "") -> str:
ident = f" id='{esc(anchor)}'" if anchor else ""
- return f"<div class='panel'{ident}><h2>{esc(title)}</h2>{inner}</div>"
+ return f"<div class='panel'{ident}><h2>{esc(title)}{extra_head}</h2>{inner}</div>"
def _rel(run: Path, path: str | None) -> str:
@@ -62,15 +88,19 @@ def _rel(run: Path, path: str | None) -> str:
# --------------------------------------------------------------------------- sections
def _hero(entry: RunEntry, urls: UrlMaker, rec: RunRecord) -> str:
- sheet = entry.sheet
- shot = (f"<a href='{esc(urls.file(entry, sheet))}'><img src='{esc(urls.file(entry, sheet))}' "
- f"alt='contact sheet — {esc(entry.slug)}' loading='eager'></a>") if sheet else \
- "<div class='empty'>no contact sheet</div>"
- badges = (f"<span class='tag tier {esc(entry.tier)}'>{esc(entry.tier)}</span>"
- f"<span class='tag {'pill-pass' if entry.passed else ('pill-fail' if entry.passed is False else '')}'>"
- f"{'passed' if entry.passed else ('failed' if entry.passed is False else 'unjudged')}</span>"
- f"<span class='tag'>{esc(entry.status)}</span>"
- f"<span class='tag'>{esc(entry.track)}</span><span class='tag'>{esc(entry.language)}</span>")
+ """One big legible view + the facts. Every other angle is in ``renders`` below,
+ which is where a grid belongs — the top of the page answers "what is this?"."""
+ image = entry.hero or entry.sheet
+ label = entry.hero_label or ("Contact sheet" if entry.sheet else "")
+ shot = (f"<a href='{esc(urls.file(entry, image))}' title='open full size'>"
+ f"<img src='{esc(urls.file(entry, image))}' "
+ f"alt='{esc(label)} — {esc(entry.slug)}' loading='eager'>"
+ f"<figcaption>{esc(label)}</figcaption></a>") if image else \
+ "<div class='empty'>no render</div>"
+ redundant = not entry.status or (entry.passed and entry.status == "passed")
+ badges = (f"{tier_tag(entry)}{verdict_tag(entry)}"
+ + ("" if redundant else f"<span class='tag'>{esc(entry.status)}</span>")
+ + f"<span class='tag'>{esc(entry.track)}</span><span class='tag'>{esc(entry.language)}</span>")
delta = ("—" if entry.score is None or entry.baseline_score is None
else format(entry.score - entry.baseline_score, "+.3f"))
facts = "".join([
@@ -96,13 +126,13 @@ def _hero(entry: RunEntry, urls: UrlMaker, rec: RunRecord) -> str:
def _rounds_table(entry: RunEntry, urls: UrlMaker) -> str:
head = ("<tr><th>r</th><th>kind</th><th class='n'>score</th><th>verdict</th><th class='n'>gates</th>"
- "<th>build</th><th class='n'>$</th><th class='n'>s</th><th>commit</th><th>sheet</th></tr>")
+ "<th>build</th><th class='n'>$</th><th class='n'>sec</th><th>commit</th><th>views</th></tr>")
rows = []
for r in entry.round_rows:
verdict = "—" if r.passed is None else ("pass" if r.passed else "fail")
build = "—" if r.build_ok is None else ("ok" if r.build_ok else "failed")
gates = str(r.gate_errors) + (" (" + ", ".join(f"{k}:{v}" for k, v in r.gates.items()) + ")" if r.gates else "")
- sheet = f"<a href='{esc(urls.file(entry, r.sheet))}'>sheet</a>" if r.sheet else "—"
+ sheet = f"<a href='{esc(urls.file(entry, r.sheet))}'>all views</a>" if r.sheet else "—"
best = " class='best'" if r.index == entry.best_round else ""
rows.append(f"<tr{best}><td class='n'>{r.index}</td><td>{esc(r.kind)}</td>"
f"<td class='n'>{_fmt(r.score)}</td><td>{verdict}</td><td class='n'>{esc(gates)}</td>"
@@ -122,9 +152,11 @@ def _judgment_panel(rec: RunRecord, best: int | None) -> str:
anchor="judge")
scores = "".join(_kv(k, f"{v:.3f}") for k, v in sorted(j.scores.items()))
issues = "".join(
- f"<li><b>{esc(i.severity)}</b> · {esc(i.target)} · {esc(i.kind)} — {esc(i.detail)}"
+ f"<li><span class='tag {SEVERITY_CLASS.get(str(i.severity).lower(), '')}'>{esc(i.severity)}</span>"
+ f" <b>{esc(i.target)}</b> · {esc(i.kind)} — {esc(i.detail)}"
+ (f" <span class='faint'>[{esc(i.evidence)}]</span>" if i.evidence else "") + "</li>"
- for i in j.issues) or "<li class='faint'>none reported</li>"
+ for i in sorted(j.issues, key=lambda i: SEVERITY_ORDER.get(str(i.severity).lower(), 9))
+ ) or "<li class='faint'>none reported</li>"
plan = "".join(f"<li><b>p{it.priority}</b> {esc(it.target)} — {esc(it.instruction)}</li>"
for it in sorted(j.improvement_plan, key=lambda i: i.priority)) or "<li class='faint'>none</li>"
strengths = "".join(f"<li>{esc(s)}</li>" for s in j.strengths)
@@ -180,19 +212,17 @@ def _renders_panel(entry: RunEntry, urls: UrlMaker, rec: RunRecord, best: int |
for v in rnd.renders.views:
rel = _rel(run, v.path)
if rel and (run / rel).is_file():
- label = v.name + (f" · t={v.time_s:g}s" if v.time_s is not None else "")
- figs.append((label, rel))
- extra = [(link.label, link.rel) for link in entry.links
+ figs.append((v.name, rel))
+ figs += [(link.label, link.rel) for link in entry.links
if link.label in ("articulation", "preview.gif") and link.rel]
- for label, rel in extra:
- figs.append((label, rel))
if not figs:
return ""
- cells = "".join(
- f"<figure><a href='{esc(urls.file(entry, rel))}'>"
- f"<img loading='lazy' src='{esc(urls.file(entry, rel))}' alt='{esc(label)}'></a>"
- f"<figcaption>{esc(label)}</figcaption></figure>" for label, rel in figs)
- return _panel(f"renders ({len(figs)})", f"<div class='shots'>{cells}</div>", anchor="renders")
+ cells = "".join(gallery_figure(label, urls.file(entry, rel), urls.file(entry, rel))
+ for label, rel in figs)
+ sheet = (f" <a class='small' href='{esc(urls.file(entry, entry.sheet))}'>· contact sheet</a>"
+ if entry.sheet else "")
+ return _panel(f"renders ({len(figs)})", f"<div class='shots'>{cells}</div>",
+ anchor="renders", extra_head=sheet)
def _cost_panel(entry: RunEntry, ws: Workspace, rec: RunRecord) -> str:
@@ -257,31 +287,74 @@ def _code_panel(entry: RunEntry, urls: UrlMaker, rec: RunRecord) -> str:
# --------------------------------------------------------------------------- page
-def render_detail(entry: RunEntry, urls: UrlMaker, ws: Workspace, rec: RunRecord) -> str:
+def _neighbours(urls: UrlMaker, prev: RunEntry | None, nxt: RunEntry | None) -> str:
+ """Triage is sequential: the next bad run is one click away, not a trip home."""
+ def one(target: RunEntry | None, glyph: str, side: str, ident: str) -> str:
+ if target is None:
+ return f"<span class='btn dead' aria-hidden='true'>{glyph}</span>"
+ label = target.title or target.slug
+ return (f"<a class='btn' id='{ident}' href='{esc(urls.detail(target))}' "
+ f"title='{side} run in this battery: {esc(label)} (arrow key)'>{glyph}</a>")
+ return (f"<span class='neighbours'>{one(prev, '← prev', 'previous', 'nav-prev')}"
+ f"{one(nxt, 'next →', 'next', 'nav-next')}</span>")
+
+
+def _foot_nav(urls: UrlMaker, prev: RunEntry | None, nxt: RunEntry | None) -> str:
+ """The same walk, repeated where the reader actually finishes reading."""
+ def one(target: RunEntry | None, glyph: str) -> str:
+ if target is None:
+ return "<span></span>"
+ return (f"<a class='btn' href='{esc(urls.detail(target))}'>{glyph} "
+ f"{esc(target.title or target.slug)}</a>")
+ if prev is None and nxt is None:
+ return ""
+ return f"<nav class='footnav'>{one(prev, '←')}{one(nxt, '→')}</nav>"
+
+
+#: ← / → walk the battery; typing in a field is never hijacked
+NEIGHBOUR_JS = """
+(function(){var p=document.getElementById('nav-prev'),n=document.getElementById('nav-next');
+document.addEventListener('keydown',function(e){
+ var t=e.target||{}; if(t.tagName==='INPUT'||t.tagName==='TEXTAREA'||t.tagName==='SELECT') return;
+ if(e.metaKey||e.ctrlKey||e.altKey) return;
+ if(e.key==='ArrowLeft'&&p&&p.href) location.href=p.href;
+ if(e.key==='ArrowRight'&&n&&n.href) location.href=n.href;
+});})();
+"""
+
+
+def render_detail(entry: RunEntry, urls: UrlMaker, ws: Workspace, rec: RunRecord, *,
+ prev: RunEntry | None = None, nxt: RunEntry | None = None) -> str:
"""Full detail page for a run whose record parsed."""
best = entry.best_round
if not entry.sheet:
entry = entry.model_copy(update={"sheet": best_sheet(ws, rec)})
- nav = " · ".join(f"<a href='#{a}'>{a}</a>" for a in
- ("rounds", "judge", "measurement", "renders", "cost", "code"))
+ if not entry.hero:
+ hero, label, n = hero_view(ws, rec, best)
+ entry = entry.model_copy(update={"hero": hero, "hero_label": label, "n_views": n})
+ nav = "".join(f"<a href='#{a}'>{a}</a>" for a in
+ ("rounds", "judge", "measurement", "renders", "cost", "code"))
body = (
top_bar("3dcv gallery",
crumbs=f"<a href='/'>gallery</a> <span class='faint'>/</span> "
f"<a href='/?battery={esc(entry.battery)}'>{esc(entry.battery)}</a> "
- f"<span class='faint'>/</span> <b>{esc(entry.slug)}</b>")
+ f"<span class='faint'>/</span> <b>{esc(entry.slug)}</b>",
+ right=_neighbours(urls, prev, nxt) if urls.has_detail else "")
+ "<main class='wrap'>"
+ _hero(entry, urls, rec)
- + f"<p class='small muted' style='margin-top:var(--s-4)'>jump to: {nav}</p>"
+ + f"<nav class='jump' aria-label='sections'>{nav}</nav>"
+ _rounds_table(entry, urls)
+ _judgment_panel(rec, best)
+ _measurement_panel(rec, best)
+ _renders_panel(entry, urls, rec, best)
+ _cost_panel(entry, ws, rec)
+ _code_panel(entry, urls, rec)
+ + (_foot_nav(urls, prev, nxt) if urls.has_detail else "")
+ "</main>"
+ footer(f"{entry.path} · record.json re-read on every request")
)
- return page_shell(f"{entry.slug} — 3dcv gallery", body, extra_css=DETAIL_CSS)
+ return page_shell(f"{entry.slug} — 3dcv gallery", body, extra_css=DETAIL_CSS,
+ scripts=NEIGHBOUR_JS)
def render_broken_detail(entry: RunEntry, urls: UrlMaker) -> str:
diff --git a/harness/codeverse/gallery/model.py b/harness/codeverse/gallery/model.py
index 49e87e46..ef37b2db 100644
--- a/harness/codeverse/gallery/model.py
+++ b/harness/codeverse/gallery/model.py
@@ -131,7 +131,7 @@ class RunEntry(BaseModel):
return {
"key": self.key, "battery": self.battery, "slug": self.slug, "name": self.title or self.slug,
"track": self.track, "lang": self.language, "backend": self.generator, "tier": self.tier,
- "pass": self.pass_state, "verdict": self.verdict, "score": self.score,
+ "pass": self.pass_state, "verdict": self.verdict, "score": self.score, "path": self.path,
"cost": round(self.cost_usd, 6), "minutes": self.minutes, "state": self.state,
"text": self.search_text(),
}
diff --git a/harness/codeverse/gallery/page.py b/harness/codeverse/gallery/page.py
index c5c09676..c5d74424 100644
--- a/harness/codeverse/gallery/page.py
+++ b/harness/codeverse/gallery/page.py
@@ -1,16 +1,23 @@
-"""The index page: summary strip, filters, per-battery sections, cards + table.
+"""The index page: status rail, filters, per-battery sections, cards + table.
Rendered identically for the local server and the static build — the only
difference is the :class:`~codeverse.gallery.urls.UrlMaker` it is handed. The
initial filter is applied **server-side** (so ``curl '/?track=graphics'`` and a
no-JS browser both see the right runs and the right summary) and then re-applied
client-side on every keystroke without a reload.
+
+The summary is a *breakdown*, not a scoreboard: four disjoint buckets that add up
+to the number of runs on screen (``89 shown = 40 passed + 40 failed + 4 unjudged
++ 5 error``). "pass 50% (40/80), not ok 5" against "89 runs" is arithmetic the
+reader has to do — and cannot.
"""
from __future__ import annotations
import json
+from codeverse.gallery.cards import TABLE_HEAD, render_card, render_row
+from codeverse.gallery.labels import VERDICT_META, VERDICTS
from codeverse.gallery.model import (
FILTER_KEYS,
GalleryIndex,
@@ -20,173 +27,121 @@ from codeverse.gallery.model import (
summarize,
)
from codeverse.gallery.scripts import INDEX_JS
-from codeverse.gallery.theme import esc, footer, page_shell, top_bar
+from codeverse.gallery.theme import INDEX_CSS, esc, footer, page_shell, top_bar
from codeverse.gallery.urls import UrlMaker
-INDEX_CSS = """
-.tablewrap{display:none}
-body.view-table .grid{display:none}
-body.view-table .tablewrap{display:block}
-body.view-table section.battery > .rootpath{margin-bottom:var(--s-2)}
-.card.broken .body{gap:8px}
-"""
-
def _fmt(value: float | None, digits: int = 3, dash: str = "—") -> str:
return dash if value is None else format(value, f".{digits}f")
-def _tier_tag(entry: RunEntry) -> str:
- return f"<span class='tag tier {esc(entry.tier)}' title='quality tier'>{esc(entry.tier)}</span>"
-
-
-def _pass_tag(entry: RunEntry) -> str:
- if entry.passed is None:
- return "<span class='tag' title='never judged'>unjudged</span>"
- cls = "pill-pass" if entry.passed else "pill-fail"
- return f"<span class='tag {cls}'>{'passed' if entry.passed else 'failed'}</span>"
-
-
-def _links_html(entry: RunEntry, urls: UrlMaker) -> str:
- parts = []
- if urls.has_detail:
- parts.append(f"<a href='{esc(urls.detail(entry))}'><b>detail</b></a>")
- parts += [f"<a href='{esc(urls.link(entry, link))}'>{esc(link.label)}</a>" for link in entry.links]
- return "<div class='links'>" + "".join(parts) + "</div>"
-
-
-def _shot(entry: RunEntry, urls: UrlMaker) -> str:
- if not entry.sheet:
- return "<div class='shot'><div class='noshot'>no render</div></div>"
- href = urls.file(entry, entry.sheet)
- alt = f"contact sheet — {entry.slug}"
- return (f"<a class='shot' href='{esc(href)}' title='open the full-size sheet'>"
- f"<img loading='lazy' decoding='async' src='{esc(urls.img(entry, entry.sheet))}' alt='{esc(alt)}'></a>")
-
-
-def render_card(entry: RunEntry, urls: UrlMaker, *, hidden: bool = False) -> str:
- """One run card. A pending / broken run keeps the same shape and says why.
-
- ``hidden`` pre-applies the server-side filter, so a curl'd query string shows
- the right runs while the client can still widen the filter without a reload."""
- hide = " is-hidden" if hidden else ""
- name = entry.title or entry.slug
- title_href = urls.detail(entry)
- head = (f"<div class='titlerow'>{_tier_tag(entry)}"
- f"<a class='name' href='{esc(title_href)}'>{esc(name)}</a>"
- f"<span class='score num' title='best score'>{_fmt(entry.score)}</span></div>")
- if entry.state != "ok":
- body = (f"{head}<div class='err'>{esc(entry.state)}: {esc(entry.error)}</div>"
- f"<p class='prompt'>{esc(entry.prompt)}</p>{_links_html(entry, urls)}")
- return (f"<article class='card broken na{hide}' data-run='{esc(entry.key)}'>"
- f"<div class='body'>{body}</div></article>")
- tags = "".join(f"<span class='tag'>{esc(t)}</span>" for t in (entry.track, entry.language, entry.generator) if t)
- delta = ""
- if entry.baseline_score is not None and entry.score is not None:
- delta = f" <span class='faint'>({entry.score - entry.baseline_score:+.3f})</span>"
- best = f"r{entry.best_round}" if entry.best_round is not None else "r–"
- facts2 = (f"<span>baseline {_fmt(entry.baseline_score)} → best {_fmt(entry.score)}{delta}</span>"
- f"<span>{best} of {entry.rounds} round{'' if entry.rounds == 1 else 's'}</span>")
- gates = (f"<span class='tag pill-warn'>{entry.gate_errors} gate err</span>" if entry.gate_errors
- else "<span class='tag'>gates clean</span>")
- money = (f"${entry.cost_usd:.2f}" + (f" · {entry.minutes:.1f} min" if entry.minutes is not None else ""))
- # the run status only earns a chip when it says something the verdict does not
- # ("passed" next to a green `passed` pill is noise; "plateau"/"budget"/"failed" is not)
- redundant = not entry.status or (entry.passed and entry.status == "passed")
- status = "" if redundant else f"<span class='tag'>{esc(entry.status)}</span>"
- caption = f"<p class='xs faint'>{esc(entry.caption)}</p>" if entry.caption else ""
- err = f"<div class='err'>{esc(entry.error[:300])}</div>" if entry.error else ""
- return (
- f"<article class='card {entry.pass_state}{hide}' data-run='{esc(entry.key)}'>"
- f"{_shot(entry, urls)}"
- f"<div class='body'>{head}"
- f"<p class='prompt' title='{esc(entry.prompt)}'>{esc(entry.prompt)}</p>{caption}"
- f"<div class='facts'>{tags}</div>"
- f"<div class='facts small'>{facts2}</div>"
- f"<div class='facts'>{_pass_tag(entry)}{gates}<span class='tag'>{esc(money)}</span>{status}</div>"
- f"{err}{_links_html(entry, urls)}</div></article>"
- )
-
+# --------------------------------------------------------------------------- summary
+def _verdict_chip(bucket: str, count: int, *, total: int) -> str:
+ label, cls, why = VERDICT_META[bucket]
+ pct = f"{round(100 * count / total)}%" if total else "0%"
+ return (f"<button type='button' class='vchip {cls}' data-verdict='{bucket}' "
+ f"aria-pressed='false' title='{esc(why)} — click to show only these'>"
+ f"<b class='num' id='vc-{bucket}'>{count}</b> {esc(label)}"
+ f"<span class='pct num' id='vp-{bucket}'>{pct}</span></button>")
-TABLE_HEAD = ("<tr><th>run</th><th>track</th><th>lang</th><th>backend</th><th>tier</th>"
- "<th class='n'>base</th><th class='n'>best</th><th class='n'>Δ</th><th class='n'>gates</th>"
- "<th class='n'>$</th><th class='n'>min</th><th>status</th><th>links</th></tr>")
+def _summary_strip(entries: list[RunEntry], total: int) -> str:
+ """One compact rail: how many runs, what happened to them, what they cost.
-def render_row(entry: RunEntry, urls: UrlMaker, *, hidden: bool = False) -> str:
- delta = (entry.score - entry.baseline_score
- if entry.score is not None and entry.baseline_score is not None else None)
- links = " ".join(f"<a href='{esc(urls.link(entry, link))}'>{esc(link.label)}</a>"
- for link in entry.links if link.label in ("workspace", "src/", "sheet", "glb"))
+ Deliberately ~1/3 the height of the old 7-tile grid — on a 900 px laptop the
+ first row of runs has to be visible without scrolling."""
+ s = summarize(entries)
+ segs = "".join(
+ f"<span class='seg {VERDICT_META[b][1]}' id='vs-{b}' style='flex:{s.breakdown[b]}'"
+ f" title='{s.breakdown[b]} {b}'></span>" for b in VERDICTS)
+ chips = "".join(_verdict_chip(b, s.breakdown[b], total=s.n) for b in VERDICTS)
+ per_pass = "—" if s.usd_per_pass is None else f"${s.usd_per_pass:.2f}"
+ nums = (f"<span title='mean / median best score'>score <b class='num' id='s-score'>"
+ f"{_fmt(s.mean_score)} / {_fmt(s.median_score)}</b></span>"
+ f"<span>spend <b class='num' id='s-cost'>${s.total_usd:.2f}</b></span>"
+ f"<span title='total spend divided by the number of passing runs'>per pass "
+ f"<b class='num' id='s-perpass'>"
+ f"{per_pass}</b></span>"
+ f"<span>wall clock <b class='num' id='s-time'>"
+ f"{(f'{s.minutes / 60:.1f} h' if s.minutes >= 90 else f'{round(s.minutes)} min')}</b></span>")
+ shown = f"{s.n}" if s.n == total else f"{s.n} <span class='faint'>of {total}</span>"
return (
- f"<tr class='{'is-hidden' if hidden else ''}' data-run='{esc(entry.key)}'>"
- f"<td class='wide'><a href='{esc(urls.detail(entry))}'>{esc(entry.title or entry.slug)}</a>"
- f"<div class='xs faint'>{esc(entry.slug)}</div></td>"
- f"<td>{esc(entry.track)}</td><td>{esc(entry.language)}</td><td>{esc(entry.generator)}</td>"
- f"<td>{_tier_tag(entry)}</td>"
- f"<td class='n'>{_fmt(entry.baseline_score)}</td><td class='n'>{_fmt(entry.score)}</td>"
- f"<td class='n'>{'—' if delta is None else format(delta, '+.3f')}</td>"
- f"<td class='n'>{entry.gate_errors}</td><td class='n'>{entry.cost_usd:.2f}</td>"
- f"<td class='n'>{_fmt(entry.minutes, 1)}</td>"
- f"<td>{esc(entry.status or entry.state)}</td><td>{links}</td></tr>"
+ "<section class='summary' aria-label='status breakdown'>"
+ f"<div class='sumn'><b class='num' id='s-n'>{shown}</b> runs shown"
+ f"<span class='eq faint'>=</span></div>"
+ f"<div class='vchips' id='vchips'>{chips}</div>"
+ f"<div class='vbar' id='vbar' aria-hidden='true'>{segs}</div>"
+ f"<div class='sumnums'>{nums}</div></section>"
)
+# --------------------------------------------------------------------------- controls
def _select(name: str, label: str, options: list[str], value: str, *, any_label: str = "all") -> str:
opts = [f"<option value=''>{esc(any_label)}</option>"]
- opts += [f"<option value='{esc(o)}'{' selected' if o == value else ''}>{esc(o)}</option>" for o in options]
- return (f"<label for='f-{name}'>{esc(label)}"
+ opts += [f"<option value='{esc(o)}'{' selected' if o == value else ''}>{esc(o)}</option>"
+ for o in options]
+ return (f"<label class='fld' for='f-{name}'><span class='flab'>{esc(label)}</span>"
f"<select id='f-{name}' name='{name}'>{''.join(opts)}</select></label>")
def _controls(index: GalleryIndex, flt: dict[str, str], sort: str) -> str:
facets = index.facets()
q = esc(flt.get("q", ""))
- parts = [
- f"<label for='f-q'>search<input type='search' id='f-q' name='q' value='{q}' "
- f"placeholder='prompt, slug, model… (/)' autocomplete='off'></label>",
+ fields = [
+ f"<label class='fld grow' for='f-q'><span class='flab'>search</span>"
+ f"<input type='search' id='f-q' name='q' value='{q}' "
+ f"placeholder='prompt, slug, model… (press /)' autocomplete='off'></label>",
_select("track", "track", facets["track"], flt.get("track", "")),
_select("lang", "language", facets["lang"], flt.get("lang", "")),
- _select("tier", "tier", facets["tier"], flt.get("tier", "")),
_select("backend", "backend", facets["backend"], flt.get("backend", "")),
- _select("pass", "verdict", ["pass", "fail", "na"], flt.get("pass", ""), any_label="any"),
+ _select("tier", "tier", facets["tier"], flt.get("tier", "")),
+ _select("verdict", "verdict", list(VERDICTS), flt.get("verdict", ""), any_label="any"),
_select("battery", "battery", facets["battery"], flt.get("battery", "")),
_select("sort", "sort", ["score", "cost", "time", "name"], sort, any_label="score"),
- "<button class='btn' id='f-reset' type='button'>reset</button>",
+ "<label class='fld'><span class='flab'>&nbsp;</span>"
+ "<button class='btn' id='f-reset' type='button'>reset</button></label>",
]
- return f"<form class='controls' onsubmit='return false'>{''.join(parts)}</form>"
+ active = sum(1 for k in FILTER_KEYS if flt.get(k))
+ badge = (f"<span class='tag pill-accent{'' if active else ' is-hidden'}' id='f-count'>"
+ f"{active}</span><span class='factive' id='f-active'></span>")
+ return (f"<details class='filters' id='filters' open><summary>filters {badge}</summary>"
+ f"<form class='controls' onsubmit='return false'>{''.join(fields)}</form></details>")
-STATS = (("s-n", "runs"), ("s-pass", "pass rate"), ("s-score", "mean / median"), ("s-cost", "total $"),
- ("s-perpass", "$ per pass"), ("s-time", "wall clock"), ("s-broken", "not ok"))
+# --------------------------------------------------------------------------- bulk bar
+def _bulk_bar() -> str:
+ """Multi-select actions. It is on screen from the start (greyed out) because a
+ bulk action nobody can see is a bulk action nobody uses.
-
-def _summary_strip(entries: list[RunEntry], total: int) -> str:
- s = summarize(entries)
- values = {
- "s-n": str(s.n) if s.n == total else f"{s.n} / {total}",
- "s-pass": f"{round(100 * s.pass_rate)}% ({s.n_passed}/{s.n_judged})" if s.pass_rate is not None else "—",
- "s-score": f"{_fmt(s.mean_score)} / {_fmt(s.median_score)}",
- "s-cost": f"${s.total_usd:.2f}",
- "s-perpass": f"${s.usd_per_pass:.2f}" if s.usd_per_pass is not None else "—",
- "s-time": f"{s.minutes / 60:.1f} h" if s.minutes >= 90 else f"{round(s.minutes)} min",
- "s-broken": str(s.broken),
- }
- cells = "".join(f"<div class='stat'><div class='k'>{esc(label)}</div>"
- f"<div class='v num' id='{sid}'>{esc(values[sid])}</div></div>" for sid, label in STATS)
- return f"<div class='strip'>{cells}</div>"
+ Compare / export / copy paths only: this server has no mutation route at all,
+ so a "re-run" button would be a lie."""
+ return (
+ "<div class='selbar empty' id='selbar' role='region' aria-label='bulk actions'>"
+ "<span class='selcount'><b class='num' id='sel-n'>0</b> selected"
+ "<span class='xs' id='sel-hint'> — tick a card or row</span></span>"
+ "<a class='btn primary' id='sel-compare' href='/compare'>compare →</a>"
+ "<a class='btn' id='sel-csv' href='/export.csv'>export csv</a>"
+ "<button class='btn' type='button' id='sel-paths'>copy paths</button>"
+ "<button class='btn' type='button' id='sel-all'>select all shown</button>"
+ "<button class='btn' type='button' id='sel-clear'>clear</button>"
+ "<span class='xs faint selnote'>read-only · no re-run from the browser</span></div>"
+ )
+# --------------------------------------------------------------------------- sections
def _section(label: str, path: str, entries: list[RunEntry], hidden: set[str], urls: UrlMaker) -> str:
cards = "".join(render_card(e, urls, hidden=e.key in hidden) for e in entries)
rows = "".join(render_row(e, urls, hidden=e.key in hidden) for e in entries)
visible = sum(1 for e in entries if e.key not in hidden)
return (
f"<section class='battery{'' if visible else ' is-hidden'}' id='b-{esc(label)}'>"
- f"<h2>{esc(label)} <span class='count' data-count>{visible} run{'' if visible == 1 else 's'}</span></h2>"
- f"<div class='rootpath'>{esc(path)}</div>"
+ f"<h2>{esc(label)} <span class='count' data-count>{visible} run{'' if visible == 1 else 's'}</span>"
+ f"<span class='rootpath'>{esc(path)}</span></h2>"
f"<div class='grid' data-items>{cards}</div>"
- f"<div class='tablewrap'><table><thead>{TABLE_HEAD}</thead>"
+ f"<div class='tablewrap'><div class='narrowhint xs faint'>narrow screen — "
+ f"thumbnail, backend, baseline, Δ, tier, minutes and links are hidden — switch to cards or widen the window"
+ f"</div>"
+ f"<table><thead>{TABLE_HEAD}</thead>"
f"<tbody data-items>{rows}</tbody></table></div></section>"
)
@@ -205,8 +160,8 @@ def render_index(index: GalleryIndex, urls: UrlMaker, *, title: str = "3dcv gall
for s in index.sections if s.entries)
if not sections:
sections = "<div class='empty'>no runs found under the given roots</div>"
- empty = ("<div class='empty is-hidden' id='empty'>nothing matches this filter</div>"
- if selected else "<div class='empty' id='empty'>nothing matches this filter</div>")
+ empty = (f"<div class='empty{'' if not selected else ' is-hidden'}' id='empty'>"
+ "nothing matches this filter</div>")
right = (f"<button class='btn' id='view-btn' type='button' aria-pressed='{'true' if view == 'table' else 'false'}'>"
f"{'▤ table' if view == 'table' else '▦ cards'}</button>")
body = (
@@ -216,6 +171,7 @@ def render_index(index: GalleryIndex, urls: UrlMaker, *, title: str = "3dcv gall
+ _summary_strip(selected, len(all_entries))
+ _controls(index, flt, sort)
+ sections + empty + "</main>"
+ + (_bulk_bar() if urls.has_detail else "")
+ footer(f"built in {index.build_ms} ms · {index.built_at:%Y-%m-%d %H:%M UTC} · "
f"roots: {', '.join(index.roots)}")
)
diff --git a/harness/codeverse/gallery/scripts.py b/harness/codeverse/gallery/scripts.py
index 402f13a2..029c8557 100644
--- a/harness/codeverse/gallery/scripts.py
+++ b/harness/codeverse/gallery/scripts.py
@@ -1,10 +1,16 @@
"""The gallery's client-side behaviour — plain ES5-ish JS, no dependencies.
The page ships its run table as JSON in a ``<script type="application/json">``
-block; filtering, sorting, the per-section counts and the whole summary strip are
-recomputed from that array on every input event. Nothing here fetches: a filter
-change never reloads the page, and the URL is kept in sync with
-``history.replaceState`` so a filtered view can be copied, bookmarked or curled.
+block; filtering, sorting, the per-section counts, the status breakdown and the
+bulk-selection bar are all recomputed from that array on every input event.
+Nothing here fetches: a filter change never reloads the page, and the URL is kept
+in sync with ``history.replaceState`` so a filtered view can be copied,
+bookmarked or curled.
+
+The bulk bar is deliberately read-only. ``compare`` and ``export csv`` are links
+to real server routes (so they work in a new tab, and without JS if you build the
+query by hand); ``copy paths`` writes to the clipboard. There is no "re-run"
+because there is no route that would run anything — see ``gallery/compare.py``.
"""
from __future__ import annotations
@@ -14,10 +20,13 @@ INDEX_JS = r"""
var node=document.getElementById('gallery-data');
if(!node) return;
var DATA=JSON.parse(node.textContent);
-var KEYS=['q','track','lang','tier','backend','pass','battery'];
+var KEYS=['q','track','lang','tier','backend','pass','verdict','battery'];
+var BUCKETS=['passed','failed','unjudged','error'];
var els={};
KEYS.concat(['sort']).forEach(function(k){els[k]=document.getElementById('f-'+k);});
var F={};
+var picked={};
+var filters=document.getElementById('filters');
function readControls(){
KEYS.forEach(function(k){F[k]=els[k]?String(els[k].value||'').trim():'';});
@@ -29,6 +38,7 @@ function match(r){
if(F.tier && r.tier!==F.tier) return false;
if(F.backend && r.backend!==F.backend) return false;
if(F.pass && r.pass!==F.pass) return false;
+ if(F.verdict && r.verdict!==F.verdict) return false;
if(F.battery && r.battery!==F.battery) return false;
return true;
}
@@ -44,25 +54,56 @@ function cmp(a,b){
function fmt(v,d){return (v===null||v===undefined)?'—':Number(v).toFixed(d);}
function set(id,txt){var e=document.getElementById(id); if(e) e.textContent=txt;}
+/* the strip's promise: the four buckets always add up to the runs on screen */
function summarize(rows){
- var scored=[],total=0,mins=0,judged=0,passed=0,broken=0;
+ var scored=[],total=0,mins=0,passed=0;
+ var b={passed:0,failed:0,unjudged:0,error:0};
rows.forEach(function(r){
if(typeof r.score==='number') scored.push(r.score);
total+=r.cost||0; mins+=r.minutes||0;
- if(r.pass!=='na'){judged++; if(r.pass==='pass') passed++;}
- if(r.state!=='ok') broken++;
+ if(b[r.verdict]===undefined) b[r.verdict]=0;
+ b[r.verdict]++;
+ if(r.verdict==='passed') passed++;
});
- var mean=scored.length?scored.reduce(function(a,b){return a+b;},0)/scored.length:null;
- var srt=scored.slice().sort(function(a,b){return a-b;});
+ var mean=scored.length?scored.reduce(function(a,c){return a+c;},0)/scored.length:null;
+ var srt=scored.slice().sort(function(a,c){return a-c;});
var med=null;
if(srt.length) med=srt.length%2?srt[(srt.length-1)/2]:(srt[srt.length/2-1]+srt[srt.length/2])/2;
- set('s-n', rows.length===DATA.length?String(rows.length):rows.length+' / '+DATA.length);
- set('s-pass', judged?Math.round(100*passed/judged)+'% ('+passed+'/'+judged+')':'—');
- set('s-score', fmt(mean,3)+' / '+fmt(med,3));
+ var n=document.getElementById('s-n');
+ if(n) n.innerHTML=rows.length===DATA.length?String(rows.length)
+ :(rows.length+" <span class='faint'>of "+DATA.length+"</span>");
+ BUCKETS.forEach(function(k){
+ set('vc-'+k,String(b[k]));
+ set('vp-'+k,(rows.length?Math.round(100*b[k]/rows.length):0)+'%');
+ var seg=document.getElementById('vs-'+k);
+ if(seg){ seg.style.flex=String(b[k]); seg.title=b[k]+' '+k; }
+ });
+ set('s-score', fmt(mean,3)+' / '+fmt(med,3));
set('s-cost', '$'+total.toFixed(2));
set('s-perpass', passed?'$'+(total/passed).toFixed(2):'—');
set('s-time', mins>=90?(mins/60).toFixed(1)+' h':Math.round(mins)+' min');
- set('s-broken', String(broken));
+}
+
+function paintChips(){
+ var chips=document.querySelectorAll('.vchip');
+ for(var i=0;i<chips.length;i++)
+ chips[i].setAttribute('aria-pressed', chips[i].getAttribute('data-verdict')===F.verdict?'true':'false');
+ var badge=document.getElementById('f-count'), active=document.getElementById('f-active');
+ var n=0;
+ KEYS.forEach(function(k){ if(F[k]) n++; });
+ if(badge){ badge.textContent=String(n); badge.classList.toggle('is-hidden',n===0); }
+ /* the collapsed accordion still has to say what is being hidden */
+ if(active){
+ active.textContent='';
+ var closed=filters && !filters.hasAttribute('open');
+ KEYS.forEach(function(k){
+ if(!F[k] || !closed) return;
+ var chip=document.createElement('span');
+ chip.className='tag';
+ chip.textContent=(k==='q'?'search':k)+': '+F[k];
+ active.appendChild(chip);
+ });
+ }
}
function apply(){
@@ -70,10 +111,8 @@ function apply(){
var keep={},rows=[];
DATA.forEach(function(r){ if(match(r)){keep[r.key]=1; rows.push(r);} });
var all=document.querySelectorAll('[data-run]');
- for(var i=0;i<all.length;i++){
- var hide=!keep[all[i].getAttribute('data-run')];
- all[i].classList.toggle('is-hidden',hide);
- }
+ for(var i=0;i<all.length;i++)
+ all[i].classList.toggle('is-hidden',!keep[all[i].getAttribute('data-run')]);
rows.sort(cmp);
var order={};
rows.forEach(function(r,i){order[r.key]=i;});
@@ -97,6 +136,7 @@ function apply(){
var empty=document.getElementById('empty');
if(empty) empty.classList.toggle('is-hidden',rows.length>0);
summarize(rows);
+ paintChips();
syncUrl();
}
@@ -109,11 +149,61 @@ function syncUrl(){
try{ history.replaceState(null,'',qs?('?'+qs):location.pathname); }catch(e){}
}
+/* ------------------------------------------------------------------ selection */
+function selKeys(){
+ return DATA.filter(function(r){return picked[r.key];}).map(function(r){return r.key;});
+}
+function paintSelection(){
+ var keys=selKeys(), bar=document.getElementById('selbar');
+ set('sel-n',String(keys.length));
+ if(bar) bar.classList.toggle('empty',keys.length===0);
+ var hint=document.getElementById('sel-hint');
+ if(hint) hint.classList.toggle('is-hidden',keys.length>0);
+ var boxes=document.querySelectorAll('input.sel');
+ for(var i=0;i<boxes.length;i++){
+ var k=boxes[i].getAttribute('data-key'), on=!!picked[k];
+ boxes[i].checked=on;
+ var host=boxes[i].closest('[data-run]');
+ if(host) host.classList.toggle('picked',on);
+ }
+ var qs='?runs='+encodeURIComponent(keys.join(','));
+ var c=document.getElementById('sel-compare'); if(c) c.href='/compare'+qs;
+ var x=document.getElementById('sel-csv'); if(x) x.href='/export.csv'+qs;
+}
+document.addEventListener('change',function(e){
+ var t=e.target;
+ if(!t || !t.classList || !t.classList.contains('sel')) return;
+ var k=t.getAttribute('data-key');
+ if(t.checked) picked[k]=1; else delete picked[k];
+ paintSelection();
+});
+function on(id,fn){var e=document.getElementById(id); if(e) e.addEventListener('click',fn);}
+on('sel-clear',function(){picked={};paintSelection();});
+on('sel-all',function(){
+ DATA.forEach(function(r){ if(match(r)) picked[r.key]=1; });
+ paintSelection();
+});
+on('sel-paths',function(e){
+ var btn=e.currentTarget;
+ var paths=DATA.filter(function(r){return picked[r.key];}).map(function(r){return r.path;}).join('\n');
+ var done=function(ok){ btn.textContent=ok?'copied':'copy failed';
+ setTimeout(function(){btn.textContent='copy paths';},1400); };
+ try{
+ navigator.clipboard.writeText(paths).then(function(){done(true);},function(){done(false);});
+ }catch(err){ done(false); }
+});
+
+/* ------------------------------------------------------------------ controls */
KEYS.concat(['sort']).forEach(function(k){
if(!els[k]) return;
els[k].addEventListener('input',apply);
els[k].addEventListener('change',apply);
});
+var chips=document.querySelectorAll('.vchip');
+for(var i=0;i<chips.length;i++) chips[i].addEventListener('click',function(e){
+ var want=e.currentTarget.getAttribute('data-verdict');
+ if(els.verdict){ els.verdict.value=(els.verdict.value===want)?'':want; apply(); }
+});
var reset=document.getElementById('f-reset');
if(reset) reset.addEventListener('click',function(){
KEYS.forEach(function(k){ if(els[k]) els[k].value=''; });
@@ -127,9 +217,24 @@ if(vb) vb.addEventListener('click',function(){
vb.textContent=on?'▤ table':'▦ cards';
syncUrl();
});
+/* a phone has no room for eight drop-downs above the first run */
+if(filters){
+ if(window.innerWidth<760) filters.removeAttribute('open');
+ filters.addEventListener('toggle',paintChips);
+}
+/* one open pop-up at a time */
+document.addEventListener('click',function(e){
+ var open=document.querySelectorAll('details.menu[open],details.views[open]');
+ for(var i=0;i<open.length;i++) if(!open[i].contains(e.target)) open[i].removeAttribute('open');
+});
document.addEventListener('keydown',function(e){
if(e.key==='/' && document.activeElement!==els.q && els.q){ e.preventDefault(); els.q.focus(); }
+ if(e.key==='Escape'){
+ var open=document.querySelectorAll('details.menu[open],details.views[open]');
+ for(var i=0;i<open.length;i++) open[i].removeAttribute('open');
+ }
});
apply();
+paintSelection();
})();
"""
diff --git a/harness/codeverse/gallery/server.py b/harness/codeverse/gallery/server.py
index f04278fb..b985a139 100644
--- a/harness/codeverse/gallery/server.py
+++ b/harness/codeverse/gallery/server.py
@@ -32,6 +32,7 @@ from urllib.parse import parse_qs, unquote, urlsplit
from codeverse._compat import UTC
from codeverse.gallery import code as code_page
from codeverse.gallery import viewer as viewer_page
+from codeverse.gallery.compare import MAX_COMPARE, export_csv, parse_keys, render_compare
from codeverse.gallery.detail import render_broken_detail, render_detail
from codeverse.gallery.index import build_index
from codeverse.gallery.model import FILTER_KEYS, RunEntry, match, sort_entries
@@ -86,6 +87,11 @@ class Response:
def text(cls, text: str, status: int = 200) -> Response:
return cls(status=status, content_type="text/plain; charset=utf-8", body=text.encode("utf-8"))
+ @classmethod
+ def csv(cls, text: str, filename: str = "runs.csv") -> Response:
+ return cls(content_type="text/csv; charset=utf-8", body=text.encode("utf-8"),
+ headers={"Content-Disposition": f'attachment; filename="{filename}"'})
+
def _error_page(status: int, title: str, detail: str) -> Response:
body = (top_bar("3dcv gallery", "", crumbs="<a href='/'>gallery</a>")
@@ -129,6 +135,31 @@ class GalleryApp:
flt = self._filters(query)
return sort_entries([e for e in self.index.entries() if match(e, flt)], query.get("sort", "score"))
+ def picked(self, keys: list[str]) -> tuple[list[RunEntry], list[str]]:
+ """``(entries, unknown_keys)`` for ``battery/slug`` keys, in the order given."""
+ found, missing = [], []
+ for key in keys:
+ battery, _, slug = key.partition("/")
+ entry = self._entry(battery, slug) if slug else None
+ if entry is None:
+ missing.append(key)
+ else:
+ found.append(entry)
+ return found, missing
+
+ def _picked(self, query: dict[str, str]) -> tuple[list[RunEntry], UrlMaker, str]:
+ """What ``?runs=`` names, capped, with a note about anything dropped."""
+ self.refresh()
+ keys = parse_keys(query.get("runs", ""))
+ entries, missing = self.picked(keys)
+ notes = []
+ if len(entries) > MAX_COMPARE:
+ notes.append(f"showing the first {MAX_COMPARE} of {len(entries)} selected runs")
+ entries = entries[:MAX_COMPARE]
+ if missing:
+ notes.append("unknown: " + ", ".join(missing[:6]))
+ return entries, self.urls, " · ".join(notes)
+
# ----------------------------------------------------------------- routing
def route(self, path: str, query: dict[str, str] | None = None) -> Response:
"""Decoded ``path`` (``/run/x/y``) + query → a response. Never raises."""
@@ -152,6 +183,12 @@ class GalleryApp:
head, rest = parts[0], parts[1:]
if head == "healthz":
return Response.text("ok")
+ if head == "compare":
+ entries, urls, note = self._picked(query)
+ return Response.html(render_compare(entries, urls, note=note))
+ if head in ("export.csv", "export"):
+ entries, _, _note = self._picked(query)
+ return Response.csv(export_csv(entries or self.selected(query)))
if head == "api":
return self._api(rest, query)
if head == "vendor":
@@ -203,7 +240,22 @@ class GalleryApp:
from codeverse.gallery.index import entry_from_record
fresh = entry_from_record(entry.battery, ws, rec) # newest rounds, even mid-bench
- return Response.html(render_detail(fresh, self.urls, ws, rec))
+ prev, nxt = self.neighbours(entry)
+ return Response.html(render_detail(fresh, self.urls, ws, rec, prev=prev, nxt=nxt))
+
+ def neighbours(self, entry: RunEntry) -> tuple[RunEntry | None, RunEntry | None]:
+ """The runs either side of ``entry`` in its battery, in the index's own order,
+ so triage can walk a battery run by run instead of bouncing off the index."""
+ section = next((s for s in self.index.sections if s.label == entry.battery), None)
+ if section is None:
+ return None, None
+ ordered = sort_entries(section.entries, "score")
+ keys = [e.key for e in ordered]
+ if entry.key not in keys:
+ return None, None
+ i = keys.index(entry.key)
+ return (ordered[i - 1] if i > 0 else None,
+ ordered[i + 1] if i + 1 < len(ordered) else None)
def _api(self, rest: list[str], query: dict[str, str]) -> Response:
self.refresh()
diff --git a/harness/codeverse/gallery/theme.py b/harness/codeverse/gallery/theme.py
index 55056730..476ff100 100644
--- a/harness/codeverse/gallery/theme.py
+++ b/harness/codeverse/gallery/theme.py
@@ -25,6 +25,9 @@ TOKENS = """
--ok:#1f7a3d; --ok-soft:#e2f3e7; --bad:#b3261e; --bad-soft:#fbe6e4; --warn:#8a5a00; --warn-soft:#fbf0d9;
--tier-a:#1f7a3d; --tier-b:#5c7a1f; --tier-c:#8a5a00; --tier-d:#b3261e;
--shadow:0 1px 2px rgba(16,16,24,.06), 0 4px 12px rgba(16,16,24,.05);
+ --shot-bg:#e8e8ec; --shot-check:#eeeef1; --shot-ring:rgba(16,16,24,.14);
+ --overlay:rgba(12,12,16,.62);
+ --chip:#ebebf0; --chip-fg:#4b4b57;
--r-1:4px; --r-2:8px; --r-3:14px;
--s-1:4px; --s-2:8px; --s-3:12px; --s-4:16px; --s-5:24px; --s-6:36px;
--fs-xs:11.5px; --fs-sm:12.5px; --fs-md:14px; --fs-lg:17px; --fs-xl:22px;
@@ -40,6 +43,9 @@ TOKENS = """
--ok:#5fd18b; --ok-soft:#14291d; --bad:#ff8a80; --bad-soft:#2e1614; --warn:#e3b341; --warn-soft:#2b2210;
--tier-a:#5fd18b; --tier-b:#a8cf5c; --tier-c:#e3b341; --tier-d:#ff8a80;
--shadow:0 1px 2px rgba(0,0,0,.5), 0 6px 18px rgba(0,0,0,.35);
+ --shot-bg:#1a1b20; --shot-check:#1f2027; --shot-ring:rgba(255,255,255,.14);
+ --overlay:rgba(0,0,0,.66);
+ --chip:#24262c; --chip-fg:#b1b2bd;
}
}
:root[data-theme="dark"]{
@@ -49,6 +55,9 @@ TOKENS = """
--ok:#5fd18b; --ok-soft:#14291d; --bad:#ff8a80; --bad-soft:#2e1614; --warn:#e3b341; --warn-soft:#2b2210;
--tier-a:#5fd18b; --tier-b:#a8cf5c; --tier-c:#e3b341; --tier-d:#ff8a80;
--shadow:0 1px 2px rgba(0,0,0,.5), 0 6px 18px rgba(0,0,0,.35);
+ --shot-bg:#1a1b20; --shot-check:#1f2027; --shot-ring:rgba(255,255,255,.14);
+ --overlay:rgba(0,0,0,.66);
+ --chip:#24262c; --chip-fg:#b1b2bd;
}
"""
@@ -86,60 +95,41 @@ header.top .bar{max-width:var(--maxw);margin:0 auto;padding:var(--s-3) var(--s-4
overflow-wrap:anywhere;min-width:0}
.crumbs a{color:var(--fg-2)}
-.strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(132px,1fr));gap:var(--s-2);
- margin:var(--s-4) 0}
-.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-2);padding:var(--s-3)}
-.stat .k{font-size:var(--fs-xs);text-transform:uppercase;letter-spacing:.06em;color:var(--fg-3)}
-.stat .v{font-size:var(--fs-lg);font-weight:650;margin-top:2px}
-
-.controls{display:flex;gap:var(--s-2);align-items:center;flex-wrap:wrap;margin:var(--s-4) 0 var(--s-3);
- padding:var(--s-3);background:var(--surface);border:1px solid var(--line);border-radius:var(--r-2)}
-.controls label{display:flex;gap:6px;align-items:center;font-size:var(--fs-sm);color:var(--fg-2)}
select,input[type=search]{font:inherit;font-size:var(--fs-sm);color:var(--fg);background:var(--bg);
- border:1px solid var(--line);border-radius:var(--r-1);padding:4px 6px;max-width:100%}
-input[type=search]{min-width:min(260px,60vw)}
+ border:1px solid var(--line);border-radius:var(--r-1);padding:5px 7px;max-width:100%;width:100%}
+.checker{background-color:var(--shot-bg);
+ background-image:repeating-conic-gradient(var(--shot-check) 0% 25%,transparent 0% 50%);
+ background-size:22px 22px}
+.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
+.up{color:var(--ok)} .down{color:var(--bad)}
+.clamp1{display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden;
+ text-overflow:ellipsis}
+.clamp2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
+ text-overflow:ellipsis}
section.battery{margin:var(--s-5) 0}
-section.battery > h2{display:flex;gap:var(--s-2);align-items:baseline}
+section.battery > h2{display:flex;gap:var(--s-2) var(--s-3);align-items:baseline;flex-wrap:wrap}
.count{font-size:var(--fs-sm);color:var(--fg-3);font-weight:500}
-.rootpath{font-size:var(--fs-xs);color:var(--fg-3);font-family:var(--mono);margin-top:2px;
- overflow-wrap:anywhere}
+.rootpath{font-size:var(--fs-xs);color:var(--fg-3);font-family:var(--mono);font-weight:400;
+ overflow-wrap:anywhere;margin-left:auto}
-.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(320px,100%),1fr));gap:var(--s-4);
- margin-top:var(--s-3)}
-.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-3);overflow:hidden;
- display:flex;flex-direction:column;box-shadow:var(--shadow)}
-.card.pass{border-top:3px solid var(--ok)} .card.fail{border-top:3px solid var(--bad)}
-.card.na{border-top:3px solid var(--line-strong)}
-.card .shot{display:block;background:var(--sunken);aspect-ratio:16/10;overflow:hidden}
-.card .shot img{width:100%;height:100%;object-fit:contain;display:block}
-.card .noshot{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
- color:var(--fg-3);font-size:var(--fs-sm)}
-.card .body{padding:var(--s-3);display:flex;flex-direction:column;gap:6px;flex:1}
-.titlerow{display:flex;gap:var(--s-2);align-items:center}
-.titlerow .name{font-weight:650;overflow-wrap:anywhere;min-width:0}
-.titlerow .score{margin-left:auto;font-size:var(--fs-lg);font-weight:650}
-.prompt{color:var(--fg-2);font-size:var(--fs-sm);overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;
- -webkit-box-orient:vertical;overflow:hidden}
-.facts{font-size:var(--fs-sm);color:var(--fg-2);display:flex;flex-wrap:wrap;gap:2px 8px}
-.links{display:flex;flex-wrap:wrap;gap:2px 8px;font-size:var(--fs-sm);padding-top:2px;
- border-top:1px solid var(--line);margin-top:auto}
-
-.tag{display:inline-flex;align-items:center;gap:4px;font-size:var(--fs-xs);padding:1px 7px;border-radius:999px;
- border:1px solid var(--line);color:var(--fg-2);background:var(--sunken);white-space:nowrap}
-.tier{font-weight:700;color:var(--accent-fg)}
-.tier.A{background:var(--tier-a);border-color:var(--tier-a)}
-.tier.B{background:var(--tier-b);border-color:var(--tier-b)}
-.tier.C{background:var(--tier-c);border-color:var(--tier-c)}
-.tier.D{background:var(--tier-d);border-color:var(--tier-d)}
-.pill-pass{color:var(--ok);background:var(--ok-soft);border-color:var(--ok)}
-.pill-fail{color:var(--bad);background:var(--bad-soft);border-color:var(--bad)}
-.pill-warn{color:var(--warn);background:var(--warn-soft);border-color:var(--warn)}
+/* --- badges: solid muted fills, no hairline outlines ------------------------ */
+.tag{display:inline-flex;align-items:center;gap:4px;font-size:var(--fs-xs);padding:2px 8px;
+ border-radius:999px;border:0;color:var(--chip-fg);background:var(--chip);white-space:nowrap;
+ font-weight:550;line-height:1.5}
+.tier{font-weight:750;color:var(--accent-fg);min-width:20px;justify-content:center}
+.tier.A{background:var(--tier-a)} .tier.B{background:var(--tier-b)}
+.tier.C{background:var(--tier-c)} .tier.D{background:var(--tier-d)}
+.pill-pass,.v-pass.tag,.pill-ok{color:var(--ok);background:var(--ok-soft)}
+.pill-fail,.v-fail.tag{color:var(--bad);background:var(--bad-soft)}
+.pill-warn,.v-err.tag{color:var(--warn);background:var(--warn-soft)}
+.v-none.tag{color:var(--fg-3);background:var(--chip)}
+.pill-accent{color:var(--accent);background:var(--accent-soft)}
.tablewrap{overflow-x:auto;margin-top:var(--s-3);border:1px solid var(--line);border-radius:var(--r-2);
background:var(--surface)}
table{border-collapse:collapse;width:100%;font-size:var(--fs-sm)}
-th,td{text-align:left;padding:6px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
+th,td{text-align:left;padding:7px 10px;border-bottom:1px solid var(--line);white-space:nowrap}
th{font-size:var(--fs-xs);text-transform:uppercase;letter-spacing:.05em;color:var(--fg-3);
position:sticky;top:0;background:var(--surface)}
tbody tr:last-child td{border-bottom:0}
@@ -156,11 +146,17 @@ td.n,th.n{text-align:right;font-variant-numeric:tabular-nums}
ul.plain{margin:0;padding-left:18px;font-size:var(--fs-sm);color:var(--fg-2)}
ul.plain li{margin:2px 0}
-.shots{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:var(--s-3)}
-.shots figure{margin:0;background:var(--sunken);border:1px solid var(--line);border-radius:var(--r-2);
- overflow:hidden}
-.shots img{width:100%;display:block;background:var(--sunken)}
-.shots figcaption{font-size:var(--fs-xs);color:var(--fg-3);padding:4px 6px;overflow-wrap:anywhere}
+/* --- render tiles: the label floats on a gradient, never a black bar -------- */
+.shots{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(210px,100%),1fr));gap:var(--s-3)}
+.shots figure{margin:0;background-color:var(--shot-bg);
+ background-image:repeating-conic-gradient(var(--shot-check) 0% 25%,transparent 0% 50%);
+ background-size:22px 22px;border-radius:var(--r-2);overflow:hidden;
+ box-shadow:inset 0 0 0 1px var(--shot-ring)}
+.shots figure a{display:block;position:relative;color:inherit}
+.shots img{width:100%;display:block;aspect-ratio:1;object-fit:contain}
+.shots figcaption{position:absolute;inset:auto 0 0 0;font-size:var(--fs-sm);font-weight:550;
+ color:#fff;padding:22px 10px 7px;overflow-wrap:anywhere;letter-spacing:.01em;
+ background:linear-gradient(to top,var(--overlay),transparent);text-shadow:0 1px 2px rgba(0,0,0,.55)}
pre.code{margin:0;padding:var(--s-3);background:var(--sunken);border:1px solid var(--line);
border-radius:var(--r-2);overflow-x:auto;font-size:var(--fs-sm);line-height:1.55;tab-size:4}
@@ -174,6 +170,168 @@ footer.foot{max-width:var(--maxw);margin:0 auto;padding:var(--s-4);color:var(--f
border-top:1px solid var(--line);overflow-wrap:anywhere}
"""
+INDEX_CSS = """
+/* --- status rail: four disjoint buckets that add up to the runs on screen --- */
+.summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--s-2) var(--s-3);
+ margin:var(--s-3) 0 var(--s-2);padding:8px var(--s-3);background:var(--surface);
+ border:1px solid var(--line);border-radius:var(--r-2)}
+.summary .sumn{font-size:var(--fs-sm);color:var(--fg-2);display:flex;align-items:baseline;gap:5px}
+.summary .sumn b{font-size:var(--fs-xl);font-weight:700;color:var(--fg)}
+.summary .eq{font-size:var(--fs-lg);padding:0 2px}
+.vchips{display:flex;flex-wrap:wrap;gap:5px}
+.vchip{font:inherit;font-size:var(--fs-sm);display:inline-flex;align-items:baseline;gap:5px;
+ padding:3px 9px;border-radius:999px;border:0;cursor:pointer;background:var(--chip);
+ color:var(--chip-fg);font-weight:550}
+.vchip b{font-size:var(--fs-md);font-weight:700}
+.vchip .pct{font-size:var(--fs-xs);opacity:.7}
+.vchip:hover{filter:brightness(.97)}
+:root[data-theme="dark"] .vchip:hover{filter:brightness(1.2)}
+.vchip.v-pass{color:var(--ok);background:var(--ok-soft)}
+.vchip.v-fail{color:var(--bad);background:var(--bad-soft)}
+.vchip.v-err{color:var(--warn);background:var(--warn-soft)}
+.vchip[aria-pressed="true"]{outline:2px solid currentColor;outline-offset:1px}
+.vbar{display:flex;height:8px;flex:1 1 160px;min-width:120px;border-radius:999px;overflow:hidden;
+ background:var(--sunken)}
+.vbar .seg{display:block;min-width:0;transition:flex-grow .2s}
+.vbar .seg.v-pass{background:var(--ok)} .vbar .seg.v-fail{background:var(--bad)}
+.vbar .seg.v-none{background:var(--line-strong)} .vbar .seg.v-err{background:var(--warn)}
+.sumnums{display:flex;flex-wrap:wrap;gap:2px var(--s-3);font-size:var(--fs-sm);color:var(--fg-3);
+ margin-left:auto}
+.sumnums b{color:var(--fg-2);font-weight:650}
+
+/* --- filters: one aligned grid, collapsible on a phone --------------------- */
+details.filters{margin:0 0 var(--s-3);background:var(--surface);border:1px solid var(--line);
+ border-radius:var(--r-2)}
+details.filters > summary{cursor:pointer;padding:7px var(--s-3);font-size:var(--fs-sm);
+ color:var(--fg-2);list-style:none;display:flex;align-items:center;gap:6px}
+details.filters > summary::-webkit-details-marker{display:none}
+details.filters > summary::before{content:"▸";display:inline-block;transition:transform .15s;
+ color:var(--fg-3)}
+details.filters[open] > summary::before{transform:rotate(90deg)}
+details.filters[open] > summary{border-bottom:1px solid var(--line)}
+.controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(126px,1fr));gap:var(--s-2) var(--s-3);
+ align-items:end;padding:var(--s-3)}
+.controls .fld{display:flex;flex-direction:column;gap:3px;min-width:0}
+.controls .fld.grow{grid-column:span 2}
+.controls .flab{font-size:var(--fs-xs);text-transform:uppercase;letter-spacing:.06em;color:var(--fg-3)}
+.controls .btn{width:100%;padding:6px 10px}
+
+/* --- cards: one hero view, a verdict rail, two links and a menu ------------- */
+.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(272px,100%),1fr));gap:var(--s-3);
+ margin-top:var(--s-3)}
+.card{position:relative;background:var(--surface);border:1px solid var(--line);
+ border-left:6px solid var(--line-strong);border-radius:var(--r-2);overflow:hidden;
+ display:flex;flex-direction:column;box-shadow:var(--shadow)}
+.card.v-pass{border-left-color:var(--ok)}
+.card.v-fail{border-left-color:var(--bad)}
+.card.v-err{border-left-color:var(--warn)}
+.card.v-none{border-left-color:var(--line-strong)}
+.card.v-fail,.card.v-err{background:color-mix(in srgb,var(--surface) 94%,var(--bad-soft))}
+.card .shot{position:relative;display:block;background-color:var(--shot-bg);
+ background-image:repeating-conic-gradient(var(--shot-check) 0% 25%,transparent 0% 50%);
+ background-size:22px 22px;aspect-ratio:4/3;overflow:hidden;
+ box-shadow:inset 0 0 0 1px var(--shot-ring)}
+.card .shot > a{display:block;height:100%}
+.card .shot > a > img{width:100%;height:100%;object-fit:contain;display:block}
+.card .noshot{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
+ color:var(--fg-3);font-size:var(--fs-sm)}
+.viewtag{position:absolute;left:0;right:0;bottom:0;padding:16px 8px 5px;color:#fff;
+ font-size:var(--fs-xs);font-weight:550;pointer-events:none;
+ background:linear-gradient(to top,var(--overlay),transparent);text-shadow:0 1px 2px rgba(0,0,0,.5)}
+details.views{position:absolute;top:6px;right:6px}
+details.views > summary{list-style:none;cursor:pointer;font-size:var(--fs-xs);font-weight:650;
+ padding:2px 7px;border-radius:999px;background:var(--overlay);color:#fff;opacity:.55}
+details.views > summary::-webkit-details-marker{display:none}
+.card:hover details.views > summary,details.views[open] > summary{opacity:1}
+details.views .sheetover{position:fixed;display:none}
+details.views[open] .sheetover{display:block;position:absolute;top:0;right:0;
+ width:min(420px,72vw);background:var(--surface);border:1px solid var(--line-strong);
+ border-radius:var(--r-2);box-shadow:var(--shadow);z-index:6;padding:3px}
+.card .pick{position:absolute;top:5px;left:5px;z-index:5;padding:6px;border-radius:var(--r-2);
+ background:color-mix(in srgb,var(--surface) 86%,transparent);opacity:.45;transition:opacity .12s;
+ cursor:pointer;box-shadow:0 1px 3px rgba(0,0,0,.18)}
+.card:hover .pick,.card .pick:focus-within,.card.picked .pick{opacity:1}
+.card.picked{outline:2px solid var(--accent);outline-offset:-2px}
+.pick input{width:18px;height:18px;accent-color:var(--accent);cursor:pointer;display:block;margin:0}
+.card .body{padding:var(--s-3);display:flex;flex-direction:column;gap:5px;flex:1}
+.titlerow{display:flex;gap:var(--s-2);align-items:baseline}
+.titlerow{align-items:start}
+.titlerow .name{font-weight:650;min-width:0;color:var(--fg);flex:1;display:-webkit-box;
+ -webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;
+ overflow-wrap:break-word}
+.titlerow .score{margin-left:auto;font-size:var(--fs-lg);font-weight:700}
+.prompt{color:var(--fg-2);font-size:var(--fs-sm);overflow-wrap:anywhere;display:-webkit-box;
+ -webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}
+.facts{font-size:var(--fs-sm);color:var(--fg-2);display:flex;flex-wrap:wrap;gap:4px 8px;
+ align-items:center}
+.facts.tags{gap:3px}
+.actions{display:flex;align-items:center;gap:var(--s-3);font-size:var(--fs-sm);padding-top:6px;
+ border-top:1px solid var(--line);margin-top:auto;position:relative}
+.actions .go{font-weight:650}
+details.menu{margin-left:auto;position:relative}
+details.menu > summary{list-style:none;cursor:pointer;color:var(--fg-3);padding:0 6px;
+ border-radius:var(--r-1);font-weight:700;letter-spacing:.08em}
+details.menu > summary::-webkit-details-marker{display:none}
+details.menu > summary:hover{color:var(--fg);background:var(--sunken)}
+details.menu .pop{position:absolute;right:0;bottom:calc(100% + 6px);z-index:8;min-width:150px;
+ display:flex;flex-direction:column;gap:1px;padding:5px;background:var(--surface);
+ border:1px solid var(--line-strong);border-radius:var(--r-2);box-shadow:var(--shadow)}
+details.menu .pop a{padding:3px 7px;border-radius:var(--r-1);white-space:nowrap}
+details.menu .pop a:hover{background:var(--sunken);text-decoration:none}
+
+/* --- table mode ------------------------------------------------------------ */
+.tablewrap{display:none}
+body.view-table .grid{display:none}
+body.view-table .tablewrap{display:block}
+body.view-table table{width:max-content;min-width:100%}
+
+td.pickcol,th.pickcol{width:30px;padding-right:0;position:sticky;left:0;z-index:2;
+ background:var(--surface)}
+th.pickcol{z-index:4}
+td.wide,th.runcol{position:sticky;left:30px;z-index:2;background:var(--surface)}
+th.runcol{z-index:4}
+tr.picked td.pickcol,tr.picked td.wide{background:var(--accent-soft)}
+td.pickcol .pick{opacity:1;position:static;background:none;padding:0}
+td.thumbcol,th.thumbcol{width:66px;padding:3px 6px}
+img.rowthumb{width:52px;height:40px;object-fit:contain;background:var(--shot-bg);border-radius:var(--r-1);
+ display:block;box-shadow:inset 0 0 0 1px var(--shot-ring)}
+tr.v-fail td:first-child{box-shadow:inset 3px 0 0 var(--bad)}
+tr.v-pass td:first-child{box-shadow:inset 3px 0 0 var(--ok)}
+tr.v-err td:first-child{box-shadow:inset 3px 0 0 var(--warn)}
+tr.picked{background:var(--accent-soft)}
+td.rowlinks a{margin-right:8px}
+td.rowlinks{white-space:nowrap}
+td.wide{min-width:180px;max-width:230px}
+td.backend,th.backend{max-width:190px;overflow:hidden;text-overflow:ellipsis}
+td.track,td.lang{max-width:140px;overflow:hidden;text-overflow:ellipsis}
+@media (max-width:1100px){td.track,th.track,td.lang,th.lang{display:none}}
+@media (max-width:640px){
+ td.backend,th.backend,td.base,th.base,td.delta,th.delta,td.min,th.min,
+ td.rowlinks,th.rowlinks,td.tier,th.tier{display:none}
+ td.wide,th.runcol{position:static;min-width:0}
+ td.pickcol,th.pickcol{position:static}
+ td.thumbcol,th.thumbcol{display:none}
+ body.view-table table{width:100%}
+ .narrowhint{display:block}
+}
+.narrowhint{display:none;padding:5px 10px;border-bottom:1px solid var(--line)}
+
+/* --- bulk bar -------------------------------------------------------------- */
+.selbar{position:sticky;bottom:0;z-index:30;display:flex;flex-wrap:wrap;align-items:center;
+ gap:var(--s-2) var(--s-3);padding:var(--s-2) var(--s-4);
+ background:color-mix(in srgb,var(--surface) 94%,transparent);backdrop-filter:blur(8px);
+ border-top:1px solid var(--line-strong);box-shadow:0 -4px 14px rgba(0,0,0,.10)}
+.selbar.empty{color:var(--fg-3)}
+.selbar.empty .btn{opacity:.45;pointer-events:none}
+.selbar .selcount b{font-size:var(--fs-lg)}
+.selbar .btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg)}
+.selbar .selnote{margin-left:auto}
+@media (max-width:520px){.selbar .selnote{display:none}}
+@media (max-width:760px){.selbar.empty{display:none}}
+.factive{display:flex;gap:4px;flex-wrap:wrap;margin-left:6px}
+"""
+
+
#: sets the stored theme before first paint so a manual choice never flashes
THEME_BOOT_JS = """
(function(){try{var t=localStorage.getItem('3dcv-gallery-theme');
diff --git a/harness/codeverse/gallery/viewer.py b/harness/codeverse/gallery/viewer.py
index 94d4b956..412395ad 100644
--- a/harness/codeverse/gallery/viewer.py
+++ b/harness/codeverse/gallery/viewer.py
@@ -22,6 +22,8 @@ VIEWER_CSS = """
#stage{width:100%;height:min(78vh,900px);background:var(--sunken);border:1px solid var(--line);
border-radius:var(--r-3);overflow:hidden;position:relative}
#stage canvas{display:block;width:100%;height:100%}
+.touch-only{display:none}
+@media (pointer:coarse){.mouse-only{display:none}.touch-only{display:inline}}
#hint{position:absolute;left:10px;bottom:10px;font-size:var(--fs-xs);color:var(--fg-3);
background:color-mix(in srgb,var(--surface) 80%,transparent);padding:3px 8px;border-radius:999px}
#vmsg{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
@@ -126,10 +128,13 @@ def render_viewer(entry: RunEntry, urls: UrlMaker, rel: str) -> str:
top_bar("3dcv gallery", entry.slug,
crumbs=f"<a href='/'>gallery</a> <span class='faint'>/</span> "
f"<a href='{esc(urls.detail(entry))}'>{esc(entry.slug)}</a> "
- f"<span class='faint'>/</span> <b>{esc(rel)}</b>")
+ f"<span class='faint'>/</span> <b>{esc(rel)}</b>",
+ right=f"<a class='btn' href='{esc(urls.detail(entry))}'>← back to the run</a>")
+ "<main class='wrap'>"
+ f"<div id='stage' data-src='{esc(src)}'><div id='vmsg'>loading {esc(rel)}…</div>"
- f"<div id='hint'>drag to orbit · scroll to zoom · right-drag to pan</div></div>"
+ f"<div id='hint'><span class='mouse-only'>drag to orbit · scroll to zoom · right-drag to pan"
+ f"</span><span class='touch-only'>drag to orbit · pinch to zoom · two-finger drag to pan"
+ f"</span></div></div>"
+ f"<p class='small muted' style='margin-top:var(--s-3)'>bounding box: <span id='dims' class='num'>—</span>"
f" · <a href='{esc(src)}'>download the raw GLB</a>"
f" · <a href='{esc(urls.detail(entry))}'>back to the run</a></p>"
diff --git a/harness/tests/gallery/test_page.py b/harness/tests/gallery/test_page.py
index c2e8ad0b..a1d3dac0 100644
--- a/harness/tests/gallery/test_page.py
+++ b/harness/tests/gallery/test_page.py
@@ -109,7 +109,7 @@ def test_server_page_applies_the_filter_server_side(gallery_tree: dict[str, Path
assert markup.count("<article class='card") == 6
# ...but only the matching one is visible, and the summary counts only that one
assert len(re.findall(r"<article class='card [^']*is-hidden' data-run=", markup)) == 5
- assert ">1 / 6<" in markup
+ assert ">1 <span class='faint'>of 6</span><" in markup
assert "<option value='threejs' selected>" in markup
diff --git a/harness/tests/gallery/test_triage.py b/harness/tests/gallery/test_triage.py
new file mode 100644
index 00000000..9808582a
--- /dev/null
+++ b/harness/tests/gallery/test_triage.py
@@ -0,0 +1,231 @@
+"""The triage affordances: the status breakdown, the hero view, label humanisation,
+multi-select routing (compare / CSV) and the detail page's neighbour links.
+
+The invariant worth a test is the arithmetic one: the four verdict buckets are
+disjoint and exhaustive, so the strip's "n runs shown = a + b + c + d" is true for
+*any* selection — including one holding half-written records.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+import pytest
+
+from codeverse.gallery.compare import (
+ CSV_COLUMNS,
+ MAX_COMPARE,
+ export_csv,
+ parse_keys,
+ render_compare,
+)
+from codeverse.gallery.index import HERO_PREFERENCE, build_index, hero_view
+from codeverse.gallery.labels import VERDICTS, humanize_view
+from codeverse.gallery.model import match, summarize, verdict_breakdown
+from codeverse.gallery.page import render_index
+from codeverse.gallery.server import GalleryApp
+from codeverse.gallery.urls import UrlMaker
+
+
+# --------------------------------------------------------------------------- breakdown
+def test_the_four_buckets_are_disjoint_and_sum_to_n(gallery_tree: dict[str, Path]):
+ entries = build_index([gallery_tree["runs"], gallery_tree["battery"]]).entries()
+ s = summarize(entries)
+ assert s.n == 6
+ assert set(s.breakdown) == set(VERDICTS)
+ assert sum(s.breakdown.values()) == s.n and s.sums()
+ # the tree holds 3 passing, 1 failing, and 2 runs with no usable record
+ assert s.breakdown == {"passed": 3, "failed": 1, "unjudged": 0, "error": 2}
+ # every entry lands in exactly one bucket
+ assert sorted(e.verdict for e in entries) == sorted(
+ k for k, n in s.breakdown.items() for _ in range(n))
+
+
+def test_a_run_with_no_record_is_error_not_unjudged(gallery_tree: dict[str, Path]):
+ entries = build_index([gallery_tree["battery"]]).entries()
+ by_slug = {e.slug: e for e in entries}
+ assert by_slug["half_written"].verdict == "error" # corrupt record
+ assert by_slug["not_started"].verdict == "error" # no record at all
+ assert by_slug["half_written"].passed is None # ...and still unjudged in the old sense
+
+
+def test_breakdown_of_an_empty_selection_is_all_zeroes():
+ b = verdict_breakdown([])
+ assert b == dict.fromkeys(VERDICTS, 0) and sum(b.values()) == 0
+ assert summarize([]).sums()
+
+
+def test_the_page_states_the_breakdown_and_it_adds_up(gallery_tree: dict[str, Path]):
+ index = build_index([gallery_tree["runs"], gallery_tree["battery"]])
+ markup = render_index(index, UrlMaker())
+ for bucket in VERDICTS:
+ assert f"id='vc-{bucket}'" in markup
+ assert "runs shown" in markup
+ # the old un-addable "pass rate / not ok" pair of tiles is gone
+ assert "PASS RATE" not in markup.upper()
+
+
+# --------------------------------------------------------------------------- verdict filter
[email protected](("verdict", "n"), [("passed", 3), ("failed", 1), ("error", 2),
+ ("unjudged", 0)])
+def test_verdict_filter_selects_exactly_its_bucket(gallery_tree: dict[str, Path], verdict: str, n: int):
+ entries = build_index([gallery_tree["runs"], gallery_tree["battery"]]).entries()
+ kept = [e for e in entries if match(e, {"verdict": verdict})]
+ assert len(kept) == n and all(e.verdict == verdict for e in kept)
+
+
+def test_verdict_filter_reaches_the_api_and_the_page(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"], gallery_tree["battery"]])
+ payload = json.loads(app.route("/api/runs", {"verdict": "error"}).body)
+ assert payload["n"] == 2 and {r["state"] for r in payload["runs"]} == {"broken", "pending"}
+ page = app.route("/", {"verdict": "failed"}).body.decode()
+ assert "<option value='failed' selected>" in page
+
+
+# --------------------------------------------------------------------------- hero view
+def test_the_card_shows_one_hero_view_not_the_contact_sheet(gallery_tree: dict[str, Path]):
+ entry = next(e for e in build_index([gallery_tree["runs"]]).entries()
+ if e.slug == "wooden_chair_ab12cd34")
+ assert entry.hero.endswith("view_front.png") # "front" is in HERO_PREFERENCE
+ assert entry.hero_label == "Front"
+ assert entry.n_views == 2
+ assert entry.sheet.endswith("sheet.png") and entry.card_image == entry.hero
+ markup = render_index(build_index([gallery_tree["runs"]]), UrlMaker())
+ assert "view_front.png" in markup
+ assert "⊞ 2" in markup # the sheet is one disclosure away
+
+
+def test_hero_falls_back_to_the_sheet_when_a_round_has_no_views(tmp_path: Path):
+ from tests.flywheel_cli.conftest import make_fake_run
+
+ ws, rec = make_fake_run(tmp_path / "runs", "noviews")
+ for rnd in rec.rounds:
+ rnd.renders = None
+ assert hero_view(ws, rec, rec.best_round) == ("", "", 0)
+
+
+def test_hero_preference_is_ordered_best_first():
+ assert HERO_PREFERENCE[0] == "front_right_34" # a ¾ view shows silhouette and depth
+
+
+# --------------------------------------------------------------------------- labels
[email protected](("raw", "human"), [
+ ("front_right_34", "Front Right ¾"),
+ ("view_front_right_34.png", "Front Right ¾"),
+ ("back_left_34", "Back Left ¾"),
+ ("low_front_left", "Low Front Left"),
+ ("front", "Front"),
+ ("t=2.5s", "t = 2.5 s"),
+ ("t=0s", "t = 0 s"),
+ ("pose_rest", "Pose · rest"),
+ ("pose_door_hinge@upper", "Pose · door_hinge@upper"),
+ ("articulation_sheet", "Articulation poses"),
+ ("preview.gif", "Animated preview"),
+ ("", ""),
+])
+def test_view_names_are_humanised(raw: str, human: str):
+ assert humanize_view(raw) == human
+
+
+def test_render_tiles_use_a_gradient_caption_not_a_black_bar(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"]])
+ page = app.route("/run/runs/wooden_chair_ab12cd34").body.decode()
+ assert "<figcaption>Front</figcaption>" in page and "<figcaption>Top</figcaption>" in page
+ assert "linear-gradient(to top,var(--overlay),transparent)" in page
+
+
+# --------------------------------------------------------------------------- multi-select
+def test_parse_keys_keeps_order_and_drops_duplicates():
+ assert parse_keys("a/b, c/d ,a/b") == ["a/b", "c/d"]
+ assert parse_keys("") == [] and parse_keys(" , ") == []
+
+
+def test_compare_route_renders_only_the_selected_runs(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"], gallery_tree["battery"]])
+ r = app.route("/compare", {"runs": "runs/wooden_chair_ab12cd34,static_v9/ctrl_med_toaster"})
+ assert r.status == 200
+ page = r.body.decode()
+ assert page.count("<td class='head'>") == 2
+ assert "wooden_chair_ab12cd34" in page and "ctrl_med_toaster" in page
+ assert "lamp_three" not in page
+ assert "Δ vs baseline" in page
+ assert "never starts, resumes or deletes" in page # the read-only stance is stated
+
+
+def test_compare_of_nothing_explains_itself(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"]])
+ page = app.route("/compare").body.decode()
+ assert "nothing to compare" in page and app.route("/compare").status == 200
+
+
+def test_compare_reports_unknown_keys_and_caps_the_width(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"], gallery_tree["battery"]])
+ page = app.route("/compare", {"runs": "runs/wooden_chair_ab12cd34,runs/ghost"}).body.decode()
+ assert "unknown: runs/ghost" in page
+ many = ",".join(["runs/wooden_chair_ab12cd34"] * 3) # dedup keeps one
+ assert app.route("/compare", {"runs": many}).status == 200
+ entries = app.index.entries()
+ assert len(render_compare(entries[:MAX_COMPARE], UrlMaker()).split("<td class='head'>")) - 1 \
+ == min(MAX_COMPARE, len(entries))
+
+
+def test_compare_survives_a_run_with_no_record(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["battery"]])
+ r = app.route("/compare", {"runs": "static_v9/half_written,static_v9/not_started"})
+ assert r.status == 200 and b"half_written" in r.body
+
+
+def test_bulk_bar_is_offered_on_the_server_but_not_in_the_static_build(gallery_tree: dict[str, Path]):
+ from codeverse.gallery.static_site import render_static
+
+ index = build_index([gallery_tree["runs"]])
+ served = render_index(index, UrlMaker())
+ assert "id='selbar'" in served and "id='sel-compare'" in served
+ assert "no re-run from the browser" in served # the refusal is written down
+ assert "id='selbar'" not in render_static(index, embed=False)
+
+
+# --------------------------------------------------------------------------- csv export
+def test_export_csv_route_and_columns(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"], gallery_tree["battery"]])
+ r = app.route("/export.csv", {"runs": "runs/wooden_chair_ab12cd34"})
+ assert r.status == 200 and r.content_type.startswith("text/csv")
+ assert "attachment" in r.headers["Content-Disposition"]
+ lines = r.body.decode().strip().splitlines()
+ assert lines[0] == ",".join(CSV_COLUMNS) and len(lines) == 2
+ assert "wooden_chair_ab12cd34" in lines[1] and ",passed," in lines[1]
+
+
+def test_export_csv_without_a_selection_exports_the_current_filter(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"], gallery_tree["battery"]])
+ body = app.route("/export.csv", {"verdict": "error"}).body.decode()
+ assert len(body.strip().splitlines()) == 3 # header + the two unusable runs
+ assert "half_written" in body and "not_started" in body
+
+
+def test_csv_quotes_a_hostile_prompt(tmp_path: Path):
+ from tests.flywheel_cli.conftest import make_fake_run
+
+ runs = tmp_path / "runs"
+ make_fake_run(runs, "comma", prompt='a chair, "quoted", \nnewline')
+ text = export_csv(build_index([runs]).entries())
+ assert len(list(__import__("csv").reader(__import__("io").StringIO(text)))) == 2
+
+
+# --------------------------------------------------------------------------- neighbours
+def test_detail_pages_link_to_the_neighbouring_runs(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"]])
+ ordered = app.neighbours(app.index.find("runs", "wooden_chair_ab12cd34"))
+ assert ordered[0] is None # highest score in the battery
+ assert ordered[1].slug == "lamp_three"
+ prev, nxt = app.neighbours(app.index.find("runs", "lamp_three"))
+ assert prev.slug == "wooden_chair_ab12cd34" and nxt is None
+ page = app.route("/run/runs/wooden_chair_ab12cd34").body.decode()
+ assert "/run/runs/lamp_three" in page and "next →" in page
+
+
+def test_neighbours_of_a_run_outside_the_index_are_empty(gallery_tree: dict[str, Path]):
+ app = GalleryApp([gallery_tree["runs"]])
+ entry = app.index.find("runs", "lamp_three").model_copy(update={"battery": "nope"})
+ assert app.neighbours(entry) == (None, None)