SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
History: list a sketch under the feature built from it (#6489) (#6494)
Lars Jansenf1cc49bcdb79
diff --git a/assets/locales/pending/history-sketches-under-feature.json b/assets/locales/pending/history-sketches-under-feature.jsonnew file mode 100644index 0000000000..042526bc59--- /dev/null+++ b/assets/locales/pending/history-sketches-under-feature.json@@ -0,0 +1,23 @@+{+ "en": {+ "prefs.history_sketches": "Sketches",+ "prefs.history_sketches_in_order": "In order",+ "prefs.history_sketches_note": "With Sketches set to Under their feature, the History at the left lists each sketch one level in, under the first feature built from it, whenever it is wide enough for names. The timeline at the bottom always keeps the creation order.",+ "prefs.history_sketches_under_feature": "Under their feature",+ "ui.history_sketch_listed_under": "Listed under {feature}"+ },+ "ja": {+ "prefs.history_sketches": "スケッチ",+ "prefs.history_sketches_in_order": "作成順",+ "prefs.history_sketches_note": "スケッチ:「フィーチャーの下」では、左側の履歴に名前が表示される幅があるとき、スケッチをそれから作成した最初のフィーチャーの下に 1 段字下げして表示します。下部のタイムラインは常に作成順です。",+ "prefs.history_sketches_under_feature": "フィーチャーの下",+ "ui.history_sketch_listed_under": "{feature} の下に表示"+ },+ "zh": {+ "prefs.history_sketches": "草图",+ "prefs.history_sketches_in_order": "按创建顺序",+ "prefs.history_sketches_note": "草图:选择“位于其特征下”后,左侧历史在宽度足以显示名称时,会将草图缩进一级,列在由其创建的第一个特征下。底部时间轴始终保持创建顺序。",+ "prefs.history_sketches_under_feature": "位于其特征下",+ "ui.history_sketch_listed_under": "列在 {feature} 下"+ }+}diff --git a/crates/ui-egui/src/history_rows.rs b/crates/ui-egui/src/history_rows.rsnew file mode 100644index 0000000000..37ee998ffc--- /dev/null+++ b/crates/ui-egui/src/history_rows.rs@@ -0,0 +1,339 @@+//! The rows of the feature History with sketches listed under the features built from them+//! (#6489): which feature each sketch is listed under, which later features point back at a sketch+//! listed under an earlier one, and which timeline position a drop above each row stands for.+//!+//! Plain data with no UI in it, so every place that draws the History lists sketches the same+//! way: the vertical History (`timeline_left`) draws exactly these rows, and another host (a+//! History in the browser) can draw them and map its drop slots from the same rows.++use std::collections::{BTreeMap, BTreeSet};++use solidcraft_engine::doc::{Feature, FeatureKind, TimelineGroup};++/// A timeline feature as the History needs it.+#[derive(Clone, Debug, PartialEq, Eq)]+pub(crate) struct HistoryFeature {+ pub id: u64,+ /// The feature is a sketch.+ pub sketch: bool,+ /// The sketches the feature is built from (`FeatureKind::input_sketches`: profiles, paths,+ /// points). Empty for a sketch: a sketch is never listed under another sketch.+ pub inputs: Vec<u64>,+}++impl HistoryFeature {+ pub(crate) fn of(feature: &Feature) -> Self {+ let sketch = matches!(feature.kind, FeatureKind::Sketch { .. });+ Self { id: feature.id, sketch, inputs: if sketch { Vec::new() } else { feature.kind.input_sketches() } }+ }+}++/// A sketch row one level in, under the feature built from it.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) struct ListedSketch {+ pub sketch: u64,+ /// The sketch's position in the timeline.+ pub index: usize,+ /// The sketch is listed under an earlier feature, and this row only points at it: it selects+ /// that sketch, isn't dragged and isn't a drop slot.+ pub reference: bool,+}++/// A row of its own, in timeline order: a feature with the sketches listed under it, or a sketch+/// no feature lists.+#[derive(Clone, Debug, PartialEq, Eq)]+pub(crate) struct HistoryRow {+ pub feature: u64,+ /// The feature's position in the timeline.+ pub index: usize,+ /// The row is a sketch (one that no feature lists).+ pub sketch: bool,+ /// The timeline position a drop just above the row stands for: where a moved feature goes and+ /// where the history marker rolls to. It comes before the sketches listed under the row that+ /// follow the previous row (or folder header, or marker), so they are moved or rolled back with+ /// it. A drop below the last row stands for the end of the timeline.+ pub slot: usize,+ /// The sketches listed one level in, in timeline order.+ pub listed: Vec<ListedSketch>,+}++/// The History's rows, in timeline order.+#[derive(Clone, Debug, Default, PartialEq, Eq)]+pub(crate) struct HistoryRows {+ pub rows: Vec<HistoryRow>,+ /// Sketch → the feature it is listed under (not its reference rows).+ hosts: BTreeMap<u64, u64>,+}++impl HistoryRows {+ /// Every feature and sketch a row of its own, in creation order: `(id, is a sketch)` for each+ /// feature in timeline order.+ pub(crate) fn in_order(features: impl IntoIterator<Item = (u64, bool)>) -> Self {+ let rows = features+ .into_iter()+ .enumerate()+ .map(|(index, (feature, sketch))| HistoryRow { feature, index, sketch, slot: index, listed: Vec::new() })+ .collect();+ Self { rows, hosts: BTreeMap::new() }+ }++ /// The feature `sketch` is listed under, when it is.+ pub(crate) fn host(&self, sketch: u64) -> Option<u64> {+ self.hosts.get(&sketch).copied()+ }++ /// The row of the feature at timeline position `index`, when it has a row of its own.+ pub(crate) fn row_at(&self, index: usize) -> Option<&HistoryRow> {+ self.rows.binary_search_by_key(&index, |row| row.index).ok().and_then(|at| self.rows.get(at))+ }++ /// Whether a reference row points at `sketch`.+ pub(crate) fn referenced(&self, sketch: u64) -> bool {+ self.rows.iter().flat_map(|row| &row.listed).any(|listed| listed.reference && listed.sketch == sketch)+ }++ /// The sketches listed under `feature` (not its reference rows): they move with it.+ pub(crate) fn listed_under(&self, feature: u64) -> impl Iterator<Item = u64> + '_ {+ self.hosts.iter().filter(move |(_, host)| **host == feature).map(|(sketch, _)| *sketch)+ }++ /// `features` and the sketches listed under them, which a move takes along.+ pub(crate) fn with_listed(&self, features: &[u64]) -> Vec<u64> {+ let mut all = features.to_vec();+ for sketch in features.iter().flat_map(|feature| self.listed_under(*feature)) {+ if !all.contains(&sketch) {+ all.push(sketch);+ }+ }+ all+ }+}++/// The History's rows with each sketch listed under the first feature built from it.+///+/// - A sketch is listed one level in under the first feature built from it when that feature is+/// not a sketch, comes after it, is in the same timeline folder and is on the same side of the+/// history marker (`marker`: the features at or after it are rolled back; `None` for none). With+/// the marker between them the sketch exists and the feature doesn't, so the sketch keeps a row+/// of its own. A sketch no feature uses, or one its first feature can't list, keeps its row too.+/// - With `reference_rows`, each later feature built from a listed sketch also lists it, as a+/// reference row.+pub(crate) fn rows(features: &[HistoryFeature], folders: &[TimelineGroup], marker: Option<usize>, reference_rows: bool) -> HistoryRows {+ let marker = marker.unwrap_or(features.len());+ let sketches: BTreeMap<u64, usize> =+ features.iter().enumerate().filter(|(_, feature)| feature.sketch).map(|(index, feature)| (feature.id, index)).collect();+ // A feature's folder: the first folder that holds it, as the timeline finds it.+ let mut folder_of = BTreeMap::new();+ for folder in folders {+ for feature in &folder.features {+ folder_of.entry(*feature).or_insert(folder.id);+ }+ }+ let mut hosts = BTreeMap::new();+ let mut listed: BTreeMap<usize, Vec<ListedSketch>> = BTreeMap::new();+ // Sketches whose first feature has been met, listed or not.+ let mut used = BTreeSet::new();+ for (index, feature) in features.iter().enumerate() {+ if feature.sketch {+ continue;+ }+ let mut inputs: Vec<(usize, u64)> =+ feature.inputs.iter().filter_map(|sketch| sketches.get(sketch).map(|at| (*at, *sketch))).filter(|(at, _)| *at < index).collect();+ inputs.sort_unstable();+ inputs.dedup();+ for (at, sketch) in inputs {+ let reference = if used.insert(sketch) {+ let marker_between = at < marker && marker <= index;+ if marker_between || folder_of.get(&sketch) != folder_of.get(&feature.id) {+ continue;+ }+ hosts.insert(sketch, feature.id);+ false+ } else if reference_rows && hosts.contains_key(&sketch) {+ true+ } else {+ continue;+ };+ listed.entry(index).or_default().push(ListedSketch { sketch, index: at, reference });+ }+ }+ // A drop above a row comes before the listed sketches that follow the previous row; a folder+ // header and the marker are drawn at their own positions, so the slot after them starts there.+ let starts = folder_starts(features, folders);+ let mut rows = Vec::new();+ let mut slot = 0;+ for (index, feature) in features.iter().enumerate() {+ if index == marker || starts.contains(&index) {+ slot = index;+ }+ if hosts.contains_key(&feature.id) {+ continue;+ }+ rows.push(HistoryRow { feature: feature.id, index, sketch: feature.sketch, slot, listed: listed.remove(&index).unwrap_or_default() });+ slot = index + 1;+ }+ HistoryRows { rows, hosts }+}++/// The timeline positions where a folder's header is drawn: before its first feature, its own or+/// a nested folder's.+fn folder_starts(features: &[HistoryFeature], folders: &[TimelineGroup]) -> BTreeSet<usize> {+ let positions: BTreeMap<u64, usize> = features.iter().enumerate().map(|(index, feature)| (feature.id, index)).collect();+ let mut first: BTreeMap<u64, usize> = BTreeMap::new();+ for folder in folders {+ for at in folder.features.iter().filter_map(|feature| positions.get(feature)) {+ // The folder and each one above it; a hand-edited cycle stops after every folder.+ let mut current = Some(folder.id);+ for _ in 0..=folders.len() {+ let Some(id) = current else { break };+ let start = first.entry(id).or_insert(*at);+ *start = (*start).min(*at);+ current = folders.iter().find(|candidate| candidate.id == id).and_then(|candidate| candidate.parent);+ }+ }+ }+ first.into_values().collect()+}++#[cfg(test)]+mod tests {+ use super::*;++ fn sketch(id: u64) -> HistoryFeature {+ HistoryFeature { id, sketch: true, inputs: Vec::new() }+ }++ fn built(id: u64, inputs: &[u64]) -> HistoryFeature {+ HistoryFeature { id, sketch: false, inputs: inputs.to_vec() }+ }++ fn folder(id: u64, features: &[u64], parent: Option<u64>) -> TimelineGroup {+ TimelineGroup { id, name: format!("Folder{id}"), parent, features: features.to_vec() }+ }++ /// The top-level rows as `(feature, slot, listed sketches as (sketch, reference))`.+ fn shape(rows: &HistoryRows) -> Vec<(u64, usize, Vec<(u64, bool)>)> {+ rows.rows.iter().map(|row| (row.feature, row.slot, row.listed.iter().map(|listed| (listed.sketch, listed.reference)).collect())).collect()+ }++ #[test]+ fn in_order_gives_every_feature_a_row_at_its_own_position() {+ let rows = HistoryRows::in_order([(1, true), (2, false), (3, true)]);+ assert_eq!(shape(&rows), vec![(1, 0, vec![]), (2, 1, vec![]), (3, 2, vec![])]);+ assert_eq!(rows.rows.iter().map(|row| row.sketch).collect::<Vec<_>>(), vec![true, false, true]);+ assert_eq!(rows.host(1), None);+ assert_eq!(rows.row_at(1).map(|row| row.feature), Some(2));+ assert_eq!(rows.with_listed(&[2]), vec![2]);+ }++ #[test]+ fn a_sketch_is_listed_under_the_first_feature_built_from_it() {+ // Profile → Block, Pocket → Second, and Unused, which no feature uses.+ let features = [sketch(1), built(2, &[1]), sketch(3), built(4, &[3]), sketch(5)];+ let rows = rows(&features, &[], None, true);+ assert_eq!(shape(&rows), vec![(2, 0, vec![(1, false)]), (4, 2, vec![(3, false)]), (5, 4, vec![])]);+ assert_eq!(rows.rows.last().map(|row| row.sketch), Some(true), "a sketch no feature uses is a row of its own");+ assert_eq!((rows.host(1), rows.host(3), rows.host(5)), (Some(2), Some(4), None));+ assert_eq!(rows.row_at(0), None, "a listed sketch has no row of its own");+ assert_eq!(rows.rows.first().and_then(|row| row.listed.first()).map(|listed| listed.index), Some(0));+ assert_eq!(rows.with_listed(&[4, 2]), vec![4, 2, 3, 1], "a move takes the listed sketches along");+ }++ #[test]+ fn later_features_point_at_a_shared_sketch_only_with_reference_rows() {+ let features = [sketch(1), built(2, &[1]), built(3, &[1])];+ let with = rows(&features, &[], None, true);+ assert_eq!(shape(&with), vec![(2, 0, vec![(1, false)]), (3, 2, vec![(1, true)])]);+ assert!(with.referenced(1));+ assert_eq!(with.with_listed(&[3]), vec![3], "a reference row doesn't move the sketch");+ assert_eq!(with.listed_under(3).count(), 0);+ let without = rows(&features, &[], None, false);+ assert_eq!(shape(&without), vec![(2, 0, vec![(1, false)]), (3, 2, vec![])]);+ assert!(!without.referenced(1));+ }++ #[test]+ fn the_marker_between_a_sketch_and_its_feature_keeps_the_sketch_a_row_of_its_own() {+ let features = [sketch(1), built(2, &[1]), built(3, &[1])];+ // The sketch exists, its features don't: no row lists it, not even as a reference.+ assert_eq!(shape(&rows(&features, &[], Some(1), true)), vec![(1, 0, vec![]), (2, 1, vec![]), (3, 2, vec![])]);+ // Both rolled back, or both before the marker: listed.+ assert_eq!(shape(&rows(&features, &[], Some(0), true)), vec![(2, 0, vec![(1, false)]), (3, 2, vec![(1, true)])]);+ assert_eq!(shape(&rows(&features, &[], Some(2), true)), vec![(2, 0, vec![(1, false)]), (3, 2, vec![(1, true)])]);+ }++ #[test]+ fn a_sketch_in_another_folder_than_its_feature_keeps_its_row() {+ let features = [sketch(1), built(2, &[1]), sketch(3), built(4, &[3])];+ let folders = [folder(10, &[1], None), folder(11, &[3, 4], None)];+ assert_eq!(shape(&rows(&features, &folders, None, true)), vec![(1, 0, vec![]), (2, 1, vec![]), (4, 2, vec![(3, false)])]);+ // Its later features don't list it either.+ let features = [sketch(1), built(2, &[1]), built(3, &[1])];+ assert_eq!(shape(&rows(&features, &[folder(10, &[2], None)], None, true)), vec![(1, 0, vec![]), (2, 1, vec![]), (3, 2, vec![])]);+ }++ #[test]+ fn a_drop_above_a_row_comes_before_the_sketches_listed_under_it() {+ // Sketches drawn ahead of their features, either way round.+ let features = [sketch(1), sketch(2), built(3, &[1]), built(4, &[2])];+ assert_eq!(shape(&rows(&features, &[], None, true)), vec![(3, 0, vec![(1, false)]), (4, 3, vec![(2, false)])]);+ let features = [sketch(2), sketch(1), built(3, &[1]), built(4, &[2])];+ assert_eq!(shape(&rows(&features, &[], None, true)), vec![(3, 0, vec![(1, false)]), (4, 3, vec![(2, false)])]);+ // A folder header between a sketch and its feature: the folder's rows start at the folder.+ let features = [sketch(1), built(2, &[]), built(3, &[]), built(4, &[1])];+ let folders = [folder(10, &[2, 3], None)];+ assert_eq!(shape(&rows(&features, &folders, None, true)), vec![(2, 1, vec![]), (3, 2, vec![]), (4, 3, vec![(1, false)])]);+ // A folder that starts with a listed sketch: the drop above its feature goes inside it.+ let features = [built(1, &[]), sketch(2), built(3, &[2])];+ let folders = [folder(10, &[2, 3], None)];+ assert_eq!(shape(&rows(&features, &folders, None, true)), vec![(1, 0, vec![]), (3, 1, vec![(2, false)])]);+ // A nested folder starts its parent too.+ let folders = [folder(10, &[], None), folder(11, &[2, 3], Some(10))];+ assert_eq!(folder_starts(&features, &folders), BTreeSet::from([1]));+ }++ #[test]+ fn several_sketches_and_odd_inputs_are_listed_once_in_timeline_order() {+ // A feature built from two sketches (a sweep's profile and path), named twice and out of+ // order, plus a sketch that comes after it and an id that isn't in the timeline.+ let features = [sketch(1), built(2, &[]), sketch(3), built(4, &[3, 1, 3, 5, 99]), sketch(5)];+ // The drop above the first row comes before the sketch listed under the later one.+ assert_eq!(shape(&rows(&features, &[], None, true)), vec![(2, 0, vec![]), (4, 2, vec![(1, false), (3, false)]), (5, 4, vec![])]);+ // A sketch never lists another sketch.+ let features = [sketch(1), HistoryFeature { id: 2, sketch: true, inputs: vec![1] }];+ assert_eq!(shape(&rows(&features, &[], None, true)), vec![(1, 0, vec![]), (2, 1, vec![])]);+ }++ #[test]+ fn features_read_the_sketches_they_are_built_from_out_of_the_design() {+ use serde_json::json;+ let mut session = solidcraft_engine::Session::default();+ for (command, params) in [+ ("sketch.create", json!({"plane": "XY", "name": "Profile"})),+ ("sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [10, 10]})),+ ("sketch.finish", json!({})),+ ("solid.extrude", json!({"sketch": "Profile", "distance": 5, "operation": "new", "name": "Block"})),+ ("solid.extrude", json!({"sketch": "Profile", "distance": 5, "operation": "new", "name": "Copy"})),+ ] {+ session.execute(command, ¶ms).unwrap();+ }+ let id = |name: &str| session.doc.find_feature(name).unwrap().id;+ let features: Vec<HistoryFeature> = session.doc.features.iter().map(HistoryFeature::of).collect();+ assert_eq!(+ features.iter().map(|feature| (feature.id, feature.sketch)).collect::<Vec<_>>(),+ vec![(id("Profile"), true), (id("Block"), false), (id("Copy"), false)]+ );+ assert!(features.iter().skip(1).all(|feature| !feature.inputs.is_empty() && feature.inputs.iter().all(|sketch| *sketch == id("Profile"))));+ let rows = rows(&features, &session.doc.timeline_groups, session.doc.marker, true);+ assert_eq!(rows.host(id("Profile")), Some(id("Block")));+ assert!(rows.referenced(id("Profile")));+ }++ #[test]+ fn hand_edited_folders_cannot_hang_it() {+ let features = [sketch(1), built(2, &[1])];+ let cycle = [folder(10, &[1, 2], Some(11)), folder(11, &[], Some(10)), folder(10, &[2], None)];+ assert_eq!(shape(&rows(&features, &cycle, None, true)), vec![(2, 0, vec![(1, false)])]);+ assert_eq!(shape(&rows(&[], &cycle, Some(7), true)), vec![]);+ }+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 6ee63053c2..d29a7815ef 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -68,6 +68,7 @@ pub mod frame_rate;pub mod gizmo;pub mod gpu;pub mod help;+pub(crate) mod history_rows;#[cfg(test)]mod hole_direction_ui_tests;pub(crate) mod hole_place;diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex 8f7390a983..3f39e1a3b1 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -319,6 +319,19 @@ impl NavigatorStyle {}}+/// How the History at the left lists sketches (Preferences: "Sketches", #6489). The timeline+/// along the bottom always keeps the creation order.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]+#[serde(rename_all = "snake_case")]+pub enum HistorySketches {+ /// Every sketch is a row of its own, in creation order (how it always was). Also what a+ /// value this version doesn't know reads as (`lenient`).+ #[default]+ InOrder,+ /// A sketch a feature is built from is listed one level in, under that feature.+ UnderFeature,+}+/// What an orbit turns around (Preferences: "Orbit around").#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "snake_case")]@@ -633,6 +646,8 @@ preference_settings! {timeline_collapsed: bool = false, PAGE_INTERFACE;/// Whether the browser beside the vertical history is collapsed to its rail.timeline_left_browser_collapsed: bool = false, PAGE_INTERFACE;+ /// Whether the History at the left lists a sketch under the feature built from it.+ history_sketches: HistorySketches = HistorySketches::default(), PAGE_INTERFACE;/// Width of the browser sidebar, which/// the user drags wider or narrower at its right edge.browser_width: f32 = DEFAULT_BROWSER_WIDTH, PAGE_INTERFACE;@@ -3384,6 +3399,7 @@ mod tests {("ribbon_labels", json!(false), PAGE_INTERFACE),("timeline_left", json!(true), PAGE_INTERFACE),("timeline_under_browser", json!(true), PAGE_INTERFACE),+ ("history_sketches", json!("under_feature"), PAGE_INTERFACE),("browser_float", json!(true), PAGE_INTERFACE),("color_vision", json!("protan"), PAGE_INTERFACE),("viewport_theme", json!("light"), PAGE_INTERFACE),@@ -3976,6 +3992,41 @@ mod tests {assert_eq!(h.app.session.doc.to_json(), design);}+ #[test]+ fn history_sketches_defaults_in_order_and_follows_preferences_transactions() {+ let old: Prefs = serde_json::from_value(json!({"timeline_left": true})).unwrap();+ assert_eq!(old.history_sketches, HistorySketches::InOrder, "designs and settings from before keep the creation order");+ assert_eq!(lenient(&json!({"history_sketches": "sideways"})).history_sketches, HistorySketches::InOrder);+ let mut h = crate::scenario::Harness::new();+ h.call("ui.prefs", json!({"timeline_left": true, "timeline_under_browser": true}));+ let design = h.app.session.doc.to_json();+ h.call("ui.prefs", json!({"open": "Interface"}));+ let row = h.app.tr("prefs.history_sketches").to_string();+ let under = h.app.tr("prefs.history_sketches_under_feature").to_string();+ let handle = format!("dialog:{row}:{under}");+ super::reveal_preference(&mut h, &handle);+ let at = crate::scenario::handle_at(&handle).unwrap();+ h.call("ui.click", json!({"x": at.x, "y": at.y}));+ assert_eq!(h.app.preferences.history_sketches, HistorySketches::UnderFeature);+ assert_eq!(h.app.session.doc.to_json(), design, "the preference changes only the History");+ h.call("ui.prefs", json!({"button": "cancel"}));+ assert_eq!(h.app.preferences.history_sketches, HistorySketches::InOrder);++ let reply = h.call("ui.prefs", json!({"history_sketches": "under_feature"}));+ assert_eq!(reply["result"]["history_sketches"], "under_feature");+ let mut restored = SolveApp::new(solidcraft_engine::Session::default(), Default::default());+ restored.load_prefs(&h.app.prefs());+ assert_eq!(restored.preferences.history_sketches, HistorySketches::UnderFeature);+ let before = h.app.preferences.clone();+ assert!(control(&mut h.app, &json!({"history_sketches": "sideways"})).is_err());+ assert_eq!(h.app.preferences, before, "an unknown value changes nothing");+ h.call("ui.prefs", json!({"open": "Interface"}));+ h.call("ui.prefs", json!({"button": "defaults"}));+ assert_eq!(h.app.preferences.history_sketches, HistorySketches::InOrder);+ h.call("ui.prefs", json!({"button": "cancel"}));+ assert_eq!(h.app.preferences.history_sketches, HistorySketches::UnderFeature);+ }+#[test]fn free_orbit_defaults_off_and_follows_preferences_transactions() {let old: Prefs = serde_json::from_value(json!({"nav":"solidworks"})).unwrap();diff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rsindex d01c6683af..579bb4ff84 100644--- a/crates/ui-egui/src/prefs/interface.rs+++ b/crates/ui-egui/src/prefs/interface.rs@@ -63,6 +63,21 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {crate::scenario::publish_handle(&format!("dialog:{row}:{}", app.tr(legacy)), at);}}+ // Only the History at the left can list a sketch under its feature (#6489).+ ui_kit::row(ui, app.tr("prefs.history_sketches"), |ui| {+ ui.add_enabled_ui(app.preferences.timeline_left, |ui| {+ let mut selected = usize::from(app.preferences.history_sketches == HistorySketches::UnderFeature);+ if ui_kit::segmented(+ ui,+ &mut selected,+ &[app.tr("prefs.history_sketches_in_order"), app.tr("prefs.history_sketches_under_feature")],+ ui_kit::Segments { proportional: true, compact: true, ..Default::default() },+ ) {+ app.preferences.history_sketches =+ if selected == 1 { HistorySketches::UnderFeature } else { HistorySketches::InOrder };+ }+ });+ });ui_kit::row(ui, app.tr("prefs.browser"), |ui| {ui.add_enabled_ui(app.ui.layout == crate::shell::LayoutMode::Floating, |ui| {let mut selected = usize::from(app.preferences.browser_float);@@ -77,6 +92,7 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {crate::scenario::publish_target("prefs:view_confirm_corner", check.rect);});ui_kit::text(ui, app.tr("prefs.layout_note"), ui_kit::Text::Hint("layout"));+ ui_kit::text(ui, app.tr("prefs.history_sketches_note"), ui_kit::Text::Hint("history_sketches"));ui_kit::LayoutPreview {compact: app.ui.layout == crate::shell::LayoutMode::Docked,labels: app.preferences.ribbon_labels,diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rsindex 1bc0c96efc..4fa7dda6b0 100644--- a/crates/ui-egui/src/timeline.rs+++ b/crates/ui-egui/src/timeline.rs@@ -543,6 +543,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {suppressed: *suppressed,error: err.is_some(),warning: warn.is_some(),+ reference: false,// A dragged feature takes the colour of its drop bar.accent: if drag == Some(Drag::Feature(*id)) { crate::theme::TabAccent::for_tab(&t, "SKETCH") } else { accent },}diff --git a/crates/ui-egui/src/timeline_left.rs b/crates/ui-egui/src/timeline_left.rsindex ccaf7b6cab..c3f7403b87 100644--- a/crates/ui-egui/src/timeline_left.rs+++ b/crates/ui-egui/src/timeline_left.rs@@ -4,6 +4,7 @@ use crate::ui_kit::{Container, Edge, Surface};use egui::{Rect, Sense, Stroke, pos2, vec2};use serde_json::json;+use crate::history_rows::{HistoryFeature, HistoryRows};use crate::theme::Tokens;use crate::timeline::{TimelineKind, clipboard_buttons, delete_after_marker_button, delete_feature, delete_features, icon_of, message_button, selected_feature_ids,@@ -673,8 +674,12 @@ pub fn delete_selected_folders(app: &mut SolveApp) -> bool {true}-/// Open the folder holding this feature and every folder above it, so its row is shown.+/// Open the folder holding this feature and every folder above it, so its row is shown. A sketch+/// listed under the feature built from it also opens that feature's fold (#6489).pub fn reveal_feature(app: &mut SolveApp, feature: u64) {+ if let Some(host) = drawn_rows(app, nests(app)).host(feature) {+ app.tree.expanded.insert(sketches_key(host));+ }let groups = &app.session.doc.timeline_groups;let mut current = group_for(groups, feature);let mut steps = 0usize;@@ -771,10 +776,34 @@ fn group_last_feature(direct.into_iter().chain(children).max()}+/// Whether Sketches: Under their feature is on (#6489).+fn nests(app: &SolveApp) -> bool {+ app.preferences.history_sketches == crate::prefs::HistorySketches::UnderFeature+}++/// The rows the vertical History draws: with `nest`, `history_rows::rows` (each sketch listed+/// under the feature built from it, with reference rows); otherwise every feature a row of its+/// own, in creation order.+fn drawn_rows(app: &SolveApp, nest: bool) -> HistoryRows {+ let doc = &app.session.doc;+ if !nest {+ let sketch = |feature: &solidcraft_engine::doc::Feature| matches!(feature.kind, solidcraft_engine::doc::FeatureKind::Sketch { .. });+ return HistoryRows::in_order(doc.features.iter().map(|feature| (feature.id, sketch(feature))));+ }+ let features: Vec<HistoryFeature> = doc.features.iter().map(HistoryFeature::of).collect();+ crate::history_rows::rows(&features, &doc.timeline_groups, doc.marker, true)+}++/// The fold of a feature's listed sketches; closed until opened.+fn sketches_key(feature: u64) -> String {+ format!("timeline/feature/{feature}/sketches")+}+fn visible_order(app: &SolveApp,features: &[(u64, String, &'static str, bool, &'static str, TimelineKind)],groups: &[solidcraft_engine::doc::TimelineGroup],+ rows: &HistoryRows,) -> Vec<TimelineItem> {let mut order = Vec::new();let mut shown = std::collections::BTreeSet::new();@@ -786,10 +815,15 @@ fn visible_order(order.push(TimelineItem::Group(group.id));}}+ // A listed sketch follows the feature built from it.+ let Some(row) = rows.row_at(index) else { continue };let group_id = group_for(groups, *id);let open = group_id.is_none_or(|group_id| group_is_open(app, groups, group_id));if open {order.push(TimelineItem::Feature(*id));+ if !row.listed.is_empty() && crate::browser::is_open(app, &sketches_key(*id), false) {+ order.extend(row.listed.iter().filter(|listed| !listed.reference).map(|listed| TimelineItem::Feature(listed.sketch)));+ }}}let mut trailing: Vec<_> = groups.iter().filter(|group| !shown.contains(&group.id)).collect();@@ -932,6 +966,45 @@ fn vertical_group_row(open}+/// The fold-arrow column of a history row. With sketches listed under their features every row+/// keeps it, so the icons of rows with and without a fold line up.+const FOLD_COLUMN: f32 = 16.0;++/// Which row of a timeline feature the vertical history draws.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+enum RowKind {+ /// A row of its own, in timeline order.+ Own,+ /// A sketch one level in, under the feature built from it (#6489).+ Nested,+ /// A row under the feature at timeline position `parent` that points at a sketch listed under+ /// an earlier feature: it selects and lights up that sketch, and isn't dragged.+ Reference { parent: usize },+}++/// What the rows of one frame of the vertical history share.+struct Rows<'a> {+ names: bool,+ /// Sketches: Under their feature, while the History shows names (#6489).+ under_feature: bool,+ features: &'a [(u64, String, &'static str, bool, &'static str, TimelineKind)],+ groups: &'a [solidcraft_engine::doc::TimelineGroup],+ order: &'a [TimelineItem],+ /// The rows to draw (`drawn_rows`).+ plan: &'a HistoryRows,+ marker: usize,+ /// Find in Timeline: the feature to scroll into view this frame (#5850).+ reveal: Option<u64>,+ /// The feature whose body is under the pointer in the 3D view.+ from_view: Option<u64>,+ /// A sketch that has a reference row and one of whose rows was hovered last frame: all its+ /// rows light up.+ linked_hover: Option<u64>,+ drag: Option<Drag>,+ hovered: Option<u64>,+ edit: Option<u64>,+}+fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {let t = Tokens::get();ui.spacing_mut().item_spacing.y = if names { t.space_2 } else { t.space_4 };@@ -945,17 +1018,18 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {}).collect();let groups = app.session.doc.timeline_groups.clone();- let order = visible_order(app, &features, &groups);- // Find in Timeline: scroll the found feature into the history on this frame (#5850).- let reveal = app.tree.timeline_reveal.take();+ let n = features.len();+ let marker = app.session.doc.marker.unwrap_or(n);+ // The narrow icon strip has no room for nesting: it keeps the creation order.+ let under_feature = names && nests(app);+ let plan = drawn_rows(app, under_feature);+ let order = visible_order(app, &features, &groups, &plan);let first_indices: std::collections::BTreeMap<u64, Option<usize>> =groups.iter().map(|group| (group.id, group_first_feature(&groups, &features, group.id))).collect();let end_indices: std::collections::BTreeMap<u64, usize> = groups.iter().map(|group| (group.id, group_last_feature(&groups, &features, group.id).map_or(features.len(), |index| index.saturating_add(1)))).collect();- let n = features.len();- let marker = app.session.doc.marker.unwrap_or(n);let from_view = match &app.viewport.hover {Some(crate::viewport::Hit::Face { body, .. } | crate::viewport::Hit::Edge { body, .. } | crate::viewport::Hit::Vertex { body, .. }) => {app.session.world_state().body(body).map(|body| body.feature)@@ -963,17 +1037,29 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {_ => None,};let drag_id = ui.id().with("tl_vertical_drag");- let mut drag: Option<Drag> = ui.data(|data| data.get_temp(drag_id));+ let mut rows = Rows {+ names,+ under_feature,+ features: &features,+ groups: &groups,+ order: &order,+ plan: &plan,+ marker,+ reveal: app.tree.timeline_reveal.take(),+ from_view,+ linked_hover: app.viewport.hover_feature.filter(|id| plan.referenced(*id)),+ drag: ui.data(|data| data.get_temp(drag_id)),+ hovered: None,+ edit: None,+ };let pointer = ui.input(|input| input.pointer.hover_pos());let mut slots = Vec::new();let mut folder_drop_zones = Vec::new();let mut shown_groups = std::collections::BTreeSet::new();let mut previous_visible_group = None;- let mut hovered = None;- let mut edit = None;let mut marker_y = f32::INFINITY;- for (index, (id, name, icon, suppressed, ty, kind)) in features.iter().enumerate() {+ for (index, (id, ..)) in features.iter().enumerate() {let group_id = group_for(&groups, *id);let mut at_index: Vec<_> = groups.iter().filter(|group| first_indices.get(&group.id).copied().flatten() == Some(index)).collect();at_index.sort_by_key(|group| (group_depth(&groups, group.id), group.id));@@ -982,7 +1068,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {let group = at_index.first().and_then(|group| group.parent);let indent_group = previous_visible_group.filter(|previous| Some(*previous) != group);slots.push(VerticalSlot { y: ui.cursor().top(), position: index, group, indent_group });- marker_y = vertical_marker(app, ui, &mut drag);+ marker_y = vertical_marker(app, ui, &mut rows.drag);}let mut rendered_group_header = false;for group in at_index {@@ -994,7 +1080,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {group,&groups,&order,- &mut drag,+ &mut rows.drag,group_depth(&groups, group.id),index,end_indices.get(&group.id).copied().unwrap_or(index),@@ -1009,139 +1095,16 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {let indent_group = (!rendered_group_header).then_some(previous_visible_group).flatten().filter(|previous| Some(*previous) != group_id);if index == marker && !marker_before_group {slots.push(VerticalSlot { y: ui.cursor().top(), position: index, group: group_open.then_some(group_id).flatten(), indent_group });- marker_y = vertical_marker(app, ui, &mut drag);+ marker_y = vertical_marker(app, ui, &mut rows.drag);}+ // A sketch listed under a feature is drawn after that feature's row.+ let Some(row) = plan.row_at(index) else { continue };if !group_open {continue;}- slots.push(VerticalSlot { y: ui.cursor().top(), position: index, group: group_id, indent_group });- let indent = group_id.map(|id| (group_depth(&groups, id) + 1) as f32 * 14.0).unwrap_or(0.0);- let has_patterns = matches!(kind, TimelineKind::Sketch) && crate::sketch_pattern_tree::has_patterns(app, *id);- let pattern_key = format!("timeline/sketch/{id}/patterns");- let patterns_open = crate::browser::is_open(app, &pattern_key, true);- let style = if names { crate::ui_kit::HistoryStyle::Names } else { crate::ui_kit::HistoryStyle::Icons };- let (row, response) = ui.allocate_exact_size(vec2(ui.available_width(), style.height()), Sense::click_and_drag());- let rect = if style == crate::ui_kit::HistoryStyle::Icons {- Rect::from_center_size(row.center(), vec2(style.height(), style.height()))- } else {- row- };- crate::scenario::publish_rect(&format!("history:feature:{name}"), rect);- if reveal == Some(*id) {- ui.scroll_to_rect(rect, Some(egui::Align::Center));- }- let fold_rect = Rect::from_min_size(rect.left_top() + vec2(indent, 0.0), vec2(16.0, rect.height()));- let on_fold = has_patterns && response.interact_pointer_pos().is_some_and(|p| fold_rect.contains(p));- crate::scenario::publish_handle(&format!("timeline:{name}"), rect.center());- let result = app.session.model.result(*id);- let elapsed = result.map(|r| r.ms);- let error = result.and_then(|result| result.error.clone());- let warning = result.and_then(|result| result.warning.clone());- let rolled = index >= marker;- let selected =- app.session.selection.iter().any(|selection| matches!(selection, solidcraft_engine::Sel::Feature { id: selected } if selected == id));- // Folder and sketch-pattern disclosure targets retain their original handles.- let inset = if names { indent + if has_patterns { 16.0 } else { 0.0 } } else { 0.0 };- let chip = Rect::from_min_max(rect.min + vec2(inset.min(rect.width()), 0.0), rect.max);- crate::ui_kit::HistoryChip {- icon,- name,- kind: ty,- selected,- hovered: response.hovered() || from_view == Some(*id),- dim: rolled,- suppressed: *suppressed,- error: error.is_some(),- warning: warning.is_some(),- // Dragged features take the colour of their drop bar.- accent: crate::theme::TabAccent::for_tab(- &t,- if matches!(&drag, Some(Drag::Items(items)) if items.features.contains(id)) { "SKETCH" } else { &app.ui.tab },- ),- }- .paint(ui.painter(), chip, style);- if has_patterns {- crate::ui_kit::disclosure(ui.painter(), fold_rect.center(), patterns_open, t.text_dim);- crate::scenario::publish_handle(&format!("timeline-sketch-fold:{name}"), fold_rect.center());- }- if response.hovered() {- hovered = Some(*id);- }- if response.drag_started() && !on_fold {- if !selected {- select_only(app, TimelineItem::Feature(*id));- }- let origin_x = drag_press_x(&response, rect.center().x);- drag = Some(Drag::Items(selected_drag_items(app, origin_x, group_id)));- }- let mut tooltip = egui::Tooltip::for_enabled(&response);- tooltip.popup = tooltip.popup.align(egui::RectAlign::RIGHT_START);- tooltip.show(|ui| {- let summary = app- .session- .doc- .features- .get(index)- .and_then(|f| f.kind.expressions().first().map(ToString::to_string))- .unwrap_or_else(|| elapsed.map_or_else(String::new, |ms| format!("{ms:.1} ms")));- let kind = crate::i18n::tr_label(ty.strip_suffix("Feature").unwrap_or(ty));- let mut tip = format!("{name} · {kind} · {summary}");- if error.is_some() || warning.is_some() {- tip.push_str(&format!("\n{}", crate::timeline::status_text(name, ty, error.as_deref(), warning.as_deref())));- }- crate::ui_kit::text(ui, &tip, crate::ui_kit::Text::Value("history", false));- });- if response.clicked() && on_fold {- crate::browser::toggle(app, &pattern_key, true);- } else if response.clicked() && !crate::timeline::pick_feature_into_dialog(app, *id, ui.input(|i| i.modifiers)) {- select_item(app, ui, TimelineItem::Feature(*id), &order);- }- if response.double_clicked() && !on_fold {- edit = Some(*id);- }- let sketch = kind.profile_sketch();- if response.secondary_clicked() && !selected {- select_only(app, TimelineItem::Feature(*id));- }- crate::ui_kit::Menu::context(&response, |ui| {- if crate::context_menu::button(ui, "Edit Feature", "edit").clicked() {- edit = Some(*id);- ui.close();- }- if let Some(sketch) = sketch- && crate::context_menu::button(ui, "Edit Profile Sketch", "sketch").clicked()- {- app.edit_sketch(sketch.0);- ui.close();- }- if crate::context_menu::button(ui, "Rename Feature", "rename").clicked() {- crate::context_menu::start_rename(app, crate::context_menu::RenameWhat::Feature(*id), rect.center());- ui.close();- }- if crate::context_menu::button(ui, if *suppressed { "Unsuppress Feature" } else { "Suppress Feature" }, "suppress").clicked() {- let _ = app.run_heavy("timeline.suppress", json!({"feature": id}));- ui.close();- }- if crate::context_menu::button(ui, "Roll Back Here", "rollback").clicked() {- let _ = app.run_heavy("timeline.roll_to", json!({"feature": id}));- ui.close();- }- ui.separator();- clipboard_buttons(app, ui, *id);- message_button(app, ui, *id);- ui.separator();- selection_actions(app, ui, &groups);- ui.separator();- if crate::context_menu::button(ui, "Delete", "delete").clicked() {- delete_feature(app, *id);- ui.close();- }- delete_after_marker_button(app, ui, *id, index, marker);- });- if names && has_patterns && patterns_open {- let depth = group_id.map_or(1, |group| group_depth(&groups, group) + 2);- crate::sketch_pattern_tree::rows(app, ui, *id, depth, "timeline", None, false);- }+ slots.push(VerticalSlot { y: ui.cursor().top(), position: row.slot.min(index), group: group_id, indent_group });+ let indent = group_id.map(|id| (group_depth(&groups, id) + 1) as f32 * FOLDER_INDENT).unwrap_or(0.0);+ feature_row(app, ui, &mut rows, index, indent, RowKind::Own);previous_visible_group = group_id;}let mut trailing: Vec<_> = groups.iter().filter(|group| !shown_groups.contains(&group.id)).collect();@@ -1155,7 +1118,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {group,&groups,&order,- &mut drag,+ &mut rows.drag,group_depth(&groups, group.id),n,n,@@ -1167,12 +1130,13 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {}slots.push(VerticalSlot { y: ui.cursor().top(), position: n, group: None, indent_group: previous_visible_group });if marker >= n {- marker_y = vertical_marker(app, ui, &mut drag);+ marker_y = vertical_marker(app, ui, &mut rows.drag);// Below the marker at the end: a feature dropped here is rolled back.slots.push(VerticalSlot { y: ui.cursor().top(), position: n, group: None, indent_group: previous_visible_group });}crate::dialogs_assembly::timeline_joints_vertical(app, ui);+ let mut drag = rows.drag.take();if drag.is_some() {ui.ctx().set_cursor_icon(egui::CursorIcon::Grabbing);}@@ -1220,8 +1184,11 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {let valid_target = folder_target.is_none_or(|target| valid_folder_target(&items, &groups, target));if valid_target {let mut params = json!({"group": folder_target, "position": slot.position});- if !items.features.is_empty() {- params["features"] = json!(items.features);+ // A feature and the sketches listed under it move as one block (#6489); the+ // move's own checks refuse a place where anything would fail.+ let features = plan.with_listed(&items.features);+ if !features.is_empty() {+ params["features"] = json!(features);}if !items.groups.is_empty() {params["groups"] = json!(items.groups);@@ -1242,12 +1209,186 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {}None => data.remove::<Drag>(drag_id),});- app.viewport.hover_feature = hovered;- if let Some(feature) = edit {+ app.viewport.hover_feature = rows.hovered;+ if let Some(feature) = rows.edit {app.edit_feature(feature);}}+/// One feature's row at timeline position `index`, `indent` points in, and for a feature that+/// sketches are listed under, those sketches' rows when its fold is open.+fn feature_row(app: &mut SolveApp, ui: &mut egui::Ui, rows: &mut Rows, index: usize, indent: f32, row_kind: RowKind) {+ let t = Tokens::get();+ let (features, names, plan, groups, order, marker) = (rows.features, rows.names, rows.plan, rows.groups, rows.order, rows.marker);+ let Some((id, name, icon, suppressed, ty, kind)) = features.get(index) else { return };+ let id = *id;+ let group_id = group_for(groups, id);+ let reference = matches!(row_kind, RowKind::Reference { .. });+ let listed =+ (row_kind == RowKind::Own).then(|| plan.row_at(index)).flatten().map(|row| row.listed.as_slice()).filter(|listed| !listed.is_empty());+ let has_patterns = !reference && matches!(kind, TimelineKind::Sketch) && crate::sketch_pattern_tree::has_patterns(app, id);+ // One fold per row: a feature's listed sketches, or a sketch's patterns.+ let fold = match listed {+ Some(_) => Some((sketches_key(id), false)),+ None => has_patterns.then(|| (format!("timeline/sketch/{id}/patterns"), true)),+ };+ let fold_open = fold.as_ref().is_some_and(|(key, default)| crate::browser::is_open(app, key, *default));+ let style = if names { crate::ui_kit::HistoryStyle::Names } else { crate::ui_kit::HistoryStyle::Icons };+ let sense = if reference { Sense::click() } else { Sense::click_and_drag() };+ let (row, response) = ui.allocate_exact_size(vec2(ui.available_width(), style.height()), sense);+ let rect =+ if style == crate::ui_kit::HistoryStyle::Icons { Rect::from_center_size(row.center(), vec2(style.height(), style.height())) } else { row };+ let parent = match row_kind {+ RowKind::Reference { parent } => features.get(parent),+ _ => None,+ };+ match parent {+ Some(parent) => crate::scenario::publish_handle(&format!("timeline-reference:{}:{name}", parent.1), rect.center()),+ None => {+ crate::scenario::publish_rect(&format!("history:feature:{name}"), rect);+ crate::scenario::publish_handle(&format!("timeline:{name}"), rect.center());+ if rows.reveal == Some(id) {+ ui.scroll_to_rect(rect, Some(egui::Align::Center));+ }+ }+ }+ let fold_rect = Rect::from_min_size(rect.left_top() + vec2(indent, 0.0), vec2(FOLD_COLUMN, rect.height()));+ let on_fold = fold.is_some() && response.interact_pointer_pos().is_some_and(|p| fold_rect.contains(p));+ let result = app.session.model.result(id);+ let elapsed = result.map(|r| r.ms);+ let error = result.and_then(|result| result.error.clone());+ let warning = result.and_then(|result| result.warning.clone());+ let rolled = match row_kind {+ RowKind::Reference { parent } => parent >= marker,+ RowKind::Own | RowKind::Nested => index >= marker,+ };+ let selected =+ app.session.selection.iter().any(|selection| matches!(selection, solidcraft_engine::Sel::Feature { id: selected } if *selected == id));+ // Folder and sketch-pattern disclosure targets retain their original handles. Listing sketches+ // under their features keeps the fold column on every row, so the icons line up.+ let column = if rows.under_feature || fold.is_some() { FOLD_COLUMN } else { 0.0 };+ let inset = if names { indent + column } else { 0.0 };+ let chip = Rect::from_min_max(rect.min + vec2(inset.min(rect.width()), 0.0), rect.max);+ // Dragged features take the colour of their drop bar, with the sketches listed under them.+ let dragged = matches!(&rows.drag, Some(Drag::Items(items)) if items.features.contains(&id)+ || (row_kind == RowKind::Nested && plan.host(id).is_some_and(|host| items.features.contains(&host))));+ crate::ui_kit::HistoryChip {+ icon,+ name,+ kind: ty,+ selected,+ hovered: response.hovered() || rows.from_view == Some(id) || rows.linked_hover == Some(id),+ dim: rolled,+ suppressed: *suppressed,+ error: error.is_some(),+ warning: warning.is_some(),+ reference,+ accent: crate::theme::TabAccent::for_tab(&t, if dragged { "SKETCH" } else { &app.ui.tab }),+ }+ .paint(ui.painter(), chip, style);+ if fold.is_some() {+ crate::ui_kit::disclosure(ui.painter(), fold_rect.center(), fold_open, t.text_dim);+ let handle = if listed.is_some() { "timeline-sketches-fold" } else { "timeline-sketch-fold" };+ crate::scenario::publish_handle(&format!("{handle}:{name}"), fold_rect.center());+ }+ if response.hovered() {+ rows.hovered = Some(id);+ }+ if response.drag_started() && !on_fold {+ if !selected {+ select_only(app, TimelineItem::Feature(id));+ }+ let origin_x = drag_press_x(&response, rect.center().x);+ rows.drag = Some(Drag::Items(selected_drag_items(app, origin_x, group_id)));+ }+ let listed_under = plan.host(id).and_then(|host| features.iter().find(|feature| feature.0 == host)).map(|feature| feature.1.as_str());+ let mut tooltip = egui::Tooltip::for_enabled(&response);+ tooltip.popup = tooltip.popup.align(egui::RectAlign::RIGHT_START);+ tooltip.show(|ui| {+ let summary = app+ .session+ .doc+ .features+ .get(index)+ .and_then(|f| f.kind.expressions().first().map(ToString::to_string))+ .unwrap_or_else(|| elapsed.map_or_else(String::new, |ms| format!("{ms:.1} ms")));+ let kind = crate::i18n::tr_label(ty.strip_suffix("Feature").unwrap_or(ty));+ let mut tip = format!("{name} · {kind} · {summary}");+ if error.is_some() || warning.is_some() {+ tip.push_str(&format!("\n{}", crate::timeline::status_text(name, ty, error.as_deref(), warning.as_deref())));+ }+ crate::ui_kit::text(ui, &tip, crate::ui_kit::Text::Value("history", false));+ // A value row is one line: where the sketch is listed gets a row of its own.+ if let Some(host) = listed_under.filter(|_| reference) {+ let listed = crate::i18n::format("ui.history_sketch_listed_under", &[("feature", host)]);+ crate::ui_kit::text(ui, &listed, crate::ui_kit::Text::Value("history_listed_under", false));+ }+ });+ if response.clicked() && on_fold {+ if let Some((key, default)) = &fold {+ crate::browser::toggle(app, key, *default);+ }+ } else if response.clicked() && !crate::timeline::pick_feature_into_dialog(app, id, ui.input(|i| i.modifiers)) {+ select_item(app, ui, TimelineItem::Feature(id), order);+ }+ if response.double_clicked() && !on_fold {+ rows.edit = Some(id);+ }+ let sketch = kind.profile_sketch();+ if response.secondary_clicked() && !selected {+ select_only(app, TimelineItem::Feature(id));+ }+ let mut edit = false;+ crate::ui_kit::Menu::context(&response, |ui| {+ if crate::context_menu::button(ui, "Edit Feature", "edit").clicked() {+ edit = true;+ ui.close();+ }+ if let Some(sketch) = sketch+ && crate::context_menu::button(ui, "Edit Profile Sketch", "sketch").clicked()+ {+ app.edit_sketch(sketch.0);+ ui.close();+ }+ if crate::context_menu::button(ui, "Rename Feature", "rename").clicked() {+ crate::context_menu::start_rename(app, crate::context_menu::RenameWhat::Feature(id), rect.center());+ ui.close();+ }+ if crate::context_menu::button(ui, if *suppressed { "Unsuppress Feature" } else { "Suppress Feature" }, "suppress").clicked() {+ let _ = app.run_heavy("timeline.suppress", json!({"feature": id}));+ ui.close();+ }+ if crate::context_menu::button(ui, "Roll Back Here", "rollback").clicked() {+ let _ = app.run_heavy("timeline.roll_to", json!({"feature": id}));+ ui.close();+ }+ ui.separator();+ clipboard_buttons(app, ui, id);+ message_button(app, ui, id);+ ui.separator();+ selection_actions(app, ui, groups);+ ui.separator();+ if crate::context_menu::button(ui, "Delete", "delete").clicked() {+ delete_feature(app, id);+ ui.close();+ }+ delete_after_marker_button(app, ui, id, index, marker);+ });+ if edit {+ rows.edit = Some(id);+ }+ if names && has_patterns && fold_open {+ let depth = group_id.map_or(1, |group| group_depth(groups, group) + 2) + usize::from(row_kind == RowKind::Nested);+ crate::sketch_pattern_tree::rows(app, ui, id, depth, "timeline", None, false);+ }+ if let Some(listed) = listed.filter(|_| names && fold_open) {+ for child in listed {+ let child_kind = if child.reference { RowKind::Reference { parent: index } } else { RowKind::Nested };+ feature_row(app, ui, rows, child.index, indent + FOLDER_INDENT, child_kind);+ }+ }+}+#[cfg(test)]mod tests {use super::*;@@ -2209,4 +2350,275 @@ mod tests {vec!["Shell", "Lip", "SnapFit", "Boss1", "Boss2", "Rest"]);}++ /// A finished sketch called `name`: a 10 mm square on XY with its corner at `x`.+ fn square(h: &mut Harness, name: &str, x: f64) -> u64 {+ h.app.run("sketch.create", json!({"plane": "XY", "name": name})).unwrap();+ let sketch = h.app.session.active_sketch.unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0": [x, 0], "p1": [x + 10.0, 10]})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ sketch+ }++ fn extrude(h: &mut Harness, sketch: &str, name: &str, operation: &str) {+ h.app.run("solid.extrude", json!({"sketch": sketch, "distance": 5, "operation": operation, "name": name, "body_name": name})).unwrap();+ }++ /// The History at the left, wide enough for names, with Sketches: Under their feature (#6489).+ fn nested_history() -> Harness {+ let mut h = Harness::new();+ h.app.home.open = false;+ h.app.preferences.timeline_left = true;+ h.app.preferences.timeline_left_width = 240.0;+ h.app.preferences.history_sketches = crate::prefs::HistorySketches::UnderFeature;+ h+ }++ fn row_y(handle: &str) -> f32 {+ handle_at(handle).unwrap_or_else(|| panic!("{handle} is not drawn")).y+ }++ fn feature_names(h: &Harness) -> Vec<&str> {+ h.app.session.doc.features.iter().map(|feature| feature.name.as_str()).collect()+ }++ #[test]+ fn sketches_keep_their_own_rows_in_creation_order_by_default() {+ let mut h = nested_history();+ h.app.preferences.history_sketches = crate::prefs::HistorySketches::default();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ square(&mut h, "Pocket", 20.0);+ extrude(&mut h, "Pocket", "Second", "new");+ h.settle();+ assert_eq!(crate::prefs::Prefs::default().history_sketches, crate::prefs::HistorySketches::InOrder);+ let ys: Vec<f32> = ["timeline:Profile", "timeline:Block", "timeline:Pocket", "timeline:Second"].into_iter().map(row_y).collect();+ assert!(ys.windows(2).all(|pair| pair[0] < pair[1]), "creation order: {ys:?}");+ assert!(handle_at("timeline-sketches-fold:Block").is_none());+ let row = crate::scenario::rect_of("history:feature:Block").unwrap();+ assert_eq!(row.height(), crate::ui_kit::TREE_ROW_HEIGHT);+ }++ #[test]+ fn a_sketch_is_listed_folded_under_the_feature_built_from_it() {+ let mut h = nested_history();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ square(&mut h, "Pocket", 20.0);+ extrude(&mut h, "Pocket", "Second", "new");+ square(&mut h, "Unused", 40.0);+ h.settle();+ let block = h.app.session.doc.find_feature("Block").unwrap().id;++ // Folded by default: only the features and the unused sketch have rows.+ for hidden in ["timeline:Profile", "timeline:Pocket"] {+ assert!(handle_at(hidden).is_none(), "{hidden} starts folded under its feature");+ }+ assert!(row_y("timeline:Block") < row_y("timeline:Second") && row_y("timeline:Second") < row_y("timeline:Unused"));+ assert!(handle_at("timeline-sketches-fold:Unused").is_none(), "a sketch no feature uses has nothing to fold");++ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Block"}})).unwrap();+ h.settle();+ assert!(row_y("timeline:Block") < row_y("timeline:Profile") && row_y("timeline:Profile") < row_y("timeline:Second"));+ assert!(handle_at("timeline:Pocket").is_none(), "only the opened feature shows its sketch");+ assert!(h.app.session.selection.is_empty(), "the fold arrow only folds");+ // The fold is kept with the browser's folds, between runs.+ let mut restored = Harness::new();+ restored.app.load_prefs(&h.app.prefs());+ assert!(restored.app.tree.expanded.contains(&sketches_key(block)));++ // The narrow icon strip keeps the creation order.+ h.app.preferences.timeline_left_width = 56.0;+ h.settle();+ assert!(row_y("timeline:Profile") < row_y("timeline:Block") && row_y("timeline:Pocket") < row_y("timeline:Second"));+ }++ #[test]+ fn a_sketch_several_features_use_is_listed_under_the_first_and_the_others_select_it() {+ let mut h = nested_history();+ let profile = square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ extrude(&mut h, "Profile", "Copy", "new");+ h.settle();+ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Block"}})).unwrap();+ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Copy"}})).unwrap();+ h.settle();+ let reference = "timeline-reference:Copy:Profile";+ assert!(row_y("timeline:Block") < row_y("timeline:Profile") && row_y("timeline:Profile") < row_y("timeline:Copy"));+ assert!(row_y("timeline:Copy") < row_y(reference));++ h.step(&json!({"click": {"handle": reference}})).unwrap();+ assert_eq!(h.app.session.selection, vec![solidcraft_engine::Sel::Feature { id: profile }], "the reference row selects the sketch");+ h.app.run("select.clear", json!({})).unwrap();+ // Hovering it lights up the same sketch: in the 3D view, and in its row under Block.+ h.step(&json!({"move": {"handle": reference}})).unwrap();+ h.frames(2);+ assert_eq!(h.app.viewport.hover_feature, Some(profile));+ // Dragging it moves nothing: it only points at the sketch.+ let before = h.app.session.doc.features.clone();+ let top = row_y("timeline:Block");+ h.step(&json!({"drag": [{"handle": reference}, [handle_at(reference).unwrap().x, top - 15.0]]})).unwrap();+ h.settle();+ assert_eq!(h.app.session.doc.features, before);+ }++ #[test]+ fn the_marker_between_a_sketch_and_its_feature_shows_the_sketch_above_it() {+ let mut h = nested_history();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ h.app.run("timeline.roll_to", json!({"position": 1})).unwrap();+ h.settle();+ assert!(row_y("timeline:Profile") < row_y("timeline:rollback") && row_y("timeline:rollback") < row_y("timeline:Block"));+ assert!(handle_at("timeline-sketches-fold:Block").is_none());++ // Both rolled back: listed again, below the marker.+ h.app.run("timeline.roll_to", json!({"position": 0})).unwrap();+ h.settle();+ assert!(row_y("timeline:rollback") < row_y("timeline:Block"));+ assert!(handle_at("timeline:Profile").is_none());++ // Dropping the marker above the feature rolls back the sketch listed under it too.+ h.app.run("timeline.roll_to", json!({})).unwrap();+ h.settle();+ let block = handle_at("timeline:Block").unwrap();+ h.step(&json!({"drag": [{"handle": "timeline:rollback"}, [block.x, block.y - 15.0]]})).unwrap();+ h.settle();+ assert_eq!(h.app.session.doc.marker, Some(0));+ assert!(handle_at("timeline-sketches-fold:Block").is_some());+ }++ #[test]+ fn editing_a_listed_sketch_shows_it_above_the_marker_until_it_is_finished() {+ let mut h = nested_history();+ let profile = square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ h.settle();+ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Block"}})).unwrap();+ h.step(&json!({"click": {"handle": "timeline:Profile"}})).unwrap();+ assert_eq!(h.app.session.selection, vec![solidcraft_engine::Sel::Feature { id: profile }], "the row under the feature is the sketch");+ h.step(&json!({"click": {"handle": "timeline:Profile"}, "button": "right"})).unwrap();+ h.step(&json!({"widget": "Edit Feature"})).unwrap();+ h.settle();+ assert_eq!(h.app.session.active_sketch, Some(profile));+ assert!(row_y("timeline:Profile") < row_y("timeline:rollback") && row_y("timeline:rollback") < row_y("timeline:Block"));+ h.app.finish_sketch();+ h.settle();+ assert_eq!(h.app.session.doc.marker, None);+ assert!(row_y("timeline:Block") < row_y("timeline:Profile"), "listed under its feature again");+ }++ #[test]+ fn a_sketch_in_another_folder_than_its_feature_keeps_its_row() {+ let mut h = nested_history();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ square(&mut h, "Pocket", 20.0);+ extrude(&mut h, "Pocket", "Second", "new");+ h.app.run("timeline.group", json!({"name": "Sketches", "features": ["Profile"]})).unwrap();+ h.app.run("timeline.group", json!({"name": "Work", "features": ["Pocket", "Second"]})).unwrap();+ h.settle();+ // Profile is in a folder and Block isn't, so Profile keeps its row; Pocket and Second share one.+ assert!(row_y("timeline-folder:Sketches") < row_y("timeline:Profile") && row_y("timeline:Profile") < row_y("timeline:Block"));+ assert!(row_y("timeline-folder:Work") < row_y("timeline:Second") && handle_at("timeline:Pocket").is_none());+ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Second"}})).unwrap();+ h.settle();+ assert!(row_y("timeline:Second") < row_y("timeline:Pocket"));+ // Collapsing the folder hides the feature and the sketch under it.+ h.step(&json!({"click": {"handle": "timeline-folder-fold:Work"}})).unwrap();+ h.settle();+ assert!(handle_at("timeline:Second").is_none() && handle_at("timeline:Pocket").is_none());+ }++ #[test]+ fn dragging_a_feature_moves_the_sketch_listed_under_it() {+ let mut h = nested_history();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ square(&mut h, "Pocket", 20.0);+ extrude(&mut h, "Pocket", "Second", "new");+ h.settle();+ let block = handle_at("timeline:Block").unwrap();+ h.step(&json!({"drag": [{"handle": "timeline:Second"}, [block.x, block.y - 15.0]]})).unwrap();+ h.settle();+ assert_eq!(feature_names(&h), vec!["Pocket", "Second", "Profile", "Block"], "the sketch moves with its feature");+ assert!(h.app.session.model.state().bodies.len() == 2);++ // The move's own checks still apply: a cut moved above the body it cuts is refused, and+ // its sketch stays with it.+ let mut h = nested_history();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ h.app.run("sketch.create", json!({"plane": "XY", "name": "Slot"})).unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0": [2, 2], "p1": [4, 4]})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ h.app.run("solid.extrude", json!({"sketch": "Slot", "distance": 5, "operation": "cut", "name": "Cut"})).unwrap();+ h.settle();+ let block = handle_at("timeline:Block").unwrap();+ h.step(&json!({"drag": [{"handle": "timeline:Cut"}, [block.x, block.y - 15.0]]})).unwrap();+ h.settle();+ assert_eq!(feature_names(&h), vec!["Profile", "Block", "Slot", "Cut"]);+ let status = h.app.status.clone().map(|(text, _, error)| (text, error));+ assert!(status.as_ref().is_some_and(|(text, error)| *error && text.contains("breaks")), "the move was refused: {status:?}");+ }++ #[test]+ fn a_dialog_taking_features_gets_clicks_on_a_feature_and_on_the_sketch_under_it() {+ let mut h = nested_history();+ square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ let block = h.app.session.doc.find_feature("Block").unwrap().id;+ h.app.run("select.clear", json!({})).unwrap();+ h.settle();+ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Block"}})).unwrap();+ h.app.start("solid.pattern.rectangular");+ h.frames(4);+ h.step(&json!({"click": {"handle": "dialog:Object Type"}})).unwrap();+ h.step(&json!({"click": {"handle": "dialog:Object Type:Features"}})).unwrap();+ h.step(&json!({"click": {"handle": "timeline:Block"}})).unwrap();+ let picked = h.app.dialog.as_ref().map(|dialog| dialog.inputs[0].items.clone());+ assert_eq!(picked, Some(vec![solidcraft_engine::Sel::Feature { id: block }]), "the feature row's click goes to the dialog");+ // Wait out the double-click time: a double click edits.+ h.frames(30);+ h.step(&json!({"click": {"handle": "timeline:Profile"}})).unwrap();+ assert!(h.app.dialog.is_some() && h.app.session.active_sketch.is_none(), "the sketch row's click goes to the dialog too");+ assert!(h.app.session.selection.is_empty(), "dialog picks leave the ordinary selection alone");+ }++ #[test]+ fn find_in_timeline_opens_the_feature_a_sketch_is_listed_under() {+ let mut h = nested_history();+ let profile = square(&mut h, "Profile", 0.0);+ extrude(&mut h, "Profile", "Block", "new");+ h.settle();+ assert!(handle_at("timeline:Profile").is_none());+ let menu = crate::context_menu::items(&h.app, &crate::context_menu::Target::Sketch { id: profile });+ let item = menu.into_iter().find(|item| item.id == "ui.findTimeline").unwrap();+ crate::context_menu::run_item(&mut h.app, &item, pos2(0.0, 0.0));+ h.settle();+ assert!(row_y("timeline:Block") < row_y("timeline:Profile"), "Find in Timeline opens the feature's fold");+ assert_eq!(h.app.session.selection, vec![solidcraft_engine::Sel::Feature { id: profile }]);+ }++ #[test]+ fn a_listed_sketch_keeps_its_pattern_rows() {+ let mut h = nested_history();+ h.app.run("sketch.create", json!({"plane": "XY", "name": "Patterned"})).unwrap();+ let sketch = h.app.session.active_sketch.unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [10, 10]})).unwrap();+ h.app.run("sketch.line", json!({"points": [[0, 20], [5, 20]], "ids": ["source"]})).unwrap();+ let pattern = h.app.run("sketch.pattern.rectangular", json!({"entities": ["source"], "count": 3, "spacing": 10})).unwrap();+ h.app.finish_sketch();+ extrude(&mut h, "Patterned", "Block", "new");+ h.settle();+ let pattern_row = format!("timeline:sketch-pattern:{sketch}:{}", pattern["pattern"].as_str().unwrap());+ assert!(handle_at(&pattern_row).is_none());+ h.step(&json!({"click": {"handle": "timeline-sketches-fold:Block"}})).unwrap();+ h.settle();+ assert!(row_y("timeline:Block") < row_y("timeline:Patterned") && row_y("timeline:Patterned") < row_y(&pattern_row));+ h.step(&json!({"click": {"handle": "timeline-sketch-fold:Patterned"}})).unwrap();+ h.settle();+ assert!(handle_at(&pattern_row).is_none(), "the listed sketch folds its patterns");+ assert!(handle_at("timeline:Patterned").is_some());+ }}diff --git a/crates/ui-egui/src/ui_kit/gallery.rs b/crates/ui-egui/src/ui_kit/gallery.rsindex aecba440c5..faa4ea9363 100644--- a/crates/ui-egui/src/ui_kit/gallery.rs+++ b/crates/ui-egui/src/ui_kit/gallery.rs@@ -1725,6 +1725,7 @@ fn confirm_radial_and_history_rows_keep_multitone_artwork() {suppressed: false,error: false,warning: false,+ reference: false,accent: crate::theme::TabAccent::for_tab(&Tokens::get(), "MODEL"),}.paint(diff --git a/crates/ui-egui/src/ui_kit/history.rs b/crates/ui-egui/src/ui_kit/history.rsindex a74b9872f4..083ba5439e 100644--- a/crates/ui-egui/src/ui_kit/history.rs+++ b/crates/ui-egui/src/ui_kit/history.rs@@ -36,6 +36,9 @@ pub(crate) struct HistoryChip<'a> {pub suppressed: bool,pub error: bool,pub warning: bool,+ /// A row that points at an item listed elsewhere (a sketch under its first feature, #6489):+ /// its name is in secondary text.+ pub reference: bool,pub accent: TabAccent,}@@ -107,7 +110,13 @@ impl HistoryChip<'_> {Rect::from_center_size(if names { pos2(rect.left() + t.space_8 + side / 2.0, rect.center().y) } else { rect.center() }, vec2(side, side));icons::paint_accented(&p, icon, self.icon, feature_icon_accent(self.kind, self.icon), 1.0);if names {- let ink = if self.selected { self.accent.ink } else { t.text };+ let ink = if self.selected {+ self.accent.ink+ } else if self.reference {+ t.text_dim+ } else {+ t.text+ };let font = if self.selected { crate::fonts::semibold(t.font_body) } else { egui::FontId::proportional(t.font_body) };let text_rect = Rect::from_min_max(pos2(icon.right() + t.space_6 + 1.0, rect.top()),@@ -534,6 +543,7 @@ mod tests {suppressed: false,error,warning: false,+ reference: false,accent,}.paint(ui.painter(), rect, style)@@ -594,6 +604,7 @@ mod tests {suppressed: false,error: false,warning: false,+ reference: false,accent: TabAccent::for_tab(&t, "MODEL"),}.paint(ui.painter(), rect, style);diff --git a/crates/ui-egui/tests/scenarios/history_sketches_under_feature.json b/crates/ui-egui/tests/scenarios/history_sketches_under_feature.jsonnew file mode 100644index 0000000000..c5f286df6a--- /dev/null+++ b/crates/ui-egui/tests/scenarios/history_sketches_under_feature.json@@ -0,0 +1,40 @@+[+ {"note": "History › Sketches: Under their feature lists a sketch under the feature built from it (#6489). Model: Sketch1 → Extrude1, Sketch2 → Cut1, and Sketch3 used by Boss1 and Hole1 (one circle each). The History sits under the browser."},+ {"call": "ui.prefs", "params": {"timeline_left": true, "timeline_under_browser": true}},+ {"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY", "name": "Sketch1"}}},+ {"call": "engine.execute", "params": {"command": "sketch.rectangle.two_point", "params": {"p0": [0, 0], "p1": [40, 30]}}},+ {"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}},+ {"call": "engine.execute", "params": {"command": "solid.extrude", "params": {"sketch": "Sketch1", "distance": 10, "operation": "new", "name": "Extrude1"}}},+ {"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY", "name": "Sketch2"}}},+ {"call": "engine.execute", "params": {"command": "sketch.rectangle.two_point", "params": {"p0": [15, 10], "p1": [25, 20]}}},+ {"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}},+ {"call": "engine.execute", "params": {"command": "solid.extrude", "params": {"sketch": "Sketch2", "through_all": true, "operation": "cut", "name": "Cut1"}}},+ {"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY", "name": "Sketch3"}}},+ {"call": "engine.execute", "params": {"command": "sketch.circle.center", "params": {"center": [7, 7], "radius": 3}}},+ {"call": "engine.execute", "params": {"command": "sketch.circle.center", "params": {"center": [33, 23], "radius": 3}}},+ {"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}},+ {"call": "engine.execute", "params": {"command": "solid.extrude", "params": {"sketch": "Sketch3", "profiles": [{"point": [7, 7]}], "distance": 18, "operation": "join", "name": "Boss1"}}},+ {"call": "engine.execute", "params": {"command": "solid.extrude", "params": {"sketch": "Sketch3", "profiles": [{"point": [33, 23]}], "through_all": true, "operation": "cut", "name": "Hole1"}}},+ {"expect": {"bodies": 1, "errors": 0}},+ {"note": "In order (the default): every sketch is a row of its own and nothing folds."},+ {"expect": {"prefs": {"history_sketches": "in_order"}, "shown_handles": ["timeline:Sketch1", "timeline:Extrude1", "timeline:Sketch2", "timeline:Cut1", "timeline:Sketch3", "timeline:Boss1", "timeline:Hole1"], "hidden_handles": ["timeline-sketches-fold:Extrude1", "timeline-sketches-fold:Boss1"]}},+ {"note": "Preferences › Interface › Sketches: Under their feature. Each sketch folds under its feature; the folds start closed."},+ {"call": "ui.prefs", "params": {"open": "Interface"}},+ {"widget": "Under their feature"},+ {"widget": "OK"},+ {"expect": {"prefs": {"dialog": null, "history_sketches": "under_feature"}, "shown_handles": ["timeline:Extrude1", "timeline-sketches-fold:Extrude1", "timeline:Cut1", "timeline-sketches-fold:Cut1", "timeline:Boss1", "timeline-sketches-fold:Boss1", "timeline:Hole1", "timeline-sketches-fold:Hole1"], "hidden_handles": ["timeline:Sketch1", "timeline:Sketch2", "timeline:Sketch3"]}},+ {"note": "Sketch3 is listed under Boss1, its first feature; Hole1 shows a row that selects the same sketch."},+ {"click": {"handle": "timeline-sketches-fold:Boss1"}},+ {"click": {"handle": "timeline-sketches-fold:Hole1"}},+ {"expect": {"shown_handles": ["timeline:Sketch3", "timeline-reference:Hole1:Sketch3"], "hidden_handles": ["timeline:Sketch1", "timeline:Sketch2"]}},+ {"click": {"handle": "timeline-reference:Hole1:Sketch3"}},+ {"expect": {"selection": 1}},+ {"note": "With the marker between Sketch3 and Boss1 the sketch exists and its features don't: it has a row of its own above the marker."},+ {"call": "engine.execute", "params": {"command": "timeline.roll_to", "params": {"feature": "Sketch3"}}},+ {"expect": {"shown_handles": ["timeline:Sketch3", "timeline:rollback", "timeline:Boss1", "timeline:Hole1"], "hidden_handles": ["timeline-sketches-fold:Boss1", "timeline-sketches-fold:Hole1", "timeline-reference:Hole1:Sketch3"]}},+ {"call": "engine.execute", "params": {"command": "timeline.roll_to", "params": {}}},+ {"expect": {"shown_handles": ["timeline-sketches-fold:Boss1", "timeline:Sketch3"], "errors": 0}},+ {"note": "Back to In order: the rows are the timeline's again."},+ {"call": "ui.prefs", "params": {"history_sketches": "in_order"}},+ {"expect": {"shown_handles": ["timeline:Sketch1", "timeline:Sketch2", "timeline:Sketch3"], "hidden_handles": ["timeline-sketches-fold:Boss1", "timeline-reference:Hole1:Sketch3"]}}+]diff --git a/docs/book/src/guide/ui-tour.md b/docs/book/src/guide/ui-tour.mdindex f42d0bb7b7..d46117e3fd 100644--- a/docs/book/src/guide/ui-tour.md+++ b/docs/book/src/guide/ui-tour.md@@ -86,6 +86,12 @@far left of the viewport, beside the browser. Its seam handle switches between iconchips and compact feature names; the browser can collapse to a rail beside either width.Previous, Play and Next sit at the top. Double-click Previous to roll to the start.+ Interface › **Sketches** › **Under their feature** lists a sketch in the vertical timeline one+ level in, under the first feature built from it, behind that feature's fold arrow. Dragging the+ feature takes its sketch along. A later feature built from the same sketch gets a row that+ selects it, and while the marker sits between a sketch and its feature, or the two are in+ different folders, the sketch keeps a row of its own. The timeline along the bottom always lists+ features in creation order.- **Command search (S).** Click the ribbon search field or press S to open the search popupbelow it. Results group commands by their ribbon path and show matching features and userparameters from this design. With an empty query, recent commands appear first, followed bydiff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 0c8c4032cf..cdef95e625 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -303,7 +303,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.| `ui.home` | `open?`: bool; `sample?`: index | the start page: show or hide it, open a built-in sample (once built); returns `open` and the recent designs || `ui.shortcut` | `command`, `key?`, `replace?` | a command's key, or rebinds it (`""` clears; a key another command uses is refused unless `replace`) || `ui.help` | `item?`: `about`, `shortcuts` (read only), `report` (opens a report draft for review), `crashes` (the Crash Reports window) | the version, commit, build date and diagnostic text |-| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned)), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `viewport_theme` (`theme` (default: the theme's own), `light`, `dark`: the 3D view in the Light or Dark theme's colours whatever the window uses, #4146), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `language` (`en`, `ja`, `de`, `fr`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there), `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `view_confirm_corner` (default false: while a dialog or a sketch is open, a check and a cross at the view's top right, handles `view:confirm:ok` and `view:confirm:cancel`, do what the dialog's OK and Cancel do, or Finish Sketch and Cancel Sketch; the axis view or cube moves down below them, #6709), `check_updates` (default true; [updates](book/src/guide/updates.md)), `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge)); `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there; `button`: `ok`, `cancel`, `apply`, `defaults`; `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark`, `viewport_dark` (whether the 3D view is dark) and `stand_up_offer` |+| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned)), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `viewport_theme` (`theme` (default: the theme's own), `light`, `dark`: the 3D view in the Light or Dark theme's colours whatever the window uses, #4146), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `language` (`en`, `ja`, `de`, `fr`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:<n>`), and a pick on a face that has a hole moves it there), `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `view_confirm_corner` (default false: while a dialog or a sketch is open, a check and a cross at the view's top right, handles `view:confirm:ok` and `view:confirm:cancel`, do what the dialog's OK and Cancel do, or Finish Sketch and Cancel Sketch; the axis view or cube moves down below them, #6709), `history_sketches` (`in_order` (default), `under_feature`: the History at the left lists a sketch under the first feature built from it, #6489; the timeline at the bottom keeps the creation order), `check_updates` (default true; [updates](book/src/guide/updates.md)), `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge)); `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there; `button`: `ok`, `cancel`, `apply`, `defaults`; `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark`, `viewport_dark` (whether the 3D view is dark) and `stand_up_offer` || `ui.capture` | `action?`: `capture`, `revert`, `cancel` | answers the Capture Position question (asked when a command starts or the design is saved while components were moved without capturing); without `action`, what waits || `ui.window` | `action`: minimize, maximize, restore, toggle, close | what the title bar's caption buttons do (on Windows and Linux the application bar is the title bar); close asks about unsaved designs first || `ui.agent_cursor` | `show` (bool), `speed`: a number from 1 to 5 (times the normal speed) or `"instant"` (no animation: the command runs at once and the pointer jumps to where it acted), `follow_camera` (bool); all optional | the settings. While the cursor is shown, `engine.execute` first glides to the command's toolbar button and to each pick, then runs and replies; later requests wait their turn. The pointer shows the command's localized name, including commands inside a closed toolbar group; an animated batch names each command it visits. It also follows the pointer input sent with `ui.move`, `ui.click`, `ui.drag` and `ui.scroll`, as each event reaches the app, and a press leaves a ripple. `"animate": false` on a call skips it |diff --git a/docs/ui-kit.md b/docs/ui-kit.mdindex 6509901b6d..c54b4a1857 100644--- a/docs/ui-kit.md+++ b/docs/ui-kit.md@@ -77,7 +77,7 @@ table. Panel/Window/Confirm compositions also have dedicated geometry and intera| Module / element | Use and options | Main tokens || --- | --- | --- || assistant: `assistant_header`, `assistant_controls`, `assistant_badge`, `assistant_bubble`, `assistant_prose`, `assistant_tool_frame/row/detail/status`, `AssistantToolState`, `assistant_approval/actions`, `assistant_composer/footer`, `assistant_input`, `assistant_send`, `assistant_empty`, `assistant_banner`, `AssistantTone` | Shared Assistant presentation: 40 pt header, 22 pt state pill, right-aligned user messages limited to 86% width, unboxed assistant prose, bordered tool groups and command detail, tinted approval heading, rounded focused composer with one unframed growing editor and pinned footer, centred setup copy and semantic notices. Closures preserve existing permission choices, protocol routing, queue actions and scenario handles. | `form_header_height/close_size`, `font_label/small/body`, `dialog_body/footer/rule`, `control_fill/border/radius`, `form_ink/dim/primary/success/error`, `accent_soft/selected_ink`, `warning`, radii and spacing |-| history: `HistoryChip`, `HistoryStyle`, `history_drop_bar`, `history_marker`, `HistorySeam`, `history_seam` | One painter family for bottom chips, 38 pt vertical icon chips and single-line 26 pt name rows (the browser's shared `TREE_ROW_HEIGHT`). Selected items use the active tab tint/ink/border; all variants retain multi-tone feature artwork using one shared kind-to-accent rule (Sketch green, Surface orange, Mesh yellow, Form purple, solids base blue); rolled-back items have 42% opacity. Error/warning badges, suppression strikes, horizontal/vertical drop bars and rollback line/hollow circle are shared. No connector lines. | `control_height`, `space_2/3/4/6/8/10/12/14/16/24`, radii, typography, `TabAccent`, `timeline_item`, `control_border`, `text/dim`, `form_error/fill` |+| history: `HistoryChip`, `HistoryStyle`, `history_drop_bar`, `history_marker`, `HistorySeam`, `history_seam` | One painter family for bottom chips, 38 pt vertical icon chips and single-line 26 pt name rows (the browser's shared `TREE_ROW_HEIGHT`). Selected items use the active tab tint/ink/border; all variants retain multi-tone feature artwork using one shared kind-to-accent rule (Sketch green, Surface orange, Mesh yellow, Form purple, solids base blue); rolled-back items have 42% opacity; a reference row (a sketch listed under another feature, #6489) has its name in secondary text. Error/warning badges, suppression strikes, horizontal/vertical drop bars and rollback line/hollow circle are shared. No connector lines. | `control_height`, `space_2/3/4/6/8/10/12/14/16/24`, radii, typography, `TabAccent`, `timeline_item`, `control_border`, `text/dim`, `form_error/fill` || search: `CommandSearch`, `MenuItem::search_row` | Ribbon search composition: one persistent ribbon editor expands from 28 to 40 pt and to 520 pt wide with its right edge anchored, magnifier and S/Esc keycap, 38 pt two-line menu row with 26 pt icon tile, accent bold substring, path, shortcut/kind keycap, counts, JSON detail box and footer. The ordinary 30 pt menu row cannot fit a second line; this variant keeps its enabled/selected states and scenario IDs. Ranking and dispatch stay with the caller. | `form_card_width × 2 − space_8` (520 pt), `control_height`, `space_2/3/4/6/8/10/12/14/16/24`, `radius_xl/control_radius`, `control_fill`, `dialog_body/footer/rule/border`, `form_ink/dim/primary/error/error_fill/success/success_fill`, `selected_ink`, `accent_soft`, typography || menu: `Menu`, `MenuItem` | Shared popup, 30 pt rows, 28 pt icon column, clipped labels, right-aligned mono shortcuts, submenu chevrons, checked/unchecked and document swatches, inert 40% disabled rows and danger ink; headings and separators; ribbon drag/pin targets retained | `dialog_body/border/rule`, `radius_xl`, `control_height/radius`, `form_ink/dim/primary/error`, `accent_soft`, typography and spacing || radial: `radial_menu` | Eight rounded annular sectors, parallel 4 pt gaps, 9 pt circular corner joins, tab-accent artwork and hover, centre label/key; existing hold/flick/release dispatch | `dialog_body/border`, `form_ink/dim`, `TabAccent`, icon palette, font/spacing tokens |