Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
Ending: "Human Imagined" subheading, editable heading lines and shown counts (#11560)
[._.]/770734a78ee5
diff --git a/client/src/components/musicVideo/EndingCard.jsx b/client/src/components/musicVideo/EndingCard.jsxindex 824df51d13..891fe7f90b 100644--- a/client/src/components/musicVideo/EndingCard.jsx+++ b/client/src/components/musicVideo/EndingCard.jsx@@ -1,4 +1,4 @@-import { useEffect, useState } from 'react';+import { useEffect, useMemo, useState } from 'react';import { Play, RotateCcw, Scissors, Square, X } from 'lucide-react';import FilmLookFrame from '../media/FilmLookFrame.jsx';import StatsOutroCanvas from './StatsOutroCanvas.jsx';@@ -6,12 +6,13 @@ import StatsOutroPanel from './StatsOutroPanel.jsx';import useMusicVideoStatsOutro from '../../hooks/useMusicVideoStatsOutro.js';import { getMusicVideoOutroStats } from '../../services/apiMusicVideo.js';import { formatCount } from '../../utils/formatters.js';-import { STATS_OUTRO_DEFAULTS, normalizeStatsOutro, statsOutroDecisions, statsOutroRows } from '../../../../server/lib/musicVideoStatsOutro.js';+import { normalizeStatsOutro, statsOutroRows } from '../../../../server/lib/musicVideoStatsOutro.js';const PREVIEW_FPS = 24;-/** The ending's length: its own when on, else the length it would get when turned on. */-const endingSeconds = (project) => normalizeStatsOutro(project.statsOutro)?.durationSec ?? STATS_OUTRO_DEFAULTS.durationSec;+/** The ending as it shows: its own settings, else the ones it gets when turned on. */+const endingLook = (project) => normalizeStatsOutro(project.statsOutro || {});+const endingSeconds = (project) => endingLook(project).durationSec;// The frame a still of the ending shows: every count landed, before it fades out.const posterTime = (seconds) => Math.max(0, seconds - 1);@@ -60,14 +61,14 @@ export function EndingThumbnail({ project, open, onOpen }) {* it shows. The counts and the floor's stills come from the project itself.*/export default function EndingCard({ project, onEditLocal, onSave, onClose }) {- const seconds = endingSeconds(project);+ const look = useMemo(() => endingLook(project), [project]);+ const seconds = look.durationSec;const stats = useEndingStats(project.id);const preview = useMusicVideoStatsOutro({ projectId: project.id, seconds });const shown = preview.stats || stats;const t = preview.active ? preview.t : posterTime(seconds);const running = preview.active && preview.t < seconds;- const rows = shown ? statsOutroRows(shown) : [];- const decisions = shown ? statsOutroDecisions(shown) : 0;+ const rows = shown ? statsOutroRows(shown, look.hidden) : [];return (<section aria-label="Ending: cutting room floor" className="space-y-2 rounded-lg border border-port-accent bg-port-card p-2"><div className="flex items-center justify-between gap-2">@@ -84,7 +85,7 @@ export default function EndingCard({ project, onEditLocal, onSave, onClose }) {<div className="space-y-1.5"><figure className="relative aspect-video w-full overflow-hidden rounded border border-port-border bg-black"><FilmLookFrame look={project.filmLook} frame={Math.round(t * PREVIEW_FPS)} playing={running} className="h-full w-full">- <StatsOutroCanvas stats={shown} t={t} durationSec={seconds} />+ <StatsOutroCanvas stats={shown} outro={look} t={t} durationSec={seconds} /></FilmLookFrame></figure><button type="button" onClick={running ? preview.stop : preview.start}@@ -96,7 +97,6 @@ export default function EndingCard({ project, onEditLocal, onSave, onClose }) {</div><div className="min-w-0 space-y-2"><StatsOutroPanel project={project} onEditLocal={onEditLocal} onSave={onSave} />- {rows.length > 0 && <p className="text-sm font-medium">Human directed · {formatCount(decisions, { fallback: '0' })} decisions</p>}{rows.length > 0 && (<dl aria-label="What the ending counts" className="space-y-0.5 text-xs">{rows.map((row) => (@@ -107,7 +107,7 @@ export default function EndingCard({ project, onEditLocal, onSave, onClose }) {))}</dl>)}- <p className="text-xs text-port-text-muted">Decisions are every shot, every image and video used, and every cut, move and effect. Unused stills fill the floor.</p>+ <p className="text-xs text-port-text-muted">Unused stills fill the floor behind the counts.</p></div></div></section>diff --git a/client/src/components/musicVideo/StatsOutro.test.jsx b/client/src/components/musicVideo/StatsOutro.test.jsxindex b656404700..5c4d27dbee 100644--- a/client/src/components/musicVideo/StatsOutro.test.jsx+++ b/client/src/components/musicVideo/StatsOutro.test.jsx@@ -43,6 +43,7 @@ describe('cutting room floor ending', () => {expect(screen.getByTestId('animatic-stats-outro')).toBeTruthy();await waitFor(() => expect(getMusicVideoOutroStats).toHaveBeenCalledWith('p', { silent: true }));expect(canvas.texts).toContain('HUMAN DIRECTED');+ expect(canvas.texts).toContain('HUMAN IMAGINED');fireEvent.play(audio);expect(screen.queryByTestId('animatic-stats-outro')).toBeNull();fireEvent.click(screen.getByRole('button', { name: /Ending/ }));@@ -61,14 +62,21 @@ describe('cutting room floor ending', () => {expect(screen.queryByTestId('animatic-stats-outro')).toBeNull();});- it('turns on with its default length and saves a new length', () => {+ it('turns on with its defaults and saves a new length, heading and shown lines', () => {const onSave = vi.fn(async () => {});const onEditLocal = vi.fn();const { rerender } = render(<StatsOutroPanel project={{ id: 'p', statsOutro: null }} onEditLocal={onEditLocal} onSave={onSave} />);fireEvent.click(screen.getByLabelText('Off'));- expect(onSave).toHaveBeenLastCalledWith({ statsOutro: { enabled: true, durationSec: 8 } });- rerender(<StatsOutroPanel project={{ id: 'p', statsOutro: { enabled: true, durationSec: 8 } }} onEditLocal={onEditLocal} onSave={onSave} />);+ const on = { enabled: true, durationSec: 8, title: 'Human Directed', subtitle: 'Human Imagined', hidden: [] };+ expect(onSave).toHaveBeenLastCalledWith({ statsOutro: on });+ rerender(<StatsOutroPanel project={{ id: 'p', statsOutro: on }} onEditLocal={onEditLocal} onSave={onSave} />);fireEvent.change(screen.getByLabelText('Length'), { target: { value: '12' } });- expect(onSave).toHaveBeenLastCalledWith({ statsOutro: { enabled: true, durationSec: 12 } });+ expect(onSave).toHaveBeenLastCalledWith({ statsOutro: { ...on, durationSec: 12 } });+ const subtitle = screen.getByLabelText('Subheading (orange)');+ fireEvent.change(subtitle, { target: { value: 'Dreamed by hand ' } });+ fireEvent.blur(subtitle);+ expect(onSave).toHaveBeenLastCalledWith({ statsOutro: { ...on, subtitle: 'Dreamed by hand' } });+ fireEvent.click(screen.getByLabelText('Left on the floor'));+ expect(onSave).toHaveBeenLastCalledWith({ statsOutro: { ...on, hidden: ['floor'] } });});});diff --git a/client/src/components/musicVideo/StatsOutroCanvas.jsx b/client/src/components/musicVideo/StatsOutroCanvas.jsxindex 3a566adc39..3526ceb5b0 100644--- a/client/src/components/musicVideo/StatsOutroCanvas.jsx+++ b/client/src/components/musicVideo/StatsOutroCanvas.jsx@@ -22,11 +22,12 @@ const floorSrc = (imageId) => (/\.png$/i.test(imageId)/*** The cutting room floor outro (lib/musicVideoStatsOutro.js) at scene time- * `t`, painted by the same function the final render captures. `stats` is the+ * `t`, painted by the same function the final render captures. `outro` is the+ * normalized record (its heading lines and hidden tally lines). `stats` is the* server's tally (null while it loads: the floor and plate draw, the numbers* read zero until it lands).*/-export default function StatsOutroCanvas({ stats, t, durationSec }) {+export default function StatsOutroCanvas({ stats, outro, t, durationSec }) {const canvasRef = useRef(null);const [images, setImages] = useState([]);const [fontsReady, setFontsReady] = useState(0);@@ -61,8 +62,9 @@ export default function StatsOutroCanvas({ stats, t, durationSec }) {useEffect(() => {const ctx = canvasRef.current?.getContext?.('2d');if (!ctx) return;- drawStatsOutro(ctx, { width: WIDTH, height: HEIGHT, t, durationSec, stats, images });- }, [t, durationSec, stats, images, fontsReady]);+ drawStatsOutro(ctx, { width: WIDTH, height: HEIGHT, t, durationSec, stats, outro, images });+ }, [t, durationSec, stats, outro, images, fontsReady]);+ const heading = [outro?.title, outro?.subtitle].filter(Boolean).join(', ');return (<canvas@@ -70,7 +72,7 @@ export default function StatsOutroCanvas({ stats, t, durationSec }) {width={WIDTH}height={HEIGHT}role="img"- aria-label="Human directed: the choices behind this video, and what was left on the cutting room floor"+ aria-label={`${heading ? `${heading}: ` : ''}the choices behind this video, and what was left on the cutting room floor`}className="pointer-events-none absolute inset-0 h-full w-full"data-testid="animatic-stats-outro"/>diff --git a/client/src/components/musicVideo/StatsOutroPanel.jsx b/client/src/components/musicVideo/StatsOutroPanel.jsxindex c1f94b4f76..93476ae350 100644--- a/client/src/components/musicVideo/StatsOutroPanel.jsx+++ b/client/src/components/musicVideo/StatsOutroPanel.jsx@@ -1,14 +1,35 @@+import { useEffect, useState } from 'react';import { Scissors } from 'lucide-react';-import { STATS_OUTRO_DEFAULTS, normalizeStatsOutro } from '../../../../server/lib/musicVideoStatsOutro.js';+import { STATS_OUTRO_DEFAULTS, STATS_OUTRO_LIMITS, STATS_OUTRO_LINES, normalizeStatsOutro } from '../../../../server/lib/musicVideoStatsOutro.js';// Lengths offered for the scene, in seconds (inside STATS_OUTRO_LIMITS).const LENGTHS = [4, 6, 8, 10, 12, 15, 20];+const FIELD = 'min-h-[44px] rounded border border-port-border bg-port-bg px-2 py-1 text-sm sm:min-h-0';++/** One heading line: edited in place, saved when it loses focus. Empty leaves the line out. */+function HeadingField({ id, label, value, onCommit }) {+ const [draft, setDraft] = useState(value);+ useEffect(() => { setDraft(value); }, [value]);+ return (+ <div className="min-w-0">+ <label htmlFor={id} className="mb-0.5 block text-xs text-port-text-muted">{label}</label>+ <input id={id} type="text" value={draft} maxLength={STATS_OUTRO_LIMITS.textMax} placeholder="Optional"+ onChange={(e) => setDraft(e.target.value)}+ onBlur={() => { if (draft.trim() !== value) onCommit(draft.trim()); }}+ onKeyDown={(e) => { if (e.key === 'Enter') e.currentTarget.blur(); }}+ className={`${FIELD} w-full`} />+ </div>+ );+}+/*** The cutting room floor ending (lib/musicVideoStatsOutro.js): an optional- * scene after the song tallying what was made, kept and turned down. Off by- * default; on, it plays in the storyboard animatic when the song ends (or from- * its Ending button) and is added after the song in the final render.+ * scene after the song with a heading, an orange subheading and a tally of+ * what was made, used and left on the floor. Off by default; on, it plays in+ * the storyboard animatic when the song ends (or from its Ending button) and+ * is added after the song in the final render. Its heading lines and which+ * tally lines show are set here.*/export default function StatsOutroPanel({ project, onEditLocal, onSave }) {const outro = normalizeStatsOutro(project.statsOutro);@@ -18,6 +39,11 @@ export default function StatsOutroPanel({ project, onEditLocal, onSave }) {onEditLocal({ statsOutro: next });return onSave({ statsOutro: next });};+ const toggleLine = (key, shown) => {+ const hidden = new Set(outro.hidden);+ if (shown) hidden.delete(key); else hidden.add(key);+ return commit({ hidden: [...hidden] });+ };const lengths = LENGTHS.includes(outro?.durationSec) || !outro ? LENGTHS : [...LENGTHS, outro.durationSec].sort((a, b) => a - b);return (<section aria-label="Cutting room floor ending" className="space-y-2 rounded-lg border border-port-border bg-port-card p-2">@@ -32,17 +58,30 @@ export default function StatsOutroPanel({ project, onEditLocal, onSave }) {</label></div>{on && (- <div className="flex flex-wrap items-end gap-x-4 gap-y-2">- <div>- <label htmlFor="mv-stats-outro-length" className="mb-0.5 block text-xs text-port-text-muted">Length</label>- <select id="mv-stats-outro-length" value={outro.durationSec} onChange={(e) => commit({ durationSec: Number(e.target.value) })}- className="min-h-[44px] rounded border border-port-border bg-port-bg px-2 py-1 text-sm sm:min-h-0">- {lengths.map((sec) => <option key={sec} value={sec}>{sec}s</option>)}- </select>+ <div className="space-y-2">+ <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,10rem),1fr))] gap-2">+ <HeadingField id="mv-stats-outro-title" label="Heading" value={outro.title} onCommit={(title) => commit({ title })} />+ <HeadingField id="mv-stats-outro-subtitle" label="Subheading (orange)" value={outro.subtitle} onCommit={(subtitle) => commit({ subtitle })} />+ <div>+ <label htmlFor="mv-stats-outro-length" className="mb-0.5 block text-xs text-port-text-muted">Length</label>+ <select id="mv-stats-outro-length" value={outro.durationSec} onChange={(e) => commit({ durationSec: Number(e.target.value) })} className={FIELD}>+ {lengths.map((sec) => <option key={sec} value={sec}>{sec}s</option>)}+ </select>+ </div></div>- <p className="min-w-0 flex-1 basis-48 text-xs text-port-text-muted">- A “Human directed” card: renders reviewed, images and videos generated against the ones used, and cuts, moves and effects, over the unused stills. Ending plays it in the player.- </p>+ <fieldset className="min-w-0">+ <legend className="mb-0.5 text-xs text-port-text-muted">Show</legend>+ <div className="flex flex-wrap gap-x-3 gap-y-1">+ {STATS_OUTRO_LINES.map(({ key, label }) => (+ <label key={key} htmlFor={`mv-stats-outro-line-${key}`} className="inline-flex min-h-[44px] items-center gap-1.5 text-xs sm:min-h-0">+ <input id={`mv-stats-outro-line-${key}`} type="checkbox" checked={!outro.hidden.includes(key)}+ onChange={(e) => toggleLine(key, e.target.checked)} className="h-4 w-4" />+ {label}+ </label>+ ))}+ </div>+ </fieldset>+ <p className="text-xs text-port-text-muted">Unused stills fill the floor behind it. Ending plays it in the player.</p></div>)}</section>diff --git a/client/src/components/musicVideo/StoryboardAnimatic.jsx b/client/src/components/musicVideo/StoryboardAnimatic.jsxindex 7da0cb2bbc..40dc0b51ed 100644--- a/client/src/components/musicVideo/StoryboardAnimatic.jsx+++ b/client/src/components/musicVideo/StoryboardAnimatic.jsx@@ -10,7 +10,7 @@ import { playthroughVersion } from './CompositionPreviewPlayer.jsx';import { useVideoFileSrc } from '../../hooks/useVideoFileSrc.js';import { selectedPerformanceInstruction } from '../../lib/musicVideoShotTiming.js';import { normalizeTitleCard } from '../../../../server/lib/musicVideoTitleCard.js';-import { statsOutroSeconds } from '../../../../server/lib/musicVideoStatsOutro.js';+import { normalizeStatsOutro, statsOutroSeconds } from '../../../../server/lib/musicVideoStatsOutro.js';import StatsOutroCanvas from './StatsOutroCanvas.jsx';import ShotStepper from './ShotStepper.jsx';import FrameStepper, { captureMediaFrame } from './FrameStepper.jsx';@@ -453,6 +453,7 @@ export default function StoryboardAnimatic({ project, audioUrl, seekRequest, colconst { overlay, failed } = useLyricOverlay({ project, enabled: lyricsAvailable && lyricsOn, audioRef, time });// The cutting room floor outro: it plays when the song ends, and Ending plays it straight away; playing or seeking the song leaves it.const outro = useMusicVideoStatsOutro({ projectId: project.id, seconds: statsOutroSeconds(project.statsOutro), audioRef });+ const outroLook = useMemo(() => normalizeStatsOutro(project.statsOutro), [project.statsOutro]);const songEndSec = Number(project.audioAnalysis?.durationSec) || 0;useEffect(() => {if (!seekRequest || applied.current === seekRequest.n || !audioRef.current) return;@@ -539,7 +540,7 @@ export default function StoryboardAnimatic({ project, audioUrl, seekRequest, col<TransitionGlitch scenes={scenes} figureRef={figureRef} audioRef={audioRef} time={time} layered={layered}endSec={Number(project.audioAnalysis?.durationSec) || null} fps={ANIMATIC_FPS} />{overlay}- {outro.active && <StatsOutroCanvas stats={outro.stats} t={outro.t} durationSec={outro.seconds} />}+ {outro.active && <StatsOutroCanvas stats={outro.stats} outro={outroLook} t={outro.t} durationSec={outro.seconds} />}</FilmLookFrame></figure><div className="flex min-w-0 flex-wrap items-center gap-2">diff --git a/client/src/components/musicVideo/stages/BoardStage.test.jsx b/client/src/components/musicVideo/stages/BoardStage.test.jsxindex f814f84b41..45a9b792fe 100644--- a/client/src/components/musicVideo/stages/BoardStage.test.jsx+++ b/client/src/components/musicVideo/stages/BoardStage.test.jsx@@ -141,11 +141,9 @@ describe('BoardStage ending', () => {const card = screen.getByRole('region', { name: 'Ending: cutting room floor' });await waitFor(() => expect(card.textContent).toContain('Left on the floor'));expect(card.textContent).toContain('Renders reviewed39');- // The 3 shots, the 12 stills and 4 clips used are the decisions; renders made are not.- expect(card.textContent).toContain('Human directed · 19 decisions');expect(screen.getByRole('button', { name: /Play 8s/ })).toBeTruthy();fireEvent.click(screen.getByLabelText(/Off/));- expect(saveProjectFields).toHaveBeenCalledWith({ statsOutro: { enabled: true, durationSec: 8 } });+ expect(saveProjectFields).toHaveBeenCalledWith({ statsOutro: { enabled: true, durationSec: 8, title: 'Human Directed', subtitle: 'Human Imagined', hidden: [] } });fireEvent.click(screen.getByRole('button', { name: 'Close the ending' }));expect(screen.getByTestId('search').textContent).not.toContain('ending');expect(screen.queryByRole('region', { name: 'Ending: cutting room floor' })).toBeNull();diff --git a/server/lib/musicVideoStatsOutro.js b/server/lib/musicVideoStatsOutro.jsindex c9e855a74f..7772dcf783 100644--- a/server/lib/musicVideoStatsOutro.js+++ b/server/lib/musicVideoStatsOutro.js@@ -1,11 +1,12 @@/*** Music Video — the cutting room floor outro: an optional closing scene that- * plays after the song ends under the title "Human Directed" and tallies the- * work behind the video (every render reviewed, the images and videos- * generated against the ones used, the cuts, moves and effects placed), over- * a floor of the stills that did not make it. One record on the project- * (`project.statsOutro`, null = off) turns it on and sets how long it runs;- * it adds that time after the song and never shortens it.+ * plays after the song ends under a heading ("Human Directed") and an orange+ * subheading ("Human Imagined") and tallies the work behind the video (every+ * render reviewed, the images and videos generated against the ones used, the+ * cuts, moves and effects placed), over a floor of the stills that did not+ * make it. One record on the project (`project.statsOutro`, null = off) turns+ * it on, sets how long it runs, its two heading lines and which tally lines+ * show; it adds its time after the song and never shortens it.** Every count comes from what the project records (`musicVideoOutroStats`):* its shots' takes and selections, its media collection and its asset marks.@@ -17,8 +18,18 @@* function of the scene's own time. Browser-safe, no imports.*/-export const STATS_OUTRO_LIMITS = Object.freeze({ durationMin: 4, durationMax: 20 });-export const STATS_OUTRO_DEFAULTS = Object.freeze({ enabled: false, durationSec: 8 });+export const STATS_OUTRO_LIMITS = Object.freeze({ durationMin: 4, durationMax: 20, textMax: 40 });+/** The tally's lines a project can hide, in the order they show. */+export const STATS_OUTRO_LINES = Object.freeze([+ Object.freeze({ key: 'renders', label: 'Renders reviewed' }),+ Object.freeze({ key: 'images', label: 'Images generated & used' }),+ Object.freeze({ key: 'videos', label: 'Videos generated & used' }),+ Object.freeze({ key: 'edits', label: 'Cuts, moves & effects' }),+ Object.freeze({ key: 'floor', label: 'Left on the floor' }),+]);+export const STATS_OUTRO_DEFAULTS = Object.freeze({+ enabled: false, durationSec: 8, title: 'Human Directed', subtitle: 'Human Imagined', hidden: Object.freeze([]),+});/** How many unused stills are piled into the floor collage behind the tally. */export const STATS_OUTRO_FLOOR_MAX = 48;/** The fonts the scene draws in (bundled OFL faces, registered by each page). */@@ -27,14 +38,22 @@ export const STATS_OUTRO_FONTS = Object.freeze({body: Object.freeze({ family: 'MV Mono', file: 'ibm-plex-mono-500.woff2' }),});-/** A stored outro from any input (null for none). */+/**+ * A stored outro from any input (null for none). A heading line left out takes+ * its default; one stored empty stays empty (that line is not drawn).+ */export function normalizeStatsOutro(input) {if (!input || typeof input !== 'object' || Array.isArray(input)) return null;- const { durationMin, durationMax } = STATS_OUTRO_LIMITS;+ const { durationMin, durationMax, textMax } = STATS_OUTRO_LIMITS;const raw = typeof input.durationSec === 'number' && Number.isFinite(input.durationSec) ? input.durationSec : STATS_OUTRO_DEFAULTS.durationSec;+ const text = (value, fallback) => (typeof value === 'string' ? value.trim().slice(0, textMax) : fallback);+ const hidden = new Set(Array.isArray(input.hidden) ? input.hidden : []);return {enabled: typeof input.enabled === 'boolean' ? input.enabled : STATS_OUTRO_DEFAULTS.enabled,durationSec: Math.round(Math.min(durationMax, Math.max(durationMin, raw)) * 10) / 10,+ title: text(input.title, STATS_OUTRO_DEFAULTS.title),+ subtitle: text(input.subtitle, STATS_OUTRO_DEFAULTS.subtitle),+ hidden: STATS_OUTRO_LINES.map((line) => line.key).filter((key) => hidden.has(key)),};}@@ -119,42 +138,39 @@ export function musicVideoOutroStats(project, { collectionItems = [] } = {}) {* module scope, only to each other by name. *//**- * The tally's lines, in order: `{ label, value, choice?, accent? }`. A- * `choice` line counts calls the director made. The images and videos lines- * always show; cuts, moves and effects are left out when there are none. The- * last line is what was left on the floor.+ * The tally's lines, in order: `{ key, label, value, accent? }`, `key` naming+ * its STATS_OUTRO_LINES entry. The images and videos lines always show unless+ * `hidden` names them; cuts, moves and effects are left out when there are+ * none. The last line is what was left on the floor.*/-function statsOutroRows(stats) {+function statsOutroRows(stats, hidden = []) {const n = (v) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? Math.round(v) : 0);const s = stats || {};const stills = s.stills || {};const clips = s.clips || {};const rows = [- { label: 'Renders reviewed', value: n(stills.made) + n(clips.made) },- { label: 'Images generated', value: n(stills.made) },- { label: 'Images used', value: n(stills.kept), choice: true },- { label: 'Videos generated', value: n(clips.made) },- { label: 'Videos used', value: n(clips.kept), choice: true },- { label: 'Cuts, moves & effects', value: n(s.transitions) + n(s.imageEffects) + n(s.cameraMoves) + n(s.lipSyncs), choice: true, optional: true },+ { key: 'renders', label: 'Renders reviewed', value: n(stills.made) + n(clips.made) },+ { key: 'images', label: 'Images generated', value: n(stills.made) },+ { key: 'images', label: 'Images used', value: n(stills.kept) },+ { key: 'videos', label: 'Videos generated', value: n(clips.made) },+ { key: 'videos', label: 'Videos used', value: n(clips.kept) },+ { key: 'edits', label: 'Cuts, moves & effects', value: n(s.transitions) + n(s.imageEffects) + n(s.cameraMoves) + n(s.lipSyncs), optional: true },].filter((row) => !row.optional || row.value > 0).map(({ optional: _optional, ...row }) => row);const floor = Math.max(0, n(stills.made) - n(stills.kept)) + Math.max(0, n(clips.made) - n(clips.kept));- rows.push({ label: 'Left on the floor', value: floor, accent: true });- return rows;-}--/** The decisions the heading counts: every shot dreamed up, plus each `choice` line. */-function statsOutroDecisions(stats) {- const shots = stats && typeof stats.shots === 'number' && stats.shots > 0 ? Math.round(stats.shots) : 0;- return shots + statsOutroRows(stats).reduce((sum, row) => sum + (row.choice ? row.value : 0), 0);+ rows.push({ key: 'floor', label: 'Left on the floor', value: floor, accent: true });+ const off = Array.isArray(hidden) ? hidden : [];+ return rows.filter((row) => !off.includes(row.key));}/*** Paint the outro at scene time `t` (0 = the song's last frame) on a* width × height 2D context. `images[i]` is the loaded still for- * `stats.floorImages[i]` (null while loading, or when none). Everything sits- * inside the title-safe area and shrinks to fit, at any aspect.+ * `stats.floorImages[i]` (null while loading, or when none). `outro` is the+ * normalized record: its heading, subheading and hidden lines (an empty+ * heading line is not drawn). Everything sits inside the title-safe area and+ * shrinks to fit, at any aspect.*/-function drawStatsOutro(ctx, { width, height, t, durationSec, stats, images = [], fonts = {} }) {+function drawStatsOutro(ctx, { width, height, t, durationSec, stats, outro = null, images = [], fonts = {} }) {const head = fonts.head || '"MV Archivo", "Arial Black", Impact, sans-serif';const body = fonts.body || '"MV Mono", Menlo, Consolas, "Courier New", monospace';const clamp = (v) => (v < 0 ? 0 : v > 1 ? 1 : v);@@ -245,7 +261,7 @@ function drawStatsOutro(ctx, { width, height, t, durationSec, stats, images = []ctx.fillRect(0, 0, width, height);// The tally: an edit log on a dark plate, inside the title-safe area.- const rows = statsOutroRows(stats);+ const rows = statsOutroRows(stats, outro && outro.hidden);const insetX = width * 0.1;const insetY = height * 0.1;const safeW = width - insetX * 2;@@ -256,19 +272,22 @@ function drawStatsOutro(ctx, { width, height, t, durationSec, stats, images = []const pad = 0.9; // plate padding, in row heightsconst lineH = 1.5;const headScale = 1.45;+ const line = (value) => (typeof value === 'string' ? value.trim().toUpperCase() : '');+ const headText = line(outro ? outro.title : 'Human Directed');+ const subText = line(outro ? outro.subtitle : 'Human Imagined');// Fit the block's height first, then its widest line.- // Plate: padding, heading, the decision line, a gap, the rows, a foot, padding (in units of the row size).- const blockUnits = pad + headScale + 1.95 + rows.length * lineH + 0.5 + pad;+ // Plate: padding, heading, subheading, a gap under the rule, the rows, a foot, padding (in units of the row size).+ const headUnits = headText ? headScale : 0;+ const subUnits = subText ? (headText ? 1.25 : 1) : 0;+ const ruled = headUnits + subUnits > 0;+ const blockUnits = pad + headUnits + subUnits + (ruled ? 0.7 : -0.5) + rows.length * lineH + 0.5 + pad;let px = safeH / blockUnits;const rowFont = (size, weight = 500) => `${weight} ${Math.floor(size * 100) / 100}px ${body}`;const headFont = (size) => `800 ${Math.floor(size * 100) / 100}px ${head}`;- const headText = 'HUMAN DIRECTED';- const decisions = statsOutroDecisions(stats);- const shots = stats && typeof stats.shots === 'number' && stats.shots > 0 ? Math.round(stats.shots) : 0;- const subText = (v) => `${fmt(v)} DECISIONS${shots ? ` · ${fmt(shots)} SHOTS` : ''}`;const widest = (size) => Math.max(- measure(headText, headFont(size * headScale)) + size * pad * 2,- measure(subText(Math.max(decisions, 10000)), rowFont(size, 600)) + size * pad * 2,+ size * 8,+ headText ? measure(headText, headFont(size * headScale)) + size * pad * 2 : 0,+ subText ? measure(subText, rowFont(size, 600)) + size * pad * 2 : 0,...rows.map((row) => measure(row.label.toUpperCase(), rowFont(size)) + measure(fmt(Math.max(row.value, 1000)), rowFont(size, 600)) + size * (2 + pad * 2)),);const wide = widest(px);@@ -286,18 +305,25 @@ function drawStatsOutro(ctx, { width, height, t, durationSec, stats, images = []ctx.strokeRect(left + px * 0.25, top + px * 0.25, plateW - px * 0.5, plateH - px * 0.5);ctx.textBaseline = 'alphabetic';ctx.textAlign = 'center';- ctx.font = headFont(px * headScale);- ctx.fillStyle = '#f3ead7';- const headY = top + px * pad + px * headScale;- ctx.fillText(headText, width / 2, headY);- // Under it, every call the director made, counting up with the rows.- ctx.font = rowFont(px, 600);- ctx.fillStyle = '#ff8a4c';- const subY = headY + px * 1.25;- ctx.fillText(subText(decisions * ease((t - 0.9) / Math.max(1, D * 0.5))), width / 2, subY);+ const headY = top + px * pad + px * headUnits;+ if (headText) {+ ctx.font = headFont(px * headScale);+ ctx.fillStyle = '#f3ead7';+ ctx.fillText(headText, width / 2, headY);+ }+ // Under it, the subheading in orange.+ const subY = headY + px * subUnits;+ if (subText) {+ ctx.font = rowFont(px, 600);+ ctx.fillStyle = '#ff8a4c';+ ctx.fillText(subText, width / 2, subY);+ }// A rule under the heading.- ctx.fillStyle = 'rgba(243, 196, 107, 0.7)';- ctx.fillRect(left + px * pad, subY + px * 0.55, plateW - px * pad * 2, Math.max(1, px * 0.06));+ if (ruled) {+ ctx.fillStyle = 'rgba(243, 196, 107, 0.7)';+ ctx.fillRect(left + px * pad, subY + px * 0.55, plateW - px * pad * 2, Math.max(1, px * 0.06));+ }+ const rowBase = subY + px * (ruled ? 0.7 : -0.5);// Rows arrive one by one in the first half of the scene, each counting up to its number.const firstRow = 0.9;const stagger = Math.min(0.4, Math.max(0.12, (D * 0.5 - firstRow) / Math.max(1, rows.length)));@@ -306,7 +332,7 @@ function drawStatsOutro(ctx, { width, height, t, durationSec, stats, images = []const show = ease((t - start) / 0.35);if (show <= 0) return;const counted = row.value * ease((t - start) / 0.9);- const y = subY + px * 0.7 + px * lineH * (i + 1) + (1 - show) * px * 0.4;+ const y = rowBase + px * lineH * (i + 1) + (1 - show) * px * 0.4;ctx.globalAlpha = plateIn * show;if (row.accent) {ctx.fillStyle = 'rgba(255, 122, 61, 0.14)';@@ -337,7 +363,7 @@ function drawStatsOutro(ctx, { width, height, t, durationSec, stats, images = []ctx.restore();}-export { statsOutroRows, statsOutroDecisions, drawStatsOutro };+export { statsOutroRows, drawStatsOutro };/*** The render page's script: draws the outro full-frame on a canvas and@@ -346,13 +372,13 @@ export { statsOutroRows, statsOutroDecisions, drawStatsOutro };* for `stats.floorImages[i]`; the faces are declared by the page's* @font-face rules. Every seek waits for the stills and faces to load.*/-export function statsOutroPageSource({ stats, imageSrcs = [], width, height, fps, durationSec }) {+export function statsOutroPageSource({ stats, outro = null, imageSrcs = [], width, height, fps, durationSec }) {const json = (value) => JSON.stringify(value).replace(/</g, '\\u003c');return `(() => {${statsOutroRows.toString()}- ${statsOutroDecisions.toString()}${drawStatsOutro.toString()}const STATS = ${json(stats)};+ const OUTRO = ${json(outro)};const SRCS = ${json(imageSrcs)};const WIDTH = ${Number(width)}, HEIGHT = ${Number(height)}, FPS = ${Number(fps)}, DURATION = ${Number(durationSec)};const canvas = document.getElementById('outro');@@ -374,7 +400,7 @@ export function statsOutroPageSource({ stats, imageSrcs = [], width, height, fpsasync seek(t) {await loaded;await faces;- drawStatsOutro(ctx, { width: WIDTH, height: HEIGHT, t, durationSec: DURATION, stats: STATS, images });+ drawStatsOutro(ctx, { width: WIDTH, height: HEIGHT, t, durationSec: DURATION, stats: STATS, outro: OUTRO, images });await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));},};diff --git a/server/lib/musicVideoStatsOutro.test.js b/server/lib/musicVideoStatsOutro.test.jsindex 9984ae2eae..608593524a 100644--- a/server/lib/musicVideoStatsOutro.test.js+++ b/server/lib/musicVideoStatsOutro.test.js@@ -1,12 +1,15 @@import { describe, expect, it } from 'vitest';-import { STATS_OUTRO_FLOOR_MAX, musicVideoOutroStats, statsOutroDecisions, normalizeStatsOutro, statsOutroRows, statsOutroSeconds } from './musicVideoStatsOutro.js';+import { STATS_OUTRO_FLOOR_MAX, musicVideoOutroStats, normalizeStatsOutro, statsOutroRows, statsOutroSeconds } from './musicVideoStatsOutro.js';describe('cutting room floor outro', () => {it('is off unless turned on, and its length stays inside its limits', () => {expect(normalizeStatsOutro(null)).toBeNull();expect(statsOutroSeconds(null)).toBe(0);expect(statsOutroSeconds({ durationSec: 10 })).toBe(0);- expect(normalizeStatsOutro({ enabled: true })).toEqual({ enabled: true, durationSec: 8 });+ expect(normalizeStatsOutro({ enabled: true })).toEqual({ enabled: true, durationSec: 8, title: 'Human Directed', subtitle: 'Human Imagined', hidden: [] });+ // A cleared heading line stays cleared; unknown lines are dropped, the rest kept in display order.+ expect(normalizeStatsOutro({ title: ' ', subtitle: ' Made by hand ', hidden: ['floor', 'nope', 'renders', 'floor'] }))+ .toEqual({ enabled: false, durationSec: 8, title: '', subtitle: 'Made by hand', hidden: ['renders', 'floor'] });expect(statsOutroSeconds({ enabled: true, durationSec: 99 })).toBe(20);expect(statsOutroSeconds({ enabled: true, durationSec: 1 })).toBe(4);});@@ -45,16 +48,15 @@ describe('cutting room floor outro', () => {});const rows = statsOutroRows(stats);expect(rows).toEqual([- { label: 'Renders reviewed', value: 8 },- { label: 'Images generated', value: 5 },- { label: 'Images used', value: 3, choice: true },- { label: 'Videos generated', value: 3 },- { label: 'Videos used', value: 1, choice: true },- { label: 'Cuts, moves & effects', value: 5, choice: true },- { label: 'Left on the floor', value: 4, accent: true },+ { key: 'renders', label: 'Renders reviewed', value: 8 },+ { key: 'images', label: 'Images generated', value: 5 },+ { key: 'images', label: 'Images used', value: 3 },+ { key: 'videos', label: 'Videos generated', value: 3 },+ { key: 'videos', label: 'Videos used', value: 1 },+ { key: 'edits', label: 'Cuts, moves & effects', value: 5 },+ { key: 'floor', label: 'Left on the floor', value: 4, accent: true },]);- // Every shot dreamed up is a decision, then each still and clip used and each cut, move and effect.- expect(statsOutroDecisions(stats)).toBe(2 + 3 + 1 + 5);+ expect(statsOutroRows(stats, ['images', 'floor']).map((row) => row.label)).toEqual(['Renders reviewed', 'Videos generated', 'Videos used', 'Cuts, moves & effects']);});it('leaves out the choices never made and spreads the floor over the whole pile', () => {diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex a5328f15e8..d03bc2c598 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -2,7 +2,7 @@ import { MUSIC_VIDEO_MEDIA_MODES } from './musicVideoMediaPolicy.js';import { MUSIC_VIDEO_GRADE_PRESETS, MUSIC_VIDEO_GRADE_MAX_GRAIN } from './musicVideoGrade.js';import { filmLookSchema } from './filmLookValidation.js';import { TITLE_CARD_FONTS, TITLE_CARD_LIMITS, TITLE_CARD_POSITIONS, TITLE_CARD_STYLES } from './musicVideoTitleCard.js';-import { STATS_OUTRO_LIMITS } from './musicVideoStatsOutro.js';+import { STATS_OUTRO_LIMITS, STATS_OUTRO_LINES } from './musicVideoStatsOutro.js';import { COVER_DESIGN_OPTIONS } from './musicVideoCoverOverlay.js';import { DISTROKID_REMEMBERED_OPTIONS } from './distrokidGenres.js';import { CROSS_LINK_EDIT_TARGETS } from './musicVideoCrossLinks.js';@@ -1310,6 +1310,9 @@ export const musicVideoCastAndSetsDirectionEditSchema = z.object({export const musicVideoStatsOutroSchema = z.object({enabled: z.boolean().optional(),durationSec: z.number().min(STATS_OUTRO_LIMITS.durationMin).max(STATS_OUTRO_LIMITS.durationMax).optional(),+ title: z.string().max(STATS_OUTRO_LIMITS.textMax).optional(),+ subtitle: z.string().max(STATS_OUTRO_LIMITS.textMax).optional(),+ hidden: z.array(z.enum(STATS_OUTRO_LINES.map((line) => line.key))).max(STATS_OUTRO_LINES.length).optional(),}).strict();// The opening title card (lib/musicVideoTitleCard.js): song title, artist, yeardiff --git a/server/services/musicVideo/statsOutro.js b/server/services/musicVideo/statsOutro.jsindex 6daca84523..a758568f56 100644--- a/server/services/musicVideo/statsOutro.js+++ b/server/services/musicVideo/statsOutro.js@@ -96,7 +96,7 @@ export async function appendStatsOutro({ project, path, jobId, signal, onProgresimageSrcs.push(staged ? `media/${name}` : '');}await writeFile(join(scratch, 'index.html'), statsOutroPage({ stats, imageSrcs, width, height, fps, durationSec }));- await writeFile(join(scratch, 'app.js'), statsOutroPageSource({ stats, imageSrcs, width, height, fps, durationSec }));+ await writeFile(join(scratch, 'app.js'), statsOutroPageSource({ stats, outro, imageSrcs, width, height, fps, durationSec }));signal?.throwIfAborted();// A render whose film look is drawn in its page (the seeked modes) has no later// pass to grade the outro, so the outro page draws the look itself.