Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 2b5d6a2b3c22528073928539005d233da15f84d9
parent 8529adbcc7b27f48f7c0757420ce1303d88d0a8d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 22 Oct 2026 10:10:17 -0400

on-screen: a Markers editor (after a clip, label, colour, align; add, remove, re-order; up to 12) and the marker layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Aumtool/components/projects/MarkersEditor.tsx | 188+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/projects/OnscreenSection.tsx | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 245 insertions(+), 4 deletions(-)

diff --git a/umtool/components/projects/MarkersEditor.tsx b/umtool/components/projects/MarkersEditor.tsx @@ -0,0 +1,188 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { buttonVariants } from "@/components/ui/button"; + +// THE DECK'S MARKERS (video knobs, plans/video-knobs-ui.md): the flags on the +// pip track, `render.chrome.deck.markers` -- each after a clip (a picker of the +// cut's clips), a label of at most 24 characters, a colour (a palette key or +// #hex), an alignment -- at most 12, added, removed and re-ordered here; and +// `deck.markerLayout`, what the deck does when labels crowd: stagger them on a +// second row, or truncate. One save writes the list and the layout and nothing +// else of the deck (PUT /api/report/chrome { markers, markerLayout }), the +// writer `umtool look deck.markers=…` uses. + +export type Marker = { after: string; label: string; color?: string; align?: string }; +type Row = { after: string; label: string; color: string; align: string }; + +export const MARKER_MAX = 12; +export const MARKER_LABEL_MAX = 24; +const PALETTE = ["amber", "accent", "fg", "muted", "dim"]; + +const input = + "rounded border border-[var(--color-line)] bg-[var(--color-ink)] px-1.5 py-0.5 text-[11px] text-[var(--color-text)] outline-none focus:border-[var(--color-sel)]"; + +const rowOf = (m: Marker): Row => ({ after: m.after, label: m.label, color: m.color ?? "", align: m.align ?? "auto" }); +const markerOf = (r: Row): Marker => ({ + after: r.after, + label: r.label.trim(), + ...(r.color.trim() ? { color: r.color.trim() } : {}), + ...(r.align && r.align !== "auto" ? { align: r.align } : {}), +}); + +export default function MarkersEditor({ + markers, + markerLayout, + clips, + aligns, + layouts, + busy, + save, +}: { + markers: Marker[]; + markerLayout: string | null; + clips: { id: string; label: string }[]; + aligns: string[]; + layouts: string[]; + busy: boolean; + save: (patch: { markers: Marker[]; markerLayout: string | null }) => Promise<boolean>; +}) { + const savedKey = JSON.stringify([markers, markerLayout]); + const [rows, setRows] = useState<Row[]>(() => markers.map(rowOf)); + const [layout, setLayout] = useState(markerLayout ?? ""); + const [dirty, setDirty] = useState(false); + useEffect(() => { + setRows(markers.map(rowOf)); + setLayout(markerLayout ?? ""); + setDirty(false); + // The saved value, by its text: a re-read with the same markers keeps the edits. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [savedKey]); + + const change = (next: Row[]) => { + setRows(next); + setDirty(true); + }; + const put = (i: number, patch: Partial<Row>) => change(rows.map((r, j) => (j === i ? { ...r, ...patch } : r))); + const move = (i: number, d: number) => { + const j = i + d; + if (j < 0 || j >= rows.length) return; + const next = [...rows]; + [next[i], next[j]] = [next[j], next[i]]; + change(next); + }; + const add = () => { + const used = new Set(rows.map((r) => r.after)); + const after = clips.find((c) => !used.has(c.id))?.id ?? clips[0]?.id ?? ""; + change([...rows, { after, label: "", color: "", align: "auto" }]); + }; + const labelLong = rows.some((r) => [...r.label.trim()].length > MARKER_LABEL_MAX); + + return ( + <div data-testid="markers-editor" className="space-y-1.5"> + <div className="flex flex-wrap items-center gap-2"> + <span className="micro">markers</span> + <span className="text-[11px] text-[var(--color-dim)]"> + {rows.length} of {MARKER_MAX} + </span> + {dirty && <span className="text-[11px] text-[var(--color-dirty)]">unsaved</span>} + <label className="flex items-center gap-1 text-[11px] text-[var(--color-dim)]" title="when labels crowd: stagger puts every other one on a second row (truncating only if that still collides); truncate shortens them in place"> + layout + <select + data-testid="markers-layout" + value={layout} + onChange={(e) => { + setLayout(e.target.value); + setDirty(true); + }} + className={input} + > + <option value="">default (stagger when a label would truncate)</option> + {layouts.map((l) => ( + <option key={l} value={l}> + {l} + </option> + ))} + </select> + </label> + <button type="button" data-testid="markers-add" disabled={busy || rows.length >= MARKER_MAX || !clips.length} onClick={add} className={buttonVariants({ size: "sm" })}> + add a marker + </button> + <button + type="button" + data-testid="markers-save" + disabled={busy || !dirty || labelLong || rows.some((r) => !r.label.trim() || !r.after)} + onClick={() => void save({ markers: rows.map(markerOf), markerLayout: layout || null }).then((ok) => ok && setDirty(false))} + className={`${buttonVariants({ variant: "outline", size: "sm" })} ml-auto`} + > + save markers + </button> + </div> + {rows.length === 0 ? ( + <p className="text-[11px] text-[var(--color-dim)]">No markers: the pip track has no flags.</p> + ) : ( + <ol className="m-0 list-none space-y-1 p-0"> + {rows.map((r, i) => { + const n = [...r.label.trim()].length; + return ( + <li key={i} data-testid={`marker-row-${i}`} className="flex flex-wrap items-center gap-1.5 text-[11px] text-[var(--color-dim)]"> + <span className="num w-4 text-right font-mono">{i + 1}</span> + <label className="flex items-center gap-1"> + after + <select data-testid={`marker-after-${i}`} value={r.after} onChange={(e) => put(i, { after: e.target.value })} className={`${input} max-w-[16em]`}> + {!clips.some((c) => c.id === r.after) && <option value={r.after}>{r.after || "(pick a clip)"}</option>} + {clips.map((c) => ( + <option key={c.id} value={c.id}> + {c.id} — {c.label} + </option> + ))} + </select> + </label> + <input + data-testid={`marker-label-${i}`} + value={r.label} + placeholder="label" + onChange={(e) => put(i, { label: e.target.value })} + className={`${input} w-44`} + /> + <span className={`num font-mono ${n > MARKER_LABEL_MAX ? "text-[var(--color-bad)]" : ""}`}> + {n}/{MARKER_LABEL_MAX} + </span> + <input + data-testid={`marker-color-${i}`} + list="marker-palette" + value={r.color} + placeholder="amber" + title="a palette key (amber, accent, fg, muted, dim) or #hex" + onChange={(e) => put(i, { color: e.target.value })} + className={`${input} w-20 font-mono`} + /> + <select data-testid={`marker-align-${i}`} value={r.align} onChange={(e) => put(i, { align: e.target.value })} className={input} title="where the label sits against its flag"> + {aligns.map((a) => ( + <option key={a} value={a}> + {a} + </option> + ))} + </select> + <button type="button" data-testid={`marker-up-${i}`} disabled={i === 0} onClick={() => move(i, -1)} className={buttonVariants({ variant: "quiet", size: "sm" })} title="move up"> + ↑ + </button> + <button type="button" data-testid={`marker-down-${i}`} disabled={i === rows.length - 1} onClick={() => move(i, 1)} className={buttonVariants({ variant: "quiet", size: "sm" })} title="move down"> + ↓ + </button> + <button type="button" data-testid={`marker-remove-${i}`} onClick={() => change(rows.filter((_, j) => j !== i))} className={buttonVariants({ variant: "quiet", size: "sm" })}> + remove + </button> + </li> + ); + })} + </ol> + )} + <datalist id="marker-palette"> + {PALETTE.map((p) => ( + <option key={p} value={p} /> + ))} + </datalist> + </div> + ); +} diff --git a/umtool/components/projects/OnscreenSection.tsx b/umtool/components/projects/OnscreenSection.tsx @@ -3,6 +3,7 @@ import GeneratedBanner from "@/components/notes/GeneratedBanner"; import { TimedVideo } from "@/components/notes/TimedNotes"; import StructureEditors from "./StructureEditors"; +import MarkersEditor, { type Marker } from "./MarkersEditor"; import { MANIFEST_CHANGED } from "./timelineApi"; import { DraftAlternatives, DraftBadge, announceDraftsChanged, useDrafts } from "./drafts"; import { announceNotesChanged, wroteNotes } from "@/components/notes/NotesProvider"; @@ -540,8 +541,10 @@ type DeckSettings = { shift: false | { scale: number; seconds: number }; qr: boolean; }; - /** Flags on the pip track (`deck.markers`): written in the manifest, carried through every save here. */ - markers?: { after: string; label: string; color?: string }[]; + /** Flags on the pip track (`deck.markers`): the Markers editor's; carried through every settings save. */ + markers?: { after: string; label: string; color?: string; align?: string }[]; + /** What the deck does when marker labels crowd (`deck.markerLayout`): the Markers editor's. */ + markerLayout?: string; }; /** `when`: the bool field that must be on for this one to apply (and be shown). */ @@ -705,6 +708,9 @@ type ChromeDoc = { deck: DeckSettings | null; defaults: DeckSettings; errors: string[]; + /** The Markers editor's choices (video knobs). */ + markerAligns?: string[]; + markerLayouts?: string[]; token: string | null; }; type Row = { @@ -1042,6 +1048,41 @@ export default function OnscreenSection({ [project, queued], ); + /** The Markers editor's save: `deck.markers` and `deck.markerLayout`, nothing else of the deck. */ + const putMarkers = useCallback( + (patch: { markers: Marker[]; markerLayout: string | null }) => + queued(async () => { + setBusy("saving…"); + setNote(null); + const r = await fetch("/api/report/chrome", { + method: "PUT", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ project, ...patch, token: token.current }), + }); + const j = (await r.json()) as Record<string, unknown>; + if (wroteNotes(j)) announceNotesChanged(project); + setBusy(null); + if (!r.ok) { + if (j.stale) { + setStale(true); + setNote(STALE); + } else { + setErrors((j.errors as string[]) ?? []); + setNote(`could not save the markers: ${String(j.error ?? r.status)}`); + } + return false; + } + token.current = String(j.token ?? ""); + setErrors([]); + setStale(false); + await loadChrome(); + await recompose(); + setNote(`saved ${patch.markers.length} marker${patch.markers.length === 1 ? "" : "s"}`); + return true; + }), + [project, queued, loadChrome, recompose], + ); + const toggle = useCallback( async (on: boolean) => { if (!doc) return; @@ -1090,13 +1131,15 @@ export default function OnscreenSection({ // Everything this form does not edit is the manifest's, carried through // as saved, never dropped by a deck save: the fact-check settings and the // other regions (threads, flips, stats, fx) beside the deck, and the - // deck's markers (`deck.markers`, written in the manifest). + // deck's markers and their layout (`deck.markers`, `deck.markerLayout`: + // the Markers editor's). const { engine: _e, layout: _l, deck: savedDeck, ...others } = doc.chrome ?? {}; const markers = (savedDeck as { markers?: unknown } | undefined)?.markers; + const markerLayout = (savedDeck as { markerLayout?: unknown } | undefined)?.markerLayout; const chrome = { engine: (doc.chrome?.engine as string) ?? "hyperframes", layout: (doc.chrome?.layout as string) ?? "deck", - deck: { ...deckOf(form, doc.defaults), ...(markers !== undefined ? { markers } : {}) }, + deck: { ...deckOf(form, doc.defaults), ...(markers !== undefined ? { markers } : {}), ...(markerLayout !== undefined ? { markerLayout } : {}) }, ...others, }; const ok = await putChrome(chrome); @@ -2103,6 +2146,16 @@ export default function OnscreenSection({ </p> </div> + <MarkersEditor + markers={((doc.chrome?.deck as { markers?: Marker[] } | undefined)?.markers ?? []) as Marker[]} + markerLayout={((doc.chrome?.deck as { markerLayout?: string } | undefined)?.markerLayout ?? null) as string | null} + clips={clips.map((c) => ({ id: c.id, label: c.label }))} + aligns={doc.markerAligns ?? ["auto", "left", "right", "center"]} + layouts={doc.markerLayouts ?? ["stagger", "truncate"]} + busy={!!busy} + save={putMarkers} + /> + <div className="space-y-1"> <span className="micro">the built video</span> {typeof finalV === "number" ? (