The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.
Python
Add corpus frame review UI
Sina Atalay54911fe6e8b7
diff --git a/tests/integration/review/__init__.py b/tests/integration/review/__init__.pynew file mode 100644index 00000000..5e24d3fe--- /dev/null+++ b/tests/integration/review/__init__.py@@ -0,0 +1,3 @@+"""The review panel: browse the corpus, compare each case's CE and manimgx renders, and give a+verdict. `app` is the server (FastAPI); `web/` is the panel (Svelte), built into `web/dist`.+"""diff --git a/tests/integration/review/app.py b/tests/integration/review/app.pynew file mode 100644index 00000000..e501158b--- /dev/null+++ b/tests/integration/review/app.py@@ -0,0 +1,337 @@+"""The review panel's server: the corpus as JSON, frames as PNG, and what a reviewer changes —+a verdict, the settings, a fresh render. It serves the built panel (`web/dist`) too.++ just review # build the panel, then serve both at http://127.0.0.1:8000+ uv run fastapi dev # the server alone, reloading (`bun run dev` in web/ for the panel)+"""++import io+import threading+from collections.abc import AsyncIterator+from contextlib import asynccontextmanager+from functools import lru_cache+from pathlib import Path+from typing import Literal++from fastapi import FastAPI, HTTPException, Response+from fastapi.staticfiles import StaticFiles+from PIL import Image+from pydantic import BaseModel+from tests.integration.corpus import references, typecheck+from tests.integration.corpus.case import (+ FPS,+ METRICS,+ Case,+ Engine,+ Failure,+ Frames,+ Settings,+ State,+ Verdict,+ discover,+ pinned,+ save_settings,+ settings,+)+from tests.integration.corpus.compare import slots+from tests.integration.corpus.frames import Pixels, decode++PANEL = Path(__file__).resolve().parent / "web" / "dist"+++# ── the API's shapes ──────────────────────────────────────────────────────────+++class Checks(BaseModel):+ source: bool # both references were rendered from this exact scene.py+ types: bool # strict ty, no escapes, no Any/Unknown from manimgx+++class CaseSummary(BaseModel):+ name: str+ state: State # a current review's verdict, else the comparison's+ auto: State # the comparison's alone+ reviewed: bool+ noted: bool+ checks: Checks+ worst: (+ float | None+ ) # the largest error of any same-time pair, in the current metric+++class Render(BaseModel):+ version: str+ frames: list[str] # each frame's hash, in order+ duration: float | None+ error: str | None+++class Slot(BaseModel):+ time: float+ ce: int | None+ ce_time: float | None # the scene time CE's frame shows (up to a frame earlier)+ manimgx: int | None+ errors: dict[str, float] | None # per metric, when both engines show this time+++class Review(BaseModel):+ verdict: Verdict | None # None: a note, and the comparison's verdict stands+ note: str+ at: str+++class CaseDetail(CaseSummary):+ source: str+ problems: list[str]+ manimgx: Render+ ce: Render+ slots: list[Slot]+ reasons: list[str] # why the comparison differs, under the current settings+ review: Review | None+ stale_review: bool # the review was given for other renders+++class ReviewIn(BaseModel):+ verdict: Verdict | Literal["auto"]+ note: str = ""+++class RenderIn(BaseModel):+ engine: Literal["manimgx", "ce", "both"] = "both"+++class SettingsIn(BaseModel):+ metric: str+ tolerance: float+++class SettingsOut(SettingsIn):+ metrics: list[str]+++# ── the type report: made once, again when a scene changes ────────────────────+++class TypeReports:+ def __init__(self) -> None:+ self._lock = threading.Lock()+ self._report: typecheck.TypeReport | None = None+ self._made_for: tuple[int, ...] = ()++ def get(self, cases: list[Case]) -> typecheck.TypeReport:+ stamp = tuple(case.scene.stat().st_mtime_ns for case in cases)+ with self._lock:+ if self._report is None or stamp != self._made_for:+ self._report, self._made_for = typecheck.report(cases), stamp+ return self._report+++types = TypeReports()+++@asynccontextmanager+async def lifespan(_: FastAPI) -> AsyncIterator[None]:+ types.get(discover()) # a few seconds, once, before the first request+ yield+++app = FastAPI(title="manimgx corpus review", lifespan=lifespan)+++# ── the corpus ────────────────────────────────────────────────────────────────+++def _case(name: str) -> Case:+ case = Case(name)+ if not case.scene.exists():+ raise HTTPException(status_code=404, detail=f"no case named {name!r}")+ return case+++def _summary(+ case: Case, current: Settings, report: typecheck.TypeReport+) -> CaseSummary:+ standing = case.standing(current)+ facts, review = standing.facts, standing.review+ worst = None+ if facts is not None and facts.comparison is not None:+ worst = round(facts.comparison.worst(current.metric), 2)+ return CaseSummary(+ name=case.name,+ state=standing.state,+ auto=standing.auto,+ reviewed=standing.reviewed,+ noted=review is not None and bool(review.note),+ checks=Checks(source=case.current(facts), types=not report.problems(case)),+ worst=worst,+ )+++def _render(render: Frames | Failure | None, version: str) -> Render:+ if isinstance(render, Frames):+ return Render(+ version=version,+ frames=render.hashes(),+ duration=float(render.duration),+ error=None,+ )+ return Render(+ version=version,+ frames=[],+ duration=None,+ error="not rendered" if render is None else render.error,+ )+++def _detail(case: Case) -> CaseDetail:+ current = settings()+ report = types.get(discover())+ summary = _summary(case, current, report)+ facts = case.facts()+ review = case.review()+ manimgx = None if facts is None else facts.manimgx+ ce = None if facts is None else facts.ce+ errors: dict[tuple[int, int], dict[str, float]] = {}+ if facts is not None and facts.comparison is not None:+ for i, k, measured in facts.comparison.pairs:+ errors[(i, k)] = dict(zip(METRICS, measured, strict=True))+ timeline = slots(+ ce if isinstance(ce, Frames) else None,+ manimgx if isinstance(manimgx, Frames) else None,+ FPS if facts is None else facts.fps,+ )+ return CaseDetail(+ **summary.model_dump(),+ source=case.scene.read_text(encoding="utf-8"),+ problems=report.problems(case),+ manimgx=_render(manimgx, ""),+ ce=_render(ce, "" if facts is None else facts.ce_version),+ slots=[+ Slot(+ time=float(s.time),+ ce=s.ce,+ ce_time=None if s.ce_time is None else float(s.ce_time),+ manimgx=s.manimgx,+ errors=(+ errors.get((s.ce, s.manimgx))+ if s.ce is not None and s.manimgx is not None+ else None+ ),+ )+ for s in timeline+ ],+ reasons=[] if facts is None else list(facts.reasons(current)),+ review=(+ None+ if review is None+ else Review(verdict=review.verdict, note=review.note, at=review.at)+ ),+ stale_review=review is not None+ and (facts is None or not pinned(review, facts)),+ )++[email protected]("/api/cases")+def list_cases() -> list[CaseSummary]:+ cases = discover()+ current, report = settings(), types.get(cases)+ return [_summary(case, current, report) for case in cases]++[email protected]("/api/sources")+def list_sources() -> dict[str, str]:+ return {case.name: case.scene.read_text(encoding="utf-8") for case in discover()}++[email protected]("/api/cases/{name}")+def read_case(name: str) -> CaseDetail:+ return _detail(_case(name))++[email protected]("/api/cases/{name}/review")+def review_case(name: str, body: ReviewIn) -> CaseDetail:+ case = _case(name)+ verdict = None if body.verdict == "auto" else body.verdict+ try:+ case.write_review(verdict, body.note)+ except ValueError as error:+ raise HTTPException(status_code=409, detail=str(error)) from error+ return _detail(case)+++_rendering = threading.Lock()++[email protected]("/api/cases/{name}/render")+def render_case(name: str, body: RenderIn) -> CaseDetail:+ case = _case(name)+ wanted: set[Engine] = {"manimgx", "ce"} if body.engine == "both" else {body.engine}+ with _rendering: # one render at a time: each takes most of the machine it asks for+ references.render(case, wanted)+ return _detail(case)++[email protected]("/api/settings")+def read_settings() -> SettingsOut:+ current = settings()+ return SettingsOut(+ metric=current.metric, tolerance=current.tolerance, metrics=list(METRICS)+ )++[email protected]("/api/settings")+def write_settings(body: SettingsIn) -> SettingsOut:+ if body.metric not in METRICS:+ raise HTTPException(status_code=422, detail=f"metric is one of {METRICS}")+ save_settings(Settings(metric=body.metric, tolerance=body.tolerance))+ return read_settings()+++# ── frames ────────────────────────────────────────────────────────────────────++_decoding = threading.Lock()+++@lru_cache(maxsize=6)+def _frames(name: str, engine: Engine, stamp: int) -> dict[str, Pixels]:+ """Each distinct frame of a case's video, by hash (`stamp`: the file's mtime)."""+ case = Case(name)+ facts = case.facts()+ render = None if facts is None else facts.render(engine)+ if facts is None or not isinstance(render, Frames):+ return {}+ hashes = render.hashes()+ found: dict[str, Pixels] = {}+ for index, pixels in enumerate(decode(case.video(engine), facts.size)):+ if index < len(hashes) and hashes[index] not in found:+ found[hashes[index]] = pixels+ return found+++@lru_cache(maxsize=512)+def _png(name: str, engine: Engine, frame: str, stamp: int) -> bytes | None:+ with _decoding:+ pixels = _frames(name, engine, stamp).get(frame)+ if pixels is None:+ return None+ buffer = io.BytesIO()+ Image.fromarray(pixels).save(buffer, format="PNG", compress_level=1)+ return buffer.getvalue()++[email protected]("/api/cases/{name}/frames/{engine}/{frame}.png")+def read_frame(name: str, engine: Engine, frame: str) -> Response:+ video = _case(name).video(engine)+ png = (+ _png(name, engine, frame, video.stat().st_mtime_ns) if video.exists() else None+ )+ if png is None:+ raise HTTPException(status_code=404, detail=f"no {engine} frame {frame}")+ # a frame's URL is its pixels' hash: it never changes+ headers = {"Cache-Control": "public, max-age=31536000, immutable"}+ return Response(content=png, media_type="image/png", headers=headers)+++# the panel itself, once built (`bun run build` in web/)+if PANEL.exists():+ app.mount("/", StaticFiles(directory=PANEL, html=True), name="panel")diff --git a/tests/integration/review/web/.gitignore b/tests/integration/review/web/.gitignorenew file mode 100644index 00000000..804bd4a4--- /dev/null+++ b/tests/integration/review/web/.gitignore@@ -0,0 +1,3 @@+node_modules+dist+*.localdiff --git a/tests/integration/review/web/bun.lock b/tests/integration/review/web/bun.locknew file mode 100644index 00000000..5960c6a0--- /dev/null+++ b/tests/integration/review/web/bun.lock@@ -0,0 +1,167 @@+{+ "lockfileVersion": 1,+ "configVersion": 1,+ "workspaces": {+ "": {+ "name": "corpus-review",+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^7.3.0",+ "@tsconfig/svelte": "^5.0.8",+ "@types/node": "^24.13.3",+ "svelte": "^5.57.0",+ "svelte-check": "^4.7.6",+ "typescript": "~6.0.2",+ "vite": "^8.3.0",+ },+ },+ },+ "packages": {+ "@jridgewell/gen-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],++ "@jridgewell/remapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],++ "@jridgewell/resolve-uri": ["@jridgewell/[email protected]", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],++ "@jridgewell/sourcemap-codec": ["@jridgewell/[email protected]", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],++ "@jridgewell/trace-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],++ "@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-J1yXrIlNDZVzE3ada310xeAw7nH8yCAyLPuUIsjKatFPmfn5bS1oW+cM+QsGOtVWd5nhSpbwZWx/rue+r5Z+PA=="],++ "@rolldown/binding-android-arm-eabi": ["@rolldown/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-bp9svZb+QurZeh+8H4BhrZkifEB0YBNvTVzNSJnJQkj4NrRwmQoDUCGP0vSN7PbvLeM7l1tK6GXL8mrTiH2myg=="],++ "@rolldown/binding-android-arm64": ["@rolldown/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-wm6Dld3RXUAZ/gRWKyUy+4W1B5CB5UeFaOzsSWJWEdxZXHH8rCYiZ5dGe6oJmhsunAPWzL7FZV+VtvmN5Ye2eA=="],++ "@rolldown/binding-darwin-arm64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-UbEfXq/AqGNgRTV3ik+X/iR6mUxu2QdYAadwRxJWquUGnW6gDqdP1FtLtFXRow7RJx0ssRwi80XAPr4r+4DtsA=="],++ "@rolldown/binding-darwin-x64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-7f5h17q5KZVx/ji1vb8OTq31ch1O2I7K8NPIr44GkyWTApXMIsmhWqZfgpOH10xeauqghDAvGlZktasCkcF6Eg=="],++ "@rolldown/binding-freebsd-x64": ["@rolldown/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-ynOk/eEYhC6ZB2xCGvKrEOwE58oBy9LnrAqtkrDF9Fz1VTaNdGZTsV0VarJdhPwb+sOJTGjCLwcuyRJZ1dnMcQ=="],++ "@rolldown/binding-linux-arm-gnueabihf": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-ERrAs185meZZhGan7a4l3RiiJK1ArSDlHdST++uvSxe+FDbR4TwUPahT/cbZJvaG6fIpDpF78surN+tX708Y4Q=="],++ "@rolldown/binding-linux-arm64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-KN7OHKD0J3jy1UzBwZWPxpwhODf9IARUIJcrH+yLYKOcmegZ8luEUM38lDP1bDVj40yP6PsSzCqOJF76vljFnQ=="],++ "@rolldown/binding-linux-arm64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-8l9wP8O+wa8zD6iw6egSfzVtu7oZVfH3hlUsMM4MwbLMhxleqeoXbZzjddyK3YyNlwLhqznq3tF7PkNJ8T/V2w=="],++ "@rolldown/binding-linux-ppc64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-SeXNKeQzA5kLhz/J0CH6ZP0/HJ3v1xm/0YbiYpE0kK7emfRC2OIGGIaE14xzkISEGv2aYuUSpiLiU5Gbq+OI0A=="],++ "@rolldown/binding-linux-s390x-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-mtht0nR+y8/hart4175Ll15w7lY8dg7CtQ+j2FDNTsDRspOWTK/2V3l0aj9sIj7XmvqxT8Yli/wq22e7feTTWg=="],++ "@rolldown/binding-linux-x64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-FSM94nGd55NYo48usCyM/nHfUKRnqc9+b0vJNuKV0oCCpIp/OGims7rO1Nv/DkFkt0S/s2rxsJ2kkS8J3HcpeA=="],++ "@rolldown/binding-linux-x64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-C3YxNB16myRLs7o+B+6PnQ6jBsdIS4+AE4Ah8glVGhDpEv9AOvxhZ/1duAb4B0UGczEK/lBbccksd8VI+p6zfw=="],++ "@rolldown/binding-openharmony-arm64": ["@rolldown/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-571TlE/F1eeTjjdjYAMMMPs1Mfv3MtX6s3+ZKVU6HiUjZ5Njc6c/qzNy/8K3zALTZnaw3JQVYrHxvNfjm43KAg=="],++ "@rolldown/binding-win32-arm64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-QXW+ZWaiqs2c7Fi++D/SsW07LTPcUrncxcskJGfGNBoaLik1IU6fJymz4HsqwEO0u5Iq11yTO0B/mc4cPk7jrQ=="],++ "@rolldown/binding-win32-x64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-5FQFGgah17YeMtG1Yd5a+rMxQpTksyNXxRtKz06FVTaQw3RKYUJQbUoKk0/5jrXBpDo+7makNP7UHA2LQyH64A=="],++ "@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="],++ "@sveltejs/acorn-typescript": ["@sveltejs/[email protected]", "", { "peerDependencies": { "acorn": "^8.9.0" } }, "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ=="],++ "@sveltejs/load-config": ["@sveltejs/[email protected]", "", {}, "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ=="],++ "@sveltejs/vite-plugin-svelte": ["@sveltejs/[email protected]", "", { "dependencies": { "deepmerge": "^4.3.1", "magic-string": "^1.0.0", "obug": "^2.1.0", "vitefu": "^1.1.2" }, "peerDependencies": { "svelte": "^5.46.4", "vite": "^8.0.0-beta.7 || ^8.0.0" } }, "sha512-ZPsLN8B1e/En+Ak5s4V7srFDT532oS0qieLsQwu63NGKsS+iAjoO2Js1BochlHlglcU+Pt7WAO3C5Ee+4f6gVA=="],++ "@tsconfig/svelte": ["@tsconfig/[email protected]", "", {}, "sha512-UkNnw1/oFEfecR8ypyHIQuWYdkPvHiwcQ78sh+ymIiYoF+uc5H1UBetbjyqT+vgGJ3qQN6nhucJviX6HesWtKQ=="],++ "@types/estree": ["@types/[email protected]", "", {}, "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg=="],++ "@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-SGrw/h3KPFshy3OE6ZL53LMBG5vGQQ8/gIpiqz/kRZhPJ7HgwCEs8LBuNtWLa8dvGZVpSF7+Bf+c11HUrCb/yg=="],++ "acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ=="],++ "aria-query": ["[email protected]", "", {}, "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g=="],++ "axobject-query": ["[email protected]", "", {}, "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ=="],++ "chokidar": ["[email protected]", "", { "dependencies": { "readdirp": "^4.0.1" } }, "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA=="],++ "clsx": ["[email protected]", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],++ "deepmerge": ["[email protected]", "", {}, "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A=="],++ "detect-libc": ["[email protected]", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],++ "devalue": ["[email protected]", "", {}, "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg=="],++ "esm-env": ["[email protected]", "", {}, "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA=="],++ "esrap": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" }, "peerDependencies": { "@typescript-eslint/types": "^8.2.0" }, "optionalPeers": ["@typescript-eslint/types"] }, "sha512-1kmQFiDHcf1T69K9qKtn2MasiKlaq6xNw2ZEgHD8jNyyoNEfx9eCOiJpYDmc0Yk0FKT0bzx5dyBocMDAitWpaQ=="],++ "fdir": ["[email protected]", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],++ "fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],++ "is-reference": ["[email protected]", "", { "dependencies": { "@types/estree": "^1.0.6" } }, "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw=="],++ "lightningcss": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.33.0", "lightningcss-darwin-arm64": "1.33.0", "lightningcss-darwin-x64": "1.33.0", "lightningcss-freebsd-x64": "1.33.0", "lightningcss-linux-arm-gnueabihf": "1.33.0", "lightningcss-linux-arm64-gnu": "1.33.0", "lightningcss-linux-arm64-musl": "1.33.0", "lightningcss-linux-x64-gnu": "1.33.0", "lightningcss-linux-x64-musl": "1.33.0", "lightningcss-win32-arm64-msvc": "1.33.0", "lightningcss-win32-x64-msvc": "1.33.0" } }, "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA=="],++ "lightningcss-android-arm64": ["[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg=="],++ "lightningcss-darwin-arm64": ["[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg=="],++ "lightningcss-darwin-x64": ["[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ=="],++ "lightningcss-freebsd-x64": ["[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg=="],++ "lightningcss-linux-arm-gnueabihf": ["[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ=="],++ "lightningcss-linux-arm64-gnu": ["[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg=="],++ "lightningcss-linux-arm64-musl": ["[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ=="],++ "lightningcss-linux-x64-gnu": ["[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg=="],++ "lightningcss-linux-x64-musl": ["[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw=="],++ "lightningcss-win32-arm64-msvc": ["[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA=="],++ "lightningcss-win32-x64-msvc": ["[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA=="],++ "locate-character": ["[email protected]", "", {}, "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA=="],++ "magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.6.0" } }, "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g=="],++ "mri": ["[email protected]", "", {}, "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="],++ "nanoid": ["[email protected]", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug=="],++ "obug": ["[email protected]", "", {}, "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q=="],++ "picocolors": ["[email protected]", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],++ "picomatch": ["[email protected]", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="],++ "postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.18", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A=="],++ "readdirp": ["[email protected]", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="],++ "rolldown": ["[email protected]", "", { "dependencies": { "@oxc-project/types": "=0.151.0", "@rolldown/pluginutils": "^1.0.0" }, "optionalDependencies": { "@rolldown/binding-android-arm-eabi": "1.2.10", "@rolldown/binding-android-arm64": "1.2.10", "@rolldown/binding-darwin-arm64": "1.2.10", "@rolldown/binding-darwin-x64": "1.2.10", "@rolldown/binding-freebsd-x64": "1.2.10", "@rolldown/binding-linux-arm-gnueabihf": "1.2.10", "@rolldown/binding-linux-arm64-gnu": "1.2.10", "@rolldown/binding-linux-arm64-musl": "1.2.10", "@rolldown/binding-linux-ppc64-gnu": "1.2.10", "@rolldown/binding-linux-s390x-gnu": "1.2.10", "@rolldown/binding-linux-x64-gnu": "1.2.10", "@rolldown/binding-linux-x64-musl": "1.2.10", "@rolldown/binding-openharmony-arm64": "1.2.10", "@rolldown/binding-win32-arm64-msvc": "1.2.10", "@rolldown/binding-win32-x64-msvc": "1.2.10" }, "bin": { "rolldown": "./bin/cli.mjs" } }, "sha512-OxkA08pSryMK7B3XiFA09B4OJ1xJMPgIYCBMY2xchzpqgBGsV1o0DetPAE+Sl3N3L4oCPiEzmHVSOj7iR04Zog=="],++ "sade": ["[email protected]", "", { "dependencies": { "mri": "^1.1.0" } }, "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A=="],++ "source-map-js": ["[email protected]", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],++ "svelte": ["[email protected]", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "@jridgewell/sourcemap-codec": "^1.6.0", "@sveltejs/acorn-typescript": "^1.0.13", "@types/estree": "^1.0.9", "acorn": "^8.18.0", "aria-query": "5.3.1", "axobject-query": "^4.1.0", "clsx": "^2.1.1", "devalue": "^5.9.2", "esm-env": "^1.2.1", "esrap": "^2.3.6", "is-reference": "^3.0.3", "locate-character": "^3.0.0", "magic-string": "^0.30.11", "zimmerframe": "^1.1.2" } }, "sha512-Uqj49lWKB+iSSnneuwiYYJ7MZgkB+eXr0LXBhv4uDuAkXqnWmq65Sxflfvp0Lc6MdKjMUxGaeOKWJqz5SNiVIA=="],++ "svelte-check": ["[email protected]", "", { "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "@sveltejs/load-config": "^0.2.3", "chokidar": "^4.0.1", "fdir": "^6.2.0", "picocolors": "^1.0.0", "sade": "^1.7.4" }, "peerDependencies": { "svelte": "^4.0.0 || ^5.0.0-next.0", "typescript": "^5.0.0 || ^6.0.0" }, "bin": { "svelte-check": "bin/svelte-check" } }, "sha512-t2scM//ZuVbSY/T2w6FSBw1v9s2NEmh/g+sy1lqtosW5ylBV5AF4wFb1Ts9Kf3MbfPDUDJDZ9L436YT0SPTdvw=="],++ "tinyglobby": ["[email protected]", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],++ "typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw=="],++ "undici-types": ["[email protected]", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],++ "vite": ["[email protected]", "", { "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", "postcss": "^8.5.28", "rolldown": "~1.2.6", "tinyglobby": "^0.2.17" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.7.1", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "@vitejs/devtools", "esbuild", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-lhZBVvEHefgE+HQZC9O7EBJgCU/nVzFNl7vkS4RE0APtWLP02/8QVIkQtzBxPquh7lq5/78NHipTj7ODQ6XuyQ=="],++ "vitefu": ["[email protected]", "", { "peerDependencies": { "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" }, "optionalPeers": ["vite"] }, "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg=="],++ "zimmerframe": ["[email protected]", "", {}, "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA=="],++ "svelte/magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],+ }+}diff --git a/tests/integration/review/web/index.html b/tests/integration/review/web/index.htmlnew file mode 100644index 00000000..6b4b070d--- /dev/null+++ b/tests/integration/review/web/index.html@@ -0,0 +1,12 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <title>review · manimgx corpus</title>+ </head>+ <body>+ <div id="app"></div>+ <script type="module" src="/src/main.ts"></script>+ </body>+</html>diff --git a/tests/integration/review/web/package.json b/tests/integration/review/web/package.jsonnew file mode 100644index 00000000..96cc281b--- /dev/null+++ b/tests/integration/review/web/package.json@@ -0,0 +1,21 @@+{+ "name": "corpus-review",+ "private": true,+ "version": "0.0.0",+ "type": "module",+ "scripts": {+ "dev": "vite",+ "build": "vite build",+ "preview": "vite preview",+ "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"+ },+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^7.3.0",+ "@tsconfig/svelte": "^5.0.8",+ "@types/node": "^24.13.3",+ "svelte": "^5.57.0",+ "svelte-check": "^4.7.6",+ "typescript": "~6.0.2",+ "vite": "^8.3.0"+ }+}diff --git a/tests/integration/review/web/src/App.svelte b/tests/integration/review/web/src/App.sveltenew file mode 100644index 00000000..64f6fc92--- /dev/null+++ b/tests/integration/review/web/src/App.svelte@@ -0,0 +1,102 @@+<script lang="ts">+ import CaseView from './lib/CaseView.svelte'+ import Sidebar from './lib/Sidebar.svelte'+ import { Review, setReview } from './lib/review.svelte'++ const review = setReview(new Review())++ // every choice is in the address (see Review.search): read it now and on back and forward+ function restore() {+ review.apply(new URLSearchParams(location.search))+ review.open(review.selected)+ }+ review.apply(new URLSearchParams(location.search))+ review.selected ??= decodeURIComponent(location.hash.slice(1)) || null // an older #case link+ review.load().then(() => review.open(review.selected))++ // and write it as they change: at most every 0.4 s, since browsers refuse a flood of history+ // writes (holding an arrow key, playing), and always the latest+ let written = 0+ $effect(() => {+ if (review.search === location.search) return+ const timer = setTimeout(+ () => {+ written = performance.now()+ history.replaceState(history.state, '', review.search || location.pathname)+ },+ Math.max(0, written + 400 - performance.now()),+ )+ return () => clearTimeout(timer)+ })++ function onkeydown(event: KeyboardEvent) {+ const typing = event.target instanceof HTMLElement && event.target.closest('input, textarea, select')+ if (typing || event.metaKey || event.ctrlKey || event.altKey) return+ if (event.key === '/') {+ event.preventDefault()+ document.getElementById('search')?.focus()+ } else if (['ArrowDown', 'ArrowUp', 'j', 'k'].includes(event.key)) {+ // up and down walk the list; left and right are the timeline's+ event.preventDefault()+ const down = event.key === 'ArrowDown' || event.key === 'j'+ const next = review.neighbour(down ? 1 : -1)+ if (next) review.go(next, 'replace')+ }+ }+</script>++<svelte:window onpopstate={restore} {onkeydown} />++<div class="panel">+ <Sidebar />+ <main>+ {#if review.error}+ <p class="error">{review.error}</p>+ {/if}+ {#if review.detail}+ <CaseView detail={review.detail} />+ {:else}+ <p class="empty">+ Pick a case. <kbd>/</kbd> searches, <kbd>↑</kbd> <kbd>↓</kbd> walk the list,+ <kbd>←</kbd> <kbd>→</kbd> the frames, <kbd>0</kbd>–<kbd>3</kbd> give the verdict.+ </p>+ {/if}+ </main>+</div>++<style>+ .panel {+ display: grid;+ grid-template-columns: 320px 1fr;+ height: 100vh;+ }++ main {+ display: flex;+ flex-direction: column;+ min-width: 0;+ min-height: 0;+ }++ .error {+ margin: 0;+ padding: 6px 12px;+ color: var(--not-working);+ background: color-mix(in srgb, var(--not-working) 12%, var(--bg));+ font-family: var(--mono);+ font-size: 12px;+ white-space: pre-wrap;+ }++ .empty {+ margin: auto;+ color: var(--faint);+ }++ kbd {+ padding: 0 4px;+ border: 1px solid var(--line);+ border-radius: 3px;+ font-family: var(--mono);+ }+</style>diff --git a/tests/integration/review/web/src/app.css b/tests/integration/review/web/src/app.cssnew file mode 100644index 00000000..5d63c524--- /dev/null+++ b/tests/integration/review/web/src/app.css@@ -0,0 +1,97 @@+/* The panel's page and its palette; each component styles itself. */++:root {+ --bg: #0e1014;+ --panel: #14171d;+ --raised: #1b1f27;+ --line: #262b36;+ --text: #d8dce4;+ --dim: #8b93a5;+ --faint: #5b6375;+ --accent: #56b6d4;++ --working: #3fcf72;+ --not-matching: #e3a33b;+ --not-working: #e5534b;+ --stale: #5b6375;++ /* the timeline's legend */+ --same: #3fcf72;+ --differs: #e5534b;+ --manimgx-only: #4f8ff7;+ --ce-only: #b77ee6;++ --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;+ --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;++ color-scheme: dark;+ font: 13px/1.4 var(--sans);+ color: var(--text);+ background: var(--bg);+}++* {+ box-sizing: border-box;+}++body {+ margin: 0;+ height: 100vh;+ overflow: hidden;+}++button,+input,+select,+textarea {+ font: inherit;+ color: inherit;+}++button,+select {+ cursor: pointer;+}++/* buttons, as the panel draws them everywhere */+.button {+ padding: 3px 9px;+ border: 1px solid var(--line);+ border-radius: 5px;+ background: var(--raised);+}++.button:hover:not(:disabled) {+ border-color: var(--faint);+}++.button.on {+ border-color: var(--accent);+ color: var(--accent);+ background: color-mix(in srgb, var(--accent) 12%, var(--raised));+}++.button:disabled {+ opacity: 0.5;+ cursor: default;+}++.field {+ padding: 3px 7px;+ border: 1px solid var(--line);+ border-radius: 5px;+ background: var(--panel);+}++.field:focus {+ outline: none;+ border-color: var(--accent);+}++.label {+ color: var(--faint);+ font-size: 11px;+ font-weight: 600;+ letter-spacing: 0.08em;+ text-transform: uppercase;+}diff --git a/tests/integration/review/web/src/lib/CaseView.svelte b/tests/integration/review/web/src/lib/CaseView.sveltenew file mode 100644index 00000000..7d22b4f7--- /dev/null+++ b/tests/integration/review/web/src/lib/CaseView.svelte@@ -0,0 +1,293 @@+<!--+ @component+ One case: its verdict (the comparison's, or a reviewer's), its renders, its source and the+ comparison with CE.+-->+<script lang="ts">+ import type { CaseDetail, Verdict } from './api'+ import Compare from './Compare.svelte'+ import { getReview, label } from './review.svelte'+ import Source from './Source.svelte'++ let { detail }: { detail: CaseDetail } = $props()++ const review = getReview()++ let copied = $state(false)++ // a review's verdict applies only to the renders it was given for+ const verdict = $derived<Verdict | 'auto'>(detail.reviewed && detail.review?.verdict ? detail.review.verdict : 'auto')+ const judged = $derived(detail.state !== 'stale' && detail.state !== 'unrendered')+ const choices = $derived<{ value: Verdict | 'auto'; text: string; key: string }[]>([+ { value: 'auto', text: `auto (${label(detail.auto)})`, key: '0' },+ { value: 'working', text: 'working', key: '1' },+ { value: 'not_matching', text: 'not matching', key: '2' },+ { value: 'not_working', text: 'not working', key: '3' },+ ])+ let note = $derived(detail.review?.note ?? '')++ function choose(value: Verdict | 'auto') {+ if (judged && value !== verdict) review.setVerdict(value, note)+ }++ const saveNote = () => {+ if (note !== (detail.review?.note ?? '')) review.setVerdict(verdict, note)+ }++ function onkeydown(event: KeyboardEvent) {+ const typing = event.target instanceof HTMLElement && event.target.closest('input, textarea, select')+ if (typing || event.metaKey || event.ctrlKey || event.altKey) return+ const choice = choices.find((c) => c.key === event.key)+ if (choice) {+ event.preventDefault()+ choose(choice.value)+ }+ }++ async function copy() {+ await navigator.clipboard.writeText(detail.name)+ copied = true+ setTimeout(() => (copied = false), 1200)+ }++ const seconds = (value: number | null) => (value === null ? '—' : `${value.toFixed(2)} s`)+</script>++<svelte:window {onkeydown} />++<header>+ <div class="line">+ <h1>{detail.name}</h1>+ <button class="button icon" title="copy the case's name" onclick={copy}>{copied ? '✓' : '⧉'}</button>+ <span class="state {detail.state}">{label(detail.state)}</span>++ <div class="verdicts" role="group" aria-label="verdict">+ {#each choices as choice (choice.value)}+ <button+ class="button verdict {choice.value}"+ class:on={verdict === choice.value}+ disabled={!judged}+ title="{choice.text} (key {choice.key})"+ onclick={() => choose(choice.value)}+ >+ <kbd>{choice.key}</kbd>{choice.text}+ </button>+ {/each}+ </div>++ <span class="actions">+ {#if review.busy}<span class="busy">{review.busy}…</span>{/if}+ <button class="button" disabled={review.busy !== null} onclick={() => review.render('manimgx')}>↻ manimgx</button>+ <button class="button" disabled={review.busy !== null} onclick={() => review.render('ce')}>↻ ce</button>+ <button class="button" disabled={review.busy !== null} onclick={() => review.render('both')}>↻ both</button>+ </span>+ </div>++ <div class="line facts">+ <span>manimgx {detail.manimgx.frames.length} frames · {seconds(detail.manimgx.duration)}</span>+ <span>ce {detail.ce.version} {detail.ce.frames.length} frames · {seconds(detail.ce.duration)}</span>+ {#if detail.reasons.length}+ <span class="reasons">differs: {detail.reasons.join(', ')}</span>+ {/if}+ {#each [detail.manimgx, detail.ce] as render, i (i)}+ {#if render.error}<span class="failed">{i === 0 ? 'manimgx' : 'ce'}: {render.error}</span>{/if}+ {/each}+ </div>++ <div class="line">+ <input+ class="field note"+ placeholder="a note for this case (saved on enter or leaving the field)"+ bind:value={note}+ onchange={saveNote}+ />+ {#if detail.stale_review}+ <span class="stale-review" title="its verdict no longer applies">review was for other renders</span>+ {/if}+ </div>+</header>++<div class="panes" class:wide={!review.showSource}>+ {#if review.showSource}+ <section class="source">+ <div class="bar">+ <button class="button icon" title="hide the source" onclick={() => (review.showSource = false)}>‹</button>+ <span class="label">source</span>+ </div>+ <Source source={detail.source} problems={detail.problems} />+ </section>+ {/if}+ <section class="compare">+ <div class="bar">+ {#if !review.showSource}+ <button class="button icon" title="show the source" onclick={() => (review.showSource = true)}>›</button>+ {/if}+ <span class="label">compare</span>+ </div>+ {#key detail.name}+ <Compare {detail} />+ {/key}+ </section>+</div>++<style>+ header {+ display: flex;+ flex-direction: column;+ gap: 6px;+ padding: 10px 14px;+ border-bottom: 1px solid var(--line);+ background: var(--panel);+ }++ .line {+ display: flex;+ align-items: center;+ gap: 10px;+ min-width: 0;+ }++ h1 {+ margin: 0;+ font: 600 15px var(--mono);+ }++ .icon {+ padding: 0 6px;+ line-height: 20px;+ }++ .state {+ padding: 1px 7px;+ border-radius: 4px;+ font-size: 11px;+ font-weight: 700;+ letter-spacing: 0.06em;+ text-transform: uppercase;+ color: var(--bg);+ background: var(--stale);+ }++ .state.working {+ background: var(--working);+ }++ .state.not_matching {+ background: var(--not-matching);+ }++ .state.not_working {+ background: var(--not-working);+ }++ .verdicts {+ display: flex;+ gap: 4px;+ }++ .verdict {+ display: flex;+ align-items: center;+ gap: 6px;+ }++ .verdict kbd {+ padding: 0 4px;+ border: 1px solid var(--line);+ border-radius: 3px;+ color: var(--faint);+ font: 11px var(--mono);+ }++ /* the chosen verdict, in its colour */+ .verdict.on {+ --tone: var(--accent);+ border-color: var(--tone);+ color: var(--tone);+ background: color-mix(in srgb, var(--tone) 14%, var(--raised));+ }++ .verdict.on.working {+ --tone: var(--working);+ }++ .verdict.on.not_matching {+ --tone: var(--not-matching);+ }++ .verdict.on.not_working {+ --tone: var(--not-working);+ }++ .verdict.on kbd {+ border-color: var(--tone);+ color: var(--tone);+ }++ .actions {+ display: flex;+ align-items: center;+ gap: 6px;+ margin-left: auto;+ }++ .busy {+ color: var(--accent);+ font-size: 12px;+ }++ .facts {+ flex-wrap: wrap;+ gap: 14px;+ color: var(--dim);+ font-family: var(--mono);+ font-size: 12px;+ }++ .reasons {+ color: var(--not-matching);+ }++ .failed {+ color: var(--not-working);+ }++ .note {+ flex: 1;+ }++ .stale-review {+ color: var(--not-matching);+ font-size: 12px;+ }++ .panes {+ flex: 1;+ display: grid;+ grid-template-columns: minmax(280px, 2fr) 3fr;+ min-height: 0;+ }++ .panes.wide {+ grid-template-columns: 1fr;+ }++ section {+ display: flex;+ flex-direction: column;+ min-width: 0;+ min-height: 0;+ }++ .source {+ border-right: 1px solid var(--line);+ }++ .bar {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 6px 12px;+ border-bottom: 1px solid var(--line);+ }+</style>diff --git a/tests/integration/review/web/src/lib/Compare.svelte b/tests/integration/review/web/src/lib/Compare.sveltenew file mode 100644index 00000000..527a0f9d--- /dev/null+++ b/tests/integration/review/web/src/lib/Compare.svelte@@ -0,0 +1,249 @@+<!--+ @component+ CE's frame and manimgx's at the same scene time — side by side, one over the other, or their+ difference — and the timeline to walk. ←/→ step, space plays, in a loop.+-->+<script lang="ts">+ import { frameUrl, type CaseDetail, type Engine } from './api'+ import { differences } from './differences'+ import { getReview, MODES } from './review.svelte'+ import Timeline from './Timeline.svelte'++ let { detail }: { detail: CaseDetail } = $props()++ const review = getReview()++ const metric = $derived(review.settings?.metric ?? 'local_max')+ const tolerance = $derived(review.settings?.tolerance ?? 0)+ const slot = $derived(detail.slots[review.at])+ const error = $derived(slot?.errors?.[metric])++ function url(engine: Engine, index: number | null | undefined): string | null {+ const hash = index === null || index === undefined ? undefined : detail[engine].frames[index]+ return hash === undefined ? null : frameUrl(detail.name, engine, hash)+ }++ const ce = $derived(url('ce', slot?.ce))+ const manimgx = $derived(url('manimgx', slot?.manimgx))++ function step(by: number) {+ review.playing = false+ review.at = Math.min(Math.max(review.at + by, 0), detail.slots.length - 1)+ }++ // how long the last step stays, in seconds, before the scene plays again: it is the scene's+ // end, with no time of its own to last+ const HOLD = 1++ // playing, in a loop: each step lasts as long as the scene time until the next, the last one+ // HOLD (and it waits while the next case loads: that one plays from its own start)+ $effect(() => {+ if (!review.playing || review.selected !== detail.name) return+ const now = detail.slots[review.at]+ if (!now || detail.slots.length < 2) return // nothing to play+ const next = detail.slots[review.at + 1]+ const lasts = next ? next.time - now.time : HOLD+ const timer = setTimeout(() => (review.at = next ? review.at + 1 : 0), Math.max(16, lasts * 1000))+ return () => clearTimeout(timer)+ })++ function onkeydown(event: KeyboardEvent) {+ if (event.target instanceof HTMLElement && event.target.closest('input, textarea, select')) return+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {+ event.preventDefault()+ step(event.key === 'ArrowLeft' ? -1 : 1)+ } else if (event.key === ' ') {+ event.preventDefault()+ play()+ }+ }++ // played from its last step, the scene starts over at once; paused there, it stays+ function play() {+ if (!review.playing && review.at >= detail.slots.length - 1) review.at = 0+ review.playing = !review.playing+ }+</script>++<svelte:window {onkeydown} />++<div class="compare">+ <div class="toolbar">+ {#each MODES as choice (choice)}+ <button class="button" class:on={review.mode === choice} onclick={() => (review.mode = choice)}>{choice}</button>+ {/each}+ <span class="readout">+ {#if slot}+ {slot.time.toFixed(2)} s+ {#if slot.ce_time !== null && slot.manimgx !== null && slot.ce_time !== slot.time}+ (ce's frame is from {slot.ce_time.toFixed(2)} s)+ {/if}+ · {review.at + 1}/{detail.slots.length}+ {#if error !== undefined}+ · <span class:exceeds={error > tolerance}>{metric} {error.toFixed(2)}</span>+ {/if}+ {/if}+ </span>+ </div>++ {#snippet frame(engine: Engine, src: string | null)}+ <figure>+ <figcaption>{engine === 'ce' ? 'manim ce' : 'manimgx'}</figcaption>+ {#if src}+ <img {src} alt="{engine} at {slot?.time.toFixed(2)} s" />+ {:else}+ <div class="missing">no {engine} frame at this time</div>+ {/if}+ </figure>+ {/snippet}++ <div class="view">+ {#if detail.slots.length === 0}+ <p class="missing">nothing rendered</p>+ {:else if review.mode === 'parallel'}+ <div class="parallel">+ {@render frame('ce', ce)}+ {@render frame('manimgx', manimgx)}+ </div>+ {:else if review.mode === 'superimposed'}+ <figure>+ <figcaption>+ <span>manim ce</span>+ <input type="range" min="0" max="1" step="0.01" bind:value={review.mix} aria-label="blend" />+ <span>manimgx</span>+ </figcaption>+ <div class="stack">+ {#if ce}<img src={ce} alt="ce" />{/if}+ {#if manimgx}<img class="over" src={manimgx} alt="manimgx" style:opacity={ce ? review.mix : 1} />{/if}+ </div>+ </figure>+ {:else if ce && manimgx}+ <figure>+ <figcaption>where they differ: black, then red → yellow → white as the difference grows</figcaption>+ {#key `${ce} ${manimgx}`}+ <canvas {@attach differences(ce, manimgx)}></canvas>+ {/key}+ </figure>+ {:else}+ <p class="missing">only one engine shows this time</p>+ {/if}+ </div>++ <div class="transport">+ <button class="button" onclick={() => step(-1)} title="previous (←)">◀</button>+ <button class="button" title="play (space)" onclick={play}>{review.playing ? '❚❚' : '▶'}</button>+ <button class="button" onclick={() => step(1)} title="next (→)">▶︎|</button>+ <div class="line">+ <Timeline+ slots={detail.slots}+ at={review.at}+ {metric}+ {tolerance}+ onselect={(i) => ((review.playing = false), (review.at = i))}+ />+ </div>+ </div>+</div>++<style>+ .compare {+ flex: 1;+ display: flex;+ flex-direction: column;+ min-height: 0;+ }++ .toolbar {+ display: flex;+ align-items: center;+ gap: 6px;+ padding: 8px 12px;+ }++ .readout {+ margin-left: auto;+ color: var(--dim);+ font-family: var(--mono);+ font-size: 12px;+ }++ .exceeds {+ color: var(--differs);+ }++ .view {+ flex: 1;+ min-height: 0;+ overflow: auto;+ padding: 4px 12px;+ }++ .parallel {+ display: grid;+ grid-template-columns: 1fr 1fr;+ gap: 10px;+ }++ figure {+ margin: 0;+ }++ figcaption {+ display: flex;+ align-items: center;+ gap: 8px;+ margin-bottom: 4px;+ color: var(--dim);+ font-size: 12px;+ }++ figcaption input {+ width: 140px;+ }++ img,+ canvas {+ display: block;+ width: 100%;+ height: auto;+ aspect-ratio: 16 / 9;+ border: 1px solid var(--line);+ background: #000;+ }++ .stack {+ position: relative;+ }++ .stack .over {+ position: absolute;+ inset: 0;+ }++ .missing {+ display: grid;+ place-items: center;+ aspect-ratio: 16 / 9;+ margin: 0;+ border: 1px dashed var(--line);+ color: var(--faint);+ }++ .transport {+ display: flex;+ align-items: flex-start;+ gap: 6px;+ padding: 10px 12px 12px;+ border-top: 1px solid var(--line);+ }++ .transport .button {+ min-width: 32px;+ }++ .line {+ flex: 1;+ min-width: 0;+ padding-top: 3px;+ }+</style>diff --git a/tests/integration/review/web/src/lib/Sidebar.svelte b/tests/integration/review/web/src/lib/Sidebar.sveltenew file mode 100644index 00000000..5cb858c5--- /dev/null+++ b/tests/integration/review/web/src/lib/Sidebar.svelte@@ -0,0 +1,284 @@+<!--+ @component+ Every case: counts, the comparison's settings, search (names, and code from three letters),+ filters, and the list.+-->+<script lang="ts">+ import Squares from './Squares.svelte'+ import { getReview, label, SORTS, STATE_FILTERS } from './review.svelte'++ const review = getReview()++ /** A plain click opens the case here; a modified one (a new tab, a copied link) follows the+ * link, which holds every choice. */+ function follow(event: MouseEvent, name: string) {+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return+ event.preventDefault()+ review.go(name, 'push')+ }++ // the chosen case stays in sight, from a link too+ let list = $state<HTMLOListElement>()+ $effect(() => {+ void [review.selected, review.visible]+ list?.querySelector('.selected')?.scrollIntoView({ block: 'nearest' })+ })++ let metric = $derived(review.settings?.metric ?? '')+ let tolerance = $derived(review.settings?.tolerance ?? 0)++ function saveSettings() {+ if (review.settings && (metric !== review.settings.metric || tolerance !== review.settings.tolerance)) {+ review.saveSettings(metric, tolerance)+ }+ }+</script>++<aside>+ <header>+ <span class="label">cases</span>+ <span class="counts">+ {#each ['working', 'not_matching', 'not_working'] as const as state (state)}+ <span class="count" title={label(state)}>+ <i class="dot {state}"></i>{review.counts.byState.get(state) ?? 0}+ </span>+ {/each}+ {#if (review.counts.byState.get('stale') ?? 0) + (review.counts.byState.get('unrendered') ?? 0) > 0}+ <span class="count" title="stale or unrendered">+ <i class="dot stale"></i>{(review.counts.byState.get('stale') ?? 0) ++ (review.counts.byState.get('unrendered') ?? 0)}+ </span>+ {/if}+ </span>+ </header>++ {#if review.settings}+ <div class="row settings" title="how CE and manimgx frames are compared">+ <span class="label">metric</span>+ <select class="field" bind:value={metric} onchange={saveSettings}>+ {#each review.settings.metrics as name (name)}+ <option value={name}>{name}</option>+ {/each}+ </select>+ <span class="label">≤</span>+ <input class="field tolerance" type="number" min="0" max="255" step="1" bind:value={tolerance} onchange={saveSettings} />+ </div>+ {/if}++ <div class="row">+ <input+ id="search"+ class="field search"+ type="search"+ placeholder="search names and code /"+ autocomplete="off"+ spellcheck="false"+ bind:value={review.query}+ />+ </div>++ <div class="row chips">+ {#each STATE_FILTERS as state (state)}+ <button class="button" class:on={review.stateFilter === state} onclick={() => (review.stateFilter = state)}>+ {state === 'all' ? 'all' : label(state)}+ </button>+ {/each}+ </div>++ <div class="row chips">+ <button class="button" class:on={review.failingSource} onclick={() => (review.failingSource = !review.failingSource)}>+ source ✗ {review.counts.source}+ </button>+ <button class="button" class:on={review.failingTypes} onclick={() => (review.failingTypes = !review.failingTypes)}>+ types ✗ {review.counts.types}+ </button>+ <span class="gap"></span>+ <button class="button" class:on={review.onlyReviewed} onclick={() => (review.onlyReviewed = !review.onlyReviewed)}>+ reviewed+ </button>+ <button class="button" class:on={review.onlyNoted} onclick={() => (review.onlyNoted = !review.onlyNoted)}>+ noted+ </button>+ </div>++ <div class="row chips">+ <span class="label">sort</span>+ {#each SORTS as sort (sort)}+ <button class="button" class:on={review.sort === sort} onclick={() => (review.sort = sort)}>{sort}</button>+ {/each}+ <span class="shown">{review.visible.length} shown</span>+ </div>++ <ol bind:this={list}>+ {#each review.visible as item (item.name)}+ <li>+ <a+ href={review.link(item.name)}+ class:selected={review.selected === item.name}+ onclick={(event) => follow(event, item.name)}+ >+ <span class="name">{item.name}</span>+ {#if review.inSource.has(item.name)}<span class="badge" title="found in the code">code</span>{/if}+ {#if item.reviewed}<span class="mark" title="verdict set by review">●</span>{/if}+ {#if item.noted}<span class="mark" title="has a note">✎</span>{/if}+ <Squares {item} />+ <span class="worst">{item.worst === null ? '' : item.worst.toFixed(1)}</span>+ </a>+ </li>+ {:else}+ <li class="none">no case matches</li>+ {/each}+ </ol>+</aside>++<style>+ aside {+ display: flex;+ flex-direction: column;+ min-height: 0;+ border-right: 1px solid var(--line);+ background: var(--panel);+ }++ header,+ .row {+ display: flex;+ align-items: center;+ gap: 6px;+ padding: 6px 10px;+ }++ header {+ justify-content: space-between;+ padding-top: 10px;+ }++ .counts {+ display: flex;+ gap: 10px;+ font-family: var(--mono);+ font-size: 12px;+ }++ .count {+ display: flex;+ align-items: center;+ gap: 4px;+ }++ .dot {+ width: 7px;+ height: 7px;+ border-radius: 50%;+ background: var(--stale);+ }++ .dot.working {+ background: var(--working);+ }++ .dot.not_matching {+ background: var(--not-matching);+ }++ .dot.not_working {+ background: var(--not-working);+ }++ .settings select {+ flex: 1;+ }++ .tolerance {+ width: 64px;+ }++ .search {+ flex: 1;+ }++ .chips {+ flex-wrap: wrap;+ gap: 4px;+ padding-top: 2px;+ padding-bottom: 2px;+ }++ .chips .button {+ padding: 1px 7px;+ font-size: 12px;+ }++ .gap {+ flex: 1;+ }++ .shown {+ margin-left: auto;+ color: var(--faint);+ font-size: 12px;+ }++ ol {+ flex: 1;+ min-height: 0;+ margin: 6px 0 0;+ padding: 0;+ overflow-y: auto;+ list-style: none;+ border-top: 1px solid var(--line);+ }++ a {+ display: flex;+ align-items: center;+ gap: 6px;+ padding: 3px 10px;+ color: var(--text);+ text-decoration: none;+ border-left: 2px solid transparent;+ }++ a:hover {+ background: var(--raised);+ }++ a.selected {+ border-left-color: var(--accent);+ background: color-mix(in srgb, var(--accent) 10%, var(--panel));+ }++ .name {+ flex: 1;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }++ .badge {+ padding: 0 4px;+ border-radius: 3px;+ color: var(--accent);+ background: color-mix(in srgb, var(--accent) 15%, transparent);+ font-size: 10px;+ }++ .mark {+ color: var(--dim);+ font-size: 10px;+ }++ .worst {+ width: 38px;+ color: var(--faint);+ font-family: var(--mono);+ font-size: 11px;+ text-align: right;+ }++ .none {+ padding: 12px;+ color: var(--faint);+ }+</style>diff --git a/tests/integration/review/web/src/lib/Source.svelte b/tests/integration/review/web/src/lib/Source.sveltenew file mode 100644index 00000000..d0eb6c87--- /dev/null+++ b/tests/integration/review/web/src/lib/Source.svelte@@ -0,0 +1,94 @@+<!--+ @component+ The scene's source — the one file both engines run — with the lines the type report flags.+-->+<script lang="ts">+ let { source, problems }: { source: string; problems: string[] } = $props()++ const lines = $derived(source.replace(/\n$/, '').split('\n'))+ const flagged = $derived(new Set(problems.map((p) => /line (\d+):/.exec(p)?.[1]).filter(Boolean).map(Number)))+</script>++<div class="source">+ <pre>{#each lines as text, i (i)}<span class="line" class:flag={flagged.has(i + 1)}>{text}</span>{/each}</pre>+ {#if problems.length}+ <ul>+ {#each problems as problem, i (i)}+ <li class:heading={!problem.startsWith(' ')}>{problem.trim()}</li>+ {/each}+ </ul>+ {:else}+ <p class="clean">type safe: strict ty, no escapes, nothing manimgx leaves Any</p>+ {/if}+</div>++<style>+ .source {+ flex: 1;+ min-height: 0;+ overflow: auto;+ }++ pre {+ margin: 0;+ padding: 8px 0;+ font: 12px/1.55 var(--mono);+ counter-reset: line;+ tab-size: 4;+ }++ .line {+ display: block;+ padding-right: 12px;+ white-space: pre;+ }++ .line::before {+ counter-increment: line;+ content: counter(line);+ display: inline-block;+ width: 3.2em;+ margin-right: 1em;+ padding-right: 0.6em;+ color: var(--faint);+ text-align: right;+ user-select: none;+ }++ .line.flag {+ background: color-mix(in srgb, var(--not-working) 14%, transparent);+ }++ .line.flag::before {+ color: var(--not-working);+ }++ ul {+ margin: 0;+ padding: 8px 14px 14px;+ border-top: 1px solid var(--line);+ list-style: none;+ font: 12px/1.5 var(--mono);+ color: var(--dim);+ }++ li {+ padding-left: 12px;+ white-space: pre-wrap;+ word-break: break-word;+ }++ li.heading {+ padding-left: 0;+ margin-top: 6px;+ color: var(--not-working);+ }++ .clean {+ margin: 0;+ padding: 8px 14px;+ border-top: 1px solid var(--line);+ color: var(--working);+ font-size: 12px;+ }+</style>diff --git a/tests/integration/review/web/src/lib/Squares.svelte b/tests/integration/review/web/src/lib/Squares.sveltenew file mode 100644index 00000000..7c391ac0--- /dev/null+++ b/tests/integration/review/web/src/lib/Squares.svelte@@ -0,0 +1,59 @@+<!--+ @component+ A case's checks at a glance: its source (both references rendered from this exact scene.py),+ its types (strict ty, no escapes, nothing manimgx leaves Any), and its comparison with CE.+-->+<script lang="ts">+ import type { CaseSummary } from './api'+ import { label } from './review.svelte'++ let { item }: { item: CaseSummary } = $props()++ const checks = $derived([+ {+ name: 'source',+ tone: item.checks.source ? 'pass' : 'fail',+ says: item.checks.source ? 'renders are of this source' : 'renders are stale',+ },+ {+ name: 'types',+ tone: item.checks.types ? 'pass' : 'fail',+ says: item.checks.types ? 'type safe' : 'type problems',+ },+ { name: 'ce', tone: item.state, says: label(item.state) },+ ])+</script>++<span class="squares">+ {#each checks as check (check.name)}+ <span class="square {check.tone}" title="{check.name}: {check.says}"></span>+ {/each}+</span>++<style>+ .squares {+ display: inline-flex;+ gap: 2px;+ }++ .square {+ width: 7px;+ height: 7px;+ border-radius: 1.5px;+ background: var(--stale);+ }++ .pass,+ .working {+ background: var(--working);+ }++ .fail,+ .not_working {+ background: var(--not-working);+ }++ .not_matching {+ background: var(--not-matching);+ }+</style>diff --git a/tests/integration/review/web/src/lib/Timeline.svelte b/tests/integration/review/web/src/lib/Timeline.sveltenew file mode 100644index 00000000..2b39cf29--- /dev/null+++ b/tests/integration/review/web/src/lib/Timeline.svelte@@ -0,0 +1,125 @@+<!--+ @component+ The scene's time, a block per step: green where CE and manimgx show the same thing (within+ tolerance), red where they differ, and the engine's colour where only one of them has a frame.+-->+<script lang="ts">+ import type { Slot } from './api'++ interface Props {+ slots: Slot[]+ at: number+ metric: string+ tolerance: number+ onselect: (index: number) => void+ }++ let { slots, at, metric, tolerance, onselect }: Props = $props()++ type Kind = 'same' | 'differs' | 'manimgx-only' | 'ce-only'++ const legend: { kind: Kind; text: string }[] = [+ { kind: 'same', text: 'same' },+ { kind: 'differs', text: 'differs' },+ { kind: 'manimgx-only', text: 'manimgx only' },+ { kind: 'ce-only', text: 'ce only' },+ ]++ const kind = (slot: Slot): Kind => {+ if (slot.ce === null) return 'manimgx-only'+ if (slot.manimgx === null) return 'ce-only'+ return (slot.errors?.[metric] ?? 0) <= tolerance ? 'same' : 'differs'+ }++ const kinds = $derived(slots.map(kind))+ const counts = $derived(+ kinds.reduce((found, k) => found.set(k, (found.get(k) ?? 0) + 1), new Map<Kind, number>()),+ )++ function title(slot: Slot, i: number): string {+ const error = slot.errors?.[metric]+ const measured = error === undefined ? '' : ` · ${metric} ${error.toFixed(2)}`+ const held = slot.ce_time !== null && slot.manimgx !== null && slot.ce_time !== slot.time+ const from = held ? ` (ce's from ${slot.ce_time?.toFixed(2)} s)` : ''+ return `${i + 1}/${slots.length} · ${slot.time.toFixed(2)} s${from}${measured}`+ }+</script>++<div class="timeline">+ {#each slots as slot, i (i)}+ <button+ class="block {kinds[i]}"+ class:at={i === at}+ title={title(slot, i)}+ aria-label={title(slot, i)}+ onclick={() => onselect(i)}+ ></button>+ {/each}+</div>++<ul class="legend">+ {#each legend as { kind, text } (kind)}+ <li><i class="block {kind}"></i>{text} {counts.get(kind) ?? 0}</li>+ {/each}+</ul>++<style>+ .timeline {+ display: flex;+ gap: 1px;+ height: 16px;+ }++ .timeline .block {+ flex: 1 1 0;+ min-width: 2px;+ padding: 0;+ border: 0;+ border-radius: 1.5px;+ }++ .block.at {+ outline: 2px solid var(--text);+ outline-offset: 1px;+ z-index: 1;+ }++ .same {+ background: var(--same);+ }++ .differs {+ background: var(--differs);+ }++ .manimgx-only {+ background: var(--manimgx-only);+ }++ .ce-only {+ background: var(--ce-only);+ }++ .legend {+ display: flex;+ gap: 14px;+ margin: 8px 0 0;+ padding: 0;+ list-style: none;+ color: var(--dim);+ font-size: 12px;+ }++ .legend li {+ display: flex;+ align-items: center;+ gap: 5px;+ }++ .legend .block {+ display: inline-block;+ width: 10px;+ height: 10px;+ border-radius: 2px;+ }+</style>diff --git a/tests/integration/review/web/src/lib/api.ts b/tests/integration/review/web/src/lib/api.tsnew file mode 100644index 00000000..706f57d7--- /dev/null+++ b/tests/integration/review/web/src/lib/api.ts@@ -0,0 +1,112 @@+// The review server's API (tests/integration/review/app.py), typed as it answers.++export type Verdict = 'working' | 'not_matching' | 'not_working'+/** Where a case stands: a verdict, or no current renders to judge. */+export type State = Verdict | 'stale' | 'unrendered'+export type Engine = 'manimgx' | 'ce'++export interface Settings {+ metric: string+ tolerance: number+ metrics: string[]+}++export interface Checks {+ /** Both references were rendered from this exact scene.py. */+ source: boolean+ /** Strict ty, no escapes, no Any/Unknown from manimgx. */+ types: boolean+}++export interface CaseSummary {+ name: string+ /** What counts: a current review's verdict, else the comparison's. */+ state: State+ /** What the comparison alone says. */+ auto: State+ reviewed: boolean+ noted: boolean+ checks: Checks+ /** The largest error of any same-time pair, in the current metric. */+ worst: number | null+}++export interface Render {+ /** The engine's version; for manimgx, empty. */+ version: string+ /** Each frame's hash, in order (a held frame repeats its hash). */+ frames: string[]+ duration: number | null+ error: string | null+}++/** One step of the timeline: a scene time, and the frame each engine has on screen then. */+export interface Slot {+ time: number+ ce: number | null+ /** The scene time CE's frame shows: up to a frame earlier, when CE's frames fall off+ * manimgx's (CE rounds each play to whole frames). */+ ce_time: number | null+ manimgx: number | null+ /** Per metric, when both engines show this time. */+ errors: Record<string, number> | null+}++export interface Review {+ /** null: a note alone, and the comparison's verdict stands. */+ verdict: Verdict | null+ note: string+ at: string+}++export interface CaseDetail extends CaseSummary {+ source: string+ /** The type report's findings, one per line. */+ problems: string[]+ manimgx: Render+ ce: Render+ slots: Slot[]+ /** Why the comparison differs under the current settings. */+ reasons: string[]+ review: Review | null+ /** A review exists, but for other renders than these. */+ stale_review: boolean+}++async function request<T>(path: string, init?: RequestInit): Promise<T> {+ const response = await fetch(path, {+ ...init,+ headers: { 'content-type': 'application/json', ...init?.headers },+ })+ if (!response.ok) {+ const body = await response.text()+ throw new Error(`${response.status} ${path}: ${body}`)+ }+ return (await response.json()) as T+}++export const api = {+ cases: () => request<CaseSummary[]>('/api/cases'),+ sources: () => request<Record<string, string>>('/api/sources'),+ detail: (name: string) => request<CaseDetail>(`/api/cases/${encodeURIComponent(name)}`),+ settings: () => request<Settings>('/api/settings'),+ saveSettings: (metric: string, tolerance: number) =>+ request<Settings>('/api/settings', {+ method: 'PUT',+ body: JSON.stringify({ metric, tolerance }),+ }),+ review: (name: string, verdict: Verdict | 'auto', note: string) =>+ request<CaseDetail>(`/api/cases/${encodeURIComponent(name)}/review`, {+ method: 'PUT',+ body: JSON.stringify({ verdict, note }),+ }),+ render: (name: string, engine: Engine | 'both') =>+ request<CaseDetail>(`/api/cases/${encodeURIComponent(name)}/render`, {+ method: 'POST',+ body: JSON.stringify({ engine }),+ }),+}++export function frameUrl(name: string, engine: Engine, hash: string): string {+ return `/api/cases/${encodeURIComponent(name)}/frames/${engine}/${hash}.png`+}diff --git a/tests/integration/review/web/src/lib/differences.ts b/tests/integration/review/web/src/lib/differences.tsnew file mode 100644index 00000000..a8b5646c--- /dev/null+++ b/tests/integration/review/web/src/lib/differences.ts@@ -0,0 +1,50 @@+import type { Attachment } from 'svelte/attachments'++async function load(url: string): Promise<HTMLImageElement> {+ const image = new Image()+ image.src = url+ await image.decode()+ return image+}++function pixels(image: HTMLImageElement): Uint8ClampedArray {+ const { naturalWidth: width, naturalHeight: height } = image+ const context = new OffscreenCanvas(width, height).getContext('2d')!+ context.drawImage(image, 0, 0)+ return context.getImageData(0, 0, width, height).data+}++/** Draws where two frames differ: each pixel's largest channel difference, as heat (black,+ * then red, yellow, white as the difference grows; square-rooted, so faint differences show). */+export function differences(a: string, b: string): Attachment<HTMLCanvasElement> {+ return (canvas) => {+ let live = true+ Promise.all([load(a), load(b)]).then(([first, second]) => {+ if (!live) return+ const width = first.naturalWidth+ const height = first.naturalHeight+ const one = pixels(first)+ const two = pixels(second)+ canvas.width = width+ canvas.height = height+ const context = canvas.getContext('2d')!+ const heat = context.createImageData(width, height)+ for (let p = 0; p < one.length; p += 4) {+ const d = Math.max(+ Math.abs(one[p]! - two[p]!),+ Math.abs(one[p + 1]! - two[p + 1]!),+ Math.abs(one[p + 2]! - two[p + 2]!),+ )+ const v = Math.sqrt(d / 255) * 765+ heat.data[p] = v+ heat.data[p + 1] = v - 255+ heat.data[p + 2] = v - 510+ heat.data[p + 3] = 255+ }+ context.putImageData(heat, 0, 0)+ })+ return () => {+ live = false+ }+ }+}diff --git a/tests/integration/review/web/src/lib/review.svelte.ts b/tests/integration/review/web/src/lib/review.svelte.tsnew file mode 100644index 00000000..a9b4e0f9--- /dev/null+++ b/tests/integration/review/web/src/lib/review.svelte.ts@@ -0,0 +1,271 @@+// The panel's state: the corpus, the case being reviewed, and every choice a reviewer makes+// (the sidebar's filters, how the case is shown). One instance, shared through context. The+// choices are the page's address (`search`, `apply`): a reload keeps them, a link shares them.++import { createContext } from 'svelte'+import {+ api,+ type CaseDetail,+ type CaseSummary,+ type Engine,+ type Settings,+ type State,+ type Verdict,+} from './api'++export type StateFilter = 'all' | State+export type Sort = 'name' | 'error'+/** How the compare pane shows the two frames. */+export type Mode = 'parallel' | 'superimposed' | 'diff'++export const STATE_FILTERS: readonly StateFilter[] = ['all', 'working', 'not_matching', 'not_working']+export const SORTS: readonly Sort[] = ['name', 'error']+export const MODES: readonly Mode[] = ['parallel', 'superimposed', 'diff']++export const STATES: readonly State[] = [+ 'working',+ 'not_matching',+ 'not_working',+ 'stale',+ 'unrendered',+]++/** How a state reads. */+export function label(state: State): string {+ return state.replace('_', ' ')+}++function summary(detail: CaseDetail): CaseSummary {+ const { name, state, auto, reviewed, noted, checks, worst } = detail+ return { name, state, auto, reviewed, noted, checks, worst }+}++export class Review {+ cases = $state.raw<CaseSummary[]>([])+ sources = $state.raw<Record<string, string>>({})+ settings = $state.raw<Settings | null>(null)+ detail = $state.raw<CaseDetail | null>(null)+ selected = $state<string | null>(null)+ /** What is running, if anything ("rendering ce", …). */+ busy = $state<string | null>(null)+ error = $state<string | null>(null)++ query = $state('')+ stateFilter = $state<StateFilter>('all')+ failingSource = $state(false)+ failingTypes = $state(false)+ onlyReviewed = $state(false)+ onlyNoted = $state(false)+ sort = $state<Sort>('name')++ mode = $state<Mode>('parallel')+ /** The superimposed frames' blend: 0 shows CE, 1 manimgx. */+ mix = $state(0.5)+ /** The timeline step shown, from 0. */+ at = $state(0)+ /** Whether the timeline plays, in a loop: a reload or a link plays on from its step. */+ playing = $state(false)+ showSource = $state(true)++ /** Every choice, as the page's query: only what differs from a fresh panel, whose address+ * stays bare. */+ search = $derived.by(() => this.#search(this.selected, this.at))++ /** Lower-cased sources, for search. */+ #haystacks = $derived(+ new Map(Object.entries(this.sources).map(([name, source]) => [name, source.toLowerCase()])),+ )++ /** Every term of the query must be in the name — or, from three letters, in the source. */+ #matches = $derived.by(() => {+ const terms = this.query.toLowerCase().split(/\s+/).filter(Boolean)+ const found = new Map<string, 'name' | 'source'>()+ for (const c of this.cases) {+ const name = c.name.toLowerCase()+ let where: 'name' | 'source' | null = 'name'+ for (const term of terms) {+ if (name.includes(term)) continue+ if (term.length >= 3 && this.#haystacks.get(c.name)?.includes(term)) where = 'source'+ else {+ where = null+ break+ }+ }+ if (where) found.set(c.name, where)+ }+ return found+ })++ visible = $derived.by(() => {+ const shown = this.cases.filter(+ (c) =>+ this.#matches.has(c.name) &&+ (this.stateFilter === 'all' || c.state === this.stateFilter) &&+ (!this.failingSource || !c.checks.source) &&+ (!this.failingTypes || !c.checks.types) &&+ (!this.onlyReviewed || c.reviewed) &&+ (!this.onlyNoted || c.noted),+ )+ if (this.sort === 'error') {+ shown.sort((a, b) => (b.worst ?? -1) - (a.worst ?? -1))+ }+ return shown+ })++ /** Cases found only in their source, not their name. */+ inSource = $derived(+ new Set([...this.#matches].filter(([, where]) => where === 'source').map(([name]) => name)),+ )++ counts = $derived.by(() => {+ const byState = new Map<State, number>(STATES.map((s) => [s, 0]))+ let source = 0+ let types = 0+ for (const c of this.cases) {+ byState.set(c.state, (byState.get(c.state) ?? 0) + 1)+ if (!c.checks.source) source += 1+ if (!c.checks.types) types += 1+ }+ return { byState, source, types }+ })++ #search(name: string | null, at: number): string {+ const params = new URLSearchParams()+ const listed = (...items: (string | false)[]) => items.filter(Boolean).join(',')+ if (name !== null) params.set('case', name)+ if (at > 0) params.set('step', String(at + 1)) // as the readout counts+ if (this.playing) params.set('play', '1')+ if (this.mode !== 'parallel') params.set('compare', this.mode)+ if (this.mix !== 0.5) params.set('mix', String(this.mix))+ if (!this.showSource) params.set('source', 'hidden')+ if (this.query) params.set('q', this.query)+ if (this.stateFilter !== 'all') params.set('state', this.stateFilter)+ const fails = listed(this.failingSource && 'source', this.failingTypes && 'types')+ if (fails) params.set('fails', fails)+ const only = listed(this.onlyReviewed && 'reviewed', this.onlyNoted && 'noted')+ if (only) params.set('only', only)+ if (this.sort !== 'name') params.set('sort', this.sort)+ const query = params.toString().replaceAll('%2C', ',') // commas need no escaping+ return query ? `?${query}` : ''+ }++ /** A case's address, from its first step, with every other choice as it is. */+ link(name: string): string {+ return this.#search(name, 0)+ }++ /** Take every choice from a query; what it leaves out or gets wrong is a fresh panel's. */+ apply(params: URLSearchParams): void {+ const pick = <T extends string>(key: string, from: readonly T[], fallback: T): T =>+ from.find((value) => value === params.get(key)) ?? fallback+ const listed = (key: string) => new Set(params.get(key)?.split(','))+ this.selected = params.get('case') || null+ const step = Number(params.get('step') ?? 1)+ this.at = Number.isInteger(step) && step > 0 ? step - 1 : 0+ this.playing = params.get('play') === '1'+ this.mode = pick('compare', MODES, 'parallel')+ const mix = Number.parseFloat(params.get('mix') ?? '')+ this.mix = mix >= 0 && mix <= 1 ? mix : 0.5+ this.showSource = params.get('source') !== 'hidden'+ this.query = params.get('q') ?? ''+ this.stateFilter = pick('state', STATE_FILTERS, 'all')+ const fails = listed('fails')+ this.failingSource = fails.has('source')+ this.failingTypes = fails.has('types')+ const only = listed('only')+ this.onlyReviewed = only.has('reviewed')+ this.onlyNoted = only.has('noted')+ this.sort = pick('sort', SORTS, 'name')+ }++ async load(): Promise<void> {+ await this.#attempt(async () => {+ ;[this.cases, this.settings] = await Promise.all([api.cases(), api.settings()])+ this.sources = await api.sources()+ })+ }++ /** Show a case at the step chosen (the address's, on a reload or back and forward). */+ async open(name: string | null): Promise<void> {+ this.selected = name+ if (name === null) {+ this.detail = null+ return+ }+ if (name === this.detail?.name) {+ this.#show(this.detail) // only the step may have moved+ return+ }+ await this.#attempt(async () => {+ const detail = await api.detail(name)+ if (this.selected === name) this.#show(detail)+ })+ }++ /** Go to a case, from its first step: as a new history entry (`push`: back returns to the+ * panel as it was), or in place of the current one. */+ go(name: string, how: 'push' | 'replace'): void {+ if (name === this.selected) return+ if (how === 'push') {+ history.replaceState(history.state, '', this.search || location.pathname)+ history.pushState(null, '', this.link(name))+ }+ this.at = 0+ void this.open(name)+ }++ /** The next or previous case in the list. */+ neighbour(offset: number): string | null {+ const list = this.visible+ if (list.length === 0) return null+ const at = list.findIndex((c) => c.name === this.selected)+ const next = at === -1 ? 0 : Math.min(Math.max(at + offset, 0), list.length - 1)+ return list[next]?.name ?? null+ }++ async setVerdict(verdict: Verdict | 'auto', note: string): Promise<void> {+ const name = this.selected+ if (name === null) return+ await this.#attempt(async () => this.#update(await api.review(name, verdict, note)))+ }++ async render(engine: Engine | 'both'): Promise<void> {+ const name = this.selected+ if (name === null) return+ this.busy = `rendering ${engine === 'both' ? 'both engines' : engine}`+ try {+ await this.#attempt(async () => this.#update(await api.render(name, engine)))+ } finally {+ this.busy = null+ }+ }++ async saveSettings(metric: string, tolerance: number): Promise<void> {+ await this.#attempt(async () => {+ this.settings = await api.saveSettings(metric, tolerance)+ this.cases = await api.cases() // every verdict may have moved+ if (this.selected !== null) this.#show(await api.detail(this.selected))+ })+ }++ #show(detail: CaseDetail): void {+ this.at = Math.max(Math.min(this.at, detail.slots.length - 1), 0)+ this.detail = detail+ }++ #update(detail: CaseDetail): void {+ if (this.selected === detail.name) this.#show(detail)+ this.cases = this.cases.map((c) => (c.name === detail.name ? summary(detail) : c))+ }++ async #attempt(work: () => Promise<void>): Promise<void> {+ this.error = null+ try {+ await work()+ } catch (error) {+ this.error = error instanceof Error ? error.message : String(error)+ }+ }+}++export const [getReview, setReview] = createContext<Review>()diff --git a/tests/integration/review/web/src/main.ts b/tests/integration/review/web/src/main.tsnew file mode 100644index 00000000..9537374b--- /dev/null+++ b/tests/integration/review/web/src/main.ts@@ -0,0 +1,5 @@+import { mount } from 'svelte'+import './app.css'+import App from './App.svelte'++mount(App, { target: document.getElementById('app')! })diff --git a/tests/integration/review/web/svelte.config.js b/tests/integration/review/web/svelte.config.jsnew file mode 100644index 00000000..0cf7db32--- /dev/null+++ b/tests/integration/review/web/svelte.config.js@@ -0,0 +1,2 @@+/** @type {import("@sveltejs/vite-plugin-svelte").SvelteConfig} */+export default {}diff --git a/tests/integration/review/web/tsconfig.app.json b/tests/integration/review/web/tsconfig.app.jsonnew file mode 100644index 00000000..cb6a5774--- /dev/null+++ b/tests/integration/review/web/tsconfig.app.json@@ -0,0 +1,24 @@+{+ "extends": "@tsconfig/svelte/tsconfig.json",+ "compilerOptions": {+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",+ "target": "es2023",+ "module": "esnext",+ "types": ["svelte", "vite/client"],+ "allowArbitraryExtensions": true,+ "noEmit": true,+ /**+ * Typecheck JS in `.svelte` and `.js` files by default.+ * Disable checkJs if you'd like to use dynamic types in JS.+ * Note that setting allowJs false does not prevent the use+ * of JS in `.svelte` files.+ */+ "allowJs": true,+ "checkJs": true,+ "moduleDetection": "force",+ "noUncheckedIndexedAccess": true,+ "noUnusedLocals": true,+ "noUnusedParameters": true+ },+ "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"]+}diff --git a/tests/integration/review/web/tsconfig.json b/tests/integration/review/web/tsconfig.jsonnew file mode 100644index 00000000..1ffef600--- /dev/null+++ b/tests/integration/review/web/tsconfig.json@@ -0,0 +1,7 @@+{+ "files": [],+ "references": [+ { "path": "./tsconfig.app.json" },+ { "path": "./tsconfig.node.json" }+ ]+}diff --git a/tests/integration/review/web/tsconfig.node.json b/tests/integration/review/web/tsconfig.node.jsonnew file mode 100644index 00000000..8455dcbc--- /dev/null+++ b/tests/integration/review/web/tsconfig.node.json@@ -0,0 +1,23 @@+{+ "compilerOptions": {+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",+ "target": "es2023",+ "lib": ["ES2023"],+ "types": ["node"],+ "skipLibCheck": true,++ /* Bundler mode */+ "module": "nodenext",+ "allowImportingTsExtensions": true,+ "verbatimModuleSyntax": true,+ "moduleDetection": "force",+ "noEmit": true,++ /* Linting */+ "noUnusedLocals": true,+ "noUnusedParameters": true,+ "erasableSyntaxOnly": true,+ "noFallthroughCasesInSwitch": true+ },+ "include": ["vite.config.ts"]+}diff --git a/tests/integration/review/web/vite.config.ts b/tests/integration/review/web/vite.config.tsnew file mode 100644index 00000000..1020e521--- /dev/null+++ b/tests/integration/review/web/vite.config.ts@@ -0,0 +1,9 @@+import { svelte } from '@sveltejs/vite-plugin-svelte'+import { defineConfig } from 'vite'++// https://vite.dev/config/+export default defineConfig({+ plugins: [svelte()],+ // `bun run dev` serves the panel with hot reload; the API is the FastAPI server+ server: { proxy: { '/api': 'http://127.0.0.1:8000' } },+})