mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-11-19 05:08:56 -06:00
Remove the dev-only scanner fixtures page and its route
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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<FixtureListItem["expected"]["data"]>;
|
||||
|
||||
export function FixturesPage() {
|
||||
const [q, setQ] = useSearchParam(scannerSearchParams, "q");
|
||||
const [fixtures, setFixtures] = useState<FixtureListItem[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(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<string, FixtureListItem[]>();
|
||||
for (const fixture of filtered) {
|
||||
const group = groups.get(fixture.detector) ?? [];
|
||||
group.push(fixture);
|
||||
groups.set(fixture.detector, group);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<SessionHeader>
|
||||
<div className={styles.controls}>
|
||||
<input
|
||||
type="search"
|
||||
className={styles.filter}
|
||||
value={q}
|
||||
onChange={(e) => setQ(e.target.value)}
|
||||
placeholder="Narrow by name substring — comma separates alternatives"
|
||||
/>
|
||||
<span className={styles.count}>
|
||||
{fixtures
|
||||
? `${filtered.length} / ${fixtures.length} fixtures`
|
||||
: "loading…"}
|
||||
</span>
|
||||
</div>
|
||||
<p className={styles.hint}>
|
||||
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.
|
||||
</p>
|
||||
</SessionHeader>
|
||||
{error ? <p className="text-error">{error}</p> : null}
|
||||
{[...groups.entries()].map(([detector, group]) => (
|
||||
<section key={detector} className={styles.group}>
|
||||
<h2 className={styles.groupTitle}>
|
||||
{detector} <span className={styles.count}>({group.length})</span>
|
||||
</h2>
|
||||
{group.map((fixture) => (
|
||||
<FixtureCard
|
||||
key={`${fixture.detector}/${fixture.name}`}
|
||||
fixture={fixture}
|
||||
autoExpand={autoExpand}
|
||||
/>
|
||||
))}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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<boolean | null>(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 (
|
||||
<article className={styles.card}>
|
||||
<header className={styles.cardHeader}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.cardToggle}
|
||||
onClick={() => setOpenOverride(!open)}
|
||||
>
|
||||
<span className={styles.cardChevron}>{open ? "▾" : "▸"}</span>
|
||||
{fixture.name}
|
||||
</button>
|
||||
<span className={styles.cardEvent}>{fixture.expected.event}</span>
|
||||
<SendouButton
|
||||
size="small"
|
||||
variant="outlined"
|
||||
icon={<ExternalLink />}
|
||||
onClick={() => inspectFixture(url)}
|
||||
>
|
||||
Inspect
|
||||
</SendouButton>
|
||||
</header>
|
||||
{open ? (
|
||||
<div className={styles.cardBody}>
|
||||
<a href={url} target="_blank" rel="noreferrer">
|
||||
<img
|
||||
className={styles.frameImg}
|
||||
src={url}
|
||||
alt={fixture.name}
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
<div className={styles.expected}>
|
||||
{notes ? <p className={styles.notes}>{notes}</p> : null}
|
||||
{skipFields && skipFields.length > 0 ? (
|
||||
<p className={styles.skips}>
|
||||
skipped fields: {skipFields.join(", ")}
|
||||
</p>
|
||||
) : null}
|
||||
{misreadFields && misreadFields.length > 0 ? (
|
||||
<p className={styles.skips}>
|
||||
known misreads: {misreadFields.join(", ")}
|
||||
</p>
|
||||
) : null}
|
||||
<ExpectedDetail fixture={fixture} url={url} />
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
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" ? (
|
||||
<PlayerStatusExpected frame={frame} data={data} />
|
||||
) : null}
|
||||
{data && event === "StripWeapons" ? (
|
||||
<StripWeaponsExpected frame={frame} data={data} />
|
||||
) : null}
|
||||
{data && event === "Objective" ? (
|
||||
<ObjectiveExpected frame={frame} data={data} />
|
||||
) : null}
|
||||
<details
|
||||
open={jsonOpen}
|
||||
onToggle={(e) => setJsonOpen(e.currentTarget.open)}
|
||||
>
|
||||
<summary className={styles.jsonSummary}>expected.json</summary>
|
||||
<pre className={styles.json}>
|
||||
{JSON.stringify(props.fixture.expected, null, 2)}
|
||||
</pre>
|
||||
</details>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** The fixture frame drawn at canonical size, for ROI crops. */
|
||||
function useNormalizedFrame(
|
||||
url: string,
|
||||
enabled: boolean,
|
||||
): HTMLCanvasElement | null {
|
||||
const [frame, setFrame] = useState<HTMLCanvasElement | null>(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 (
|
||||
<div className={styles.strips}>
|
||||
{([0, 1] as const).map((side) => (
|
||||
<figure key={side} className={styles.strip}>
|
||||
<RoiCrop
|
||||
frame={props.frame}
|
||||
roi={objective.STATUS_STRIP_ROIS[side]}
|
||||
scale={0.75}
|
||||
/>
|
||||
<figcaption className={styles.stripCaptions}>
|
||||
{[0, 1, 2, 3].map((slot) => (
|
||||
<span key={slot} className={props.slotClassName?.(side, slot)}>
|
||||
{props.slotCaption(side, slot)}
|
||||
</span>
|
||||
))}
|
||||
</figcaption>
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PlayerStatusExpected(props: {
|
||||
frame: HTMLCanvasElement | null;
|
||||
data: ExpectedData;
|
||||
}) {
|
||||
const { data } = props;
|
||||
return (
|
||||
<div className={styles.rich}>
|
||||
<div className={styles.richStats}>
|
||||
<span>
|
||||
cast <b>{data.cast ? "yes" : "unknown"}</b>
|
||||
</span>
|
||||
{typeof data.time === "number" ? (
|
||||
<span>
|
||||
time <b>{formatTimer(data.time)}</b>
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
{props.frame ? (
|
||||
<SlotStrips
|
||||
frame={props.frame}
|
||||
slotCaption={(side, slot) =>
|
||||
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}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function StripWeaponsExpected(props: {
|
||||
frame: HTMLCanvasElement | null;
|
||||
data: ExpectedData;
|
||||
}) {
|
||||
const { data } = props;
|
||||
return (
|
||||
<div className={styles.rich}>
|
||||
{props.frame ? (
|
||||
<SlotStrips
|
||||
frame={props.frame}
|
||||
slotCaption={(side, slot) => {
|
||||
const weaponId = data.weapons?.[side]?.[slot] ?? null;
|
||||
if (weaponId === null) return "skipped";
|
||||
return (
|
||||
<>
|
||||
<img
|
||||
className={styles.weaponIcon}
|
||||
src={`${mainWeaponImageUrl(weaponId)}.avif`}
|
||||
alt=""
|
||||
/>
|
||||
{mainWeaponLabel(weaponId) ?? weaponId}
|
||||
</>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ObjectiveExpected(props: {
|
||||
frame: HTMLCanvasElement | null;
|
||||
data: ExpectedData;
|
||||
}) {
|
||||
const { data } = props;
|
||||
if (data.position !== undefined) return <TrackObjectiveExpected {...props} />;
|
||||
return (
|
||||
<div className={styles.rich}>
|
||||
<div className={styles.richStats}>
|
||||
<span>
|
||||
control{" "}
|
||||
<b>
|
||||
{data.control === 0
|
||||
? "left"
|
||||
: data.control === 1
|
||||
? "right"
|
||||
: "none"}
|
||||
</b>
|
||||
</span>
|
||||
<span>
|
||||
penalty{" "}
|
||||
<b>
|
||||
{data.penalty?.[0] ?? "—"} / {data.penalty?.[1] ?? "—"}
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
||||
{props.frame ? (
|
||||
<div className={styles.objectiveCrops}>
|
||||
<figure className={styles.slot}>
|
||||
<RoiCrop frame={props.frame} roi={objective.SCORE_ROIS[0]} />
|
||||
<figcaption>left count {data.score?.[0] ?? "?"}</figcaption>
|
||||
</figure>
|
||||
<figure className={styles.slot}>
|
||||
<RoiCrop frame={props.frame} roi={objective.TIMER_DIGIT_ROI} />
|
||||
<figcaption>timer {formatTimer(data.time ?? null)}</figcaption>
|
||||
</figure>
|
||||
<figure className={styles.slot}>
|
||||
<RoiCrop frame={props.frame} roi={objective.SCORE_ROIS[1]} />
|
||||
<figcaption>right count {data.score?.[1] ?? "?"}</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** 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 (
|
||||
<div className={styles.rich}>
|
||||
<div className={styles.richStats}>
|
||||
<span>
|
||||
mode <b>{data.mode ?? "?"}</b>
|
||||
</span>
|
||||
<span>
|
||||
timer <b>{formatTimer(data.time ?? null)}</b>
|
||||
</span>
|
||||
<span>
|
||||
control{" "}
|
||||
<b>
|
||||
{data.control === 0
|
||||
? "left"
|
||||
: data.control === 1
|
||||
? "right"
|
||||
: "none"}
|
||||
</b>
|
||||
</span>
|
||||
<span>
|
||||
position <b>{data.position ?? "—"}</b>
|
||||
</span>
|
||||
<span>
|
||||
counts{" "}
|
||||
<b>
|
||||
{data.score?.[0] ?? "—"} / {data.score?.[1] ?? "—"}
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
||||
{props.frame ? (
|
||||
<RoiCrop
|
||||
frame={props.frame}
|
||||
roi={{
|
||||
x: objective.TRACK_PLATE_DIGIT_ROI.x,
|
||||
y: objective.TRACK_Y - 30,
|
||||
w: objective.TRACK_PLATE_DIGIT_ROI.w,
|
||||
h:
|
||||
objective.TRACK_PLATE_DIGIT_ROI.y +
|
||||
objective.TRACK_PLATE_DIGIT_ROI.h -
|
||||
(objective.TRACK_Y - 30),
|
||||
}}
|
||||
scale={0.75}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -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() {
|
||||
<ClipsView />
|
||||
) : view === "debug" ? (
|
||||
<ScreenshotPage />
|
||||
) : view === "fixtures" && process.env.NODE_ENV === "development" ? (
|
||||
<FixturesPage />
|
||||
) : view === "montage" && process.env.NODE_ENV === "development" ? (
|
||||
<MontageView />
|
||||
) : (
|
||||
|
||||
@@ -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")}`;
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
</SendouButton>
|
||||
) : null}
|
||||
{showDevLinks ? (
|
||||
<>
|
||||
<Link
|
||||
to={scannerSearchParams.href(SCANNER_PAGE, {
|
||||
view: "fixtures",
|
||||
})}
|
||||
defaultShouldRevalidate={false}
|
||||
>
|
||||
Fixtures
|
||||
</Link>
|
||||
<Link
|
||||
to={scannerSearchParams.href(SCANNER_PAGE, {
|
||||
view: "montage",
|
||||
})}
|
||||
defaultShouldRevalidate={false}
|
||||
>
|
||||
Tournament montage
|
||||
</Link>
|
||||
</>
|
||||
<Link
|
||||
to={scannerSearchParams.href(SCANNER_PAGE, {
|
||||
view: "montage",
|
||||
})}
|
||||
defaultShouldRevalidate={false}
|
||||
>
|
||||
Tournament montage
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -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,
|
||||
})),
|
||||
);
|
||||
}
|
||||
@@ -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],
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user