"use server"; // The video page's Scan button (release 30, lane P): one `frame-scan` job for // this video on the poker profile, through the same controller as // `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, 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 { const out = await enqueueFrameScan({ slug, id: videoId, profile }, { paths: getPaths() }); 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; misread?: boolean; clear?: boolean; note?: string }, ): Promise { const out = await correctFrameReading(getPaths(), { slug, id: videoId, profile, ...req }); if (out.ok) revalidatePath(`/channels/${slug}/videos/${videoId}`); return out; }