commit 535c19ec322207f98ad899a8b9a1c9e11736d5b9
parent 6e178040801fb0b5771a591960b2eff5667e2f61
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 24 Oct 2026 03:04:21 -0400
umtool: the walk on a phone -- pinned picture, edge strip with sentence snap, walk dock; Play the cut's Edit this clip / Back to the cut
Below md the clip bench is one document: the place bar and the picture
pinned (a 120 px strip once the quote is under it), the record and the
quote, the edge strip (the sentence as the unit of an edge: boundaries from
the pre-cut's rule in lib/report/sentenceEdges.mjs, sentence steps, a drag
that snaps within 0.6 s, Snap | Free remembered per browser), the
transcript, every other concern folded, and a walk dock (Note what's wrong
in a sheet, play, Confirm with a ten-second Undo). The desk's boxes are
flattened with display: contents and ordered for the phone; every phone
class on a desk element is max-md:, so md and up are unchanged.
Play the cut: Edit this clip (button, E, the phone dock) opens the bench
with ?from=play; Back to the cut saves an unsaved window and returns to the
project's cut by clip id and offset. A take's edit goes to the project's
manifest, and the bench says so. Phone pass on Play (pinned player, dock)
and on the two swipe decks (safe area, 44 px targets).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
17 files changed, 2059 insertions(+), 90 deletions(-)
diff --git a/umtool/app/globals.css b/umtool/app/globals.css
@@ -864,3 +864,40 @@ canvas.grabbable {
}
}
+
+/* ---- phone: the walk ---- */
+/* The clip bench's walk, Play the cut and the swipe decks below md (the phone
+ design brief, "The walk"). Every rule is inside the phone query, so the desk
+ (md and up) is untouched; most of the walk is `max-md:` utilities on the
+ components, and these are the few a utility cannot say. Unlayered on
+ purpose: they must beat the controls' own size utilities. */
+@media (max-width: 767.98px) {
+ /* The pinned picture: edge to edge, no frame -- and a strip once the quote
+ has scrolled under it (ClipBench `compact`). */
+ [data-walk-pin] video,
+ [data-walk-pin] [data-walk-pin-empty] {
+ border-radius: 0;
+ border-width: 0;
+ }
+ [data-walk-pin][data-compact] video,
+ [data-walk-pin][data-compact] [data-walk-pin-empty] {
+ flex: none;
+ width: 213px;
+ height: 120px;
+ aspect-ratio: auto;
+ }
+ /* What the walk folds away is still worked with a thumb: every control in
+ an opened section is a 44 px target, and a field is 16 px so the phone
+ does not zoom the page to type into it. */
+ [data-walk-in] :is(button, select, summary, input[type="text"], textarea) {
+ min-height: 44px;
+ }
+ [data-walk-in] :is(input[type="text"], textarea, select) {
+ font-size: 16px;
+ }
+ /* A note written in Play the cut scrolls clear of the pinned player and the dock. */
+ [data-play-composer] {
+ scroll-margin: 140px 0 96px;
+ }
+}
+/* ---- end phone: the walk ---- */
diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx
@@ -1,9 +1,10 @@
"use client";
-import AnchoredNotes from "@/components/notes/AnchoredNotes";
+import AnchoredNotes, { notesOn } from "@/components/notes/AnchoredNotes";
import GeneratedBanner from "@/components/notes/GeneratedBanner";
import { useSharedNotes, wroteNotes } from "@/components/notes/NotesProvider";
import { useCallback, useEffect, useRef, useState } from "react";
+import { createPortal } from "react-dom";
import Link from "next/link";
import { useRouter } from "next/navigation";
import Waveform, { type Peaks } from "@/components/Waveform";
@@ -13,8 +14,10 @@ import { StoredUrlCheckbox, useStoredUrlOffered } from "@/components/clips/Store
import { STORED_URL_UI_MODE } from "yt-dlp-transcript-common/lib/storedMediaUrl";
import { ReaderPane, paperButtonVariants } from "@/components/ui/reader-pane";
import { citationText } from "@/lib/research/facets.mjs";
+import { cn } from "@/lib/utils";
import { BenchBody, VerdictBar } from "./bench/BenchShell";
import CopyCitation from "./bench/CopyCitation";
+import EdgeStrip from "./bench/EdgeStrip";
// The renderer's own line, imported rather than re-written. A preview that
// disagrees with the header by a character is worth less than no preview: you
// would only find out twenty minutes into a build.
@@ -268,6 +271,18 @@ export type ClipBenchData = {
deckOn: boolean;
/** The manifest's `generatedBy`: edits here are noted for the agent that runs it. */
generatedBy?: string | null;
+ /**
+ * The walk's links, built server-side so they carry `?from=play` when the
+ * bench was opened from Play the cut: p / n, Confirm's advance, and the
+ * phone's place bar (`back` is the piece's cut).
+ */
+ walkHrefs?: { prev: string | null; next: string | null; back: string; backLabel: string };
+ /**
+ * Opened from Play the cut ("Edit this clip"): where "Back to the cut"
+ * returns -- the project's cut at this clip -- and the take that was playing,
+ * if one was (its render does not change when this manifest does).
+ */
+ fromPlay?: { href: string; take: string | null } | null;
};
const hms = (t: number) => {
@@ -283,6 +298,50 @@ const hms = (t: number) => {
const round2 = (n: number) => Number(n.toFixed(2));
// ---------------------------------------------------------------------------
+// THE WALK ON A PHONE (the phone design brief, "The walk").
+//
+// The same bench, below md: one document, the picture pinned at the top and
+// shrinking to a strip once the quote has scrolled under it, the edge strip
+// (bench/EdgeStrip.tsx) where the desk has its waveform, the transcript, then
+// every other concern folded, and the verdict in a dock under the thumb. The
+// desk's boxes are flattened (`display: contents`, BenchBody's `phoneFlat`)
+// and re-ordered with `order`, so it is one tree and one <video> -- the
+// playback engine above never knows which layout it is in. Every phone class
+// on a desk element is `max-md:`, so nothing from md up moves.
+// ---------------------------------------------------------------------------
+const PHONE = "(max-width: 767.98px)";
+const isPhoneNow = () => typeof window !== "undefined" && window.matchMedia(PHONE).matches;
+/** The place bar's height plus its progress hairline: what slides away on the way down. */
+const BAR_H = 46;
+/** The picture as a strip, once the quote has gone under it. */
+const STRIP_H = 120;
+/** How long a Confirm can be undone. */
+const UNDO_MS = 10_000;
+const UNDO_KEY = "umtool.walk.undo";
+/**
+ * A Confirm, remembered across the advance so the next clip's page can offer
+ * its Undo. sessionStorage: one tab's walk, gone with the tab.
+ */
+type UndoRec = {
+ project: string;
+ clip: string;
+ next: string | null;
+ at: number;
+ /** The entry as it was before the Confirm (the writer's `before`). */
+ before: Record<string, unknown>;
+ /** The Confirm carried a moved window, so Undo puts the edges back too. */
+ moved: boolean;
+};
+const readUndo = (): UndoRec | null => {
+ try {
+ const raw = sessionStorage.getItem(UNDO_KEY);
+ return raw ? (JSON.parse(raw) as UndoRec) : null;
+ } catch {
+ return null;
+ }
+};
+
+// ---------------------------------------------------------------------------
// Playback preferences.
//
// Per BROWSER, never per manifest: how fast somebody listens and whether a
@@ -476,6 +535,103 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
// seek, and a clip that replays itself every time you drag is unusable.
const autoPlayed = useRef<string | null>(null);
+ // ---- the phone ------------------------------------------------------------
+ // Which layout is showing decides only BEHAVIOUR (does `x` open the note
+ // sheet or focus the desk's box; does the transcript follow the playhead);
+ // what is drawn is CSS, so the server and the first paint agree.
+ const [isPhone, setIsPhone] = useState(false);
+ useEffect(() => {
+ const m = window.matchMedia(PHONE);
+ const on = () => setIsPhone(m.matches);
+ on();
+ m.addEventListener("change", on);
+ return () => m.removeEventListener("change", on);
+ }, []);
+ // The folded sections, by name. All folded on arrival: the walk is the
+ // picture, the edges and the words; the rest is there when asked for.
+ const [openSec, setOpenSec] = useState<Record<string, boolean>>({});
+ const toggleSec = (k: string) => setOpenSec((o) => ({ ...o, [k]: !o[k] }));
+ /** A folded section's body: hidden on a phone until opened, untouched on the desk. */
+ const secBody = (k: string, order: string) => cn(order, !openSec[k] && "max-md:hidden");
+ // "Note what's wrong": a sheet with the keyboard up, rather than a box far
+ // down the page.
+ const [sheet, setSheet] = useState(false);
+ // The pinned picture: a strip once the quote is under it, and the place bar
+ // away on the way down, back on the way up.
+ const pinRef = useRef<HTMLDivElement | null>(null);
+ const recordRef = useRef<HTMLDivElement | null>(null);
+ const [compact, setCompact] = useState(false);
+ const [barHidden, setBarHidden] = useState(false);
+ useEffect(() => {
+ if (!isPhone) {
+ setCompact(false);
+ setBarHidden(false);
+ return;
+ }
+ let lastY = window.scrollY;
+ let raf = 0;
+ const run = () => {
+ raf = 0;
+ const y = window.scrollY;
+ const rec = recordRef.current;
+ const w = pinRef.current?.clientWidth || window.innerWidth;
+ // In DOCUMENT coordinates, so the strip's own change of size cannot
+ // flip it back: the pin keeps its footprint (its margin makes up the
+ // difference), and nothing below it moves.
+ if (rec) setCompact(y + BAR_H + (w * 9) / 16 > rec.getBoundingClientRect().bottom + y + 1);
+ if (Math.abs(y - lastY) > 6) {
+ setBarHidden(y > lastY && y > BAR_H);
+ lastY = y;
+ }
+ };
+ const on = () => {
+ if (!raf) raf = requestAnimationFrame(run);
+ };
+ run();
+ window.addEventListener("scroll", on, { passive: true });
+ window.addEventListener("resize", on);
+ return () => {
+ cancelAnimationFrame(raf);
+ window.removeEventListener("scroll", on);
+ window.removeEventListener("resize", on);
+ };
+ }, [isPhone]);
+ // The writer's last answer: Confirm's Undo needs the entry as it was (`before`).
+ const lastSaved = useRef<Record<string, unknown> | null>(null);
+ // A Confirm that can still be undone: this clip's own, or the one that
+ // advanced here (sessionStorage carries it across the navigation).
+ const [undo, setUndo] = useState<UndoRec | null>(null);
+ useEffect(() => {
+ const u = readUndo();
+ if (!u) return;
+ try {
+ sessionStorage.removeItem(UNDO_KEY);
+ } catch {
+ /* nothing to clear */
+ }
+ if (u.project !== data.project || (u.next !== data.clip.id && u.clip !== data.clip.id)) return;
+ if (Date.now() - u.at >= UNDO_MS) return;
+ setUndo(u);
+ }, [data.project, data.clip.id]);
+ useEffect(() => {
+ if (!undo) return;
+ const id = window.setTimeout(() => setUndo(null), Math.max(0, undo.at + UNDO_MS - Date.now()));
+ return () => window.clearTimeout(id);
+ }, [undo]);
+ // The desk's "Back to the cut" lives in the bench head (BenchTop's slot).
+ const [topSlot, setTopSlot] = useState<Element | null>(null);
+ useEffect(() => {
+ if (data.fromPlay) setTopSlot(document.querySelector("[data-bench-top-slot]"));
+ }, [data.fromPlay]);
+ const hrefOf = useCallback(
+ (which: "prev" | "next") => {
+ const id = which === "prev" ? data.prev : data.next;
+ if (!id) return null;
+ return data.walkHrefs?.[which] ?? `/projects/${data.project}/clip/${id}`;
+ },
+ [data.prev, data.next, data.walkHrefs, data.project],
+ );
+
// The widest cached file is the one the bench draws from: it is how much room
// there is to drag before anything has to be fetched.
const cached = windows[0] ?? null;
@@ -502,13 +658,16 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
// Follow the playhead in the reading pane, and ONLY while something is
// playing: scrolling the words out from under somebody who is reading ahead
// would be worse than not following at all.
+ //
+ // Never on a phone: there the transcript is the PAGE, and following it would
+ // scroll the edge strip out from under the thumb auditioning an edge.
useEffect(() => {
- if (playhead == null) return;
+ if (playhead == null || isPhone) return;
const box = transcriptBox.current;
if (!box) return;
const row = box.querySelector(`[data-tcue="${cues.find((c) => playhead >= c.start && playhead < c.end)?.start ?? -1}"]`);
if (row) row.scrollIntoView({ block: "nearest" });
- }, [playhead, cues]);
+ }, [playhead, cues, isPhone]);
// ---- reading ahead --------------------------------------------------------
//
@@ -1185,6 +1344,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
body: JSON.stringify({ project: data.project, clip: clip.id, token: token.current, ...patch }),
});
const j = (await r.json()) as Record<string, unknown>;
+ lastSaved.current = j;
setBusy(null);
if (wroteNotes(j)) void notes.reload();
if (!r.ok) {
@@ -1353,8 +1513,96 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
? "saved — the window moved with it, and the cut no longer fitted and was cleared"
: "saved — the window you moved was saved with it",
);
- if (ok && data.next) router.push(`/projects/${data.project}/clip/${data.next}`);
- }, [save, router, data.project, data.next, windowMoved, muteMoved, windowPatch]);
+ if (!ok) return;
+ // Undo for ten seconds: the phone's toast, on whichever page shows next.
+ // A verdict is a state change, and a thumb lands where it did not mean to.
+ const before = (lastSaved.current?.before ?? null) as Record<string, unknown> | null;
+ if (before) {
+ const rec: UndoRec = { project: data.project, clip: clip.id, next: data.next, at: Date.now(), before, moved: !!win };
+ try {
+ sessionStorage.setItem(UNDO_KEY, JSON.stringify(rec));
+ } catch {
+ /* no storage: the confirm stands, without an Undo */
+ }
+ if (!data.next) setUndo(rec);
+ }
+ const nextHref = hrefOf("next");
+ if (nextHref) router.push(nextHref);
+ }, [save, router, data.project, data.next, clip.id, windowMoved, muteMoved, windowPatch, hrefOf]);
+
+ /**
+ * Undo a Confirm: the verdict as it was, and the edges too when the Confirm
+ * carried them -- through the same writer, with that clip's own token -- and
+ * back to the clip, which is where the next decision about it is made.
+ */
+ const undoConfirm = useCallback(
+ async (u: UndoRec) => {
+ setUndo(null);
+ const b = u.before;
+ const r = await fetch(`/api/report/clip?project=${encodeURIComponent(u.project)}&clip=${encodeURIComponent(u.clip)}`, {
+ cache: "no-store",
+ });
+ if (!r.ok) {
+ setNote(`could not undo: ${r.status}`);
+ return;
+ }
+ const tok = ((await r.json()) as { token?: string }).token ?? null;
+ const patch: Record<string, unknown> = { verdict: b.verdict === "confirmed" || b.verdict === "incorrect" ? b.verdict : "" };
+ if (u.moved) {
+ patch.start = b.start;
+ patch.end = b.end;
+ patch.cutStart = b.cutStart ?? "";
+ patch.cutEnd = b.cutEnd ?? "";
+ patch.muteFrom = b.muteFrom ?? "";
+ }
+ const w = await fetch("/api/report/window", {
+ method: "PUT",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ project: u.project, clip: u.clip, token: tok, ...patch }),
+ });
+ const j = (await w.json()) as Record<string, unknown>;
+ if (!w.ok) {
+ setNote(j.stale ? "could not undo: the manifest changed since — reload" : `could not undo: ${String(j.error ?? w.status)}`);
+ return;
+ }
+ if (wroteNotes(j)) void notes.reload();
+ if (u.clip === clip.id) {
+ const next = fromEntry(clip, j.entry as Record<string, unknown>);
+ setClip(next);
+ setSel({ from: next.start, to: next.end });
+ setDirty(false);
+ setMute(next.muteFrom);
+ muteRef.current = next.muteFrom;
+ token.current = String(j.token ?? "");
+ setNote("undone — not yet reviewed");
+ return;
+ }
+ // The same address this page was opened with, on that clip: `from=play`
+ // rides along, `at` (the clip Play was on) does not.
+ const q = new URLSearchParams(window.location.search);
+ q.delete("at");
+ const qs = q.toString();
+ router.push(`/projects/${u.project}/clip/${encodeURIComponent(u.clip)}${qs ? `?${qs}` : ""}`);
+ },
+ // `notes.reload` is the stable part of `notes`.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [clip, router],
+ );
+
+ /**
+ * Back to Play the cut, at this clip. An unsaved window is saved first --
+ * the whole point of the round trip is to hear the edit -- and the button
+ * says so before it is pressed.
+ */
+ const backToPlay = useCallback(async () => {
+ const to = data.fromPlay?.href;
+ if (!to) return;
+ if (dirty || muteMoved) {
+ const ok = await save(windowPatch());
+ if (!ok) return;
+ }
+ router.push(to);
+ }, [data.fromPlay, dirty, muteMoved, save, windowPatch, router]);
const rejectClip = useCallback(() => {
setNeedNote(true);
@@ -1367,6 +1615,12 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
if (ok) setNeedNote(false);
});
}
+ // On a phone the note is written in a sheet, keyboard up, not in a box
+ // folded away under Attribution.
+ if (isPhoneNow()) {
+ setSheet(true);
+ return;
+ }
const el = correctionBox.current;
if (!el) return;
el.focus();
@@ -1487,13 +1741,17 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
// and going back to the project page between each one is nineteen round
// trips to re-find where you were.
case "n":
- case "N":
- if (data.next) router.push(`/projects/${data.project}/clip/${data.next}`);
+ case "N": {
+ const h = hrefOf("next");
+ if (h) router.push(h);
break;
+ }
case "p":
- case "P":
- if (data.prev) router.push(`/projects/${data.project}/clip/${data.prev}`);
+ case "P": {
+ const h = hrefOf("prev");
+ if (h) router.push(h);
break;
+ }
// The two answers to "is this accurate". `y` also advances, so a cut
// that is mostly right is walked with one finger.
case "y":
@@ -1557,6 +1815,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
data.project,
data.prev,
data.next,
+ hrefOf,
confirmClip,
rejectClip,
choosePlayback,
@@ -1989,6 +2248,8 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
const verdictBar = (
<VerdictBar
data-verdict-for={clip.id}
+ // A phone answers from the walk dock (below).
+ className="max-md:hidden"
question={
sentenceEnd != null ? (
<>Extend {clip.id} to the end of the sentence?</>
@@ -2093,7 +2354,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
});
const readerPane = (
<ReaderPane
- className="h-full"
+ className="h-full max-md:order-[40] max-md:-mx-4"
source={data.sourceTitle || clip.title || clip.video}
byline={[
data.sourceChannel || clip.channel,
@@ -2165,7 +2426,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
}
void play(c.start, Math.min(c.end + 4, view.to));
}}
- className={`flex w-full items-baseline gap-3 px-2.5 py-[3px] text-left hover:bg-[color-mix(in_srgb,var(--reader-signal)_6%,transparent)] ${
+ className={`flex w-full items-baseline gap-3 px-2.5 py-[3px] text-left max-md:py-2 hover:bg-[color-mix(in_srgb,var(--reader-signal)_6%,transparent)] ${
inSel ? "bg-[color-mix(in_srgb,var(--reader-signal)_11%,transparent)]" : ""
} ${lit ? "border-l-[3px] border-reader-signal" : "border-l-[3px] border-transparent"}`}
>
@@ -2207,7 +2468,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
bottom of its scrollport: they cost the pane a line and the
left column nothing, and "peek further" ends up beside the
dimmed lines it widens. Opaque, because it sits over text. */}
- <div className="micro sticky bottom-0 z-10 flex flex-wrap items-center gap-2 border-t border-reader-seam bg-reader px-2.5 py-1">
+ <div className="micro sticky bottom-0 z-10 flex flex-wrap items-center gap-2 border-t border-reader-seam bg-reader px-2.5 py-1 max-md:static max-md:py-2">
<span>click a line to play it</span>
{peek.length > 0 && (
<>
@@ -2226,6 +2487,316 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</ReaderPane>
);
+ // ---- the phone's own pieces (see "THE WALK ON A PHONE", above) -------------
+ // Each is md:hidden; the desk never draws them. Their data attributes are
+ // their own (`data-walk-*`), so no desk selector ever matches two elements.
+ const backLabel = data.walkHrefs?.backLabel ?? data.project;
+ const navBtn = "flex h-11 min-w-11 items-center justify-center rounded-[3px] text-[20px] leading-none";
+ const placeBar = (
+ <div data-walk-bar="" className="border-b border-seam bg-panel md:hidden">
+ <div className="flex h-11 items-center gap-1 px-1">
+ <Link
+ href={data.walkHrefs?.back ?? `/projects/${data.project}`}
+ prefetch={false}
+ aria-label={`back to ${backLabel}`}
+ data-walk-up=""
+ className={cn(navBtn, "text-muted-2")}
+ >
+ ‹
+ </Link>
+ <span className="min-w-0 max-w-[30%] shrink truncate font-mono text-[12px] text-muted-2">{backLabel}</span>
+ <span className="text-seam-2">/</span>
+ <span aria-current="page" data-walk-here="" className="min-w-0 truncate font-mono text-[13px] font-medium text-text">
+ {clip.id}
+ </span>
+ <span data-walk-pos={`${data.index}/${data.total}`} className="ml-auto shrink-0 pl-1 font-mono text-[12px] text-meter">
+ {data.index}/{data.total}
+ </span>
+ {(["prev", "next"] as const).map((w) => {
+ const h = hrefOf(w);
+ const glyph = w === "prev" ? "‹" : "›";
+ return h ? (
+ <Link key={w} href={h} prefetch={false} data-walk-nav={w} aria-label={`${w === "prev" ? "previous" : "next"} clip`} className={cn(navBtn, "text-text")}>
+ {glyph}
+ </Link>
+ ) : (
+ <span key={w} aria-hidden className={cn(navBtn, "text-seam-2")}>
+ {glyph}
+ </span>
+ );
+ })}
+ </div>
+ {/* The walk's progress: reviewed of the cut, a 2 px hairline. */}
+ <div aria-hidden className="h-0.5 bg-seam">
+ <div data-walk-progress={reviewed} className="h-full bg-meter" style={{ width: `${data.total ? (reviewed / data.total) * 100 : 0}%` }} />
+ </div>
+ </div>
+ );
+ const playing = playInfo?.state === "playing";
+ const stripSide = (
+ <div data-walk-strip-side="" className={cn("min-w-0 flex-1 flex-col justify-center gap-0.5 px-3 md:hidden", compact ? "flex" : "hidden")}>
+ <span className="truncate font-mono text-[13px] text-text">{clip.id}</span>
+ <span className="num font-mono text-[11.5px] text-meter">
+ {hms(sel.from)} – {hms(sel.to)}
+ </span>
+ <span className="text-[11.5px] text-muted">{playing ? "playing" : verdictLabel(clip)}</span>
+ </div>
+ );
+ const recordIso =
+ clip.date ||
+ (data.uploadDate ? `${data.uploadDate.slice(0, 4)}-${data.uploadDate.slice(4, 6)}-${data.uploadDate.slice(6, 8)}` : null);
+ // "22 Oct 2026": read at a glance, where the desk's fields keep the ISO form.
+ const recordDate =
+ recordIso && /^\d{4}-\d{2}-\d{2}$/.test(recordIso)
+ ? `${Number(recordIso.slice(8, 10))} ${["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][Number(recordIso.slice(5, 7)) - 1] ?? ""} ${recordIso.slice(0, 4)}`
+ : recordIso;
+ const phoneMiddle = (
+ <>
+ {/* The record and the quote, in flow: read once, scrolled under the picture. */}
+ <div ref={recordRef} data-walk-record="" className="order-[20] space-y-1.5 md:hidden">
+ <p className="m-0 truncate font-mono text-[12px] text-muted">
+ {[recordDate, data.sourceChannel || clip.channel, data.sourceTitle || clip.title].filter(Boolean).join(" · ")}
+ </p>
+ <p data-walk-quote="" className="m-0 font-serif text-[18px] leading-snug text-text">
+ {draft.quote.trim() ? `“${draft.quote.trim()}”` : <span className="text-muted">no quote on this entry</span>}
+ </p>
+ {data.fromPlay?.take && (
+ <p data-walk-take-note={data.fromPlay.take} className="m-0 text-[12.5px] leading-snug text-text-2">
+ Opened from take <span className="font-mono">{data.fromPlay.take}</span>. Edits here go to the project’s cut, not
+ to the take’s render, so Back plays the project’s cut.
+ </p>
+ )}
+ </div>
+ {cached && (
+ <EdgeStrip
+ className="order-[30] md:hidden"
+ view={view}
+ sel={sel}
+ peaks={peaks}
+ cues={railCues}
+ playhead={playhead}
+ limit={{ from: fetchStart, to: clampTo }}
+ busy={!!busy}
+ fmt={hms}
+ onSel={onSel}
+ onFetch={(edge, t) =>
+ void fetchMore(
+ edge === "end"
+ ? { padBefore: keepBefore, padAfter: Math.min(data.maxPad, Math.ceil(t + 2 - clip.end)) }
+ : { padBefore: Math.min(data.maxPad, Math.ceil(clip.start - (t - 2))), padAfter: keepAfter },
+ )
+ }
+ />
+ )}
+ {/* What the edges and the last save say, under the strip. */}
+ <div data-walk-status="" className="order-[31] flex flex-wrap items-center gap-2 text-[12.5px] md:hidden">
+ {unsaved && (
+ <>
+ <span className="text-doubt-text">Unsaved — Confirm saves the edges with it.</span>
+ <button type="button" data-walk-save="" disabled={!!busy} onClick={saveWindow} className={cn(buttonVariants({ variant: "outline", size: "md" }), "h-11")}>
+ Save edges
+ </button>
+ <button type="button" data-walk-reset="" onClick={() => resetRef.current()} className={cn(buttonVariants({ variant: "quiet", size: "md" }), "h-11")}>
+ Reset
+ </button>
+ </>
+ )}
+ {!unsaved && extendedFrom && (
+ <button type="button" data-walk-reset="" onClick={() => resetRef.current()} className={cn(buttonVariants({ variant: "quiet", size: "md" }), "h-11")}>
+ Undo the extension
+ </button>
+ )}
+ {busy && <span className="text-meter">{busy}</span>}
+ {note && (
+ <span data-walk-said="" className="text-doubt-text">
+ {note}
+ </span>
+ )}
+ <span data-walk-verdict={verdict} className={cn("ml-auto", verdict === "confirmed" ? "text-kept-text" : verdict === "incorrect" ? "text-doubt-text" : "text-muted")}>
+ {verdictLabel(clip)}
+ </span>
+ </div>
+ </>
+ );
+ /** A folded section's head (a phone): what it holds, and a one-line summary. */
+ const phoneSecHead = (k: string, order: string, label: string, summary: string | null) => (
+ <button
+ type="button"
+ data-walk-sec={k}
+ aria-expanded={!!openSec[k]}
+ onClick={() => toggleSec(k)}
+ className={cn("flex min-h-11 w-full items-center gap-2 border-t border-seam pt-1 text-left md:hidden", order)}
+ >
+ <span aria-hidden className="w-3 text-[11px] text-muted">
+ {openSec[k] ? "▾" : "▸"}
+ </span>
+ <span className="shrink-0 text-[14px] font-medium text-text">{label}</span>
+ {summary && <span className="min-w-0 truncate font-mono text-[11.5px] text-muted">{summary}</span>}
+ </button>
+ );
+ const clipNotes = notesOn(notes.notes, { kind: "entry", entry: clip.id }).filter((n) => n.anchor.kind !== "moment");
+ const openNotes = clipNotes.filter((n) => n.status === "open").length;
+ const phoneNotesHead = (
+ <>
+ {phoneSecHead("notes", "max-md:order-[90]", `Notes (${clipNotes.length})`, openNotes ? `${openNotes} open` : null)}
+ {data.generatedBy && (
+ <p data-walk-generated="" className={cn("m-0 text-[12px] text-muted md:hidden", secBody("notes", "order-[91]"))}>
+ From <code className="font-mono">{data.generatedBy}</code> — rebuilding the manifests overwrites edits made here.
+ </p>
+ )}
+ </>
+ );
+ const closeSheet = () => {
+ setSheet(false);
+ if (!draft.correction.trim()) setNeedNote(false);
+ };
+ const phoneDock = (
+ <>
+ {undo && (
+ <div
+ role="status"
+ data-walk-toast=""
+ className="fixed inset-x-3 bottom-[calc(80px+env(safe-area-inset-bottom))] z-40 flex items-center gap-3 rounded-[4px] border border-seam-2 bg-panel py-1 pl-3 pr-1 text-[13.5px] text-text shadow-lg md:hidden"
+ >
+ <span className="min-w-0 flex-1">
+ Confirmed <span className="font-mono">{undo.clip}</span>
+ {undo.clip !== clip.id ? (
+ <>
+ {" "}
+ — next: <span className="font-mono">{clip.id}</span>
+ </>
+ ) : (
+ " — the walk's last"
+ )}
+ </span>
+ <button type="button" data-walk-undo="" onClick={() => void undoConfirm(undo)} className="h-11 shrink-0 rounded-[3px] px-3 font-semibold text-signal-text">
+ Undo
+ </button>
+ </div>
+ )}
+ {/* THE WALK DOCK: the two answers and the selection, under the thumb. */}
+ <nav
+ aria-label="Walk"
+ data-walk-dock=""
+ className="fixed inset-x-0 bottom-0 z-40 border-t border-seam bg-ground px-3 pb-[calc(8px+env(safe-area-inset-bottom))] pt-2 md:hidden"
+ >
+ <div className="flex items-stretch gap-2">
+ {data.fromPlay && (
+ <button
+ type="button"
+ data-walk-back-play=""
+ disabled={!!busy}
+ onClick={() => void backToPlay()}
+ className={cn(buttonVariants({ variant: "outline", size: "md" }), "h-12 shrink-0 whitespace-normal px-2 leading-tight")}
+ >
+ {unsaved ? "Save, back to the cut" : "‹ The cut"}
+ </button>
+ )}
+ <button
+ type="button"
+ data-walk-note=""
+ onClick={rejectClip}
+ className={cn(buttonVariants({ variant: "outline", size: "md" }), "h-12 min-w-0 flex-1 whitespace-normal px-2 text-[13.5px] leading-tight")}
+ >
+ Note what’s wrong
+ </button>
+ <button
+ type="button"
+ data-walk-play={playing ? "playing" : ""}
+ aria-label={playing ? "stop" : "play the selection"}
+ disabled={!cached}
+ onClick={() => (playing ? stopPlayback() : void play(sel.from, sel.to))}
+ className={cn(buttonVariants({ variant: "outline", size: "md" }), "h-12 w-12 shrink-0 px-0 text-[16px]")}
+ >
+ {playing ? "■" : "▶"}
+ </button>
+ <button
+ type="button"
+ data-walk-confirm=""
+ disabled={!!busy}
+ onClick={() => void confirmClip()}
+ className={cn(buttonVariants({ variant: "go", size: "md" }), "h-12 min-w-0 flex-1 px-2 text-[14px]")}
+ >
+ Confirm
+ </button>
+ </div>
+ </nav>
+ {sheet && (
+ <div
+ role="dialog"
+ aria-modal="true"
+ aria-label="Note what's wrong"
+ data-walk-sheet=""
+ className="fixed inset-0 z-50 flex flex-col justify-end bg-[color-mix(in_srgb,var(--ground)_70%,transparent)] md:hidden"
+ onClick={closeSheet}
+ >
+ <div
+ className="max-h-[80vh] overflow-y-auto rounded-t-[8px] border-t border-seam-2 bg-panel px-4 pb-[calc(12px+env(safe-area-inset-bottom))] pt-2"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <div aria-hidden className="mx-auto mb-2 h-1 w-10 rounded-full bg-seam-2" />
+ <p className="m-0 text-[15px] text-text">
+ What is wrong with <span className="font-mono">{clip.id}</span>?
+ </p>
+ <p className="m-0 mt-0.5 text-[12.5px] text-muted">
+ Speaker, addressee, date, wording… Saving marks it incorrect, and the walk stays on it.
+ </p>
+ <textarea
+ autoFocus
+ rows={4}
+ data-walk-note-field=""
+ aria-label={`what is wrong with ${clip.id}`}
+ value={draft.correction}
+ onChange={(e) => setDraft((d) => ({ ...d, correction: e.target.value }))}
+ className="mt-2 w-full rounded-[3px] border border-seam-2 bg-ground px-2 py-2 text-[16px] text-text outline-none focus:border-signal"
+ />
+ <div className="mt-2 flex gap-2">
+ <button
+ type="button"
+ data-walk-note-save=""
+ disabled={!draft.correction.trim() || !!busy}
+ onClick={() => {
+ commit("correction");
+ setSheet(false);
+ }}
+ className={cn(buttonVariants({ variant: "go", size: "md" }), "h-12 flex-1 text-[14px]")}
+ >
+ Save note
+ </button>
+ <button type="button" onClick={closeSheet} className={cn(buttonVariants({ variant: "quiet", size: "md" }), "h-12 px-4 text-[14px]")}>
+ Cancel
+ </button>
+ </div>
+ </div>
+ </div>
+ )}
+ </>
+ );
+ // The desk's Back to the cut, in the bench head.
+ const deskBack =
+ data.fromPlay && topSlot
+ ? createPortal(
+ <>
+ <button
+ type="button"
+ data-back-to-play=""
+ disabled={!!busy}
+ title={unsaved ? "saves the window you moved, then plays the cut from this clip" : "plays the cut from this clip"}
+ onClick={() => void backToPlay()}
+ className={buttonVariants({ variant: "outline", size: "sm" })}
+ >
+ {unsaved ? "Save and back to the cut" : "‹ Back to the cut"}
+ </button>
+ {data.fromPlay.take && (
+ <span data-back-take={data.fromPlay.take} className="ml-2 text-[11.5px] text-muted-2">
+ edits go to the project’s cut, not take {data.fromPlay.take}
+ </span>
+ )}
+ </>,
+ topSlot,
+ )
+ : null;
+
return (
// ONE SCREEN, at a desk.
//
@@ -2237,25 +2808,33 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
// scrolls, and what does not earn its height is folded rather than cut.
// Below lg it is a single scrolling column -- a phone cannot hold this and
// pretending otherwise would cost the desk case something.
- <BenchBody verdict={verdictBar} reader={readerPane} workClassName="lg:overflow-hidden">
+ <BenchBody verdict={verdictBar} reader={readerPane} workClassName="lg:overflow-hidden" phoneFlat>
<div
data-bench={clip.id}
data-verdict={verdict}
- className="flex flex-col gap-2 lg:h-full lg:min-h-0 lg:overflow-hidden"
+ className="flex flex-col gap-2 lg:h-full lg:min-h-0 lg:overflow-hidden max-md:contents"
>
- <GeneratedBanner generatedBy={data.generatedBy} />
+ {/* On a phone the banner is one muted line under Notes (phoneNotesHead).
+ The wrapper only when there is a banner: an empty one would be a
+ flex item, and a gap, on the desk. */}
+ {data.generatedBy && (
+ <div className="max-md:hidden">
+ <GeneratedBanner generatedBy={data.generatedBy} />
+ </div>
+ )}
{/* ---- where you are, where you can go, and what will be burned in ---- */}
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px]">
- <span className="micro" data-review-progress="">
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] max-md:contents">
+ {/* On a phone both counts are the place bar's `50/51` and its hairline. */}
+ <span className="micro max-md:hidden" data-review-progress="">
{reviewed} reviewed
</span>
{/* What the WALK has left, which is not the same number: a clip nobody
has fetched still needs judgement and cannot get it today. */}
- <span className="micro" data-ready-count="">
+ <span className="micro max-md:hidden" data-ready-count="">
ready {data.ready} of {data.needing} needing judgement
</span>
{!data.fetched && (
- <span className={badgeVariants({ variant: "state", size: "sm" })} data-clip-unfetched="">
+ <span className={cn(badgeVariants({ variant: "state", size: "sm" }), "max-md:order-[21] max-md:self-start")} data-clip-unfetched="">
not fetched yet
</span>
)}
@@ -2265,18 +2844,43 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
<span
data-attrib-preview=""
title={previewLine}
- className="num ml-auto min-w-0 max-w-full truncate rounded bg-[var(--color-panel-2)] px-2 py-0.5 text-[12px] text-[var(--color-meter)]"
+ className={cn(
+ "num ml-auto min-w-0 max-w-full truncate rounded bg-[var(--color-panel-2)] px-2 py-0.5 text-[12px] text-[var(--color-meter)]",
+ secBody("attribution", "max-md:order-[81] max-md:ml-0 max-md:whitespace-normal"),
+ )}
>
{previewLine}
</span>
</div>
- <div className="grid min-h-0 flex-1 gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,23rem)]">
+ <div className="grid min-h-0 flex-1 gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(20rem,23rem)] max-md:contents">
{/* ================= the picture, and its edges ================= */}
{/* Since P4b the words are the bench's reader pane: this column is the
picture and everything that moves its edges, and it scrolls on its
own before the picture shrinks below a usable height. */}
- <div className="flex min-h-0 flex-col gap-2 lg:overflow-y-auto">
+ <div className="flex min-h-0 flex-col gap-2 lg:overflow-y-auto max-md:contents">
+ {/* ---- the pin (a phone): the place bar over the picture ----
+ On the desk this wrapper and the row inside it are `contents`:
+ the <video> is the column's flex item exactly as before. */}
+ <div
+ ref={pinRef}
+ data-walk-pin=""
+ data-compact={compact ? "" : undefined}
+ data-bar={barHidden ? "hidden" : "shown"}
+ className="md:contents max-md:sticky max-md:top-0 max-md:z-30 max-md:order-[10] max-md:-mx-4 max-md:bg-ground max-md:transition-transform max-md:duration-200"
+ style={
+ isPhone
+ ? {
+ transform: barHidden ? `translateY(-${BAR_H}px)` : undefined,
+ // The strip keeps the full picture's footprint, so the page
+ // under it does not jump when it shrinks.
+ marginBottom: compact ? `calc(100vw * 9 / 16 - ${STRIP_H}px)` : undefined,
+ }
+ : undefined
+ }
+ >
+ {placeBar}
+ <div className="flex md:contents">
{cached ? (
<video
ref={video}
@@ -2293,13 +2897,18 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
controls
/>
) : (
- <div className="flex aspect-video w-full items-center justify-center rounded border border-dashed border-[var(--color-line)] text-[12px] text-[var(--color-dim)] lg:aspect-auto lg:min-h-[200px] lg:flex-[3_1_0%]">
+ <div data-walk-pin-empty="" className="flex aspect-video w-full items-center justify-center rounded border border-dashed border-[var(--color-line)] text-[12px] text-[var(--color-dim)] lg:aspect-auto lg:min-h-[200px] lg:flex-[3_1_0%]">
nothing fetched for this clip yet
</div>
)}
+ {stripSide}
+ </div>
+ </div>
+ {phoneMiddle}
+ {phoneSecHead("window", "max-md:order-[50]", "Window, cut, mute and speed", `${hms(sel.from)} – ${hms(sel.to)}`)}
{/* ---- the window, and everything that moves it, in one row ---- */}
- <div className="flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[12px]">
+ <div data-walk-in="window" className={cn("flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[12px]", secBody("window", "max-md:order-[51]"))}>
<span className="num text-[var(--color-meter)]">
{hms(sel.from)} – {hms(sel.to)}{" "}
<span className="text-[var(--color-dim)]">({(sel.to - sel.from).toFixed(2)}s)</span>
@@ -2519,7 +3128,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</button>
)}
</span>
- <span className="micro">
+ <span className="micro max-md:hidden">
<kbd>[</kbd> <kbd>]</kbd> start · <kbd>,</kbd> <kbd>.</kbd> end — each plays the edge
it moved · <kbd>space</kbd> the whole selection · <kbd>R</kbd> reset · <kbd>-</kbd>{" "}
<kbd>=</kbd> speed · <kbd>a</kbd> auto · <kbd>m</kbd> mute from the playhead,{" "}
@@ -2533,8 +3142,10 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
)}
</div>
- {/* ---- the instrument ---- */}
- <div className="relative">
+ {/* ---- the instrument ----
+ On a phone the edge strip is the instrument; this one is still
+ there, folded under Window, for the mute mark. */}
+ <div className={cn("relative", secBody("window", "max-md:order-[52]"))}>
<Waveform
view={view}
sel={sel}
@@ -2592,7 +3203,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
sentence is exactly when you want the seconds it is in, and
dragging to the edge first to be allowed to ask is a ritual. */}
{(atStartEdge || atEndEdge || peekOutside) && (
- <div className="flex flex-wrap items-center gap-2 text-[12px]">
+ <div data-walk-in="window" className={cn("flex flex-wrap items-center gap-2 text-[12px]", secBody("window", "max-md:order-[53]"))}>
{atStartEdge || atEndEdge ? (
<span className="text-[var(--color-dirty)]">
that is the edge of what is cached{cached ? ` (${cached.name})` : ""}
@@ -2655,7 +3266,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
)}
{/* ---- the cue rail, and what is past the cache ---- */}
- <div className="relative h-14 w-full shrink-0 overflow-hidden rounded border border-[var(--color-line)] bg-[var(--color-panel-2)]">
+ <div className={cn("relative h-14 w-full shrink-0 overflow-hidden rounded border border-[var(--color-line)] bg-[var(--color-panel-2)]", secBody("window", "max-md:order-[54]"))}>
{/* The cached span, shaded. The waveform above is exactly this
stretch; everything outside it is text and nothing else. */}
{peek.length > 0 && (
@@ -2791,7 +3402,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
{midSentence && (
<p
data-warn="mid-sentence"
- className="shrink-0 rounded border border-[var(--color-dirty)] bg-[color-mix(in_srgb,var(--color-dirty)_10%,transparent)] px-2 py-1 text-[11px] leading-snug text-[var(--color-dirty)]"
+ className="shrink-0 max-md:order-[32] rounded border border-[var(--color-dirty)] bg-[color-mix(in_srgb,var(--color-dirty)_10%,transparent)] px-2 py-1 text-[11px] leading-snug text-[var(--color-dirty)]"
>
Ends mid-sentence — the cut lands inside “…
{endCue?.text.trim().slice(-56)}”. Run it to the end of the sentence, or set{" "}
@@ -2801,7 +3412,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
{data.noPunctuation && (
<p
data-warn="no-punctuation"
- className="shrink-0 rounded border border-[var(--color-line)] px-2 py-1 text-[11px] leading-snug text-[var(--color-dim)]"
+ className="shrink-0 max-md:order-[32] rounded border border-[var(--color-line)] px-2 py-1 text-[11px] leading-snug text-[var(--color-dim)]"
>
This upload’s ASR carries no punctuation, so there are no sentence boundaries to
find and widening cannot help. Set these edges by ear and lock them.
@@ -2810,7 +3421,8 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
{wouldRevert && (
<p
data-warn="would-revert"
- className="flex flex-wrap items-center gap-2 rounded border border-[var(--color-dirty)] px-2 py-1 text-[11px] leading-snug text-[var(--color-dirty)]"
+ data-walk-in="window"
+ className="max-md:order-[32] flex flex-wrap items-center gap-2 rounded border border-[var(--color-dirty)] px-2 py-1 text-[11px] leading-snug text-[var(--color-dirty)]"
>
<span>
<code className="font-mono">resolve-windows --write</code> would make this{" "}
@@ -2840,7 +3452,11 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
<details
data-rendered-strip=""
onToggle={(e) => setRenderedOpen((e.currentTarget as HTMLDetailsElement).open)}
- className="shrink-0 rounded border border-[var(--color-line)] px-2 py-1 text-[12px] open:max-h-[55vh] open:overflow-y-auto"
+ data-walk-in="window"
+ className={cn(
+ "shrink-0 rounded border border-[var(--color-line)] px-2 py-1 text-[12px] open:max-h-[55vh] open:overflow-y-auto max-md:open:max-h-none",
+ secBody("window", "max-md:order-[55]"),
+ )}
>
<summary className="cursor-pointer text-[11px] text-[var(--color-dim)]">
this clip as rendered{" "}
@@ -2979,7 +3595,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</div>
{/* ============ what this clip IS, and what the header says ============ */}
- <div className="flex min-h-0 flex-col gap-2 overflow-y-auto text-[12px]">
+ <div className="flex min-h-0 flex-col gap-2 overflow-y-auto text-[12px] max-md:contents">
{/* ---- WHAT IT CLAIMS: read, then scrolled past ----
This column is a claim on top and an answer underneath, and the
two have different jobs. The claim is read once per clip; the
@@ -2993,15 +3609,16 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
follows, one level down. */}
<div
data-clip-context=""
- className="flex flex-col gap-2 lg:min-h-[6rem] lg:flex-1 lg:overflow-y-auto"
+ className="flex flex-col gap-2 lg:min-h-[6rem] lg:flex-1 lg:overflow-y-auto max-md:contents"
>
+ {phoneSecHead("about", "max-md:order-[60]", "About this clip", siblings.length ? `${siblings.length} more from this video` : null)}
{/* ---- the description, and the one question ----
A clip is a claim: the report said somebody said this, here. The
walk is somebody checking that claim against the audio, and the
only two answers are "yes" and a note saying what is wrong. */}
<section
data-clip-description=""
- className="space-y-1 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-2 py-1.5"
+ className={cn(secBody("about", "max-md:order-[61]"), "space-y-1 rounded border border-[var(--color-line)] bg-[var(--color-panel)] px-2 py-1.5")}
>
<div className="micro">this clip is supposed to be</div>
<p data-clip-quote="" className="leading-snug text-[var(--color-text)]">
@@ -3020,7 +3637,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
duplicate. */}
<section
data-siblings={siblings.length}
- className="space-y-1 rounded border border-[var(--color-line)] px-2 py-1.5 text-[11px]"
+ className={cn("space-y-1 rounded border border-[var(--color-line)] px-2 py-1.5 text-[11px]", secBody("about", "max-md:order-[62]"))}
>
<div className="micro">also from this video</div>
{siblings.length === 0 ? (
@@ -3069,9 +3686,10 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</div>
{/* ---- THE ANSWER: on screen for every clip, never scrolled to ---- */}
- <div data-clip-answer="" className="flex flex-col gap-2 lg:flex-none">
+ <div data-clip-answer="" className="flex flex-col gap-2 lg:flex-none max-md:contents">
+ {phoneSecHead("attribution", "max-md:order-[80]", "Attribution", previewLine)}
{data.sourceTitle == null && (
- <div className="text-[11px] leading-snug text-[var(--color-dirty)]">
+ <div className={cn("text-[11px] leading-snug text-[var(--color-dirty)]", secBody("attribution", "max-md:order-[81]"))}>
No cue file was found for this source, so the archived record’s own title and
upload date cannot be read here — set <code className="font-mono">title</code> and{" "}
<code className="font-mono">date</code> by hand, or the build will fail before it
@@ -3079,7 +3697,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</div>
)}
- <div className="micro">
+ <div className={cn("micro", secBody("attribution", "max-md:order-[81]"))}>
archive: <span className="text-[var(--color-text)]">{data.sourceTitle || "—"}</span> ·{" "}
<span className="text-[var(--color-text)]">{data.uploadDate || "—"}</span>
</div>
@@ -3087,7 +3705,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
{/* ---- the six fields that decide the header ----
Each field's reason is a tooltip now rather than a paragraph: the
explanations are read once and the boxes are used every clip. */}
- <div className="space-y-1.5">
+ <div data-walk-in="attribution" className={cn("space-y-1.5", secBody("attribution", "max-md:order-[81]"))}>
{ATTRIB.map(([k, label, why]) => {
const changed = draft[k] !== attribValue(clip, k);
return (
@@ -3155,16 +3773,21 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</div>
{/* ---- notes on this clip, for whoever acts on them ---- */}
- <AnchoredNotes notes={notes} pin={{ kind: "entry", entry: clip.id }} startOpen={false} />
+ {phoneNotesHead}
+ <div data-walk-in="notes" className={secBody("notes", "max-md:order-[91]")}>
+ <AnchoredNotes notes={notes} pin={{ kind: "entry", entry: clip.id }} startOpen={false} />
+ </div>
{/* ---- on-screen: what the panel under the footage says ----
Beside the header's fields because it is the same sitting: the
words you hear are the words a title should summarise. Both
save together, on blur or Enter; an empty one is the grey text. */}
+ {phoneSecHead("onscreen", "max-md:order-[70]", "On-screen title", osShown.title || null)}
<div
data-testid="bench-onscreen"
data-deck-on={data.deckOn ? "1" : "0"}
- className="space-y-1 rounded border border-[var(--color-line)] px-2 py-1.5"
+ data-walk-in="onscreen"
+ className={cn("space-y-1 rounded border border-[var(--color-line)] px-2 py-1.5", secBody("onscreen", "max-md:order-[71]"))}
>
<div className="flex flex-wrap items-baseline gap-2">
<span className="micro">on-screen</span>
@@ -3236,7 +3859,7 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
)}
</div>
- <details className="rounded border border-[var(--color-line)] px-2 py-1 text-[11px] text-[var(--color-dim)]">
+ <details className={cn("rounded border border-[var(--color-line)] px-2 py-1 text-[11px] text-[var(--color-dim)]", secBody("attribution", "max-md:order-[82]"))}>
<summary className="cursor-pointer">what these fields are for</summary>
<div className="mt-1 space-y-1 leading-snug">
<p>
@@ -3256,6 +3879,8 @@ export default function ClipBench({ data }: { data: ClipBenchData }) {
</div>
</div>
</div>
+ {phoneDock}
+ {deskBack}
</BenchBody>
);
}
diff --git a/umtool/components/projects/ClipBenchPage.tsx b/umtool/components/projects/ClipBenchPage.tsx
@@ -1,5 +1,5 @@
import { notFound } from "next/navigation";
-import { projectsHref, clipBenchHref } from "@/lib/hrefs";
+import { projectsHref, clipBenchHref, playHref } from "@/lib/hrefs";
import { BenchFrame, BenchTop } from "./bench/BenchShell";
import ClipBench, { type ClipBenchData } from "./ClipBench";
import { manifestToken } from "@/lib/report/manifest.mjs";
@@ -25,9 +25,11 @@ import type { ProjectRef } from "@/lib/project-types";
export default async function ClipBenchPage({
project,
clipId,
+ search = {},
}: {
project: ProjectRef;
clipId: string;
+ search?: Record<string, string | undefined>;
}) {
const manifest = await readManifest(project.dir);
if (!manifest) notFound();
@@ -170,7 +172,27 @@ export default async function ClipBenchPage({
// The piece this view belongs to: the article's when an article claims the project (P4a-2).
const back = await pieceHrefOfProject(project.id, { tab: "cut" });
- const href = (id: string) => clipBenchHref(project.id, id);
+ // ---- opened from Play the cut ("Edit this clip") --------------------------
+ //
+ // `?from=play` rides every walk link from here (p / n / Confirm's advance),
+ // so "Back to the cut" survives walking on; `at` is only ever the clip Play
+ // was on. Back lands on the PROJECT's cut, positioned by clip id plus the
+ // offset into it -- never by raw cut seconds, which the edit just moved for
+ // everything after this clip. A take's render does not change when the
+ // project's manifest does, so a take's Back is the project's cut too, and
+ // the bench says so (`take`).
+ const fromPlay = search.from === "play";
+ const playTake = fromPlay && search.take ? search.take : null;
+ const atRaw = Number(search.at);
+ const at = fromPlay && Number.isFinite(atRaw) && atRaw > 0 ? atRaw : 0;
+ const href = (id: string) => clipBenchHref(project.id, id, fromPlay ? { play: { take: playTake } } : {});
+ data.walkHrefs = {
+ prev: prev ? href(prev) : null,
+ next: next ? href(next) : null,
+ back,
+ backLabel: project.name,
+ };
+ data.fromPlay = fromPlay ? { href: playHref(project.id, { clip: clipId, at }), take: playTake } : null;
return (
// The bench shell (P4b): its top bar here, the body -- the work, the
// verdict bar, the reader -- in ClipBench, which owns their state.
@@ -182,6 +204,9 @@ export default async function ClipBenchPage({
back={{ href: back, label: project.name }}
kind="Clip bench"
here={clipId}
+ // The walk on a phone draws its own place bar (ClipBench).
+ phone="hidden"
+ slot={fromPlay}
pos={{ index: i + 1, total: clips.length }}
prev={prev ? { href: href(prev), label: prev, attrs: { "data-clip-nav": "prev" } } : null}
next={next ? { href: href(next), label: next, attrs: { "data-clip-nav": "next" } } : null}
diff --git a/umtool/components/projects/PlayCutPage.tsx b/umtool/components/projects/PlayCutPage.tsx
@@ -16,7 +16,20 @@ import PlayCut, { type PlayViewData } from "./review/PlayCut";
// notes`), or the video assistant's to answer. lib/report/playView.mjs reads
// what it plays; nothing here fetches, cuts or renders.
-export default async function PlayCutPage({ project, take, note }: { project: ProjectRef; take?: string; note?: string }) {
+export default async function PlayCutPage({
+ project,
+ take,
+ note,
+ clip,
+ at,
+}: {
+ project: ProjectRef;
+ take?: string;
+ note?: string;
+ /** `?clip=<id>&at=<s>`: start on that clip, that far into it (the clip bench's "Back to the cut"). */
+ clip?: string;
+ at?: string;
+}) {
const [view, back] = await Promise.all([playView(project, { take: take || null }), pieceHrefOfProject(project.id, { tab: "cut" })]);
const top = (
<BenchTop
@@ -45,7 +58,11 @@ export default async function PlayCutPage({ project, take, note }: { project: Pr
return (
<BenchFrame kind="play" top={top}>
<NotesProvider target={{ project: project.id }}>
- <PlayCut view={view as PlayViewData} initialNote={note ?? null} />
+ <PlayCut
+ view={view as PlayViewData}
+ initialNote={note ?? null}
+ initialAt={clip ? { clip, at: Number.isFinite(Number(at)) ? Math.max(0, Number(at)) : 0 } : null}
+ />
</NotesProvider>
</BenchFrame>
);
diff --git a/umtool/components/projects/ProjectView.tsx b/umtool/components/projects/ProjectView.tsx
@@ -48,7 +48,7 @@ export default async function ProjectView({
// `/browse/<project>/clip/<id>` -- the bench. A view the kind does not
// declare is a 404 rather than a page that silently drops half its URL.
if (rest.length === 2 && rest[0] === "clip") {
- return <ClipBenchPage project={project} clipId={rest[1]} />;
+ return <ClipBenchPage project={project} clipId={rest[1]} search={search} />;
}
// `/browse/<project>/claim/<id>` -- ruling on one ledger entry against
// the audio, rather than editing a window.
@@ -70,7 +70,7 @@ export default async function ProjectView({
if (rest.length === 1 && rest[0] === "clips") return <ClipDeckPage project={project} show={search.show} mode={search.mode} clip={search.clip} />;
// `/projects/<project>/play` -- the whole cut (or `?take=<id>`) played in
// the browser in its final look, no render, with notes taken as it plays.
- if (rest.length === 1 && rest[0] === "play") return <PlayCutPage project={project} take={search.take} note={search.note} />;
+ if (rest.length === 1 && rest[0] === "play") return <PlayCutPage project={project} take={search.take} note={search.note} clip={search.clip} at={search.at} />;
return notFound();
}
case "sweep-report": {
diff --git a/umtool/components/projects/bench/BenchShell.tsx b/umtool/components/projects/bench/BenchShell.tsx
@@ -18,8 +18,10 @@ import { cn } from "@/lib/utils";
// thread (components/ui/reader-pane.tsx)
//
// Fits 1366×768: the frame is the viewport, only its columns scroll. Below lg
-// it is one scrolling column (a phone cannot hold a bench; pretending would
-// cost the desk).
+// it is one scrolling column. Below md (a phone) the PAGE is that column: the
+// frame stops being a scroller and the document scrolls, so a bench can pin
+// what it is judging (position: sticky needs the viewport as its scroller) and
+// nothing scrolls inside anything (the phone design brief, rule 1).
//
// No hooks and no server imports: a client bench (ClipBench) composes
// BenchBody itself, so its verdict bar and reader can read its own state; a
@@ -43,7 +45,13 @@ export function BenchFrame({
className?: string;
}) {
return (
- <div data-bench-shell={kind} className={cn("flex h-full min-h-0 flex-col overflow-auto lg:overflow-hidden", className)}>
+ <div
+ data-bench-shell={kind}
+ className={cn(
+ "flex h-full min-h-0 flex-col overflow-auto lg:overflow-hidden max-md:h-auto max-md:min-h-full max-md:overflow-visible",
+ className,
+ )}
+ >
{top}
{children}
</div>
@@ -61,6 +69,8 @@ export function BenchTop({
next,
keys = [],
note,
+ phone = "shown",
+ slot = false,
}: {
/** The piece this bench belongs to: "← <its name>". */
back: BenchLink;
@@ -77,12 +87,22 @@ export function BenchTop({
keys?: BenchKey[];
/** The bench's one-line status, the head's last `.micro`. */
note?: React.ReactNode;
+ /** `hidden`: below md the bench draws its own place bar (the clip bench's walk). */
+ phone?: "shown" | "hidden";
+ /**
+ * An empty `[data-bench-top-slot]` before the keys, for a client bench to
+ * portal a control into (the clip bench's "Back to the cut"). Hidden while empty.
+ */
+ slot?: boolean;
}) {
return (
<header
data-app-header="bench"
data-bench-top=""
- className="flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-seam bg-panel px-4 py-2"
+ className={cn(
+ "flex flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-seam bg-panel px-4 py-2",
+ phone === "hidden" && "max-md:hidden",
+ )}
>
<Link href="/" prefetch={false} aria-label="umtool home" className="shrink-0">
<Mark size={18} />
@@ -144,6 +164,7 @@ export function BenchTop({
)}
</span>
)}
+ {slot && <span data-bench-top-slot="" className="flex items-center empty:hidden" />}
{(keys.length > 0 || note) && (
<span className="ml-auto flex flex-wrap items-center gap-x-2.5 gap-y-1">
{keys.length > 0 && (
@@ -171,11 +192,19 @@ export function BenchBody({
reader,
children,
workClassName,
+ phoneFlat = false,
}: {
verdict?: React.ReactNode;
reader?: React.ReactNode;
children: React.ReactNode;
workClassName?: string;
+ /**
+ * Below md, ONE flex column of the bench's leaves: the wrappers between them
+ * and this body are `display: contents`, so the bench orders its pieces for a
+ * phone with `order` and pins one with `sticky` against the whole page (the
+ * clip bench's walk). The desk's boxes are untouched from md up.
+ */
+ phoneFlat?: boolean;
}) {
return (
<div
@@ -183,15 +212,26 @@ export function BenchBody({
className={cn(
"flex min-h-0 flex-1 flex-col lg:grid",
reader ? "lg:grid-cols-[minmax(0,1fr)_minmax(320px,28%)]" : "lg:grid-cols-[minmax(0,1fr)]",
+ // The dock's height plus the safe area under it: the last line clears it.
+ phoneFlat && "max-md:gap-3 max-md:px-4 max-md:pb-[calc(88px+env(safe-area-inset-bottom))]",
)}
>
- <div className="flex min-h-0 min-w-0 flex-col">
- <main data-bench-work="" className={cn("deck-main min-h-0 flex-1 p-4", workClassName)}>
+ <div className={cn("flex min-h-0 min-w-0 flex-col", phoneFlat && "max-md:contents")}>
+ <main data-bench-work="" className={cn("deck-main min-h-0 flex-1 p-4", workClassName, phoneFlat && "max-md:contents")}>
{children}
</main>
{verdict}
</div>
- {reader && <div className="flex min-h-[320px] flex-col border-t border-seam lg:min-h-0 lg:border-t-0">{reader}</div>}
+ {reader && (
+ <div
+ className={cn(
+ "flex min-h-[320px] flex-col border-t border-seam lg:min-h-0 lg:border-t-0",
+ phoneFlat && "max-md:contents",
+ )}
+ >
+ {reader}
+ </div>
+ )}
</div>
);
}
diff --git a/umtool/components/projects/bench/EdgeStrip.tsx b/umtool/components/projects/bench/EdgeStrip.tsx
@@ -0,0 +1,385 @@
+"use client";
+
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import type { Peaks } from "@/components/Waveform";
+import { usePalette } from "@/components/ui/use-palette";
+import { cn } from "@/lib/utils";
+import {
+ SNAP_RADIUS,
+ sentenceBoundaries,
+ snapToBoundary,
+ stepBoundary,
+ wordsAtEdge,
+} from "@/lib/report/sentenceEdges.mjs";
+
+// ---------------------------------------------------------------------------
+// THE EDGE STRIP (the phone walk's signature; the design brief, "Signature:
+// the edge strip with sentence snap").
+//
+// The desk moves an edge with a 10 px handle on a wide waveform and `[ ] , .`;
+// a thumb on a 358 px strip can do neither, and the standing complaint is cuts
+// that land mid-sentence anyway. So here THE SENTENCE IS THE UNIT OF AN EDGE:
+//
+// - the cached window's peaks across the full width, the selection lit in
+// Signal at 10%, every sentence boundary (lib/report/sentenceEdges.mjs,
+// the pre-cut's rule) a full-height seam tick;
+// - each edge a 28 px grab tab that hangs BELOW the waveform, so the thumb
+// holding it does not cover the line it is placing;
+// - a drag snaps to the nearest boundary within SNAP_RADIUS, and the tick it
+// lands on flashes; `Snap | Free` turns that off for an exact cut, and is
+// remembered per browser like the playback speed;
+// - per edge, `‹ sentence` / `sentence ›` step it to the previous / next
+// boundary. A step that would leave the cached window OFFERS the fetch
+// instead of clamping -- a button that silently stops short is the same
+// lie the desk's drag refuses to tell (ClipBench, "A DRAG NEVER DOWNLOADS").
+//
+// It never saves. Like the desk's handles it moves the bench's draft selection
+// through `onSel` -- which auditions the moved edge on release, never during a
+// drag -- and Confirm (or Save) writes it through the one window writer.
+// ---------------------------------------------------------------------------
+
+type Cue = { start: number; end: number; text: string };
+type Edge = "start" | "end";
+
+const SNAP_KEY = "umtool.bench.edgeSnap";
+/** The shortest selection an edge may make: an edge never crosses the other. */
+const MIN_SPAN = 0.2;
+const WAVE_H = 72;
+
+export default function EdgeStrip({
+ view,
+ sel,
+ peaks,
+ cues,
+ playhead,
+ limit,
+ busy,
+ fmt,
+ onSel,
+ onFetch,
+ className,
+}: {
+ /** The cached window, which the waveform spans. */
+ view: { from: number; to: number };
+ sel: { from: number; to: number };
+ peaks: Peaks | null;
+ /** The cues the boundaries are read from: the cached window's and the peek past it. */
+ cues: Cue[];
+ playhead: number | null;
+ /** How far an edge may go without a fetch (the cache, and the recording's own length). */
+ limit: { from: number; to: number };
+ busy: boolean;
+ fmt: (t: number) => string;
+ onSel: (next: { from: number; to: number }, dragging: boolean, edge: Edge) => void;
+ /** Fetch far enough to put `t` inside the cache, on `edge`'s side. */
+ onFetch: (edge: Edge, t: number) => void;
+ className?: string;
+}) {
+ const pal = usePalette();
+ const box = useRef<HTMLDivElement | null>(null);
+ const canvas = useRef<HTMLCanvasElement | null>(null);
+ const [width, setWidth] = useState(358);
+ // Snap on until this browser said otherwise; read after mount, as the
+ // bench's playback preference is, so the first paint matches the server's.
+ const [snap, setSnap] = useState(true);
+ useEffect(() => {
+ try {
+ if (localStorage.getItem(SNAP_KEY) === "free") setSnap(false);
+ } catch {
+ /* a private window: snapping stays on */
+ }
+ }, []);
+ const chooseSnap = (on: boolean) => {
+ setSnap(on);
+ try {
+ localStorage.setItem(SNAP_KEY, on ? "snap" : "free");
+ } catch {
+ /* the choice still holds for this page */
+ }
+ };
+
+ const bounds = useMemo(() => sentenceBoundaries(cues), [cues]);
+ // The boundary an edge last landed on, lit briefly.
+ const [landed, setLanded] = useState<number | null>(null);
+ useEffect(() => {
+ if (landed == null) return;
+ const id = window.setTimeout(() => setLanded(null), 700);
+ return () => window.clearTimeout(id);
+ }, [landed]);
+ // A step that would leave the cache: what to fetch, offered in place.
+ const [offer, setOffer] = useState<{ edge: Edge; t: number } | null>(null);
+ useEffect(() => setOffer(null), [limit.from, limit.to]);
+
+ useEffect(() => {
+ const el = box.current;
+ if (!el) return;
+ const ro = new ResizeObserver(() => setWidth(el.clientWidth || 358));
+ ro.observe(el);
+ setWidth(el.clientWidth || 358);
+ return () => ro.disconnect();
+ }, []);
+
+ const span = Math.max(1e-6, view.to - view.from);
+ const pct = (t: number) => `${((t - view.from) / span) * 100}%`;
+ const inView = (t: number) => t >= view.from - 0.01 && t <= view.to + 0.01;
+
+ // ---- the waveform ----
+ useEffect(() => {
+ const cv = canvas.current;
+ if (!cv) return;
+ const dpr = window.devicePixelRatio || 1;
+ cv.width = Math.max(1, Math.floor(width * dpr));
+ cv.height = Math.floor(WAVE_H * dpr);
+ const g = cv.getContext("2d");
+ if (!g) return;
+ g.setTransform(dpr, 0, 0, dpr, 0, 0);
+ g.clearRect(0, 0, width, WAVE_H);
+ const mid = WAVE_H / 2;
+ const toX = (t: number) => ((t - view.from) / span) * width;
+ if (peaks && peaks.max.length) {
+ const n = peaks.max.length;
+ const pSpan = Math.max(1e-6, peaks.to - peaks.from);
+ for (let i = 0; i < n; i += 1) {
+ const t0 = peaks.from + (i / n) * pSpan;
+ const x = toX(t0);
+ if (x < -2 || x > width + 2) continue;
+ g.fillStyle = t0 >= sel.from && t0 <= sel.to ? pal.text : pal["seam-2"];
+ const y0 = mid - peaks.max[i] * (mid - 4);
+ const y1 = mid - peaks.min[i] * (mid - 4);
+ g.fillRect(x, Math.min(y0, y1), Math.max(1, width / n), Math.max(1, Math.abs(y1 - y0)));
+ }
+ } else {
+ g.fillStyle = pal.seam;
+ g.fillRect(0, mid - 1, width, 2);
+ }
+ }, [peaks, width, view.from, span, sel.from, sel.to, pal]);
+
+ // ---- moving an edge ----
+ const clampEdge = useCallback(
+ (edge: Edge, t: number) =>
+ edge === "start"
+ ? Math.max(limit.from, Math.min(t, sel.to - MIN_SPAN))
+ : Math.min(limit.to, Math.max(t, sel.from + MIN_SPAN)),
+ [limit.from, limit.to, sel.from, sel.to],
+ );
+ const listOf = (edge: Edge) => (edge === "start" ? bounds.starts : bounds.ends);
+
+ // `dx`: how far from the edge line the thumb took hold. The tab sits beside
+ // its line, so without it the edge would jump a tab's width on first move.
+ const drag = useRef<{ edge: Edge; id: number; dx: number } | null>(null);
+ const xOf = (t: number) => {
+ const r = box.current?.getBoundingClientRect();
+ return r ? r.left + ((t - view.from) / span) * r.width : 0;
+ };
+ const tAt = (clientX: number) => {
+ const r = box.current?.getBoundingClientRect();
+ if (!r) return null;
+ const frac = Math.min(1, Math.max(0, (clientX - r.left) / Math.max(1, r.width)));
+ return view.from + frac * span;
+ };
+ /** Where a drag at clientX puts `edge`, snapped when snapping is on. */
+ const place = (edge: Edge, clientX: number) => {
+ const raw = tAt(clientX - (drag.current?.dx ?? 0));
+ if (raw == null) return null;
+ const s = snap ? snapToBoundary(listOf(edge), raw, SNAP_RADIUS) : { t: raw, boundary: null };
+ const t = clampEdge(edge, s.t);
+ return { t, boundary: s.boundary != null && Math.abs(t - s.boundary) < 0.01 ? s.boundary : null };
+ };
+ const move = (edge: Edge, t: number, dragging: boolean) =>
+ onSel(edge === "start" ? { from: t, to: sel.to } : { from: sel.from, to: t }, dragging, edge);
+
+ const tabHandlers = (edge: Edge) => ({
+ onPointerDown: (e: React.PointerEvent<HTMLDivElement>) => {
+ if (busy) return;
+ e.preventDefault();
+ e.currentTarget.setPointerCapture(e.pointerId);
+ drag.current = { edge, id: e.pointerId, dx: e.clientX - xOf(edge === "start" ? sel.from : sel.to) };
+ setOffer(null);
+ },
+ onPointerMove: (e: React.PointerEvent<HTMLDivElement>) => {
+ const d = drag.current;
+ if (!d || d.id !== e.pointerId) return;
+ const p = place(d.edge, e.clientX);
+ if (p) move(d.edge, p.t, true);
+ },
+ onPointerUp: (e: React.PointerEvent<HTMLDivElement>) => {
+ const d = drag.current;
+ if (!d || d.id !== e.pointerId) return;
+ const p = place(d.edge, e.clientX);
+ drag.current = null;
+ if (!p) return;
+ if (p.boundary != null) setLanded(p.boundary);
+ // Release auditions the moved edge (ClipBench's onSel), as on the desk.
+ move(d.edge, p.t, false);
+ },
+ onPointerCancel: () => {
+ drag.current = null;
+ },
+ });
+
+ /** `‹ sentence` / `sentence ›`: the next boundary that way, or the fetch that reaches it. */
+ const stepTarget = (edge: Edge, dir: 1 | -1) => {
+ const cur = edge === "start" ? sel.from : sel.to;
+ const t = stepBoundary(listOf(edge), cur, dir);
+ if (t == null) return null;
+ // Never across the other edge.
+ if (edge === "start" && t > sel.to - MIN_SPAN) return null;
+ if (edge === "end" && t < sel.from + MIN_SPAN) return null;
+ const outside = edge === "start" ? t < limit.from - 0.01 : t > limit.to + 0.01;
+ return { t, outside };
+ };
+ const step = (edge: Edge, dir: 1 | -1) => {
+ const s = stepTarget(edge, dir);
+ if (!s) return;
+ if (s.outside) {
+ setOffer({ edge, t: s.t });
+ return;
+ }
+ setOffer(null);
+ setLanded(s.t);
+ move(edge, s.t, false);
+ };
+
+ const words = { start: wordsAtEdge(cues, sel.from, "start"), end: wordsAtEdge(cues, sel.to, "end") };
+ const stepBtn = "inline-flex h-11 min-w-0 items-center justify-center rounded-[3px] border border-seam-2 px-2 text-[13px] text-text active:bg-panel-2 disabled:opacity-40";
+
+ return (
+ <section
+ data-edge-strip=""
+ data-snap={snap ? "on" : "off"}
+ data-sel={`${sel.from.toFixed(2)}-${sel.to.toFixed(2)}`}
+ aria-label="Edges"
+ className={cn("flex flex-col gap-2", className)}
+ >
+ <div className="flex items-center gap-2">
+ <span className="micro">Edges</span>
+ <span className="num min-w-0 truncate font-mono text-[12px] text-meter">
+ {fmt(sel.from)} – {fmt(sel.to)} <span className="text-muted">({(sel.to - sel.from).toFixed(2)} s)</span>
+ </span>
+ {/* Snap | Free: a visible segmented control, never a long-press. */}
+ <div role="group" aria-label="Edge snapping" className="ml-auto flex shrink-0 rounded-[3px] border border-seam-2 p-0.5 text-[12px]">
+ {([true, false] as const).map((on) => (
+ <button
+ key={String(on)}
+ type="button"
+ data-edge-snap={on ? "snap" : "free"}
+ aria-pressed={snap === on}
+ onClick={() => chooseSnap(on)}
+ className={cn("min-h-9 rounded-[2px] px-2.5", snap === on ? "bg-panel-2 font-medium text-text" : "text-muted-2")}
+ >
+ {on ? "Snap" : "Free"}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {/* The waveform, and the tabs hanging under it. pb is the tabs' reach;
+ mx is a tab's width, so a tab at either end of the cache stays on
+ the page instead of pushing it sideways. */}
+ <div className="relative mx-7 pb-5">
+ <div ref={box} data-edge-wave="" className="relative overflow-hidden rounded-[3px] border border-seam bg-ground" style={{ height: WAVE_H }}>
+ <canvas ref={canvas} className="absolute inset-0 h-full w-full" aria-hidden />
+ <div
+ aria-hidden
+ className="pointer-events-none absolute inset-y-0 bg-[color-mix(in_srgb,var(--signal)_10%,transparent)]"
+ style={{ left: pct(Math.max(view.from, sel.from)), width: `calc(${pct(Math.min(view.to, sel.to))} - ${pct(Math.max(view.from, sel.from))})` }}
+ />
+ {bounds.all.filter(inView).map((t) => (
+ <div
+ key={t}
+ data-boundary={t}
+ data-landed={landed != null && Math.abs(landed - t) < 0.01 ? "" : undefined}
+ aria-hidden
+ className={cn(
+ "pointer-events-none absolute inset-y-0 w-px transition-colors duration-300",
+ landed != null && Math.abs(landed - t) < 0.01 ? "w-[3px] -translate-x-px bg-signal" : "bg-seam-2",
+ )}
+ style={{ left: pct(t) }}
+ />
+ ))}
+ {playhead != null && inView(playhead) && (
+ <div aria-hidden className="pointer-events-none absolute inset-y-0 w-px bg-text" style={{ left: pct(playhead) }} />
+ )}
+ </div>
+ {(["start", "end"] as const).map((edge) => {
+ const t = edge === "start" ? sel.from : sel.to;
+ if (!inView(t)) return null;
+ return (
+ <div
+ key={edge}
+ role="slider"
+ tabIndex={0}
+ aria-label={edge === "start" ? "start edge" : "end edge"}
+ aria-valuemin={limit.from}
+ aria-valuemax={limit.to}
+ aria-valuenow={Number(t.toFixed(2))}
+ aria-valuetext={fmt(t)}
+ data-edge-tab={edge}
+ {...tabHandlers(edge)}
+ className={cn(
+ "absolute top-0 z-10 flex h-full w-7 touch-none select-none flex-col items-center",
+ edge === "start" ? "-translate-x-full" : "",
+ )}
+ style={{ left: pct(t) }}
+ >
+ {/* The edge line over the waveform, then the grab tab under it. */}
+ <span aria-hidden className={cn("w-0.5 bg-signal", edge === "start" ? "self-end" : "self-start")} style={{ height: WAVE_H }} />
+ <span
+ aria-hidden
+ className={cn(
+ "flex h-5 w-7 items-center justify-center bg-signal text-[11px] leading-none text-on-signal",
+ edge === "start" ? "rounded-l-full" : "rounded-r-full",
+ )}
+ >
+ {edge === "start" ? "◖" : "◗"}
+ </span>
+ </div>
+ );
+ })}
+ </div>
+
+ {/* Per edge: the sentence either way. */}
+ {(["start", "end"] as const).map((edge) => {
+ const back = stepTarget(edge, -1);
+ const on = stepTarget(edge, 1);
+ return (
+ <div key={edge} className="grid grid-cols-[1fr_auto_1fr] items-center gap-2" data-edge-row={edge}>
+ <button type="button" data-edge-step={`${edge}-back`} disabled={busy || !back} onClick={() => step(edge, -1)} className={stepBtn}>
+ ‹ sentence
+ </button>
+ <span className="text-center text-[12px] text-muted-2">
+ {edge}
+ <span className="block font-mono text-[11.5px] text-text-2">{fmt(edge === "start" ? sel.from : sel.to)}</span>
+ </span>
+ <button type="button" data-edge-step={`${edge}-on`} disabled={busy || !on} onClick={() => step(edge, 1)} className={stepBtn}>
+ sentence ›
+ </button>
+ </div>
+ );
+ })}
+
+ {offer && (
+ <p data-edge-offer={offer.edge} className="m-0 flex flex-wrap items-center gap-2 text-[12.5px] text-text-2">
+ <span>
+ The {offer.edge === "start" ? "previous" : "next"} sentence {offer.edge === "start" ? "starts" : "ends"} at {fmt(offer.t)}, past what is fetched.
+ </span>
+ <button
+ type="button"
+ data-edge-fetch={offer.edge}
+ disabled={busy}
+ onClick={() => onFetch(offer.edge, offer.t)}
+ className="inline-flex h-11 items-center rounded-[3px] border border-seam-2 px-3 text-[13px] text-text"
+ >
+ Fetch to {fmt(offer.t)}
+ </button>
+ </p>
+ )}
+
+ {/* The words at each edge, in the reader's serif. */}
+ <div data-edge-words="" className="space-y-0.5 font-serif text-[15px] leading-snug text-text-2">
+ {words.start && <p className="m-0" data-edge-words-start="">{words.start}</p>}
+ {words.end && <p className="m-0 text-right" data-edge-words-end="">{words.end}</p>}
+ </div>
+ </section>
+ );
+}
diff --git a/umtool/components/projects/review/AuditionDeck.tsx b/umtool/components/projects/review/AuditionDeck.tsx
@@ -336,10 +336,10 @@ export default function AuditionDeck({
const toggle = (
<div className="flex items-center gap-2 text-[12px]">
- <span data-review-view-current="deck" className={buttonVariants({ variant: "pressed", size: "sm" })} aria-current="page">
+ <span data-review-view-current="deck" className={cn(buttonVariants({ variant: "pressed", size: "sm" }), "max-md:min-h-11 max-md:px-3")} aria-current="page">
Deck
</span>
- <Link href={listHref} prefetch={false} data-review-view="list" className={buttonVariants({ variant: "outline", size: "sm" })}>
+ <Link href={listHref} prefetch={false} data-review-view="list" className={cn(buttonVariants({ variant: "outline", size: "sm" }), "max-md:min-h-11 max-md:px-3")}>
List
</Link>
<span data-deck-count="" className="ml-auto font-mono text-[11.5px] text-muted">
@@ -427,7 +427,8 @@ export default function AuditionDeck({
const peeks = Math.min(3, live.length - 1);
return (
- <main data-deck="" className="deck-main flex min-h-0 flex-1 flex-col p-3 pb-24 sm:p-4 md:pb-4">
+ // On a phone the bar is the dock: the page clears it and the safe area under it.
+ <main data-deck="" className="deck-main flex min-h-0 flex-1 flex-col p-3 pb-24 sm:p-4 md:pb-4 max-md:pb-[calc(6.5rem+env(safe-area-inset-bottom))]">
<div className="mx-auto flex w-full max-w-[520px] flex-col gap-3">
{toggle}
<style>{DECK_CSS}</style>
@@ -538,7 +539,7 @@ export default function AuditionDeck({
onMouseDown={(e) => e.preventDefault()}
onClick={() => setReason(reason === r ? "" : r)}
className={cn(
- "rounded-full border px-2 py-[2px] text-[11.5px]",
+ "rounded-full border px-2 py-[2px] text-[11.5px] max-md:min-h-11 max-md:px-3 max-md:text-[13px]",
reason === r ? "border-muted bg-panel-2 text-text" : "border-seam-2 text-muted-2 hover:text-text",
)}
>
@@ -559,7 +560,7 @@ export default function AuditionDeck({
aria-label="Why cut, in a few words"
data-cut-note=""
maxLength={300}
- className="min-w-[10rem] flex-1 rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[2px] text-[11.5px] text-text outline-none focus:border-signal"
+ className="min-w-[10rem] flex-1 rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[2px] text-[11.5px] text-text outline-none focus:border-signal max-md:min-h-11 max-md:text-[16px]"
/>
</div>
{error && (
@@ -570,7 +571,7 @@ export default function AuditionDeck({
{/* Every gesture is a button too: a bar under the thumb on a phone. */}
<nav
aria-label="Decide"
- className="fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 gap-1.5 border-t border-seam bg-ground p-2 md:static md:z-auto md:border-0 md:bg-transparent md:p-0"
+ className="fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 gap-1.5 border-t border-seam bg-ground p-2 md:static md:z-auto md:border-0 md:bg-transparent md:p-0 max-md:pb-[calc(0.5rem+env(safe-area-inset-bottom))]"
>
<DeckButton action="undo" label="Undo" k="z" disabled={!undos.length || busy} onClick={() => void undo()} />
<DeckButton action="cut" label="Cut" k="←" disabled={busy} onClick={() => decide("left")} />
@@ -600,7 +601,7 @@ function DeckButton({ action, label, k, go = false, disabled, onClick }: { actio
aria-label={`${label} (${k})`}
onMouseDown={(e) => e.preventDefault()}
onClick={onClick}
- className={cn(buttonVariants({ variant: go ? "go" : "outline", size: "lg" }), "flex-col gap-0 px-1 py-2 md:flex-row md:gap-1.5")}
+ className={cn(buttonVariants({ variant: go ? "go" : "outline", size: "lg" }), "flex-col gap-0 px-1 py-2 md:flex-row md:gap-1.5 max-md:min-h-12")}
>
<span>{label}</span>
<kbd className="hidden md:inline">{k}</kbd>
diff --git a/umtool/components/projects/review/ClipDeck.tsx b/umtool/components/projects/review/ClipDeck.tsx
@@ -423,7 +423,7 @@ export default function ClipDeck({
aria-pressed={show === s.show}
onMouseDown={(e) => e.preventDefault()}
onClick={() => walk(s.show)}
- className={buttonVariants({ variant: show === s.show ? "pressed" : "outline", size: "sm" })}
+ className={cn(buttonVariants({ variant: show === s.show ? "pressed" : "outline", size: "sm" }), "max-md:min-h-11 max-md:px-3 max-md:text-[13px]")}
>
{s.label}
</button>
@@ -493,7 +493,8 @@ export default function ClipDeck({
const peeks = Math.min(3, live.length - 1);
const ghostCard = ghost ? byId.get(ghost.id) : null;
return (
- <main data-deck="" data-clip-deck="" className="deck-main flex min-h-0 flex-1 flex-col p-3 pb-24 sm:p-4 md:pb-4">
+ // On a phone the bar is the dock: the page clears it and the safe area under it.
+ <main data-deck="" data-clip-deck="" className="deck-main flex min-h-0 flex-1 flex-col p-3 pb-24 sm:p-4 md:pb-4 max-md:pb-[calc(6.5rem+env(safe-area-inset-bottom))]">
<div className="mx-auto flex w-full max-w-[560px] flex-col gap-3">
{head}
<style>{DECK_CSS}</style>
@@ -592,7 +593,7 @@ export default function ClipDeck({
aria-pressed={reason === r}
onMouseDown={(e) => e.preventDefault()}
onClick={() => setReason(reason === r ? "" : r)}
- className={cn("rounded-full border px-2 py-[2px] text-[11.5px]", reason === r ? "border-muted bg-panel-2 text-text" : "border-seam-2 text-muted-2 hover:text-text")}
+ className={cn("rounded-full border px-2 py-[2px] text-[11.5px] max-md:min-h-11 max-md:px-3 max-md:text-[13px]", reason === r ? "border-muted bg-panel-2 text-text" : "border-seam-2 text-muted-2 hover:text-text")}
>
{r}
</button>
@@ -604,7 +605,7 @@ export default function ClipDeck({
aria-label="Why, in a few words"
data-reason-note=""
maxLength={300}
- className="min-w-[10rem] flex-1 rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[2px] text-[11.5px] text-text outline-none focus:border-signal"
+ className="min-w-[10rem] flex-1 rounded-[3px] border border-seam-2 bg-ground px-1.5 py-[2px] text-[11.5px] text-text outline-none focus:border-signal max-md:min-h-11 max-md:text-[16px]"
/>
</div>
<div className="flex flex-wrap items-center gap-1.5">
@@ -618,7 +619,7 @@ export default function ClipDeck({
</p>
)}
{/* Every gesture is a button too: a bar under the thumb on a phone. */}
- <nav aria-label="Rule" className="fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 gap-1.5 border-t border-seam bg-ground p-2 md:static md:z-auto md:border-0 md:bg-transparent md:p-0">
+ <nav aria-label="Rule" className="fixed inset-x-0 bottom-0 z-30 grid grid-cols-5 gap-1.5 border-t border-seam bg-ground p-2 md:static md:z-auto md:border-0 md:bg-transparent md:p-0 max-md:pb-[calc(0.5rem+env(safe-area-inset-bottom))]">
<DeckButton action="undo" label="Undo" k="z" disabled={!undos.length || busy} onClick={() => void undo()} />
<DeckButton action="cut" label="Cut" k="←" disabled={busy || !writable} onClick={() => decide("left")} />
<DeckButton action="not-him" label="Not him" k="↓" disabled={busy || !writable} onClick={() => decide("down")} />
@@ -646,7 +647,7 @@ function DeckButton({ action, label, k, go = false, disabled, onClick }: { actio
aria-label={`${label} (${k})`}
onMouseDown={(e) => e.preventDefault()}
onClick={onClick}
- className={cn(buttonVariants({ variant: go ? "go" : "outline", size: "lg" }), "flex-col gap-0 px-1 py-2 text-[12.5px] leading-tight md:flex-row md:gap-1.5 md:text-[13px]")}
+ className={cn(buttonVariants({ variant: go ? "go" : "outline", size: "lg" }), "flex-col gap-0 px-1 py-2 text-[12.5px] leading-tight md:flex-row md:gap-1.5 md:text-[13px] max-md:min-h-12")}
>
<span>{label}</span>
<kbd className="hidden md:inline">{k}</kbd>
@@ -663,7 +664,7 @@ function QuietButton({ action, label, k, pressed, disabled, onClick }: { action:
disabled={disabled}
onMouseDown={(e) => e.preventDefault()}
onClick={onClick}
- className={buttonVariants({ variant: pressed ? "pressed" : "quiet", size: "sm" })}
+ className={cn(buttonVariants({ variant: pressed ? "pressed" : "quiet", size: "sm" }), "max-md:min-h-11 max-md:px-3 max-md:text-[13px]")}
>
{label} <kbd className="hidden md:inline">{k}</kbd>
</button>
diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx
@@ -7,7 +7,7 @@ import { buttonVariants } from "@/components/ui/button";
import { useSharedNotes } from "@/components/notes/NotesProvider";
import { NoteThread } from "@/components/notes/NoteThread";
import type { Anchor, CutAsk, Note } from "@/lib/annotations/types";
-import { playHref } from "@/lib/hrefs";
+import { clipBenchHref, playHref } from "@/lib/hrefs";
import { cn } from "@/lib/utils";
import { footageAt } from "@/lib/report/footage-move.mjs";
import { finaleUp, stampAt, tallyAt } from "@/lib/report/liveClock.mjs";
@@ -62,6 +62,20 @@ import ReelStrip, { type StripCounter } from "./ReelStrip";
// for an agent; "Send to the assistant" asks the video assistant (the
// editor's `video-assist`, routed by settings.generation), which replies on
// the note with an Apply -- nothing is written until the operator's click.
+//
+// EDIT THIS CLIP (E, or the button): the clip on screen opens on the clip
+// bench with a way back -- `?from=play&at=<offset into the clip>` -- and the
+// bench's "Back to the cut" lands here as `?clip=<id>&at=<offset>`. By clip id
+// and offset, never by raw cut seconds: the edit just changed this clip's
+// length, which moves every cut second after it. The page is a fresh server
+// render of the manifest (force-dynamic), so the new edges are what plays. A
+// take's Edit goes to the project's manifest too (a take's render does not
+// change), and its Back plays the project's cut; the bench says so.
+//
+// ON A PHONE (the phone design brief): one document, the player pinned at the
+// top -- a strip once the transport has scrolled under it -- the strip, Now
+// and the notes below it, and a dock for note / prev / play / next / edit.
+// Layout only: the engine above does not know which it is in.
// ---------------------------------------------------------------------------
export type PlayEntry = {
@@ -135,6 +149,7 @@ const KEYS: { keys: string; what: string }[] = [
{ keys: "P N", what: "previous / next clip" },
{ keys: "[ ]", what: "previous / next note" },
{ keys: "M", what: "note at the playhead" },
+ { keys: "E", what: "edit this clip on the bench (Back returns here)" },
{ keys: "Alt+T C M F L O", what: "the note's kind, while writing" },
{ keys: "Enter", what: "save the note (Shift+Enter: a new line)" },
{ keys: "Esc", what: "close the note, or this" },
@@ -144,10 +159,22 @@ const KEYS: { keys: string; what: string }[] = [
const APPROXIMATE =
"Approximate: crossfades are hard cuts at their middle, cards and teasers are placeholders, edges are not snapped to silence, the sound is the recording's own, the clock is the estimate's."
+/** The pinned player as a strip, once the transport is under it (a phone). */
+const STRIP_H = 120;
+
/** `mm:ss.s` -- a note's or the playhead's timecode. */
const timecode = (t: number) => `${runningTime(t)}.${Math.floor(((Math.max(0, t) % 1) + 1e-9) * 10)}`;
-export default function PlayCut({ view, initialNote }: { view: PlayViewData; initialNote: string | null }) {
+export default function PlayCut({
+ view,
+ initialNote,
+ initialAt = null,
+}: {
+ view: PlayViewData;
+ initialNote: string | null;
+ /** Start on this clip, `at` seconds into what the page shows of it (`?clip=&at=`). */
+ initialAt?: { clip: string; at: number } | null;
+}) {
const router = useRouter();
const project = view.project;
const take = view.take?.id ?? null;
@@ -335,6 +362,23 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
publish();
}, [plan, enter, publish]);
+ // `?clip=&at=` (back from the clip bench): that clip, that far in -- placed
+ // again when the composed schedule replaces the estimate's, since the two
+ // clocks differ, and let go once the composition has settled.
+ const anchor = useRef(initialAt);
+ useEffect(() => {
+ const a = anchor.current;
+ if (!a) return;
+ const i = plan.items.findIndex((x) => x.id === a.clip);
+ if (i < 0) {
+ anchor.current = null;
+ return;
+ }
+ const it = plan.items[i];
+ seekTo(Math.min(it.from + a.at, Math.max(it.from, it.to - 0.05)));
+ if (composeState !== "composing") anchor.current = null;
+ }, [plan, composeState, seekTo]);
+
useEffect(() => {
eng.current.rate = rate;
for (const v of [vA.current, vB.current]) if (v) v.playbackRate = rate;
@@ -499,6 +543,20 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
seekTo((n.anchor as CutAnchor).t);
}, [initialNote, mine, seekTo]);
+ // ---- edit this clip ----------------------------------------------------------------
+ const editHref = useCallback(() => {
+ const e = eng.current;
+ const it = planRef.current.items[e.cur];
+ if (!it?.clip) return null;
+ return clipBenchHref(project, it.id, { play: { at: Math.round(Math.max(0, e.t - it.from) * 100) / 100, take } });
+ }, [project, take]);
+ const editHere = useCallback(() => {
+ const h = editHref();
+ if (!h) return;
+ setPlaying(false);
+ router.push(h);
+ }, [editHref, router, setPlaying]);
+
// ---- the keys ----------------------------------------------------------------------
const [help, setHelp] = useState(false);
useEffect(() => {
@@ -521,6 +579,7 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
else if (k === "[") stepNote(-1);
else if (k === "]") stepNote(1);
else if (k === "m" || k === "M") noteHere();
+ else if (k === "e" || k === "E") editHere();
else if (k === "?") setHelp((h) => !h);
else return;
ev.preventDefault();
@@ -536,7 +595,7 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
window.removeEventListener("keydown", onKey);
window.removeEventListener("keyup", onUp);
};
- }, [back, help, lPlay, next, prev, skip, stepNote, noteHere, setPlaying]);
+ }, [back, help, lPlay, next, prev, skip, stepNote, noteHere, editHere, setPlaying]);
// ---- what is on screen -------------------------------------------------------------
const t = ui.t;
@@ -591,6 +650,52 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
</div>
) : null;
+ // ---- the phone: the pinned player --------------------------------------------------
+ // Pinned at full width; a strip (the picture left, where it is right) once
+ // the transport has scrolled under it. The strip keeps the full player's
+ // footprint (its margin makes up the difference), so nothing below jumps.
+ const rootRef = useRef<HTMLDivElement | null>(null);
+ const playerRef = useRef<HTMLDivElement | null>(null);
+ const [isPhone, setIsPhone] = useState(false);
+ const [compact, setCompact] = useState(false);
+ const [fullH, setFullH] = useState(0);
+ useEffect(() => {
+ const m = window.matchMedia("(max-width: 767.98px)");
+ const on = () => setIsPhone(m.matches);
+ on();
+ m.addEventListener("change", on);
+ return () => m.removeEventListener("change", on);
+ }, []);
+ useEffect(() => {
+ if (!isPhone) {
+ setCompact(false);
+ return;
+ }
+ let raf = 0;
+ const run = () => {
+ raf = 0;
+ const pl = playerRef.current;
+ const tr = rootRef.current?.querySelector("[data-play-transport]");
+ if (!pl || !tr) return;
+ const full = (window.innerWidth * 9) / 16;
+ setFullH(full);
+ const y = window.scrollY;
+ setCompact(y + full > tr.getBoundingClientRect().top + y + 1);
+ };
+ const on = () => {
+ if (!raf) raf = requestAnimationFrame(run);
+ };
+ run();
+ window.addEventListener("scroll", on, { passive: true });
+ window.addEventListener("resize", on);
+ return () => {
+ cancelAnimationFrame(raf);
+ window.removeEventListener("scroll", on);
+ window.removeEventListener("resize", on);
+ };
+ }, [isPhone]);
+ const dockBtn = cn(buttonVariants({ variant: "outline", size: "md" }), "h-12 min-w-0 px-1 text-[13px]");
+
const footageCanvas = (style: React.CSSProperties | undefined, w: number, h: number) => (
<canvas ref={canvas} data-play-footage="" data-play-move={move ? move.segment : ""} width={w} height={h} className="absolute" style={style} />
);
@@ -598,15 +703,19 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
return (
<div
+ ref={rootRef}
data-play-cut={take ?? ""}
+ // The clip on screen's play window, in source seconds: what an edit on
+ // the bench changes, and what "Back to the cut" must play.
+ data-play-source={item?.clip ? `${item.clip.sourceFrom}-${item.clip.sourceTo}` : ""}
data-play-state={ui.ended ? "ended" : ui.playing ? (ui.waiting ? "waiting" : "playing") : "paused"}
data-play-t={String(Math.round(t * 100) / 100)}
data-play-item={item?.id ?? ""}
data-play-compose={composeState}
- className="flex flex-col min-[900px]:min-h-0 min-[900px]:flex-1 min-[900px]:overflow-hidden"
+ className="flex flex-col min-[900px]:min-h-0 min-[900px]:flex-1 min-[900px]:overflow-hidden max-md:gap-3 max-md:px-4 max-md:pb-[calc(88px+env(safe-area-inset-bottom))]"
>
{/* ---- the head: the cut's title, what plays, the running time ---- */}
- <header className="flex flex-wrap items-center gap-x-4 gap-y-1.5 border-b border-seam px-4 py-2">
+ <header className="flex flex-wrap items-center gap-x-4 gap-y-1.5 border-b border-seam px-4 py-2 max-md:-mx-4">
<h1 className="m-0 min-w-0 truncate font-display text-[17px] font-semibold tracking-[-0.01em] text-text">{view.title}</h1>
<nav aria-label="What plays" className="flex flex-wrap items-center rounded-[3px] border border-seam-2 p-0.5 text-[12px]" data-play-takes="">
{[{ id: null as string | null, label: "The cut", made: true }, ...view.takes].map((tk) => {
@@ -633,21 +742,31 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
</button>
</header>
{view.take && (
- <p className="m-0 border-b border-seam px-4 py-1 text-[11.5px] text-text-2" data-play-take={view.take.id}>
+ <p className="m-0 border-b border-seam px-4 py-1 text-[11.5px] text-text-2 max-md:-mx-4 max-md:-mt-3" data-play-take={view.take.id}>
take “{view.take.label}”: the project’s cut with its patch ({view.take.from}){view.take.made ? "" : " — not rendered yet"}
{view.take.summary ? ` · ${view.take.summary}` : ""}
</p>
)}
- <div className="grid grid-cols-1 min-[900px]:min-h-0 min-[900px]:flex-1 min-[900px]:grid-cols-[minmax(0,1fr)_minmax(300px,380px)]">
- <main className="deck-main min-w-0 space-y-3 p-4 min-[900px]:min-h-0 min-[900px]:overflow-auto">
+ <div className="grid grid-cols-1 min-[900px]:min-h-0 min-[900px]:flex-1 min-[900px]:grid-cols-[minmax(0,1fr)_minmax(300px,380px)] max-md:contents">
+ <main className="deck-main min-w-0 space-y-3 p-4 min-[900px]:min-h-0 min-[900px]:overflow-auto max-md:contents max-md:space-y-0">
{/* ---- the player ----
The two <video>s sit full size UNDER the frame (which is opaque
and drawn from them): an element the browser can see on the
page loads and decodes a paused frame, where a hidden 1 px one
was left at its metadata. They stay put while the frame above
switches from plain to composed. */}
- <div className="relative w-full" style={{ maxWidth: PLAYER_MAX_W }}>
+ <div
+ ref={playerRef}
+ data-play-pin=""
+ data-compact={compact ? "" : undefined}
+ className="relative w-full max-md:sticky max-md:top-0 max-md:z-30 max-md:-mx-4 max-md:w-auto max-md:bg-ground"
+ style={
+ compact
+ ? { maxWidth: PLAYER_MAX_W, width: (STRIP_H * 16) / 9, marginBottom: Math.max(0, fullH - STRIP_H) }
+ : { maxWidth: PLAYER_MAX_W }
+ }
+ >
<div className="pointer-events-none absolute inset-0 overflow-hidden" aria-hidden>
<video ref={vA} data-play-slot="0" preload="auto" playsInline onError={() => onMediaError(0)} className="absolute inset-0 h-full w-full" />
<video ref={vB} data-play-slot="1" preload="auto" playsInline onError={() => onMediaError(1)} className="absolute inset-0 h-full w-full" />
@@ -668,12 +787,22 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
)}
</DeckFrame>
) : (
- <div className="relative w-full overflow-hidden rounded border border-seam bg-black" style={{ aspectRatio: "16 / 9" }} data-testid="play-plain">
+ <div className="relative w-full overflow-hidden rounded border border-seam bg-black max-md:rounded-none max-md:border-0" style={{ aspectRatio: "16 / 9" }} data-testid="play-plain">
{footageCanvas({ inset: 0, width: "100%", height: "100%" }, 1280, 720)}
{placeholderCard}
</div>
)}
</div>
+ {/* The strip's right side (a phone): where you are. */}
+ {compact && (
+ <div data-play-strip-side="" className="absolute left-full top-0 flex h-full w-[calc(100vw-213px)] flex-col justify-center gap-0.5 bg-ground px-3 md:hidden">
+ <span className="truncate font-mono text-[13px] text-text">{item?.id ?? ""}</span>
+ <span className="font-mono text-[12px] text-meter">
+ {runningTime(t)} <span className="text-muted">/ {runningTime(plan.total)}</span>
+ </span>
+ <span className="text-[11.5px] text-muted">{ui.playing ? "playing" : "paused"}</span>
+ </div>
+ )}
</div>
{/* ---- the transport ---- */}
@@ -709,6 +838,23 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
</span>
)}
{ui.waiting && <span className="text-[11.5px] text-muted" data-play-waiting="">loading…</span>}
+ {/* The clip on the bench, and back here after (E). */}
+ <button
+ type="button"
+ data-play-edit=""
+ disabled={!item?.clip}
+ onClick={editHere}
+ className={cn(buttonVariants({ variant: "outline", size: "sm" }))}
+ title={
+ item?.clip
+ ? take
+ ? "edit this clip on the bench (E): the edit goes to the project's cut, not this take's render; Back plays the project's cut"
+ : "edit this clip on the bench (E); Back to the cut returns here"
+ : "a card is not edited on the clip bench"
+ }
+ >
+ Edit this clip
+ </button>
<span className="ml-auto flex flex-wrap items-center gap-x-2 text-[11.5px] text-muted" data-play-hud="">
{tally.length > 0 && <span className="sr-only" data-play-tally={tally.map((r) => `${r.verdict}:${r.count}`).join(",")} />}
{schedule?.factcheck && (
@@ -772,7 +918,7 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
</main>
{/* ---- the notes ---- */}
- <aside className="flex min-h-0 flex-col border-t border-seam bg-panel min-[900px]:border-l min-[900px]:border-t-0" data-play-side="">
+ <aside className="flex min-h-0 flex-col border-t border-seam bg-panel min-[900px]:border-l min-[900px]:border-t-0 max-md:-mx-4" data-play-side="">
<PlayNotes
project={project}
take={take}
@@ -800,6 +946,36 @@ export default function PlayCut({ view, initialNote }: { view: PlayViewData; ini
</aside>
</div>
+ {/* ---- the dock (a phone): note, the clips either side, play, edit ---- */}
+ <nav
+ aria-label="Play"
+ data-play-dock=""
+ className="fixed inset-x-0 bottom-0 z-40 border-t border-seam bg-ground px-3 pb-[calc(8px+env(safe-area-inset-bottom))] pt-2 md:hidden"
+ >
+ <div className="grid grid-cols-[1fr_auto_1.2fr_auto_1fr] gap-1.5">
+ <button type="button" data-play-dock-note="" onClick={noteHere} className={dockBtn}>
+ Note
+ </button>
+ <button type="button" data-play-dock-prev="" onClick={prev} aria-label="previous clip" className={cn(dockBtn, "w-12 text-[18px]")}>
+ ‹
+ </button>
+ <button
+ type="button"
+ data-play-dock-toggle=""
+ onClick={() => setPlaying(!ui.playing)}
+ className={cn(buttonVariants({ variant: "go", size: "md" }), "h-12 min-w-0 px-1 text-[14px]")}
+ >
+ {ui.playing ? "Pause" : "Play"}
+ </button>
+ <button type="button" data-play-dock-next="" onClick={next} aria-label="next clip" className={cn(dockBtn, "w-12 text-[18px]")}>
+ ›
+ </button>
+ <button type="button" data-play-dock-edit="" disabled={!item?.clip} onClick={editHere} className={dockBtn}>
+ Edit clip
+ </button>
+ </div>
+ </nav>
+
{help && (
<div role="dialog" aria-modal="true" aria-label="Keys" className="fixed inset-0 z-50 flex items-center justify-center bg-black/55 p-4" onClick={() => setHelp(false)} data-play-keys="">
<div className="w-full max-w-[420px] rounded-[3px] border border-seam-2 bg-panel p-4 text-[12.5px] text-text-2" onClick={(e) => e.stopPropagation()}>
diff --git a/umtool/e2e/fixtures/make-fixture.mjs b/umtool/e2e/fixtures/make-fixture.mjs
@@ -993,6 +993,23 @@ const WALK = writeProject(
]),
);
+// THE WALK ON A PHONE (phone-walk.spec.ts): its own, and WRITABLE -- the spec
+// confirms p01 and undoes it, and walk-fixture's counts must not move.
+//
+// p01 3.00- 6.00 on vid1, whose sentences end at 3, 9, 12, 15 and 21 (the
+// 3-6 cue runs on): `sentence ›` takes the end to 9.00,
+// `‹ sentence` the start to 0.00, and a drag near 9 snaps
+// p02 12.00-15.00 the walk's next, where Confirm on p01 lands
+//
+// Locked, so neither raises the bench's resolver warnings over the strip.
+const PHONE_WALK = writeProject(
+ "phone-walk-fixture",
+ manifest("phone-walk-fixture", "The Phone Walk Fixture", { siteOrigin: "https://archive.example" }, [
+ { type: "clip", id: "p01", video: "vid1", start: 3.0, end: 6.0, cite: 3, section: 0, lock: true, quote: "and because" },
+ { type: "clip", id: "p02", video: "vid1", start: 12.0, end: 15.0, cite: 12, section: 0, lock: true, quote: "a fourth one" },
+ ]),
+);
+
// -- THE EDITOR-FETCH FIXTURE -------------------------------------------------
//
@@ -1836,6 +1853,9 @@ makeMarksFixture({ reports, manifest, cachedWindow: path.join(REPORT, "out", "cl
makeLivePreviewFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
// The Play view: the whole cut (and a take) played with no render, notes at the playhead (play-cut.spec.ts).
makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4") });
+// The same cut for Play → Edit this clip → Back (phone-walk.spec.ts), which WRITES
+// an edge: its own copy, so play-cut.spec's clock is never moved.
+makePlayCutFixture({ reports, deckManifest, cachedWindow: path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), name: "play-edit-fixture", title: "The Play Edit Fixture" });
// TWO MORE cached windows for vid1, and they are the regression rather than
// decoration.
@@ -1860,6 +1880,11 @@ for (const name of ["vid1_10.00-16.00.mp4", "vid1_14.50-18.50.mp4"]) {
// one. The content is the same nine seconds of tone in all three; what is being
// fixed here is which windows are held, not what is in them.
mkdirSync(path.join(WALK, "out", "clips-raw"), { recursive: true });
+// phone-walk-fixture's: p01 in the first, p02 in the second.
+mkdirSync(path.join(PHONE_WALK, "out", "clips-raw"), { recursive: true });
+for (const name of ["vid1_0.00-9.00.mp4", "vid1_11.50-15.50.mp4"]) {
+ copyFileSync(path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"), path.join(PHONE_WALK, "out", "clips-raw", name));
+}
for (const name of ["vid1_0.00-9.00.mp4", "vid1_11.50-15.50.mp4", "vid1_14.50-18.50.mp4"]) {
copyFileSync(
path.join(REPORT, "out", "clips-raw", "vid1_0.00-9.00.mp4"),
diff --git a/umtool/e2e/fixtures/play-cut-fixture.mjs b/umtool/e2e/fixtures/play-cut-fixture.mjs
@@ -15,10 +15,11 @@ import { copyFileSync, mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
/**
- * @param {{ reports: string, deckManifest: Function, cachedWindow: string }} o
+ * @param {{ reports: string, deckManifest: Function, cachedWindow: string, name?: string, title?: string }} o
+ * `name`: a second copy under another name (play-edit-fixture, which a spec writes to).
*/
-export function makePlayCutFixture({ reports, deckManifest, cachedWindow }) {
- const dir = path.join(reports, "play-cut-fixture");
+export function makePlayCutFixture({ reports, deckManifest, cachedWindow, name = "play-cut-fixture", title = "The Play Cut Fixture" }) {
+ const dir = path.join(reports, name);
mkdirSync(dir, { recursive: true });
const timeline = [
{ type: "clip", id: "c01", video: "vid1", start: 1.0, end: 3.0, cite: 1, section: 0, lock: true, quote: "This is a complete sentence.", onscreen: { title: "24 Oct 2020" } },
@@ -33,7 +34,7 @@ export function makePlayCutFixture({ reports, deckManifest, cachedWindow }) {
claim: { id: "k2", verdict: "CORROBORATED", count: 2 },
},
];
- const m = deckManifest("play-cut-fixture", "The Play Cut Fixture", timeline);
+ const m = deckManifest(name, title, timeline);
m.render.fetchPad = 0;
// One counter, as the Huck cut has: the reel strip's staircase steps 1 at c02, 2 more at c04.
m.render.chrome = { ...m.render.chrome, factcheck: { verdicts: { CORROBORATED: { label: "Seizures", color: "#6fa8dc" } }, stamp: { seconds: 1 } } };
diff --git a/umtool/e2e/phone-walk.spec.ts b/umtool/e2e/phone-walk.spec.ts
@@ -0,0 +1,344 @@
+import { test, expect, type Page } from "@playwright/test";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import * as urls from "./urls";
+
+// ---------------------------------------------------------------------------
+// The walk on a phone (the phone design brief, "The walk" and "Proof"), and
+// Play the cut's Edit this clip → Back to the cut round trip on the desk and
+// on a phone.
+//
+// phone-walk-fixture (WRITABLE, make-fixture.mjs): p01 3.00-6.00 and p02
+// 12.00-15.00 on vid1, whose sentences end at 3, 9, 12, 15 and 21 -- so p01's
+// `sentence ›` takes its end to 9.00 and `‹ sentence` its start to 0.00.
+// play-edit-fixture is play-cut-fixture's cut under its own name, because the
+// round trip writes an edge and play-cut.spec reads the clock.
+// ---------------------------------------------------------------------------
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const FIXTURE = path.join(HERE, "..", ".e2e-song");
+const WALK = "reports/phone-walk-fixture";
+const PLAY = "reports/play-edit-fixture";
+const PHONE = { width: 390, height: 844 };
+const SMALL = { width: 360, height: 740 };
+
+type Entry = { id: string; start: number; end: number; verdict?: string; correction?: string };
+const entryOf = (project: string, id: string): Entry => {
+ const m = JSON.parse(readFileSync(path.join(FIXTURE, ...project.split("/"), "video.manifest.json"), "utf8")) as { timeline: Entry[] };
+ return m.timeline.find((e) => e.id === id)!;
+};
+
+const sel = (page: Page) => page.locator("[data-edge-strip]").getAttribute("data-sel");
+
+/** The walk is hydrated: the strip is drawn and its buttons answer. */
+const walkReady = async (page: Page, clip: string) => {
+ await expect(page.locator(`[data-bench="${clip}"]`)).toHaveCount(1);
+ await expect(page.locator("[data-edge-strip]")).toBeVisible();
+ await expect(page.locator('[data-edge-step="end-on"]')).toBeEnabled();
+};
+
+/**
+ * What is pinned on screen, in px: the union of every sticky or fixed box's
+ * visible part. A box inside another counted one is not counted twice, and a
+ * box translated off the top counts only for what is still on screen.
+ */
+const pinnedPx = (page: Page) =>
+ page.evaluate(() => {
+ const vh = window.innerHeight;
+ const spans: [number, number][] = [];
+ const pinned = [...document.querySelectorAll<HTMLElement>("body *")].filter((el) => {
+ const cs = getComputedStyle(el);
+ if (cs.position !== "sticky" && cs.position !== "fixed") return false;
+ if (cs.display === "none" || cs.visibility === "hidden") return false;
+ const r = el.getBoundingClientRect();
+ return r.height > 2 && r.width > 2;
+ });
+ for (const el of pinned) {
+ if (pinned.some((o) => o !== el && o.contains(el))) continue;
+ // A sticky box only pins once it is stuck; one still in flow is just page.
+ const cs = getComputedStyle(el);
+ const r = el.getBoundingClientRect();
+ if (cs.position === "sticky" && r.top > parseFloat(cs.top || "0") + 1) continue;
+ const a = Math.max(0, r.top);
+ const b = Math.min(vh, r.bottom);
+ if (b > a) spans.push([a, b]);
+ }
+ spans.sort((x, y) => x[0] - y[0]);
+ let total = 0;
+ let end = -1;
+ for (const [a, b] of spans) {
+ if (a > end) {
+ total += b - a;
+ end = b;
+ } else if (b > end) {
+ total += b - end;
+ end = b;
+ }
+ }
+ return Math.round(total);
+ });
+
+const noSideways = async (page: Page) =>
+ expect(await page.evaluate(() => document.documentElement.scrollWidth - window.innerWidth)).toBeLessThanOrEqual(0);
+
+test.beforeEach(() => {
+ test.setTimeout(120_000);
+});
+
+test("the walk at 390: the picture pinned, a strip after 600 px, the dock under the thumb", async ({ page }) => {
+ await page.setViewportSize(PHONE);
+ await page.goto(urls.clipBenchHref(WALK, "p01"));
+ await walkReady(page, "p01");
+ // The desk's head and verdict bar are not drawn; the walk's own are.
+ await expect(page.locator("[data-bench-top]")).toBeHidden();
+ await expect(page.locator("[data-verdict-bar]")).toBeHidden();
+ await expect(page.locator("[data-walk-bar]")).toBeVisible();
+ await expect(page.locator("[data-walk-pos]")).toHaveText("1/2");
+ const dock = page.locator("[data-walk-dock]");
+ await expect(dock).toBeVisible();
+ const d = (await dock.boundingBox())!;
+ expect(d.y + d.height).toBeLessThanOrEqual(PHONE.height + 1);
+ for (const b of ["[data-walk-note]", "[data-walk-play]", "[data-walk-confirm]"]) {
+ expect((await dock.locator(b).boundingBox())!.height).toBeGreaterThanOrEqual(44);
+ }
+ // At rest: the place bar, the 16:9 picture (390 wide) and the dock.
+ const video = page.locator("[data-testid=clip-video]");
+ expect(Math.round((await video.boundingBox())!.height)).toBeGreaterThanOrEqual(215);
+ await page.screenshot({ path: test.info().outputPath("walk-390-top.png") });
+
+ // 600 px down: the quote is under the picture, so the picture is a 120 px
+ // strip; the place bar has gone (it comes back on the way up).
+ await page.evaluate(() => window.scrollTo(0, 600));
+ await expect(page.locator("[data-walk-pin]")).toHaveAttribute("data-compact", "");
+ await expect(page.locator("[data-walk-pin]")).toHaveAttribute("data-bar", "hidden");
+ await expect.poll(async () => Math.round((await video.boundingBox())!.height)).toBe(120);
+ await expect(page.locator("[data-walk-strip-side]")).toContainText("p01");
+ // Pinned while reading: the strip and the dock -- the picture is the
+ // exception the brief makes, and only at its smallest.
+ await expect.poll(() => pinnedPx(page)).toBeLessThanOrEqual(120 + 72 + 4);
+ await page.screenshot({ path: test.info().outputPath("walk-390-scrolled.png") });
+ await page.evaluate(() => window.scrollBy(0, -200));
+ await expect(page.locator("[data-walk-pin]")).toHaveAttribute("data-bar", "shown");
+ await noSideways(page);
+});
+
+test("sentence buttons move an edge to the next boundary; a drag snaps; Snap | Free is remembered", async ({ page }) => {
+ await page.setViewportSize(PHONE);
+ await page.goto(urls.clipBenchHref(WALK, "p01"));
+ await walkReady(page, "p01");
+ expect(await sel(page)).toBe("3.00-6.00");
+ // The boundaries are drawn: vid1's sentences in the 0-9 cache.
+ for (const t of ["0", "3", "9"]) await expect(page.locator(`[data-boundary="${t}"]`)).toHaveCount(1);
+ await expect(page.locator('[data-boundary="6"]')).toHaveCount(0);
+
+ // `sentence ›` on the end: the run-on 3-6 cue's sentence ends at 9.
+ await page.locator('[data-edge-step="end-on"]').click();
+ await expect.poll(() => sel(page)).toBe("3.00-9.00");
+ await expect(page.locator("[data-edge-words-end]")).toHaveText("of that it finishes here.|");
+ // `‹ sentence` on the start: the sentence before starts at 0.
+ await page.locator('[data-edge-step="start-back"]').click();
+ await expect.poll(() => sel(page)).toBe("0.00-9.00");
+ // There is no sentence before 0, nor an end past 9 inside the cache... past
+ // it the next end (12) is OFFERED as a fetch, never clamped to.
+ await expect(page.locator('[data-edge-step="start-back"]')).toBeDisabled();
+ await page.locator('[data-edge-step="end-on"]').click();
+ await expect(page.locator('[data-edge-offer="end"]')).toContainText("past what is fetched");
+ await expect(page.locator('[data-edge-fetch="end"]')).toHaveText(/Fetch to 0:12/);
+ expect(await sel(page)).toBe("0.00-9.00");
+ // Unsaved, and said so under the strip; Reset puts it back.
+ await expect(page.locator("[data-walk-status]")).toContainText("Unsaved");
+ await page.locator("[data-walk-reset]").first().click();
+ await expect.poll(() => sel(page)).toBe("3.00-6.00");
+
+ // A drag: the end tab from 6.0 to 8.7 lands ON 9 (within 0.6 s). From the
+ // top of the page: scrolled, the strip goes under the pinned picture.
+ await page.evaluate(() => window.scrollTo(0, 0));
+ await expect(page.locator("[data-walk-pin]")).not.toHaveAttribute("data-compact", "");
+ const wave = (await page.locator("[data-edge-wave]").boundingBox())!;
+ const xAt = (t: number) => wave.x + (t / 9) * wave.width; // the cache is 0.00-9.00
+ const tab = page.locator('[data-edge-tab="end"]');
+ const tb = (await tab.boundingBox())!;
+ const grabX = tb.x + tb.width / 2;
+ const grabY = tb.y + tb.height - 8;
+ const dx = grabX - xAt(6);
+ await page.mouse.move(grabX, grabY);
+ await page.mouse.down();
+ await page.mouse.move(xAt(7.6) + dx, grabY, { steps: 4 });
+ await page.mouse.move(xAt(8.7) + dx, grabY, { steps: 4 });
+ await page.mouse.up();
+ await expect.poll(() => sel(page)).toBe("3.00-9.00");
+
+ // Free: the same kind of drag stands where it is let go.
+ await page.locator('[data-edge-snap="free"]').click();
+ await expect(page.locator("[data-edge-strip]")).toHaveAttribute("data-snap", "off");
+ const tb2 = (await tab.boundingBox())!;
+ const grab2 = tb2.x + tb2.width / 2;
+ const dx2 = grab2 - xAt(9);
+ await page.mouse.move(grab2, grabY);
+ await page.mouse.down();
+ await page.mouse.move(xAt(7.5) + dx2, grabY, { steps: 6 });
+ await page.mouse.up();
+ await expect.poll(async () => Number(String(await sel(page)).split("-")[1])).toBeGreaterThan(7.3);
+ expect(Number(String(await sel(page)).split("-")[1])).toBeLessThan(7.7);
+ // Remembered per browser, like the playback speed.
+ await page.reload();
+ await walkReady(page, "p01");
+ await expect(page.locator('[data-edge-snap="free"]')).toHaveAttribute("aria-pressed", "true");
+ // Nothing was written: edges are drafts until Confirm or Save.
+ const e = entryOf(WALK, "p01");
+ expect([e.start, e.end]).toEqual([3, 6]);
+});
+
+test("Confirm advances with the moved edges and offers Undo; Undo puts both back", async ({ page }) => {
+ await page.setViewportSize(PHONE);
+ await page.goto(urls.clipBenchHref(WALK, "p01"));
+ await walkReady(page, "p01");
+ await page.locator('[data-edge-step="end-on"]').click();
+ await expect.poll(() => sel(page)).toBe("3.00-9.00");
+ await page.locator("[data-walk-confirm]").click();
+ await expect(page).toHaveURL(new RegExp(`/clip/p02$`), { timeout: 20_000 });
+ const toast = page.locator("[data-walk-toast]");
+ await expect(toast).toContainText("Confirmed p01 — next: p02");
+ let e = entryOf(WALK, "p01");
+ expect(e.verdict).toBe("confirmed");
+ expect(e.end).toBe(9);
+ await page.screenshot({ path: test.info().outputPath("walk-390-toast.png") });
+
+ await toast.locator("[data-walk-undo]").click();
+ await expect(page).toHaveURL(new RegExp(`/clip/p01$`), { timeout: 20_000 });
+ await walkReady(page, "p01");
+ await expect(page.locator("[data-walk-verdict]")).toHaveAttribute("data-walk-verdict", "unreviewed");
+ e = entryOf(WALK, "p01");
+ expect(e.verdict).toBeUndefined();
+ expect([e.start, e.end]).toEqual([3, 6]);
+});
+
+test("Note what's wrong is a sheet with the keyboard up; saving it marks the clip incorrect and stays", async ({ page, request }) => {
+ await page.setViewportSize(PHONE);
+ await page.goto(urls.clipBenchHref(WALK, "p02"));
+ await walkReady(page, "p02");
+ await page.locator("[data-walk-note]").click();
+ const field = page.locator("[data-walk-note-field]");
+ await expect(field).toBeFocused();
+ await field.fill("the speaker is the co-host");
+ await page.locator("[data-walk-note-save]").click();
+ await expect(page.locator("[data-walk-sheet]")).toHaveCount(0);
+ await expect(page.locator("[data-walk-verdict]")).toHaveAttribute("data-walk-verdict", "incorrect");
+ await expect.poll(() => entryOf(WALK, "p02").verdict).toBe("incorrect");
+ expect(entryOf(WALK, "p02").correction).toBe("the speaker is the co-host");
+ await expect(page).toHaveURL(new RegExp(`/clip/p02$`));
+ // Put it back for whatever runs next.
+ const { token } = (await (await request.get(`/api/report/clip?project=${encodeURIComponent(WALK)}&clip=p02`)).json()) as { token: string };
+ const r = await request.put("/api/report/window", { data: { project: WALK, clip: "p02", token, correction: "", verdict: "" } });
+ expect(r.ok()).toBe(true);
+});
+
+test("no sideways scroll at 360: the walk (every section open), Play the cut, the decks", async ({ page }) => {
+ await page.setViewportSize(SMALL);
+ await page.goto(urls.clipBenchHref(WALK, "p01"));
+ await walkReady(page, "p01");
+ await noSideways(page);
+ for (const sec of await page.locator("[data-walk-sec]").all()) await sec.click();
+ await expect(page.locator('[data-walk-sec][aria-expanded="false"]')).toHaveCount(0);
+ await noSideways(page);
+ await page.screenshot({ path: test.info().outputPath("walk-360-open.png"), fullPage: true });
+
+ await page.goto(urls.playHref("reports/play-cut-fixture"));
+ await expect(page.locator("[data-play-cut]")).toHaveAttribute("data-play-state", "paused");
+ await expect(page.locator("[data-play-dock]")).toBeVisible();
+ await noSideways(page);
+ await page.evaluate(() => window.scrollTo(0, 500));
+ await expect(page.locator("[data-play-pin]")).toHaveAttribute("data-compact", "");
+ await noSideways(page);
+
+ await page.goto(urls.clipDeckHref("reports/clip-deck-fixture", { show: "all" }));
+ await expect(page.locator("[data-card-top]")).toBeVisible();
+ await noSideways(page);
+ await page.goto(urls.reviewHref("reports/review-player-fixture"));
+ await expect(page.locator("[data-deck]").first()).toBeVisible();
+ await noSideways(page);
+});
+
+test("Play → Edit this clip → move an edge → Back: the new bounds are what plays (desk)", async ({ page }) => {
+ await page.setViewportSize({ width: 1366, height: 900 });
+ await page.goto(urls.playHref(PLAY));
+ const root = page.locator("[data-play-cut]");
+ await expect(root).toHaveAttribute("data-play-state", "paused");
+ // c02 (3.5-5.5), from its first shown second.
+ await page.locator('[data-play-row="c02"]').press("Enter");
+ await expect(root).toHaveAttribute("data-play-item", "c02");
+ await expect(root).toHaveAttribute("data-play-source", "3.5-5.5");
+ await page.locator("[data-play-edit]").click();
+ await expect(page).toHaveURL(/\/clip\/c02\?from=play/, { timeout: 20_000 });
+ const back = page.locator("[data-back-to-play]");
+ await expect(back).toHaveText("‹ Back to the cut");
+ // `{` is the start a half second earlier (the button is portalled in by an
+ // effect, so the keys are live once it shows); Back saves it first, and says so.
+ await page.locator("body").press("Shift+BracketLeft");
+ await expect(back).toHaveText("Save and back to the cut");
+ await back.click();
+ await expect(page).toHaveURL(/\/play\?clip=c02/, { timeout: 20_000 });
+ await expect(root).toHaveAttribute("data-play-item", "c02");
+ expect(entryOf(PLAY, "c02").start).toBe(3);
+ await expect(root).toHaveAttribute("data-play-source", "3-5.5");
+ // Placed by clip id: on c02's first shown second of the re-read cut.
+ await page.locator("[data-play-toggle]").click();
+ await expect(root).toHaveAttribute("data-play-item", "c02");
+ await page.keyboard.press("k");
+
+ // A take: the edit goes to the project's cut, and the bench says so; Back
+ // plays the PROJECT's cut (the take's render does not change).
+ await page.goto(urls.playHref(PLAY, { take: "short" }));
+ await expect(root).toHaveAttribute("data-play-item", "c04");
+ // E (the key is live once hydrated, which the first render cannot show).
+ await expect(async () => {
+ await page.keyboard.press("e");
+ await expect(page).toHaveURL(/\/clip\/c04\?from=play.*take=short/, { timeout: 1500 });
+ }).toPass({ timeout: 15_000 });
+ await expect(page.locator('[data-back-take="short"]')).toContainText("not take short");
+ await page.locator("[data-back-to-play]").click();
+ await expect(page).toHaveURL(/\/play\?clip=c04$/, { timeout: 20_000 });
+ await expect(root).toHaveAttribute("data-play-cut", "");
+ await expect(root).toHaveAttribute("data-play-item", "c04");
+});
+
+test("Play → Edit this clip → move an edge → Back: the new bounds are what plays (phone)", async ({ page }) => {
+ await page.setViewportSize(PHONE);
+ await page.goto(urls.playHref(PLAY));
+ const root = page.locator("[data-play-cut]");
+ await expect(root).toHaveAttribute("data-play-state", "paused");
+ await expect(root).toHaveAttribute("data-play-item", "c01");
+ const before = entryOf(PLAY, "c01");
+ await expect(root).toHaveAttribute("data-play-source", `${before.start}-${before.end}`);
+ await page.locator("[data-play-dock-edit]").click();
+ await expect(page).toHaveURL(/\/clip\/c01\?from=play/, { timeout: 20_000 });
+ await walkReady(page, "c01");
+ // c01 ends on a sentence at 3; the next one ends at 9.
+ await page.locator('[data-edge-step="end-on"]').click();
+ await expect.poll(() => sel(page)).toBe(`${before.start.toFixed(2)}-9.00`);
+ const back = page.locator("[data-walk-back-play]");
+ await expect(back).toHaveText("Save, back to the cut");
+ await back.click();
+ await expect(page).toHaveURL(/\/play\?clip=c01/, { timeout: 20_000 });
+ await expect(root).toHaveAttribute("data-play-item", "c01");
+ expect(entryOf(PLAY, "c01").end).toBe(9);
+ await expect(root).toHaveAttribute("data-play-source", `${before.start}-9`);
+ await page.screenshot({ path: test.info().outputPath("play-390-back.png") });
+});
+
+test("how it looks at 390: Play the cut and the two decks", async ({ page }) => {
+ await page.setViewportSize(PHONE);
+ await page.goto(urls.playHref("reports/play-cut-fixture"));
+ await expect(page.locator("[data-play-cut]")).toHaveAttribute("data-play-state", "paused");
+ await page.screenshot({ path: test.info().outputPath("play-390-top.png") });
+ await page.evaluate(() => window.scrollTo(0, 500));
+ await expect(page.locator("[data-play-pin]")).toHaveAttribute("data-compact", "");
+ await page.screenshot({ path: test.info().outputPath("play-390-scrolled.png") });
+ await page.goto(urls.clipDeckHref("reports/clip-deck-fixture", { show: "all" }));
+ await expect(page.locator("[data-card-top]")).toBeVisible();
+ await page.screenshot({ path: test.info().outputPath("deck-390.png") });
+ await page.goto(urls.reviewHref("reports/review-player-fixture"));
+ await expect(page.locator("[data-deck]").first()).toBeVisible();
+ await page.screenshot({ path: test.info().outputPath("audition-390.png") });
+});
diff --git a/umtool/lib/hrefs.test.mjs b/umtool/lib/hrefs.test.mjs
@@ -118,3 +118,16 @@ test("Create and Settings (P5)", () => {
assert.equal(H.generationPolicyHref(), "/settings/generation");
assert.equal(H.settingsHref(), "/settings");
});
+
+test("Play the cut ↔ the clip bench: Edit this clip carries the way back, Back lands by clip and offset", () => {
+ // Edit this clip: `from=play`, the offset into the clip, the take that was playing.
+ assert.equal(H.clipBenchHref("a/b", "c02", { play: { at: 1.234 } }), "/projects/a/b/clip/c02?from=play&at=1.23");
+ assert.equal(H.clipBenchHref("a/b", "c02", { play: { at: 0, take: "short" } }), "/projects/a/b/clip/c02?from=play&take=short");
+ assert.equal(H.clipBenchHref("a/b", "c02", { play: null, note: "n" }), "/projects/a/b/clip/c02?note=n");
+ // Back: the project's cut at the clip; an offset of 0 is the clip's start, said by leaving it out.
+ assert.equal(H.playHref("a/b", { clip: "c02", at: 0.5 }), "/projects/a/b/play?clip=c02&at=0.50");
+ assert.equal(H.playHref("a/b", { clip: "c02", at: 0 }), "/projects/a/b/play?clip=c02");
+ // No clip, no offset: `at` means nothing on its own.
+ assert.equal(H.playHref("a/b", { at: 3 }), "/projects/a/b/play");
+ assert.equal(H.playHref("a/b", { take: "t1", note: "n" }), "/projects/a/b/play?take=t1¬e=n");
+});
diff --git a/umtool/lib/hrefs.ts b/umtool/lib/hrefs.ts
@@ -265,8 +265,25 @@ export function projectAtHref(id: string, q: NoteOpt = {}): string {
}
/** The clip bench, one timeline entry. */
-export function clipBenchHref(project: string, clip: string, q: NoteOpt = {}): string {
- return withQuery(`/projects/${encodePath(project)}/clip/${encodeURIComponent(clip)}`, {}, q.note);
+export function clipBenchHref(
+ project: string,
+ clip: string,
+ q: NoteOpt & {
+ /**
+ * Opened from Play the cut ("Edit this clip"): the bench offers "Back to
+ * the cut", landing `at` seconds into this clip. `take` is the take that
+ * was playing -- said on the bench, because the edit goes to the
+ * project's manifest and not to the take's render.
+ */
+ play?: { at?: number | null; take?: string | null } | null;
+ } = {},
+): string {
+ const play = q.play;
+ return withQuery(
+ `/projects/${encodePath(project)}/clip/${encodeURIComponent(clip)}`,
+ play ? { from: "play", at: play.at != null && play.at > 0 ? play.at.toFixed(2) : null, take: play.take ?? null } : {},
+ q.note,
+ );
}
/** The claim bench, one ledger entry. */
@@ -302,8 +319,20 @@ export function clipEditorHref(project: string, q: NoteOpt & { clip?: string; mo
* in its final look, no render; `take` plays that take (the project's
* manifest with its patches).
*/
-export function playHref(project: string, q: NoteOpt & { take?: string | null } = {}): string {
- return withQuery(`/projects/${encodePath(project)}/play`, q.take ? { take: q.take } : {}, q.note);
+export function playHref(
+ project: string,
+ q: NoteOpt & {
+ take?: string | null;
+ /** Start on this clip, `at` seconds into what the page shows of it (the bench's Back to the cut). */
+ clip?: string | null;
+ at?: number | null;
+ } = {},
+): string {
+ return withQuery(
+ `/projects/${encodePath(project)}/play`,
+ { take: q.take, clip: q.clip, at: q.clip && q.at != null && q.at > 0 ? q.at.toFixed(2) : null },
+ q.note,
+ );
}
/** The narration script, card by card. */
diff --git a/umtool/lib/report/sentenceEdges.mjs b/umtool/lib/report/sentenceEdges.mjs
@@ -0,0 +1,152 @@
+// THE SENTENCE AS THE UNIT OF AN EDGE (the phone walk's edge strip).
+//
+// The operator's standing complaint is cuts that land mid-sentence, and on a
+// phone a 10 px handle on a 300 px waveform cannot fix that. So an edge moves
+// by SENTENCE: `‹ sentence` / `sentence ›` step it to the previous or next
+// boundary, and a drag snaps to the nearest one within SNAP_RADIUS.
+//
+// THE RULE IS THE PRE-CUT'S (the job dir's precut.py, which re-cut the Huck
+// walk's unruled clips), ported rather than re-imagined -- its one addition is
+// the curly closing quotes a transcript sometimes carries -- so the
+// strip and the pass that already re-cut a whole cut agree on where a sentence
+// ends:
+//
+// a cue ENDS a sentence when its text ends in . ? ! (closing quotes or
+// brackets allowed after it), or the next cue starts
+// SENTENCE_GAP seconds or more after it ends;
+// a cue STARTS a sentence when it is the first, or the cue before it ends one
+// by the same two tests.
+//
+// A start edge lands on a sentence START (a cue's start), an end edge on a
+// sentence END (a cue's end). On a contiguous transcript the two are the same
+// second; across a pause they are not, and an end placed at the next start
+// would carry the silence into the clip.
+//
+// Pure: no DOM, no React. Absolute source seconds throughout, like the bench.
+
+/** A pause this long between two cues is a sentence boundary, punctuation or not. */
+export const SENTENCE_GAP = 1.5;
+
+/** A dragged edge snaps to a boundary this close (seconds). */
+export const SNAP_RADIUS = 0.6;
+
+/** Two boundaries closer than this are one (a cue's end and the next one's start). */
+const SAME = 0.05;
+
+const TERMINAL = /[.?!]["')\]”’]*\s*$/;
+
+/** Does this text close a sentence by its punctuation? */
+export function endsWithTerminal(text) {
+ return TERMINAL.test(String(text ?? ""));
+}
+
+const fin = (v) => typeof v === "number" && Number.isFinite(v);
+
+/**
+ * @typedef {{ start: number, end: number, text: string }} Cue
+ * @param {Cue | undefined} c
+ * @param {Cue | undefined | null} next
+ */
+export function endsSentence(c, next) {
+ if (!c) return false;
+ return endsWithTerminal(c.text) || (!!next && next.start - c.end >= SENTENCE_GAP);
+}
+
+/**
+ * @param {Cue | undefined} c
+ * @param {Cue | undefined | null} prev
+ */
+export function startsSentence(c, prev) {
+ if (!c) return false;
+ return !prev || endsWithTerminal(prev.text) || c.start - prev.end >= SENTENCE_GAP;
+}
+
+/**
+ * Every sentence boundary in a run of cues, as source seconds, ascending.
+ *
+ * `starts` is where a start edge may land, `ends` where an end edge may;
+ * `all` is both, merged where they coincide -- what the strip draws as ticks.
+ *
+ * @param {Cue[]} cues
+ * @returns {{ starts: number[], ends: number[], all: number[] }}
+ */
+export function sentenceBoundaries(cues) {
+ const cs = (cues ?? []).filter((c) => c && fin(c.start) && fin(c.end)).slice().sort((a, b) => a.start - b.start);
+ const starts = [];
+ const ends = [];
+ for (let i = 0; i < cs.length; i += 1) {
+ if (startsSentence(cs[i], cs[i - 1] ?? null)) starts.push(cs[i].start);
+ if (endsSentence(cs[i], cs[i + 1] ?? null)) ends.push(cs[i].end);
+ }
+ const all = [];
+ for (const t of [...starts, ...ends].sort((a, b) => a - b)) {
+ if (!all.length || t - all[all.length - 1] > SAME) all.push(t);
+ }
+ return { starts: dedupe(starts), ends: dedupe(ends), all };
+}
+
+function dedupe(list) {
+ const out = [];
+ for (const t of list) if (!out.length || t - out[out.length - 1] > SAME) out.push(t);
+ return out;
+}
+
+/**
+ * The next boundary strictly past `t` in direction `dir` (+1 later, -1
+ * earlier), or null when there is none. "Strictly": an edge already ON a
+ * boundary steps to the next one, not to itself.
+ *
+ * @param {number[]} list ascending
+ * @param {number} t
+ * @param {1 | -1} dir
+ */
+export function stepBoundary(list, t, dir) {
+ if (!fin(t)) return null;
+ if (dir > 0) return list.find((b) => b > t + SAME) ?? null;
+ for (let i = list.length - 1; i >= 0; i -= 1) if (list[i] < t - SAME) return list[i];
+ return null;
+}
+
+/**
+ * Snap `t` to the nearest boundary within `radius`. Returns the second it
+ * lands on and which boundary that is (null when nothing is close enough, and
+ * `t` stands).
+ *
+ * @param {number[]} list
+ * @param {number} t
+ * @param {number} [radius]
+ * @returns {{ t: number, boundary: number | null }}
+ */
+export function snapToBoundary(list, t, radius = SNAP_RADIUS) {
+ let best = null;
+ for (const b of list) if (Math.abs(b - t) <= radius && (best === null || Math.abs(b - t) < Math.abs(best - t))) best = b;
+ return best === null ? { t, boundary: null } : { t: best, boundary: best };
+}
+
+/**
+ * The words either side of an edge, for the line under the strip: the end of
+ * what plays before an end edge (`…can live on no matter what.|`), the start
+ * of what plays after a start edge (`|And this one runs on…`). The cue the
+ * edge is in, or the nearest one on the playing side.
+ *
+ * @param {Cue[]} cues
+ * @param {number} t
+ * @param {"start" | "end"} edge
+ * @param {number} [words] how many words to show
+ */
+export function wordsAtEdge(cues, t, edge, words = 7) {
+ const cs = (cues ?? []).filter((c) => c && fin(c.start) && fin(c.end)).slice().sort((a, b) => a.start - b.start);
+ if (!cs.length || !fin(t)) return "";
+ if (edge === "end") {
+ // The last cue that starts before the edge: what you hear last.
+ const c = [...cs].reverse().find((x) => x.start < t - SAME / 2);
+ if (!c) return "";
+ const w = String(c.text).trim().split(/\s+/);
+ return `${w.length > words ? "…" : ""}${w.slice(-words).join(" ")}|`;
+ }
+ // The first cue that ends after the edge: what you hear first.
+ const c = cs.find((x) => x.end > t + SAME / 2);
+ if (!c) return "";
+ const w = String(c.text).trim().split(/\s+/);
+ return `|${w.slice(0, words).join(" ")}${w.length > words ? "…" : ""}`;
+}
diff --git a/umtool/lib/report/sentenceEdges.test.mjs b/umtool/lib/report/sentenceEdges.test.mjs
@@ -0,0 +1,98 @@
+// The sentence boundaries the phone walk's edge strip steps and snaps to
+// (sentenceEdges.mjs): the pre-cut's rule -- . ? ! (closing quotes allowed),
+// or a pause of SENTENCE_GAP -- the starts and ends kept apart across a pause,
+// stepping strictly past an edge, snapping within the radius, and the words
+// shown under the strip.
+//
+// Run with: node --test lib/report/sentenceEdges.test.mjs
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import {
+ SENTENCE_GAP, SNAP_RADIUS, endsSentence, endsWithTerminal, sentenceBoundaries, snapToBoundary, startsSentence,
+ stepBoundary, wordsAtEdge,
+} from "./sentenceEdges.mjs";
+
+// The e2e fixture's vid1 (e2e/fixtures/make-fixture.mjs), which the phone
+// walk spec steps through: 0-3, 9, 12, 15 close sentences; 3-6 and 15-18 run on.
+const VID1 = [
+ [0, 3, "This is a complete sentence."],
+ [3, 6, "And this one runs on and because"],
+ [6, 9, "of that it finishes here."],
+ [9, 12, "Another whole sentence entirely."],
+ [12, 15, "A fourth one, done."],
+ [15, 18, "trailing off and then"],
+ [18, 21, "it lands at last."],
+].map(([start, end, text]) => ({ start, end, text }));
+
+test("terminal punctuation, with closing quotes and brackets after it", () => {
+ for (const t of ["done.", "really?", "stop!", 'he said "no."', "(as he put it.)", "it’s over.’", "end. "]) assert.equal(endsWithTerminal(t), true, t);
+ for (const t of ["and because", "e.g. the", "3.5 seconds", "", "comma,"]) assert.equal(endsWithTerminal(t), false, t);
+});
+
+test("a pause of SENTENCE_GAP or more is a boundary with no punctuation at all", () => {
+ const a = { start: 0, end: 2, text: "no full stop here" };
+ const near = { start: 2 + SENTENCE_GAP - 0.01, end: 5, text: "x" };
+ const far = { start: 2 + SENTENCE_GAP, end: 5, text: "x" };
+ assert.equal(endsSentence(a, near), false);
+ assert.equal(endsSentence(a, far), true);
+ assert.equal(startsSentence(far, a), true);
+ assert.equal(startsSentence(near, a), false);
+ // The first cue starts one; the last ends one only by its punctuation.
+ assert.equal(startsSentence(a, null), true);
+ assert.equal(endsSentence(a, null), false);
+});
+
+test("vid1's boundaries: starts and ends coincide on a contiguous transcript", () => {
+ const b = sentenceBoundaries(VID1);
+ assert.deepEqual(b.starts, [0, 3, 9, 12, 15]);
+ assert.deepEqual(b.ends, [3, 9, 12, 15, 21]);
+ assert.deepEqual(b.all, [0, 3, 9, 12, 15, 21]);
+});
+
+test("across a pause the end is the cue's end and the start the next cue's start", () => {
+ const cues = [
+ { start: 0, end: 2, text: "one thought" },
+ { start: 4, end: 6, text: "another one" },
+ ];
+ const b = sentenceBoundaries(cues);
+ assert.deepEqual(b.ends, [2]);
+ assert.deepEqual(b.starts, [0, 4]);
+ assert.deepEqual(b.all, [0, 2, 4]);
+});
+
+test("unsorted cues and junk rows are tolerated", () => {
+ const b = sentenceBoundaries([VID1[3], null, VID1[2], { start: "x", end: 1, text: "y" }, VID1[1]]);
+ assert.deepEqual(b.ends, [9, 12]);
+});
+
+test("stepping moves strictly past an edge already on a boundary", () => {
+ const { starts, ends } = sentenceBoundaries(VID1);
+ // The phone walk spec's clip: 3.00-6.00.
+ assert.equal(stepBoundary(ends, 6, 1), 9);
+ assert.equal(stepBoundary(ends, 6, -1), 3);
+ assert.equal(stepBoundary(starts, 3, -1), 0);
+ assert.equal(stepBoundary(starts, 3, 1), 9);
+ assert.equal(stepBoundary(ends, 9, 1), 12);
+ assert.equal(stepBoundary(ends, 21, 1), null);
+ assert.equal(stepBoundary(starts, 0, -1), null);
+ assert.equal(stepBoundary(starts, Number.NaN, 1), null);
+});
+
+test("a drag snaps to the nearest boundary within the radius, else stands", () => {
+ const { ends } = sentenceBoundaries(VID1);
+ assert.deepEqual(snapToBoundary(ends, 8.6), { t: 9, boundary: 9 });
+ assert.deepEqual(snapToBoundary(ends, 9 + SNAP_RADIUS), { t: 9, boundary: 9 });
+ assert.deepEqual(snapToBoundary(ends, 7.5), { t: 7.5, boundary: null });
+ // Nearest wins when two are in reach.
+ assert.deepEqual(snapToBoundary([1, 1.8], 1.5, 0.6), { t: 1.8, boundary: 1.8 });
+});
+
+test("the words either side of an edge", () => {
+ assert.equal(wordsAtEdge(VID1, 9, "end"), "of that it finishes here.|");
+ assert.equal(wordsAtEdge(VID1, 9, "end", 3), "…it finishes here.|");
+ assert.equal(wordsAtEdge(VID1, 3, "start"), "|And this one runs on and because");
+ assert.equal(wordsAtEdge(VID1, 3, "start", 3), "|And this one…");
+ assert.equal(wordsAtEdge(VID1, 0, "end"), "");
+ assert.equal(wordsAtEdge([], 3, "start"), "");
+});