commit e7cfcda6169f352cbe6fc94f4f8436139585c82e
parent 2ca377dba5fc9eb78b929ee5fce5e639ee298158
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 19:46:05 -0500
umtool: the inspector panels follow the draft -- MANIFEST_CHANGED both ways, the Project panel read on open (redesign L6)
Each panel announces its write (the timeline's Undo and the other holders re-read their token) and re-reads
on another's, keeping a form being typed in. The Cut tab's Project panel mounts its panels only once it is
opened (WhenOpen): the ledger's rows and the corpus's channels are not read on every Cut tab load.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
8 files changed, 88 insertions(+), 22 deletions(-)
diff --git a/umtool/components/projects/inspector/LedgerInspector.tsx b/umtool/components/projects/inspector/LedgerInspector.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Field, Input, Select, Textarea } from "@/components/ui/field";
-import { InspectorFrame, SaidLine, call, refusal, type InspectorProps, type Said } from "./shared";
+import { InspectorFrame, SaidLine, announceManifestChanged, call, refusal, useOnManifestChanged, type InspectorProps, type Said } from "./shared";
// A MEASURE LEDGER's ROWS (umtool redesign L6, item 3; agents added and fixed them with jq this week): the rows the
// instruments draw from, each with its date, scope (a track), form, value (a number, or a regime and its event on
@@ -47,6 +47,7 @@ export default function LedgerInspector({ project, block = null }: InspectorProp
useEffect(() => {
void load();
}, [load]);
+ useOnManifestChanged(project, load);
const declared = view?.schema?.fields ?? [];
const keys = useMemo(() => [...BASE_KEYS, ...declared.map((f) => f.key)], [declared]);
const rows = useMemo(() => {
@@ -121,6 +122,7 @@ export default function LedgerInspector({ project, block = null }: InspectorProp
await load();
setEditing(null);
setSaid({ ok: true, text: `${editing === "" ? "Added" : "Saved"} ${j.row?.id ?? ""}: ${String(j.row?.display ?? "")} — in the draft.` });
+ announceManifestChanged(project);
router.refresh();
} finally {
setBusy(false);
@@ -139,6 +141,7 @@ export default function LedgerInspector({ project, block = null }: InspectorProp
await load();
setEditing(null);
setSaid({ ok: true, text: `Removed ${id}.` });
+ announceManifestChanged(project);
router.refresh();
} finally {
setBusy(false);
diff --git a/umtool/components/projects/inspector/LinksInspector.tsx b/umtool/components/projects/inspector/LinksInspector.tsx
@@ -3,7 +3,7 @@
import { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
-import { InspectorFrame, SaidLine, call, refusal, type InspectorProps, type Said } from "./shared";
+import { InspectorFrame, SaidLine, announceManifestChanged, call, refusal, useOnManifestChanged, type InspectorProps, type Said } from "./shared";
// THE RUMBLE CITE FIX (umtool redesign L6, item 5; 4 and 8 Nov: a Rumble clip's QR named the URL-slug folder the
// corpus keeps it under, and the archive serves the EMBED id -- 15/15 dead on quartering-midterms): each clip of
@@ -29,6 +29,7 @@ export default function LinksInspector({ project, block = null }: InspectorProps
useEffect(() => {
void load();
}, [load]);
+ useOnManifestChanged(project, load);
if (!view) return null;
const rows = block ? view.rows.filter((r) => r.clip === block) : view.rows;
const dead = rows.filter((r) => r.state === "dead");
@@ -46,6 +47,7 @@ export default function LinksInspector({ project, block = null }: InspectorProps
await load();
const fixed = j.fixed ?? [];
setSaid({ ok: true, text: `${fixed.map((f) => `${f.clip} → ${f.siteVideo}`).join(", ")}: saved to the draft — Check links on the Overview reads the site again.` });
+ announceManifestChanged(project);
router.refresh();
} finally {
setBusy(false);
diff --git a/umtool/components/projects/inspector/PostItemInspector.tsx b/umtool/components/projects/inspector/PostItemInspector.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { addRange, piecesOf, rangesOf, settleRanges, snapToWords, spansOf } from "@/lib/report/excerptPick.mjs";
-import { InspectorFrame, SaidLine, call, refusal, type InspectorProps, type Said } from "./shared";
+import { InspectorFrame, SaidLine, announceManifestChanged, call, refusal, useOnManifestChanged, type InspectorProps, type Said } from "./shared";
// A POST ITEM (umtool redesign L6, item 4; 6-8 Nov these were `posts set-item excerpt=…` and `posts narrate
// --recording` by hand), with `block` the item's id:
@@ -47,7 +47,7 @@ export default function PostItemInspector({ project, block = null }: InspectorPr
const [file, setFile] = useState<File | null>(null);
const textRef = useRef<HTMLDivElement>(null);
const fileRef = useRef<HTMLInputElement>(null);
- const load = useCallback(async () => {
+ const load = useCallback(async (reset = true) => {
if (!block) return null;
const { ok, j } = await call<View>(`/api/report/post-item/inspector?${new URLSearchParams({ project, id: block }).toString()}`);
if (!ok) {
@@ -56,12 +56,13 @@ export default function PostItemInspector({ project, block = null }: InspectorPr
}
setMissing(null);
setView(j);
- setRanges(j.ranges ?? []);
+ if (reset) setRanges(j.ranges ?? []);
return j;
}, [project, block]);
useEffect(() => {
void load();
}, [load]);
+ useOnManifestChanged(project, () => load(false));
if (!block) return null;
if (missing) return <InspectorFrame kind="post-item" title={`Post item ${block}`}><p className="m-0 text-muted">{missing}</p></InspectorFrame>;
if (!view) return null;
@@ -80,6 +81,7 @@ export default function PostItemInspector({ project, block = null }: InspectorPr
}
await load();
setSaid({ ok: true, text: ok });
+ announceManifestChanged(project);
router.refresh();
return true;
} finally {
@@ -139,6 +141,7 @@ export default function PostItemInspector({ project, block = null }: InspectorPr
setFile(null);
if (fileRef.current) fileRef.current.value = "";
await load();
+ announceManifestChanged(project);
setSaid({ ok: true, text: `Kept as ${j.take.file}${typeof j.take.seconds === "number" ? ` (${j.take.seconds.toFixed(1)} s` : " ("}${typeof j.gain === "number" ? `, levelled ${j.gain >= 0 ? "+" : ""}${j.gain} dB)` : ")"} and picked.` });
router.refresh();
} finally {
diff --git a/umtool/components/projects/inspector/ProvenanceInspector.tsx b/umtool/components/projects/inspector/ProvenanceInspector.tsx
@@ -5,7 +5,7 @@ import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Field, Input } from "@/components/ui/field";
import LinkPolicyPanel from "../report/LinkPolicyPanel";
-import { InspectorFrame, SaidLine, call, refusal, type InspectorProps, type Said } from "./shared";
+import { InspectorFrame, SaidLine, announceManifestChanged, call, refusal, useOnManifestChanged, type InspectorProps, type Said } from "./shared";
// THE PROJECT'S PROVENANCE (umtool redesign L6, item 1; the owed provenance writer): where the cut's QRs open
// (provenance.siteOrigin), the channel a clip with no `channel` of its own is from (provenance.channelSlug --
@@ -29,16 +29,17 @@ export default function ProvenanceInspector({ project }: InspectorProps) {
const [busy, setBusy] = useState(false);
const [said, setSaid] = useState<Said>(null);
const [policyKey, setPolicyKey] = useState(0);
- const load = useCallback(async () => {
+ const load = useCallback(async (reset = true) => {
const { ok, j } = await call<View>(`/api/report/provenance?project=${encodeURIComponent(project)}`);
if (!ok) return null;
setView(j);
- setDraft({ siteOrigin: j.provenance.siteOrigin ?? "", channelSlug: j.provenance.channelSlug ?? "", channel: j.provenance.channel ?? "" });
+ if (reset) setDraft({ siteOrigin: j.provenance.siteOrigin ?? "", channelSlug: j.provenance.channelSlug ?? "", channel: j.provenance.channel ?? "" });
return j;
}, [project]);
useEffect(() => {
void load();
}, [load]);
+ useOnManifestChanged(project, () => load(false));
if (!view) return null;
const changed = KEYS.filter((k) => draft[k].trim() !== (view.provenance[k] ?? ""));
const set = (k: (typeof KEYS)[number], v: string) => {
@@ -59,6 +60,7 @@ export default function ProvenanceInspector({ project }: InspectorProps) {
await load();
setPolicyKey((n) => n + 1);
setSaid({ ok: true, text: `Saved to the draft: ${Object.keys(j.changed ?? {}).join(", ") || "nothing changed"}.` });
+ announceManifestChanged(project);
router.refresh();
} finally {
setBusy(false);
diff --git a/umtool/components/projects/inspector/TeaserInspector.tsx b/umtool/components/projects/inspector/TeaserInspector.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Field, Input, Select } from "@/components/ui/field";
-import { InspectorFrame, SaidLine, call, refusal, type InspectorProps, type Said } from "./shared";
+import { InspectorFrame, SaidLine, announceManifestChanged, call, refusal, useOnManifestChanged, type InspectorProps, type Said } from "./shared";
// A TEASER OR CLOSING CARD (umtool redesign L6, item 2): with no `block`, a NEW card -- where it goes (the end: a
// closing card; the start: a cold open; after an entry), its lines (the first its title; each with the end of
@@ -46,12 +46,12 @@ export default function TeaserInspector({ project, block = null }: InspectorProp
const [busy, setBusy] = useState(false);
const [said, setSaid] = useState<Said>(null);
const editing = block ? view?.teasers.find((t) => t.id === block) ?? null : null;
- const load = useCallback(async () => {
+ const load = useCallback(async (reset = true) => {
const { ok, j } = await call<View>(`/api/report/teaser?project=${encodeURIComponent(project)}`);
if (!ok) return null;
setView(j);
const t = block ? j.teasers.find((x) => x.id === block) : null;
- if (t) {
+ if (t && reset) {
setLines(t.lines.length ? t.lines.map(lineOf) : [blank()]);
setBeat(t.beat === null ? "" : String(t.beat));
}
@@ -60,6 +60,7 @@ export default function TeaserInspector({ project, block = null }: InspectorProp
useEffect(() => {
void load();
}, [load]);
+ useOnManifestChanged(project, () => load(false));
if (!view) return null;
if (block && !editing) return <InspectorFrame kind="teaser" title="Teaser"><p className="m-0 text-muted">No teaser {block} in the draft.</p></InspectorFrame>;
@@ -93,6 +94,7 @@ export default function TeaserInspector({ project, block = null }: InspectorProp
setBeat("");
setSaid({ ok: true, text: `Inserted ${j.id} at ${(j.at ?? 0) + 1} — Undo last edit takes it back.` });
}
+ announceManifestChanged(project);
router.refresh();
} finally {
setBusy(false);
diff --git a/umtool/components/projects/inspector/TitleInspector.tsx b/umtool/components/projects/inspector/TitleInspector.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Field, Input } from "@/components/ui/field";
-import { InspectorFrame, SaidLine, call, refusal, type InspectorProps, type Said } from "./shared";
+import { InspectorFrame, SaidLine, announceManifestChanged, call, refusal, useOnManifestChanged, type InspectorProps, type Said } from "./shared";
// THE PROJECT'S TITLE AND SUBTITLE (umtool redesign L6, item 7): the manifest's `title` and `subtitle`, through
// PUT /api/report/title (`umtool title <p> "<title>" [--subtitle "…"]`). An empty subtitle removes it.
@@ -18,17 +18,20 @@ export default function TitleInspector({ project }: InspectorProps) {
const [subtitle, setSubtitle] = useState("");
const [busy, setBusy] = useState(false);
const [said, setSaid] = useState<Said>(null);
- const load = useCallback(async () => {
+ const load = useCallback(async (reset = true) => {
const { ok, j } = await call<View>(`/api/report/title?project=${encodeURIComponent(project)}`);
if (!ok) return null;
setView(j);
- setTitle(j.title ?? "");
- setSubtitle(j.subtitle ?? "");
+ if (reset) {
+ setTitle(j.title ?? "");
+ setSubtitle(j.subtitle ?? "");
+ }
return j;
}, [project]);
useEffect(() => {
void load();
}, [load]);
+ useOnManifestChanged(project, () => load(false));
if (!view) return null;
const dirty = title.trim() !== (view.title ?? "") || subtitle.trim() !== (view.subtitle ?? "");
const save = async () => {
@@ -43,6 +46,7 @@ export default function TitleInspector({ project }: InspectorProps) {
}
await load();
setSaid({ ok: true, text: "Saved to the draft." });
+ announceManifestChanged(project);
router.refresh();
} finally {
setBusy(false);
diff --git a/umtool/components/projects/inspector/shared.tsx b/umtool/components/projects/inspector/shared.tsx
@@ -1,8 +1,11 @@
"use client";
-import { useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
+import { MANIFEST_CHANGED, announceManifestChanged } from "../timelineApi";
+
+export { announceManifestChanged };
// ---------------------------------------------------------------------------
// THE INSPECTOR PANELS' COMMON PARTS (umtool redesign L6). Every panel in this directory is self-contained: it
@@ -66,3 +69,48 @@ export function InspectorToggle({ label = "Edit", testid, children, className }:
</>
);
}
+
+/**
+ * Read again whenever the draft changed under the panel (the page's MANIFEST_CHANGED: another panel's write, the
+ * timeline's Undo), so its token is never the stale one. `reread` keeps a form being typed in (it refreshes the
+ * view, not the fields).
+ */
+export function useOnManifestChanged(project: string, reread: () => unknown) {
+ const fn = useRef(reread);
+ fn.current = reread;
+ useEffect(() => {
+ const on = (e: Event) => {
+ if ((e as CustomEvent).detail?.project === project) void fn.current();
+ };
+ window.addEventListener(MANIFEST_CHANGED, on);
+ return () => window.removeEventListener(MANIFEST_CHANGED, on);
+ }, [project]);
+}
+
+/**
+ * Its children only once the `<details>` it sits in has been opened (an Options panel): the panels inside read
+ * nothing until somebody looks. Outside a `<details>`, at once.
+ */
+export function WhenOpen({ children }: { children: React.ReactNode }) {
+ const ref = useRef<HTMLSpanElement>(null);
+ const [open, setOpen] = useState(false);
+ useEffect(() => {
+ const d = ref.current?.closest("details");
+ if (!d) {
+ setOpen(true);
+ return;
+ }
+ const on = () => {
+ if (d.open) setOpen(true);
+ };
+ on();
+ d.addEventListener("toggle", on);
+ return () => d.removeEventListener("toggle", on);
+ }, []);
+ return (
+ <>
+ <span ref={ref} hidden />
+ {open ? children : null}
+ </>
+ );
+}
diff --git a/umtool/components/projects/report/CutTab.tsx b/umtool/components/projects/report/CutTab.tsx
@@ -39,7 +39,7 @@ import { clipMomentKey } from "umtool-report-to-video/montage-rulings";
import { trailerCandidates } from "@/lib/report/trailerCandidates.mjs";
import IntroRow from "./IntroEditor";
// The inspector panels for this week's hand edits (umtool redesign L6), mounted here until L7's workspace inspector.
-import { InspectorToggle } from "../inspector/shared";
+import { InspectorToggle, WhenOpen } from "../inspector/shared";
import TitleInspector from "../inspector/TitleInspector";
import ProvenanceInspector from "../inspector/ProvenanceInspector";
import TeaserInspector from "../inspector/TeaserInspector";
@@ -518,11 +518,13 @@ export default async function CutTab({ project, detail, search, tabHref }: Repor
)}
{/* The project's own facts, each an inspector panel (L6): what agents set by hand this week. */}
<Options id="cut-project" label="Project" hint="title · provenance · Rumble cites · ledger · shots" bodyClassName="w-[min(1100px,calc(100vw-3rem))] flex-col items-stretch">
- <TitleInspector project={project.id} />
- <ProvenanceInspector project={project.id} />
- {clips.length > 0 && <LinksInspector project={project.id} />}
- {(Array.isArray(m?.ledger) || m?.ledgerSchema) && <LedgerInspector project={project.id} />}
- <StillInspector project={project.id} />
+ <WhenOpen>
+ <TitleInspector project={project.id} />
+ <ProvenanceInspector project={project.id} />
+ {clips.length > 0 && <LinksInspector project={project.id} />}
+ {(Array.isArray(m?.ledger) || m?.ledgerSchema) && <LedgerInspector project={project.id} />}
+ <StillInspector project={project.id} />
+ </WhenOpen>
</Options>
<Advanced id="cut" hint="voices · tight windows · bench prep">
{clips.length > 0 && (