commit 11d213c1db2b49e207f563c03ada665fb05e4265
parent 977e795b92bfa9ba3a72b58bea41b3d5bd1586d4
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 12:26:32 -0400
umtool: the Look panel (Build tab), Frame the short + Make a short (clip editor), the Shorts list (Deliver tab)
LookPanel: header, timeline footer, QR, the join's length and style, loudness (as recorded / -16 / custom),
speaker captions with each role's name and the size; Save the look writes only what changed. The clip
editor: a speaker's name for the captions beside each speaker; Frame the short draws a 9:16 box on the
player (drag, size slider; written when let go; Centre it); Make a short starts the job and follows it.
ShortsList: play, download, make again (the old one set aside), frame it; says when the clip moved since.
Redesign primitives and role tokens only; nothing calls a model.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 597 insertions(+), 5 deletions(-)
diff --git a/umtool/components/projects/report/BuildTab.tsx b/umtool/components/projects/report/BuildTab.tsx
@@ -2,10 +2,11 @@ import Link from "next/link";
import { fmtAgo, fmtBytes } from "@/lib/format";
import { mixHref } from "@/lib/hrefs";
import ReportBuildChain from "../ReportBuildChain";
+import LookPanel from "./LookPanel";
import type { ReportTabProps } from "./shared";
-// The Build tab: the final video and the build chain (its job on the ONE
-// JobProgress). The on-screen panel was parked here until P4b moved it to
+// The Build tab: the final video, the look (LookPanel, release 36) and the
+// build chain (its job on the ONE JobProgress). The on-screen panel was parked here until P4b moved it to
// the Media tab.
export default function BuildTab({ project, detail }: ReportTabProps) {
@@ -29,6 +30,8 @@ export default function BuildTab({ project, detail }: ReportTabProps) {
</Link>
</div>
)}
+ {/* --- the look: header, QR, joins, loudness, captions (release 36) */}
+ <LookPanel project={project.id} />
{/* --- building it ---------------------------------------------- */}
<ReportBuildChain
project={project.id}
diff --git a/umtool/components/projects/report/DeliverTab.tsx b/umtool/components/projects/report/DeliverTab.tsx
@@ -3,6 +3,7 @@ import { EXPORT_FORMATS, exportableVariants } from "@/lib/report/export.mjs";
import { podcastFor } from "@/lib/report/serve.mjs";
import DeliverSection from "../DeliverSection";
import PodcastExport from "../PodcastExport";
+import ShortsList from "./ShortsList";
import type { ReportTabProps } from "./shared";
// The Deliver tab: the deliver panel (cuts, share batches, rulings applied,
@@ -29,6 +30,9 @@ export default async function DeliverTab({ project, detail }: ReportTabProps) {
own clip files is the other, and both wait on the same walk. */}
<DeliverSection project={project} manifest={m} entries={entries} />
+ {/* --- the shorts: one clip each, 1080x1920 (release 36) ---------- */}
+ <ShortsList project={project.id} />
+
{/* --- exports --------------------------------------------------- */}
<section data-exports="" className="rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-3 py-2">
<h2 className="micro mb-1">export</h2>
diff --git a/umtool/components/projects/report/LookPanel.tsx b/umtool/components/projects/report/LookPanel.tsx
@@ -0,0 +1,230 @@
+"use client";
+
+import { useCallback, useEffect, useState } from "react";
+import { buttonVariants } from "@/components/ui/button";
+import { Field, Input, Select } from "@/components/ui/field";
+import { Panel } from "@/components/ui/panel";
+
+// THE LOOK (release 36 lane C): the render keys a person sets for a cut with
+// no deck -- the header, the timeline footer, the QR, the crossfade's length
+// and style, the loudness target, the speaker captions -- written through
+// /api/report/render (lib/report/manifest.mjs updateRender, the build's own
+// checks). Nothing here calls a model. A deck cut keeps its own settings
+// (the Media tab); a montage levels with render.montage.
+
+type Look = {
+ headerHeight?: number;
+ footerHeight?: number;
+ qr?: unknown;
+ transition?: number;
+ transitionStyle?: string;
+ loudness?: { target: number } | null;
+ captions?: { style: "speakers"; labels?: { host?: string | null; subject?: string | null } | null; size?: "m" | "l" } | null;
+};
+type View = { look: Look; deck: boolean; montage: boolean; styles: string[]; errors: string[]; token: string | null };
+
+const STYLE_WORDS: Record<string, string> = { fade: "crossfade", fadeblack: "dip to black", fadewhite: "dip to white", dissolve: "dissolve" };
+
+type Draft = {
+ header: boolean;
+ footer: boolean;
+ qr: boolean;
+ transition: string;
+ style: string;
+ loudness: "off" | "-16" | "custom";
+ target: string;
+ captions: boolean;
+ host: string;
+ subject: string;
+ size: "m" | "l";
+};
+
+function draftOf(l: Look): Draft {
+ const t = l.loudness?.target;
+ return {
+ header: l.headerHeight !== 0,
+ footer: l.footerHeight !== 0,
+ qr: l.qr !== false,
+ transition: String(l.transition ?? 0.5),
+ style: l.transitionStyle ?? "fade",
+ loudness: typeof t !== "number" ? "off" : t === -16 ? "-16" : "custom",
+ target: typeof t === "number" ? String(t) : "-16",
+ captions: !!l.captions,
+ host: l.captions?.labels?.host ?? "",
+ subject: l.captions?.labels?.subject ?? "",
+ size: l.captions?.size ?? "m",
+ };
+}
+
+/** The patch that takes the saved look to the draft: only what changed, `null` to remove a key. */
+function patchOf(was: Look, d: Draft, view: View): Record<string, unknown> {
+ const p: Record<string, unknown> = {};
+ if (d.header !== (was.headerHeight !== 0)) p.headerHeight = d.header ? null : 0;
+ if (d.footer !== (was.footerHeight !== 0)) p.footerHeight = d.footer ? null : 0;
+ if (d.qr !== (was.qr !== false)) p.qr = d.qr;
+ const tr = Number(d.transition);
+ if (tr !== (was.transition ?? 0.5)) p.transition = tr;
+ if (d.style !== (was.transitionStyle ?? "fade")) p.transitionStyle = d.style === "fade" ? null : d.style;
+ if (!view.montage) {
+ const target = d.loudness === "off" ? null : d.loudness === "-16" ? -16 : Number(d.target);
+ if (target !== (was.loudness?.target ?? null)) p.loudness = target === null ? null : { target };
+ }
+ if (!view.montage && !view.deck) {
+ const labels = { ...(d.host.trim() ? { host: d.host.trim() } : {}), ...(d.subject.trim() ? { subject: d.subject.trim() } : {}) };
+ const next = d.captions ? { style: "speakers", ...(Object.keys(labels).length ? { labels } : {}), ...(d.size === "l" ? { size: "l" } : {}) } : null;
+ if (JSON.stringify(next) !== JSON.stringify(was.captions ?? null)) p.captions = next;
+ }
+ return p;
+}
+
+export default function LookPanel({ project }: { project: string }) {
+ const [view, setView] = useState<View | null>(null);
+ const [draft, setDraft] = useState<Draft | null>(null);
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const [status, setStatus] = useState<string | null>(null);
+
+ const load = useCallback(async () => {
+ const r = await fetch(`/api/report/render?project=${encodeURIComponent(project)}`, { cache: "no-store" });
+ const j = (await r.json()) as View & { error?: string };
+ if (!r.ok) throw new Error(j.error ?? `HTTP ${r.status}`);
+ setView(j);
+ setDraft(draftOf(j.look));
+ }, [project]);
+ useEffect(() => {
+ load().catch((e) => setError(e instanceof Error ? e.message : String(e)));
+ }, [load]);
+
+ if (!view || !draft) {
+ return (
+ <Panel title="Look" data-look-panel="loading">
+ <p className="m-0 text-[12px] text-muted">{error ?? "reading the look…"}</p>
+ </Panel>
+ );
+ }
+ const set = (k: Partial<Draft>) => {
+ setDraft({ ...draft, ...k });
+ setStatus(null);
+ };
+ const patch = patchOf(view.look, draft, view);
+ const dirty = Object.keys(patch).length > 0;
+ const save = async () => {
+ setBusy(true);
+ setError(null);
+ try {
+ const r = await fetch("/api/report/render", { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, token: view.token, patch }) });
+ const j = (await r.json().catch(() => ({}))) as { error?: string; errors?: string[]; stale?: boolean; look?: Look; token?: string };
+ if (r.status === 409) {
+ await load();
+ setError("the manifest changed since this was read — reloaded; check and save again");
+ return;
+ }
+ if (!r.ok) {
+ setError((j.errors ?? [j.error ?? `HTTP ${r.status}`]).join("; "));
+ return;
+ }
+ setView({ ...view, look: j.look ?? {}, token: j.token ?? null, errors: [] });
+ setDraft(draftOf(j.look ?? {}));
+ setStatus("Saved — the next render uses it");
+ } finally {
+ setBusy(false);
+ }
+ };
+ const check = (k: keyof Draft, label: string, attr: string, disabled = false) => (
+ <label className="inline-flex items-center gap-1.5 text-[12.5px] text-text">
+ <input type="checkbox" {...{ [attr]: "" }} checked={draft[k] as boolean} disabled={disabled || busy} onChange={(e) => set({ [k]: e.target.checked } as Partial<Draft>)} />
+ {label}
+ </label>
+ );
+
+ return (
+ <Panel title="Look" data-look-panel="" data-look-dirty={dirty ? "" : undefined}>
+ {view.errors.length > 0 && (
+ <p role="alert" data-look-errors="" className="m-0 mb-2 text-[12px] text-reject-text">
+ {view.errors.join("; ")}
+ </p>
+ )}
+ <div className="flex flex-wrap items-center gap-x-5 gap-y-2">
+ {check("header", "Header", "data-look-header")}
+ {check("footer", "Timeline footer", "data-look-footer")}
+ {check("qr", "QR code", "data-look-qr")}
+ </div>
+ <div className="mt-3 flex flex-wrap items-end gap-4">
+ <Field label="Between clips, s">
+ <Input data-look-transition="" type="number" min={0} max={3} step={0.1} value={draft.transition} disabled={busy} onChange={(e) => set({ transition: e.target.value })} className="w-[6em]" />
+ </Field>
+ <Field label="Join">
+ <Select data-look-style="" value={draft.style} disabled={busy || Number(draft.transition) === 0} onChange={(e) => set({ style: e.target.value })}>
+ {view.styles.map((s) => (
+ <option key={s} value={s}>
+ {STYLE_WORDS[s] ?? s}
+ </option>
+ ))}
+ </Select>
+ </Field>
+ {!view.montage && (
+ <Field label="Loudness">
+ <span className="flex items-center gap-1.5">
+ <Select data-look-loudness="" value={draft.loudness} disabled={busy} onChange={(e) => set({ loudness: e.target.value as Draft["loudness"] })}>
+ <option value="off">as recorded</option>
+ <option value="-16">−16 LUFS (even)</option>
+ <option value="custom">custom</option>
+ </Select>
+ {draft.loudness === "custom" && (
+ <Input data-look-target="" type="number" min={-30} max={-8} step={0.5} value={draft.target} disabled={busy} onChange={(e) => set({ target: e.target.value })} className="w-[5.5em]" aria-label="Loudness target, LUFS" />
+ )}
+ </span>
+ </Field>
+ )}
+ </div>
+ <div className="mt-3 space-y-2">
+ {view.deck || view.montage ? (
+ <p className="m-0 text-[12px] text-muted" data-look-captions-off="">
+ {view.deck ? "Captions: the deck draws its own words (Media tab)." : "Captions: not for a montage."}
+ </p>
+ ) : (
+ <>
+ {check("captions", "Speaker captions", "data-look-captions")}
+ {draft.captions && (
+ <div className="flex flex-wrap items-end gap-4 pl-5">
+ <Field label="Host's name" hint="blank: told apart by colour">
+ <Input data-look-label-host="" value={draft.host} maxLength={40} disabled={busy} onChange={(e) => set({ host: e.target.value })} className="w-[12em]" />
+ </Field>
+ <Field label="Subject's name">
+ <Input data-look-label-subject="" value={draft.subject} maxLength={40} disabled={busy} onChange={(e) => set({ subject: e.target.value })} className="w-[12em]" />
+ </Field>
+ <Field label="Size">
+ <Select data-look-size="" value={draft.size} disabled={busy} onChange={(e) => set({ size: e.target.value as Draft["size"] })}>
+ <option value="m">medium</option>
+ <option value="l">large</option>
+ </Select>
+ </Field>
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ <div className="mt-3 flex flex-wrap items-center gap-3">
+ <button type="button" data-look-save="" disabled={busy || !dirty} onClick={() => void save()} className={buttonVariants({ variant: dirty ? "go" : "outline", size: "md" })}>
+ Save the look
+ </button>
+ {dirty && (
+ <button type="button" disabled={busy} onClick={() => setDraft(draftOf(view.look))} className={buttonVariants({ variant: "quiet", size: "md" })}>
+ Undo changes
+ </button>
+ )}
+ <span aria-live="polite" className="text-[12px]">
+ {error ? (
+ <span role="alert" data-look-error="" className="text-reject-text">
+ {error}
+ </span>
+ ) : status ? (
+ <span data-look-status="" className="text-muted">
+ {status}
+ </span>
+ ) : null}
+ </span>
+ </div>
+ </Panel>
+ );
+}
diff --git a/umtool/components/projects/report/ShortsList.tsx b/umtool/components/projects/report/ShortsList.tsx
@@ -0,0 +1,126 @@
+"use client";
+
+import Link from "next/link";
+import { useCallback, useEffect, useState } from "react";
+import { badgeVariants } from "@/components/ui/badge";
+import { buttonVariants } from "@/components/ui/button";
+import { Panel } from "@/components/ui/panel";
+import { fmtAgo, fmtBytes } from "@/lib/format";
+import { clipEditorHref } from "@/lib/hrefs";
+
+// THE SHORTS (release 36 lane C): `<project>/shorts/<clipId>.mp4`, each one
+// clip at 1080x1920 (the clip editor's Make a short). Play one here, download
+// it, or make it again (the old one is set aside, never overwritten).
+
+type Short = { clip: string; size: number; mtimeMs: number; stale: boolean; gone: boolean; record: { cut?: [number, number] | null; captions?: { lines: number } | null; loudness?: { target: number } | null } | null };
+type Job = { id: string; state: string; error: string | null; kind?: string };
+
+export default function ShortsList({ project }: { project: string }) {
+ const [shorts, setShorts] = useState<Short[] | null>(null);
+ const [job, setJob] = useState<Job | null>(null);
+ const [playing, setPlaying] = useState<string | null>(null);
+ const [error, setError] = useState<string | null>(null);
+
+ const load = useCallback(async () => {
+ const r = await fetch(`/api/report/shorts?project=${encodeURIComponent(project)}`, { cache: "no-store" });
+ const j = (await r.json()) as { shorts?: Short[]; running?: Job | null; error?: string };
+ if (!r.ok) throw new Error(j.error ?? `HTTP ${r.status}`);
+ setShorts(j.shorts ?? []);
+ if (j.running) setJob(j.running);
+ }, [project]);
+ useEffect(() => {
+ load().catch((e) => setError(e instanceof Error ? e.message : String(e)));
+ }, [load]);
+ useEffect(() => {
+ if (!job || job.state !== "running") return;
+ const t = setInterval(async () => {
+ const r = await fetch(`/api/report/shorts?job=${job.id}`, { cache: "no-store" }).catch(() => null);
+ if (!r?.ok) return;
+ const j = (await r.json()) as Job;
+ setJob(j);
+ if (j.state !== "running") await load().catch(() => {});
+ }, 1500);
+ return () => clearInterval(t);
+ }, [job, load]);
+
+ const remake = async (clip: string) => {
+ setError(null);
+ const r = await fetch("/api/report/shorts", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, clip, replace: true }) });
+ const j = (await r.json().catch(() => ({}))) as { job?: Job; error?: string };
+ if (!r.ok || !j.job) setError(j.error ?? `HTTP ${r.status}`);
+ else setJob(j.job);
+ };
+ const cancel = async () => {
+ if (!job) return;
+ await fetch(`/api/report/shorts?cancel=${job.id}`, { method: "POST" }).catch(() => null);
+ };
+ const file = (s: Short, extra = "") => `/api/report/shorts?project=${encodeURIComponent(project)}&clip=${encodeURIComponent(s.clip)}&file=1&v=${s.mtimeMs}${extra}`;
+ const running = job?.state === "running";
+
+ return (
+ <Panel title={`Shorts${shorts?.length ? ` — ${shorts.length}` : ""}`} data-shorts={shorts?.length ?? 0}>
+ {shorts === null ? (
+ <p className="m-0 text-[12px] text-muted">{error ?? "reading the shorts…"}</p>
+ ) : shorts.length === 0 && !running ? (
+ <p className="m-0 text-[12px] text-muted" data-shorts-empty="">
+ No shorts yet: the clip editor makes one of a clip (Make a short).{" "}
+ <Link href={clipEditorHref(project)} prefetch={false} className="ink-link">
+ Clip editor
+ </Link>
+ </p>
+ ) : (
+ <ul className="m-0 list-none space-y-2 p-0">
+ {shorts.map((s) => (
+ <li key={s.clip} data-short={s.clip} data-short-stale={s.stale ? "" : undefined} className="space-y-1">
+ <div className="flex flex-wrap items-baseline gap-x-3 gap-y-1 text-[12px] text-text-2">
+ <span className="font-mono text-[12.5px] text-text">{s.clip}</span>
+ <span className="num">
+ {fmtBytes(s.size)} · {fmtAgo(s.mtimeMs)}
+ {s.record?.cut ? ` · ${(s.record.cut[1] - s.record.cut[0]).toFixed(1)} s` : ""}
+ </span>
+ {s.stale && <span className={badgeVariants({ variant: "open", size: "sm" })}>the clip moved since</span>}
+ {s.gone && <span className={badgeVariants({ variant: "info", size: "sm" })}>no such clip now</span>}
+ <span className="ml-auto flex flex-wrap gap-1.5">
+ <button type="button" data-short-play={s.clip} onClick={() => setPlaying(playing === s.clip ? null : s.clip)} className={buttonVariants({ variant: playing === s.clip ? "pressed" : "outline", size: "sm" })}>
+ {playing === s.clip ? "Close" : "Play"}
+ </button>
+ <a href={file(s, "&download=1")} data-short-download={s.clip} className={buttonVariants({ size: "sm" })}>
+ Download
+ </a>
+ {!s.gone && (
+ <button type="button" data-short-remake={s.clip} disabled={running} onClick={() => void remake(s.clip)} className={buttonVariants({ size: "sm" })}>
+ Make again
+ </button>
+ )}
+ {!s.gone && (
+ <Link href={clipEditorHref(project, { clip: s.clip })} prefetch={false} className={buttonVariants({ variant: "quiet", size: "sm" })}>
+ Frame it
+ </Link>
+ )}
+ </span>
+ </div>
+ {playing === s.clip && (
+ <video data-short-player={s.clip} src={file(s)} controls playsInline autoPlay className="max-h-[70vh] w-auto max-w-full rounded-[3px] bg-black" style={{ aspectRatio: "9 / 16" }} />
+ )}
+ </li>
+ ))}
+ </ul>
+ )}
+ {job && (
+ <p data-shorts-job={job.state} className="m-0 mt-2 flex flex-wrap items-center gap-2 text-[12px] text-text-2">
+ {running ? `Making ${job.kind?.split(" ").at(-1) ?? "a short"}…` : job.state === "done" ? "Made." : `Failed${job.error ? `: ${job.error}` : ""}`}
+ {running && (
+ <button type="button" onClick={() => void cancel()} className={buttonVariants({ variant: "quiet", size: "sm" })}>
+ Cancel
+ </button>
+ )}
+ </p>
+ )}
+ {error && shorts !== null && (
+ <p role="alert" className="m-0 mt-1 text-[12px] text-reject-text">
+ {error}
+ </p>
+ )}
+ </Panel>
+ );
+}
diff --git a/umtool/components/projects/review/ClipEditor.tsx b/umtool/components/projects/review/ClipEditor.tsx
@@ -29,6 +29,9 @@ import { startTakeJob } from "../NewTakePanel";
// version, Add a clip from the selection, Bring in a proposal
// the comments a note on the clip (notes.json, anchored to it), its thread
// and an agent's replies, resolve / reopen
+// the short (release 36) a 9:16 box dragged on the player (the clip's
+// `vertical.crop`), Make a short (a job: shorts/<clip>.mp4);
+// a speaker's name for the captions in the Speakers list
//
// Every write is one POST to /api/report/clip-editor; the answer is the whole
// view again, so the page never guesses what the server did. Edge edits are
@@ -81,6 +84,7 @@ export default function ClipEditor({
const [speakerPick, setSpeakerPick] = useState<number | null>(null);
const [rolesChanged, setRolesChanged] = useState(false);
const [busy, setBusy] = useState(false);
+ const [framing, setFraming] = useState(false);
const [error, setError] = useState<string | null>(null);
const [status, setStatus] = useState<string | null>(null);
const token = useRef<string | null>(initialView.token);
@@ -256,6 +260,12 @@ export default function ClipEditor({
if (j) setRolesChanged(true);
});
};
+ const setLabel = (speaker: number, label: string) => {
+ void write({ op: "label", speaker, label: label.trim() || null }, label.trim() ? `Speaker ${speaker} is “${label.trim()}” in the captions` : `Speaker ${speaker}'s name cleared`);
+ };
+ const setCrop = (crop: number[] | null, aspect?: number) => {
+ void write({ op: "vertical", clip: clip.id, crop, ...(crop && aspect ? { aspect: Math.round(aspect * 10000) / 10000 } : {}) }, crop ? "Saved the short's framing" : "The short is framed from the centre");
+ };
// Re-propose: the clip finder's proposal pass as a job (`umtool clips
// propose`, /api/report/clips); clips a person edited are never touched.
const [proposing, setProposing] = useState<{ id: string; state: string; error: string | null } | null>(null);
@@ -386,7 +396,7 @@ export default function ClipEditor({
</p>
)}
- <Player ref={player} clipId={clip.id} targets={targets} cut={cut} onTime={setPlayhead} onPlaying={setPlaying} />
+ <Player ref={player} clipId={clip.id} targets={targets} cut={cut} onTime={setPlayhead} onPlaying={setPlaying} frame={framing ? { crop: clip.vertical?.crop ?? null, onChange: setCrop, busy } : null} />
{/* ---- the strip --------------------------------------------------- */}
<div className="space-y-1">
@@ -619,6 +629,7 @@ export default function ClipEditor({
{typeof s.sameAs === "number" ? ` · same voice as ${s.sameAs}` : ""}
</span>
<span className="num font-mono text-[11px] text-muted">{typeof s.seconds === "number" ? `${Math.round(s.seconds)} s` : ""}</span>
+ <SpeakerLabel speaker={s} busy={busy} onSave={(v) => setLabel(s.index, v)} />
{s.role !== "host" && (
<button type="button" data-speaker-host={s.index} disabled={busy} onClick={() => setRole(s.index, "host")} className={cn(buttonVariants({ variant: "quiet", size: "sm" }), "ml-auto")}>
This is the host
@@ -632,6 +643,7 @@ export default function ClipEditor({
{view.reactionsError && <p className="m-0 text-[12px] text-reject-text">{view.reactionsError}</p>}
{view.rulingsError && <p className="m-0 text-[12px] text-reject-text">{view.rulingsError}</p>}
+ <ShortMaker project={project} clipId={clip.id} short={view.shorts?.[clip.id] ?? null} framed={!!clip.vertical} framing={framing} onFraming={setFraming} onCentre={() => setCrop(null)} onMade={() => void reload().catch(() => {})} busy={busy} />
<RenderTake project={project} render={render} takes={takes} takesHref={takesHref} />
</aside>
</div>
@@ -644,11 +656,14 @@ export default function ClipEditor({
// ---------------------------------------------------------------------------
type PlayerHandle = { toggle: () => void; seek: (t: number) => void };
+/** The short's framing on the player: the clip's crop (null = the centre) and its writer. */
+type Frame = { crop: number[] | null; onChange: (crop: number[] | null, aspect?: number) => void; busy: boolean };
type Target = { channel: string; video: string; from: number; to: number; project: string; clip: string };
-const Player = forwardRef<PlayerHandle, { clipId: string; targets: Target[]; cut: Cut; onTime: (t: number) => void; onPlaying: (p: boolean) => void }>(function Player({ clipId, targets, cut, onTime, onPlaying }, ref) {
+const Player = forwardRef<PlayerHandle, { clipId: string; targets: Target[]; cut: Cut; onTime: (t: number) => void; onPlaying: (p: boolean) => void; frame?: Frame | null }>(function Player({ clipId, targets, cut, onTime, onPlaying, frame = null }, ref) {
const [found, setFound] = useState<{ play: CitedPlay; from: number } | null | undefined>(undefined);
+ const [dims, setDims] = useState<{ w: number; h: number } | null>(null);
const media = useRef<HTMLMediaElement | null>(null);
// The seek to the cut on load is the player's own, not a person's: it must
// not move the playhead somebody just set by clicking a word.
@@ -733,6 +748,8 @@ const Player = forwardRef<PlayerHandle, { clipId: string; targets: Target[]; cut
onLoadedMetadata: (e: React.SyntheticEvent<HTMLMediaElement>) => {
ownSeek.current = true;
e.currentTarget.currentTime = fileT(cutRef.current.cutStart);
+ const v = e.currentTarget as HTMLVideoElement;
+ if (v.videoWidth > 0 && v.videoHeight > 0) setDims({ w: v.videoWidth, h: v.videoHeight });
},
onSeeked: (e: React.SyntheticEvent<HTMLMediaElement>) => {
if (ownSeek.current) ownSeek.current = false;
@@ -751,7 +768,19 @@ const Player = forwardRef<PlayerHandle, { clipId: string; targets: Target[]; cut
};
return (
<div data-editor-player={found.play.kind} className="w-full max-w-[720px]">
- {found.play.audio ? <audio {...props} className="w-full" /> : <video {...props} playsInline className="aspect-video w-full rounded-[3px] bg-black" />}
+ {found.play.audio ? (
+ <audio {...props} className="w-full" />
+ ) : (
+ <div className="relative overflow-hidden rounded-[3px]">
+ <video {...props} playsInline className="aspect-video w-full rounded-[3px] bg-black" />
+ {frame && dims && <CropBox frame={frame} aspect={dims.w / dims.h} />}
+ </div>
+ )}
+ {frame && (found.play.audio || !dims) && (
+ <span data-crop-none="" className="micro block">
+ {found.play.audio ? "no picture here to frame: the short is cut from the centre" : "reading the picture…"}
+ </span>
+ )}
<span className="micro">{found.play.label}</span>
</div>
);
@@ -1081,3 +1110,203 @@ function RenderTake({ project, render, takes, takesHref }: { project: string; re
</section>
);
}
+
+// ---------------------------------------------------------------------------
+// The short (release 36): its 9:16 box on the player, its name for a voice,
+// and Make a short.
+// ---------------------------------------------------------------------------
+
+const VERTICAL = 9 / 16;
+const r4 = (n: number) => Math.round(n * 10000) / 10000;
+/** The centred, full-height 9:16 box on a source of aspect `a` (report-to-video/look.mjs defaultCrop). */
+function centreCrop(a: number): number[] {
+ let w = VERTICAL / a;
+ let h = 1;
+ if (w > 1) {
+ h = a / VERTICAL;
+ w = 1;
+ }
+ return [r4((1 - w) / 2), r4((1 - h) / 2), r4(w), r4(h)];
+}
+/** A box of height `h` (a fraction) about the centre (cx, cy), 9:16 on the source, inside the picture. */
+function boxAt(a: number, h: number, cx: number, cy: number): number[] {
+ let hh = Math.min(1, Math.max(0.2, h));
+ let w = (hh * VERTICAL) / a;
+ if (w > 1) {
+ w = 1;
+ hh = (w * a) / VERTICAL;
+ }
+ const x = Math.min(1 - w, Math.max(0, cx - w / 2));
+ const y = Math.min(1 - hh, Math.max(0, cy - hh / 2));
+ return [r4(x), r4(y), r4(w), r4(hh)];
+}
+
+/** The short's box over the picture: drag to move it, the slider sizes it; written when let go. */
+function CropBox({ frame, aspect }: { frame: Frame; aspect: number }) {
+ const [draft, setDraft] = useState<number[] | null>(null);
+ const crop = draft ?? frame.crop ?? centreCrop(aspect);
+ const area = useRef<HTMLDivElement | null>(null);
+ const drag = useRef<{ x0: number; y0: number; crop: number[]; w: number; h: number } | null>(null);
+ useEffect(() => setDraft(null), [frame.crop]);
+ // The picture inside the 16:9 player (object-fit: contain).
+ const P = 16 / 9;
+ const content = aspect >= P ? { left: 0, top: ((1 - P / aspect) / 2) * 100, width: 100, height: (P / aspect) * 100 } : { left: ((1 - aspect / P) / 2) * 100, top: 0, width: (aspect / P) * 100, height: 100 };
+ const [x, y, w, h] = crop;
+ const commit = (c: number[]) => frame.onChange(c, aspect);
+ return (
+ <>
+ <div ref={area} className="pointer-events-none absolute" style={{ left: `${content.left}%`, top: `${content.top}%`, width: `${content.width}%`, height: `${content.height}%` }}>
+ <div
+ data-crop-box={crop.join(",")}
+ role="slider"
+ aria-label="The short's framing: drag to move"
+ aria-valuenow={x}
+ tabIndex={0}
+ onPointerDown={(e) => {
+ if (e.button !== 0 || frame.busy) return;
+ e.stopPropagation();
+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
+ const r = area.current!.getBoundingClientRect();
+ drag.current = { x0: e.clientX, y0: e.clientY, crop, w: Math.max(1, r.width), h: Math.max(1, r.height) };
+ }}
+ onPointerMove={(e) => {
+ const d = drag.current;
+ if (!d) return;
+ const [dx, dy, dw, dh] = d.crop;
+ setDraft(boxAt(aspect, dh, dx + dw / 2 + (e.clientX - d.x0) / d.w, dy + dh / 2 + (e.clientY - d.y0) / d.h));
+ }}
+ onPointerUp={() => {
+ const moved = drag.current && draft;
+ drag.current = null;
+ if (moved && draft) commit(draft);
+ }}
+ className="pointer-events-auto absolute cursor-move border-2 border-signal shadow-[0_0_0_9999px_color-mix(in_srgb,black_55%,transparent)]"
+ style={{ left: `${x * 100}%`, top: `${y * 100}%`, width: `${w * 100}%`, height: `${h * 100}%` }}
+ />
+ </div>
+ <div className="absolute bottom-12 left-2 flex items-center gap-2 rounded-[3px] bg-[color-mix(in_srgb,black_70%,transparent)] px-2 py-1 text-[11.5px] text-white">
+ <label htmlFor="crop-size">Size</label>
+ <input
+ id="crop-size"
+ data-crop-size=""
+ type="range"
+ min={0.3}
+ max={1}
+ step={0.01}
+ value={h}
+ disabled={frame.busy}
+ onChange={(e) => setDraft(boxAt(aspect, Number(e.target.value), x + w / 2, y + h / 2))}
+ onPointerUp={() => draft && commit(draft)}
+ onKeyUp={() => draft && commit(draft)}
+ />
+ </div>
+ </>
+ );
+}
+
+/** A speaker's name in the captions: blank is the default (told apart by colour). */
+function SpeakerLabel({ speaker, busy, onSave }: { speaker: Speaker; busy: boolean; onSave: (v: string) => void }) {
+ const fallback = speaker.role === "host" ? "Host" : speaker.role === "subject" ? "Subject" : `Speaker ${speaker.index + 1}`;
+ const saved = speaker.label && speaker.label !== fallback ? speaker.label : "";
+ const [text, setText] = useState(saved);
+ useEffect(() => setText(saved), [saved]);
+ const commit = () => {
+ if (text.trim() !== saved) onSave(text);
+ };
+ return (
+ <input
+ data-speaker-label={speaker.index}
+ aria-label={`Speaker ${speaker.index}'s name in the captions`}
+ value={text}
+ maxLength={40}
+ disabled={busy}
+ placeholder="name"
+ onChange={(e) => setText(e.target.value)}
+ onBlur={commit}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") (e.target as HTMLInputElement).blur();
+ if (e.key === "Escape") {
+ setText(saved);
+ (e.target as HTMLInputElement).blur();
+ }
+ }}
+ className="w-[7.5em] rounded border border-seam-2 bg-ground px-1.5 py-0.5 text-[11.5px] text-text outline-none focus:border-signal"
+ />
+ );
+}
+
+/** Make a short: the clip at 1080x1920 from its box, a job; the one there is set aside, never overwritten. */
+function ShortMaker({ project, clipId, short, framed, framing, onFraming, onCentre, onMade, busy }: {
+ project: string;
+ clipId: string;
+ short: { mtimeMs: number; size: number; stale: boolean } | null;
+ framed: boolean;
+ framing: boolean;
+ onFraming: (on: boolean) => void;
+ onCentre: () => void;
+ onMade: () => void;
+ busy: boolean;
+}) {
+ const [job, setJob] = useState<{ id: string; state: string; error: string | null } | null>(null);
+ const [err, setErr] = useState<string | null>(null);
+ useEffect(() => {
+ setJob(null);
+ setErr(null);
+ }, [clipId]);
+ useEffect(() => {
+ if (!job || job.state !== "running") return;
+ const t = setInterval(async () => {
+ const r = await fetch(`/api/report/shorts?job=${job.id}`, { cache: "no-store" }).catch(() => null);
+ if (!r?.ok) return;
+ const j = (await r.json()) as { id: string; state: string; error: string | null };
+ setJob({ id: j.id, state: j.state, error: j.error });
+ if (j.state !== "running") onMade();
+ }, 1500);
+ return () => clearInterval(t);
+ }, [job, onMade]);
+ const make = async () => {
+ setErr(null);
+ const r = await fetch("/api/report/shorts", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, clip: clipId, replace: !!short }) });
+ const j = (await r.json().catch(() => ({}))) as { job?: { id: string; state: string; error: string | null }; error?: string };
+ if (!r.ok || !j.job) setErr(j.error ?? `HTTP ${r.status}`);
+ else setJob({ id: j.job.id, state: j.job.state, error: j.job.error });
+ };
+ const running = job?.state === "running";
+ return (
+ <section data-short-maker={clipId} data-short-made={short ? "" : undefined} className="space-y-1.5">
+ <h2 className="micro m-0">Short</h2>
+ <p className="m-0 text-[12px] text-text-2">
+ {framed ? "Framed by you" : "Framed from the centre"}
+ {short ? ` · made ${new Date(short.mtimeMs).toLocaleString()}${short.stale ? " · the clip moved since" : ""}` : ""}
+ </p>
+ <div className="flex flex-wrap gap-1.5">
+ <button type="button" data-frame-short="" aria-pressed={framing} onClick={() => onFraming(!framing)} className={buttonVariants({ variant: framing ? "pressed" : "outline", size: "sm" })}>
+ {framing ? "Done framing" : "Frame the short"}
+ </button>
+ {framed && (
+ <button type="button" data-crop-centre="" disabled={busy} onClick={onCentre} className={buttonVariants({ variant: "quiet", size: "sm" })}>
+ Centre it
+ </button>
+ )}
+ <button type="button" data-make-short={clipId} disabled={running || busy} onClick={() => void make()} className={buttonVariants({ variant: "go", size: "sm" })}>
+ {running ? "Making the short…" : short ? "Make the short again" : "Make a short"}
+ </button>
+ {short && (
+ <a href={`/api/report/shorts?project=${encodeURIComponent(project)}&clip=${encodeURIComponent(clipId)}&file=1&v=${short.mtimeMs}`} target="_blank" rel="noreferrer" data-short-open={clipId} className={buttonVariants({ variant: "quiet", size: "sm" })}>
+ Play it
+ </a>
+ )}
+ </div>
+ {job && (
+ <p data-short-job={job.state} className="m-0 text-[12px] text-text-2">
+ {running ? "Rendering 1080×1920 in the heavy slot" : job.state === "done" ? "Made — on the Deliver tab's Shorts list" : `Failed${job.error ? `: ${job.error}` : ""}`}
+ </p>
+ )}
+ {err && (
+ <p role="alert" className="m-0 text-[12px] text-reject-text">
+ {err}
+ </p>
+ )}
+ </section>
+ );
+}