Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Browser rows truncate long names with an ellipsis and a tooltip; Solve Sketch is no longer offered in the UI (#3940)

bherbruck97383454c6f7
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs
index 2c95b6b441..c2d540f67c 100644
--- a/crates/ui-egui/src/browser.rs
+++ b/crates/ui-egui/src/browser.rs
@@ -428,9 +428,19 @@ pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp {
if row.selected { crate::theme::TabAccent::current(ui.ctx()).ink } else { row.color.unwrap_or(if row.dim { t.text_dim } else { t.text }) };
let label_display = if row.name { crate::i18n::tr_name(row.label) } else { crate::i18n::tr_dyn(row.label) };
let font = if row.selected { crate::fonts::semibold(t.font_label) } else { FontId::proportional(t.font_label) };
- let galley = ui.painter().layout_no_wrap(label_display, font, col);
+ // The label stops before the badges and the card's edge; a longer name ends in an ellipsis
+ // and its full text is in the tooltip.
+ let badges_width = row.badges.len() as f32 * 15.0;
+ let room = (r.right() - 4.0 - badges_width - x).max(0.0);
+ let mut job = egui::text::LayoutJob::simple(label_display.to_string(), font, col, room);
+ job.wrap.max_rows = 1;
+ job.wrap.break_anywhere = true;
+ job.wrap.overflow_character = Some('\u{2026}');
+ let galley = ui.painter().layout_job(job);
let lw = galley.size().x;
- ui.painter().galley(pos2(x, cy - galley.size().y / 2.0), galley, col);
+ let elided = galley.elided;
+ crate::scenario::publish_rect(&format!("row_label:{}", row.label), Rect::from_min_size(pos2(x, cy - galley.size().y / 2.0), galley.size()));
+ ui.painter().with_clip_rect(ui.painter().clip_rect().intersect(r)).galley(pos2(x, cy - galley.size().y / 2.0), galley, col);
let mut bx = (x + lw + 6.0).min(r.right() - 16.0);
for b in row.badges {
let br = Rect::from_center_size(pos2(bx + 6.0, cy), vec2(12.0, 12.0));
@@ -446,6 +456,7 @@ pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp {
};
let resp = match tip {
Some(t) => resp.on_hover_text(t),
+ None if elided => resp.on_hover_text(label_display.to_string()),
None => resp,
};
out.on_control = press_on != 0;
diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rs
index dc579ea63a..d3e72973b0 100644
--- a/crates/ui-egui/src/browser_card_tests.rs
+++ b/crates/ui-egui/src/browser_card_tests.rs
@@ -239,3 +239,16 @@ fn browser_width_rejects_hostile_preferences_and_tiny_windows_still_fit() {
assert!(available.contains_rect(bounds));
}
}
+
+#[test]
+fn a_long_body_name_stays_inside_the_card_and_ends_in_an_ellipsis() {
+ let mut h = Harness::new();
+ h.call("ui.resize", json!({"width":1400,"height":900}));
+ let name = "W".repeat(200);
+ h.app.run("solid.box", json!({"body_name":name, "operation":"new", "length":10, "width":10, "height":10})).unwrap();
+ h.settle();
+ let card = rect_of("browser:card").unwrap();
+ let label = rect_of(&format!("row_label:{name}")).expect("the body row is drawn");
+ assert!(label.right() <= card.right(), "{label:?} spills out of {card:?}");
+ assert!(label.width() > 100.0, "the name keeps the room it has: {label:?}");
+}
diff --git a/crates/ui-egui/src/shortcut_box.rs b/crates/ui-egui/src/shortcut_box.rs
index 1bf014ca13..2c7903aeec 100644
--- a/crates/ui-egui/src/shortcut_box.rs
+++ b/crates/ui-egui/src/shortcut_box.rs
@@ -136,6 +136,7 @@ pub fn search(app: &SolveApp, q: &str) -> Vec<Row> {
let q = q.trim().to_lowercase();
let mut v: Vec<(u32, Row)> = command_specs()
.into_iter()
+ .filter(|c| !crate::workspace::AGENT_ONLY.contains(&c.id))
.filter_map(|c| {
let (home_tab, home_panel) = crate::workspace::destination(c).unwrap_or(("", ""));
let (label, tab, panel) = (crate::i18n::tr_label(c.label), crate::i18n::tr_label(home_tab), crate::i18n::tr_label(home_panel));
@@ -658,6 +659,15 @@ mod tests {
assert_eq!((other.sbox.pinned.clone(), other.sbox.recent.len()), (vec!["solid.extrude".to_string()], 2));
}
+ #[test]
+ fn solve_sketch_is_not_offered_but_the_command_remains() {
+ let app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
+ for q in ["solve", "sketch.solve", ""] {
+ assert!(!search(&app, q).iter().any(|x| x.0 == "sketch.solve"), "{q:?}");
+ }
+ assert!(solidcraft_engine::find_command("sketch.solve").is_some(), "agents and MCP keep it");
+ }
+
/// The box shows each command's label and place in the current language, and finds a name
/// typed in that language, in English, or an id (#2544).
#[test]
diff --git a/crates/ui-egui/src/workspace.rs b/crates/ui-egui/src/workspace.rs
index 5fc377e900..3e9915170f 100644
--- a/crates/ui-egui/src/workspace.rs
+++ b/crates/ui-egui/src/workspace.rs
@@ -65,6 +65,10 @@ pub struct Section {
/// canonical home.
const CONFIGURE: &[&str] = &["parameters.change", "config.table", "config.configure"];
+/// Commands that stay for agents, MCP and scripts but are not offered to people: the sketch solves
+/// itself after every edit, so a Solve button (and the search hit for it) only confuses.
+pub const AGENT_ONLY: &[&str] = &["sketch.solve"];
+
pub const SECTIONS: &[Section] = &[
Section {
tab: "MODEL",