commit ac25c2ddf8025f5fe64311c6a02477913f29dc34
parent 9e9f9e990dd6ab02033f47dfa2dbaa9f72d9761d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 16 Oct 2026 16:44:03 -0400
editor: the Frame scan panel re-derives and takes a person's correction of a reading, with no model
"Re-derive (no model)" beside the hero's screen name (frame-scan's rederive,
which the panel's action used to refuse); "Correct a reading": open the
reading at a time (or from an event's "Correct", `?reading=<s>`), set fields
to what the frame shows or mark it a misread, saved to the sidecar's
corrections and derived again at once; the corrections listed under the
flags; the summary says when it was re-derived.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
7 files changed, 449 insertions(+), 3 deletions(-)
diff --git a/editor/app/channels/[slug]/videos/[id]/components/FrameReadingEditor.tsx b/editor/app/channels/[slug]/videos/[id]/components/FrameReadingEditor.tsx
@@ -0,0 +1,230 @@
+"use client";
+
+import { useCallback, useEffect, useState, useTransition } from "react";
+import { useRouter } from "next/navigation";
+import { Button } from "yt-dlp-transcript-common/components/ui/button";
+import type { FrameReadingView } from "yt-dlp-transcript-common/controller/frameCorrections";
+import { correctFrameReadingAction, frameReadingAction } from "../frameScanActions";
+
+// A person corrects one frame reading (release 32): open the reading at a
+// time (or from an event's "Correct"), set a field to what the frame shows —
+// or set the whole reading aside as a misread — and the scan is derived again
+// at once with the person's values. The model's reading is kept as it was and
+// shown beside each field that differs.
+
+type Values = Record<string, string>;
+
+function toText(v: unknown, kind: string): string {
+ if (v === null || v === undefined) return "";
+ if (Array.isArray(v)) return v.join(kind === "lines" ? "\n" : " ");
+ return String(v);
+}
+
+/** "1:02:03", "4:05" or "125" → seconds; null when it is none of them. */
+export function parseClock(s: string): number | null {
+ const parts = s.trim().split(":");
+ if (!parts.length || parts.length > 3 || parts.some((p) => !/^\d+(\.\d+)?$/.test(p))) return null;
+ return parts.reduce((acc, p) => acc * 60 + Number(p), 0);
+}
+
+function clock(t: number): string {
+ const s = Math.max(0, Math.round(t));
+ const h = Math.floor(s / 3600);
+ const m = Math.floor((s % 3600) / 60);
+ const sec = s % 60;
+ return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}` : `${m}:${String(sec).padStart(2, "0")}`;
+}
+
+export function FrameReadingEditor({
+ slug,
+ videoId,
+ profile,
+ initialT,
+}: {
+ slug: string;
+ videoId: string;
+ profile: string;
+ initialT: number | null;
+}) {
+ const router = useRouter();
+ const [hydrated, setHydrated] = useState(false);
+ const [at, setAt] = useState(initialT !== null ? clock(initialT) : "");
+ const [view, setView] = useState<FrameReadingView | null>(null);
+ const [values, setValues] = useState<Values>({});
+ const [note, setNote] = useState("");
+ const [status, setStatus] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const [pending, start] = useTransition();
+
+ const show = useCallback((v: FrameReadingView) => {
+ setView(v);
+ setAt(clock(v.t));
+ setValues(Object.fromEntries(v.fields.map((f) => [f.path, toText(f.value, f.kind)])));
+ setNote(v.correction?.note ?? "");
+ }, []);
+
+ const open = useCallback(
+ (t: number) => {
+ setError(null);
+ setStatus(null);
+ start(async () => {
+ const res = await frameReadingAction(slug, videoId, profile, t);
+ if (!res.ok) setError(res.error);
+ else show(res.view);
+ });
+ },
+ [slug, videoId, profile, show],
+ );
+
+ useEffect(() => {
+ setHydrated(true);
+ if (initialT !== null) open(initialT);
+ }, [initialT, open]);
+
+ const save = (req: { misread?: boolean; clear?: boolean }) => {
+ if (!view) return;
+ setError(null);
+ setStatus(null);
+ start(async () => {
+ const set = req.clear || req.misread ? undefined : values;
+ const res = await correctFrameReadingAction(slug, videoId, profile, {
+ t: view.t,
+ ...(set ? { set } : {}),
+ ...(req.misread ? { misread: true } : {}),
+ ...(req.clear ? { clear: true } : {}),
+ ...(note.trim() ? { note } : {}),
+ });
+ if (!res.ok) {
+ setError(res.error);
+ return;
+ }
+ show(res.view);
+ const { before: b, after: a } = res.rederived;
+ setStatus(
+ `${res.correction ? (res.correction.misread ? "Set aside as a misread" : "Correction saved") : "No correction kept"}; ` +
+ `derived again: events ${b.events} → ${a.events}, tournaments ${b.tournaments} → ${a.tournaments}`,
+ );
+ router.refresh();
+ });
+ };
+
+ const disabled = !hydrated || pending;
+ return (
+ <section id="frame-reading" aria-label="frame reading" className="flex flex-col gap-2 border-t border-border pt-3">
+ <h4 className="text-sm font-semibold">Correct a reading</h4>
+ <form
+ className="flex flex-wrap items-center gap-2 text-sm"
+ onSubmit={(e) => {
+ e.preventDefault();
+ const t = parseClock(at);
+ if (t === null) setError("give a time: 1:02:03, 4:05 or seconds");
+ else open(t);
+ }}
+ >
+ <input
+ value={at}
+ onChange={(e) => setAt(e.target.value)}
+ aria-label="reading time"
+ placeholder="h:mm:ss"
+ className="rounded border border-border bg-card px-2 py-1 text-sm w-28 font-mono"
+ />
+ <Button type="submit" size="sm" variant="outline" disabled={disabled}>
+ Open reading
+ </Button>
+ {view && (
+ <>
+ <Button type="button" size="sm" variant="ghost" disabled={disabled || view.prev === null} onClick={() => view.prev !== null && open(view.prev)}>
+ Earlier
+ </Button>
+ <Button type="button" size="sm" variant="ghost" disabled={disabled || view.next === null} onClick={() => view.next !== null && open(view.next)}>
+ Later
+ </Button>
+ </>
+ )}
+ </form>
+ {view && (
+ <div className="flex flex-col gap-2" data-testid="frame-reading-form">
+ <p className="text-xs text-muted-foreground" aria-label="frame reading heading">
+ Reading at {clock(view.t)}
+ {view.copyOf !== null && ` (a duplicate of the frame at ${clock(view.copyOf)})`}
+ {view.misread && " · set aside as a misread"}
+ {view.correction && !view.misread && " · corrected by a person"}
+ </p>
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2">
+ {view.fields.map((f) => (
+ <label key={f.path} className="flex flex-col gap-0.5 text-sm">
+ <span className="text-xs text-muted-foreground">
+ {f.label}
+ {f.corrected && <span className="text-warning"> · read {toText(f.read, f.kind) || "nothing"}</span>}
+ </span>
+ {f.kind === "enum" ? (
+ <select
+ value={values[f.path] ?? ""}
+ onChange={(e) => setValues((v) => ({ ...v, [f.path]: e.target.value }))}
+ aria-label={f.label}
+ className="rounded border border-border bg-card px-2 py-1 text-sm"
+ >
+ {!f.required && <option value="">—</option>}
+ {(f.options ?? []).map((o) => (
+ <option key={o} value={o}>
+ {o}
+ </option>
+ ))}
+ </select>
+ ) : f.kind === "lines" ? (
+ <textarea
+ value={values[f.path] ?? ""}
+ onChange={(e) => setValues((v) => ({ ...v, [f.path]: e.target.value }))}
+ aria-label={f.label}
+ rows={3}
+ className="rounded border border-border bg-card px-2 py-1 text-xs font-mono"
+ />
+ ) : (
+ <input
+ value={values[f.path] ?? ""}
+ onChange={(e) => setValues((v) => ({ ...v, [f.path]: e.target.value }))}
+ aria-label={f.label}
+ inputMode={f.kind === "whole" || f.kind === "number" ? "decimal" : undefined}
+ className="rounded border border-border bg-card px-2 py-1 text-sm"
+ />
+ )}
+ </label>
+ ))}
+ </div>
+ <label className="flex flex-col gap-0.5 text-sm">
+ <span className="text-xs text-muted-foreground">Note</span>
+ <input
+ value={note}
+ onChange={(e) => setNote(e.target.value)}
+ aria-label="correction note"
+ className="rounded border border-border bg-card px-2 py-1 text-sm"
+ />
+ </label>
+ <div className="flex flex-wrap gap-2">
+ <Button type="button" size="sm" disabled={disabled} onClick={() => save({})}>
+ Save correction
+ </Button>
+ <Button type="button" size="sm" variant="outline" disabled={disabled || view.misread} onClick={() => save({ misread: true })}>
+ Mark misread
+ </Button>
+ {view.correction && (
+ <Button type="button" size="sm" variant="ghost" disabled={disabled} onClick={() => save({ clear: true })}>
+ Clear correction
+ </Button>
+ )}
+ </div>
+ </div>
+ )}
+ {status && (
+ <p role="status" aria-label="frame reading status" className="text-xs text-muted-foreground">
+ {status}
+ </p>
+ )}
+ {error && (
+ <p role="alert" aria-label="frame reading error" className="text-xs text-destructive">
+ {error}
+ </p>
+ )}
+ </section>
+ );
+}
diff --git a/editor/app/channels/[slug]/videos/[id]/components/FrameRederiveControl.tsx b/editor/app/channels/[slug]/videos/[id]/components/FrameRederiveControl.tsx
@@ -0,0 +1,80 @@
+"use client";
+
+import { useEffect, useState, useTransition } from "react";
+import { useRouter } from "next/navigation";
+import { Button } from "yt-dlp-transcript-common/components/ui/button";
+import { frameRederiveAction } from "../frameScanActions";
+
+// "Re-derive (no model)": the scan's timeline worked out again from the
+// readings it holds — no model, no frame — as `archilyzer frames rederive`
+// does. The hero's screen name may be changed with it (the derivation reads
+// the hero's pots, all-ins and bust by name).
+export function FrameRederiveControl({
+ slug,
+ videoId,
+ profile,
+ hero,
+}: {
+ slug: string;
+ videoId: string;
+ profile: string;
+ hero: string | null;
+}) {
+ const router = useRouter();
+ const [hydrated, setHydrated] = useState(false);
+ useEffect(() => setHydrated(true), []);
+ const [name, setName] = useState(hero ?? "");
+ const [pending, start] = useTransition();
+ const [done, setDone] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+ const run = () => {
+ setError(null);
+ setDone(null);
+ start(async () => {
+ const res = await frameRederiveAction(slug, videoId, profile, name);
+ if (!res.ok) {
+ setError(res.error);
+ return;
+ }
+ const { before: b, after: a, eventsByKind } = res.rederived;
+ const kinds = Object.entries(eventsByKind)
+ .map(([k, n]) => `${k} ${n}`)
+ .join(", ");
+ setDone(
+ `Re-derived from ${res.rederived.readings} readings: tournaments ${b.tournaments} → ${a.tournaments}, ` +
+ `events ${b.events} → ${a.events}, flags ${b.flags} → ${a.flags}, misreads ${b.misreads} → ${a.misreads}` +
+ (kinds ? ` (${kinds})` : ""),
+ );
+ router.refresh();
+ });
+ };
+ return (
+ <div className="flex flex-col gap-2">
+ <div className="flex flex-wrap items-center gap-2 text-sm">
+ <label className="flex items-center gap-2">
+ <span className="text-muted-foreground">Hero</span>
+ <input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ aria-label="hero screen name"
+ placeholder="screen name"
+ className="rounded border border-border bg-card px-2 py-1 text-sm w-44"
+ />
+ </label>
+ <Button type="button" size="sm" variant="outline" disabled={!hydrated || pending} onClick={run}>
+ {pending ? "Re-deriving…" : "Re-derive (no model)"}
+ </Button>
+ </div>
+ {done && (
+ <p role="status" aria-label="re-derive result" className="text-xs text-muted-foreground">
+ {done}
+ </p>
+ )}
+ {error && (
+ <p role="alert" aria-label="re-derive error" className="text-xs text-destructive">
+ {error}
+ </p>
+ )}
+ </div>
+ );
+}
diff --git a/editor/app/channels/[slug]/videos/[id]/components/FrameScanPanel.tsx b/editor/app/channels/[slug]/videos/[id]/components/FrameScanPanel.tsx
@@ -2,14 +2,19 @@
// the phase strip, a small chart per tournament, the events (each a link to
// the moment on the video's platform), the flags where something said and
// something read disagree — and the Scan button when the video is saved.
+// With no model (release 32): Re-derive, and a person's correction of any
+// reading (each event has a "Correct" beside it).
//
// Not a registry operation (those are corpus-wide lanes, one panel each
// below): a scan is asked for one stream at a time. Drawn when the sidecar
// exists or the video's container is saved; otherwise there is nothing to
// show and nothing to scan.
+import Link from "next/link";
import type { FrameScanView } from "../lib/frameScanView";
import { FrameScanControl } from "./FrameScanControl";
+import { FrameRederiveControl } from "./FrameRederiveControl";
+import { FrameReadingEditor } from "./FrameReadingEditor";
const PHASE_CLASS: Record<string, string> = {
table: "bg-success",
@@ -23,11 +28,14 @@ export function FrameScanPanel({
videoId,
views,
canScan,
+ readingT = null,
}: {
slug: string;
videoId: string;
views: FrameScanView[];
canScan: boolean;
+ // The reading to open in the correction form (`?reading=<s>` on the page).
+ readingT?: number | null;
}) {
if (!views.length && !canScan) return null;
return (
@@ -96,6 +104,14 @@ export function FrameScanPanel({
)}
<span className="font-medium">{e.kind}</span>
<span className="text-muted-foreground">{e.detail}</span>
+ <Link
+ href={`?reading=${Math.round(e.t)}#frame-reading`}
+ scroll={false}
+ aria-label={`Correct the reading at ${e.at}`}
+ className="text-xs text-muted-foreground underline hover:text-foreground"
+ >
+ Correct
+ </Link>
</li>
))}
</ul>
@@ -107,6 +123,24 @@ export function FrameScanPanel({
))}
</ul>
)}
+ {v.corrections.length > 0 && (
+ <div className="flex flex-col gap-0.5 text-xs">
+ <span className="font-medium">Corrected by a person ({v.corrections.length})</span>
+ <ul className="flex flex-col gap-0.5 text-muted-foreground" aria-label="frame scan corrections">
+ {v.corrections.map((c) => (
+ <li key={c.t} className="flex gap-2">
+ <Link href={`?reading=${Math.round(c.t)}#frame-reading`} scroll={false} className="font-mono underline hover:text-foreground">
+ {c.at}
+ </Link>
+ <span>{c.what}</span>
+ {c.note && <span className="italic">{c.note}</span>}
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+ <FrameRederiveControl slug={slug} videoId={videoId} profile={v.profile} hero={v.hero} />
+ <FrameReadingEditor slug={slug} videoId={videoId} profile={v.profile} initialT={readingT} />
</div>
))}
{canScan && <FrameScanControl slug={slug} videoId={videoId} profile="poker" scanned={views.some((v) => v.profile === "poker")} />}
diff --git a/editor/app/channels/[slug]/videos/[id]/frameScanActions.ts b/editor/app/channels/[slug]/videos/[id]/frameScanActions.ts
@@ -5,11 +5,24 @@
// `pnpm ops frame-scan`. Its refusals (no saved video, the route, the day's
// cap) come back as the button's error.
//
+// And (release 32, lane R3) the panel's model-free half: Re-derive — the
+// sidecar's `derived` worked out again from its stored readings, as
+// `frame-scan {rederive: true}` and `archilyzer frames rederive` do — and a
+// person's correction of one reading (controller/frameCorrections.ts), which
+// re-derives at once. Neither is a job: each answers in the request.
+//
// NOTHING BUT FUNCTIONS IS DECLARED HERE (a "use server" file; see
// operationActions.ts).
+import { revalidatePath } from "next/cache";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
-import { enqueueFrameScan } from "yt-dlp-transcript-common/controller/frameScan";
+import { enqueueFrameScan, type FrameScanRederived } from "yt-dlp-transcript-common/controller/frameScan";
+import {
+ correctFrameReading,
+ frameReadingAt,
+ type CorrectFrameReadingResult,
+ type FrameReadingView,
+} from "yt-dlp-transcript-common/controller/frameCorrections";
import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand";
export async function frameScanAction(slug: string, videoId: string, profile: string): Promise<StreamActionResult> {
@@ -17,3 +30,39 @@ export async function frameScanAction(slug: string, videoId: string, profile: st
if ("evicted" in out || "rederived" in out) return { ok: false, error: "nothing to scan" };
return out.result;
}
+
+export async function frameRederiveAction(
+ slug: string,
+ videoId: string,
+ profile: string,
+ hero?: string,
+): Promise<{ ok: true; rederived: FrameScanRederived } | { ok: false; error: string }> {
+ const name = hero?.trim();
+ const out = await enqueueFrameScan({ slug, id: videoId, profile, rederive: true, ...(name ? { hero: name } : {}) }, { paths: getPaths() });
+ if ("rederived" in out) {
+ revalidatePath(`/channels/${slug}/videos/${videoId}`);
+ return { ok: true, rederived: out.rederived };
+ }
+ if ("result" in out && !out.result.ok) return { ok: false, error: out.result.error };
+ return { ok: false, error: "not re-derived" };
+}
+
+export async function frameReadingAction(
+ slug: string,
+ videoId: string,
+ profile: string,
+ t: number,
+): Promise<{ ok: true; view: FrameReadingView } | { ok: false; error: string }> {
+ return frameReadingAt(getPaths(), { slug, id: videoId, profile, t });
+}
+
+export async function correctFrameReadingAction(
+ slug: string,
+ videoId: string,
+ profile: string,
+ req: { t: number; set?: Record<string, unknown>; misread?: boolean; clear?: boolean; note?: string },
+): Promise<CorrectFrameReadingResult> {
+ const out = await correctFrameReading(getPaths(), { slug, id: videoId, profile, ...req });
+ if (out.ok) revalidatePath(`/channels/${slug}/videos/${videoId}`);
+ return out;
+}
diff --git a/editor/app/channels/[slug]/videos/[id]/lib/frameScanView.test.ts b/editor/app/channels/[slug]/videos/[id]/lib/frameScanView.test.ts
@@ -49,3 +49,23 @@ test("frameScanView: strip, charts, events with links, flags, summary", () => {
assert.equal(v.summary, "20 frames every 10 s, 12 read (8 duplicates skipped) on claude-haiku-4-5 · $0.04 · 1 misread set aside · 1 smaller pot won");
assert.equal(v.stopped, "cap");
});
+
+test("frameScanView: the hero, a person's corrections (release 32), and when it was re-derived", () => {
+ const r = {
+ ...record(),
+ hints: { hero: "SynthHero" },
+ rederivedAt: "2026-10-16T09:30:00.000Z",
+ corrections: [
+ { t: 40, at: "2026-10-16T09:29:00Z", by: "person" as const, misread: true as const, note: "the webcam" },
+ { t: 90, at: "2026-10-16T09:29:30Z", by: "person" as const, set: { "hero.stack": 41000, "tournament.name": null } },
+ ],
+ };
+ const v = frameScanView(r, null);
+ assert.equal(v.hero, "SynthHero");
+ assert.deepEqual(v.corrections, [
+ { t: 40, at: "0:40", what: "misread, set aside", note: "the webcam" },
+ { t: 90, at: "1:30", what: "hero.stack 41,000, tournament.name not shown", note: null },
+ ]);
+ assert.match(v.summary, / · re-derived 2026-10-16 09:30$/);
+ assert.equal(frameScanView(record(), null).hero, null);
+});
diff --git a/editor/app/channels/[slug]/videos/[id]/lib/frameScanView.ts b/editor/app/channels/[slug]/videos/[id]/lib/frameScanView.ts
@@ -10,9 +10,14 @@ export type StripPart = { phase: string; leftPct: number; widthPct: number; labe
export type Spark = { label: string; points: string; min: number; max: number; last: number };
export type TournamentView = { key: string; name: string; span: string; sparks: Spark[]; facts: string[] };
export type EventView = { t: number; at: string; kind: string; detail: string; href: string | null; source: string };
+export type CorrectionView = { t: number; at: string; what: string; note: string | null };
export type FrameScanView = {
profile: string;
summary: string;
+ // The hero's screen name the scan was told (a re-derive may change it).
+ hero: string | null;
+ // A person's corrections of readings (release 32), by second.
+ corrections: CorrectionView[];
strip: StripPart[];
tournaments: TournamentView[];
events: EventView[];
@@ -102,6 +107,27 @@ export function frameScanView(r: FrameScanRecord, webpageUrl: string | null): Fr
`${fmtNum(r.sampling.frames)} frames every ${r.sampling.everySeconds} s, ${fmtNum(r.readings.length)} read` +
` (${fmtNum(r.sampling.skippedDuplicates)} duplicates skipped) on ${r.model.model} · $${r.costUsd.toFixed(2)}` +
(r.derived.misreads.length ? ` · ${r.derived.misreads.length} misread${r.derived.misreads.length === 1 ? "" : "s"} set aside` : "") +
- (pots ? ` · ${pots} smaller pot${pots === 1 ? "" : "s"} won` : "");
- return { profile: r.profile, summary, strip, tournaments, events, flags, stopped: last?.stopped ?? null };
+ (pots ? ` · ${pots} smaller pot${pots === 1 ? "" : "s"} won` : "") +
+ (r.rederivedAt ? ` · re-derived ${r.rederivedAt.slice(0, 16).replace("T", " ")}` : "");
+ const corrections = (r.corrections ?? []).map((c) => ({
+ t: c.t,
+ at: clock(c.t),
+ what: c.misread
+ ? "misread, set aside"
+ : Object.entries(c.set ?? {})
+ .map(([k, v]) => `${k} ${v === null ? "not shown" : Array.isArray(v) ? v.join(" ") : typeof v === "number" ? fmtNum(v) : v}`)
+ .join(", "),
+ note: c.note ?? null,
+ }));
+ return {
+ profile: r.profile,
+ summary,
+ hero: r.hints?.hero ?? null,
+ corrections,
+ strip,
+ tournaments,
+ events,
+ flags,
+ stopped: last?.stopped ?? null,
+ };
}
diff --git a/editor/app/channels/[slug]/videos/[id]/page.tsx b/editor/app/channels/[slug]/videos/[id]/page.tsx
@@ -105,10 +105,16 @@ export async function generateMetadata({
export default async function VideoDetailPage({
params,
+ searchParams,
}: {
params: Promise<{ slug: string; id: string }>;
+ searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const { slug, id } = await params;
+ // `?reading=<s>`: the frame reading the Frame scan panel's correction form opens.
+ const readingRaw = (await searchParams).reading;
+ const readingT =
+ typeof readingRaw === "string" && /^\d+(\.\d+)?$/.test(readingRaw) ? Number(readingRaw) : null;
const config = await readChannelConfig(getPaths(), slug);
if (!config) notFound();
// Everything below reads the video's TEXT, which is on the corpus disk
@@ -392,6 +398,7 @@ export default async function VideoDetailPage({
videoId={id}
views={frameScans.map((r) => frameScanView(r, meta.webpageUrl ?? null))}
canScan={!!savedVideo}
+ readingT={readingT}
/>
{/* The external operations' per-video surface is the pipeline stage