Skip to content

Commit 9226140

Browse files
committed
fix(mcp): offer auto only while the timeline holds one composition, keep the current format writable
Part of #1180
1 parent afe88da commit 9226140

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

‎electron/ai-edition/editor-settings-tool.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,31 @@ describe("setEditorSettings", () => {
123123
const vertical = set(document, { aspectRatio: "9:16" });
124124
expect(JSON.parse(vertical.resultJson).applied).toEqual(["aspectRatio", "formatFollowCursor"]);
125125
expect(getEditorSettings(vertical.document as AxcutDocument).formatFollowCursor).toBe(true);
126+
// Two shapes on the timeline: auto is not offered, as in the picker.
127+
const mixed = documentSchema.parse({
128+
...document,
129+
assets: [
130+
...document.assets,
131+
{ ...document.assets[0], id: "asset_2", video: { width: 1080, height: 1920 } },
132+
],
133+
timeline: {
134+
...document.timeline,
135+
clips: [
136+
...document.timeline.clips,
137+
{
138+
...document.timeline.clips[0],
139+
id: "clip_2",
140+
assetId: "asset_2",
141+
timelineStartSec: 30,
142+
timelineEndSec: 60,
143+
},
144+
],
145+
},
146+
});
147+
expect(
148+
set(set(mixed, { aspectRatio: "9:16" }).document as AxcutDocument, { aspectRatio: "auto" })
149+
.ok,
150+
).toBe(false);
126151
// The alias takes the same shapes.
127152
expect(
128153
executeAgentTool(document, "setAspectRatio", JSON.stringify({ aspectRatio: "683:384" })).ok,

‎electron/ai-edition/editor-settings-tool.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,14 @@ export function editorSettingsSnapshot(
329329
};
330330
}
331331

332-
/** `"auto"`, a preset, or one of the timeline's own shapes: what the format picker offers. */
332+
/** What the format picker offers: auto (while the timeline holds one composition), a preset, or
333+
* one of the timeline's own shapes. The current value always passes, so a read written back
334+
* as is never fails on it. */
333335
function aspectRatioError(document: AxcutDocument, value: string): string | null {
334336
const original = collectNativeFormats(document).map((f) => f.token);
335-
const allowed = ["auto", ...ASPECT_RATIO_PRESETS, ...original];
336-
return allowed.includes(value)
337+
const auto = isAutoFormatAvailable(document) ? ["auto"] : [];
338+
const allowed = [...auto, ...ASPECT_RATIO_PRESETS, ...original];
339+
return allowed.includes(value) || value === getEditorSettings(document).aspectRatio
337340
? null
338341
: `aspectRatio ${JSON.stringify(value)} is not offered for this project. Use one of: ${allowed.join(", ")}.`;
339342
}

0 commit comments

Comments
 (0)