From 606e264f6df268b4dff8d5ac075b2017aabfd4fb Mon Sep 17 00:00:00 2001 From: Homero Thompson Date: Wed, 4 Nov 2026 05:59:52 +0000 Subject: [PATCH] UI: the Dependents button of the INSPECT HISTORY ribbon no longer fails without a feature (#11642) --- .../pending/timeline-dependents-button.json | 10 ++++ crates/ui-egui/src/lib.rs | 20 +++++++ .../ui-egui/src/timeline_dependents_tests.rs | 54 +++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 assets/locales/pending/timeline-dependents-button.json create mode 100644 crates/ui-egui/src/timeline_dependents_tests.rs diff --git a/assets/locales/pending/timeline-dependents-button.json b/assets/locales/pending/timeline-dependents-button.json new file mode 100644 index 000000000..1176e368a --- /dev/null +++ b/assets/locales/pending/timeline-dependents-button.json @@ -0,0 +1,10 @@ +{ + "en": { "ui.dependents_select_first": "Select what to list the dependents of first" }, + "ar": { "ui.dependents_select_first": "حدّد أولًا ما تريد سرد معتمداته" }, + "de": { "ui.dependents_select_first": "Wählen Sie zuerst aus, wessen Abhängige aufgelistet werden sollen" }, + "he": { "ui.dependents_select_first": "בחרו קודם מה להציג את התלויים שלו" }, + "ja": { "ui.dependents_select_first": "先に、依存先を表示する対象を選択してください" }, + "ko": { "ui.dependents_select_first": "먼저 종속 항목을 표시할 대상을 선택하세요" }, + "vi": { "ui.dependents_select_first": "Hãy chọn trước đối tượng để liệt kê các phần phụ thuộc của nó" }, + "zh": { "ui.dependents_select_first": "请先选择要列出其依赖项的对象" } +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index f960a6876..8ab93ba2a 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -131,6 +131,8 @@ mod surface_clamp_tests; #[cfg(test)] mod surface_errors_tests; #[cfg(test)] +mod timeline_dependents_tests; +#[cfg(test)] mod timeline_marks_tests; #[cfg(test)] mod status_tests { @@ -1610,6 +1612,24 @@ impl SolveApp { } return; } + // The Dependents button of INSPECT ▸ HISTORY asks for the dependents of ONE + // feature, so it needs a target. With nothing selected it used to run the + // command with no feature and the engine answered "Feature Dependents: + // `feature` must be an id or name". It reports the dependents of what is + // selected, one command call per selected feature. + if id == "timeline.dependents" { + let selected = timeline::selected_feature_ids(self); + if selected.is_empty() { + self.set_status(self.tr("ui.dependents_select_first"), false); + return; + } + for feature_id in selected { + if let Err(why) = self.run("timeline.dependents", json!({ "feature": feature_id })) { + self.set_status(why, true); + } + } + return; + } // Front … Isometric (Ctrl+1…7 by default) turn the view as the view cube's faces do. The // flat pattern is a 2D page: it has no other side to turn to. if solidcraft_engine::standard_view(id).is_some() { diff --git a/crates/ui-egui/src/timeline_dependents_tests.rs b/crates/ui-egui/src/timeline_dependents_tests.rs new file mode 100644 index 000000000..49d92108f --- /dev/null +++ b/crates/ui-egui/src/timeline_dependents_tests.rs @@ -0,0 +1,54 @@ +//! The Dependents button of INSPECT ▸ HISTORY asks the engine for the dependents of ONE +//! feature. The button used to run `timeline.dependents` with no `feature` at all, and the +//! engine answered "`feature` must be an id or name" (#12007). With nothing selected it now +//! says what to pick, and with a feature selected it asks about that feature. + +use serde_json::json; + +use crate::scenario::Harness; + +/// A design with a body and a feature on it, so the timeline has something to ask about. +fn design() -> Harness { + let mut h = Harness::new(); + h.app.run("solid.box", json!({"length": 20, "width": 20, "height": 10})).unwrap(); + h.app.run("sketch.create", json!({"plane": "XY", "name": "S1"})).unwrap(); + h.app.run("sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [10, 10]})).unwrap(); + h.app.run("sketch.finish", json!({})).unwrap(); + h.app.run("solid.extrude", json!({"distance": 5})).unwrap(); + h.frames(2); + h +} + +/// With nothing selected the button says what to pick, and the engine is never asked. +#[test] +fn the_dependents_button_with_nothing_selected_says_what_to_pick() { + let mut h = design(); + h.app.run("select.clear", json!({})).unwrap(); + h.frames(2); + + // What the ribbon button does: `app.start(id)` with no parameters. + h.app.start("timeline.dependents"); + h.frames(2); + + let (text, _, error) = h.app.status.clone().expect("the button says what to pick"); + assert!(!error, "the button must not report a failure: {text}"); + assert_eq!(text, h.app.tr("ui.dependents_select_first")); + assert!(!text.contains("must be an id or name"), "{text}"); +} + +/// With a feature selected the button asks the engine about that feature, and the engine +/// answers instead of refusing the missing `feature`. +#[test] +fn the_dependents_button_with_a_feature_selected_asks_the_engine() { + let mut h = design(); + let id = h.app.session.doc.find_feature("S1").expect("the sketch").id; + h.app.run("select.set", json!({"items": [{"type": "feature", "id": id}]})).unwrap(); + h.frames(2); + + h.app.start("timeline.dependents"); + h.frames(2); + + let log = h.app.session.log.join("\n"); + assert!(!log.contains("must be an id or name"), "the engine refused the feature: {log}"); + assert!(log.contains("Feature Dependents done"), "the engine never answered: {log}"); +}