Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(ai-edition): refuse a set that runs into a look-alike region
EtienneLescot0be3e1b82f57
diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.tsindex a5730b583..eb05f084a 100644--- a/electron/ai-edition/agent-tools.test.ts+++ b/electron/ai-edition/agent-tools.test.ts@@ -449,8 +449,8 @@ describe("executeAgentTool", () => {it("addZooms leaves overlapping regions overlapping, exactly as one-at-a-time does", () => {// A deliberate non-decision, pinned so it stays deliberate.//- // `timelineMap.ts` forbids two zooms of different identities from- // overlapping, but only the `set*` path clamps (via `replacePillSpan`) —+ // `timelineMap.ts` forbids a moved zoom from overlapping another zoom,+ // but only the `set*` path clamps (via `replacePillSpan`) —// no `add*` does, in the agent OR in the UI. So two overlapping addZoom// calls already produce an overlapping document today. Deconflicting// inside the batch would make `addZooms` mean something its unitary@@ -932,6 +932,29 @@ describe("executeAgentTool", () => {expect(executeAgentTool(document, "setZoom", JSON.stringify({ zoomId, startSec: 3, endSec: 4 })).ok,).toBe(true);++ // A look-alike is in the way too: the drag would stop against it (#1133), so a set is+ // refused rather than landed short of where it was asked.+ add("addZoom", { startSec: 12, endSec: 14, depth: 2 });+ expect(+ executeAgentTool(document, "setZoom", JSON.stringify({ zoomId, startSec: 13, endSec: 15 }))+ .ok,+ ).toBe(false);+ add("addSpeed", { startSec: 20, endSec: 22, speed: 2 });+ add("addSpeed", { startSec: 24, endSec: 26, speed: 2 });+ const speedId = (+ (document.legacyEditor as Record<string, unknown>).speedRegions as Array<{+ id: string;+ startMs: number;+ }>+ ).find((r) => r.startMs === 20_000)?.id;+ const speedBlocked = executeAgentTool(+ document,+ "setSpeed",+ JSON.stringify({ speedId, startSec: 23, endSec: 25 }),+ );+ expect(speedBlocked.ok).toBe(false);+ expect(speedBlocked.resultJson).toMatch(/cannot overlap/);});it("snapshot exposes clips/trims/effects as virtual-time groups with a time-base note", () => {diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.tsindex de60eea44..e32527548 100644--- a/electron/ai-edition/agent-tools.ts+++ b/electron/ai-edition/agent-tools.ts@@ -134,12 +134,13 @@ function resolveSpanMs(/*** For the effect set* tools: the region another span of the same kind would have to cross.*- * `replacePillSpan` follows the editor's drag rule: a region dragged into a neighbour with other- * settings stops against it, part of the way back to where it started. That is right under a+ * `replacePillSpan` follows the editor's drag rule: a region dragged into a neighbour stops+ * against it, part of the way back to where it started. That is right under a* mouse, which shows the stop as it happens. For a caller who named an exact span it put the* region somewhere it never asked for (asked 7.6 – 9.5 s, landed 1.5 – 3.3 s), so a set that* would be stopped is refused instead, naming what is in the way. The neighbours are the same- * walls the drag rule sees: other pills with other settings, not ones the region already overlaps.+ * walls the drag rule sees: every other pill, look-alikes included (#1133), but not one the region+ * already overlaps.*/function refuseIfBlocked<T extends { id: string; startMs: number; endMs: number }>(kind: string,@@ -155,7 +156,6 @@ function refuseIfBlocked<T extends { id: string; startMs: number; endMs: numberconst wall = pills.find((other) =>other !== pill &&- other.identity !== pill.identity &&(other.end <= pill.start || other.start >= pill.end) &&other.start < end &&other.end > start,@@ -163,8 +163,8 @@ function refuseIfBlocked<T extends { id: string; startMs: number; endMs: numberif (!wall) return null;return failure(`The ${kind} was NOT changed: ${formatSec(start)} – ${formatSec(end)} would run into ${kind} ` +- `${wall.ids[0]} at ${formatSec(wall.start)} – ${formatSec(wall.end)}, and two ${kind}s with ` +- "different settings cannot overlap. Move or shorten that one first, or pick a span clear of it.",+ `${wall.ids[0]} at ${formatSec(wall.start)} – ${formatSec(wall.end)}, and two ${kind}s ` ++ "cannot overlap. Move or shorten that one first, or pick a span clear of it.",);}