setSequencerTransitions parsed the submitted timeline without comparing timeline.revision, so a stale submission replaced the sequencer timeline instead of conflicting. It now compares timeline.revision against the current SceneIR and reports REVISION_CONFLICT, which is the check setSequencerStrips already makes. The revision contract moves the command out of the unchecked set, and the authoring probe takes its timeline from a snapshot read after its edits and records a stale submission next to an accepted one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
51 lines
3.6 KiB
TypeScript
51 lines
3.6 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { test, expect } from "@playwright/test";
|
|
import { observeNative } from "../fixtures/native-ui-workflow";
|
|
|
|
const root = path.resolve(import.meta.dirname, "../../..");
|
|
|
|
test("sequencer color balance and modifiers reach native Main", async ({ page }) => {
|
|
test.setTimeout(300_000);
|
|
await observeNative(page);
|
|
await page.goto("/");
|
|
await page.getByTestId("blend-file-input").setInputFiles(path.join(root, "blender-5.2.0/tests/files/sequence_editing/effects/fx_comp.blend"));
|
|
await expect.poll(async () => page.locator("main.blender-app").evaluate((n) => (n as HTMLElement).dataset.projectId), { timeout: 60000 }).not.toBe("");
|
|
await expect(page.getByTestId("engine-status")).toContainText("SceneIR", { timeout: 60000 });
|
|
const out = await page.evaluate(async () => {
|
|
const worker = (window as any).__nativeWorkflowEngine as Worker;
|
|
const send = (command: any) => new Promise<any>((resolve, reject) => {
|
|
const requestId = `seq-${crypto.randomUUID()}`;
|
|
const receive = (event: MessageEvent) => {
|
|
if (event.data?.requestId !== requestId || event.data?.kind !== 'result') return;
|
|
worker.removeEventListener('message', receive);
|
|
if (event.data.ok) resolve(event.data.result); else reject(Object.assign(new Error(`${event.data.error?.code}: ${event.data.error?.message}`), { detail: event.data.error }));
|
|
};
|
|
worker.addEventListener('message', receive); worker.postMessage({ requestId, command });
|
|
});
|
|
const snapshot = (await send({ type: 'snapshot' })).snapshot as any;
|
|
const scene = snapshot.scenes[0];
|
|
const timeline = scene.sequencer ?? scene.sequencerTimeline ?? null;
|
|
const strips = timeline?.strips ?? [];
|
|
const strip = strips[0] ?? null;
|
|
const log: any = { sceneId: scene.id, revision: snapshot.revision, stripCount: strips.length, strip: strip && { id: strip.id, type: strip.type } };
|
|
if (!strip) return log;
|
|
const apply = (payload: any) => send({ type: 'applyCommand', payload }).then((r: any) => r?.status ?? 'ok', (e: Error) => `ERR ${e.message}`);
|
|
log.colorBalance = await apply({ type: 'setSequencerColorBalance', sceneId: scene.id, stripId: strip.id, colorBalance: { lift: [0.9, 1.0, 1.1], gamma: [1.0, 1.0, 1.0], gain: [1.2, 1.0, 0.8], exposure: 0, contrast: 1, saturation: 1.2 } });
|
|
log.modifiers = await apply({ type: 'setSequencerStripModifiers', sceneId: scene.id, stripId: strip.id, modifiers: [
|
|
{ id: `${strip.id}:cb`, type: 'COLOR', enabled: true },
|
|
{ id: `${strip.id}:bc`, type: 'BRIGHT_CONTRAST', enabled: false },
|
|
] });
|
|
/* The transition command now rejects a stale timeline revision, so take the
|
|
* timeline from a snapshot read after the two edits above. */
|
|
const freshScene = (await send({ type: 'snapshot' })).snapshot.scenes[0];
|
|
log.transitions = await apply({ type: 'setSequencerTransitions', sceneId: scene.id, timeline: freshScene.sequencer ?? freshScene.sequencerTimeline ?? null });
|
|
log.staleTransitions = await apply({ type: 'setSequencerTransitions', sceneId: scene.id, timeline });
|
|
log.after = await send({ type: 'snapshot' }).then((r: any) => ({ revision: r.snapshot.revision, strips: (r.snapshot.scenes[0].sequencer?.strips ?? []).length }), (e: Error) => `ERR ${e.message}`);
|
|
log.undo = await send({ type: 'applyCommand', payload: { type: 'undo' } }).then((r: any) => r?.status ?? 'ok', (e: Error) => `ERR ${e.message}`);
|
|
log.redo = await send({ type: 'applyCommand', payload: { type: 'redo' } }).then((r: any) => r?.status ?? 'ok', (e: Error) => `ERR ${e.message}`);
|
|
return log;
|
|
});
|
|
fs.writeFileSync("/tmp/sequencer-authoring.json", JSON.stringify(out, null, 2));
|
|
});
|