Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/development/images/heif-377/node-en-US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/development/lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u
- **Media representation follow-up:** [Issue #282](https://github.com/ThinkFlowLab/OpenDirector/issues/282) exposed copy/export paths that read displayed pixels and archive imports that displayed unsupported original bytes. A browser preview and an original asset need distinct read paths while retaining the same asset identity. Verify original bytes through download, fresh publication, cross-project paste fallback and archive round trips, including the first display after import. [PR #287 review](https://github.com/ThinkFlowLab/OpenDirector/pull/287#pullrequestreview-5857373679) also exposed missing MIME-extension mappings and a fallback that could name preview PNG bytes as HEIC. Carry the expected original type into readers, reject a missing original, and check timeline/FCPXML packages as well as canvas archives.

- **Upload acknowledgement follow-up:** Investigating [PR #287's camera sample](https://github.com/ThinkFlowLab/OpenDirector/pull/287#pullrequestreview-5868923062) reproduced a failed preview being swallowed into a successfully saved empty generation item. Require a usable preview before completing a HEIF import, and assert the failure leaves the original registered without creating an empty item. Slow uploads also crossed the first save acknowledgement: default expansion and model display labels were mistaken for user edits. Compare effective settings while retaining actual content, model, frame-selection and lock conflicts; exercise upload into a newly created node and its reference composer before the first save finishes.
- **Quality-default follow-up:** [Issue #377](https://github.com/ThinkFlowLab/OpenDirector/issues/377) reproduced the new-node HEIF upload failure again: image projection expands omitted quality to `auto`, while edit comparison still distinguished those equivalent values. Cover actual projected defaults in both upload guards and generation edit identities, retain rejection of explicit quality changes, and assert that the original node ID binds the uploaded asset before and after reopening. A synthetic saved-settings fixture that omits a projection default can pass while the browser path fails.

- **Color profile follow-up:** [PR #287's P3 review](https://github.com/ThinkFlowLab/OpenDirector/pull/287#pullrequestreview-5870014881) found that a correct full-size PNG did not prove correct thumbnails: the library JPEG and the asset/history WebP used separate encoders that both omitted ICC. Check every displayed rendition and the actual embedded profile, not only dimensions or successful decoding. Preserve RGB profiles through resizing, but do not attach a non-RGB source profile after converting its channels to RGB. / **颜色配置补充:** 同一素材的全尺寸 PNG 正确,并不能证明素材库 JPEG 和资产/版本历史 WebP 正确。逐条检查显示路径的实际 ICC;缩放保留 RGB 配置,转换通道后不能继续附带非 RGB 源配置。

Expand Down
2 changes: 2 additions & 0 deletions src/canvas/generationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export function getNodeGenerationSettings(
export function generationEditSettings(node: CanvasNode) {
if (!["image", "video", "audio"].includes(node.type)) return node.data.settings;
const settings = getNodeGenerationSettings(node);
// Image save receipts expand an omitted quality to the same effective default.
if (node.type === "image") settings.imageQuality ??= "auto";
if (settings.videoMode !== "first-last") delete settings.frameSlotsInitialized;
return { ...settings, model: settings.modelConfigId ? "" : settings.model };
}
Expand Down
14 changes: 11 additions & 3 deletions tests/browser/heif_upload_recovery.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ try {
await page.goto(`${base}/ai-tool/ai-canvas/${id}?creation=unified`);
await page.locator(".cw-language-toggle").getByRole("button", { name: en ? "EN" : "中文", exact: true }).click();
await page.getByText(saved, { exact: true }).waitFor();
let targetNodeId;
let uploadStarted;
const uploading = new Promise(resolve => { uploadStarted = resolve; });
const onRequest = request => {
Expand All @@ -65,7 +66,7 @@ try {
await route.fulfill({ status: 404, contentType: "application/json", body: JSON.stringify({ detail: "Preview unavailable" }) });
return;
}
await until(snapshot, value => value.canvasItems.length === 1, "initial node save");
await until(snapshot, value => value.canvasItems.some(item => item.id === targetNodeId), "initial target node save");
await page.getByText(saved, { exact: true }).waitFor();
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
await page.unroute("**/browser-image", previewRoute);
Expand All @@ -78,6 +79,8 @@ try {
await page.route("**/browser-image", previewRoute);
await page.getByRole("button", { name: mode === "video-reference"
? (en ? "Add Video" : "添加视频") : (en ? "Add Image" : "添加图片"), exact: true }).click();
targetNodeId = await page.locator(".react-flow__node").getAttribute("data-id");
assert.ok(targetNodeId, "capture the original upload target identity");
} else if (mode === "failure") await page.route("**/browser-image", previewRoute);
const upload = { name, mimeType: "application/octet-stream", buffer: bytes };
if (mode === "node") {
Expand Down Expand Up @@ -106,7 +109,7 @@ try {
} else {
const stored = await until(snapshot, value => reference
? value.references.some(ref => ref.active)
: value.canvasItems.some(item => item.binding.role === "material"), mode);
: value.canvasItems.some(item => (!targetNodeId || item.id === targetNodeId) && item.binding.role === "material"), mode);
assert.equal(stored.assets.length, 1);
const asset = stored.assets[0];
assert.equal(asset.metadata.mimeType, "image/heic");
Expand All @@ -128,7 +131,12 @@ try {
const ref = stored.references.find(ref => ref.active);
const source = stored.canvasItems.find(item => item.id === ref.source.id);
assert.equal(source.binding.objectRef.assetId, asset.id);
} else assert.equal(stored.canvasItems.length, 1);
} else {
assert.equal(stored.canvasItems.length, 1);
const item = stored.canvasItems[0];
if (targetNodeId) assert.equal(item.id, targetNodeId);
assert.equal(item.binding.objectRef.assetId, asset.id);
}
}
await page.screenshot({ path: `test-results/heif/recovery/${mode}-${locale}.png`, fullPage: true });
console.log(`PASS ${mode} ${locale} ${name}`);
Expand Down
21 changes: 21 additions & 0 deletions tests/canvasWorkspaceEntry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ import {

setActiveLocale("zh-CN");

test("image quality defaults from save receipts preserve upload and edit identity", () => {
for (const locale of ["zh-CN", "en-US"] as const) {
setActiveLocale(locale);
const draft = createNode("image", undefined, {
settings: { ...generationDefaults("image"), modelConfigId: "image-model" },
});
const saved = { ...draft, data: { ...draft.data,
settings: { ...draft.data.settings!, imageQuality: "auto" as const } } };
assert.equal(uploadTargetUnchanged(saved, draft), true, locale);
assert.equal(uploadTargetUnchanged(draft, saved), true, locale);
assert.equal(generationEditIdentity(saved, []), generationEditIdentity(draft, []), locale);
for (const imageQuality of ["low", "medium", "high"] as const) {
const edited = { ...saved, data: { ...saved.data,
settings: { ...saved.data.settings, imageQuality } } };
assert.equal(uploadTargetUnchanged(edited, draft), false, imageQuality);
assert.notEqual(generationEditIdentity(edited, []), generationEditIdentity(draft, []));
}
}
setActiveLocale("zh-CN");
});

test("upload guards accept saved defaults but reject edits to content and settings", () => {
const draft = createNode("image", undefined, {
settings: { ...generationDefaults("image"), model: "Configured image model", modelConfigId: "image-model", resolution: "auto", voiceName: undefined },
Expand Down
Loading