From 5f9c7d307ef6abd6ec4336d8564328246da3cc44 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 15 Oct 2026 18:25:28 -0400 Subject: [PATCH 1/6] New Document: Color Profile, the working space or another profile of the mode (#321) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Photoshop's New Document has Advanced Options › Color Profile; PhotoCraft's always opened in the working space, so a document in another space had to be made and then assigned a profile. `file.new` takes `profile` (working, a built-in id or an .icc path), checked against the colour mode before the document opens, and the New Document dialog lists the working space (by its profile) and the built-in and installed profiles of the mode's colour space. Changing the mode drops a profile of the old space. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/commands.rs | 14 +++- crates/engine/src/document_preset_cmds.rs | 1 + crates/engine/src/tests.rs | 25 +++++++ crates/ui-egui/src/new_doc_ui.rs | 82 +++++++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index 2f041871284..df882a5ee5e 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -467,7 +467,7 @@ fn build() -> Vec { "New…", ["File"], Some("Cmd+N"), - r##"{"width":1..300000=1920,"height":1..300000=1080 (pixel counts are rounded),"mode":"rgb|gray|grayscale|cmyk|lab"="rgb","depth":8|16|32=8,"background":"white|black|backgroundColor|transparent|#rrggbb"="white","backgroundColor":[r,g,b]? (0..1; defaults to toolbox colour),"resolution":1..30000=72 (ppi),"name":str}"##, + r##"{"width":1..300000=1920,"height":1..300000=1080 (pixel counts are rounded),"mode":"rgb|gray|grayscale|cmyk|lab"="rgb","depth":8|16|32=8,"background":"white|black|backgroundColor|transparent|#rrggbb"="white","backgroundColor":[r,g,b]? (0..1; defaults to toolbox colour),"resolution":1..30000=72 (ppi),"name":str,"profile":"working"|built-in id|path to an .icc file="working" (the colour profile it is tagged with; it must suit the mode)}"##, always, |s, p| { use crate::document_preset_cmds::{MAX_DIMENSION, MAX_RESOLUTION, background_color, color_mode, sample_type}; @@ -503,6 +503,18 @@ fn build() -> Vec { } }; doc.resolution_dpi = res; + // Photoshop's New Document › Color Profile: tag the document with another profile + // than the working space (#321). Checked before the document opens. + if let Some(spec) = p.get("profile").and_then(Value::as_str).filter(|spec| !matches!(*spec, "working" | "none")) { + let prof = s.color.resolve(spec, Some(&doc), None)?; + if prof.color_space != crate::color_cmds::mode_space(doc.mode) { + return Err(EngineError::BadParams { + cmd: "file.new".into(), + msg: format!("profile `{}` is {:?}; the document is {:?}", prof.description, prof.color_space, doc.mode), + }); + } + doc.icc_profile = Some(prof.to_bytes()); + } let i = s.add_document(doc, None); Ok(json!({ "document": i })) } diff --git a/crates/engine/src/document_preset_cmds.rs b/crates/engine/src/document_preset_cmds.rs index 0bb409b818b..f0847e4b8b2 100644 --- a/crates/engine/src/document_preset_cmds.rs +++ b/crates/engine/src/document_preset_cmds.rs @@ -78,6 +78,7 @@ pub(crate) fn validate_new_params(s: &Session, p: &Value) -> Result<()> { continue; } "name" => (value.is_string(), "a string".into()), + "profile" => (value.as_str().is_some_and(|v| !v.is_empty()), "working, a built-in profile id or an .icc path".into()), _ => return Err(bad(cmd, format!("unknown parameter `{key}`"))), }; if !valid { diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 04063d30733..9c105158c9a 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -158,6 +158,31 @@ fn file_new_keeps_defaults_and_supported_modes_and_depths() { } } +#[test] +fn file_new_tags_the_document_with_the_chosen_profile() { + // #321: New Document › Color Profile, as in Photoshop: another profile than the working space. + let desc = |s: &Session| { + let bytes = s.active().unwrap().doc.icc_profile.clone(); + bytes.map(|b| photocraft_cms::Profile::parse(&b).unwrap().description) + }; + let mut s = Session::new(); + s.execute("file.new", json!({"width": 4, "height": 4, "profile": "adobe-rgb-compat"})).unwrap(); + assert_eq!(desc(&s).as_deref(), Some(photocraft_cms::Builtin::AdobeRgbCompat.description())); + s.execute("file.new", json!({"width": 4, "height": 4, "mode": "cmyk", "profile": "coated-cmyk"})).unwrap(); + assert!(desc(&s).is_some()); + // The working space (the default, or asked for) leaves it as before. + for p in [json!({"width": 4, "height": 4}), json!({"width": 4, "height": 4, "profile": "working"})] { + s.execute("file.new", p).unwrap(); + assert_eq!(desc(&s), None); + } + // A profile that doesn't suit the mode, an unknown one or a wrong type opens nothing. + let open = s.documents().len(); + for bad in [json!("coated-cmyk"), json!("no-such-profile"), json!(""), json!(7), json!(null)] { + assert!(s.execute("file.new", json!({"width": 4, "height": 4, "profile": bad})).is_err(), "{bad}"); + } + assert_eq!(s.documents().len(), open); +} + #[test] fn file_new_variants() { let mut s = Session::new(); diff --git a/crates/ui-egui/src/new_doc_ui.rs b/crates/ui-egui/src/new_doc_ui.rs index e615620d4ca..fd43bc15351 100644 --- a/crates/ui-egui/src/new_doc_ui.rs +++ b/crates/ui-egui/src/new_doc_ui.rs @@ -231,6 +231,33 @@ pub fn apply_preset(f: &mut Map, p: &Preset, units: &UnitsAndRule f.insert("__unit".into(), json!(unit)); } +/// The colour mode of the dialog's `mode` value. +fn color_mode_of(mode: &str) -> Option { + use photocraft_color::ColorMode; + match mode { + "rgb" => Some(ColorMode::Rgb), + "gray" | "grayscale" => Some(ColorMode::Grayscale), + "cmyk" => Some(ColorMode::Cmyk), + "lab" => Some(ColorMode::Lab), + _ => None, + } +} + +/// The Color Profile menu for a document of colour `space` (#321): the working space (shown with +/// its profile's description), then the built-in and installed profiles of that space, as +/// `file.new`'s `profile` values (an id or a path) with their labels. +fn profile_options( + space: Option, + working: &str, + installed: &[photocraft_engine::installed_profiles::InstalledProfile], +) -> Vec<(String, String)> { + let mut v = vec![("working".to_string(), crate::i18n::fmt(tl!("Working: {working}"), &[("working", working)]))]; + let Some(space) = space else { return v }; + v.extend(photocraft_cms::Builtin::ALL.iter().filter(|b| b.profile().color_space == space).map(|b| (b.id().to_string(), b.description().to_string()))); + v.extend(installed.iter().filter(|i| i.is_destination() && i.color_space == space).map(|i| (i.path.clone(), i.description.clone()))); + v +} + /// Fields `file.new` takes (drops the dialog's `__` UI keys). pub fn command_params(f: &Map) -> Value { Value::Object(f.iter().filter(|(k, _)| !k.starts_with("__")).map(|(k, v)| (k.clone(), v.clone())).collect()) @@ -695,6 +722,8 @@ pub fn body(app: &mut crate::PhotocraftApp, ui: &mut egui::Ui, f: &mut Map = opts.iter().map(|(v, l)| (v.clone(), l.as_str())).collect(); + if widgets::dropdown(ui, "nd-profile", &mut profile, &shown, 240.0) { + if profile == "working" { + f.remove("profile"); + } else { + f.insert("profile".into(), json!(profile)); + } + f.remove("__savedPreset"); + } + } + ui.add_space(4.0); small_label(ui, tl!("Background Contents")); // A custom colour is kept as its "#rrggbb", which `file.new` takes as is (#4789). let current = get_s(f, "background", "white"); @@ -768,6 +821,35 @@ pub fn body(app: &mut crate::PhotocraftApp, ui: &mut egui::Ui, f: &mut Map>(); + let rgb = values("rgb"); + assert_eq!(rgb[0], "working"); + assert!(rgb.contains(&Builtin::AdobeRgbCompat.id().to_string()) && rgb.contains(&"panel.icc".to_string())); + assert!(!rgb.contains(&Builtin::CoatedCmyk.id().to_string()) && !rgb.contains(&"press.icc".to_string())); + let cmyk = values("cmyk"); + assert!(cmyk.contains(&"press.icc".to_string()) && !cmyk.contains(&Builtin::Srgb.id().to_string())); + assert!(profile_options(None, "sRGB", &installed).len() == 1, "an unknown mode offers only the working space"); + // Every entry is one `file.new` takes for that mode. + for mode in ["rgb", "gray", "cmyk", "lab"] { + for v in values(mode).into_iter().filter(|v| !v.ends_with(".icc")) { + let mut s = photocraft_engine::Session::new(); + s.execute("file.new", json!({"width": 2, "height": 2, "mode": mode, "profile": v})).unwrap_or_else(|e| panic!("{mode} {v}: {e}")); + } + } + } + #[test] fn units_round_trip_through_pixels() { assert_eq!(to_unit(2100.0, "in", 300.0), 7.0); From c1c44507d1bf7b36c2a74e3597348a7e7c39197c Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 15 Oct 2026 18:40:18 -0400 Subject: [PATCH 2/6] Automation: file.new's profile path is an ambient read, gated like Assign Profile's (#321) Co-Authored-By: Claude Opus 5.5 --- crates/automation/src/workspace.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs index 23b64ae30ee..6919041b823 100644 --- a/crates/automation/src/workspace.rs +++ b/crates/automation/src/workspace.rs @@ -323,6 +323,8 @@ fn params_contain_ambient_path(id: &str, params: &Value) -> bool { } "image.mode.rgb" | "image.mode.grayscale" | "image.mode.cmyk" | "image.mode.lab" => &["profile"], "edit.assignProfile" | "edit.convertToProfile" | "edit.profileInfo" | "view.proofSetup" | "view.gamutWarning" => &["profile"], + // New Document's Color Profile (#321) can name an .icc file. + "file.new" => &["profile"], "edit.colorSettings" => &["workingRgb", "workingCmyk", "workingGray"], _ => &[], }; @@ -712,6 +714,8 @@ mod tests { assert!(authorize_desktop_engine_command("image.mode.cmyk", &serde_json::json!({})).is_err()); assert!(authorize_engine_command("image.mode.rgb", &serde_json::json!({"profile": "/outside/profile.icc"})).is_err()); assert!(authorize_engine_command("image.mode.rgb", &serde_json::json!({"profile": "srgb"})).is_ok()); + assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "/outside/profile.icc"})).is_err()); + assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "adobe-rgb-compat"})).is_ok()); assert!(authorize_engine_command("filter.distort.displace", &serde_json::json!({"mapPath": "outside.png"})).is_err()); assert!(authorize_engine_command("layer.setAdjustment", &serde_json::json!({"file": "outside.cube"})).is_err()); assert!(authorize_engine_command("prefs.set", &serde_json::json!({"path": "colorSettings.workingRgb", "value": "outside.icc"})).is_err()); From a80ece00aa778917ac422d5664301fdabe7a2665 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 15 Oct 2026 23:01:51 -0400 Subject: [PATCH 3/6] Merge origin/main; cargo fmt (new_doc_ui.rs, smart_filter_authorization.rs) Co-Authored-By: Claude Opus 5.5 --- crates/automation/tests/smart_filter_authorization.rs | 8 +++----- crates/ui-egui/src/new_doc_ui.rs | 10 ++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/automation/tests/smart_filter_authorization.rs b/crates/automation/tests/smart_filter_authorization.rs index a5c1681a52e..30f17b795bf 100644 --- a/crates/automation/tests/smart_filter_authorization.rs +++ b/crates/automation/tests/smart_filter_authorization.rs @@ -230,11 +230,9 @@ fn a_refresh_outside_command_execution_surfaces_the_denial_instead_of_rendering_ let before = h.session.active().unwrap().doc.clone(); // Session::edit is the outside-execute mutation path (an edit closure the UI or a // linked-file change runs); the stored filter must be denied there too. - assert_denied(h.session.edit("Re-render", |d, _| { - match smart_cmds::refresh(d, layer) { - Ok(_) => Ok(()), - Err(e) => Err(e), - } + assert_denied(h.session.edit("Re-render", |d, _| match smart_cmds::refresh(d, layer) { + Ok(_) => Ok(()), + Err(e) => Err(e), })); assert!(Arc::ptr_eq(&before, &h.session.active().unwrap().doc)); // A trusted session (no gate) still renders the same document. diff --git a/crates/ui-egui/src/new_doc_ui.rs b/crates/ui-egui/src/new_doc_ui.rs index fd43bc15351..761b1fd85c4 100644 --- a/crates/ui-egui/src/new_doc_ui.rs +++ b/crates/ui-egui/src/new_doc_ui.rs @@ -830,10 +830,12 @@ mod tests { InstalledProfile { path: "press.icc".into(), description: "Press".into(), class: ProfileClass::Output, color_space: ColorSpace::Cmyk }, InstalledProfile { path: "panel.icc".into(), description: "Panel".into(), class: ProfileClass::Display, color_space: ColorSpace::Rgb }, ]; - let values = |mode: &str| profile_options(color_mode_of(mode).map(photocraft_engine::color_cmds::mode_space), "sRGB", &installed) - .into_iter() - .map(|(v, _)| v) - .collect::>(); + let values = |mode: &str| { + profile_options(color_mode_of(mode).map(photocraft_engine::color_cmds::mode_space), "sRGB", &installed) + .into_iter() + .map(|(v, _)| v) + .collect::>() + }; let rgb = values("rgb"); assert_eq!(rgb[0], "working"); assert!(rgb.contains(&Builtin::AdobeRgbCompat.id().to_string()) && rgb.contains(&"panel.icc".to_string())); From 4527b6a7e28270e2f326fb522818966aa002c3aa Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Sun, 18 Oct 2026 15:04:19 -0400 Subject: [PATCH 4/6] New Document: presets keep the Color Profile; a stale profile is cleared - DocumentSettings gains an optional `profile`, so document.presets.save and Recent keep the Color Profile and command_params gives it back to file.new. Older presets load as the working space. - Applying a saved preset drops the profile picked before, and a profile that doesn't suit the mode is removed from the dialog state, so Create never sends it. - The rejected-profile test also checks the active document and its history are unchanged. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/document_preset_cmds.rs | 33 +++++++++++++++++++++++ crates/engine/src/tests.rs | 4 ++- crates/ui-egui/src/new_doc_ui.rs | 23 ++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/document_preset_cmds.rs b/crates/engine/src/document_preset_cmds.rs index f0847e4b8b2..52c637fdc00 100644 --- a/crates/engine/src/document_preset_cmds.rs +++ b/crates/engine/src/document_preset_cmds.rs @@ -102,6 +102,10 @@ pub struct DocumentSettings { pub background: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub background_color: Option<[f32; 3]>, + /// `file.new`'s Color Profile (#321): a built-in profile id or an .icc path; absent is the + /// working space, as in presets saved before it existed. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub profile: Option, /// Display units only; width/height are always pixels and resolution is always ppi. pub unit: String, pub resolution_unit: String, @@ -128,6 +132,9 @@ impl DocumentSettings { if self.background_color.is_some_and(|c| !c.iter().all(|v| v.is_finite() && (0.0..=1.0).contains(v))) { return Err("Background colour components must be within 0..1".into()); } + if self.profile.as_deref().is_some_and(|p| p.trim().is_empty()) { + return Err("A saved Color Profile needs a profile id or path".into()); + } if !matches!(self.unit.as_str(), "px" | "in" | "cm" | "mm" | "pt" | "pica") || !matches!(self.resolution_unit.as_str(), "in" | "cm") { return Err("Unknown dimension or resolution display unit".into()); } @@ -171,6 +178,9 @@ impl DocumentSettings { if let Some(c) = self.background_color { p["backgroundColor"] = json!(c); } + if let Some(profile) = &self.profile { + p["profile"] = json!(profile); + } p } } @@ -359,6 +369,29 @@ mod tests { next } + /// #321: a preset keeps New Document's Color Profile through a reload and back into + /// `file.new`; one saved without it (or before it existed) stays on the working space. + #[test] + fn the_color_profile_survives_save_reload_and_file_new() { + let mut s = Session::new(); + let mut config = settings(); + config["mode"] = json!("cmyk"); + config["profile"] = json!("coated-cmyk"); + let preset = saved(&mut s, "Press", config.clone()); + assert_eq!(preset["settings"]["profile"], "coated-cmyk"); + let next = reload(&s); + let params = next.presets.documents[0].settings.command_params(); + assert_eq!(params["profile"], "coated-cmyk"); + let mut s2 = Session::new(); + s2.execute("file.new", params).unwrap(); + assert!(s2.active().unwrap().doc.icc_profile.is_some()); + let plain = saved(&mut s, "Plain", settings()); + assert!(plain["settings"].get("profile").is_none()); + assert!(s.presets.documents[1].settings.command_params().get("profile").is_none()); + config["profile"] = json!(" "); + assert!(s.execute("document.presets.save", json!({"name":"Blank","settings":config})).is_err()); + } + #[test] fn every_field_survives_save_reload_and_file_new() { for mode in ["rgb", "gray", "cmyk", "lab"] { diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 9c105158c9a..9bb00b30b62 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -177,10 +177,12 @@ fn file_new_tags_the_document_with_the_chosen_profile() { } // A profile that doesn't suit the mode, an unknown one or a wrong type opens nothing. let open = s.documents().len(); + let (active, steps) = (s.active().unwrap().doc.id, s.active().unwrap().history.past_len()); for bad in [json!("coated-cmyk"), json!("no-such-profile"), json!(""), json!(7), json!(null)] { assert!(s.execute("file.new", json!({"width": 4, "height": 4, "profile": bad})).is_err(), "{bad}"); + assert_eq!(s.documents().len(), open, "{bad}"); + assert_eq!((s.active().unwrap().doc.id, s.active().unwrap().history.past_len()), (active, steps), "{bad}"); } - assert_eq!(s.documents().len(), open); } #[test] diff --git a/crates/ui-egui/src/new_doc_ui.rs b/crates/ui-egui/src/new_doc_ui.rs index 761b1fd85c4..ca836b61f54 100644 --- a/crates/ui-egui/src/new_doc_ui.rs +++ b/crates/ui-egui/src/new_doc_ui.rs @@ -346,6 +346,8 @@ pub fn apply_saved_preset(f: &mut Map, preset: &photocraft_engine /// Restore every setting of a saved or recent document (all but its name). pub fn apply_settings(f: &mut Map, settings: &DocumentSettings) { f.remove("backgroundColor"); + // A preset without a Color Profile is on the working space, whatever was picked before. + f.remove("profile"); if let Some(params) = settings.command_params().as_object() { f.extend(params.clone()); } @@ -745,7 +747,9 @@ pub fn body(app: &mut crate::PhotocraftApp, ui: &mut egui::Ui, f: &mut Map = opts.iter().map(|(v, l)| (v.clone(), l.as_str())).collect(); if widgets::dropdown(ui, "nd-profile", &mut profile, &shown, 240.0) { @@ -852,6 +856,24 @@ mod tests { } } + /// A saved preset replaces the Color Profile picked before: its own, or the working space. + #[test] + fn applying_a_preset_replaces_the_picked_profile() { + let mut s = photocraft_engine::Session::new(); + let base = json!({"width": 8, "height": 8, "mode": "cmyk", "unit": "px"}); + s.execute("document.presets.save", json!({"name": "Plain", "settings": base})).unwrap(); + let mut press = base.clone(); + press["profile"] = json!("coated-cmyk"); + s.execute("document.presets.save", json!({"name": "Press", "settings": press})).unwrap(); + let mut f = Map::new(); + f.insert("profile".into(), json!(photocraft_cms::Builtin::AdobeRgbCompat.id())); + apply_saved_preset(&mut f, &s.presets.documents[0]); + assert!(!f.contains_key("profile"), "{f:?}"); + assert!(s.execute("file.new", command_params(&f)).is_ok()); + apply_saved_preset(&mut f, &s.presets.documents[1]); + assert_eq!(f["profile"], "coated-cmyk"); + } + #[test] fn units_round_trip_through_pixels() { assert_eq!(to_unit(2100.0, "in", 300.0), 7.0); @@ -1028,6 +1050,7 @@ mod tests { depth: 8, background: "white".into(), background_color: None, + profile: None, unit: "px".into(), resolution_unit: "in".into(), }; From 98b4574545cd047d9f4ce07814601f6ea78369ca Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 20:53:16 -0400 Subject: [PATCH 5/6] Automation: deny file.new profiles that resolve the configured working space `default` and the `working-*` aliases make file.new resolve Color Settings' working profile, which on the desktop can be a user-configured .icc path. Treat them like edit.assignProfile does; exact `working` and `none` skip resolution and stay allowed. Co-Authored-By: Claude Opus 5.5 --- crates/automation/src/workspace.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs index 9c7c5bb8941..caa58645dbd 100644 --- a/crates/automation/src/workspace.rs +++ b/crates/automation/src/workspace.rs @@ -358,6 +358,13 @@ fn profile_command_may_read_ambient(id: &str, params: &Value) -> bool { if matches!(id, "color.profileMismatch" | "edit.colorSettings" | "edit.installedProfiles" | "view.proofSetup") { return true; } + // New Document skips exact `working` and `none`; the other working aliases resolve + // the configured working space, which may be an .icc path. + if id == "file.new" { + return params.get("profile").and_then(Value::as_str).is_some_and(|profile| { + matches!(profile, "default" | "working-cmyk" | "workingCmyk" | "working-rgb" | "workingRgb" | "working-gray" | "workingGray") + }); + } matches!(id, "edit.assignProfile" | "edit.convertToProfile" | "edit.profileInfo") && params.get("profile").and_then(Value::as_str).is_some_and(|profile| { matches!(profile, "working" | "default" | "working-cmyk" | "workingCmyk" | "working-rgb" | "workingRgb" | "working-gray" | "workingGray") @@ -763,6 +770,10 @@ mod tests { assert!(authorize_engine_command("image.mode.rgb", &serde_json::json!({"profile": "srgb"})).is_ok()); assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "/outside/profile.icc"})).is_err()); assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "adobe-rgb-compat"})).is_ok()); + assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "working"})).is_ok()); + assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "none"})).is_ok()); + assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "default"})).is_err()); + assert!(authorize_engine_command("file.new", &serde_json::json!({"profile": "working-cmyk"})).is_err()); // Shortcut sets: text in and out is fine; a path reads or writes the filesystem. let ks = |p: serde_json::Value| authorize_engine_command("edit.keyboardShortcuts", &p); assert!(ks(serde_json::json!({"exportKys": true, "summarize": true, "importKys": ""})).is_ok()); From 6dbc8956ada3e2de8a6db55d71366c7756102a04 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 20:53:16 -0400 Subject: [PATCH 6/6] Document presets: check a rejected blank profile leaves preferences unchanged Move the empty/whitespace/non-string Color Profile cases into the bad-input table, which asserts the preferences (presets included) and their revision are untouched. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/document_preset_cmds.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/document_preset_cmds.rs b/crates/engine/src/document_preset_cmds.rs index 52c637fdc00..e65856951ba 100644 --- a/crates/engine/src/document_preset_cmds.rs +++ b/crates/engine/src/document_preset_cmds.rs @@ -388,8 +388,6 @@ mod tests { let plain = saved(&mut s, "Plain", settings()); assert!(plain["settings"].get("profile").is_none()); assert!(s.presets.documents[1].settings.command_params().get("profile").is_none()); - config["profile"] = json!(" "); - assert!(s.execute("document.presets.save", json!({"name":"Blank","settings":config})).is_err()); } #[test] @@ -529,6 +527,9 @@ mod tests { ("backgroundColor", json!([2, 0, 0])), ("unit", json!("yards")), ("resolutionUnit", json!("px")), + ("profile", json!("")), + ("profile", json!(" \t")), + ("profile", json!(12)), ] { let mut config = settings(); config[key] = bad;