From 59b03f29483ef4d68f67d1a95aca52ba23a31bcb Mon Sep 17 00:00:00 2001 From: Korg1ch <57859048+Korg1ch@users.noreply.github.com> Date: Mon, 19 Oct 2026 05:53:29 +0300 Subject: [PATCH 1/2] fix(atn): a Minimum / Maximum step with Preserve: Roundness is not exported as Squareness (#7233) --- crates/engine/src/atn_cmds.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rs index 9e8eb6cb7ca..b80a6fece54 100644 --- a/crates/engine/src/atn_cmds.rs +++ b/crates/engine/src/atn_cmds.rs @@ -872,6 +872,11 @@ struct Event { macro_rules! ev { ($code:literal, $name:literal, $label:literal, $id:literal, $fields:expr) => { + ev!($code, $name, $label, $id, $fields, unless | _ | false) + }; + // `unless`: params the descriptor can't carry, so such a step isn't exported (it would replay + // differently) rather than losing them. + ($code:literal, $name:literal, $label:literal, $id:literal, $fields:expr, unless $skip:expr) => { Event { code: $code, name: $name, @@ -881,11 +886,18 @@ macro_rules! ev { Some(m) => step($id, Value::Object(m)), None => Mapped::Unsupported { harmless: false }, }, - to: |_, p| if pixel_target(p) { fields_to(p, $fields, desc("null")) } else { None }, + to: |_, p| if pixel_target(p) && !($skip)(p) { fields_to(p, $fields, desc("null")) } else { None }, } }; } +/// Minimum / Maximum with Preserve: Roundness. The descriptor here maps the radius only, and +/// Photoshop's encoding of the shape isn't verified, so such a step is not exported: it would +/// replay as the default Squareness (#7233). +fn preserves_roundness(p: &Value) -> bool { + p.get("preserve").and_then(Value::as_str) == Some("roundness") +} + /// Whether `p` edits the layer's pixels: no `"target"` or `"target":"pixels"`. Photoshop's /// descriptor for a plain event has no field for a mask, Quick Mask or channel target, so such /// a step can't be exported faithfully. @@ -2718,8 +2730,8 @@ const EVENTS: &[Event] = &[ ev!("ShrM", "sharpenMore", "Sharpen More", "filter.sharpen.sharpenMore", &[]), ev!("ShrE", "sharpenEdges", "Sharpen Edges", "filter.sharpen.sharpenEdges", &[]), ev!("HghP", "highPass", "High Pass", "filter.other.highPass", &[F("Rds ", "radius", Kind::Px)]), - ev!("Mnm ", "minimum", "Minimum", "filter.other.minimum", &[F("Rds ", "radius", Kind::Px)]), - ev!("Mxm ", "maximum", "Maximum", "filter.other.maximum", &[F("Rds ", "radius", Kind::Px)]), + ev!("Mnm ", "minimum", "Minimum", "filter.other.minimum", &[F("Rds ", "radius", Kind::Px)], unless preserves_roundness), + ev!("Mxm ", "maximum", "Maximum", "filter.other.maximum", &[F("Rds ", "radius", Kind::Px)], unless preserves_roundness), ev!( "Ofst", "offset", From ec0fc7cb0e1aae518e1ea572494e6b626852856d Mon Sep 17 00:00:00 2001 From: Korg1ch <57859048+Korg1ch@users.noreply.github.com> Date: Mon, 19 Oct 2026 05:53:29 +0300 Subject: [PATCH 2/2] test(atn): strict export refuses Minimum / Maximum with Roundness; Squareness round-trips (#7233) --- crates/engine/src/atn_cmds/tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rs index 26865d40609..1e1e9a0d8bf 100644 --- a/crates/engine/src/atn_cmds/tests.rs +++ b/crates/engine/src/atn_cmds/tests.rs @@ -1267,6 +1267,28 @@ fn save_while_recording_includes_pending_steps() { assert_eq!(action["steps"].as_array().unwrap().len(), 2, "both steps must be present without duplication"); } +/// #7233: the Minimum / Maximum descriptor carries the radius only, so a step with Preserve: +/// Roundness is refused by strict export (and left out, reported, otherwise) instead of replaying +/// as the default Squareness. Squareness, explicit or by default, still round-trips. +#[test] +fn minimum_and_maximum_with_roundness_are_not_exported_as_squareness() { + for id in ["filter.other.minimum", "filter.other.maximum"] { + let round = Action { name: "Round".into(), steps: vec![(id.into(), json!({"radius": 2, "preserve": "roundness"}))], ..Default::default() }; + assert!(export("Audit", &[&round], &[], false).is_err(), "{id}: strict export refuses it"); + let (_, skipped) = export("Audit", &[&round], &[], true).unwrap(); + assert_eq!(skipped, vec![Skipped { action: "Round".into(), step: 0, id: id.into() }], "{id}"); + for p in [json!({"radius": 2}), json!({"radius": 2, "preserve": "squareness"})] { + let square = Action { name: "Square".into(), steps: vec![(id.into(), p.clone())], ..Default::default() }; + let (bytes, skipped) = export("Audit", &[&square], &[], false).unwrap(); + assert!(skipped.is_empty(), "{id} {p}"); + let imported = import(&bytes).unwrap(); + let (got, params) = &imported.actions[0].steps[0]; + assert_eq!((got.as_str(), params["radius"].as_f64()), (id, Some(2.0)), "{id} {p}"); + assert!(params.get("preserve").is_none_or(|v| v == "squareness"), "{id} {p}: {params}"); + } + } +} + /// Photoshop's Close has no document target: a Close of a specific document must not be /// exported as a plain Close, which would close the active document on playback. #[test]