SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
History in the browser: a History layout that lists each component's history in the browser (#7709) (#7710)
tr1pp47adbe0037730
diff --git a/assets/locales/pending/history-in-browser.json b/assets/locales/pending/history-in-browser.jsonnew file mode 100644index 0000000000..dbf0e9f10d--- /dev/null+++ b/assets/locales/pending/history-in-browser.json@@ -0,0 +1,23 @@+{+ "en": {+ "prefs.in_browser": "In browser"+ },+ "de": {+ "prefs.in_browser": "Im Browser"+ },+ "ar": {+ "prefs.in_browser": "في المستعرض"+ },+ "he": {+ "prefs.in_browser": "בעץ התכן"+ },+ "ja": {+ "prefs.in_browser": "ブラウザー内"+ },+ "vi": {+ "prefs.in_browser": "Trong cây thư mục"+ },+ "zh": {+ "prefs.in_browser": "在浏览器中"+ }+}diff --git a/crates/engine/src/cmd/view_navigation.rs b/crates/engine/src/cmd/view_navigation.rsindex 5e23781fe2..90525633df 100644--- a/crates/engine/src/cmd/view_navigation.rs+++ b/crates/engine/src/cmd/view_navigation.rs@@ -75,7 +75,7 @@ CommandSpec::new("view.render_dock", "Move Render Dock", crate::checked!("view.rCommandSpec::new("view.layout", "Workspace layout", layout).icon("settings").noundo().doc_only().params("mode: floating|compact → validated workspace layout; display only, never opens a dialog"),CommandSpec::new("view.history_layout", "History layout", history_layout)- .icon("settings").noundo().doc_only().params("width?: 1..1000000; dock?: bottom|left|under_browser; collapsed?: bool → validated layout request; display only, never opens a dialog"),+ .icon("settings").noundo().doc_only().params("width?: 1..1000000; dock?: bottom|left|under_browser|browser (browser: the history in the browser, no timeline); collapsed?: bool → validated layout request; display only, never opens a dialog"),CommandSpec::new("view.graphics_preset", "Graphics Preset", graphics_preset).icon("settings").noundo().doc_only().params("preset: performance|quality → preset, enabled, display_quality, supersampling, supersampling_adaptive; Quality: AO, Fine, adaptive 2x SSAA; Performance: no AO, Normal, no SSAA"),CommandSpec::new("view.ambient_occlusion", "Ambient Occlusion", ambient_occlusion)@@ -365,8 +365,8 @@ fn history_layout(_s: &mut Session, p: &Value) -> Result<Value> {if let Some(value) = p.get("dock") {let dock = value.as_str()- .filter(|v| matches!(*v, "bottom" | "left" | "under_browser"))- .ok_or_else(|| bad(cmd, "dock must be bottom, left or under_browser"))?;+ .filter(|v| matches!(*v, "bottom" | "left" | "under_browser" | "browser"))+ .ok_or_else(|| bad(cmd, "dock must be bottom, left, under_browser or browser"))?;result.insert("dock".into(), json!(dock));}if let Some(value) = p.get("collapsed") {diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rsindex c039e6fba0..a8fbfeef03 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -62,6 +62,10 @@ pub(crate) fn reveal_body(app: &mut SolveApp, body: &str) {}}+pub(crate) fn reveal_in_history(app: &mut SolveApp, id: u64) {+ features::reveal_in_history(app, id);+}+#[cfg(test)]#[path = "browser_model_tests.rs"]mod model_tests;@@ -2273,7 +2277,9 @@ fn folder_rows_at(// eyes, hover and drops do its jobs. It is always open, as nothing could open it again.let render = crate::render_workspace::active(app);let folded = !render && folder == "bodies" && bodies_folded(app, comp, prefix, data.entries().count());- let open = folded || is_open(app, key, true);+ // With the history in the browser the sketches are there too: their folder starts closed.+ let default_open = !(folder == "sketches" && app.preferences.history_in_browser);+ let open = folded || is_open(app, key, default_open);let inner = if folded { depth } else { depth + 1 };// The folder's eye is its own: hiding it hides its items without changing theirs, and its// items never change it. It and everything in it fade while it or a placement above is@@ -2300,13 +2306,13 @@ fn folder_rows_at()};if r.fold {- toggle(app, key, true);+ toggle(app, key, default_open);} else if r.clicked {// The Bodies label is the whole set while a command is asking for bodies. The arrow// still folds it. With no such command, the label folds, as it always has.let names: Vec<String> = data.entries().flat_map(|e| e.bodies.clone()).collect();if !offer_bodies(app, &names, Take::Toggle) {- toggle(app, key, true);+ toggle(app, key, default_open);}}if r.eye {diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rsindex f0918a77d3..08740ecc9d 100644--- a/crates/ui-egui/src/browser/features.rs+++ b/crates/ui-egui/src/browser/features.rs@@ -1,6 +1,7 @@//! Native feature rows in the component browser, separate from timeline layout and order.use super::*;+use crate::history_rows::{HistoryFeature, HistoryRows};#[derive(Clone, Debug)]pub(crate) struct Reveal {@@ -42,25 +43,45 @@ pub(crate) fn reveal(app: &mut SolveApp, id: u64, body: &str) {app.tree.reveal_feature = Some(Reveal { id, path });}+/// With the history in the browser: open the feature's component and history, and scroll to it.+pub(crate) fn reveal_in_history(app: &mut SolveApp, id: u64) {+ let Some(component) = app.session.doc.feature(id).map(|feature| feature.component) else { return };+ app.ui.show_browser = true;+ app.tree.collapsed.remove("c0");+ app.tree.collapsed.remove(&format!("c{component}"));+ app.tree.collapsed.remove(&format!("c{component}/history"));+ app.tree.reveal_feature = Some(Reveal { id, path: Vec::new() });+}+pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, component: u64, path: &[u64], depth: usize, acts: &mut Actions) {- let has_features = match app.tree.model.as_ref().filter(|m| m.matches(&app.session)) {+ // Compact history: every feature of the component, sketches too, in history order with the+ // marker, in place of the timeline.+ let compact = app.preferences.history_in_browser;+ let has_features = match app.tree.model.as_ref().filter(|m| m.matches(&app.session) && !compact) {Some(model) => model.features.get(&component).is_some_and(|features| !features.is_empty()),- None => app.session.doc.features.iter().any(|feature| feature.component == component && !matches!(feature.kind, FeatureKind::Sketch { .. })),+ None => app+ .session+ .doc+ .features+ .iter()+ .any(|feature| feature.component == component && (compact || !matches!(feature.kind, FeatureKind::Sketch { .. }))),};if !has_features {return;}let scope = if path.is_empty() { format!("c{component}") } else { occurrence_key(path) };- let key = format!("{scope}/features");- let open = is_open(app, &key, false);- let r = draw_row(ui, ui.id().with(&key), &Row { depth, fold: Some(open), icon: "folder", label: "Features", ..Default::default() });+ // The history opens by default; the Features folder stays closed until opened.+ let (key, label) =+ if compact { (format!("{scope}/history"), crate::i18n::tr("ui.history_title")) } else { (format!("{scope}/features"), "Features") };+ let open = is_open(app, &key, compact);+ let r = draw_row(ui, ui.id().with(&key), &Row { depth, fold: Some(open), icon: "folder", label, ..Default::default() });if r.fold || r.clicked {- toggle(app, &key, false);+ toggle(app, &key, compact);}if !open {return;}- let indices = match app.tree.model.as_ref().filter(|m| m.matches(&app.session)) {+ let indices = match app.tree.model.as_ref().filter(|m| m.matches(&app.session) && !compact) {Some(model) => model.features.get(&component).cloned().unwrap_or_default(),None => app.session@@ -68,64 +89,196 @@ pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, component: u64, path:.features.iter().enumerate()- .filter_map(|(i, f)| (f.component == component && !matches!(f.kind, FeatureKind::Sketch { .. })).then_some(i))+ .filter_map(|(i, f)| (f.component == component && (compact || !matches!(f.kind, FeatureKind::Sketch { .. }))).then_some(i)).collect(),};+ let here = Here { component, path, scope: &scope };// The feature that made what is under the cursor or picked in the viewport, as the history- // lights it.+ // lights it, and in the history layout what a selected history row lights.let from_view = [crate::timeline::hovered_feature(app), crate::timeline::picked_feature(app)];- for index in indices {- let Some(feature) = app.session.doc.features.get(index) else { continue };- let (id, label, icon) = (feature.id, feature.name.clone(), crate::timeline::icon_of(&feature.kind));- let sketch = crate::timeline::TimelineKind::of(&feature.kind).profile_sketch();- // Behind the history marker or suppressed: not built, drawn faint as in the timeline.- let dim = feature.suppressed || app.session.doc.marker.is_some_and(|marker| index >= marker);- let selected = app.session.selection.contains(&Sel::Feature { id });- let mark = if from_view.contains(&Some(id)) { Mark::Here } else { Mark::None };- app.tree.remember(&format!("f:{id}"));- let action = sketch.map(|_| ("sketch", "Edit Profile Sketch"));- // The bodies it made show and hide with its eye (#5099); a component listed on its own- // stands for all of its placements.- let placement = (component == 0 || !path.is_empty()).then_some((component, path));- let bodies = app.session.feature_bodies(&[id], placement);- let visible = bodies.iter().any(|b| !app.session.visibility.hidden_bodies.contains(b));- let eye = (!bodies.is_empty()).then_some(visible);- let r = draw_row(- ui,- ui.id().with(("browser_feature", id)),- &Row { depth: depth + 1, eye, icon, label: &label, selected, dim: dim || eye == Some(false), mark, action, ..Default::default() },- );- if r.eye {- let mut p = json!({"visible": !visible, "features": [id]});- if !path.is_empty() {- p["path"] = json!(path);- }- let _ = app.run("browser.visibility", p);+ let lit = if compact { lit_by_selection(app) } else { BTreeSet::new() };+ let mark = |app: &SolveApp, index: usize| {+ let id = app.session.doc.features.get(index).map(|f| f.id);+ if id.is_some_and(|id| lit.contains(&id) || from_view.contains(&Some(id))) { Mark::Here } else { Mark::None }+ };+ if !compact {+ for index in indices {+ let _ = feature_row(app, ui, acts, &here, index, depth + 1, None, mark(app, index));}- if r.action- && let Some(sketch) = sketch- {- app.edit_sketch(sketch.0);- continue;+ return;+ }+ let n = app.session.doc.features.len();+ let marker = app.session.doc.marker.unwrap_or(n);+ let plan = history_plan(app, &indices, marker);+ // `plan` counts in the component's own features; a timeline position is a global index.+ let global = |at: usize| indices.get(at).copied().unwrap_or_else(|| indices.last().map_or(n, |last| last + 1));+ // Where the marker can be dropped: the top of each row (it and the sketches listed under it+ // first rolled back) and below the last.+ let mut slots: Vec<(f32, usize)> = Vec::new();+ let mut marker_resp = None;+ for row in &plan.rows {+ let index = global(row.index);+ if marker_resp.is_none() && index >= marker {+ marker_resp = Some(marker_row(app, ui, depth + 1));}- if let Some(rect) = r.rect {- crate::scenario::publish_handle(&format!("row:browser-feature:{scope}:{id}"), rect.center());- if app.tree.reveal_feature.as_ref().is_some_and(|target| target.id == id && target.path == path) {- ui.scroll_to_rect(rect, Some(egui::Align::Center));- app.tree.reveal_feature = None;- }+ slots.push((ui.cursor().min.y, global(row.slot)));+ // The same fold as in the vertical History, so it stays open when the layout changes.+ let key = crate::timeline_left::sketches_key(row.feature);+ let open = is_open(app, &key, false);+ let listed: Vec<usize> = row.listed.iter().filter(|listed| !listed.reference).map(|listed| global(listed.index)).collect();+ let fold = (!listed.is_empty()).then_some(open);+ if feature_row(app, ui, acts, &here, index, depth + 1, fold, mark(app, index)) {+ toggle(app, &key, false);}- if r.double {- if !path.is_empty() {- let _ = app.run("component.activate", json!({"component":component,"occurrence":path.last(),"path":path}));+ if open {+ for index in listed {+ let _ = feature_row(app, ui, acts, &here, index, depth + 2, None, mark(app, index));}- app.edit_feature(id);- } else if r.clicked {- click_select(app, ui, format!("f:{id}"), Some(Sel::Feature { id }));}- if let Some(at) = r.secondary {- acts.menu = Some((at, Target::Feature { id }));+ }+ let resp = marker_resp.unwrap_or_else(|| marker_row(app, ui, depth + 1));+ if !plan.rows.is_empty() {+ slots.push((ui.cursor().min.y, global(indices.len())));+ }+ drag_marker(app, ui, &resp, &slots, marker);+}++/// Where a history row is drawn: its component and placement.+struct Here<'a> {+ component: u64,+ path: &'a [u64],+ scope: &'a str,+}++/// The component's history rows, `indices` its features' timeline positions: with Sketches:+/// Under their feature, each sketch listed under the feature built from it as the vertical+/// History lists it (`history_rows`, without reference rows); otherwise in creation order.+fn history_plan(app: &SolveApp, indices: &[usize], marker: usize) -> HistoryRows {+ let doc = &app.session.doc;+ let features: Vec<HistoryFeature> = indices.iter().filter_map(|index| doc.features.get(*index)).map(HistoryFeature::of).collect();+ if !crate::timeline_left::nests(app) {+ return HistoryRows::in_order(features.iter().map(|feature| (feature.id, feature.sketch)));+ }+ let local = indices.iter().take_while(|index| **index < marker).count();+ crate::history_rows::rows(&features, &doc.timeline_groups, (local < features.len()).then_some(local), false)+}++/// What a selected history row lights up: a feature's sketches, and the features built from a+/// selected sketch.+fn lit_by_selection(app: &SolveApp) -> BTreeSet<u64> {+ let mut lit = BTreeSet::new();+ let doc = &app.session.doc;+ for selection in &app.session.selection {+ let Sel::Feature { id } = selection else { continue };+ let Some(feature) = doc.feature(*id) else { continue };+ if matches!(feature.kind, FeatureKind::Sketch { .. }) {+ lit.extend(doc.features.iter().filter(|f| f.kind.input_sketches().contains(id)).map(|f| f.id));+ } else {+ lit.extend(feature.kind.input_sketches());+ }+ }+ lit+}++/// One feature or sketch row; returns whether its fold arrow was clicked.+#[allow(clippy::too_many_arguments)]+fn feature_row(+ app: &mut SolveApp,+ ui: &mut egui::Ui,+ acts: &mut Actions,+ here: &Here,+ index: usize,+ depth: usize,+ fold: Option<bool>,+ mark: Mark,+) -> bool {+ let Some(feature) = app.session.doc.features.get(index) else { return false };+ let (component, path) = (here.component, here.path);+ let (id, label, icon) = (feature.id, feature.name.clone(), crate::timeline::icon_of(&feature.kind));+ let is_sketch = matches!(feature.kind, FeatureKind::Sketch { .. });+ let sketch = crate::timeline::TimelineKind::of(&feature.kind).profile_sketch();+ // Behind the history marker or suppressed: not built, drawn faint as in the timeline.+ let dim = feature.suppressed || app.session.doc.marker.is_some_and(|marker| index >= marker);+ let selected = app.session.selection.contains(&Sel::Feature { id });+ app.tree.remember(&format!("f:{id}"));+ let action = sketch.map(|_| ("sketch", "Edit Profile Sketch"));+ // A sketch row has the eye its Sketches folder row has. A feature's eye shows and hides the+ // bodies it made (#5099); a component listed on its own stands for all of its placements.+ let placement = (component == 0 || !path.is_empty()).then_some((component, path));+ let bodies = if is_sketch { Vec::new() } else { app.session.feature_bodies(&[id], placement) };+ let visible =+ if is_sketch { crate::browser::sketch_visible(app, id) } else { bodies.iter().any(|b| !app.session.visibility.hidden_bodies.contains(b)) };+ let eye = (is_sketch || !bodies.is_empty()).then_some(visible);+ let r = draw_row(+ ui,+ ui.id().with(("browser_feature", id)),+ &Row { depth, fold, eye, icon, label: &label, selected, dim: dim || (!is_sketch && eye == Some(false)), action, mark, ..Default::default() },+ );+ if r.eye && is_sketch {+ crate::browser::set_sketch_visible(app, id, !visible);+ } else if r.eye {+ let mut p = json!({"visible": !visible, "features": [id]});+ if !path.is_empty() {+ p["path"] = json!(path);}+ let _ = app.run("browser.visibility", p);+ }+ if r.action+ && let Some(sketch) = sketch+ {+ app.edit_sketch(sketch.0);+ return false;+ }+ let scope = here.scope;+ if let Some(rect) = r.rect {+ crate::scenario::publish_handle(&format!("row:browser-feature:{scope}:{id}"), rect.center());+ if app.tree.reveal_feature.as_ref().is_some_and(|target| target.id == id && target.path == path) {+ ui.scroll_to_rect(rect, Some(egui::Align::Center));+ app.tree.reveal_feature = None;+ }+ }+ if r.double {+ if !path.is_empty() {+ let _ = app.run("component.activate", json!({"component":component,"occurrence":path.last(),"path":path}));+ }+ app.edit_feature(id);+ } else if r.clicked {+ click_select(app, ui, format!("f:{id}"), Some(Sel::Feature { id }));+ }+ if let Some(at) = r.secondary {+ acts.menu = Some((at, if is_sketch { Target::Sketch { id } } else { Target::Feature { id } }));+ }+ r.fold+}++/// The history marker between the rows, as in the vertical timeline.+fn marker_row(app: &SolveApp, ui: &mut egui::Ui, depth: usize) -> egui::Response {+ let t = Tokens::get();+ let (rect, response) = ui.allocate_exact_size(vec2(ui.available_width(), t.space_12), Sense::drag());+ let line = Rect::from_min_max(pos2(rect.left() + 2.0 + depth as f32 * INDENT, rect.top()), rect.max);+ crate::ui_kit::history_marker(ui.painter(), line, true, crate::theme::TabAccent::for_tab(&t, &app.ui.tab));+ crate::scenario::publish_handle("browser:rollback", rect.center());+ if response.hovered() || response.dragged() {+ ui.ctx().set_cursor_icon(egui::CursorIcon::Grab);+ }+ response.on_hover_text(crate::i18n::tr("ui.history_marker_tip"))+}++/// Dragging the marker shows where it lands; letting go rolls the history there, through the+/// timeline's own command.+fn drag_marker(app: &mut SolveApp, ui: &egui::Ui, resp: &egui::Response, slots: &[(f32, usize)], marker: usize) {+ if !resp.dragged() && !resp.drag_stopped() {+ return;+ }+ let Some(y) = ui.ctx().pointer_latest_pos().map(|p| p.y) else { return };+ let Some(&(slot_y, position)) = slots.iter().min_by(|a, b| (a.0 - y).abs().total_cmp(&(b.0 - y).abs())) else { return };+ if resp.dragged() && position != marker {+ let accent = crate::theme::TabAccent::current(ui.ctx()).color;+ ui.painter().hline(resp.rect.left() + 4.0..=resp.rect.right() - 4.0, slot_y, Stroke::new(2.0, accent));+ }+ if resp.drag_stopped() && position != marker {+ let n = app.session.doc.features.len();+ let _ = app.run_heavy("timeline.roll_to", if position >= n { json!({}) } else { json!({ "position": position }) });}}@@ -512,4 +665,132 @@ mod tests {let labels: Vec<_> = drawn_rows().into_iter().map(|(label, ..)| label).collect();assert!(labels.contains(&block_name), "a rolled-back feature stays listed: {labels:?}");}++ fn settle_heavy(h: &mut Harness) {+ for _ in 0..500 {+ if h.app.deferred.is_none() && h.app.deferred_queue.is_empty() {+ break;+ }+ h.frame();+ }+ h.frames(2);+ }++ fn count(label: &str) -> usize {+ drawn_rows().iter().filter(|(l, ..)| l == label).count()+ }++ fn fold_of(label: &str) -> Option<bool> {+ drawn_rows().into_iter().find(|(l, ..)| l == label).and_then(|(.., open)| open)+ }++ /// History in the browser: no timeline; with Sketches: Under their feature a sketch sits+ /// under its extrusion, folded; dragging the marker above that extrusion rolls both back with+ /// the timeline's command.+ #[test]+ fn browser_history_mode_nests_a_sketch_under_its_feature_and_drags_the_marker() {+ let mut h = Harness::new();+ let sketch = h.app.run("sketch.create", json!({"plane":"XY","name":"Profile"})).unwrap()["sketch"].as_u64().unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[20,15]})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ let pad = h.app.run("solid.extrude", json!({"distance":10,"name":"Pad","body_name":"Plate"})).unwrap()["feature"].as_u64().unwrap();+ h.app.run("solid.box", json!({"length":5,"width":5,"height":5,"name":"Block","body_name":"Block"})).unwrap();+ h.app.run("view.history_layout", json!({"dock":"browser"})).unwrap();+ assert!(h.app.preferences.history_in_browser && !h.app.preferences.timeline_left);+ h.frames(3);+ assert!(h.app.shell.history.is_none(), "no timeline beside the browser history");+ assert_eq!(count("Profile"), 1, "the Sketches folder starts closed: only the sketch's history row");+ assert_eq!(fold_of("Pad"), None, "in creation order nothing is listed under the extrusion");++ h.app.preferences.history_sketches = crate::prefs::HistorySketches::UnderFeature;+ h.frames(2);+ assert_eq!(fold_of("Pad"), Some(false), "the extrusion folds over its sketch");+ assert_eq!(count("Profile"), 0, "folded: the sketch is not a row of its own");+ h.step(&json!({"click": {"handle": "fold:Pad"}})).unwrap();+ h.frames(2);+ assert_eq!(count("Profile"), 1, "unfolded: the sketch is under the extrusion");+ assert!(h.app.tree.expanded.contains(&crate::timeline_left::sketches_key(pad)), "the same fold as the vertical History");+ let rows = drawn_rows();+ let (sketch_row, pad_row) = (rows.iter().find(|(l, ..)| l == "Profile").unwrap().1, rows.iter().find(|(l, ..)| l == "Pad").unwrap().1);+ assert!(sketch_row.top() > pad_row.top(), "the sketch is below its feature");++ let row = crate::scenario::handle_at(&format!("row:browser-feature:c0:{pad}")).unwrap();+ h.step(&json!({"drag":[{"handle":"browser:rollback"},[row.x, row.y - 8.0]]})).unwrap();+ settle_heavy(&mut h);+ let sketch_index = h.app.session.doc.feature_index(sketch).unwrap();+ assert_eq!(h.app.session.doc.marker, Some(sketch_index), "dropped above the extrusion: it and its sketch are rolled back");+ assert_eq!(fold_of("Pad"), Some(true), "rolled back together, the sketch stays under it");++ h.app.run("view.history_layout", json!({"dock":"bottom"})).unwrap();+ assert!(!h.app.preferences.history_in_browser);+ }++ /// The browser lists sketches as the vertical History does (`history_rows`): a shared sketch+ /// under its first feature, an unused one and one the marker separates from its feature as+ /// rows of their own; selecting a feature lights its sketch.+ #[test]+ fn browser_history_mode_lists_sketches_like_the_vertical_history() {+ let mut h = Harness::new();+ let two = h.app.run("sketch.create", json!({"plane":"XY","name":"Two"})).unwrap()["sketch"].as_u64().unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[10,10]})).unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0":[20,0],"p1":[30,10]})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ h.app.run("solid.extrude", json!({"sketch":"Two","profiles":[0],"distance":5,"name":"Low","body_name":"A"})).unwrap();+ let high = h.app.run("solid.extrude", json!({"sketch":"Two","profiles":[1],"distance":15,"name":"High","body_name":"B"})).unwrap()["feature"]+ .as_u64()+ .unwrap();+ let post = h.app.run("sketch.create", json!({"plane":"XY","name":"PostSketch"})).unwrap()["sketch"].as_u64().unwrap();+ h.app.run("sketch.circle.center", json!({"center":[50,5],"radius":3})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ h.app.run("solid.extrude", json!({"distance":8,"name":"Post","body_name":"C"})).unwrap();+ h.app.run("sketch.create", json!({"plane":"XZ","name":"Unused"})).unwrap();+ h.app.run("sketch.circle.center", json!({"center":[0,0],"radius":3})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ h.app.preferences.history_sketches = crate::prefs::HistorySketches::UnderFeature;+ h.app.run("view.history_layout", json!({"dock":"browser"})).unwrap();+ h.frames(3);+ assert_eq!(fold_of("Low"), Some(false), "a shared sketch is listed under its first feature");+ assert_eq!(fold_of("High"), None, "no reference rows in the browser");+ assert_eq!(count("Unused"), 1, "an unused sketch is its own row");+ assert_eq!(fold_of("Post"), Some(false), "the post's own sketch is under it");++ // Selecting a feature lights the row of the sketch it is built from.+ h.app.run("select.set", json!({"items":[{"type":"feature","id":high}]})).unwrap();+ h.frames(2);+ assert!(lit_by_selection(&h.app).contains(&two));++ // The marker between the post's sketch and the post: the sketch is built, the post is+ // not, so the sketch shows on its own above the marker.+ let index = h.app.session.doc.feature_index(post).unwrap();+ h.app.run("timeline.roll_to", json!({"position": index + 1})).unwrap();+ h.frames(2);+ assert_eq!(fold_of("Post"), None, "split by the marker: nothing under the post");+ assert_eq!(count("PostSketch"), 1, "the sketch is its own row");+ }++ /// A sketch row in the browser's history has the eye its Sketches folder row has.+ #[test]+ fn browser_history_sketch_rows_have_an_eye() {+ let mut h = Harness::new();+ h.app.preferences.history_sketches = crate::prefs::HistorySketches::UnderFeature;+ h.app.run("view.history_layout", json!({"dock":"browser"})).unwrap();+ let two = h.app.run("sketch.create", json!({"plane":"XY","name":"Two"})).unwrap()["sketch"].as_u64().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!({"sketch":"Two","profiles":[0],"distance":5,"name":"Low","body_name":"A"})).unwrap();+ let shown = |h: &Harness| solidcraft_engine::view::sketch_shown(&h.app.session, two);+ h.frames(2);+ assert!(!shown(&h), "a used sketch is hidden");+ h.step(&json!({"click": {"handle": "fold:Low"}})).unwrap();+ h.frames(2);+ let row = crate::scenario::handle_at(&format!("row:browser-feature:c0:{two}")).unwrap();+ let eye = crate::scenario::handle_at("eye:Two").unwrap();+ assert!((eye.y - row.y).abs() < 2.0, "the eye is on the sketch's history row");+ h.step(&json!({"click": {"handle": "eye:Two"}})).unwrap();+ h.frames(2);+ assert!(shown(&h), "its eye shows it");+ h.step(&json!({"click": {"handle": "eye:Two"}})).unwrap();+ h.frames(2);+ assert!(!shown(&h), "and hides it again");+ }}diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rsindex 8a3c36e52e..d6bff4ece8 100644--- a/crates/ui-egui/src/context_menu.rs+++ b/crates/ui-egui/src/context_menu.rs@@ -1384,12 +1384,16 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {let body = p.get("body").and_then(Value::as_str);let f = id_of(&p, "feature").or_else(|| body.and_then(|b| body_feature(app, b)));if let Some(f) = f {- app.ui.show_timeline = true;- crate::timeline_left::reveal_feature(app, f);- // From a face or body, the Browser shows the feature in that body's copy. From a- // sketch, plane or feature row there is no body: that row is the Browser's view.- if let Some(body) = body {- crate::browser::reveal_feature(app, f, body);+ if app.preferences.history_in_browser {+ crate::browser::reveal_in_history(app, f);+ } else {+ app.ui.show_timeline = true;+ crate::timeline_left::reveal_feature(app, f);+ // From a face or body, the Browser shows the feature in that body's copy. From a+ // sketch, plane or feature row there is no body: that row is the Browser's view.+ if let Some(body) = body {+ crate::browser::reveal_feature(app, f, body);+ }}let _ = app.run("select.set", json!({"items": [{"type": "feature", "id": f}]}));app.tree.timeline_reveal = Some(f);diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 51a3cb77ef..8a82c6aafa 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1163,7 +1163,8 @@ impl SolveApp {self.preferences.timeline_left_width = ui_kit::history_snap_width(width as f32);}if let Some(dock) = v.get("dock").and_then(Value::as_str) {- self.preferences.timeline_left = dock != "bottom";+ self.preferences.timeline_left = !matches!(dock, "bottom" | "browser");+ self.preferences.history_in_browser = dock == "browser";self.preferences.timeline_under_browser = dock == "under_browser";self.preferences.timeline_collapsed = false;self.preferences.timeline_left_browser_collapsed = false;@@ -2411,7 +2412,7 @@ impl SolveApp {let floating = render_workspace::active(self) || ui_kit::Container::new(ui.ctx(), ui_kit::Surface::Panel).floating();timeline::follow_view_pick(self);render_ui::focus_shortcut(self, ui);- let show_timeline = self.ui.show_timeline && !render_workspace::active(self);+ let show_timeline = self.ui.show_timeline && !render_workspace::active(self) && !self.preferences.history_in_browser;let left_timeline = show_timeline && self.preferences.timeline_left;timeline_left::animate_folds(self, ui.ctx());if !floating && !self.embedded {diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex 0996294337..6b4fd67c75 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -947,6 +947,9 @@ preference_settings! {timeline_left_width: f32 = 130.0, PAGE_INTERFACE;/// Share the browser column, vertically, instead of a separate left column.timeline_under_browser: bool = false, PAGE_INTERFACE;+ /// Compact history: the browser lists each component's features in history order with the+ /// marker, and neither timeline is shown.+ history_in_browser: bool = false, PAGE_INTERFACE;/// Fold the shared-column history to its header.timeline_collapsed: bool = false, PAGE_INTERFACE;/// The browser's share of the column's height when History sits under it, which the userdiff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rsindex 29958a6914..8e6f0605d3 100644--- a/crates/ui-egui/src/prefs/interface.rs+++ b/crates/ui-egui/src/prefs/interface.rs@@ -105,14 +105,31 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {}}ui_kit::row(ui, app.tr("prefs.history"), |ui| {- let mut selected = if app.preferences.timeline_left { if app.preferences.timeline_under_browser { 2 } else { 1 } } else { 0 };+ let mut selected = if app.preferences.history_in_browser {+ 3+ } else if app.preferences.timeline_left {+ if app.preferences.timeline_under_browser { 2 } else { 1 }+ } else {+ 0+ };if ui_kit::segmented(ui,&mut selected,- &[crate::i18n::tr("prefs.bottom"), crate::i18n::tr("prefs.left"), crate::i18n::tr("prefs.under_browser")],+ &[+ crate::i18n::tr("prefs.bottom"),+ crate::i18n::tr("prefs.left"),+ crate::i18n::tr("prefs.under_browser"),+ crate::i18n::tr("prefs.in_browser"),+ ],ui_kit::Segments { proportional: true, compact: true, ..Default::default() },) {- let _ = app.run("view.history_layout", json!({"dock": match selected { 1=>"left",2=>"under_browser",_=>"bottom" }}));+ let dock = match selected {+ 1 => "left",+ 2 => "under_browser",+ 3 => "browser",+ _ => "bottom",+ };+ let _ = app.run("view.history_layout", json!({ "dock": dock }));}});for (short, legacy) in [@@ -125,9 +142,10 @@ 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).+ // The History at the left and the one in the browser can list a sketch under its+ // feature (#6489); the timeline at the bottom can't.ui_kit::row(ui, app.tr("prefs.history_sketches"), |ui| {- ui.add_enabled_ui(app.preferences.timeline_left, |ui| {+ ui.add_enabled_ui(app.preferences.timeline_left || app.preferences.history_in_browser, |ui| {let mut selected = usize::from(app.preferences.history_sketches == HistorySketches::UnderFeature);if ui_kit::segmented(ui,@@ -193,7 +211,13 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {ui_kit::LayoutPreview {compact: app.ui.layout == crate::shell::LayoutMode::Docked,labels: app.preferences.ribbon_labels,- history: if app.preferences.timeline_left { if app.preferences.timeline_under_browser { 2 } else { 1 } } else { 0 },+ history: if app.preferences.history_in_browser {+ 3+ } else if app.preferences.timeline_left {+ if app.preferences.timeline_under_browser { 2 } else { 1 }+ } else {+ 0+ },translucent: app.preferences.browser_float,}})diff --git a/crates/ui-egui/src/timeline_left.rs b/crates/ui-egui/src/timeline_left.rsindex ceb11513ba..fca0c73d0c 100644--- a/crates/ui-egui/src/timeline_left.rs+++ b/crates/ui-egui/src/timeline_left.rs@@ -859,7 +859,7 @@ fn group_last_feature(}/// Whether Sketches: Under their feature is on (#6489).-fn nests(app: &SolveApp) -> bool {+pub(crate) fn nests(app: &SolveApp) -> bool {app.preferences.history_sketches == crate::prefs::HistorySketches::UnderFeature}@@ -877,7 +877,7 @@ fn drawn_rows(app: &SolveApp, nest: bool) -> HistoryRows {}/// The fold of a feature's listed sketches; closed until opened.-fn sketches_key(feature: u64) -> String {+pub(crate) fn sketches_key(feature: u64) -> String {format!("timeline/feature/{feature}/sketches")}diff --git a/crates/ui-egui/src/ui_kit/preferences_figures.rs b/crates/ui-egui/src/ui_kit/preferences_figures.rsindex 523a7dad0b..acc9cea990 100644--- a/crates/ui-egui/src/ui_kit/preferences_figures.rs+++ b/crates/ui-egui/src/ui_kit/preferences_figures.rs@@ -243,11 +243,13 @@ pub(crate) fn paint_layout(ui: &mut egui::Ui, state: super::preferences::LayoutPcrate::icons::glyphs::brand_mark_silhouette(&p, object_centre, c.width(22.0), quiet);p.circle_filled(c.at(110.0 - inset, top + 7.0), c.width(3.5), quiet);let history = match state.history {- 1 => panel(inset, top, 10.0, bottom - top, "", t.selected_bg),- 2 => panel(bx, top + browser_height + gap, bw, bottom - top - browser_height - gap, "History", t.selected_bg),- _ => panel(inset, bottom - 10.0, 120.0 - inset * 2.0, 10.0, "History", t.selected_bg),+ 1 => Some(panel(inset, top, 10.0, bottom - top, "", t.selected_bg)),+ 2 => Some(panel(bx, top + browser_height + gap, bw, bottom - top - browser_height - gap, "History", t.selected_bg)),+ // In the browser: no history panel of its own.+ 3 => None,+ _ => Some(panel(inset, bottom - 10.0, 120.0 - inset * 2.0, 10.0, "History", t.selected_bg)),};- if state.history == 1 {+ if let Some(history) = history.filter(|_| state.history == 1) {// A single vertical mark reads as the narrow icon-only history rail.p.line_segment([history.center_top() + vec2(0.0, t.space_8), history.center_bottom() - vec2(0.0, t.space_8)],