diff --git a/crates/engine-core/src/filters/validation/tests.rs b/crates/engine-core/src/filters/validation/tests.rs index 94b427ff9cb..1492f88544b 100644 --- a/crates/engine-core/src/filters/validation/tests.rs +++ b/crates/engine-core/src/filters/validation/tests.rs @@ -369,6 +369,7 @@ fn injected_channel_targets_and_extended_filter_colours_keep_working() { /// The finite single-range top-level params of every checked command's schema. fn documented_ranges() -> Vec<(&'static str, String, f64, f64)> { + crate::install().unwrap(); let mut out = Vec::new(); for spec in crate::commands::command_specs().iter().filter(|c| checked(c.id)) { let Some(schema) = crate::param_schema::of(spec) else { continue }; diff --git a/crates/engine-core/src/param_check.rs b/crates/engine-core/src/param_check.rs index a160efac7bf..c37f4e79f6a 100644 --- a/crates/engine-core/src/param_check.rs +++ b/crates/engine-core/src/param_check.rs @@ -175,6 +175,7 @@ mod tests { #[test] fn every_command_with_a_closed_doc_rejects_an_unknown_key() { // #7596: an undocumented key used to run the command on its defaults and report success. + crate::install().unwrap(); let mut checked = 0; for spec in crate::commands::command_specs() { let Some(schema) = param_schema::of(spec) else { continue }; @@ -200,6 +201,7 @@ mod tests { #[test] fn incomplete_docs_are_registered_closed_docs() { + crate::install().unwrap(); for id in INCOMPLETE { let spec = crate::commands::find(id).unwrap_or_else(|| panic!("{id} is not registered")); assert!(param_schema::of(spec).is_some_and(|p| !p.open()), "{id}: open or unparsed docs are not checked anyway"); @@ -209,7 +211,7 @@ mod tests { #[test] fn a_misspelled_key_fails_through_dispatch_instead_of_running_on_defaults() { - let mut s = Session::new(); + let mut s = crate::session(); s.execute("file.new", json!({"width": 8, "height": 8})).unwrap(); s.execute("layer.new.layer", json!({})).unwrap(); let err = s.execute("paint.gradient", json!({"from": [0, 0], "to": [7, 7], "colour": "red"})).unwrap_err().to_string(); diff --git a/crates/engine-core/src/param_schema/tests.rs b/crates/engine-core/src/param_schema/tests.rs index 71784e07657..2aee80015f4 100644 --- a/crates/engine-core/src/param_schema/tests.rs +++ b/crates/engine-core/src/param_schema/tests.rs @@ -2,6 +2,16 @@ use serde_json::json; use super::*; +fn specs() -> &'static [crate::commands::CommandSpec] { + crate::install().unwrap(); + crate::commands::command_specs() +} + +fn registered(id: &str) -> &'static crate::commands::CommandSpec { + crate::install().unwrap(); + crate::commands::find(id).expect("registered") +} + fn parse(doc: &str) -> Params { Params::parse(doc).unwrap_or_else(|| panic!("{doc}")) } @@ -28,7 +38,7 @@ const UNPARSED: &[&str] = &[ #[test] fn every_registry_doc_parses_and_renders_back_byte_for_byte() { let mut unparsed = Vec::new(); - for c in crate::commands::command_specs() { + for c in specs() { match Params::parse(c.params) { Some(p) => assert_eq!(p.render(), c.params, "{}: the schema must reproduce the doc", c.id), None => unparsed.push(c.id), @@ -57,7 +67,7 @@ fn no_registry_range_is_left_as_prose() { } } } - for c in crate::commands::command_specs() { + for c in specs() { if let Some(p) = Params::parse(c.params) { for (_, o) in &p.objects { walk(c.id, o); @@ -146,7 +156,7 @@ fn universal_keys_are_the_ones_every_command_honours() { #[test] fn the_registry_schema_is_read_once_and_shared() { - let spec = crate::commands::find("filter.blur.gaussianBlur").unwrap(); + let spec = registered("filter.blur.gaussianBlur"); let a = of(spec).unwrap(); assert!(std::ptr::eq(a, of(spec).unwrap())); assert_eq!(a.param("radius").unwrap().range(), Some((0.1, 1000.0))); @@ -156,7 +166,7 @@ fn the_registry_schema_is_read_once_and_shared() { /// before any trailing notes, so composed keys stay documented (#15255). #[test] fn new_adjustment_layer_docs_keep_composed_options_in_front_of_notes() { - let spec = crate::commands::find("layer.newAdjustmentLayer.gradientMap").expect("registered"); + let spec = registered("layer.newAdjustmentLayer.gradientMap"); let schema = parse(spec.params); assert!(schema.has_key("opacity"), "{}", spec.params); assert!(schema.has_key("name"), "{}", spec.params); @@ -171,7 +181,7 @@ fn new_adjustment_layer_docs_keep_composed_options_in_front_of_notes() { /// `opacity`, so `action: "set"` is accepted and no range is left as prose (#15255). #[test] fn gradient_presets_stop_documents_the_set_keys() { - let spec = crate::commands::find("gradient.presets.stop").expect("registered"); + let spec = registered("gradient.presets.stop"); let schema = parse(spec.params); assert!(schema.has_key("stops"), "{}", spec.params); assert!(schema.has_key("transparency"), "{}", spec.params); @@ -182,7 +192,7 @@ fn gradient_presets_stop_documents_the_set_keys() { /// `data` payload is accepted and not rejected as unknown (#15255). #[test] fn import_csh_documents_path_and_data() { - let spec = crate::commands::find("shape.presets.importCsh").expect("registered"); + let spec = registered("shape.presets.importCsh"); let schema = parse(spec.params); assert!(schema.has_key("path"), "{}", spec.params); assert!(schema.has_key("data"), "{}", spec.params); diff --git a/crates/ui-egui/src/dialogs/filter_dialog.rs b/crates/ui-egui/src/dialogs/filter_dialog.rs index add4fa6e7e8..c50c79497ad 100644 --- a/crates/ui-egui/src/dialogs/filter_dialog.rs +++ b/crates/ui-egui/src/dialogs/filter_dialog.rs @@ -683,9 +683,14 @@ 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"); } - // The Input resolution row is display-only; sending it made dispatch reject the Bitmap command (#15255). - if command == "image.mode.bitmap" { - map.remove("inputResolution"); + // 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.