"use client"; import { useCallback, useEffect, useState } from "react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { InspectorFrame, SaidLine, call, type InspectorProps, type Said } from "./shared"; // A STILL AT SECOND N (umtool redesign L6, item 6): one frame of the clip on screen at the playhead's SOURCE // second, from its fetched window, saved in the project's shots/ (POST /api/report/still-frame; a single ffmpeg // frame, nothing fetched, nothing in the cut written). `StillButton` sits by Play's controls; `StillInspector` // lists the project's shots (with `block` a clip's id: that clip's stills). `umtool still` is the twin. type Shot = { rel: string; name: string; bytes: number; mtime: string; still: { clip: string; at: number } | null }; const shotUrl = (project: string, rel: string, v = "") => `/api/report/still-frame?${new URLSearchParams({ project, file: rel }).toString()}${v ? `&v=${encodeURIComponent(v)}` : ""}`; export default function StillInspector({ project, block = null }: InspectorProps) { const [shots, setShots] = useState(null); const load = useCallback(async () => { const { ok, j } = await call<{ shots: Shot[] }>(`/api/report/still-frame?project=${encodeURIComponent(project)}`); if (ok) setShots(j.shots); }, [project]); useEffect(() => { void load(); // A still grabbed in Play (another component) is listed here once it lands. const on = () => void load(); window.addEventListener("umtool:still-grabbed", on); return () => window.removeEventListener("umtool:still-grabbed", on); }, [load]); if (!shots) return null; const list = block ? shots.filter((s) => s.still?.clip === block) : shots; return ( umtool still {project} <clip> --at <s>}> {list.length === 0 ? (

No pictures in shots/ yet — Play’s Still button grabs the frame on screen.

) : ( )}
); } /** * Play's STILL button: the frame of the clip on screen at the playhead (`source()` -- the clip's id and the SOURCE * second, or null on a card) grabbed into shots/. */ export function StillButton({ project, take = null, source, className }: { project: string; take?: string | null; source: () => { clip: string; at: number } | null; className?: string }) { const [busy, setBusy] = useState(false); const [said, setSaid] = useState(null); const [last, setLast] = useState(null); const grab = async () => { const s = source(); if (!s) { setSaid({ ok: false, text: "a card has no frame to keep: pause on a clip" }); return; } setBusy(true); setSaid(null); try { const { ok, j } = await call<{ rel?: string; at?: number }>("/api/report/still-frame", { method: "POST", body: JSON.stringify({ project, clip: s.clip, at: s.at, ...(take ? { take } : {}) }) }); if (!ok || !j.rel) { setSaid({ ok: false, text: j.error ?? "the frame could not be grabbed" }); return; } setLast(j.rel); setSaid({ ok: true, text: `${j.rel} (${s.clip} @ ${(j.at ?? s.at).toFixed(2)} s)` }); window.dispatchEvent(new CustomEvent("umtool:still-grabbed", { detail: { rel: j.rel } })); } finally { setBusy(false); } }; return ( {said && ( {said.ok && last && ( open )} )} ); }