From d1bf36c6665b2fac3b42ddc066a0cf4cc3a65e7e Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Tue, 18 Aug 2026 15:26:45 +0200 Subject: [PATCH] fix(dashboard): recut duration display and stale durable URL - A recut clip's start/end are the covering source range, so end - start showed a 20s two-segment clip as minutes long; duration now sums the recipe segments when present. - Drop the clip's durable R2 URL after a rerender: archive_clip_edit deletes the superseded object, so the stale URL would 404 as the playback fallback. --- dashboard/src/App.jsx | 8 ++++++++ dashboard/src/components/ResultCard.jsx | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index d0e82bd..aa9e4ef 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -309,6 +309,14 @@ function App() { : c)), }; }); + // The old durable R2 object is deleted when the recut is archived, so the + // stale URL would 404 as a fallback; drop it until the next refresh. + setDurableClips((prev) => { + if (!(index in prev)) return prev; + const next = { ...prev }; + delete next[index]; + return next; + }); handleClipStateChange(index, { activeLayers: null, serverVideoFile: newFile }); }; diff --git a/dashboard/src/components/ResultCard.jsx b/dashboard/src/components/ResultCard.jsx index 0f55816..c25bf00 100644 --- a/dashboard/src/components/ResultCard.jsx +++ b/dashboard/src/components/ResultCard.jsx @@ -19,8 +19,18 @@ const PLATFORM_OPTIONS = [ { value: 'youtube', label: 'youtube', icon: }, ]; +function clipDurationSeconds(clip) { + // A recut clip's start/end are the covering source range (segments may be + // non-contiguous or reordered); its real duration is the segment sum. + const segments = clip.recipe?.segments; + if (segments?.length) { + return segments.reduce((acc, s) => acc + (s.end - s.start), 0); + } + return clip.end && clip.start ? clip.end - clip.start : NaN; +} + function formatDuration(clip) { - const secs = clip.end && clip.start ? Math.floor(clip.end - clip.start) : NaN; + const secs = Math.floor(clipDurationSeconds(clip)); if (!Number.isFinite(secs) || secs < 0) return null; return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`; } @@ -126,7 +136,10 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK const [showTranslateModal, setShowTranslateModal] = useState(false); const [editError, setEditError] = useState(null); - const [clipDuration, setClipDuration] = useState(clip.end && clip.start ? clip.end - clip.start : 30); + const [clipDuration, setClipDuration] = useState(() => { + const secs = clipDurationSeconds(clip); + return Number.isFinite(secs) ? secs : 30; + }); // Accumulate Remotion layers across operations. A reopened project restores // the layers persisted in its project state, so the next edit composes over