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(background): carry an old blur switch through reverse migration and look copy

EtienneLescot2217424e97f0
diff --git a/src/lib/ai-edition/document/migrate.test.ts b/src/lib/ai-edition/document/migrate.test.ts
index dd74fa1d5..385f11a2c 100644
--- a/src/lib/ai-edition/document/migrate.test.ts
+++ b/src/lib/ai-edition/document/migrate.test.ts
@@ -354,6 +354,16 @@ describe("migrateAxcutDocumentToProjectData", () => {
expect(back.editor.webcamMaskShape).toBe("circle");
});
+ it("reads a legacyEditor blur switch as the amount it drew", () => {
+ const doc = migrateProjectDataToAxcutDocument(makeV2Project());
+ const { backgroundBlur: _amount, ...legacy } = doc.legacyEditor as Record<string, unknown>;
+ const back = migrateAxcutDocumentToProjectData({
+ ...doc,
+ legacyEditor: { ...legacy, showBlur: true },
+ });
+ expect(back.editor.backgroundBlur).toBe(0.5);
+ });
+
it("defaults wallpaperMotion to none when legacyEditor lacks it", () => {
const doc = migrateProjectDataToAxcutDocument(makeV2Project());
const { wallpaperMotion: _omitted, ...legacy } = doc.legacyEditor as Record<string, unknown>;
diff --git a/src/lib/ai-edition/document/migrate.ts b/src/lib/ai-edition/document/migrate.ts
index 19b9c8f9b..8a387375e 100644
--- a/src/lib/ai-edition/document/migrate.ts
+++ b/src/lib/ai-edition/document/migrate.ts
@@ -21,6 +21,7 @@ import type {
TrimRegion,
ZoomRegion,
} from "@/components/video-editor/types";
+import { readBackgroundBlur } from "@/lib/projectDefaults";
import type { ProjectMedia } from "@/lib/recordingSession";
import {
type AxcutAnnotationRegion,
@@ -349,6 +350,9 @@ export function migrateAxcutDocumentToProjectData(input: AxcutDocument): EditorP
const legacy = document.legacyEditor;
if (legacy && typeof legacy === "object") {
Object.assign(editor, legacy);
+ // A document from before the amount holds only the `showBlur` switch; the default 0
+ // above would otherwise win over it once the project is read back.
+ editor.backgroundBlur = readBackgroundBlur(legacy, 0);
}
const reverseZoomRegions: ZoomRegion[] = (document.zoomRanges ?? []).map((region) => ({
diff --git a/src/lib/ai-edition/stylePresets.ts b/src/lib/ai-edition/stylePresets.ts
index d72ef8b75..f7cbe68e9 100644
--- a/src/lib/ai-edition/stylePresets.ts
+++ b/src/lib/ai-edition/stylePresets.ts
@@ -460,12 +460,17 @@ export function stylePresetLegacyEditor(appearance: StylePresetAppearance): Fiel
* audio, format and everything else that belongs to that footage stay behind. */
export function lookFromLegacyEditor(legacyEditor: unknown): Fields {
if (!isRecord(legacyEditor)) return {};
- return Object.fromEntries(
+ const look: Fields = Object.fromEntries(
LOOK_LEGACY_EDITOR_KEYS.filter((key) => legacyEditor[key] !== undefined).map((key) => [
key,
legacyEditor[key],
]),
);
+ // A project from before the amount holds only the old switch, under a key the list drops.
+ if (look.backgroundBlur === undefined && typeof legacyEditor.showBlur === "boolean") {
+ look.backgroundBlur = legacyEditor.showBlur ? LEGACY_BACKGROUND_BLUR_ON : 0;
+ }
+ return look;
}
/** Validates a parsed preset file (the JSON value, not the text). */
diff --git a/src/lib/ai-edition/stylePresetsEditor.test.ts b/src/lib/ai-edition/stylePresetsEditor.test.ts
index 4da39fbc0..0308dc39f 100644
--- a/src/lib/ai-edition/stylePresetsEditor.test.ts
+++ b/src/lib/ai-edition/stylePresetsEditor.test.ts
@@ -169,6 +169,12 @@ describe("new-project look (main-process side)", () => {
expect(lookFromLegacyEditor(null)).toEqual({});
});
+ it("carries the old background blur switch as the amount it drew", () => {
+ expect(lookFromLegacyEditor({ showBlur: true }).backgroundBlur).toBe(0.5);
+ expect(lookFromLegacyEditor({ showBlur: false }).backgroundBlur).toBe(0);
+ expect(lookFromLegacyEditor({ showBlur: true, backgroundBlur: 0.2 }).backgroundBlur).toBe(0.2);
+ });
+
it("carries the old always-arrow switch of a project saved before the cursor kinds", () => {
const look = lookFromLegacyEditor({ cursorAlwaysArrow: true, cropRegion: { x: 0.2 } });
expect(getEditorSettings(docWith(look)).cursor.asArrow).toEqual(CURSOR_KIND_IDS);