From 17f149e73c3e1ef5a288294c2f37195f0b71bfd0 Mon Sep 17 00:00:00 2001 From: abc2cb <271337822+abc2cb@users.noreply.github.com> Date: Thu, 22 Oct 2026 00:14:11 +0300 Subject: [PATCH] Smart Filters: one command builder for OK, mask thumbnails keyed by size - smart_ui.rs: confirm_command sends every Smart Filter edit through smart_filter_dialog::edit_command, the builder the canvas preview already uses, so preview and OK cannot build different payloads. - lib.rs: the mask thumbnail cache revision includes the document height as well as the width. Two documents that restore the same layer id and width no longer share a thumbnail framed for the other's height. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/lib.rs | 4 ++-- crates/ui-egui/src/smart_ui.rs | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index bac2d588e6c..7297dde8f85 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -2475,7 +2475,7 @@ impl PhotocraftApp { self.mask_thumb_kind(ctx, doc, id, mask, mask_thumbs_ui::THUMB_MASK) } - /// The thumbnail of `mask` under cache `kind`, re-rendered only when the mask's pixels or the document width change; Smart Filter and layer masks are cached apart. + /// The thumbnail of `mask` under cache `kind`, re-rendered only when the mask's pixels or the document size change; Smart Filter and layer masks are cached apart. pub(crate) fn mask_thumb_kind( &mut self, ctx: &egui::Context, @@ -2484,7 +2484,7 @@ impl PhotocraftApp { mask: &photocraft_doc::LayerMask, kind: u8, ) -> egui::TextureId { - let rev = surface_fingerprint(&mask.surface) ^ (doc.size.width as u64) << 40; + let rev = surface_fingerprint(&mask.surface) ^ (doc.size.width as u64) << 40 ^ (doc.size.height as u64) << 16; let key = (id, kind); if let Some((r, tex)) = self.thumbs.get(&key) && *r == rev diff --git a/crates/ui-egui/src/smart_ui.rs b/crates/ui-egui/src/smart_ui.rs index f924323b7d1..65dbc45b733 100644 --- a/crates/ui-egui/src/smart_ui.rs +++ b/crates/ui-egui/src/smart_ui.rs @@ -396,16 +396,11 @@ pub fn preview_command<'a>(fields: &serde_json::Map, command: &'a /// The command a confirmed filter dialog runs: smart-filter edits update the recorded filter. pub fn confirm_command(app: &PhotocraftApp, fields: &serde_json::Map, command: String, params: Value) -> Result<(String, Value), String> { - if crate::smart_filter_dialog::owns(fields) { + // One builder for the preview and for OK, so the two cannot differ. + if fields.contains_key("__smartFilter") { return crate::smart_filter_dialog::edit_command(app, fields); } - match fields.get("__smartFilter") { - Some(sf) => { - let (layer, index) = crate::smart_filter_dialog::validate_target(app, sf)?; - Ok(("layer.smartFilter.setParams".into(), json!({"layer": layer.0, "index": index, "params": params}))) - } - None => Ok((command, params)), - } + Ok((command, params)) } #[cfg(test)]