SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Browser and History: keep row tools working when either panel is hidden (#11303) (#11416)
Nathan Dane9e3e403b3f86
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rsindex d446427caa..1ffe9e0253 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -36,10 +36,12 @@ pub(crate) fn reveal_feature(app: &mut SolveApp, id: u64, body: &str) {/// to it, its Bodies folder and any group around it) and scroll its row into view. The rows/// are opened here, not while drawing, because a collapsed ancestor never draws its children.pub(crate) fn reveal_body(app: &mut SolveApp, body: &str) {+ sync_reveals(app);app.ui.show_browser = true;app.preferences.timeline_left_browser_collapsed = false;app.tree.reveal_feature = None;app.tree.reveal = Some(body.to_string());+ remember_reveal_source(app, body);let state = app.session.model.state();let Some(source) = crate::open_meshing::session_world(&app.session).body(body).map(|selected| selected.definition_name().to_string()) else {return;@@ -96,20 +98,14 @@ use crate::theme::Tokens;use crate::SolveApp;-thread_local! {- /// The rows drawn this frame: (label, row, fold arrow area, open). For automation- /// (`ui.at {browser | chevron}`, `ui.browser`).- static DRAWN: std::cell::RefCell<Vec<(String, Rect, Option<Rect>, Option<bool>)>> = const { std::cell::RefCell::new(Vec::new()) };- static OCCURRENCES: std::cell::RefCell<Vec<(Vec<u64>, String, Rect, bool)>> = const { std::cell::RefCell::new(Vec::new()) };+/// The Browser's rows on screen: (label, row rect, fold arrow area, open).+/// Other presentations expose their geometry through `semantic_content::output`.+pub fn drawn_rows() -> Vec<crate::semantic_content::DrawnRow> {+ crate::semantic_content::output(crate::semantic_content::ContentOwner::BROWSER).rows}-/// The rows on screen: (label, row rect, fold arrow area, open).-pub fn drawn_rows() -> Vec<(String, Rect, Option<Rect>, Option<bool>)> {- DRAWN.with(|d| d.borrow().clone())-}--pub fn drawn_occurrences() -> Vec<(Vec<u64>, String, Rect, bool)> {- OCCURRENCES.with(|d| d.borrow().clone())+pub fn drawn_occurrences() -> Vec<crate::semantic_content::DrawnOccurrence> {+ crate::semantic_content::output(crate::semantic_content::ContentOwner::BROWSER).occurrences}/// Browser state kept between frames.@@ -125,6 +121,10 @@ pub struct TreeState {/// of a part apart) and open the components, placements and folders above it: Find in/// Browser, and a body picked in the viewport (#3005).pub reveal: Option<String>,+ /// Enough provenance to distinguish temporary rollback/suppression from target removal.+ reveal_source: Option<BodyRevealSource>,+ /// Runtime owner of the active pending requests, including requests with numeric IDs.+ reveal_session: Option<u64>,/// A native feature to reveal in its placed component's Features folder (Find in Timeline).pub(super) reveal_feature: Option<features::Reveal>,/// The Move/Copy panel of an occurrence.@@ -155,13 +155,8 @@ pub struct TreeState {pub view_pick: Option<u64>,/// The Edit Canvas / Calibrate panel.pub canvas_panel: Option<CanvasPanel>,- /// The bodies a row at the top of the history lights this frame (`history_rows`), for the- /// browser, drawn after it, to keep.- history_hover: Vec<String>,/// The Edit Point Cloud panel.pub cloud_panel: Option<CloudPanel>,- /// The plane a row at the top of the history lights this frame, kept the same way (#6975).- history_plane: Option<String>,/// A Section Analysis hidden with its eye in the Analysis folder: its plane (origin,/// normal), so the eye can bring it back (#822).pub hidden_section: Option<(solidcore_record::Vec3, solidcore_record::Vec3)>,@@ -175,15 +170,8 @@ pub struct TreeState {pub capture_prompt: Option<String>,/// The design, undo depth and visibility when the button last went down: a drag over the eyes/// merges the steps it made into one (`eye_drag_frame`).- eye_press: Option<(Arc<Document>, usize, solidcraft_engine::Visibility)>,- /// The last row clicked (for Shift ranges).- anchor: Option<String>,- /// Row keys in drawing order this frame (for Shift ranges).- order: Vec<String>,- /// The previous frame's complete row order: a Shift click resolves its range here, since- /// this frame's `order` does not yet hold the rows below the clicked one (#4991).- order_prev: Vec<String>,- order_len: usize,+ eye_press: Option<(u64, Arc<Document>, usize, solidcraft_engine::Visibility)>,+ pub(crate) content: crate::semantic_content::Frame,cache: Option<cache::Cache>,}@@ -193,6 +181,71 @@ struct FolderPick {doc: Weak<Document>,}+struct BodyRevealSource {+ body: String,+ session: u64,+ creator: u64,+}++/// Pending presentation requests parked alongside their session in a bounded document slot.+/// Pointer input (`view_pick`) deliberately never travels with the slot.+#[derive(Default)]+pub(crate) struct PendingReveals {+ session: Option<u64>,+ body: Option<String>,+ source: Option<BodyRevealSource>,+ feature: Option<features::Reveal>,+ timeline: Option<u64>,+}++pub(crate) fn discard_reveals(app: &mut SolveApp) {+ app.tree.reveal = None;+ app.tree.reveal_source = None;+ app.tree.reveal_feature = None;+ app.tree.timeline_reveal = None;+ app.tree.view_pick = None;+ app.tree.reveal_session = Some(app.session.uid);+}++/// Guard request creation and presentation even when a session changes after frame begin.+pub(crate) fn sync_reveals(app: &mut SolveApp) {+ if app.tree.reveal_session.is_some_and(|session| session != app.session.uid) {+ discard_reveals(app);+ }+ if app.tree.reveal_source.as_ref().is_some_and(|source| source.session != app.session.uid) {+ app.tree.reveal = None;+ app.tree.reveal_source = None;+ }+ app.tree.reveal_session = Some(app.session.uid);+}++pub(crate) fn take_reveals(app: &mut SolveApp) -> PendingReveals {+ sync_reveals(app);+ app.tree.view_pick = None;+ PendingReveals {+ session: Some(app.session.uid),+ body: app.tree.reveal.take(),+ source: app.tree.reveal_source.take(),+ feature: app.tree.reveal_feature.take(),+ timeline: app.tree.timeline_reveal.take(),+ }+}++pub(crate) fn restore_reveals(app: &mut SolveApp, pending: PendingReveals) {+ discard_reveals(app);+ if pending.session == Some(app.session.uid) {+ app.tree.reveal = pending.body;+ app.tree.reveal_source = pending.source;+ app.tree.reveal_feature = pending.feature;+ app.tree.timeline_reveal = pending.timeline;+ }+}++pub(crate) fn request_timeline_reveal(app: &mut SolveApp, id: u64) {+ sync_reveals(app);+ app.tree.timeline_reveal = Some(id);+}+impl FolderPick {fn current(&self, app: &SolveApp) -> bool {self.session == app.session.uid && std::ptr::eq(self.doc.as_ptr(), Arc::as_ptr(&app.session.doc))@@ -200,6 +253,10 @@ impl FolderPick {}impl TreeState {+ pub(crate) fn for_session(session: u64) -> Self {+ Self { reveal_session: Some(session), ..Default::default() }+ }+pub(crate) fn clear_folder_pick(&mut self) {self.picked_folder = None;}@@ -224,15 +281,7 @@ impl TreeState {}fn remember(&mut self, key: &str) {- if let Some(slot) = self.order.get_mut(self.order_len) {- if slot != key {- slot.clear();- slot.push_str(key);- }- } else {- self.order.push(key.to_owned());- }- self.order_len += 1;+ self.content.current_mut().remember(key);}}@@ -478,15 +527,29 @@ pub fn toggle_folder(app: &mut SolveApp, key: &str) {/// hidden items are noted; when it comes up, the steps the drag made are merged into the first of/// them. Runs every frame, whatever else is open, so a release is never missed.pub(crate) fn eye_drag_frame(app: &mut SolveApp, ctx: &egui::Context) {+ crate::semantic_content::ensure_session(app, ctx);let (pressed, down) = ctx.input(|i| (i.pointer.primary_pressed(), i.pointer.primary_down()));- if pressed {- app.tree.eye_press = Some((app.session.doc.clone(), app.session.undo.len(), without_origin(app.session.visibility.clone())));+ if pressed && app.tree.eye_press.is_none() {+ app.tree.eye_press = Some((app.session.uid, app.session.doc.clone(), app.session.undo.len(), without_origin(app.session.visibility.clone())));}if down {return;}+ end_eye_drag(app, ctx);+}++/// Also called when the presentation holding the gesture disappears while the button is down.+pub(crate) fn end_eye_drag(app: &mut SolveApp, ctx: &egui::Context) {+ let capture = crate::semantic_content::release_eye(ctx);let dragged = ctx.data_mut(|d| d.remove_temp::<bool>(crate::ui_kit::eye_drag_id())).is_some();- let Some((doc, depth, visibility)) = app.tree.eye_press.take().filter(|_| dragged) else { return };+ let Some((_, doc, depth, visibility)) = app+ .tree+ .eye_press+ .take()+ .filter(|(session, ..)| dragged && *session == app.session.uid && capture.is_none_or(|source| source.session == *session))+ else {+ return;+ };// shortcut: once the history is full (200 steps) its length stops growing, so the drag is left as// separate steps, like the point-cloud and canvas drags; the visibility test keeps a trimmed front// from being merged wrongly.@@ -496,6 +559,10 @@ pub(crate) fn eye_drag_frame(app: &mut SolveApp, ctx: &egui::Context) {}}+pub(crate) fn discard_eye_press(app: &mut SolveApp) {+ app.tree.eye_press = None;+}+/// The Origin's own eye is not an undo step (`set_origin_shown`), so the drag's steps do not hold it:/// it is left out of the comparison.fn without_origin(mut visibility: solidcraft_engine::Visibility) -> solidcraft_engine::Visibility {@@ -612,11 +679,12 @@ fn eye_left(ui: &egui::Ui) -> bool {pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row<'_>) -> RowResp {let compact = compact_tree(ui);- let out = crate::ui_kit::tree_row(ui, id, &Row { compact, eye_left: eye_left(ui), ..*row });+ let mut out = crate::ui_kit::tree_row(ui, id, &Row { compact, eye_left: eye_left(ui), ..*row });+ crate::semantic_content::route_response(ui, id, &mut out);if let Some(r) = out.rect.filter(|r| ui.is_rect_visible(*r)) {let x = r.left() + if compact { Tokens::get().space_8 } else { 2.0 } + row.depth as f32 * INDENT;let fold = row.fold.map(|_| Rect::from_min_max(pos2(x - 4.0, r.top()), pos2(x + 15.0, r.bottom())));- DRAWN.with(|d| d.borrow_mut().push((row.label.to_string(), r, fold, row.fold)));+ crate::semantic_content::record_row(ui, (row.label.to_string(), r, fold, row.fold), &out);}out}@@ -624,11 +692,11 @@ pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row<'_>) -> RowRes/// A Ctrl/Shift-aware click on a selectable row.fn click_select(app: &mut SolveApp, ui: &egui::Ui, key: String, sel: Option<Sel>) {let mods = ui.input(|i| i.modifiers);+ let rows = app.tree.content.current_mut();if mods.shift- && let Some(a) = app.tree.anchor.as_deref()+ && let Some(a) = rows.anchor.as_deref(){- let order = app.tree.order.get(..app.tree.order_len).unwrap_or(&[]);- let items = shift_range(&app.tree.order_prev, a, &key).or_else(|| shift_range(order, a, &key));+ let items = shift_range(&rows.previous, a, &key).or_else(|| shift_range(rows.current_order(), a, &key));if let Some(items) = items {// Move/Copy (and any open command whose active input takes bodies) gets every body// in the range. Otherwise the range is an ordinary selection.@@ -646,7 +714,7 @@ fn click_select(app: &mut SolveApp, ui: &egui::Ui, key: String, sel: Option<Sel>return;}}- app.tree.anchor = Some(key);+ app.tree.content.current_mut().anchor = Some(key);let Some(sel) = sel else { return };if mods.command || mods.ctrl {if app.session.selection.contains(&sel) {@@ -701,18 +769,29 @@ pub(crate) fn picked_body(sel: &Sel) -> Option<&str> {/// A pick in the viewport: the Browser, when shown, opens down to the picked body's row and/// scrolls to it (#3005). The body of the last item picked.pub(crate) fn reveal_pick(app: &mut SolveApp) {+ sync_reveals(app);if app.ui.show_browser&& let Some(body) = app.session.selection.last().and_then(picked_body){- app.tree.reveal = Some(body.to_string());+ let body = body.to_owned();+ remember_reveal_source(app, &body);+ app.tree.reveal = Some(body);}}+fn remember_reveal_source(app: &mut SolveApp, body: &str) {+ app.tree.reveal_source = crate::open_meshing::session_world(&app.session).body(body).map(|selected| BodyRevealSource {+ body: body.to_owned(),+ session: app.session.uid,+ creator: selected.feature,+ });+}+/// The placement path of the body being revealed, resolved once per model: a row opens when/// the body's path runs through it, instead of every row expanding its subtree to test/// containment (#7502). `None` when nothing is revealed or the body is a top-level design body.fn reveal_path(app: &mut SolveApp) -> Option<Vec<u64>> {- let body = app.tree.reveal.clone()?;+ let body = body_reveal(app)?.to_owned();prepare_model(app);app.tree.model.as_mut()?.body_path(&app.session, &body)}@@ -774,17 +853,24 @@ pub fn apply_fold(app: &mut SolveApp, open: bool, open_by_default: &[String], cl/// Everything a frame's rows want done, applied after drawing.#[derive(Default)]-struct Actions {+pub(crate) struct Actions {+ pub(crate) session: Option<u64>,menu: Option<(Pos2, Target)>,- hover_bodies: Vec<String>,- hovered: bool,+ pub(crate) hover_bodies: Vec<String>,+ pub(crate) hovered: bool,/// The plane whose row is under the pointer, lit in the view (#6975).- hover_plane: Option<String>,- drop: Option<DropAction>,+ pub(crate) hover_plane: Option<String>,+ drop: Option<(crate::semantic_content::ContentSource, DropAction)>,/// What the selection and the 3D view's pointer light in the tree.lit: Lit,}+impl Actions {+ fn drop_from(&mut self, source: crate::semantic_content::ContentSource, action: DropAction) {+ self.drop = Some((source, action));+ }+}+/// Something in the 3D view with a row in the tree.#[derive(Clone, Debug, PartialEq, Eq, Hash)]enum Thing {@@ -1018,16 +1104,11 @@ fn reveal_tab(ui: &egui::Ui, card: Rect, opacity: f32) {/// One content-hugging browser; the shared container supplies floating or flush compact chrome.pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {+ sync_reveals(app);let available = ui.available_rect_before_wrap();let t = Tokens::get();- std::mem::swap(&mut app.tree.order_prev, &mut app.tree.order);- app.tree.order_len = 0;- DRAWN.with(|d| d.borrow_mut().clear());- OCCURRENCES.with(|d| d.borrow_mut().clear());- let mut acts = Actions { hover_bodies: std::mem::take(&mut app.viewport.hover_bodies), ..Default::default() };if crate::render_workspace::active(app) {- render_card(app, ui, &mut acts);- finish_browser(app, ui, acts);+ render_card(app, ui);return;}let stacked = crate::timeline_left::stacked(app);@@ -1084,7 +1165,7 @@ pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {if collapsed {browser_collapsed_rail(app, ui);} else {- browser_contents(app, ui, &mut acts, true);+ browser_contents(app, ui, true);}})})@@ -1104,10 +1185,9 @@ pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {crate::scenario::publish_rect("browser:float", rect);}}- finish_browser(app, ui, acts);}-fn render_card(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {+fn render_card(app: &mut SolveApp, ui: &mut egui::Ui) {let bounds = crate::shell::panel_bounds(app, ui.available_rect_before_wrap());let narrow = bounds.width() < 800.0;crate::shell::register_panel(app, "render:browser:show", None, None);@@ -1154,7 +1234,7 @@ fn render_card(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {}}ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("sc_compact_tree"), true));- browser_contents(app, ui, acts, true);+ browser_contents(app, ui, true);ui.ctx().data_mut(|d| d.remove::<bool>(egui::Id::new("sc_compact_tree")));},);@@ -1220,7 +1300,7 @@ pub(crate) fn panel_bounds(available: Rect, history: Option<Rect>, width: f32, gRect::from_min_max(min, pos2((min.x + width).min(right), bottom))}-fn browser_contents(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions, collapsible: bool) {+fn browser_contents(app: &mut SolveApp, ui: &mut egui::Ui, collapsible: bool) {let t = Tokens::get();// Only the floating card folds; the docked column keeps its full height.let render = crate::render_workspace::active(app);@@ -1248,9 +1328,9 @@ fn browser_contents(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions, c}crate::edit_in_place::browser_strip(app, ui);if collapsible && !stacked {- browser_rows_hugging(app, ui, acts);+ browser_rows_hugging(app, ui);} else {- browser_rows(app, ui, acts);+ browser_rows(app, ui);}}@@ -1362,19 +1442,28 @@ fn model_feature_indices(app: &SolveApp, component: u64, sketches: bool) -> Vec<}}-fn browser_rows(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {- rows_scrolling(app, ui, acts, false);+fn browser_rows(app: &mut SolveApp, ui: &mut egui::Ui) {+ crate::semantic_content::show(+ app,+ ui,+ crate::semantic_content::ContentOwner::BROWSER,+ crate::semantic_content::ContentRequest::Browser { shrink_height: false },+ );}/// As [browser_rows], but the area hugs the rows it drew (the floating card), up to the height/// the caller allowed.-fn browser_rows_hugging(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {- rows_scrolling(app, ui, acts, true);+fn browser_rows_hugging(app: &mut SolveApp, ui: &mut egui::Ui) {+ crate::semantic_content::show(+ app,+ ui,+ crate::semantic_content::ContentOwner::BROWSER,+ crate::semantic_content::ContentRequest::Browser { shrink_height: true },+ );}fn rows_scrolling(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions, shrink_height: bool) {prepare_model(app);- acts.lit = Lit::of(app);let mut cache = app.tree.cache.take().unwrap_or_default();cache.prepare(app);egui::ScrollArea::vertical()@@ -1394,23 +1483,32 @@ fn rows_scrolling(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions, shrcomponent_rows(app, ui, 0, 0, acts, &mut cache);}});- // The row was reached and scrolled to, or isn't in the tree (a body a later feature removes):- // either way the reveal is done.- app.tree.reveal = None;app.tree.cache = Some(cache);}-/// The Bodies folder and the Origin at the top of the vertical History (Preferences › Interface:-/// Show origin and bodies at the top, #6490): the browser's own rows, with their eyes, selection,-/// menus and fold state. The bodies are the active component's, in the placement being edited,-/// as that component's folder in the browser lists them. The rows stay out of the browser's row-/// order, automation list and reveal, which the browser keeps for its own rows.+/// Existing semantic rows, reusable by either presentation without a panel host.+pub(crate) fn render_content(app: &mut SolveApp, ui: &mut egui::Ui, request: crate::semantic_content::ContentRequest) -> Actions {+ crate::semantic_content::ensure_session(app, ui.ctx());+ let mut acts = Actions { session: Some(app.session.uid), lit: Lit::of(app), ..Default::default() };+ match request {+ crate::semantic_content::ContentRequest::Browser { shrink_height } => rows_scrolling(app, ui, &mut acts, shrink_height),+ crate::semantic_content::ContentRequest::ActiveBodiesOrigin => active_bodies_origin(app, ui, &mut acts),+ }+ acts+}++/// History's optional prefix shares the Browser's cache, folds, row renderers and commands.pub(crate) fn history_rows(app: &mut SolveApp, ui: &mut egui::Ui) {+ crate::semantic_content::show(+ app,+ ui,+ crate::semantic_content::ContentOwner::HISTORY,+ crate::semantic_content::ContentRequest::ActiveBodiesOrigin,+ );+}++fn active_bodies_origin(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions) {prepare_model(app);- let mut acts = Actions { lit: Lit::of(app), ..Default::default() };- let reveal = app.tree.reveal.take();- let order = app.tree.order_len;- let drawn = DRAWN.with(|d| d.borrow().len());let component = app.session.active_component;let path = (component != 0).then(|| app.session.active_occurrence_path.clone().unwrap_or_else(|| app.session.doc.first_path(component)))@@ -1422,41 +1520,35 @@ pub(crate) fn history_rows(app: &mut SolveApp, ui: &mut egui::Ui) {app.tree.cache = Some(cache);ui.scope(|ui| {ui.spacing_mut().item_spacing.y = 0.0;- folder_rows_at(app, ui, component, path.as_deref(), "bodies", 0, &mut acts, &bodies);- origin_rows(app, ui, 0, &mut acts);+ folder_rows_at(app, ui, component, path.as_deref(), "bodies", 0, acts, &bodies);+ origin_rows(app, ui, 0, acts);});- app.tree.reveal = reveal;- // The browser's own rows reuse these order slots (`TreeState::remember`).- app.tree.order_len = order;- DRAWN.with(|d| d.borrow_mut().truncate(drawn));- app.viewport.hover_bodies = acts.hover_bodies.clone();- app.tree.history_hover = acts.hover_bodies;- app.viewport.hover_plane = acts.hover_plane.clone();- app.tree.history_plane = acts.hover_plane;- if let Some(d) = acts.drop {- apply_drop(app, d);- }- if let Some((at, target)) = acts.menu {- crate::context_menu::open_for(app, at, target);- }}-fn finish_browser(app: &mut SolveApp, ui: &mut egui::Ui, mut acts: Actions) {- app.tree.order.truncate(app.tree.order_len);- if !acts.hovered {- acts.hover_bodies.clear();+pub(crate) fn apply_content_actions(app: &mut SolveApp, acts: Actions) {+ if acts.session != Some(app.session.uid) {+ return;}- // The history's rows, drawn before the browser, light bodies too (`history_rows`).- let history = std::mem::take(&mut app.tree.history_hover);- app.viewport.hover_bodies = if acts.hover_bodies.is_empty() { history } else { acts.hover_bodies };- let history_plane = app.tree.history_plane.take();- app.viewport.hover_plane = acts.hover_plane.or(history_plane);- if let Some(d) = acts.drop {+ if let Some((_, d)) = acts.drop.filter(|(source, _)| crate::semantic_content::source_present(app, *source)) {+ // The target may have consumed a payload before its source's absence was known.+ // Commit only after all owners have reported, using the payload's original source.apply_drop(app, d);}if let Some((at, target)) = acts.menu {crate::context_menu::open_for(app, at, target);}+}++pub(crate) fn cancel_content_drag(ctx: &egui::Context, session: u64) {+ if egui::DragAndDrop::payload::<Drag>(ctx).is_some_and(|payload| payload.source.session == session)+ || egui::DragAndDrop::payload::<OccurrenceDrag>(ctx).is_some_and(|payload| payload.source.session == session)+ {+ egui::DragAndDrop::clear_payload(ctx);+ }+}++/// App-owned editor lifecycle; these windows do not depend on any tree being presented.+pub(crate) fn editors(app: &mut SolveApp, ui: &mut egui::Ui) {crate::browser_prompts::occurrence_panel(app, ui);crate::browser_prompts::capture_prompt(app, ui.ctx());crate::browser_canvas::panel(app, ui.ctx());@@ -1464,6 +1556,43 @@ fn finish_browser(app: &mut SolveApp, ui: &mut egui::Ui, mut acts: Actions) {crate::sketch_attachment_ui::panel(app, ui.ctx());}+/// History's prefix must neither open ancestors nor acknowledge a Browser reveal.+fn body_reveal(app: &SolveApp) -> Option<&str> {+ app.tree.content.browser_presentation().then_some(app.tree.reveal.as_deref()).flatten()+}++/// A hidden or collapsed presentation retains its request. Removed targets expire here.+pub(crate) fn prune_reveals(app: &mut SolveApp) {+ sync_reveals(app);+ if let Some(body) = app.tree.reveal.as_ref() {+ let world = crate::open_meshing::session_world(&app.session);+ let source = app.tree.reveal_source.as_ref().filter(|source| source.body == *body);+ let removed = source.is_some_and(|source| source.session != app.session.uid || app.session.doc.feature(source.creator).is_none());+ let evaluated = match source {+ Some(source) => app.session.doc.features.iter().enumerate().any(|(index, feature)| {+ feature.id == source.creator && !feature.suppressed && app.session.doc.marker.is_none_or(|marker| index < marker)+ }),+ None => app.session.doc.marker.is_none() && !app.session.doc.features.iter().any(|feature| feature.suppressed),+ };+ // A refused feature can temporarily remove a body from evaluation too. Its pending+ // reveal remains useful when the feature is repaired.+ let healthy =+ app.session.model.results.iter().all(|result| result.error.is_none()) && crate::open_meshing::placement_error(&app.session).is_none();+ if world.body(body).is_none() && (removed || (evaluated && healthy)) {+ app.tree.reveal = None;+ app.tree.reveal_source = None;+ }+ } else {+ app.tree.reveal_source = None;+ }+ if app.tree.reveal_feature.as_ref().is_some_and(|target| app.session.doc.feature(target.id).is_none()) {+ app.tree.reveal_feature = None;+ }+ if app.tree.timeline_reveal.is_some_and(|id| app.session.doc.feature(id).is_none()) {+ app.tree.timeline_reveal = None;+ }+}+fn component_name(app: &SolveApp, id: u64) -> String {if id == 0 {return app.session.doc.name.clone();@@ -1500,7 +1629,7 @@ fn component_rows_inner(return;}let key = &root.key;- let reveal = app.tree.reveal.clone();+ let reveal = body_reveal(app).map(str::to_owned);if let Some(body) = reveal.as_ref() {let reveals =cache.root_bodies.contains(body) || reveal_path(app).is_some_and(|rp| root.children.iter().any(|path| rp.starts_with(path.as_slice())));@@ -1583,7 +1712,7 @@ fn component_rows_inner(if let Some(resp) = &r.resp&& let Some(d) = drop_target(ui, resp, |d: &Drag| d.comp != id && d.folder != "construction" && d.groups.is_empty(), DropMark::Box){- acts.drop = Some(DropAction::Component { to: id, folder: d.folder, keys: d.keys.clone() });+ acts.drop_from(d.source, DropAction::Component { to: id, folder: d.folder, keys: d.keys.clone() });}// A placement row dropped on the design row moves out to the design.@@ -1591,7 +1720,7 @@ fn component_rows_inner(&& let Some(d) = occurrence_drop_target(ui, resp, |d| occurrence_can_land(app, d, id)){let occurrence = d.path.last().copied().unwrap_or(0);- acts.drop = Some(DropAction::Reparent { occurrence, path: d.path.clone(), parent: id, parent_path: None });+ acts.drop_from(d.source, DropAction::Reparent { occurrence, path: d.path.clone(), parent: id, parent_path: None });}if !open {return;@@ -1705,7 +1834,7 @@ fn occurrence_rows_inner(},);if let Some(rect) = r.rect.filter(|_| r.resp.is_some()) {- OCCURRENCES.with(|d| d.borrow_mut().push((path.to_vec(), placement.name.clone(), rect, open)));+ crate::semantic_content::record_occurrence(ui, (path.to_vec(), placement.name.clone(), rect, open));// Near the row's end, clear of an eye there.let end = r.eye_at.filter(|e| e.x > rect.center().x).map_or(rect.right() - 12.0, |e| e.x - 24.0);crate::scenario::publish_handle(&format!("row:occurrence:{}", key.trim_start_matches("o:")), pos2(end, rect.center().y));@@ -1725,8 +1854,11 @@ fn occurrence_rows_inner(});// Dragging the row moves the placement it stands for. A press on its fold arrow, eye or// radio is not a drag of the row, so those controls keep their own jobs.- if resp.drag_started() && !r.on_control {- resp.dnd_set_drag_payload(OccurrenceDrag { path: path.to_vec(), component: placement.component });+ if resp.drag_started()+ && !r.on_control+ && let Some(source) = crate::semantic_content::current_source(app)+ {+ resp.dnd_set_drag_payload(OccurrenceDrag { source, path: path.to_vec(), component: placement.component });}}if r.fold {@@ -1770,7 +1902,7 @@ fn occurrence_rows_inner(&& let Some(d) =drop_target(ui, resp, |d: &Drag| d.comp != placement.component && d.folder != "construction" && d.groups.is_empty(), DropMark::Box){- acts.drop = Some(DropAction::Component { to: placement.component, folder: d.folder, keys: d.keys.clone() });+ acts.drop_from(d.source, DropAction::Component { to: placement.component, folder: d.folder, keys: d.keys.clone() });}// The top of a sibling's row puts the dragged placement before it; the rest of the row, and@@ -1786,8 +1918,7 @@ fn occurrence_rows_inner(app.session.doc.sort_placements(parent, &mut order);let at = order.iter().position(|o| *o == placement.occurrence).unwrap_or(order.len());order.insert(at, dragged);- let order: Vec<String> = order.iter().map(u64::to_string).collect();- let _ = app.run("browser.order", json!({ "folder": "components", "component": parent, "order": order }));+ acts.drop_from(d.source, DropAction::OccurrenceOrder { parent, order });}// A placement row dropped on this one moves into this row's component.if let Some(resp) = &r.resp@@ -1796,7 +1927,10 @@ fn occurrence_rows_inner(}){let occurrence = d.path.last().copied().unwrap_or(0);- acts.drop = Some(DropAction::Reparent { occurrence, path: d.path.clone(), parent: placement.component, parent_path: Some(path.to_vec()) });+ acts.drop_from(+ d.source,+ DropAction::Reparent { occurrence, path: d.path.clone(), parent: placement.component, parent_path: Some(path.to_vec()) },+ );}if !open {return;@@ -1914,7 +2048,7 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut Aapp.set_origin_shown(!app.origin_shown());}if let Some(p) = r.secondary {- crate::context_menu::open_for(app, p, Target::Origin);+ acts.menu = Some((p, Target::Origin));}if !open {return;@@ -1957,7 +2091,7 @@ fn origin_rows(app: &mut SolveApp, ui: &mut egui::Ui, depth: usize, acts: &mut A_ => None,};if let Some(target) = target {- crate::context_menu::open_for(app, p, target);+ acts.menu = Some((p, target));}}if r.hovered && icon == "plane" {@@ -2450,6 +2584,7 @@ impl Entry {/// What is being dragged in the tree: items of one component folder.#[derive(Clone, Debug)]struct Drag {+ source: crate::semantic_content::ContentSource,comp: u64,folder: &'static str,keys: Vec<String>,@@ -2467,6 +2602,7 @@ impl Drag {/// A placement row dragged in the tree: the exact path it sits at, and the component it places.#[derive(Clone, Debug)]struct OccurrenceDrag {+ source: crate::semantic_content::ContentSource,/// The placement's path from the design root (its own occurrence id last).path: Vec<u64>,/// The component the placement is an instance of.@@ -2622,7 +2758,7 @@ fn folder_rows_at(let fstatic = folder_static(folder);let key = &data.key;let prefix = key.rsplit_once('/').map_or(key.as_str(), |(prefix, _)| prefix);- if let Some(r) = app.tree.reveal.as_deref()+ if let Some(r) = body_reveal(app)&& folder == "bodies"&& let Some(e) = data.entries().find(|e| e.row_key.strip_prefix("b:") == Some(r)){@@ -2693,17 +2829,20 @@ fn folder_rows_at(DropMark::Box,){- acts.drop = Some(if d.comp == comp {- DropAction::Order {- comp,- folder: fstatic,- keys: d.keys.clone(),- groups: d.groups.clone(),- order: order_before(&data.top_order, &d.entries(), None),- }- } else {- DropAction::Component { to: comp, folder: d.folder, keys: d.keys.clone() }- });+ acts.drop_from(+ d.source,+ if d.comp == comp {+ DropAction::Order {+ comp,+ folder: fstatic,+ keys: d.keys.clone(),+ groups: d.groups.clone(),+ order: order_before(&data.top_order, &d.entries(), None),+ }+ } else {+ DropAction::Component { to: comp, folder: d.folder, keys: d.keys.clone() }+ },+ );}if !open {return;@@ -2790,8 +2929,11 @@ fn folder_level(}if let Some(resp) = &r.resp {// Dragging a group row moves the group; a press on its arrow or eye is not a drag.- if resp.drag_started() && !r.on_control {- resp.dnd_set_drag_payload(Drag { comp, folder: fstatic, keys: Vec::new(), groups: vec![id] });+ if resp.drag_started()+ && !r.on_control+ && let Some(source) = crate::semantic_content::current_source(app)+ {+ resp.dnd_set_drag_payload(Drag { source, comp, folder: fstatic, keys: Vec::new(), groups: vec![id] });}// The top of the row puts the drop before the group; the rest puts it inside.let level = app.session.doc.group_level(id);@@ -2803,26 +2945,29 @@ fn folder_level(d.comp == comp && d.folder == fstatic && fits(d, if zone == DropMark::Above { level - 1 } else { level })}) {let before = BrowserEntry::Group(id);- acts.drop = Some(match (zone, holder) {- (DropMark::Box, _) => {- DropAction::Move { comp, folder: fstatic, keys: d.keys.clone(), groups: d.groups.clone(), group: Some(id), before: None }- }- (DropMark::Above, Some(h)) => DropAction::Move {- comp,- folder: fstatic,- keys: d.keys.clone(),- groups: d.groups.clone(),- group: Some(h),- before: Some(before),- },- (DropMark::Above, None) => DropAction::Order {- comp,- folder: fstatic,- order: order_before(top, &d.entries(), Some(&before)),- keys: d.keys.clone(),- groups: d.groups.clone(),+ acts.drop_from(+ d.source,+ match (zone, holder) {+ (DropMark::Box, _) => {+ DropAction::Move { comp, folder: fstatic, keys: d.keys.clone(), groups: d.groups.clone(), group: Some(id), before: None }+ }+ (DropMark::Above, Some(h)) => DropAction::Move {+ comp,+ folder: fstatic,+ keys: d.keys.clone(),+ groups: d.groups.clone(),+ group: Some(h),+ before: Some(before),+ },+ (DropMark::Above, None) => DropAction::Order {+ comp,+ folder: fstatic,+ order: order_before(top, &d.entries(), Some(&before)),+ keys: d.keys.clone(),+ groups: d.groups.clone(),+ },},- });+ );}}if gopen {@@ -2901,7 +3046,7 @@ fn entry_row(let pattern_key = e.patterns.as_deref();let patterns_open = pattern_key.is_some_and(|key| is_open(app, key, true));let rect = row_rect(ui);- let revealed = folder == "bodies" && app.tree.reveal.as_ref().is_some_and(|b| e.row_key.strip_prefix("b:") == Some(b.as_str()));+ let revealed = folder == "bodies" && body_reveal(app).is_some_and(|b| e.row_key.strip_prefix("b:") == Some(b));if !ui.is_rect_visible(rect) && !patterns_open && !revealed {ui.allocate_space(rect.size());return;@@ -2959,10 +3104,10 @@ fn entry_row(toggle(app, key, true);}if folder == "bodies"- && app.tree.reveal.as_ref().is_some_and(|b| e.row_key.strip_prefix("b:") == Some(b.as_str()))+ && body_reveal(app).is_some_and(|b| e.row_key.strip_prefix("b:") == Some(b))&& let Some(rect) = r.rect+ && crate::semantic_content::scroll_acknowledged(ui, rect){- ui.scroll_to_rect(rect, Some(egui::Align::Center));app.tree.reveal = None;}if r.eye {@@ -2979,7 +3124,7 @@ fn entry_row(if folder == "construction" || (folder == "bodies" && !shift && app.dialog.is_some()) {if let Some(s) = e.sel.clone() {if matches!(s, Sel::Body { .. }) {- app.tree.anchor = Some(e.row_key.clone());+ app.tree.content.current_mut().anchor = Some(e.row_key.clone());}pick_from_browser(app, s);}@@ -3030,9 +3175,12 @@ fn entry_row(}let Some(resp) = &r.resp else { return };// Drag: the selected items of this folder when this one is selected, else just this one.- if resp.drag_started() && !r.on_control {+ if resp.drag_started()+ && !r.on_control+ && let Some(source) = crate::semantic_content::current_source(app)+ {let keys: Vec<String> = if selected { selected_keys(app, comp, folder) } else { vec![e.key.clone()] };- resp.dnd_set_drag_payload(Drag { comp, folder, keys, groups: Vec::new() });+ resp.dnd_set_drag_payload(Drag { source, comp, folder, keys, groups: Vec::new() });}let fits = |d: &Drag| {let doc = &app.session.doc;@@ -3043,16 +3191,19 @@ fn entry_row(};if let Some(d) = drop_target(ui, resp, |d: &Drag| d.comp == comp && d.folder == folder && !d.keys.contains(&e.key) && fits(d), DropMark::Above) {let before = BrowserEntry::item(&e.key);- acts.drop = Some(match group {- Some(g) => DropAction::Move { comp, folder, keys: d.keys.clone(), groups: d.groups.clone(), group: Some(g), before: Some(before) },- None => DropAction::Order {- comp,- folder,- order: order_before(top, &d.entries(), Some(&before)),- keys: d.keys.clone(),- groups: d.groups.clone(),+ acts.drop_from(+ d.source,+ match group {+ Some(g) => DropAction::Move { comp, folder, keys: d.keys.clone(), groups: d.groups.clone(), group: Some(g), before: Some(before) },+ None => DropAction::Order {+ comp,+ folder,+ order: order_before(top, &d.entries(), Some(&before)),+ keys: d.keys.clone(),+ groups: d.groups.clone(),+ },},- });+ );}}@@ -3071,6 +3222,7 @@ enum DropMark {/// While a matching payload hovers the row, mark where it would land; on release, the payload.fn drop_target(ui: &egui::Ui, resp: &egui::Response, accept: impl Fn(&Drag) -> bool, mark: DropMark) -> Option<std::sync::Arc<Drag>> {+ let accept = |drag: &Drag| crate::semantic_content::same_document(ui, drag.source) && accept(drag);let t = Tokens::get();let hovering = resp.dnd_hover_payload::<Drag>().filter(|d| accept(d));if hovering.is_some() {@@ -3091,6 +3243,7 @@ fn drop_target(ui: &egui::Ui, resp: &egui::Response, accept: impl Fn(&Drag) -> b/// Like [`drop_target`] for a row that takes a drop above it (its top part) or inside it.fn drop_target_zone(ui: &egui::Ui, resp: &egui::Response, accept: impl Fn(&Drag, DropMark) -> bool) -> Option<(std::sync::Arc<Drag>, DropMark)> {+ let accept = |drag: &Drag, zone| crate::semantic_content::same_document(ui, drag.source) && accept(drag, zone);let t = Tokens::get();let r = resp.rect;let at = ui.input(|i| i.pointer.hover_pos().or(i.pointer.latest_pos()));@@ -3143,6 +3296,7 @@ fn occurrence_reorder_target(resp: &egui::Response,accept: impl Fn(&OccurrenceDrag) -> bool,) -> Option<std::sync::Arc<OccurrenceDrag>> {+ let accept = |drag: &OccurrenceDrag| crate::semantic_content::same_document(ui, drag.source) && accept(drag);if resp.dnd_hover_payload::<OccurrenceDrag>().is_some_and(|d| accept(&d)) {ui.painter().hline(resp.rect.x_range(), resp.rect.top(), Stroke::new(2.0, Tokens::get().accent));}@@ -3154,6 +3308,7 @@ fn occurrence_reorder_target(/// While a matching placement drag hovers the row, mark where it would land; on release, the payload.fn occurrence_drop_target(ui: &egui::Ui, resp: &egui::Response, accept: impl Fn(&OccurrenceDrag) -> bool) -> Option<std::sync::Arc<OccurrenceDrag>> {+ let accept = |drag: &OccurrenceDrag| crate::semantic_content::same_document(ui, drag.source) && accept(drag);let t = Tokens::get();let hovering = resp.dnd_hover_payload::<OccurrenceDrag>().filter(|d| accept(d));if hovering.is_some() {@@ -3169,14 +3324,40 @@ fn occurrence_drop_target(ui: &egui::Ui, resp: &egui::Response, accept: impl Fn(/// A drop, applied after the tree is drawn.enum DropAction {+ OccurrenceOrder {+ parent: u64,+ order: Vec<u64>,+ },/// Into a group (before an item of it), or out of groups.- Move { comp: u64, folder: &'static str, keys: Vec<String>, groups: Vec<u64>, group: Option<u64>, before: Option<BrowserEntry> },+ Move {+ comp: u64,+ folder: &'static str,+ keys: Vec<String>,+ groups: Vec<u64>,+ group: Option<u64>,+ before: Option<BrowserEntry>,+ },/// Out of groups, in this order of the folder's top level.- Order { comp: u64, folder: &'static str, keys: Vec<String>, groups: Vec<u64>, order: Vec<BrowserEntry> },+ Order {+ comp: u64,+ folder: &'static str,+ keys: Vec<String>,+ groups: Vec<u64>,+ order: Vec<BrowserEntry>,+ },/// Into another component (bodies and sketches).- Component { to: u64, folder: &'static str, keys: Vec<String> },+ Component {+ to: u64,+ folder: &'static str,+ keys: Vec<String>,+ },/// A placement moved into another component (or the design, `parent` 0).- Reparent { occurrence: u64, path: Vec<u64>, parent: u64, parent_path: Option<Vec<u64>> },+ Reparent {+ occurrence: u64,+ path: Vec<u64>,+ parent: u64,+ parent_path: Option<Vec<u64>>,+ },}fn entry_json(e: &BrowserEntry) -> Value {@@ -3193,6 +3374,10 @@ fn entries_json(keys: &[String], groups: &[u64]) -> Vec<Value> {fn apply_drop(app: &mut SolveApp, d: DropAction) {match d {+ DropAction::OccurrenceOrder { parent, order } => {+ let order: Vec<String> = order.iter().map(u64::to_string).collect();+ let _ = app.run("browser.order", json!({ "folder": "components", "component": parent, "order": order }));+ }DropAction::Move { comp, folder, keys, groups, group, before } => {let items = entries_json(&keys, &groups);let before = before.map(|b| entry_json(&b));diff --git a/crates/ui-egui/src/browser/features.rs b/crates/ui-egui/src/browser/features.rsindex 75322ffd5e..4d1d9b4342 100644--- a/crates/ui-egui/src/browser/features.rs+++ b/crates/ui-egui/src/browser/features.rs@@ -2,11 +2,14 @@use super::*;use crate::history_rows::{HistoryFeature, HistoryRows};+use crate::semantic_content::FeatureDrag;#[derive(Clone, Debug)]pub(crate) struct Reveal {pub id: u64,pub path: Vec<u64>,+ /// Native Features and combined History are distinct presentations of the same feature.+ history: bool,}#[cfg(test)]@@ -19,6 +22,7 @@ thread_local! {/// active component or history marker. The folder is the one of the placement `body` belongs to:/// without a body there is no telling which copy of a component was meant.pub(crate) fn reveal(app: &mut SolveApp, id: u64, body: &str) {+ sync_reveals(app);let Some(feature) = app.session.doc.feature(id) else { return };if matches!(feature.kind, FeatureKind::Sketch { .. }) {return; // Sketches are listed in Sketches, not Features.@@ -46,17 +50,31 @@ pub(crate) fn reveal(app: &mut SolveApp, id: u64, body: &str) {let scope = if path.is_empty() { format!("c{component}") } else { occurrence_key(&path) };app.tree.open_row(&scope);app.tree.expanded.insert(format!("{scope}/features"));- app.tree.reveal_feature = Some(Reveal { id, path });+ app.tree.reveal_feature = Some(Reveal { id, path, history: false });}/// 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) {+ sync_reveals(app);let Some(component) = app.session.doc.feature(id).map(|feature| feature.component) else { return };+ let path = if component == 0 {+ Vec::new()+ } else {+ app.session+ .active_occurrence_path+ .clone()+ .filter(|_| app.session.active_component == component)+ .unwrap_or_else(|| app.session.doc.first_path(component))+ };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() });+ for depth in 1..=path.len() {+ app.tree.open_row(&occurrence_key(&path[..depth]));+ }+ let scope = if path.is_empty() { format!("c{component}") } else { occurrence_key(&path) };+ app.tree.open_row(&scope);+ app.tree.collapsed.remove(&format!("{scope}/history"));+ app.tree.reveal_feature = Some(Reveal { id, path, history: true });}/// Feature folders hide later rows only while editing; history always lists every feature.@@ -150,8 +168,8 @@ pub(super) fn rows(app: &mut SolveApp, ui: &mut egui::Ui, component: u64, path:let mut slots: Vec<(f32, usize)> = Vec::new();// Where dragged rows can be dropped, as in the History at the left: these slots and one// before the marker, each with the folder the rows join (#9565).- let drag_id = egui::Id::new(("sc_browser_history_drag", &scope));- let mut dragged: Option<Vec<u64>> = ui.data(|d| d.get_temp(drag_id));+ let drag_id = ui.id().with(("sc_browser_history_drag", &scope));+ let mut dragged = app.tree.content.current_mut().feature_drags.get(&drag_id).cloned();let mut drops: Vec<DropSlot> = Vec::new();let mut marker_resp = None;for row in &plan.rows {@@ -251,7 +269,7 @@ fn feature_row(depth: usize,fold: Option<bool>,mark: Mark,- drag: Option<&mut Option<Vec<u64>>>,+ drag: Option<&mut Option<FeatureDrag>>,) -> bool {let Some(feature) = app.session.doc.features.get(index) else { return false };let (component, path) = (here.component, here.path);@@ -315,10 +333,16 @@ fn feature_row(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));+ let history = app.preferences.history_in_browser;+ if app.tree.content.browser_presentation()+ && app.tree.reveal_feature.as_ref().is_some_and(|target| target.id == id && target.path == path && target.history == history)+ && crate::semantic_content::scroll_acknowledged(ui, rect)+ {app.tree.reveal_feature = None;}+ if history && app.tree.timeline_reveal == Some(id) && crate::semantic_content::scroll_acknowledged(ui, rect) {+ app.tree.timeline_reveal = None;+ }}if r.double {if !path.is_empty() {@@ -335,8 +359,9 @@ fn feature_row(if let Some(drag) = drag&& !r.on_control&& r.resp.as_ref().is_some_and(egui::Response::drag_started)+ && let Some(source) = crate::semantic_content::current_source(app){- *drag = Some(crate::timeline_left::drag_features(app, id, selected));+ *drag = Some(FeatureDrag { source, features: crate::timeline_left::drag_features(app, id, selected) });}r.fold}@@ -345,6 +370,7 @@ fn feature_row(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());+ crate::semantic_content::record_capture(ui, &response);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());@@ -366,7 +392,11 @@ fn drag_marker(app: &mut SolveApp, ui: &egui::Ui, resp: &egui::Response, slots: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 {+ if resp.drag_stopped()+ && position != marker+ && crate::semantic_content::current_source(app).is_some_and(|source| crate::semantic_content::source_present(app, source))+ && crate::semantic_content::claim_action(ui, resp.id)+ {let n = app.session.doc.features.len();let _ = app.run_heavy("timeline.roll_to", if position >= n { json!({}) } else { json!({ "position": position }) });}@@ -374,11 +404,23 @@ fn drag_marker(app: &mut SolveApp, ui: &egui::Ui, resp: &egui::Response, slots:/// Dragging feature rows shows where they land with the History's drop bar; letting go moves them/// with the History's own move, before or behind the marker by the side of it they land on.-fn drag_rows(app: &mut SolveApp, ui: &egui::Ui, plan: &HistoryRows, drag_id: egui::Id, dragged: Option<Vec<u64>>, drops: &[DropSlot], marker_y: f32) {- let Some(features) = dragged else { return };+fn drag_rows(+ app: &mut SolveApp,+ ui: &egui::Ui,+ plan: &HistoryRows,+ drag_id: egui::Id,+ dragged: Option<FeatureDrag>,+ drops: &[DropSlot],+ marker_y: f32,+) {+ let Some(drag) = dragged else { return };+ if !crate::semantic_content::source_present(app, drag.source) {+ app.tree.content.current_mut().feature_drags.remove(&drag_id);+ return;+ }let (released, down) = ui.input(|i| (i.pointer.any_released(), i.pointer.any_down()));if released || !down {- ui.data_mut(|d| d.remove::<Vec<u64>>(drag_id));+ app.tree.content.current_mut().feature_drags.remove(&drag_id);}if !released && !down {return;@@ -394,7 +436,7 @@ fn drag_rows(app: &mut SolveApp, ui: &egui::Ui, plan: &HistoryRows, drag_id: egu.and_then(|p| drops.iter().min_by(|a, b| (a.y - p.y).abs().total_cmp(&(b.y - p.y).abs())).copied());if released {if let Some(drop) = slot {- crate::timeline_left::drop_items(app, plan, &features, &[], drop.group, drop.position, drop.y < marker_y);+ crate::timeline_left::drop_items(app, plan, &drag.features, &[], drop.group, drop.position, drop.y < marker_y);}return;}@@ -407,7 +449,7 @@ fn drag_rows(app: &mut SolveApp, ui: &egui::Ui, plan: &HistoryRows, drag_id: eguTokens::get().sketch_accent,);}- ui.data_mut(|d| d.insert_temp(drag_id, features));+ app.tree.content.current_mut().feature_drags.insert(drag_id, drag);}#[cfg(test)]@@ -423,9 +465,20 @@ mod tests {_ => None,};h.app.tree.expanded.insert("c0/features".into());- DRAWN.with(|d| d.borrow_mut().clear());let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() };- h.ctx.run_ui(raw, |ui| rows(&mut h.app, ui, 0, &[], 0, &mut Actions::default())).textures_delta.clear();+ h.ctx+ .run_ui(raw, |ui| {+ use crate::semantic_content::{self, ContentOwner, ContentRequest};+ semantic_content::begin(&mut h.app, ui.ctx());+ semantic_content::render_scope(&mut h.app, ui, ContentOwner::BROWSER, ContentRequest::Browser { shrink_height: false }, |app, ui| {+ let mut actions = Actions::default();+ rows(app, ui, 0, &[], 0, &mut actions);+ actions+ });+ semantic_content::finalize(&mut h.app, ui.ctx());+ })+ .textures_delta+ .clear();drawn_rows().into_iter().map(|(label, ..)| label).collect()}diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rsindex 924a2792f8..ae5df4d437 100644--- a/crates/ui-egui/src/browser_card_tests.rs+++ b/crates/ui-egui/src/browser_card_tests.rs@@ -1,5 +1,6 @@use super::*;use crate::scenario::{Harness, handle_at, rect_of};+use crate::semantic_content::{self, ContentOwner, ContentRequest};use crate::shell::{LayoutMode, SHELL_GAP};#[test]@@ -1051,3 +1052,1151 @@ fn hiding_or_showing_body_or_sketch_updates_row_dimming() {h.settle();assert!(!body_hidden(&h, "One"));}++/// Draw content without either panel host. Changing submission order does not change IDs,+/// screen placement or the input stream, so these exercise the adapters' shared boundary.+fn semantic_frame(h: &mut Harness, owners: &[ContentOwner], events: Vec<egui::Event>, modifiers: egui::Modifiers) {+ semantic_frame_switch(h, owners, events, modifiers, None);+}++fn semantic_frame_switch(h: &mut Harness, owners: &[ContentOwner], events: Vec<egui::Event>, modifiers: egui::Modifiers, tab: Option<usize>) {+ semantic_frame_transitions(h, owners, events, modifiers, tab, None);+}++fn semantic_frame_transitions(+ h: &mut Harness,+ owners: &[ContentOwner],+ events: Vec<egui::Event>,+ modifiers: egui::Modifiers,+ tab: Option<usize>,+ after_content: Option<usize>,+) {+ let raw = egui::RawInput {+ screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(900.0, 900.0))),+ focused: true,+ events: std::iter::once(egui::Event::ModifiersChanged(modifiers)).chain(events).collect(),+ ..Default::default()+ };+ h.ctx+ .run_ui(raw, |ui| {+ crate::scenario::clear_handles();+ publish_row_prefs(&h.app, ui.ctx());+ eye_drag_frame(&mut h.app, ui.ctx());+ semantic_content::begin(&mut h.app, ui.ctx());+ if let Some(tab) = tab {+ crate::documents::switch(&mut h.app, tab);+ }+ for &owner in owners {+ let x = if owner == ContentOwner::BROWSER { 10.0 } else { 450.0 };+ let mut content = ui.new_child(+ egui::UiBuilder::new().id_salt(("semantic-test", owner)).max_rect(Rect::from_min_size(pos2(x, 10.0), vec2(400.0, 850.0))),+ );+ let request = if owner == ContentOwner::HISTORY {+ ContentRequest::ActiveBodiesOrigin+ } else {+ ContentRequest::Browser { shrink_height: false }+ };+ semantic_content::show(&mut h.app, &mut content, owner, request);+ }+ if let Some(tab) = after_content {+ crate::documents::switch(&mut h.app, tab);+ }+ semantic_content::finalize(&mut h.app, ui.ctx());+ // App paths may converge after an early return; finalization must be idempotent.+ semantic_content::finalize(&mut h.app, ui.ctx());+ if ui.ctx().data_mut(|data| data.remove_temp::<bool>(egui::Id::new("semantic-test-discard"))).unwrap_or(false) {+ ui.ctx().request_discard("repeat semantic layout after input");+ }+ })+ .textures_delta+ .clear();+}++fn semantic_at(owner: ContentOwner, label: &str) -> Pos2 {+ semantic_content::output(owner).rows.into_iter().find(|(name, ..)| name == label).unwrap().1.center()+}++fn semantic_control(owner: ContentOwner, handle: &str) -> Pos2 {+ let rows = semantic_content::output(owner).rows;+ crate::scenario::handles(handle)+ .into_iter()+ .find(|(name, point)| name == handle && rows.iter().any(|(_, rect, ..)| rect.contains(*point)))+ .unwrap()+ .1+}++fn semantic_button(at: Pos2, button: egui::PointerButton, pressed: bool, modifiers: egui::Modifiers) -> egui::Event {+ egui::Event::PointerButton { pos: at, button, pressed, modifiers }+}++fn semantic_click(h: &mut Harness, owners: &[ContentOwner], at: Pos2, modifiers: egui::Modifiers) {+ semantic_frame(h, owners, vec![egui::Event::PointerMoved(at)], modifiers);+ semantic_frame(h, owners, vec![semantic_button(at, egui::PointerButton::Primary, true, modifiers)], modifiers);+ semantic_frame(h, owners, vec![semantic_button(at, egui::PointerButton::Primary, false, modifiers)], modifiers);+}++#[test]+fn history_bodies_and_origin_work_with_browser_hidden() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.ui.show_browser = false;+ h.app.preferences.timeline_left = true;+ h.app.preferences.timeline_left_width = 260.0;+ h.app.preferences.timeline_origin_bodies = true;+ h.app.tree.expanded.insert("origin".into());+ h.frames(4);+ assert!(drawn_rows().is_empty() && drawn_occurrences().is_empty());+ let body = semantic_at(ContentOwner::HISTORY, "One");+ h.step(&json!({"move":[body.x, body.y]})).unwrap();+ assert_eq!(h.app.viewport.hover_bodies, ["One"]);+ h.step(&json!({"click":[body.x, body.y]})).unwrap();+ assert_eq!(h.app.session.selection, [Sel::Body { name: "One".into() }]);+ let eye = semantic_control(ContentOwner::HISTORY, "eye:One");+ let undo = h.app.session.undo.len();+ h.step(&json!({"click":[eye.x, eye.y]})).unwrap();+ assert!(body_hidden(&h, "One"));+ assert_eq!(h.app.session.undo.len(), undo + 1);+ let plane = semantic_at(ContentOwner::HISTORY, "XY");+ h.step(&json!({"move":[plane.x, plane.y]})).unwrap();+ assert_eq!(h.app.viewport.hover_plane.as_deref(), Some("XY"));+ h.step(&json!({"click":[plane.x, plane.y]})).unwrap();+ assert_eq!(h.app.session.selection, [Sel::Plane { name: "XY".into() }]);+ h.step(&json!({"click":[plane.x, plane.y],"button":"right"})).unwrap();+ assert_eq!(h.app.menu.target, Target::OriginPlane { name: "XY".into() });+ crate::context_menu::close(&mut h.app);+ h.frames(2);+ let body = semantic_at(ContentOwner::HISTORY, "Two");+ h.step(&json!({"click":[body.x, body.y],"button":"right"})).unwrap();+ assert_eq!(h.app.menu.target, Target::Body { name: "Two".into() });+ crate::context_menu::close(&mut h.app);+ h.app.run("select.clear", json!({})).unwrap();+ h.app.start("solid.combine");+ h.frames(2);+ for name in ["One", "Two"] {+ let body = semantic_at(ContentOwner::HISTORY, name);+ h.step(&json!({"click":[body.x, body.y]})).unwrap();+ }+ let dialog = h.app.dialog.as_ref().unwrap();+ assert_eq!(dialog.inputs[0].items, [Sel::Body { name: "One".into() }]);+ assert_eq!(dialog.inputs[1].items, [Sel::Body { name: "Two".into() }]);+ assert!(h.app.session.selection.is_empty(), "tool picks do not leak into document selection");+}++#[test]+fn semantic_owner_submission_order_preserves_hover_selection_picks_and_single_visibility_command() {+ for owners in [[ContentOwner::BROWSER, ContentOwner::HISTORY], [ContentOwner::HISTORY, ContentOwner::BROWSER]] {+ for owner in [ContentOwner::BROWSER, ContentOwner::HISTORY] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let body = semantic_at(owner, "One");+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(body)], egui::Modifiers::NONE);+ assert_eq!(h.app.viewport.hover_bodies, ["One"], "{owners:?}, {owner:?}");+ let ctrl = egui::Modifiers { ctrl: true, ..Default::default() };+ semantic_click(&mut h, &owners, body, ctrl);+ assert_eq!(h.app.session.selection, [Sel::Body { name: "One".into() }], "Ctrl must toggle exactly once");+ let eye = semantic_control(owner, "eye:Two");+ let undo = h.app.session.undo.len();+ semantic_click(&mut h, &owners, eye, egui::Modifiers::NONE);+ assert_eq!(h.app.session.undo.len(), undo + 1, "visibility command runs once");+ assert!(body_hidden(&h, "Two"));+ h.app.run("select.clear", json!({})).unwrap();+ h.app.start("solid.combine");+ for name in ["One", "Three"] {+ let body = semantic_at(owner, name);+ semantic_click(&mut h, &owners, body, egui::Modifiers::NONE);+ }+ let dialog = h.app.dialog.as_ref().unwrap();+ assert_eq!(dialog.inputs[0].items, [Sel::Body { name: "One".into() }]);+ assert_eq!(dialog.inputs[1].items, [Sel::Body { name: "Three".into() }]);+ assert!(h.app.session.selection.is_empty());+ }+ }+}++#[test]+fn absent_semantic_owners_expire_geometry_and_hover_without_losing_selection_or_folds() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.tree.expanded.insert("origin".into());+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let body = semantic_at(ContentOwner::HISTORY, "One");+ semantic_click(&mut h, &owners, body, egui::Modifiers::NONE);+ assert_eq!(h.app.viewport.hover_bodies, ["One"]);+ let selected = h.app.session.selection.clone();+ let folds = (h.app.tree.collapsed.clone(), h.app.tree.expanded.clone());+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert!(h.app.viewport.hover_bodies.is_empty() && h.app.viewport.hover_plane.is_none());+ for owner in owners {+ let output = semantic_content::output(owner);+ assert!(output.rows.is_empty() && output.occurrences.is_empty());+ }+ assert_eq!(h.app.session.selection, selected);+ assert_eq!((h.app.tree.collapsed.clone(), h.app.tree.expanded.clone()), folds);+ // Unrelated viewport contributors must survive frames with no semantic presentations.+ h.app.viewport.hover_bodies = vec!["external contributor".into()];+ h.app.viewport.hover_plane = Some("external plane".into());+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert_eq!(h.app.viewport.hover_bodies, ["external contributor"]);+ assert_eq!(h.app.viewport.hover_plane.as_deref(), Some("external plane"));+ // Egui hit-tests the previous pass: register the reappearing rows before moving to one.+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ let body = semantic_at(ContentOwner::HISTORY, "One");+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(body)], egui::Modifiers::NONE);+ assert!(+ h.app.viewport.hover_bodies.contains(&"external contributor".into()) && h.app.viewport.hover_bodies.contains(&"One".into()),+ "hover contributors: {:?}",+ h.app.viewport.hover_bodies+ );+ let plane = semantic_at(ContentOwner::HISTORY, "XY");+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(plane)], egui::Modifiers::NONE);+ assert_eq!(h.app.viewport.hover_plane.as_deref(), Some("XY"));+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert_eq!(h.app.viewport.hover_bodies, ["external contributor"]);+ assert_eq!(h.app.viewport.hover_plane.as_deref(), Some("external plane"));+}++#[test]+fn semantic_shift_and_ctrl_ranges_use_each_owners_anchor_and_complete_previous_order() {+ for owners in [[ContentOwner::BROWSER, ContentOwner::HISTORY], [ContentOwner::HISTORY, ContentOwner::BROWSER]] {+ for (owner, other) in [(ContentOwner::BROWSER, ContentOwner::HISTORY), (ContentOwner::HISTORY, ContentOwner::BROWSER)] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let first = semantic_at(owner, "One");+ semantic_click(&mut h, &owners, first, egui::Modifiers::NONE);+ let unrelated = semantic_at(other, "Three");+ semantic_click(&mut h, &owners, unrelated, egui::Modifiers::NONE);+ let middle = semantic_at(owner, "Two");+ semantic_click(&mut h, &owners, middle, egui::Modifiers { shift: true, ..Default::default() });+ assert_eq!(h.app.session.selection, [Sel::Body { name: "One".into() }, Sel::Body { name: "Two".into() }]);+ // Start below the target, so the current order is incomplete at the Shift click.+ let last = semantic_at(owner, "Three");+ semantic_click(&mut h, &owners, last, egui::Modifiers::NONE);+ let first = semantic_at(owner, "One");+ semantic_click(&mut h, &owners, first, egui::Modifiers { shift: true, ctrl: true, ..Default::default() });+ let names: BTreeSet<_> = h.app.session.selection.iter().filter_map(|selection| picked_body(selection).map(str::to_owned)).collect();+ assert_eq!(names, BTreeSet::from(["One".into(), "Two".into(), "Three".into()]));+ }+ }+}++#[test]+fn browser_body_reveal_survives_history_only_and_unrelated_presentations() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ reveal_body(&mut h.app, "Three");+ for owners in [&[ContentOwner::HISTORY][..], &[][..], &[ContentOwner::HISTORY][..]] {+ semantic_frame(&mut h, owners, Vec::new(), egui::Modifiers::NONE);+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Three"));+ }+ h.app.ui.show_browser = true;+ h.app.ui.show_timeline = false;+ h.app.preferences.browser_collapsed = true;+ h.frames(3);+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Three"), "collapsed Browser does not acknowledge a row");+ h.app.preferences.browser_collapsed = false;+ for _ in 0..4 {+ semantic_frame(&mut h, &[ContentOwner::HISTORY, ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ }+ assert!(h.app.tree.reveal.is_none());+ assert!(drawn_rows().iter().any(|(label, ..)| label == "Three"));+}++#[test]+fn history_reveal_survives_hidden_and_nonmatching_content_in_all_existing_compositions() {+ for (left, combined) in [(false, false), (true, false), (false, true)] {+ let mut h = Harness::new();+ h.app.home.open = false;+ let feature = h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"name":"Target","body_name":"Body"})).unwrap()["feature"]+ .as_u64()+ .unwrap();+ h.app.preferences.timeline_left = left;+ h.app.preferences.history_in_browser = combined;+ h.app.ui.show_timeline = false;+ h.app.ui.show_browser = false;+ h.app.tree.timeline_reveal = Some(feature);+ h.frames(3);+ assert_eq!(h.app.tree.timeline_reveal, Some(feature));+ semantic_frame(&mut h, &[ContentOwner::HISTORY], Vec::new(), egui::Modifiers::NONE);+ assert_eq!(h.app.tree.timeline_reveal, Some(feature), "Bodies/Origin is not a feature presentation");+ if combined {+ h.app.ui.show_browser = true;+ h.app.preferences.browser_collapsed = false;+ h.app.tree.collapsed.insert("c0/history".into());+ h.frames(3);+ assert_eq!(h.app.tree.timeline_reveal, Some(feature), "a folded combined History retains the request");+ h.app.tree.collapsed.remove("c0/history");+ } else {+ h.app.ui.show_timeline = true;+ }+ h.frames(8);+ assert!(h.app.tree.timeline_reveal.is_none(), "left={left}, combined={combined}");+ }+}++#[test]+fn native_feature_reveal_waits_for_its_intended_browser_composition() {+ let mut h = Harness::new();+ h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Body"})).unwrap();+ let id = h.app.session.doc.features[0].id;+ reveal_feature(&mut h.app, id, "Body");+ h.app.preferences.history_in_browser = true;+ h.frames(3);+ assert!(h.app.tree.reveal_feature.is_some(), "combined History does not consume a native Features request");+ h.app.preferences.history_in_browser = false;+ h.frames(4);+ assert!(h.app.tree.reveal_feature.is_none());+}++#[test]+fn eye_capture_disappearance_finishes_one_undo_group_and_does_not_transfer_to_another_owner() {+ for owner in [ContentOwner::BROWSER, ContentOwner::HISTORY] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let first = semantic_control(owner, "eye:One");+ let undo = h.app.session.undo.len();+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(first)], egui::Modifiers::NONE);+ semantic_frame(+ &mut h,+ &owners,+ vec![semantic_button(first, egui::PointerButton::Primary, true, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ let middle = semantic_control(owner, "eye:Two");+ for at in [first + vec2(0.0, 7.0), middle] {+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(at)], egui::Modifiers::NONE);+ }+ assert!(h.ctx.data(|data| data.get_temp::<bool>(crate::ui_kit::eye_drag_id())).is_some());+ assert!(body_hidden(&h, "One") && body_hidden(&h, "Two") && !body_hidden(&h, "Three"));+ let other = if owner == ContentOwner::BROWSER { ContentOwner::HISTORY } else { ContentOwner::BROWSER };+ let other_eye = semantic_control(other, "eye:Three");+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert!(h.ctx.data(|data| data.get_temp::<bool>(crate::ui_kit::eye_drag_id())).is_none());+ assert!(h.app.tree.eye_press.is_none());+ assert_eq!(h.app.session.undo.len(), undo + 1, "disappearance closes the existing drag group");+ semantic_frame(&mut h, &[other], vec![egui::Event::PointerMoved(other_eye)], egui::Modifiers::NONE);+ assert!(!body_hidden(&h, "Three"), "the vanished owner's eye target cannot transfer to another presentation");+ semantic_frame(+ &mut h,+ &owners,+ vec![semantic_button(other_eye, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ h.app.run("edit.undo", json!({})).unwrap();+ assert!(!body_hidden(&h, "One") && !body_hidden(&h, "Two") && !body_hidden(&h, "Three"));+ }+}++#[test]+fn shared_body_origin_rows_keep_their_geometry_labels_and_composition() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.tree.expanded.insert("origin".into());+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let browser = semantic_content::output(ContentOwner::BROWSER);+ let history = semantic_content::output(ContentOwner::HISTORY);+ let labels: Vec<_> = history.rows.iter().map(|(label, ..)| label.as_str()).collect();+ assert_eq!(labels, ["Bodies", "One", "Two", "Three", "Origin", "O", "X", "Y", "Z", "XY", "XZ", "YZ"]);+ for (label, rect, fold, open) in history.rows {+ let (_, browser_rect, browser_fold, browser_open) = browser.rows.iter().find(|(name, ..)| *name == label).unwrap();+ assert_eq!(rect.height(), browser_rect.height(), "{label}: existing shared row height");+ assert_eq!(fold.is_some(), browser_fold.is_some(), "{label}: existing disclosure composition");+ assert_eq!(open, *browser_open, "{label}: canonical fold state");+ }+ assert_eq!(drawn_rows(), browser.rows, "legacy automation remains Browser-only");+}++#[test]+fn semantic_drop_runs_once_in_either_owner_submission_order() {+ for owners in [[ContentOwner::BROWSER, ContentOwner::HISTORY], [ContentOwner::HISTORY, ContentOwner::BROWSER]] {+ for owner in [ContentOwner::BROWSER, ContentOwner::HISTORY] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let group = h.app.run("browser.group", json!({"component":0,"folder":"bodies","name":"Destination"})).unwrap()["group"].as_u64().unwrap();+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(owner, "One");+ let to = semantic_at(owner, "Destination (0)");+ let undo = h.app.session.undo.len();+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(from)], egui::Modifiers::NONE);+ semantic_frame(+ &mut h,+ &owners,+ vec![semantic_button(from, egui::PointerButton::Primary, true, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ for at in [from + vec2(8.0, 0.0), to] {+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(at)], egui::Modifiers::NONE);+ }+ semantic_frame(+ &mut h,+ &owners,+ vec![semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ assert!(h.app.session.doc.browser_group(group).unwrap().has_item("One"));+ assert_eq!(h.app.session.undo.len(), undo + 1, "{owners:?}, {owner:?}: exactly one drop command");+ h.app.run("edit.undo", json!({})).unwrap();+ assert!(!h.app.session.doc.browser_group(group).unwrap().has_item("One"));+ }+ }+}++#[test]+fn disappearing_semantic_drag_owner_releases_only_its_payload_and_widget_capture() {+ for owner in [ContentOwner::BROWSER, ContentOwner::HISTORY] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ for _ in 0..3 {+ semantic_frame(&mut h, &[owner], Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(owner, "One");+ semantic_frame(&mut h, &[owner], vec![egui::Event::PointerMoved(from)], egui::Modifiers::NONE);+ semantic_frame(+ &mut h,+ &[owner],+ vec![semantic_button(from, egui::PointerButton::Primary, true, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ semantic_frame(&mut h, &[owner], vec![egui::Event::PointerMoved(from + vec2(10.0, 0.0))], egui::Modifiers::NONE);+ assert!(egui::DragAndDrop::has_payload_of_type::<Drag>(&h.ctx));+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert!(!egui::DragAndDrop::has_any_payload(&h.ctx));+ assert!(h.ctx.dragged_id().is_none());+ assert!(semantic_content::output(owner).rows.is_empty());+ }+}++#[test]+fn pending_semantic_reveals_expire_when_their_targets_are_removed() {+ let mut h = Harness::new();+ h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Body"})).unwrap();+ let feature = h.app.session.doc.features[0].id;+ let other = h+ .app+ .run("solid.box", json!({"length":10,"width":10,"height":10,"corner":[20,0,0],"operation":"new_body","body_name":"Other"}))+ .unwrap()["feature"]+ .as_u64()+ .unwrap();+ h.app.run("timeline.suppress", json!({"feature":other})).unwrap();+ reveal_body(&mut h.app, "Body");+ reveal_feature(&mut h.app, feature, "Body");+ h.app.tree.reveal = Some("Body".into());+ h.app.tree.timeline_reveal = Some(feature);+ h.app.run("selection.delete", json!({"items":[Sel::Feature { id: feature }]})).unwrap();+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert!(h.app.tree.reveal.is_none() && h.app.tree.reveal_feature.is_none() && h.app.tree.timeline_reveal.is_none());+}++#[test]+fn semantic_row_commands_are_consumed_once_across_layout_repeats() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let at = semantic_control(ContentOwner::HISTORY, "eye:One");+ let undo = h.app.session.undo.len();+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(at)], egui::Modifiers::NONE);+ semantic_frame(&mut h, &owners, vec![semantic_button(at, egui::PointerButton::Primary, true, egui::Modifiers::NONE)], egui::Modifiers::NONE);+ h.ctx.data_mut(|data| data.insert_temp(egui::Id::new("semantic-test-discard"), true));+ semantic_frame(&mut h, &owners, vec![semantic_button(at, egui::PointerButton::Primary, false, egui::Modifiers::NONE)], egui::Modifiers::NONE);+ assert!(body_hidden(&h, "One"), "a repeated layout cannot toggle the eye back on");+ assert_eq!(h.app.session.undo.len(), undo + 1);+}++#[test]+fn invisible_browser_content_keeps_its_reveal_and_publishes_no_geometry() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ reveal_body(&mut h.app, "Three");+ let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(900.0, 900.0))), ..Default::default() };+ h.ctx+ .run_ui(raw, |ui| {+ semantic_content::begin(&mut h.app, ui.ctx());+ ui.set_opacity(0.0);+ semantic_content::show(&mut h.app, ui, ContentOwner::BROWSER, ContentRequest::Browser { shrink_height: false });+ semantic_content::finalize(&mut h.app, ui.ctx());+ })+ .textures_delta+ .clear();+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Three"));+ assert!(drawn_rows().is_empty() && drawn_occurrences().is_empty());+}++#[test]+fn combined_history_reveal_opens_and_acknowledges_the_features_placement() {+ let (mut h, _, occurrence) = crate::test_support::component_box();+ let feature = h.app.session.model.state().body("Body1").unwrap().feature;+ h.app.preferences.history_in_browser = true;+ h.app.tree.close_row(&occurrence_key(&[occurrence]));+ reveal_in_history(&mut h.app, feature);+ h.app.tree.timeline_reveal = Some(feature);+ h.frames(6);+ assert!(is_open(&h.app, &occurrence_key(&[occurrence]), true));+ assert!(h.app.tree.reveal_feature.is_none() && h.app.tree.timeline_reveal.is_none());+ let name = &h.app.session.doc.feature(feature).unwrap().name;+ assert!(drawn_rows().iter().any(|(label, ..)| label == name));+}++#[test]+fn browser_editors_have_one_app_owned_host_when_both_presentations_are_hidden() {+ let (mut h, _, occurrence) = crate::test_support::component_box();+ h.app.ui.show_browser = false;+ h.app.ui.show_timeline = false;+ h.app.tree.occurrence_move = Some(OccMove::new(occurrence));+ h.frames(4);+ assert!(drawn_rows().is_empty());+ let fields = crate::scenario::handles("occurrence-move:distance:0");+ assert_eq!(+ fields.iter().filter(|(name, _)| name == "occurrence-move:distance:0").count(),+ 1,+ "the editor is hosted once despite both panels being hidden"+ );+ assert!(h.app.tree.occurrence_move.as_ref().unwrap().baseline.is_some());+}++#[test]+fn body_reveal_waits_through_rollback_until_its_creator_is_presented_again() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ reveal_body(&mut h.app, "Three");+ h.app.run("timeline.roll_to", json!({"position":1})).unwrap();+ for _ in 0..3 {+ semantic_frame(&mut h, &[ContentOwner::HISTORY, ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Three"), "rollback is not removal");+ }+ h.app.run("timeline.roll_to", json!({})).unwrap();+ for _ in 0..4 {+ semantic_frame(&mut h, &[ContentOwner::HISTORY, ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ }+ assert!(h.app.tree.reveal.is_none());+}++/// Make an actual second document tab with identical semantic names and IDs. Return to A;+/// tests can switch during an input frame without rebuilding or rendering B first.+fn matching_semantic_tab(h: &mut Harness) -> (usize, String, usize) {+ let original = h.app.docs.active;+ let incoming = solidcraft_engine::Session::new((*h.app.session.doc).clone());+ let original_session = h.app.session.uid;+ crate::documents::open_tab(&mut h.app, incoming).unwrap();+ assert_ne!(h.app.session.uid, original_session);+ let tab = h.app.docs.active;+ let document = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ crate::documents::switch(&mut h.app, original);+ (tab, document, undo)+}++fn semantic_drag_start(h: &mut Harness, owners: &[ContentOwner], from: Pos2) {+ semantic_frame(h, owners, vec![egui::Event::PointerMoved(from)], egui::Modifiers::NONE);+ semantic_frame(h, owners, vec![semantic_button(from, egui::PointerButton::Primary, true, egui::Modifiers::NONE)], egui::Modifiers::NONE);+ semantic_frame(h, owners, vec![egui::Event::PointerMoved(from + vec2(10.0, 0.0))], egui::Modifiers::NONE);+}++fn semantic_occurrence_at(owner: ContentOwner, occurrence: u64) -> Pos2 {+ semantic_content::output(owner).occurrences.into_iter().find(|(path, ..)| path.last() == Some(&occurrence)).unwrap().2.center()+}++#[test]+fn switching_documents_cancels_body_payloads_before_matching_incoming_groups_can_drop() {+ for after_begin in [false, true] {+ for owner in [ContentOwner::BROWSER, ContentOwner::HISTORY] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.run("browser.group", json!({"component":0,"folder":"bodies","name":"Destination"})).unwrap();+ let (tab, document, undo) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(owner, "One");+ let to = semantic_at(owner, "Destination (0)");+ semantic_drag_start(&mut h, &owners, from);+ let outgoing = h.app.session.uid;+ let payload = egui::DragAndDrop::payload::<Drag>(&h.ctx).unwrap();+ assert_eq!(payload.source.session, outgoing);+ let stale_payload = (*payload).clone();+ if !after_begin {+ crate::documents::switch(&mut h.app, tab);+ }+ semantic_frame_switch(+ &mut h,+ &owners,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ after_begin.then_some(tab),+ );+ assert_ne!(h.app.session.uid, outgoing);+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ assert!(!egui::DragAndDrop::has_payload_of_type::<Drag>(&h.ctx));+ assert!(h.ctx.dragged_id().is_none());+ // Even a delayed payload reintroduced after cancellation must fail provenance+ // validation; matching body/group names cannot make it belong to the new tab.+ egui::DragAndDrop::set_payload(&h.ctx, stale_payload);+ semantic_frame(+ &mut h,+ &owners,+ vec![semantic_button(to, egui::PointerButton::Primary, true, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ semantic_frame(+ &mut h,+ &owners,+ vec![semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ }+ }+}++#[test]+fn switching_documents_cancels_occurrence_payloads_with_matching_component_and_path_ids() {+ for after_begin in [false, true] {+ let (mut h, _, occurrence) = crate::test_support::component_box();+ let destination = h.app.run("component.create", json!({"name":"Destination"})).unwrap()["occurrence"].as_u64().unwrap();+ h.app.run("component.activate", json!({"component":0})).unwrap();+ let (tab, document, undo) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_occurrence_at(ContentOwner::BROWSER, occurrence);+ let to = semantic_occurrence_at(ContentOwner::BROWSER, destination);+ semantic_drag_start(&mut h, &owners, from);+ assert!(egui::DragAndDrop::has_payload_of_type::<OccurrenceDrag>(&h.ctx));+ if !after_begin {+ crate::documents::switch(&mut h.app, tab);+ }+ semantic_frame_switch(+ &mut h,+ &owners,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ after_begin.then_some(tab),+ );+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ assert!(!egui::DragAndDrop::has_payload_of_type::<OccurrenceDrag>(&h.ctx));+ assert!(h.ctx.dragged_id().is_none());+ }+}++#[test]+fn switching_documents_clears_combined_history_drag_even_when_feature_ids_match() {+ for after_begin in [false, true] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.preferences.history_in_browser = true;+ let source = h.app.session.doc.features[2].id;+ let target = h.app.session.doc.features[0].id;+ let (tab, document, undo) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_control(ContentOwner::BROWSER, &format!("row:browser-feature:c0:{source}"));+ let to = semantic_control(ContentOwner::BROWSER, &format!("row:browser-feature:c0:{target}"));+ semantic_drag_start(&mut h, &owners, from);+ assert!(!h.app.tree.content.owner(ContentOwner::BROWSER).unwrap().feature_drags.is_empty());+ if !after_begin {+ crate::documents::switch(&mut h.app, tab);+ }+ semantic_frame_switch(+ &mut h,+ &owners,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ after_begin.then_some(tab),+ );+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ assert!(h.app.tree.content.owner(ContentOwner::BROWSER).unwrap().feature_drags.is_empty());+ assert!(h.ctx.dragged_id().is_none());+ }+}++#[test]+fn document_switch_drops_shift_anchors_without_changing_the_incoming_document_or_undo() {+ for owner in [ContentOwner::BROWSER, ContentOwner::HISTORY] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let (tab, document, undo) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let at = semantic_at(owner, "One");+ semantic_click(&mut h, &owners, at, egui::Modifiers::NONE);+ assert!(h.app.tree.content.owner(owner).unwrap().anchor.is_some());+ semantic_frame_switch(&mut h, &owners, Vec::new(), egui::Modifiers::NONE, Some(tab));+ assert!(h.app.tree.content.owner(owner).unwrap().anchor.is_none());+ let at = semantic_at(owner, "Two");+ semantic_click(&mut h, &owners, at, egui::Modifiers { shift: true, ..Default::default() });+ assert_eq!(h.app.session.selection, [Sel::Body { name: "Two".into() }], "A's One anchor cannot extend B's selection");+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ }+}++#[test]+fn switching_documents_finishes_eye_undo_group_in_the_outgoing_session_only() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let original = h.app.docs.active;+ let (tab, document, undo_b) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let undo_a = h.app.session.undo.len();+ let one = semantic_control(ContentOwner::BROWSER, "eye:One");+ let two = semantic_control(ContentOwner::BROWSER, "eye:Two");+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(one)], egui::Modifiers::NONE);+ semantic_frame(&mut h, &owners, vec![semantic_button(one, egui::PointerButton::Primary, true, egui::Modifiers::NONE)], egui::Modifiers::NONE);+ for point in [one + vec2(0.0, 7.0), two] {+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(point)], egui::Modifiers::NONE);+ }+ assert!(body_hidden(&h, "One") && body_hidden(&h, "Two"));+ semantic_frame_switch(&mut h, &owners, Vec::new(), egui::Modifiers::NONE, Some(tab));+ let three = semantic_control(ContentOwner::BROWSER, "eye:Three");+ semantic_frame(&mut h, &owners, vec![egui::Event::PointerMoved(three)], egui::Modifiers::NONE);+ semantic_frame(&mut h, &owners, vec![semantic_button(three, egui::PointerButton::Primary, false, egui::Modifiers::NONE)], egui::Modifiers::NONE);+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo_b);+ assert!(!body_hidden(&h, "One") && !body_hidden(&h, "Two") && !body_hidden(&h, "Three"));+ crate::documents::switch(&mut h.app, original);+ assert_eq!(h.app.session.undo.len(), undo_a + 1, "only the outgoing session receives the merged drag undo group");+ h.app.run("edit.undo", json!({})).unwrap();+ assert!(!body_hidden(&h, "One") && !body_hidden(&h, "Two"));+}++#[test]+fn switching_semantic_documents_preserves_unrelated_payload_and_capture() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let (tab, _, _) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(ContentOwner::BROWSER, "One");+ semantic_drag_start(&mut h, &owners, from);+ let external = egui::Id::new("external capture");+ egui::DragAndDrop::set_payload(&h.ctx, "external payload".to_string());+ h.ctx.set_dragged_id(external);+ crate::documents::switch(&mut h.app, tab);+ assert_eq!(egui::DragAndDrop::payload::<String>(&h.ctx).as_deref().map(String::as_str), Some("external payload"));+ assert_eq!(h.ctx.dragged_id(), Some(external));+}++#[test]+fn hidden_body_or_group_drag_source_cannot_drop_through_a_surviving_history_target() {+ for group_source in [false, true] {+ for keep_source in [false, true] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ if group_source {+ h.app.run("browser.group", json!({"component":0,"folder":"bodies","name":"Source","items":["One"]})).unwrap();+ }+ let destination =+ h.app.run("browser.group", json!({"component":0,"folder":"bodies","name":"Destination"})).unwrap()["group"].as_u64().unwrap();+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(ContentOwner::BROWSER, if group_source { "Source (1)" } else { "One" });+ let to = semantic_at(ContentOwner::HISTORY, "Destination (0)");+ let document = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ semantic_drag_start(&mut h, &owners, from);+ assert!(egui::DragAndDrop::has_payload_of_type::<Drag>(&h.ctx));+ let presented = if keep_source { &owners[..] } else { &[ContentOwner::HISTORY][..] };+ semantic_frame(+ &mut h,+ presented,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ if keep_source {+ assert_ne!(h.app.session.doc.to_json(), document, "cross-owner drops remain valid while both owners are presented");+ assert_eq!(h.app.session.undo.len(), undo + 1);+ if !group_source {+ assert!(h.app.session.doc.browser_group(destination).unwrap().has_item("One"));+ }+ } else {+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ }+ assert!(!egui::DragAndDrop::has_payload_of_type::<Drag>(&h.ctx));+ assert!(h.ctx.dragged_id().is_none());+ }+ }+}++#[test]+fn hidden_occurrence_source_cannot_reparent_or_reorder_through_a_surviving_adapter() {+ for reorder in [false, true] {+ for keep_source in [false, true] {+ let (mut h, _, occurrence) = crate::test_support::component_box();+ let destination = h.app.run("component.create", json!({"name":"Destination"})).unwrap()["occurrence"].as_u64().unwrap();+ h.app.run("component.activate", json!({"component":0})).unwrap();+ let adapter = ContentOwner(2);+ let owners = [ContentOwner::BROWSER, adapter];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ // Move the later placement before the earlier one for a real reorder change.+ let (source, target) = if reorder { (destination, occurrence) } else { (occurrence, destination) };+ let from = semantic_occurrence_at(ContentOwner::BROWSER, source);+ let mut to = semantic_occurrence_at(adapter, target);+ if reorder {+ to.y -= crate::ui_kit::TREE_ROW_HEIGHT * 0.4;+ }+ let document = h.app.session.doc.to_json();+ let undo = h.app.session.undo.len();+ semantic_drag_start(&mut h, &owners, from);+ assert!(egui::DragAndDrop::has_payload_of_type::<OccurrenceDrag>(&h.ctx));+ let presented = if keep_source { &owners[..] } else { std::slice::from_ref(&adapter) };+ semantic_frame(+ &mut h,+ presented,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ if keep_source {+ assert_ne!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo + 1);+ } else {+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ }+ assert!(!egui::DragAndDrop::has_payload_of_type::<OccurrenceDrag>(&h.ctx));+ assert!(h.ctx.dragged_id().is_none());+ }+ }+}++#[test]+fn session_switch_after_target_rows_render_discards_their_already_queued_drop() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.run("browser.group", json!({"component":0,"folder":"bodies","name":"Destination"})).unwrap();+ let (tab, document, undo) = matching_semantic_tab(&mut h);+ let owners = [ContentOwner::BROWSER, ContentOwner::HISTORY];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(ContentOwner::BROWSER, "One");+ let to = semantic_at(ContentOwner::HISTORY, "Destination (0)");+ semantic_drag_start(&mut h, &owners, from);+ semantic_frame_transitions(+ &mut h,+ &owners,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ None,+ Some(tab),+ );+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ assert!(semantic_content::output(ContentOwner::BROWSER).rows.is_empty());+ assert!(semantic_content::output(ContentOwner::HISTORY).rows.is_empty());+}++#[test]+fn semantic_entrypoints_reject_replaced_sessions_even_without_a_documents_hook() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ h.app.run("browser.group", json!({"component":0,"folder":"bodies","name":"Destination"})).unwrap();+ let incoming = solidcraft_engine::Session::new((*h.app.session.doc).clone());+ let document = incoming.doc.to_json();+ let undo = incoming.undo.len();+ let owners = [ContentOwner::BROWSER];+ for _ in 0..3 {+ semantic_frame(&mut h, &owners, Vec::new(), egui::Modifiers::NONE);+ }+ let from = semantic_at(ContentOwner::BROWSER, "One");+ semantic_click(&mut h, &owners, from, egui::Modifiers::NONE);+ let to = semantic_at(ContentOwner::BROWSER, "Destination (0)");+ semantic_drag_start(&mut h, &owners, from);+ assert!(egui::DragAndDrop::has_payload_of_type::<Drag>(&h.ctx));+ h.app.session.replace_design(incoming);+ semantic_frame(+ &mut h,+ &owners,+ vec![egui::Event::PointerMoved(to), semantic_button(to, egui::PointerButton::Primary, false, egui::Modifiers::NONE)],+ egui::Modifiers::NONE,+ );+ assert_eq!(h.app.session.doc.to_json(), document);+ assert_eq!(h.app.session.undo.len(), undo);+ assert!(h.app.tree.content.owner(ContentOwner::BROWSER).unwrap().anchor.is_none());+ assert!(!egui::DragAndDrop::has_payload_of_type::<Drag>(&h.ctx));+ assert!(h.ctx.dragged_id().is_none());+}++fn reveal_browser_at_height(h: &mut Harness, height: f32) {+ let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(900.0, 600.0))), ..Default::default() };+ h.ctx+ .run_ui(raw, |ui| {+ semantic_content::begin(&mut h.app, ui.ctx());+ let mut content = ui.new_child(+ egui::UiBuilder::new().id_salt("reveal-document-test").max_rect(Rect::from_min_size(pos2(10.0, 10.0), vec2(400.0, height))),+ );+ semantic_content::show(&mut h.app, &mut content, ContentOwner::BROWSER, ContentRequest::Browser { shrink_height: false });+ semantic_content::finalize(&mut h.app, ui.ctx());+ })+ .textures_delta+ .clear();+}++fn assert_no_pending_reveals(h: &Harness) {+ assert!(h.app.tree.reveal.is_none());+ assert!(h.app.tree.reveal_source.is_none());+ assert!(h.app.tree.reveal_feature.is_none());+ assert!(h.app.tree.timeline_reveal.is_none());+ assert!(h.app.tree.view_pick.is_none());+}++fn queue_all_document_reveals(h: &mut Harness) -> u64 {+ let feature = h.app.session.model.state().body("Three").unwrap().feature;+ reveal_body(&mut h.app, "Three");+ reveal_feature(&mut h.app, feature, "Three");+ // Keep both independently pending presentations, with the body's real provenance from+ // reveal_body. Public request fields also remain supported for existing adapters.+ h.app.tree.reveal = Some("Three".into());+ request_timeline_reveal(&mut h.app, feature);+ h.app.tree.view_pick = Some(feature);+ h.app.ui.show_browser = false;+ h.app.ui.show_timeline = false;+ feature+}++#[test]+fn body_reveals_park_with_each_document_and_cannot_scroll_a_matching_incoming_browser() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let original = h.app.docs.active;+ let original_uid = h.app.session.uid;+ let (tab, _, _) = matching_semantic_tab(&mut h);+ crate::documents::switch(&mut h.app, tab);+ for _ in 0..3 {+ reveal_browser_at_height(&mut h, 120.0);+ }+ let root = h.app.session.doc.name.clone();+ let incoming_root = semantic_at(ContentOwner::BROWSER, &root);+ assert!(!drawn_rows().iter().any(|(label, ..)| label == "Three"), "the target starts outside the scroll viewport");+ crate::documents::switch(&mut h.app, original);+ reveal_body(&mut h.app, "Three");+ h.app.ui.show_browser = false;+ h.app.tree.view_pick = Some(h.app.session.doc.features[2].id);+ semantic_frame_transitions(&mut h, &[ContentOwner::HISTORY], Vec::new(), egui::Modifiers::NONE, None, Some(tab));+ assert_no_pending_reveals(&h);+ for _ in 0..8 {+ reveal_browser_at_height(&mut h, 120.0);+ }+ assert_eq!(semantic_at(ContentOwner::BROWSER, &root), incoming_root, "B must not scroll in response to A's same-named body");+ reveal_body(&mut h.app, "Two");+ h.app.ui.show_browser = false;+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Two"));+ crate::documents::switch(&mut h.app, original);+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Three"));+ assert_eq!(h.app.tree.reveal_source.as_ref().unwrap().session, original_uid);+ assert!(h.app.tree.view_pick.is_none());+ for _ in 0..30 {+ reveal_browser_at_height(&mut h, 120.0);+ }+ assert!(h.app.tree.reveal.is_none(), "A acknowledges its restored target only after scrolling presents it");+ crate::documents::switch(&mut h.app, tab);+ assert_eq!(h.app.tree.reveal.as_deref(), Some("Two"), "B's independent request survives A's acknowledgment");+ for _ in 0..30 {+ reveal_browser_at_height(&mut h, 120.0);+ }+ assert!(h.app.tree.reveal.is_none());+}++#[test]+fn native_feature_reveals_restore_only_in_their_document_even_when_feature_ids_match() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let original = h.app.docs.active;+ let target_a = h.app.session.doc.features[2].id;+ let target_b = h.app.session.doc.features[0].id;+ let (tab, _, _) = matching_semantic_tab(&mut h);+ reveal_feature(&mut h.app, target_a, "Three");+ h.app.ui.show_browser = false;+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ semantic_frame_switch(&mut h, &[ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE, Some(tab));+ assert_no_pending_reveals(&h);+ assert!(h.app.session.doc.feature(target_a).is_some(), "matching numeric IDs do exist in B");+ reveal_feature(&mut h.app, target_b, "One");+ h.app.ui.show_browser = false;+ crate::documents::switch(&mut h.app, original);+ assert_eq!(h.app.tree.reveal_feature.as_ref().map(|target| target.id), Some(target_a));+ for _ in 0..4 {+ semantic_frame(&mut h, &[ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ }+ assert!(h.app.tree.reveal_feature.is_none());+ crate::documents::switch(&mut h.app, tab);+ assert_eq!(h.app.tree.reveal_feature.as_ref().map(|target| target.id), Some(target_b));+ for _ in 0..4 {+ semantic_frame(&mut h, &[ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ }+ assert!(h.app.tree.reveal_feature.is_none());+}++#[test]+fn timeline_reveals_remain_per_document_in_bottom_vertical_and_combined_history() {+ for (left, combined) in [(false, false), (true, false), (false, true)] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let original = h.app.docs.active;+ let target_a = h.app.session.doc.features[2].id;+ let target_b = h.app.session.doc.features[0].id;+ let (tab, _, _) = matching_semantic_tab(&mut h);+ h.app.preferences.timeline_left = left;+ h.app.preferences.history_in_browser = combined;+ if combined {+ reveal_in_history(&mut h.app, target_a);+ }+ request_timeline_reveal(&mut h.app, target_a);+ h.app.tree.view_pick = Some(target_a);+ h.app.ui.show_timeline = false;+ h.app.ui.show_browser = false;+ h.frames(2);+ semantic_frame_switch(&mut h, &[], Vec::new(), egui::Modifiers::NONE, Some(tab));+ assert_no_pending_reveals(&h);+ h.app.ui.show_timeline = true;+ h.app.ui.show_browser = combined;+ h.frames(4);+ assert!(h.app.tree.timeline_reveal.is_none());+ request_timeline_reveal(&mut h.app, target_b);+ h.app.ui.show_timeline = false;+ h.app.ui.show_browser = false;+ h.frames(2);+ semantic_frame_switch(&mut h, &[], Vec::new(), egui::Modifiers::NONE, Some(original));+ assert_eq!(h.app.tree.timeline_reveal, Some(target_a));+ assert!(h.app.tree.view_pick.is_none());+ if combined {+ assert_eq!(h.app.tree.reveal_feature.as_ref().map(|target| target.id), Some(target_a));+ }+ h.app.ui.show_timeline = true;+ h.app.ui.show_browser = combined;+ h.frames(8);+ assert!(h.app.tree.timeline_reveal.is_none(), "left={left}, combined={combined}: A acknowledges its own request");+ assert!(h.app.tree.reveal_feature.is_none());+ crate::documents::switch(&mut h.app, tab);+ assert_eq!(h.app.tree.timeline_reveal, Some(target_b));+ h.frames(8);+ assert!(h.app.tree.timeline_reveal.is_none(), "B acknowledges its independent request");+ }+}++#[test]+fn closing_a_document_destroys_its_parked_reveals_and_clears_stale_view_pick() {+ for active in [false, true] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let original = h.app.docs.active;+ let (tab, _, _) = matching_semantic_tab(&mut h);+ queue_all_document_reveals(&mut h);+ if !active {+ crate::documents::switch(&mut h.app, tab);+ }+ crate::documents::close(&mut h.app, original, true);+ assert_eq!(h.app.docs.count(), 1);+ assert_no_pending_reveals(&h);+ let replacement = solidcraft_engine::Session::new((*h.app.session.doc).clone());+ crate::documents::open_tab(&mut h.app, replacement).unwrap();+ assert_no_pending_reveals(&h);+ for _ in 0..3 {+ semantic_frame(&mut h, &[ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ }+ assert_no_pending_reveals(&h);+ }+}++#[test]+fn last_close_blank_adoption_and_direct_replacement_discard_outgoing_reveal_requests() {+ for replacement in ["last-close", "blank-adopt", "direct"] {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let incoming = solidcraft_engine::Session::new((*h.app.session.doc).clone());+ queue_all_document_reveals(&mut h);+ match replacement {+ "last-close" => {+ let original = h.app.docs.active;+ crate::documents::close(&mut h.app, original, true);+ assert_no_pending_reveals(&h);+ crate::documents::adopt(&mut h.app, incoming);+ assert_no_pending_reveals(&h);+ }+ "blank-adopt" => {+ h.app.session.replace_design(solidcraft_engine::Session::default());+ crate::documents::adopt(&mut h.app, incoming);+ assert_no_pending_reveals(&h);+ }+ _ => h.app.session.replace_design(incoming),+ }+ for _ in 0..3 {+ semantic_frame(&mut h, &[ContentOwner::BROWSER], Vec::new(), egui::Modifiers::NONE);+ }+ assert_no_pending_reveals(&h);+ assert!(h.app.session.model.state().body("Three").is_some(), "the incoming target still exists; matching names cannot preserve A's request");+ }+}++#[test]+fn unpresented_app_requests_have_provenance_before_a_direct_session_replacement() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let document = (*h.app.session.doc).clone();+ h.app = crate::SolveApp::new(solidcraft_engine::Session::new(document.clone()), crate::Services::default());+ // Existing callers can set the public request fields before the first UI frame.+ h.app.tree.reveal = Some("Three".into());+ h.app.tree.timeline_reveal = Some(document.features[2].id);+ h.app.tree.view_pick = Some(document.features[2].id);+ h.app.session.replace_design(solidcraft_engine::Session::new(document));+ semantic_frame(&mut h, &[ContentOwner::HISTORY], Vec::new(), egui::Modifiers::NONE);+ assert_no_pending_reveals(&h);+}++#[test]+fn parked_reveals_are_pruned_against_their_own_document_when_the_target_is_removed() {+ let mut h = Harness::new();+ three_bodies(&mut h);+ let original = h.app.docs.active;+ let owner = h.app.session.uid;+ let (tab, _, _) = matching_semantic_tab(&mut h);+ let feature = queue_all_document_reveals(&mut h);+ crate::documents::switch(&mut h.app, tab);+ let parked = h.app.docs.background_mut().find(|slot| slot.session.uid == owner).unwrap();+ parked.session.execute("selection.delete", &json!({"items":[Sel::Feature { id: feature }]})).unwrap();+ assert_no_pending_reveals(&h);+ assert!(h.app.session.doc.feature(feature).is_some(), "B retains the matching feature");+ crate::documents::switch(&mut h.app, original);+ assert_eq!(h.app.tree.timeline_reveal, Some(feature), "the request returns to A before ordinary target pruning");+ semantic_frame(&mut h, &[], Vec::new(), egui::Modifiers::NONE);+ assert_no_pending_reveals(&h);+}diff --git a/crates/ui-egui/src/browser_model_tests.rs b/crates/ui-egui/src/browser_model_tests.rsindex f60f72ae36..a562ace072 100644--- a/crates/ui-egui/src/browser_model_tests.rs+++ b/crates/ui-egui/src/browser_model_tests.rs@@ -95,7 +95,10 @@ fn a_face_picked_in_the_viewport_opens_the_browser_to_its_placements_body() {let (one, two) = (super::occurrence_key(&[occurrence]), super::occurrence_key(&[copy]));h.app.tree.collapsed.extend([one.clone(), two.clone(), format!("{two}/bodies")]);h.frames(2);- assert!(!h.app.tree.order.contains(&format!("b:{second}")), "the body's row is closed away");+ assert!(+ !h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&format!("b:{second}")),+ "the body's row is closed away"+ );let face = Sel::Face { body: second.clone(), index: 0, point: solidcore_record::Vec3::new(55.0, 5.0, 10.0) };crate::viewport::select(&mut h.app, Some(face), false, false);assert_eq!(h.app.tree.reveal.as_deref(), Some(second.as_str()));@@ -103,8 +106,14 @@ fn a_face_picked_in_the_viewport_opens_the_browser_to_its_placements_body() {assert!(h.app.tree.reveal.is_none(), "revealed");assert!(!h.app.tree.collapsed.contains(&two) && !h.app.tree.collapsed.contains(&format!("{two}/bodies")));assert!(h.app.tree.collapsed.contains(&one), "the other placement stays as it was");- assert!(h.app.tree.order.contains(&format!("b:{second}")), "the row is drawn");- assert!(!h.app.tree.order.contains(&format!("b:{first}")), "the other placement's row stays closed away");+ assert!(+ h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&format!("b:{second}")),+ "the row is drawn"+ );+ assert!(+ !h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&format!("b:{first}")),+ "the other placement's row stays closed away"+ );}/// Hovering a placement row lights its whole subtree: the subtree is walked once per model, not@@ -553,5 +562,8 @@ fn find_in_browser_opens_placements_that_start_closed() {super::reveal_body(&mut h.app, &body);h.frames(3);assert!(super::is_open(&h.app, &super::occurrence_key(&[occurrence]), true));- assert!(h.app.tree.order.contains(&format!("b:{body}")), "the body's row is drawn");+ assert!(+ h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&format!("b:{body}")),+ "the body's row is drawn"+ );}diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rsindex c165b05e9c..d00e87ae08 100644--- a/crates/ui-egui/src/context_menu.rs+++ b/crates/ui-egui/src/context_menu.rs@@ -1603,7 +1603,7 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {}}let _ = app.run("select.set", json!({"items": [{"type": "feature", "id": f}]}));- app.tree.timeline_reveal = Some(f);+ crate::browser::request_timeline_reveal(app, f);}}"ui.tangentChain" => tangent_chain(app),diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rsindex 0e48f34d79..78d15c8764 100644--- a/crates/ui-egui/src/documents.rs+++ b/crates/ui-egui/src/documents.rs@@ -47,6 +47,7 @@ pub struct DocSlot {pre_sketch_component: Option<crate::PreSketchComponent>,view: DocView,occurrence_move: Option<crate::browser::OccMove>,+ reveals: crate::browser::PendingReveals,agent_chat: crate::agent_chat::AgentChat,/// Its linked design files as the design last read them (`Documents::link_stamps`).link_stamps: Vec<(u64, crate::linked_source::Stamp)>,@@ -142,6 +143,7 @@ impl DocSlot {pre_sketch_component: None,view: DocView::default(),occurrence_move: None,+ reveals: Default::default(),agent_chat: Default::default(),link_stamps: Vec::new(),edit_in_place: None,@@ -215,6 +217,8 @@ fn put_view(app: &mut SolveApp, v: DocView) {/// Put `slot` into the app and return what was there.fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot {+ let reveals = crate::browser::take_reveals(app);+ crate::semantic_content::leave_document(app);if crate::render_workspace::active(app) {let _ = crate::render_workspace::enter(app, false);}@@ -248,12 +252,14 @@ fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot {pre_sketch_component: std::mem::replace(&mut app.pre_sketch_component, slot.pre_sketch_component),view: take_view(app),occurrence_move: std::mem::replace(&mut app.tree.occurrence_move, slot.occurrence_move),+ reveals,agent_chat: slot.agent_chat,link_stamps: std::mem::replace(&mut app.docs.link_stamps, slot.link_stamps),edit_in_place: std::mem::replace(&mut app.edit_in_place.active, slot.edit_in_place),work,jobs: app.swap_jobs(slot.jobs),};+ crate::browser::restore_reveals(app, slot.reveals);// Only the displayed design owns the process-wide crash replay journal.app.session.crash_journal = out.session.crash_journal;out.session.crash_journal = false;@@ -458,6 +464,8 @@ pub fn active_is_blank(app: &SolveApp) -> bool {pub fn adopt(app: &mut SolveApp, session: Session) {if active_is_blank(app) {let rev = app.session.revision;+ crate::browser::discard_reveals(app);+ crate::semantic_content::leave_document(app);crate::dialogs::cancel(app);app.tool = None;crate::design_properties::close_object(app);@@ -545,6 +553,8 @@ pub fn close(app: &mut SolveApp, i: usize, force: bool) {}app.docs.closing = None;if n <= 1 {+ crate::browser::discard_reveals(app);+ crate::semantic_content::leave_document(app);// The last design: a blank one takes its place.reset_chat(app);if let Some(a) = app.autosave.as_mut().and_then(|a| a.active.take()) {diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 07d562a9f2..fe197fe9e6 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -239,6 +239,7 @@ pub mod scenario;pub(crate) mod scene_palette;pub mod select_other;pub mod selection;+pub mod semantic_content;pub mod settings_profiles;#[cfg(test)]mod settings_profiles_tests;@@ -792,6 +793,7 @@ impl SolveApp {render_workspace.image_host = image_host;#[cfg(not(target_arch = "wasm32"))]solidcraft_engine::slicer_files::clean_old();+ let tree = browser::TreeState::for_session(session.uid);let mut app = SolveApp {panel_runtime: None,viewport_status: Default::default(),@@ -824,7 +826,7 @@ impl SolveApp {material_card_review: None,menu: context_menu::MenuState::default(),gesture: mouse_gesture::State::default(),- tree: browser::TreeState::default(),+ tree,linked_design_clipboard: None,sbox: shortcut_box::ShortcutBox::default(),keymap: keymap::Keymap::default(),@@ -3021,7 +3023,9 @@ impl SolveApp {let _language = crate::i18n::scope(&self.preferences.language);let mut report_input = None;issue_report::CadInput::block(self, ui, &mut report_input);+ semantic_content::begin(self, ui.ctx());self.cad_ui(ui, &mut report_input);+ semantic_content::finalize(self, ui.ctx());drop(report_input);// After everything else, on every page (the start page too, which returns early from// `cad_ui`): the window's edges resize it (#1381).@@ -3080,6 +3084,7 @@ impl SolveApp {agent_chat::poll(self, ui.ctx());// Preferences and Keyboard Shortcuts open from Home too (its links, the gear, Ctrl+,).prefs::show(self, ui.ctx());+ browser::editors(self, ui);return;}}@@ -3163,6 +3168,10 @@ impl SolveApp {if self.ui.show_browser && !render_ui::focused(self) {browser::browser(self, ui);}+ // All shared semantic content has now submitted its output. Apply it before the+ // viewport/dialog/menu consumers, regardless of which presentations were visible.+ semantic_content::finalize(self, ui.ctx());+ browser::editors(self, ui);if floating {agent_chat::show(self, ui);}diff --git a/crates/ui-egui/src/occurrence_ui_tests.rs b/crates/ui-egui/src/occurrence_ui_tests.rsindex 260fa243d9..069fb80fd3 100644--- a/crates/ui-egui/src/occurrence_ui_tests.rs+++ b/crates/ui-egui/src/occurrence_ui_tests.rs@@ -499,7 +499,10 @@ fn find_in_browser_reaches_a_folded_body() {let scope = super::occurrence_key(&[second]);h.app.tree.collapsed.extend([super::occurrence_key(&[first]), scope.clone(), format!("{scope}/bodies")]);h.frames(2);- assert!(!h.app.tree.order.contains(&format!("b:{body}")), "the body's row is closed away");+ assert!(+ !h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&format!("b:{body}")),+ "the body's row is closed away"+ );h.app.session.selection = vec![Sel::Body { name: body.clone() }];let find = context_menu::items(&h.app, &Target::Viewport).into_iter().find(|i| i.id == "ui.findBrowser").unwrap();context_menu::run_item(&mut h.app, &find, egui::Pos2::ZERO);@@ -507,7 +510,10 @@ fn find_in_browser_reaches_a_folded_body() {h.frames(2);assert!(h.app.tree.reveal.is_none(), "revealed");assert!(!h.app.tree.collapsed.contains(&scope));- assert!(h.app.tree.order.contains(&format!("b:{body}")), "the row is drawn");+ assert!(+ h.app.tree.content.owner(crate::semantic_content::ContentOwner::BROWSER).unwrap().order.contains(&format!("b:{body}")),+ "the row is drawn"+ );assert!(crate::scenario::handle_at("fold:Bodies").is_none(), "with no folder row");}diff --git a/crates/ui-egui/src/select_other.rs b/crates/ui-egui/src/select_other.rsindex 61aface993..f9102fbec3 100644--- a/crates/ui-egui/src/select_other.rs+++ b/crates/ui-egui/src/select_other.rs@@ -417,7 +417,7 @@ pub fn close(app: &mut SolveApp) {if let Some(p) = app.viewport.select_other.popup.take()&& p.lit_body{- app.viewport.hover_bodies.clear();+ crate::semantic_content::set_external_body_hover(app, Vec::new());}}@@ -557,12 +557,12 @@ pub fn hover_override(app: &mut SolveApp) {app.viewport.hover = if body.is_some() { None } else { row.map(|r| r.hit.clone()) };match body {Some(b) => {- app.viewport.hover_bodies = vec![b];p.lit_body = true;+ crate::semantic_content::set_external_body_hover(app, vec![b]);}None if p.lit_body => {- app.viewport.hover_bodies.clear();p.lit_body = false;+ crate::semantic_content::set_external_body_hover(app, Vec::new());}None => {}}diff --git a/crates/ui-egui/src/select_other_tests.rs b/crates/ui-egui/src/select_other_tests.rsindex 3fab5009b0..502bc4d988 100644--- a/crates/ui-egui/src/select_other_tests.rs+++ b/crates/ui-egui/src/select_other_tests.rs@@ -7,6 +7,50 @@ use solidcraft_engine::geom::prelude::*;use crate::scenario::Harness;+#[test]+fn same_body_select_other_refresh_survives_disappearing_semantic_owners() {+ let mut h = Harness::new();+ h.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Body1"})).unwrap();+ h.frames(4);+ let body_row = crate::browser::drawn_rows().into_iter().find(|(label, ..)| label == "Body1").unwrap().1.center();+ h.step(&json!({"move":[body_row.x,body_row.y]})).unwrap();+ assert_eq!(h.app.viewport.hover_bodies, ["Body1"], "establish actual Browser row hover first");+ h.app.ui.show_browser = false;+ h.app.ui.show_timeline = false;+ h.app.viewport.select_other.popup = Some(super::Popup {+ at: egui::pos2(500.0, 300.0),+ rows: vec![super::Row {+ hit: crate::viewport::Hit::Face { body: "Body1".into(), index: 0, point: solidcore_record::Vec3::ZERO },+ sel: Sel::Body { name: "Body1".into() },+ label: "Body1".into(),+ icon: "body",+ }],+ total: 1,+ hovered: Some(0),+ revision: h.app.session.revision,+ dialog: false,+ include_hidden: h.app.preferences.select_other_hidden,+ lit_body: false,+ held: Default::default(),+ });+ let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() };+ h.ctx+ .run_ui(raw, |ui| {+ crate::semantic_content::begin(&mut h.app, ui.ctx());+ // Floating show_workspace calls this real producer before semantic finalization.+ // Its new body name is deliberately identical to the previous Browser contribution.+ super::hover_override(&mut h.app);+ assert_eq!(h.app.viewport.hover_bodies, ["Body1"]);+ crate::semantic_content::finalize(&mut h.app, ui.ctx());+ })+ .textures_delta+ .clear();+ assert_eq!(h.app.viewport.hover_bodies, ["Body1"], "fresh external ownership survives missing semantic owners");+ assert!(crate::browser::drawn_rows().is_empty());+ super::close(&mut h.app);+ assert!(h.app.viewport.hover_bodies.is_empty(), "Select Other retains responsibility for clearing its own contribution");+}+/// A sketch with two lines drawn on top of each other (l1, then l2), off the origin axes.fn two_lines() -> (Harness, Value) {let mut h = Harness::new();diff --git a/crates/ui-egui/src/semantic_content.rs b/crates/ui-egui/src/semantic_content.rsnew file mode 100644index 0000000000..826d04f0cc--- /dev/null+++ b/crates/ui-egui/src/semantic_content.rs@@ -0,0 +1,466 @@+//! Shared tree content, independent of the panels which present it.+//!+//! A frame has one app-owned begin/finalize pair. Each presentation owns its range order,+//! anchor, geometry and transient input; the document, selection, folds and row cache remain+//! in `SolveApp`. Hosts and future adapters can render the same content through `show`.++use std::cell::RefCell;+use std::collections::{BTreeMap, HashMap, HashSet};++use egui::{Rect, Ui};++use crate::SolveApp;++/// A presentation identity, independent of its placement or content composition.+#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]+pub struct ContentOwner(pub u64);++impl ContentOwner {+ pub const BROWSER: Self = Self(0);+ pub const HISTORY: Self = Self(1);+}++/// Runtime identity of the document and presentation which produced an interaction.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) struct ContentSource {+ pub(crate) session: u64,+ pub(crate) owner: ContentOwner,+}++#[derive(Clone)]+pub(crate) struct FeatureDrag {+ pub(crate) source: ContentSource,+ pub(crate) features: Vec<u64>,+}++/// Existing row compositions. This interface deliberately contains no panel or host policy.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) enum ContentRequest {+ Browser { shrink_height: bool },+ ActiveBodiesOrigin,+}++pub type DrawnRow = (String, Rect, Option<Rect>, Option<bool>);+pub type DrawnOccurrence = (Vec<u64>, String, Rect, bool);++/// Geometry belongs to one presentation and expires at the next semantic frame.+#[derive(Clone, Default)]+pub struct Output {+ pub rows: Vec<DrawnRow>,+ pub occurrences: Vec<DrawnOccurrence>,+ pointer_owned: bool,+}++thread_local! {+ // Compatibility/automation snapshots, published by the owner rather than by each row.+ static PUBLISHED: RefCell<BTreeMap<ContentOwner, Output>> = const { RefCell::new(BTreeMap::new()) };+}++pub fn output(owner: ContentOwner) -> Output {+ PUBLISHED.with(|outputs| outputs.borrow().get(&owner).cloned().unwrap_or_default())+}++#[derive(Default)]+pub(crate) struct OwnerState {+ pub(crate) order: Vec<String>,+ pub(crate) previous: Vec<String>,+ pub(crate) anchor: Option<String>,+ pub(crate) feature_drags: HashMap<egui::Id, FeatureDrag>,+ order_len: usize,+ output: Output,+ actions: Option<crate::browser::Actions>,+ presented: bool,+}++impl OwnerState {+ pub(crate) fn remember(&mut self, key: &str) {+ if let Some(slot) = self.order.get_mut(self.order_len) {+ if slot != key {+ slot.clear();+ slot.push_str(key);+ }+ } else {+ self.order.push(key.to_owned());+ }+ self.order_len += 1;+ }++ pub(crate) fn current_order(&self) -> &[String] {+ self.order.get(..self.order_len).unwrap_or(&[])+ }+}++#[derive(Default)]+pub(crate) struct Frame {+ session: Option<u64>,+ context: Option<egui::Context>,+ owners: BTreeMap<ContentOwner, OwnerState>,+ active: Option<(ContentOwner, ContentRequest)>,+ last_bodies: Vec<String>,+ last_plane: Option<String>,+ plane_underlay: Option<String>,+ finalized: bool,+}++impl Frame {+ pub(crate) fn owner(&self, owner: ContentOwner) -> Option<&OwnerState> {+ self.owners.get(&owner)+ }++ pub(crate) fn current_mut(&mut self) -> &mut OwnerState {+ let owner = self.active.map_or(ContentOwner::BROWSER, |(owner, _)| owner);+ self.owners.entry(owner).or_default()+ }++ pub(crate) fn browser_presentation(&self) -> bool {+ matches!(self.active, Some((ContentOwner::BROWSER, ContentRequest::Browser { .. })))+ }+}++fn active_id() -> egui::Id {+ egui::Id::new("sc_semantic_content_owner")+}++fn output_id(owner: ContentOwner) -> egui::Id {+ egui::Id::new(("sc_semantic_content_output", owner))+}++fn capture_id() -> egui::Id {+ egui::Id::new("sc_semantic_content_eye_owner")+}++#[derive(Clone, Copy)]+struct EyeCapture {+ source: ContentSource,+ widget: egui::Id,+ target: bool,+}++#[derive(Clone, Copy)]+struct RowCapture {+ source: ContentSource,+ widget: egui::Id,+}++#[derive(Clone, Default)]+struct InputClaims {+ frame: u64,+ actions: HashSet<egui::Id>,+}++/// Egui may repeat layout within an input frame. A consumed row action must not execute a+/// second time on that pass (in particular a Ctrl toggle or an eye visibility command).+pub(crate) fn claim_action(ui: &Ui, widget: egui::Id) -> bool {+ let frame = ui.ctx().cumulative_frame_nr();+ ui.ctx().data_mut(|data| {+ let claims = data.get_temp_mut_or_default::<InputClaims>(egui::Id::new("sc_semantic_content_input_claims"));+ if claims.frame != frame {+ claims.frame = frame;+ claims.actions.clear();+ }+ claims.actions.insert(widget)+ })+}++fn row_capture_id() -> egui::Id {+ egui::Id::new("sc_semantic_content_row_capture")+}++pub(crate) fn current_source(app: &SolveApp) -> Option<ContentSource> {+ let (owner, _) = app.tree.content.active?;+ (app.tree.content.session == Some(app.session.uid)).then_some(ContentSource { session: app.session.uid, owner })+}++pub(crate) fn same_document(ui: &Ui, source: ContentSource) -> bool {+ ui.ctx().data(|data| data.get_temp::<ContentSource>(active_id())).is_some_and(|active| active.session == source.session)+}++pub(crate) fn source_present(app: &SolveApp, source: ContentSource) -> bool {+ app.tree.content.session == Some(source.session)+ && app.session.uid == source.session+ && app.tree.content.owner(source.owner).is_some_and(|state| state.presented)+}++/// Called while the outgoing session (and its undo stack) is still active. Context is retained+/// solely for cancelling owned egui capture when a tab changes outside the drawing callback.+pub(crate) fn leave_document(app: &mut SolveApp) {+ let context = app.tree.content.context.clone();+ if let (Some(ctx), Some(session)) = (&context, app.tree.content.session) {+ if ctx.data(|data| data.get_temp::<EyeCapture>(capture_id())).is_some_and(|capture| capture.source.session == session) {+ crate::browser::end_eye_drag(app, ctx);+ }+ if let Some(capture) = ctx.data(|data| data.get_temp::<RowCapture>(row_capture_id())).filter(|capture| capture.source.session == session) {+ if ctx.dragged_id() == Some(capture.widget) {+ ctx.stop_dragging();+ }+ ctx.data_mut(|data| data.remove::<RowCapture>(row_capture_id()));+ }+ crate::browser::cancel_content_drag(ctx, session);+ ctx.data_mut(|data| {+ if data.get_temp::<ContentSource>(active_id()).is_some_and(|source| source.session == session) {+ data.remove::<ContentSource>(active_id());+ }+ for owner in app.tree.content.owners.keys() {+ data.remove::<Output>(output_id(*owner));+ }+ });+ }+ crate::browser::discard_eye_press(app);+ let _ = expire_hover(app);+ app.tree.content = Frame { context, ..Default::default() };+ PUBLISHED.with(|outputs| outputs.borrow_mut().clear());+}++/// Also protects callers which replace a Session without passing through Documents.+pub(crate) fn ensure_session(app: &mut SolveApp, ctx: &egui::Context) {+ crate::browser::sync_reveals(app);+ if app.tree.content.session != Some(app.session.uid) {+ leave_document(app);+ app.tree.content.session = Some(app.session.uid);+ }+ app.tree.content.context = Some(ctx.clone());+}++/// An external producer replaced this slot. Its ownership supersedes our previous write even+/// when the new vector contains precisely the same names (Select Other is one such producer).+pub(crate) fn set_external_body_hover(app: &mut SolveApp, bodies: Vec<String>) {+ app.tree.content.last_bodies.clear();+ app.viewport.hover_bodies = bodies;+}++fn expire_hover(app: &mut SolveApp) -> (Vec<String>, Option<String>) {+ let old_bodies = std::mem::take(&mut app.tree.content.last_bodies);+ let old_plane = app.tree.content.last_plane.take();+ for body in &old_bodies {+ if let Some(index) = app.viewport.hover_bodies.iter().position(|candidate| candidate == body) {+ app.viewport.hover_bodies.remove(index);+ }+ }+ let plane_underlay = app.tree.content.plane_underlay.take();+ if old_plane.is_some() && app.viewport.hover_plane == old_plane {+ app.viewport.hover_plane = plane_underlay;+ }+ (old_bodies, old_plane)+}++pub(crate) fn begin(app: &mut SolveApp, ctx: &egui::Context) {+ ensure_session(app, ctx);+ let frame = &mut app.tree.content;+ frame.active = None;+ frame.finalized = false;+ for state in frame.owners.values_mut() {+ if state.presented {+ std::mem::swap(&mut state.previous, &mut state.order);+ }+ state.order_len = 0;+ state.output = Output::default();+ state.actions = None;+ state.presented = false;+ }+ PUBLISHED.with(|outputs| outputs.borrow_mut().clear());+ ctx.data_mut(|data| data.remove::<ContentSource>(active_id()));+ crate::browser::prune_reveals(app);+}++/// Render into an existing UI. Stable item IDs and command paths belong to the row renderers.+pub(crate) fn show(app: &mut SolveApp, ui: &mut Ui, owner: ContentOwner, request: ContentRequest) {+ render_scope(app, ui, owner, request, |app, ui| crate::browser::render_content(app, ui, request));+}++pub(crate) fn render_scope(+ app: &mut SolveApp,+ ui: &mut Ui,+ owner: ContentOwner,+ request: ContentRequest,+ render: impl FnOnce(&mut SolveApp, &mut Ui) -> crate::browser::Actions,+) {+ ensure_session(app, ui.ctx());+ if app.tree.content.owners.get(&owner).is_some_and(|state| state.presented) {+ return;+ }+ app.tree.content.active = Some((owner, request));+ app.tree.content.owners.entry(owner).or_default().presented = presented(ui);+ ui.ctx().data_mut(|data| {+ data.insert_temp(active_id(), ContentSource { session: app.session.uid, owner });+ data.insert_temp(output_id(owner), Output::default());+ });+ let session = app.session.uid;+ let actions = ui.push_id(("semantic_content", session, owner), |ui| render(app, ui)).inner;+ if session != app.session.uid {+ ensure_session(app, ui.ctx());+ return;+ }+ let output = ui.ctx().data_mut(|data| {+ data.remove::<ContentSource>(active_id());+ data.remove_temp::<Output>(output_id(owner)).unwrap_or_default()+ });+ PUBLISHED.with(|outputs| outputs.borrow_mut().insert(owner, output.clone()));+ let state = app.tree.content.owners.entry(owner).or_default();+ state.order.truncate(state.order_len);+ state.output = output;+ state.actions = Some(actions);+ app.tree.content.active = None;+}++pub(crate) fn record_row(ui: &Ui, row: DrawnRow, response: &crate::ui_kit::RowResp) {+ if !presented(ui) {+ return;+ }+ let Some(source) = ui.ctx().data(|data| data.get_temp::<ContentSource>(active_id())) else { return };+ let owner = source.owner;+ ui.ctx().data_mut(|data| {+ let output = data.get_temp_mut_or_default::<Output>(output_id(owner));+ output.rows.push(row);+ output.pointer_owned |= response.hovered || response.resp.as_ref().is_some_and(|response| response.contains_pointer());+ });+ if !response.on_control+ && let Some(response) = &response.resp+ {+ record_capture(ui, response);+ }+}++pub(crate) fn record_capture(ui: &Ui, response: &egui::Response) {+ if response.drag_started()+ && let Some(source) = ui.ctx().data(|data| data.get_temp::<ContentSource>(active_id()))+ {+ ui.ctx().data_mut(|data| data.insert_temp(row_capture_id(), RowCapture { source, widget: response.id }));+ }+}++pub(crate) fn record_occurrence(ui: &Ui, row: DrawnOccurrence) {+ if !presented(ui) {+ return;+ }+ let Some(source) = ui.ctx().data(|data| data.get_temp::<ContentSource>(active_id())) else { return };+ let owner = source.owner;+ ui.ctx().data_mut(|data| data.get_temp_mut_or_default::<Output>(output_id(owner)).occurrences.push(row));+}++/// The kit's eye gesture keeps its existing shared target value; its capture belongs to the+/// presentation where it began, so another copy of a body cannot apply the same drag again.+pub(crate) fn route_response(ui: &Ui, widget: egui::Id, response: &mut crate::ui_kit::RowResp) {+ let Some(source) = ui.ctx().data(|data| data.get_temp::<ContentSource>(active_id())) else { return };+ response.hovered &= response.resp.as_ref().is_some_and(|response| response.contains_pointer());+ let action =+ response.clicked || response.double || response.secondary.is_some() || response.fold || response.eye || response.radio || response.action;+ let visible = presented(ui);+ if !visible {+ response.hovered = false;+ response.resp = None;+ }+ if !visible || (action && !claim_action(ui, widget)) {+ response.clicked = false;+ response.double = false;+ response.secondary = None;+ response.fold = false;+ response.eye = false;+ response.radio = false;+ response.action = false;+ }+ let capture = ui.ctx().data(|data| data.get_temp::<EyeCapture>(capture_id()));+ if let Some(capture) = capture {+ // A layout repeat may run the kit's drag-start branch again after visibility changed.+ // Keep the gesture's original target rather than letting that branch invert it.+ ui.ctx().data_mut(|data| data.insert_temp(crate::ui_kit::eye_drag_id(), capture.target));+ }+ if capture.is_some_and(|capture| capture.source != source) {+ response.eye = false;+ } else if response.eye+ && let Some(response) = response.resp.as_ref().filter(|response| response.drag_started())+ {+ ui.ctx().data_mut(|data| {+ if let Some(target) = data.get_temp::<bool>(crate::ui_kit::eye_drag_id()) {+ data.insert_temp(capture_id(), EyeCapture { source, widget: response.id, target });+ }+ });+ }+}++pub(crate) fn release_eye(ctx: &egui::Context) -> Option<ContentSource> {+ let capture = ctx.data_mut(|data| {+ let capture = data.get_temp::<EyeCapture>(capture_id());+ data.remove::<EyeCapture>(capture_id());+ capture+ })?;+ if ctx.dragged_id() == Some(capture.widget) {+ ctx.stop_dragging();+ }+ Some(capture.source)+}++/// A reveal is acknowledged only after its row is presented in the scroll viewport. An+/// offscreen target requests scrolling again on the next frame until that happens.+pub(crate) fn scroll_acknowledged(ui: &Ui, rect: Rect) -> bool {+ ui.scroll_to_rect(rect, Some(egui::Align::Center));+ presented(ui) && ui.is_rect_visible(rect) && ui.clip_rect().contains(rect.center())+}++fn presented(ui: &Ui) -> bool {+ ui.is_visible() && ui.opacity() > 0.0+}++pub(crate) fn finalize(app: &mut SolveApp, ctx: &egui::Context) {+ ensure_session(app, ctx);+ if app.tree.content.finalized {+ return;+ }+ app.tree.content.finalized = true;+ let mut capture = ctx.data(|data| data.get_temp::<EyeCapture>(capture_id())).map(|capture| capture.source);+ if capture.is_some_and(|source| !source_present(app, source)) {+ crate::browser::end_eye_drag(app, ctx);+ capture = None;+ }+ if let Some(capture) = ctx.data(|data| data.get_temp::<RowCapture>(row_capture_id())) {+ if !source_present(app, capture.source) {+ crate::browser::cancel_content_drag(ctx, capture.source.session);+ if ctx.dragged_id() == Some(capture.widget) {+ ctx.stop_dragging();+ }+ ctx.data_mut(|data| data.remove::<RowCapture>(row_capture_id()));+ } else if !ctx.input(|input| input.pointer.primary_down()) {+ ctx.data_mut(|data| data.remove::<RowCapture>(row_capture_id()));+ }+ }+ // Keep the previous contribution until finalization: floating viewports paint before+ // their overlaid panels. Expire only our contribution, leaving other producers intact.+ let (old_bodies, old_plane) = expire_hover(app);+ // Egui's response hit testing supplies pointer ownership, including occlusion and capture.+ // Stable owner iteration only breaks ties; submission order never decides the winner.+ let winner = app.tree.content.owners.iter().find_map(|(owner, state)| {+ let actions = state.actions.as_ref()?;+ (state.presented+ && actions.session == Some(app.session.uid)+ && capture.is_none_or(|capture| capture.owner == *owner && capture.session == app.session.uid)+ && (state.output.pointer_owned || actions.hovered || actions.hover_plane.is_some()))+ .then_some(*owner)+ });+ let mut effect = None;+ for (owner, state) in &mut app.tree.content.owners {+ if !state.presented {+ state.order.clear();+ state.feature_drags.clear();+ }+ let actions = state.actions.take();+ if Some(*owner) == winner {+ effect = actions;+ }+ }+ if let Some(actions) = effect {+ for body in &actions.hover_bodies {+ if !app.viewport.hover_bodies.contains(body) {+ app.viewport.hover_bodies.push(body.clone());+ app.tree.content.last_bodies.push(body.clone());+ }+ }+ if actions.hover_plane.is_some() && actions.hover_plane != app.viewport.hover_plane {+ app.tree.content.plane_underlay = app.viewport.hover_plane.take();+ app.tree.content.last_plane.clone_from(&actions.hover_plane);+ app.viewport.hover_plane.clone_from(&actions.hover_plane);+ }+ crate::browser::apply_content_actions(app, actions);+ }+ if old_bodies != app.tree.content.last_bodies || old_plane != app.tree.content.last_plane {+ ctx.request_repaint();+ }+}diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rsindex 673c25d478..09e45d8aa4 100644--- a/crates/ui-egui/src/timeline.rs+++ b/crates/ui-egui/src/timeline.rs@@ -93,13 +93,16 @@ pub(crate) fn picked_feature(app: &SolveApp) -> Option<u64> {/// A new face or edge picked in the view scrolls the history shown to the feature that made it,/// once per pick; the history stays where it is while the pick does not change.pub(crate) fn follow_view_pick(app: &mut SolveApp) {+ crate::browser::sync_reveals(app);let picked = picked_feature(app);if picked == app.tree.view_pick {return;}app.tree.view_pick = picked;- if picked.is_some() && app.ui.show_timeline {- app.tree.timeline_reveal = picked;+ if app.ui.show_timeline+ && let Some(id) = picked+ {+ crate::browser::request_timeline_reveal(app, id);}}@@ -772,6 +775,7 @@ pub(crate) fn tick_playback(app: &mut SolveApp, ctx: &egui::Context) {}pub fn timeline(app: &mut SolveApp, ui: &mut egui::Ui) {+ crate::browser::sync_reveals(app);let t = Tokens::get();app.shell.history_dock_space = Some(ui.available_rect_before_wrap());if Container::for_layout(app.ui.layout, Surface::Panel).floating() {@@ -991,7 +995,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {.collect();let order: Vec<u64> = feats.iter().map(|f| f.0).collect();// Find in Timeline: scroll the found feature into the strip on this frame (#5850).- let reveal = app.tree.timeline_reveal.take();+ let reveal = app.tree.timeline_reveal;// The feature that made what is under the cursor or picked in the viewport.let from_view = [hovered_feature(app), picked_feature(app)];let drag_id = ui.id().with("tl_drag");@@ -1061,8 +1065,8 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {*slot = x;}let br = Rect::from_min_size(pos2(x, r.top() + 6.0), vec2(28.0, 28.0));- if reveal == Some(*id) {- ui.scroll_to_rect(br, Some(egui::Align::Center));+ if reveal == Some(*id) && crate::semantic_content::scroll_acknowledged(ui, br) {+ app.tree.timeline_reveal = None;}crate::scenario::publish_handle(&format!("timeline:{name}"), br.center());// A chip scrolled out of the strip is neither drawn nor interactive: a longdiff --git a/crates/ui-egui/src/timeline_left.rs b/crates/ui-egui/src/timeline_left.rsindex 503b08a69f..c3331ffbf0 100644--- a/crates/ui-egui/src/timeline_left.rs+++ b/crates/ui-egui/src/timeline_left.rs@@ -226,6 +226,7 @@ fn card_fill(app: &SolveApp, floating: bool) -> egui::Color32 {/// Full-height left card, or a card sharing the browser column below it.pub fn left_panel(app: &mut SolveApp, ui: &mut egui::Ui) {+ crate::browser::sync_reveals(app);let t = Tokens::get();let available = ui.available_rect_before_wrap();app.shell.history_dock_space = Some(available);@@ -1282,7 +1283,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {}).collect(),results: crate::timeline::result_index(&app.session.model.results),- reveal: app.tree.timeline_reveal.take(),+ reveal: app.tree.timeline_reveal,from_view,linked_hover: app.viewport.hover_feature.filter(|id| plan.referenced(*id)),drag: ui.data(|data| data.get_temp(drag_id)),@@ -1480,8 +1481,8 @@ fn feature_row(app: &mut SolveApp, ui: &mut egui::Ui, rows: &mut Rows, index: usNone => {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));+ if rows.reveal == Some(id) && crate::semantic_content::scroll_acknowledged(ui, rect) {+ app.tree.timeline_reveal = None;}}}