From cf5347b545ce65554cbf1378cfe0d161d8576a7c Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 22 Nov 2026 02:46:35 +0100 Subject: [PATCH] Integration: fix the batch 27 CI failures (fmt, null Image Size percent) - cargo fmt for the merged Tool list in paint_mouse.rs. - The #11516 fix refused an exported Image Size step with "percent": null, which main's review test treats as omitted. Native playback now omits a null percent like a null side or resolution, and export follows it, so both still agree. The null case moves from the invalid-percent test to a new native + round-trip test. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/atn_cmds/steps_doc.rs | 2 +- crates/engine/src/cmd/atn_cmds/tests.rs | 2 +- crates/engine/src/cmd/image_cmds.rs | 3 ++- .../engine/tests/it/atn_mapped_identifiers.rs | 25 +++++++++++++++++++ crates/ui-egui/src/canvas/paint_mouse.rs | 10 +++++++- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/atn_cmds/steps_doc.rs b/crates/engine/src/cmd/atn_cmds/steps_doc.rs index caa3393de6..2625254fb0 100644 --- a/crates/engine/src/cmd/atn_cmds/steps_doc.rs +++ b/crates/engine/src/cmd/atn_cmds/steps_doc.rs @@ -529,7 +529,7 @@ pub(super) fn image_size_to(_: &str, p: &Value) -> Option { }; // Native playback validates a supplied percentage even when explicit sides override it. // Dropping an invalid percentage would turn a refused action into a different, valid edit. - if p.get("percent").is_some_and(|value| value.as_f64().is_none_or(|pc| !pc.is_finite() || pc <= 0.0)) { + if p.get("percent").is_some_and(|value| !value.is_null() && value.as_f64().is_none_or(|pc| !pc.is_finite() || pc <= 0.0)) { return None; } // Resolution only with Resample on imports as keep-print-size; a command without it cannot be told apart. diff --git a/crates/engine/src/cmd/atn_cmds/tests.rs b/crates/engine/src/cmd/atn_cmds/tests.rs index 057a14dd71..59a7a66b16 100644 --- a/crates/engine/src/cmd/atn_cmds/tests.rs +++ b/crates/engine/src/cmd/atn_cmds/tests.rs @@ -3610,7 +3610,7 @@ fn image_size_explicit_sides_keep_precedence_over_percent() { #[test] fn image_size_explicit_sides_do_not_hide_invalid_percent() { - for percent in [json!(0), json!(-1), json!("50"), json!(false), json!(null)] { + for percent in [json!(0), json!(-1), json!("50"), json!(false)] { let params = json!({"width": 20, "height": 18, "percent": percent, "resample": "nearest"}); let mut native = Session::new(); native.execute("file.new", json!({"width": 32, "height": 24})).unwrap(); diff --git a/crates/engine/src/cmd/image_cmds.rs b/crates/engine/src/cmd/image_cmds.rs index c87de3a02a..7aa0608111 100644 --- a/crates/engine/src/cmd/image_cmds.rs +++ b/crates/engine/src/cmd/image_cmds.rs @@ -257,7 +257,8 @@ fn image_size(s: &mut Session, p: &Value) -> Result { ph = scaled_dimension(p, "height", scale, "image.imageSize")?; } // `percent` scales both sides (what a Photoshop action records as "200%"); an explicit side wins. - if let Some(pc) = p.get("percent") { + // A null `percent` is omitted, like a null side or resolution. + if let Some(pc) = p.get("percent").filter(|value| !value.is_null()) { let pc = pc.as_f64().filter(|v| v.is_finite() && *v > 0.0).ok_or_else(|| bad("image.imageSize", "`percent` must be a positive number"))?; pw = pw.or(Some(ow as f64 * pc / 100.0)); ph = ph.or(Some(oh as f64 * pc / 100.0)); diff --git a/crates/engine/tests/it/atn_mapped_identifiers.rs b/crates/engine/tests/it/atn_mapped_identifiers.rs index daed23a2e6..6fb8097bb2 100644 --- a/crates/engine/tests/it/atn_mapped_identifiers.rs +++ b/crates/engine/tests/it/atn_mapped_identifiers.rs @@ -94,6 +94,31 @@ fn review_point_resize_exports_with_null_optional_values() { } } +/// A null percentage is omitted at playback too, so an exported step and the native command agree. +#[test] +fn review_null_percent_is_omitted_by_the_native_resize() { + for params in + [json!({"width":72,"units":"pt","resample":"nearest","scaleStyles":false,"percent":null}), json!({"width":30,"resample":"nearest","percent":null})] + { + let mut without = params.clone(); + without.as_object_mut().unwrap().remove("percent"); + let mut expected = sized_document(20, 10, 144); + expected.execute("image.imageSize", without).unwrap(); + let mut actual = sized_document(20, 10, 144); + actual.execute("image.imageSize", params.clone()).expect("a null percent must not refuse the resize"); + assert_eq!(actual.active().unwrap().doc.size, expected.active().unwrap().doc.size); + let action = Action::new("Recorded", vec![ActionStep::new("image.imageSize", params)]); + let (bytes, skipped) = atn_cmds::export("Identifiers", &[&action], &[], false).unwrap(); + assert!(skipped.is_empty()); + let imported = atn_cmds::import(&bytes).unwrap(); + let mut replayed = sized_document(20, 10, 144); + replayed.actions.list = ActionList::from_file(ActionsFile::new(imported.actions, Vec::new())); + let result = replayed.execute("actions.play", json!({"action":"Recorded"})).unwrap(); + assert!(result.get("failed").is_none(), "{result}"); + assert_eq!(replayed.active().unwrap().doc.size, expected.active().unwrap().doc.size); + } +} + /// The native default resampler must be explicit in a physical-size recording. #[test] fn review_point_resize_exports_the_default_resampler() { diff --git a/crates/ui-egui/src/canvas/paint_mouse.rs b/crates/ui-egui/src/canvas/paint_mouse.rs index 9d99724f22..cd58e26268 100644 --- a/crates/ui-egui/src/canvas/paint_mouse.rs +++ b/crates/ui-egui/src/canvas/paint_mouse.rs @@ -54,7 +54,15 @@ pub fn sync_tool_brush(app: &mut PhotocraftApp) { // start at 0° and off too, whatever the outgoing brush has (#12629). None if matches!( tool, - Tool::BackgroundEraser | Tool::Healing | Tool::Burn | Tool::Dodge | Tool::Sponge | Tool::CloneStamp | Tool::Smudge | Tool::AdjustmentBrush | Tool::ArtHistoryBrush + Tool::BackgroundEraser + | Tool::Healing + | Tool::Burn + | Tool::Dodge + | Tool::Sponge + | Tool::CloneStamp + | Tool::Smudge + | Tool::AdjustmentBrush + | Tool::ArtHistoryBrush ) => { fresh_brush(tool, ¤t)