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(mcp): refuse a camera crop and pan that place the framing in two spots
EtienneLescot2382b8ecdedf
diff --git a/electron/ai-edition/editor-settings-tool.test.ts b/electron/ai-edition/editor-settings-tool.test.tsindex cb939a6c5..d838e95ce 100644--- a/electron/ai-edition/editor-settings-tool.test.ts+++ b/electron/ai-edition/editor-settings-tool.test.ts@@ -184,6 +184,19 @@ describe("setEditorSettings", () => {expect(set(document, { webcamCropRegion: { x: 0, y: 0, width: 0.5, height: 0.6 } }).ok).toBe(false,);+ // A rect and a pan that disagree are refused; at full size any pan agrees.+ expect(+ set(framed, {+ webcamCropRegion: { x: 0, y: 0, width: 0.5, height: 0.5 },+ webcamCropPan: { x: 1, y: 0 },+ }).ok,+ ).toBe(false);+ expect(+ set(framed, {+ webcamCropRegion: { x: 0, y: 0, width: 1, height: 1 },+ webcamCropPan: { x: 1, y: 0 },+ }).ok,+ ).toBe(true);});it("says which of the settings it wrote change nothing in the current state", () => {diff --git a/electron/ai-edition/editor-settings-tool.ts b/electron/ai-edition/editor-settings-tool.tsindex 9bae3c603..f233494b0 100644--- a/electron/ai-edition/editor-settings-tool.ts+++ b/electron/ai-edition/editor-settings-tool.ts@@ -388,6 +388,18 @@ function editorPatch(document: AxcutDocument, args: SetEditorSettingsArgs): Editreturn patch;}+/** A rect and a pan sent together that place the window in two different spots. At full size+ * there is no room to place it in, so any pan agrees with the rect there. */+function cropFramingConflict(args: SetEditorSettingsArgs): string | null {+ const { webcamCropRegion: region, webcamCropPan: pan } = args;+ if (!region || !pan) return null;+ const agrees = (offset: number, size: number, share: number) =>+ Math.abs(offset - share * (1 - size)) < 1e-6;+ return agrees(region.x, region.width, pan.x) && agrees(region.y, region.height, pan.y)+ ? null+ : "webcamCropRegion and webcamCropPan place the framing in two different spots: send one of them, or both as getCurrentDocument returns them.";+}+/** Every key a patch sets, `cursor.*` for the cursor's: what the result reports as applied. */function patchKeys(patch: EditorSettingsPatch): string[] {const { cursor, ...rest } = patch;@@ -406,6 +418,8 @@ export function executeSetEditorSettings(if (!parsed.success) {return { ok: false, resultJson: JSON.stringify({ error: parsed.error.message }) };}+ const conflict = cropFramingConflict(parsed.data);+ if (conflict) return { ok: false, resultJson: JSON.stringify({ error: conflict }) };const patch = editorPatch(document, parsed.data);const keys = patchKeys(patch);if (keys.length === 0) {