Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(mcp): name the duplicated clip by id, and give every asset on a file its cursor read

EtienneLescotc489df4e0e0f
diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.ts
index af629ae70..98487a3d5 100644
--- a/electron/ai-edition/agent-tools.test.ts
+++ b/electron/ai-edition/agent-tools.test.ts
@@ -3607,6 +3607,18 @@ describe("clip structure (#1180)", () => {
expect(run(twoTakes(), "duplicateClip", { clipId: "clip_x" }).ok).toBe(false);
});
+ it("duplicateClip names the copy even when the clips before it fold together", () => {
+ // clip_1 and clip_2 already meet, so the pass after the copy makes them one clip and
+ // the copy is no longer at the original's index + 1.
+ const result = run(fixtureDocument(), "duplicateClip", { clipId: "clip_2" });
+ const { clipId } = JSON.parse(result.resultJson);
+ expect(result.ok).toBe(true);
+ expect((result.document as AxcutDocument).timeline.clips.map((c) => c.id)).toEqual([
+ "clip_1",
+ clipId,
+ ]);
+ });
+
it("setClipRange crops a clip without touching its range, and the snapshot reads it back", () => {
const crop = { x: 0.1, y: 0.2, width: 0.5, height: 0.6 };
const result = run(twoTakes(), "setClipRange", { clipId: "clip_1", cropRegion: crop });
diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.ts
index a2420cb9f..83ea23f9b 100644
--- a/electron/ai-edition/agent-tools.ts
+++ b/electron/ai-edition/agent-tools.ts
@@ -2474,12 +2474,17 @@ export function executeAgentTool(
const parsed = duplicateClipArgs.safeParse(args);
if (!parsed.success) return failure(parsed.error.message);
const { clipId } = parsed.data;
- const index = document.timeline.clips.findIndex((c) => c.id === clipId);
- if (index < 0) return failure(`Unknown clip: ${clipId}. ${clipRoster(document)}`);
+ if (!document.timeline.clips.some((c) => c.id === clipId)) {
+ return failure(`Unknown clip: ${clipId}. ${clipRoster(document)}`);
+ }
// The editor's Duplicate: the copy right after the original, with its own copy of
// the original's cuts and anchored effects.
const next = duplicateClip(document, clipId, "agent", "");
- const copy = next.timeline.clips[index + 1];
+ // By id, not position: the pass every clip edit ends with can fold clips that
+ // already met, which moves the positions.
+ const before = new Set(document.timeline.clips.map((c) => c.id));
+ const copy = next.timeline.clips.find((c) => !before.has(c.id));
+ if (!copy) return failure(`Clip ${clipId} could not be copied. Nothing was modified.`);
return {
ok: true,
document: next,
diff --git a/electron/ai-edition/deep-agent/service.ts b/electron/ai-edition/deep-agent/service.ts
index 408a2aa4d..e003a7460 100644
--- a/electron/ai-edition/deep-agent/service.ts
+++ b/electron/ai-edition/deep-agent/service.ts
@@ -375,10 +375,11 @@ async function planAutoZooms(
if (!cursor) return undefined;
const telemetry: AutoZoomPlan["telemetry"] = {};
const suggestions = await collectAutoZoomSuggestionsForDocument(document, async (videoPath) => {
- const asset = document.assets.find((a) => a.originalPath === videoPath);
- if (!asset) return [];
- const load = await readCursor(cursor, asset.id, videoPath);
- telemetry[asset.id] = load.status;
+ // The plan asks by path; every asset on that file gets the verdict of its one read.
+ const assets = document.assets.filter((a) => a.originalPath === videoPath);
+ if (assets.length === 0) return [];
+ const load = await readCursor(cursor, assets[0].id, videoPath);
+ for (const asset of assets) telemetry[asset.id] = load.status;
// The sidecar's samples, read as the renderer's `getTelemetry` reads them.
return load.status === "ok" ? (load.samples as CursorTelemetryPoint[]) : [];
});