"use client"; // FIND CLIPS (release 36, lane A): the clip finder's whole chain for this // video, one button — the same job as `pnpm ops find-clips` // (controller/findClips.ts). Each step it skips or runs is in the job's log; // what the last run found (data//find-clips.json) is drawn below it: the // umtool project, linked, and the narrated-video segments umtool found, each // with its own "Find clips in this part". // // TYPE-ONLY from lib/findClipsRecord-server (it reaches node:fs through // sidecar-server): the record arrives as a prop, read by the page. import { useState } from "react"; import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog"; import type { FindClipsRecord } from "yt-dlp-transcript-common/lib/findClipsRecord-server"; import { cancelJobAction } from "../../../../../jobs/actions"; import { findClipsAction } from "../findClipsActions"; const input = "rounded border border-border bg-card px-2 py-1 text-sm"; function clock(seconds: number): string { const s = Math.max(0, Math.round(seconds)); 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 FindClipsPanel({ slug, videoId, umtoolUrl, holds, record, }: { slug: string; videoId: string; // UMTOOL_URL on the editor (lib/umtoolUrl.ts), read by the page. Null: the // button is disabled and the status line says why. umtoolUrl: string | null; // What would hold a step right now ("the transcription workers are paused", // "the backfill lane is held"), read by the page. Any: the "while paused" // checkbox is offered — this one video's steps run past them. holds: string[]; record: FindClipsRecord | null; }) { const [minutes, setMinutes] = useState(""); const [whilePaused, setWhilePaused] = useState(false); const target = Number(minutes) > 0 ? Math.round(Number(minutes) * 60) : undefined; const opts = (segment?: string) => ({ ...(target !== undefined ? { target } : {}), ...(segment ? { segment } : {}), ...(holds.length > 0 && whilePaused ? { whilePaused: true } : {}), }); const status = !umtoolUrl ? "off" : record ? `last run ${record.at.slice(0, 10)}: ${record.segments.length} segment${record.segments.length === 1 ? "" : "s"}` : "not run yet"; return (

Find clips

{status}
{!umtoolUrl && (

UMTOOL_URL is not set on the editor: Find clips hands the recording to umtool's clip finder.

)}
{holds.length > 0 && ( )}
{holds.length > 0 && (

{holds.join("; ").replace(/^./, (c) => c.toUpperCase())}.

)} findClipsAction(slug, videoId, opts())} cancelAction={cancelJobAction} buttonLabel="Find clips" runningLabel="Finding clips…" label={`Find clips in ${videoId}`} disabled={!umtoolUrl} /> {record && (

Clips:{" "} {record.project} {" "} ({record.created ? "new project" : "re-analyzed"} {record.segment ? `, segment ${record.segment}` : ""})

{record.segments.length > 0 && (
    {record.segments.map((s) => (
  • {s.id} {clock(s.from)}–{clock(s.to)} {s.why ? — {s.why} : null} findClipsAction(slug, videoId, opts(s.id))} cancelAction={cancelJobAction} buttonLabel="Find clips in this part" runningLabel="Finding clips…" label={`Find clips in segment ${s.id}`} disabled={!umtoolUrl} />
  • ))}
)}
)}
); }