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
fix: address round-2 excerpt review findings (#8986)
[._.]/ Adam Eivya3bc4683e252
diff --git a/client/src/components/musicVideo/ExcerptPanel.jsx b/client/src/components/musicVideo/ExcerptPanel.jsxindex 3636fbcccd..ca939d4f06 100644--- a/client/src/components/musicVideo/ExcerptPanel.jsx+++ b/client/src/components/musicVideo/ExcerptPanel.jsx@@ -65,8 +65,12 @@ function ExcerptCard({ excerpt, deleting, noteBusy, onDelete, onCancel, onAddNotconst seek = (t) => { if (videoRef.current) { videoRef.current.currentTime = t; videoRef.current.play?.().catch(() => {}); } };const addNoteHere = () => {if (!draft.trim()) return;- onAddNote(excerpt.id, { atSec: videoRef.current?.currentTime ?? 0, note: draft.trim() });- setDraft('');+ // Only clear the draft once the note actually saved — `addNote` resolves+ // null on failure — so a transient request error doesn't silently discard+ // what the reviewer typed.+ onAddNote(excerpt.id, { atSec: videoRef.current?.currentTime ?? 0, note: draft.trim() }).then((result) => {+ if (result) setDraft('');+ });};return (<li className="rounded border border-port-border p-2 space-y-2">diff --git a/client/src/hooks/useMusicVideoExcerpts.js b/client/src/hooks/useMusicVideoExcerpts.jsindex 434d150535..c28a7f5444 100644--- a/client/src/hooks/useMusicVideoExcerpts.js+++ b/client/src/hooks/useMusicVideoExcerpts.js@@ -34,9 +34,13 @@ export default function useMusicVideoExcerpts({ project, replaceProject } = {})const [noteBusyId, setNoteBusyId] = useState(null);const [deletingId, setDeletingId] = useState(null);- const reload = () => {- if (!projectId) return;- getMusicVideoProject(projectId, { silent: true }).then(replaceProject).catch(() => {});+ // Reload the project the render was STARTED for, not whichever one is+ // currently selected — `job.start` below captures `projectId` as the slot's+ // `context`, handed back here on every terminal frame, so switching to a+ // different project mid-render can't reload/overwrite the wrong record.+ const reload = (id) => {+ if (!id) return;+ getMusicVideoProject(id, { silent: true }).then(replaceProject).catch(() => {});};const job = useSseJobSlot({@@ -44,8 +48,8 @@ export default function useMusicVideoExcerpts({ project, replaceProject } = {})eventsUrl: musicVideoExcerptRenderEventsUrl,cancelRequest: cancelMusicVideoExcerptRender,readPercent,- onComplete: reload,- onErrorFrame: () => { reload(); return true; }, // reload already surfaces the persisted `error` field; skip the generic toast+ onComplete: (_frame, id) => reload(id),+ onErrorFrame: (_frame, id) => { reload(id); return true; }, // reload already surfaces the persisted `error` field; skip the generic toastonKickoffError: (err) => {if (err?.status === 409) { toast.error(err.message || 'An excerpt render is already in progress'); return true; }return false;diff --git a/server/services/htmlComposition/encode.js b/server/services/htmlComposition/encode.jsindex 5032e49475..9159ff65ab 100644--- a/server/services/htmlComposition/encode.js+++ b/server/services/htmlComposition/encode.js@@ -180,18 +180,25 @@ export async function encodeReferenceContactSheet(videoPath, outputPath, { every// sampling a REAL rendered video file at explicit `times` (seconds, relative// to the file's own start) rather than a browser composition or a uniform// step (#8986 — the excerpt render's cut/cue contact sheet from-// `excerptBoundaryTimes` in services/musicVideo/render.js). `between(t,…)`-// selects a small window around each target time rather than an exact frame-// timestamp match, which floating-point frame times almost never hit exactly.-export async function encodeFileContactSheetAtTimes(videoPath, outputPath, times, { width, height } = {}) {+// `excerptBoundaryTimes` in services/musicVideo/render.js). Each time is+// converted to an exact frame INDEX and selected with `eq(n,…)` — the same+// technique `extractEvaluationFrames` (lib/ffmpeg.js) uses for multi-frame+// selection — rather than a `between(t,…)` time window: at 30/60fps a time+// window can match several consecutive frames, overfilling the tile before+// later boundary times are ever reached.+export async function encodeFileContactSheetAtTimes(videoPath, outputPath, times, { width, height, fps } = {}) {const ffmpeg = await findFfmpeg();if (!ffmpeg) throw new Error('ffmpeg not found on PATH');if (!Array.isArray(times) || times.length === 0) throw new Error('encodeFileContactSheetAtTimes: no sample times');+ if (!(fps > 0)) throw new Error('encodeFileContactSheetAtTimes: fps is required');const tileWidth = width && height && width < height ? 240 : 360;const columns = Math.min(PROOF_COLUMNS, times.length);const rows = Math.ceil(times.length / columns);- const eps = 0.05;- const selectExpr = times.map((t) => `between(t,${Math.max(0, t).toFixed(3)},${(t + eps).toFixed(3)})`).join('+');+ // Two very close boundary times can round to the same frame index — the+ // dedup means the tile gets one fewer real frame than requested (a padded+ // cell), never a duplicate or an out-of-order one.+ const indices = [...new Set(times.map((t) => Math.max(0, Math.round(t * fps))))];+ const selectExpr = indices.map((i) => `eq(n,${i})`).join('+');const result = await runFfmpegProcess({bin: ffmpeg,args: ['-hide_banner', '-loglevel', 'error', '-i', videoPath, '-vf',diff --git a/server/services/musicVideo/excerptRender.js b/server/services/musicVideo/excerptRender.jsindex 9431441e42..8dee412a47 100644--- a/server/services/musicVideo/excerptRender.js+++ b/server/services/musicVideo/excerptRender.js@@ -136,7 +136,7 @@ export async function startExcerptRender(projectId, { startSec, endSec }) {try {const times = excerptBoundaryTimes(probe.sections, cues, startSec, endClamped, { fps: probe.fps });const sheetFilename = `${filename.replace(/\.mp4$/, '')}-sheet.png`;- await encodeFileContactSheetAtTimes(outputPath, join(PATHS.videoThumbnails, sheetFilename), times, { width: probe.canonW, height: probe.canonH });+ await encodeFileContactSheetAtTimes(outputPath, join(PATHS.videoThumbnails, sheetFilename), times, { width: probe.canonW, height: probe.canonH, fps: probe.fps });return sheetFilename;} catch (err) {console.warn(`⚠️ Music-video excerpt render [${jobId.slice(4, 12)}] contact sheet failed: ${err.message}`);@@ -183,8 +183,11 @@ export async function startExcerptRender(projectId, { startSec, endSec }) {const reason = `Failed to spawn ffmpeg: ${err.message}`;job.lastError = reason;console.error(`❌ Music-video excerpt render spawn error [${jobId.slice(4, 12)}]: ${reason}`);- broadcastSse(job, { type: 'error', error: reason });+ // Persist before broadcasting: a client that reloads the instant it+ // sees the terminal frame must not race ahead of the write and read+ // back a stale `status: 'rendering'`.await finalize({ status: 'error', error: reason, filename: null, jobId: null });+ broadcastSse(job, { type: 'error', error: reason });},onClose: async (code, signal) => {job.process = null;@@ -197,8 +200,8 @@ export async function startExcerptRender(projectId, { startSec, endSec }) {logClose(`${canceled ? '🛑' : '❌'} Music-video excerpt render ${canceled ? 'cancelled' : 'failed'} [${jobId.slice(4, 12)}]: ${reason}`);// #8986 acceptance: cancelling an excerpt removes its partial output.await unlink(outputPath).catch(() => {});- broadcastSse(job, { type: canceled ? 'canceled' : 'error', error: reason });await finalize({ status: canceled ? 'canceled' : 'error', error: canceled ? null : reason, filename: null, jobId: null });+ broadcastSse(job, { type: canceled ? 'canceled' : 'error', error: reason });return;}try {@@ -251,8 +254,8 @@ export async function startExcerptRender(projectId, { startSec, endSec }) {job.lastError = reason;const log = canceled ? console.log : console.error;log(`${canceled ? '🛑' : '❌'} Music-video excerpt render ${canceled ? 'cancelled' : 'failed'} [${jobId.slice(4, 12)}]: ${reason}`);- broadcastSse(job, { type: canceled ? 'canceled' : 'error', error: reason });await finalize({ status: canceled ? 'canceled' : 'error', error: canceled ? null : reason, filename: null, jobId: null });+ broadcastSse(job, { type: canceled ? 'canceled' : 'error', error: reason });});return { jobId, excerptId };