From 99cb8a2f8e37e7c338d3f57bd1156dc6c1f506cb Mon Sep 17 00:00:00 2001 From: wangtiance Date: Sat, 28 Nov 2026 12:35:56 +0800 Subject: [PATCH] [bugfix] Preserve HEIF uploads across image preset defaults --- docs/development/lessons.md | 1 + src/canvas/generationSettings.ts | 7 +++++-- tests/canvasWorkspaceEntry.test.ts | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/development/lessons.md b/docs/development/lessons.md index 03b556ee8..f012d62d0 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -33,6 +33,7 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **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. - **Large media import:** A Windows Electron renderer exited with a V8 Zone OOM while importing a 128 MiB MP4. The crash log did not identify the failing allocation. Source inspection found whole-file data URL conversion before the shared upload API. Use the original File for audio and video imports and verify the saved asset fingerprint through the file picker flow. Upload-only benchmarks start after file selection and miss renderer work before the request. - **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. +- **Preset-default follow-up:** [Nightly 46089353845](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/46089353845/job/140806362007) reproduced the empty-node upload when projection began filling an omitted face-emphasis flag with `false`. The upload guard and generation edit identity must treat both forms as the same default and still detect explicit enablement. - **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 源配置。 diff --git a/src/canvas/generationSettings.ts b/src/canvas/generationSettings.ts index b49e6b693..5b910dcef 100644 --- a/src/canvas/generationSettings.ts +++ b/src/canvas/generationSettings.ts @@ -84,8 +84,11 @@ 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"; + // Image save receipts can fill defaults without changing the draft. + if (node.type === "image") { + settings.imageQuality ??= "auto"; + settings.faceEmphasis ??= false; + } if (settings.videoMode !== "first-last") delete settings.frameSlotsInitialized; return { ...settings, model: settings.modelConfigId ? "" : settings.model }; } diff --git a/tests/canvasWorkspaceEntry.test.ts b/tests/canvasWorkspaceEntry.test.ts index 234dc20ce..c85b174b2 100644 --- a/tests/canvasWorkspaceEntry.test.ts +++ b/tests/canvasWorkspaceEntry.test.ts @@ -23,17 +23,21 @@ import { setActiveLocale("zh-CN"); -test("image quality defaults from save receipts preserve upload and edit identity", () => { +test("image 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 } } }; + settings: { ...draft.data.settings!, imageQuality: "auto" as const, faceEmphasis: false } } }; assert.equal(uploadTargetUnchanged(saved, draft), true, locale); assert.equal(uploadTargetUnchanged(draft, saved), true, locale); assert.equal(generationEditIdentity(saved, []), generationEditIdentity(draft, []), locale); + const emphasized = { ...saved, data: { ...saved.data, + settings: { ...saved.data.settings, faceEmphasis: true } } }; + assert.equal(uploadTargetUnchanged(emphasized, draft), false, locale); + assert.notEqual(generationEditIdentity(emphasized, []), generationEditIdentity(draft, []), locale); for (const imageQuality of ["low", "medium", "high"] as const) { const edited = { ...saved, data: { ...saved.data, settings: { ...saved.data.settings, imageQuality } } };