From 1628311e6b32c06bbfc62db2541890a4f2cfbb01 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:40:45 -0800 Subject: [PATCH 1/8] 3D: OK keeps the running preview and commits it OK in the 3D dialog replaced its live preview with a new one before running the values again. The new preview no longer owned the interaction the dialog's preview had started, so it ran nothing while that interaction was open, and the commit then refused with "Finish the active edit first." With Preview on, OK left the dialog open and saved nothing, and a refused draft reported that message instead of the engine's reason. OK now forgets only the values the preview last ran (LivePreview::rerun_next) and keeps its interaction, so the values run again inside it and the commit keeps that interaction as one undo step. This fixes four vectorcraft-ui-egui tests that fail on main under both cargo test and cargo nextest: - dialogs::revolve::tests::lighting_presets_cancel_restores_an_existing_custom_light_rig - dialogs::three_d::unchanged_tests::refused_three_d_preview_confirmation_retries_the_same_draft - dialogs::three_d::unchanged_tests::three_d_dialog_changed_options_commit_once_or_cancel - dialogs::track_cube::precision_tests::screen_plane_keys_preserve_the_untouched_rotation_axes_through_preview_and_ok --- crates/ui-egui/src/dialogs/preview.rs | 6 ++++++ crates/ui-egui/src/dialogs/three_d.rs | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/preview.rs b/crates/ui-egui/src/dialogs/preview.rs index 2e029fc1c6..f55dadb7c6 100644 --- a/crates/ui-egui/src/dialogs/preview.rs +++ b/crates/ui-egui/src/dialogs/preview.rs @@ -94,6 +94,12 @@ impl LivePreview { Some(answer) } + /// Forgets the values last previewed and keeps the interaction they ran in, so the next [`Self::run`] previews + /// them again inside that interaction and returns the command's answer, a refusal included. + pub(crate) fn rerun_next(&mut self) { + self.previewed = None; + } + /// OK: keeps the previewed `cmd` as one undo step, or, when its preview is not running, keeps typing in progress /// and runs `cmd` as a step of its own; the command's warning, or a plug-in run's notice, shows in the status bar /// either way. Another edit in progress is left as it is and OK is refused. On an error the dialog stays open. diff --git a/crates/ui-egui/src/dialogs/three_d.rs b/crates/ui-egui/src/dialogs/three_d.rs index 4706074962..293aae4f45 100644 --- a/crates/ui-egui/src/dialogs/three_d.rs +++ b/crates/ui-egui/src/dialogs/three_d.rs @@ -254,8 +254,9 @@ fn ok(app: &mut VectorcraftApp, answer: &ParamResult) -> Result<(), String> { return Err(why); } let (cmd, p, _) = s.request(&answer.fields); - // OK must validate afresh: the live preview also caches refused requests. - s.preview = LivePreview::default(); + // OK must validate afresh: the live preview also caches refused requests. The preview keeps its interaction, so + // the values run again inside it and the commit below keeps that interaction as the undo step. + s.preview.rerun_next(); match s.run_preview(app, cmd, &p) { Some(Ok(())) if finish_unchanged_preview(app) => return Ok(()), Some(Err(why)) => { From e508073632ca28802a1c8cf24e87f5814ed9440d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 12:03:06 -0800 Subject: [PATCH 2/8] 3D: take main's OK fix instead of this branch's #9970 fixed the 3D dialogs' OK on main by ending the running preview before the values run again. This takes out this branch's earlier fix (LivePreview::rerun_next) so the two do not overlap. --- crates/ui-egui/src/dialogs/preview.rs | 6 ------ crates/ui-egui/src/dialogs/three_d.rs | 5 ++--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/dialogs/preview.rs b/crates/ui-egui/src/dialogs/preview.rs index f55dadb7c6..2e029fc1c6 100644 --- a/crates/ui-egui/src/dialogs/preview.rs +++ b/crates/ui-egui/src/dialogs/preview.rs @@ -94,12 +94,6 @@ impl LivePreview { Some(answer) } - /// Forgets the values last previewed and keeps the interaction they ran in, so the next [`Self::run`] previews - /// them again inside that interaction and returns the command's answer, a refusal included. - pub(crate) fn rerun_next(&mut self) { - self.previewed = None; - } - /// OK: keeps the previewed `cmd` as one undo step, or, when its preview is not running, keeps typing in progress /// and runs `cmd` as a step of its own; the command's warning, or a plug-in run's notice, shows in the status bar /// either way. Another edit in progress is left as it is and OK is refused. On an error the dialog stays open. diff --git a/crates/ui-egui/src/dialogs/three_d.rs b/crates/ui-egui/src/dialogs/three_d.rs index 293aae4f45..4706074962 100644 --- a/crates/ui-egui/src/dialogs/three_d.rs +++ b/crates/ui-egui/src/dialogs/three_d.rs @@ -254,9 +254,8 @@ fn ok(app: &mut VectorcraftApp, answer: &ParamResult) -> Result<(), String> { return Err(why); } let (cmd, p, _) = s.request(&answer.fields); - // OK must validate afresh: the live preview also caches refused requests. The preview keeps its interaction, so - // the values run again inside it and the commit below keeps that interaction as the undo step. - s.preview.rerun_next(); + // OK must validate afresh: the live preview also caches refused requests. + s.preview = LivePreview::default(); match s.run_preview(app, cmd, &p) { Some(Ok(())) if finish_unchanged_preview(app) => return Ok(()), Some(Err(why)) => { From e87a7f09d9431bb5f2f0b247a2532acc14a1ca64 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 10:52:42 -0800 Subject: [PATCH 3/8] Paint: a bad target is refused when ids or id names the objects item_target_at read `target` only when no `ids` or `id` was given, so paint.setFill and paint.setStroke with an `id` and a target such as "content" painted the object instead of refusing it, and tests::paintopacity::a_bad_target_is_refused_with_an_id_or_selected_characters (added in #8099) failed. item_target_at now reads `target` first, for every command that names its item through it, and the selected-part path no longer needs its own early read. --- crates/engine/src/cmd/appearance.rs | 4 +++- crates/engine/src/cmd/paint.rs | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/appearance.rs b/crates/engine/src/cmd/appearance.rs index 4fb4537ee4..d319e0d2a4 100644 --- a/crates/engine/src/cmd/appearance.rs +++ b/crates/engine/src/cmd/appearance.rs @@ -253,6 +253,8 @@ pub(crate) fn item_target(s: &Session, p: &Value, cmd: &str) -> Result Result { let aligned = aligned(p, cmd)?; + // Read `target` whatever names the objects, so that a bad one is refused with `ids` or `id` too. + let contents = targets_contents(p)?; match p.get(key) { Some(Value::Null) => Ok(ItemTarget::Top), Some(v) => v @@ -260,7 +262,7 @@ pub(crate) fn item_target_at(s: &Session, p: &Value, key: &str, cmd: &str) -> Re .map(|i| ItemTarget::Item { index: index(i), explicit: true, aligned }) .ok_or_else(|| bad(cmd, format!("`{key}` must be an appearance item index (paint order) or null"))), // The active item is a row of the first selected object's own stack. - None if p.get("ids").is_some() || p.get("id").is_some() || targets_contents(p)? => Ok(ItemTarget::Top), + None if p.get("ids").is_some() || p.get("id").is_some() || contents => Ok(ItemTarget::Top), // A row of a graph design's art in a series stands for nothing: the commands leave that art out. None if s.active().and_then(|st| st.selection.subjects().first().map(|id| super::graph::is_design_art(&st.doc, *id))) == Some(true) => { Ok(ItemTarget::Top) diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index 1ac467789c..c3e64db4d0 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -1474,8 +1474,6 @@ fn selected_part_target(s: &Session, p: &Value, cmd: &str) -> Result Date: Sat, 28 Nov 2026 10:52:42 -0800 Subject: [PATCH 4/8] i18n: id catalog defines the opacity messages once #8099 added five @msg rows to id.tsv that #7642 had already added, so i18n::tests::bundled_catalogs_are_consistent failed on the repeated definitions. The later copies are removed; the rows #7642 added stay. --- crates/ui-egui/src/i18n/id.tsv | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 499b782aa9..48af87f872 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -9200,11 +9200,6 @@ file-filter Applications Aplikasi @msg the layer effects of {n} layers weren't drawn efek lapisan dari {n} lapisan tidak digambar @msg the vector masks of 1 layer weren't applied masker vektor dari 1 lapisan tidak diterapkan @msg the vector masks of {n} layers weren't applied masker vektor dari {n} lapisan tidak diterapkan -@msg `opacity` must be a number from 0 to 100 `opacity` harus berupa angka dari 0 sampai 100 -@msg `opacity` must be true or false `opacity` harus true atau false -@msg type characters have no opacity of their own: add a fill or stroke with the Appearance panel's Add New Fill or Add New Stroke karakter teks tidak memiliki opasitas sendiri: tambahkan isian atau guratan dengan Tambahkan isian baru atau Tambahkan guratan baru di panel Tampilan -@msg an object selected in a symbol instance has no fill or stroke opacity of its own objek yang dipilih dalam instans simbol tidak memiliki opasitas isian atau guratan sendiri -@msg no target has that fill or stroke to take the opacity tidak ada target yang memiliki isian atau guratan itu untuk menerima opasitas @msg give color, none, swatch, gradient or opacity berikan color, none, swatch, gradient, atau opacity @msg the knockout of 1 layer wasn't applied knockout dari 1 lapisan tidak diterapkan @msg the knockout of {n} layers wasn't applied knockout dari {n} lapisan tidak diterapkan From fcc22890423d213b00011eb21b77ae3919cf08a8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 10:52:42 -0800 Subject: [PATCH 5/8] Color Wheel: the null-key test expects the contrast settings ui.colorWheel answers contrast, contrastFor and contrastBackground since #7718, and the test #8099 added still expected the keys from before it. The test now sets contrast and contrastFor, checks that a null keeps each of them, and expects contrastBackground, whose null unpins the background. --- .../src/panels/tests_color_wheel_hex.rs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/panels/tests_color_wheel_hex.rs b/crates/ui-egui/src/panels/tests_color_wheel_hex.rs index 735df1b0fd..e2c5a62b80 100644 --- a/crates/ui-egui/src/panels/tests_color_wheel_hex.rs +++ b/crates/ui-egui/src/panels/tests_color_wheel_hex.rs @@ -120,17 +120,32 @@ fn show_hex_field_is_a_setting_of_the_panel() { } /// An explicit null for any `ui.colorWheel` key keeps that key's value, as leaving the key out does, -/// and the other keys of the same call still apply. +/// and the other keys of the same call still apply. `contrastBackground` is the exception: null +/// unpins the background. #[test] fn ui_color_wheel_keeps_a_key_given_as_null() { let mut app = VectorcraftApp::new(Session::new(), Default::default()); let set = json!({ "view": "box", "channel": "red", "opacity": true, "hexField": true, "sliders": "oklch", - "gamut": true, "harmony": true, "harmonyRule": "triad", "vision": true, "documentColors": true + "gamut": true, "harmony": true, "harmonyRule": "triad", "contrast": true, "contrastFor": "largeText", + "contrastBackground": null, "vision": true, "documentColors": true }); let all = app.run("ui.colorWheel", set.clone()).unwrap(); assert_eq!(all, set); - for key in ["view", "channel", "opacity", "hexField", "sliders", "gamut", "harmony", "harmonyRule", "vision", "documentColors"] { + for key in [ + "view", + "channel", + "opacity", + "hexField", + "sliders", + "gamut", + "harmony", + "harmonyRule", + "contrast", + "contrastFor", + "vision", + "documentColors", + ] { assert_eq!(app.run("ui.colorWheel", json!({ key: null })).unwrap(), all, "{key}: null"); } let got = app.run("ui.colorWheel", json!({"view": null, "channel": "blue", "opacity": null, "hexField": false})).unwrap(); @@ -138,7 +153,8 @@ fn ui_color_wheel_keeps_a_key_given_as_null() { got, json!({ "view": "box", "channel": "blue", "opacity": true, "hexField": false, "sliders": "oklch", - "gamut": true, "harmony": true, "harmonyRule": "triad", "vision": true, "documentColors": true + "gamut": true, "harmony": true, "harmonyRule": "triad", "contrast": true, "contrastFor": "largeText", + "contrastBackground": null, "vision": true, "documentColors": true }) ); } From 55e8083aff1daebf82a42b72971ec890172ce891 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 11:21:49 -0800 Subject: [PATCH 6/8] Scripts: the control-size test measures the field by its name tests::script_window::controls_are_drawn_at_the_size_the_script_gave_them took the first text input in the accessibility update. The field exposes two, the field itself, named Text and 200 points wide, and the editor inside its 6-point padding, 188 points wide, and egui lists the update's nodes in hash-map order, which other widgets in the frame change. After #9255 merged, the editor came first and the test failed although the field is drawn at its preferred width. The test now looks the field up by its name. --- crates/ui-egui/src/tests/script_window.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tests/script_window.rs b/crates/ui-egui/src/tests/script_window.rs index b605447733..e69a40c670 100644 --- a/crates/ui-egui/src/tests/script_window.rs +++ b/crates/ui-egui/src/tests/script_window.rs @@ -876,10 +876,12 @@ fn controls_are_drawn_at_the_size_the_script_gave_them() { .unwrap_or_else(|| panic!("no {role:?} {label:?}")) }; let w = app.session.script_window().unwrap(); + // The field is the text input named for screen readers; the editor inside its padding is a text + // input too, and the update lists the two in no fixed order. let (wide, ok, field) = ( bounds(egui::accesskit::Role::Button, Some("Wide")), bounds(egui::accesskit::Role::Button, Some("OK")), - bounds(egui::accesskit::Role::TextInput, None), + bounds(egui::accesskit::Role::TextInput, Some("Text")), ); assert!(wide.width() > ok.width() && wide.height() > ok.height(), "the wide button is larger than OK: {wide:?} {ok:?}"); assert!((wide.width() - f64::from(w.nodes[1].rect.w)).abs() < 1.0, "the wide button is as wide as its preferred size: {wide:?}"); From 38f28d231b06a13ec7b7f94c71b2df7f9b0c426b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 11:23:33 -0800 Subject: [PATCH 7/8] Paint: the early target read names the case it still covers item_target now reads `target` with `ids` or `id` too, so the comment above the early read in apply_paint_opacity names only the case it still covers: selected characters take the paint before item_target runs. --- crates/engine/src/cmd/paint.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index c3e64db4d0..b8136e8cf5 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -945,8 +945,8 @@ fn apply_paint_opacity(s: &mut Session, p: &Value, paint: Option, opacity let cmd = if fill { "paint.setFill" } else { "paint.setStroke" }; let for_tool = tool_color_params(s, p, cmd, !fill)?; let p = for_tool.as_ref().unwrap_or(p); - // A bad `target` or `aligned` is refused for every kind of target: `item_target` reads no - // `target` once `id` or `ids` names an object, and selected characters read neither. + // A bad `target` or `aligned` is refused for every kind of target: selected characters take + // the paint before `item_target` reads either. super::appearance::aligned(p, cmd)?; super::appearance::targets_contents(p)?; let focus = switch_or(p, "focus", true, cmd)?; From 8285a7b2cfc2189dfc8ee5ca99f67b98d09a9b63 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 12:22:26 -0800 Subject: [PATCH 8/8] Stroke: a test that stroke.set refuses a bad target with an id stroke.set names its appearance item through item_target_at as the paint commands do. The test fails without the change to item_target_at: stroke.set with `target: "content"` and an `id` answered {objects: 1}. --- crates/engine/src/tests/paintopacity.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/engine/src/tests/paintopacity.rs b/crates/engine/src/tests/paintopacity.rs index 38ce7b6a0d..fd88ff8e27 100644 --- a/crates/engine/src/tests/paintopacity.rs +++ b/crates/engine/src/tests/paintopacity.rs @@ -513,6 +513,23 @@ fn a_bad_target_is_refused_with_an_id_or_selected_characters() { } } +/// The other commands that name their appearance item the same way refuse a bad `target` with an +/// `id` or `ids` too, and leave the document alone; a good one still edits the object. +#[test] +fn a_stroke_edit_refuses_a_bad_target_with_an_id() { + let mut s = session(); + let r = rect(&mut s, 10.0); + select(&mut s, &[r]); + let doc = s.doc().unwrap().doc.clone(); + for p in [json!({"weight": 9, "target": "content", "id": r.0}), json!({"weight": 9, "target": "content", "ids": [r.0]})] { + let e = s.execute("stroke.set", &p).unwrap_err(); + assert!(e.to_string().contains("`target` must be"), "{p}: {e}"); + assert_eq!(*s.doc().unwrap().doc, *doc, "{p}"); + } + s.execute("stroke.set", &json!({"weight": 9, "target": "object", "id": r.0})).unwrap(); + assert_ne!(*s.doc().unwrap().doc, *doc); +} + /// A gradient mesh point picked with the Mesh tool takes a fill opacity itself, and the proxy shows /// it; the object's fill item and the other points stay as they were. #[test]