SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Assistant: the agent list and the boxes under the switcher keep the panel's margin (#10172) (#10179)
semmelrinde6541a4e980c9
diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rsindex 5d3df95b9a..d1a94f2a0e 100644--- a/crates/ui-egui/src/agent_chat/panel.rs+++ b/crates/ui-egui/src/agent_chat/panel.rs@@ -804,17 +804,19 @@ fn desktop_body(app: &mut SolveApp, ui: &mut egui::Ui) {let state = app.agent_chat.state();if app.agent_chat.confirm_new {ui_kit::scope(ui, |ui| {- ui.set_width(ui.available_width());- ui_kit::text(ui, tr("ui.agent_chat_new_confirm"), ui_kit::Text::Report("new_chat", false));- ui.horizontal(|ui| {- let yes = ui_kit::button(ui, tr("ui.agent_chat_new"), ui_kit::Button::Normal);- crate::scenario::publish_handle("agent_chat:new_confirm", yes.rect.center());- if yes.clicked() {- new_chat(app);- }- if ui_kit::button(ui, tr("ui.agent_chat_cancel"), ui_kit::Button::Normal).clicked() {- app.agent_chat.confirm_new = false;- }+ inset(ui, |ui| {+ ui.set_width(ui.available_width());+ ui_kit::text(ui, tr("ui.agent_chat_new_confirm"), ui_kit::Text::Report("new_chat", false));+ ui.horizontal(|ui| {+ let yes = ui_kit::button(ui, tr("ui.agent_chat_new"), ui_kit::Button::Normal);+ crate::scenario::publish_handle("agent_chat:new_confirm", yes.rect.center());+ if yes.clicked() {+ new_chat(app);+ }+ if ui_kit::button(ui, tr("ui.agent_chat_cancel"), ui_kit::Button::Normal).clicked() {+ app.agent_chat.confirm_new = false;+ }+ });});});}@@ -826,7 +828,7 @@ fn desktop_body(app: &mut SolveApp, ui: &mut egui::Ui) {.auto_shrink([false, true]).show(ui, |ui| picker(app, ui));if state == State::NeedsAuth {- auth_box(app, ui);+ inset(ui, |ui| auth_box(app, ui));}// The input sits at the bottom of the panel and grows upwards: a long message makes its box// taller up to `edit_max`, then it scrolls, and the conversation takes what is left above. It@@ -1444,6 +1446,13 @@ mod config_ui_tests {}}+/// What is drawn under the agent switcher keeps the switcher's side margin (#10172): it starts+/// where the switcher's fields start, not at the panel's edge.+#[cfg(not(target_arch = "wasm32"))]+fn inset<R>(ui: &mut egui::Ui, add: impl FnOnce(&mut egui::Ui) -> R) -> R {+ egui::Frame::NONE.inner_margin(egui::Margin::symmetric(Tokens::get().space_12 as i8, 0)).show(ui, add).inner+}+/// Before the first connection: what's installed, how to install the rest, and Add agent.#[cfg(not(target_arch = "wasm32"))]fn picker(app: &mut SolveApp, ui: &mut egui::Ui) {@@ -1451,6 +1460,12 @@ fn picker(app: &mut SolveApp, ui: &mut egui::Ui) {if !open {return;}+ inset(ui, |ui| agent_list(app, ui));+}++/// [`picker`]'s content: the agents found, Refresh and Add agent, and what isn't installed.+#[cfg(not(target_arch = "wasm32"))]+fn agent_list(app: &mut SolveApp, ui: &mut egui::Ui) {let all = agents::entries(app);let current = agents::current(app);ui.horizontal(|ui| {diff --git a/crates/ui-egui/src/agent_chat/tests.rs b/crates/ui-egui/src/agent_chat/tests.rsindex 79261a31d7..9277669437 100644--- a/crates/ui-egui/src/agent_chat/tests.rs+++ b/crates/ui-egui/src/agent_chat/tests.rs@@ -2236,6 +2236,35 @@ fn narrow_chat() -> crate::scenario::Harness {h}+/// #10172: before a connection, what the panel draws under the agent switcher (the Agent row+/// with Add agent and Refresh) keeps the panel's side margin, docked and floating: nothing starts+/// at the panel's edge or is cut off at the other one.+#[test]+fn the_agent_list_keeps_the_panels_side_margin() {+ use crate::shell::LayoutMode;+ for layout in [LayoutMode::Docked, LayoutMode::Floating] {+ let mut h = narrow_chat();+ h.app.ui.layout = layout;+ h.frames(3);+ h.frame();+ let panel = crate::scenario::rect_of("agent_chat:panel").expect("the panel");+ let mut texts = Vec::new();+ for clipped in &h.shapes {+ crate::test_support::each_shape(&clipped.shape, &mut |s| {+ if let egui::Shape::Text(t) = s {+ texts.push((t.galley.text().to_string(), egui::Rect::from_min_size(t.pos, t.galley.rect.size())));+ }+ });+ }+ let at = |label: &str| texts.iter().find(|(text, r)| text == label && panel.contains(r.center())).map(|(_, r)| *r);+ let margin = crate::theme::Tokens::get().space_12 - 0.5;+ let agent = at(tr("ui.agent_chat_pick")).expect("the Agent row");+ assert!(agent.left() >= panel.left() + margin, "{layout:?}: Agent at {agent:?} in {panel:?}");+ let refresh = at(tr("ui.agent_chat_refresh")).expect("Refresh");+ assert!(refresh.right() <= panel.right() - margin, "{layout:?}: Refresh at {refresh:?} in {panel:?}");+ }+}+/// Every chip and the text box sit inside the panel.fn assert_inside_the_panel(chips: usize) {use crate::scenario::rect_of;