From d46b85a8521473ba130bd2dcc3f563cd7c67e4f7 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Tue, 10 Nov 2026 21:04:58 +0200 Subject: [PATCH] Remove the dev-only scanner fixtures page and its route --- .../components/FixturesPage.module.css | 216 --------- .../scanner/components/FixturesPage.tsx | 439 ------------------ .../scanner/components/ScannerApp.tsx | 3 - .../scanner/components/ScreenshotPage.tsx | 4 +- .../scanner/components/SettingsPopover.tsx | 28 +- .../scanner/routes/scanner.fixtures.ts | 56 --- .../scanner/scanner-search-params.test.ts | 2 - app/features/scanner/scanner-search-params.ts | 6 - app/routes.ts | 4 - .../src/content/feature-readmes/scanner.mdx | 9 +- 10 files changed, 12 insertions(+), 755 deletions(-) delete mode 100644 app/features/scanner/components/FixturesPage.module.css delete mode 100644 app/features/scanner/components/FixturesPage.tsx delete mode 100644 app/features/scanner/routes/scanner.fixtures.ts diff --git a/app/features/scanner/components/FixturesPage.module.css b/app/features/scanner/components/FixturesPage.module.css deleted file mode 100644 index 77b00796b..000000000 --- a/app/features/scanner/components/FixturesPage.module.css +++ /dev/null @@ -1,216 +0,0 @@ -.page { - display: flex; - flex-direction: column; - gap: var(--s-4); -} - -.controls { - display: flex; - align-items: center; - gap: var(--s-3); -} - -.filter { - flex: 1; - max-width: 32rem; -} - -.count { - color: var(--color-text-high); - font-size: var(--font-xs); - white-space: nowrap; -} - -.hint { - color: var(--color-text-high); - font-size: var(--font-xs); - margin: 0; -} - -.group { - display: flex; - flex-direction: column; - gap: var(--s-2); -} - -.groupTitle { - font-size: var(--font-sm); - margin: 0; -} - -.card { - border: var(--border-width) solid var(--color-bg-high); - border-radius: var(--radius-box); - container-type: inline-size; -} - -.cardHeader { - display: flex; - align-items: center; - gap: var(--s-3); - padding: var(--s-1-5) var(--s-2); - font-size: var(--font-xs); -} - -/* undo the scanner-wide solid button look; the whole title row is the target */ -button.cardToggle { - display: flex; - align-items: center; - justify-content: flex-start; - gap: var(--s-1-5); - flex: 1; - min-width: 0; - height: auto; - background: none; - border: none; - padding: 0; - color: inherit; - font: inherit; - font-size: var(--font-xs); - font-weight: var(--weight-bold); - text-align: left; - white-space: normal; - overflow-wrap: anywhere; -} - -.cardChevron { - color: var(--color-text-high); -} - -.cardEvent { - padding: 0 var(--s-1-5); - border-radius: var(--radius-selector); - background: var(--color-bg-high); - color: var(--color-text-high); - font-size: var(--font-2xs); - font-weight: var(--weight-bold); - white-space: nowrap; -} - -.cardBody { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); - gap: var(--s-3); - padding: var(--s-2); - border-top: var(--border-width) solid var(--color-bg-high); - - @container (max-width: 60rem) { - grid-template-columns: minmax(0, 1fr); - } -} - -.frameImg { - display: block; - width: 100%; - border-radius: var(--radius-selector); - background: #000; -} - -.expected { - display: flex; - flex-direction: column; - gap: var(--s-2); - min-width: 0; - font-size: var(--font-xs); -} - -.notes { - margin: 0; - color: var(--color-text-high); -} - -.skips { - margin: 0; - color: var(--color-warning-high); - font-size: var(--font-2xs); -} - -.rich { - display: flex; - flex-direction: column; - gap: var(--s-2); -} - -.richStats { - display: flex; - flex-wrap: wrap; - gap: var(--s-3); - color: var(--color-text-high); - font-size: var(--font-2xs); - - & b { - color: var(--color-text); - } -} - -.strips { - display: flex; - flex-direction: column; - gap: var(--s-2); -} - -.strip { - margin: 0; - display: flex; - flex-direction: column; - gap: var(--s-1); - inline-size: fit-content; - - & canvas { - display: block; - background: #000; - border-radius: var(--radius-selector); - } -} - -.stripCaptions { - display: grid; - grid-template-columns: repeat(4, 1fr); - font-size: var(--font-2xs); - color: var(--color-text-high); - - & > span { - display: flex; - align-items: center; - justify-content: center; - gap: var(--s-1); - } -} - -.slotDead { - color: var(--color-error-high); - font-weight: var(--weight-bold); -} - -.slotSpecial { - color: var(--color-warning-high); - font-weight: var(--weight-bold); -} - -.objectiveCrops { - display: flex; - flex-wrap: wrap; - gap: var(--s-3); - align-items: end; -} - -.weaponIcon { - inline-size: 1.25rem; - block-size: 1.25rem; - object-fit: contain; -} - -.jsonSummary { - cursor: pointer; - font-size: var(--font-2xs); - color: var(--color-text-high); -} - -.json { - margin: var(--s-1) 0 0; - padding: var(--s-2); - border-radius: var(--radius-selector); - background: var(--color-bg-high); - font-size: var(--font-2xs); - overflow-x: auto; -} diff --git a/app/features/scanner/components/FixturesPage.tsx b/app/features/scanner/components/FixturesPage.tsx deleted file mode 100644 index 9a2cfb378..000000000 --- a/app/features/scanner/components/FixturesPage.tsx +++ /dev/null @@ -1,439 +0,0 @@ -import { ExternalLink } from "lucide-react"; -import { type ReactNode, useEffect, useState } from "react"; -import { SendouButton } from "~/components/elements/Button"; -import { useSearchParam } from "~/modules/search-params/hooks"; -import { mainWeaponImageUrl, SCANNER_PAGE } from "~/utils/urls"; -import * as objective from "../core/detectors/objective/rois"; -import { mainWeaponLabel } from "../core/labels"; -import type { FixtureListItem } from "../routes/scanner.fixtures"; -import { scannerSearchParams } from "../scanner-search-params"; -import { newInspectKey, putInspectFrame } from "../store/inspect"; -import styles from "./FixturesPage.module.css"; -import { drawNormalizedCanvas } from "./normalized-canvas"; -import { formatTimer, RoiCrop } from "./ScreenshotPage"; -import { SessionHeader } from "./SessionHeader"; - -const FIXTURES_ENDPOINT = "/scanner/fixtures"; -/** Filtering down to this many cases opens every card, for one-glance review */ -const AUTO_EXPAND_MAX = 8; - -type ExpectedData = NonNullable; - -export function FixturesPage() { - const [q, setQ] = useSearchParam(scannerSearchParams, "q"); - const [fixtures, setFixtures] = useState(null); - const [error, setError] = useState(null); - - useEffect(() => { - let cancelled = false; - fetch(FIXTURES_ENDPOINT) - .then((res) => - res.ok - ? (res.json() as Promise<{ fixtures: FixtureListItem[] }>) - : Promise.reject(new Error(`fixture list failed (${res.status})`)), - ) - .then( - (body) => { - if (!cancelled) setFixtures(body.fixtures); - }, - (e) => { - if (!cancelled) setError(String(e)); - }, - ); - return () => { - cancelled = true; - }; - }, []); - - const terms = q - .split(",") - .map((term) => term.trim().toLowerCase()) - .filter(Boolean); - const filtered = (fixtures ?? []).filter( - (fixture) => - terms.length === 0 || - terms.some((term) => - `${fixture.detector}/${fixture.name}`.toLowerCase().includes(term), - ), - ); - const autoExpand = filtered.length > 0 && filtered.length <= AUTO_EXPAND_MAX; - - const groups = new Map(); - for (const fixture of filtered) { - const group = groups.get(fixture.detector) ?? []; - group.push(fixture); - groups.set(fixture.detector, group); - } - - return ( -
- -
- setQ(e.target.value)} - placeholder="Narrow by name substring — comma separates alternatives" - /> - - {fixtures - ? `${filtered.length} / ${fixtures.length} fixtures` - : "loading…"} - -
-

- Ground-truth review: check each expected label against its frame. The - filter lives in the URL, so a narrowed selection can be shared as a - link. -

-
- {error ?

{error}

: null} - {[...groups.entries()].map(([detector, group]) => ( -
-

- {detector} ({group.length}) -

- {group.map((fixture) => ( - - ))} -
- ))} -
- ); -} - -function frameUrl(fixture: FixtureListItem): string { - return `${FIXTURES_ENDPOINT}/${encodeURIComponent(fixture.detector)}/${encodeURIComponent(fixture.name)}`; -} - -/** Re-analyze the frame in the screenshot tab via the cross-tab handoff. */ -function inspectFixture(url: string) { - const key = newInspectKey(); - window.open( - scannerSearchParams.href(SCANNER_PAGE, { view: "debug", inspect: key }), - "_blank", - ); - void fetch(url) - .then((res) => res.blob()) - .then((blob) => putInspectFrame(key, blob)); -} - -function FixtureCard(props: { fixture: FixtureListItem; autoExpand: boolean }) { - const { fixture } = props; - const [openOverride, setOpenOverride] = useState(null); - const open = openOverride ?? props.autoExpand; - const url = frameUrl(fixture); - const notes = fixture.expected.options?.notes; - const skipFields = fixture.expected.options?.skipFields; - const misreadFields = fixture.expected.options?.misreadFields; - - return ( -
-
- - {fixture.expected.event} - } - onClick={() => inspectFixture(url)} - > - Inspect - -
- {open ? ( -
- - {fixture.name} - -
- {notes ?

{notes}

: null} - {skipFields && skipFields.length > 0 ? ( -

- skipped fields: {skipFields.join(", ")} -

- ) : null} - {misreadFields && misreadFields.length > 0 ? ( -

- known misreads: {misreadFields.join(", ")} -

- ) : null} - -
-
- ) : null} -
- ); -} - -function ExpectedDetail(props: { fixture: FixtureListItem; url: string }) { - const { event, data } = props.fixture.expected; - const richView = - event === "PlayerStatus" || - event === "StripWeapons" || - event === "Objective"; - const frame = useNormalizedFrame(props.url, richView); - const [jsonOpen, setJsonOpen] = useState(!richView); - - return ( - <> - {data && event === "PlayerStatus" ? ( - - ) : null} - {data && event === "StripWeapons" ? ( - - ) : null} - {data && event === "Objective" ? ( - - ) : null} -
setJsonOpen(e.currentTarget.open)} - > - expected.json -
-					{JSON.stringify(props.fixture.expected, null, 2)}
-				
-
- - ); -} - -/** The fixture frame drawn at canonical size, for ROI crops. */ -function useNormalizedFrame( - url: string, - enabled: boolean, -): HTMLCanvasElement | null { - const [frame, setFrame] = useState(null); - useEffect(() => { - if (!enabled) return; - let cancelled = false; - const image = new Image(); - image.onload = () => { - if (cancelled) return; - setFrame( - drawNormalizedCanvas(image, image.naturalWidth, image.naturalHeight), - ); - }; - image.src = url; - return () => { - cancelled = true; - }; - }, [url, enabled]); - return frame; -} - -/** Both teams' icon strips, the expected label of each slot (left-to-right) under it. */ -function SlotStrips(props: { - frame: HTMLCanvasElement; - slotCaption: (side: 0 | 1, slot: number) => ReactNode; - slotClassName?: (side: 0 | 1, slot: number) => string | undefined; -}) { - return ( -
- {([0, 1] as const).map((side) => ( -
- -
- {[0, 1, 2, 3].map((slot) => ( - - {props.slotCaption(side, slot)} - - ))} -
-
- ))} -
- ); -} - -function PlayerStatusExpected(props: { - frame: HTMLCanvasElement | null; - data: ExpectedData; -}) { - const { data } = props; - return ( -
-
- - cast {data.cast ? "yes" : "unknown"} - - {typeof data.time === "number" ? ( - - time {formatTimer(data.time)} - - ) : null} -
- {props.frame ? ( - - data.dead?.[side]?.[slot] - ? "✗ dead" - : data.special?.[side]?.[slot] - ? "★ special" - : "alive" - } - slotClassName={(side, slot) => - data.dead?.[side]?.[slot] - ? styles.slotDead - : data.special?.[side]?.[slot] - ? styles.slotSpecial - : undefined - } - /> - ) : null} -
- ); -} - -function StripWeaponsExpected(props: { - frame: HTMLCanvasElement | null; - data: ExpectedData; -}) { - const { data } = props; - return ( -
- {props.frame ? ( - { - const weaponId = data.weapons?.[side]?.[slot] ?? null; - if (weaponId === null) return "skipped"; - return ( - <> - - {mainWeaponLabel(weaponId) ?? weaponId} - - ); - }} - /> - ) : null} -
- ); -} - -function ObjectiveExpected(props: { - frame: HTMLCanvasElement | null; - data: ExpectedData; -}) { - const { data } = props; - if (data.position !== undefined) return ; - return ( -
-
- - control{" "} - - {data.control === 0 - ? "left" - : data.control === 1 - ? "right" - : "none"} - - - - penalty{" "} - - {data.penalty?.[0] ?? "—"} / {data.penalty?.[1] ?? "—"} - - -
- {props.frame ? ( -
-
- -
left count {data.score?.[0] ?? "?"}
-
-
- -
timer {formatTimer(data.time ?? null)}
-
-
- -
right count {data.score?.[1] ?? "?"}
-
-
- ) : null} -
- ); -} - -/** TC/RM: the track with its icon and the plate band under it, whose plates slide with the pushes. */ -function TrackObjectiveExpected(props: { - frame: HTMLCanvasElement | null; - data: ExpectedData; -}) { - const { data } = props; - return ( -
-
- - mode {data.mode ?? "?"} - - - timer {formatTimer(data.time ?? null)} - - - control{" "} - - {data.control === 0 - ? "left" - : data.control === 1 - ? "right" - : "none"} - - - - position {data.position ?? "—"} - - - counts{" "} - - {data.score?.[0] ?? "—"} / {data.score?.[1] ?? "—"} - - -
- {props.frame ? ( - - ) : null} -
- ); -} diff --git a/app/features/scanner/components/ScannerApp.tsx b/app/features/scanner/components/ScannerApp.tsx index 57dce99eb..8af0bfa05 100644 --- a/app/features/scanner/components/ScannerApp.tsx +++ b/app/features/scanner/components/ScannerApp.tsx @@ -11,7 +11,6 @@ import { useSearchParam } from "~/modules/search-params/hooks"; import { scannerSearchParams } from "../scanner-search-params"; import { ClipsView } from "./ClipsView"; import { CoachView } from "./CoachView"; -import { FixturesPage } from "./FixturesPage"; import { LandingView } from "./LandingView"; import { LiveView } from "./LiveView"; import { @@ -66,8 +65,6 @@ export function ScannerApp() { ) : view === "debug" ? ( - ) : view === "fixtures" && process.env.NODE_ENV === "development" ? ( - ) : view === "montage" && process.env.NODE_ENV === "development" ? ( ) : ( diff --git a/app/features/scanner/components/ScreenshotPage.tsx b/app/features/scanner/components/ScreenshotPage.tsx index 453893e4f..5d7c8453f 100644 --- a/app/features/scanner/components/ScreenshotPage.tsx +++ b/app/features/scanner/components/ScreenshotPage.tsx @@ -76,7 +76,7 @@ const QUICK_TO_RAW = invertHomography(homographyFromQuad(QUICK_RECTIFY)); const onRawFrame = (roi: Roi) => projectedBounds(QUICK_TO_RAW, roi); /** Draw a ROI crop from the normalized frame, scaled up. */ -export function RoiCrop(props: { +function RoiCrop(props: { frame: HTMLCanvasElement; roi: Roi; scale?: number; @@ -222,7 +222,7 @@ function playerFlags(p: { dead: boolean; specialReady: boolean }) { return `${p.dead ? " ✗" : ""}${p.specialReady ? " ★" : ""}`; } -export function formatTimer(time: number | null) { +function formatTimer(time: number | null) { if (time === null) return "?:??"; return `${Math.floor(time / 60)}:${String(time % 60).padStart(2, "0")}`; } diff --git a/app/features/scanner/components/SettingsPopover.tsx b/app/features/scanner/components/SettingsPopover.tsx index 815bddf1c..d75e88c05 100644 --- a/app/features/scanner/components/SettingsPopover.tsx +++ b/app/features/scanner/components/SettingsPopover.tsx @@ -1,7 +1,7 @@ /** * The settings popover, opened from ⚙ on the landing and the live header: * the upload, clip and GPU toggles, the retention notes, and the debug tools - * (enabling debug mode, saving the live frame, the fixtures and montage links in development). The source lives on the landing's Live card, the one place + * (enabling debug mode, saving the live frame, the montage link in development). The source lives on the landing's Live card, the one place * it must be right. */ import { Bug, Camera, Settings } from "lucide-react"; @@ -175,24 +175,14 @@ export function SettingsPopover({ ) : null} {showDevLinks ? ( - <> - - Fixtures - - - Tournament montage - - + + Tournament montage + ) : null} diff --git a/app/features/scanner/routes/scanner.fixtures.ts b/app/features/scanner/routes/scanner.fixtures.ts deleted file mode 100644 index f3d8852f8..000000000 --- a/app/features/scanner/routes/scanner.fixtures.ts +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Dev-only resource route backing the Fixtures tab: without params it lists - * every fixture with its expected.json, with params it serves the raw frame - * bytes. Registered under devOnlyRoutes — the corpus only exists in a checkout. - */ -import { readdirSync, readFileSync } from "node:fs"; -import type { LoaderFunctionArgs } from "react-router"; -import { notFound, notFoundIfNullish } from "~/utils/remix.server"; -import { FIXTURES_DIR, type Fixture, loadFixtures } from "../node/fixtures"; - -export interface FixtureListItem { - detector: string; - name: string; - expected: Fixture["expected"]; -} - -const PATH_SEGMENT_RE = /^[\w.-]+$/; - -export const loader = ({ params }: LoaderFunctionArgs) => { - const { detector, caseName } = params; - if (!detector) return Response.json({ fixtures: listAllFixtures() }); - if ( - !PATH_SEGMENT_RE.test(detector) || - !caseName || - !PATH_SEGMENT_RE.test(caseName) - ) { - notFound(); - } - - const fixture = notFoundIfNullish( - loadFixtures(detector).find((f) => f.name === caseName), - ); - - return new Response(new Uint8Array(readFileSync(fixture.framePath)), { - headers: { - "Content-Type": fixture.framePath.endsWith(".png") - ? "image/png" - : fixture.framePath.endsWith(".webp") - ? "image/webp" - : "image/jpeg", - "Cache-Control": "no-cache", - }, - }); -}; - -function listAllFixtures(): FixtureListItem[] { - return readdirSync(FIXTURES_DIR, { withFileTypes: true }) - .filter((entry) => entry.isDirectory()) - .flatMap((entry) => - loadFixtures(entry.name).map((fixture) => ({ - detector: entry.name, - name: fixture.name, - expected: fixture.expected, - })), - ); -} diff --git a/app/features/scanner/scanner-search-params.test.ts b/app/features/scanner/scanner-search-params.test.ts index f15c5eb34..972dfcf23 100644 --- a/app/features/scanner/scanner-search-params.test.ts +++ b/app/features/scanner/scanner-search-params.test.ts @@ -16,13 +16,11 @@ describe("scannerSearchParams", () => { "coach", "clips", "debug", - "fixtures", "montage", ], id: [1758040920000, 0, null], name: ["sws26-finals.mkv", "a b.mp4", null], t: [754, 0, null], - q: ["", "gauge-overlay", "player-status/cast,ready-trough"], inspect: ["1723456789012-abc123", null], telemetry: [true, false], debug: [true, false], diff --git a/app/features/scanner/scanner-search-params.ts b/app/features/scanner/scanner-search-params.ts index c727fdf5a..7c037fed2 100644 --- a/app/features/scanner/scanner-search-params.ts +++ b/app/features/scanner/scanner-search-params.ts @@ -11,7 +11,6 @@ const SCANNER_VIEWS = [ "coach", "clips", "debug", - "fixtures", "montage", ] as const; @@ -29,11 +28,6 @@ export const scannerSearchParams = SearchParams.define({ t: SP.param(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0))), { loader: false, }), - /** Fixtures view filter: comma-separated substrings, any match keeps a case */ - q: SP.param(v.pipe(v.string(), v.maxLength(200)), { - default: "", - loader: false, - }), /** Inspect handoff key: the debug view claims this frame on load */ inspect: SP.param(v.nullable(v.pipe(v.string(), v.maxLength(100))), { loader: false, diff --git a/app/routes.ts b/app/routes.ts index 47615b1ef..bc4b1e68a 100644 --- a/app/routes.ts +++ b/app/routes.ts @@ -36,10 +36,6 @@ const devOnlyRoutes = "/lobbies/weapon-roll-test", "features/lobbies/routes/lobbies.weapon-roll-test.tsx", ), - route( - "/scanner/fixtures/:detector?/:caseName?", - "features/scanner/routes/scanner.fixtures.ts", - ), ...prefix("/dev", [ route("/identity", "features/dev-tools/routes/dev.identity.ts"), route("/scenarios", "features/dev-tools/routes/dev.scenarios.ts"), diff --git a/docs/site/src/content/feature-readmes/scanner.mdx b/docs/site/src/content/feature-readmes/scanner.mdx index 8f1a58603..9ea84286e 100644 --- a/docs/site/src/content/feature-readmes/scanner.mdx +++ b/docs/site/src/content/feature-readmes/scanner.mdx @@ -889,14 +889,7 @@ untrusted: unpack it only with `pnpm scanner:unpack-zip` (`node/game-data-zip.ts`), which accepts nothing but that exact shape — the `scanner-misread` Claude skill drives the zip → fixtures → fix loop. **Fixture ground-truth labels are hand-corrected by the user (the Splatoon domain authority) — treat them as -definitive over any matcher output.** The dev-only fixtures view -(`/scanner?view=fixtures`) renders every fixture's frame beside its -`expected.json` for that ground-truth review — player-status and -strip-weapons cases get per-slot icon crops with the expected label under -each icon, and Inspect re-analyzes any frame in the debug view (`/scanner?view=debug`). The `q` -param narrows by case-name substring (comma = OR) and lives in the URL, so -finished labeling work can be handed over as a reviewable link, e.g. -`/scanner?view=fixtures&q=gauge-overlay,ready-trough`. Fixtures are committed as plain blobs +definitive over any matcher output.** Fixtures are committed as plain blobs (no LFS for now); keep additions deliberate — fixture IO is isolated in `node/fixtures.ts` if a retreat to LFS/an external corpus is needed.