The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
fix(ui): a trim no longer swallows an accumulated track change
Jareerd759a13bc39e
diff --git a/desktop/src/lib/editor-echo.test.ts b/desktop/src/lib/editor-echo.test.tsindex b5a23c2b..320d799c 100644--- a/desktop/src/lib/editor-echo.test.ts+++ b/desktop/src/lib/editor-echo.test.ts@@ -66,13 +66,22 @@ describe("commandsForEcho: moves", () => {]);});- test("a trackId echoed back unchanged still emits the move", () => {- // Current behaviour, pinned deliberately: dropping a clip back onto its- // own track at its own start commits a do-nothing MoveClips (and so an- // empty undo step). If this ever changes to [], that is an improvement -- // update this expectation, not the caller.- expect(commandsForEcho(clip(), { trackId: "T1" })).toEqual([- { op: "moveClips", moves: [{ clipId: "c1", start: 0, trackId: "T1" }] },+ test("a trackId echoed back unchanged commits nothing", () => {+ // Dropping a clip back onto its own track at its own start is not an+ // edit: the same-value guard start and duration already have. It used to+ // commit a do-nothing MoveClips and burn an empty undo step.+ expect(commandsForEcho(clip(), { trackId: "T1" })).toEqual([]);+ });++ test("a track change combined with a trim commits both", () => {+ // A busy panel's mixed accumulation: the head trim commits first (the+ // engine places the start), then the move carries the track - it used to+ // be silently lost in the trim's else-branch.+ expect(+ commandsForEcho(clip({ start: 2, duration: 4 }), { start: 3, duration: 3, trackId: "T2" }),+ ).toEqual([+ { op: "trimClip", clipId: "c1", edge: "start", delta: 1 },+ { op: "moveClips", moves: [{ clipId: "c1", start: 3, trackId: "T2" }] },]);});});diff --git a/desktop/src/lib/editor.ts b/desktop/src/lib/editor.tsindex 631d8195..78db9a15 100644--- a/desktop/src/lib/editor.ts+++ b/desktop/src/lib/editor.ts@@ -442,6 +442,10 @@ export function commandsForEcho(base: Clip, patch: Partial<Clip>): EditorCommand? patch.duration !== base.duration: false;const startChanged = has("start") && patch.start !== undefined && patch.start !== base.start;+ // Same-value guard, like start: an echoed-but-unchanged track must not+ // commit a do-nothing MoveClips, which would burn an empty undo step.+ const trackChanged =+ has("trackId") && patch.trackId !== undefined && patch.trackId !== base.trackId;if (durationChanged && startChanged) {commands.push({@@ -457,7 +461,14 @@ export function commandsForEcho(base: Clip, patch: Partial<Clip>): EditorCommandedge: "end",delta: (patch.duration ?? base.duration) - base.duration,});- } else if (startChanged || has("trackId")) {+ }++ // A move commits whatever the trims above did not. Not an else-branch: an+ // echo holding both a trim and a track change (a busy panel's mixed+ // accumulation) used to commit the trim and silently lose the move. After+ // a head trim the engine has already placed the start, so the move's start+ // - the same value - is idempotent and only the track genuinely applies.+ if (trackChanged || (startChanged && !durationChanged)) {commands.push({op: "moveClips",moves: [