Actions: keep a wrong-typed Smart Sharpen step, read an unpadded Rds (CodeRabbit review on crates/engine/src/cmd/atn_cmds/steps_image.rs:575)

The enum and Boolean gates passed a present key of another type, and
the amount and radius fell back to their defaults. The key gate admits
`Rds` without its padding, but the radius was read as `Rds ` only, so it
played as 1. Every key now goes through `setting`, which reads the key
as the gate admits it and keeps a wrong-typed step as a Photoshop step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hector VillarrealandClaude Opus 5.5 committed 2026-10-31 21:24:40 -06:00
1 parent 7525fde387
commit 1eb8f7d4da
2 files changed
+41 -10

No files matched your search

+17 -10
View File
@@ -1,6 +1,6 @@
use super::descriptors::{
PX, Target, ang, boolean, class, code, desc, enm, get_bool, get_enum, get_num, get_obj, get_ref, jbool, jnum, jstr, layer_ref, layer_target, long, num,
pct, px, ref_class, target, trimmed,
PX, Target, ang, boolean, class, code, desc, enm, enumerated, get_bool, get_enum, get_num, get_obj, get_ref, jbool, jnum, jstr, layer_ref, layer_target,
long, num, pct, px, ref_class, target, trimmed,
};
use super::events::pixel_target;
use super::fields::{F, Kind, Mapped, fields_from, fields_to, step};
@@ -575,21 +575,28 @@ pub(super) fn oil_paint_to(_: &str, p: &Value) -> Option<Descriptor> {
/// asks for what the command does not do (another blur, More Accurate, the newer filter, a
/// preset) keeps it as a Photoshop step.
pub(super) fn smart_sharpen_from(d: &Descriptor) -> Mapped {
match smart_sharpen_params(d) {
Some(p) => step("filter.sharpen.smartSharpen", Value::Object(p)),
None => Mapped::Unsupported { harmless: false },
}
}
fn smart_sharpen_params(d: &Descriptor) -> Option<Map<String, Value>> {
let keys = ["presetKind", "useLegacy", "Amnt", "Rds", "moreAccurate", "blur"];
let as_recorded = only_keys(d, &keys)
&& get_enum(d, "presetKind").is_none_or(|k| k == "presetKindCustom")
&& get_bool(d, "useLegacy") != Some(false)
&& get_bool(d, "moreAccurate") != Some(true)
&& get_enum(d, "blur").is_none_or(|b| b == "lensBlur");
&& setting(d, "presetKind", enumerated, "presetKindCustom".into())? == "presetKindCustom"
&& setting(d, "useLegacy", boolean, true)?
&& !setting(d, "moreAccurate", boolean, false)?
&& setting(d, "blur", enumerated, "lensBlur".into())? == "lensBlur";
if !as_recorded {
return Mapped::Unsupported { harmless: false };
return None;
}
let mut p = Map::new();
for (key, param, default) in [("Amnt", "amount", 200.0), ("Rds ", "radius", 1.0)] {
p.insert(param.into(), get_num(d, key).unwrap_or(default).into());
for (key, param, default) in [("Amnt", "amount", 200.0), ("Rds", "radius", 1.0)] {
p.insert(param.into(), setting(d, key, num, default)?.into());
}
p.insert("reduceNoise".into(), 0.into());
step("filter.sharpen.smartSharpen", Value::Object(p))
Some(p)
}
/// Every key in recorded order. The legacy filter has no noise reduction, so only a step that
+24
View File
@@ -3308,3 +3308,27 @@ fn oil_paint_with_a_wrong_typed_setting_is_kept() {
],
);
}
#[test]
fn smart_sharpen_with_a_wrong_typed_setting_is_kept() {
kept_when_wrong_typed(
"smartSharpen",
&[
("presetKind", text("presetKindDefault")),
("useLegacy", D::Integer(0)),
("moreAccurate", D::Integer(1)),
("blur", text("motionBlur")),
("Amnt", D::Boolean(true)),
("Rds ", text("2")),
("Rds", text("2")),
],
);
}
/// `only_keys` admits a code without its space padding, so the mapper reads it too: an
/// unpadded `Rds` radius is the step's radius, not the default 1 (#10610).
#[test]
fn smart_sharpen_reads_an_unpadded_radius() {
let d = desc("null").with("Amnt", pct(150.0)).with("Rds", px(2.5));
assert_eq!(mapped(newer("smartSharpen", d)), ("filter.sharpen.smartSharpen".into(), json!({"amount": 150.0, "radius": 2.5, "reduceNoise": 0})));
}