From 60910bb9bbed7303efbfb157ded86afe0ed63c3e Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Mon, 23 Nov 2026 07:08:01 +0700 Subject: [PATCH] fix(ui-egui): strip undocumented dialog keys only after reshaping The closed-schema filter dropped Image Processor's jpeg/width rows before nest() turned them into the jpeg object the command takes, so OK wrote only a full-size JPEG. Apply Image is still on the incomplete list and needs sourceLayer, which the same filter had also removed. The filter now runs after nest() and the other command-specific rewrites, and it skips commands whose docs are still incomplete. --- crates/engine-core/src/lib.rs | 1 + crates/engine-core/src/param_check.rs | 5 +++++ crates/ui-egui/src/dialogs/filter_dialog.rs | 21 ++++++++++++--------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/engine-core/src/lib.rs b/crates/engine-core/src/lib.rs index f5be4d267e..77c5ba3cf9 100644 --- a/crates/engine-core/src/lib.rs +++ b/crates/engine-core/src/lib.rs @@ -35,6 +35,7 @@ pub mod memory; pub mod memory_gate; pub mod new_layer; mod param_check; +pub use param_check::is_incomplete; pub mod param_schema; mod pixels; pub mod prefs; diff --git a/crates/engine-core/src/param_check.rs b/crates/engine-core/src/param_check.rs index c37f4e79f6..062660fb15 100644 --- a/crates/engine-core/src/param_check.rs +++ b/crates/engine-core/src/param_check.rs @@ -144,6 +144,11 @@ pub(crate) fn check(spec: &CommandSpec, params: &Value) -> Result<()> { /// `"channel"`/`"targetChannel"` (`adjust_params` reads them for all kinds), and `_`-prefixed /// keys are the engine's own bookkeeping (a PSD-embedded displacement map, an imported action's /// descriptor), never typed by a caller. +/// Whether `id` is on the incomplete-docs list: unknown keys are not rejected yet. +pub fn is_incomplete(id: &str) -> bool { + INCOMPLETE.contains(&id) +} + fn implied(id: &str, key: &str) -> bool { (key == "layer" && id.starts_with("filter.")) || (id.starts_with("image.adjustments.") && matches!(key, "layer" | "channel" | "targetChannel")) diff --git a/crates/ui-egui/src/dialogs/filter_dialog.rs b/crates/ui-egui/src/dialogs/filter_dialog.rs index c50c79497a..95d38ed93c 100644 --- a/crates/ui-egui/src/dialogs/filter_dialog.rs +++ b/crates/ui-egui/src/dialogs/filter_dialog.rs @@ -683,15 +683,6 @@ pub(crate) fn command_params(command: &str, fields: &DialogFields) -> Value { if command == "image.adjustments.colorLookup" && map.get("data").and_then(Value::as_str).is_some_and(str::is_empty) { map.remove("data"); } - // Drop display-only and other keys a closed schema does not take (Bitmap's Input row is - // `inputResolution`; dispatch would reject it and OK would leave the document unchanged). - if let Some(spec) = photocraft_engine::commands::find(command) - && let Some(schema) = photocraft_engine::param_schema::of(spec) - && !schema.open() - { - const KEEP: &[&str] = &["coalesce", "target", "layer", "channel", "targetChannel", "document"]; - map.retain(|key, _| key.starts_with('_') || KEEP.contains(&key.as_str()) || schema.has_key(key)); - } if command == "image.mode.indexedColor" { // The matte colour row belongs to the "custom" choice, which the command takes as the colour itself. let color = map.remove(rows::MATTE_COLOR); @@ -723,6 +714,18 @@ pub(crate) fn command_params(command: &str, fields: &DialogFields) -> Value { if command == super::rotate_canvas_ui::COMMAND { super::rotate_canvas_ui::command_params(&mut map); } + // After dialog keys have been reshaped into command keys (Image Processor's jpeg/width + // becomes jpeg.width, and so on). Doing this earlier dropped those rows. + // Drop display-only and other keys a closed schema does not take (Bitmap's Input row is + // `inputResolution`; dispatch would reject it and OK would leave the document unchanged). + if let Some(spec) = photocraft_engine::commands::find(command) + && let Some(schema) = photocraft_engine::param_schema::of(spec) + && !schema.open() + && !photocraft_engine::is_incomplete(command) + { + const KEEP: &[&str] = &["coalesce", "target", "layer", "channel", "targetChannel", "document"]; + map.retain(|key, _| key.starts_with('_') || KEEP.contains(&key.as_str()) || schema.has_key(key)); + } params_of(&map) }