Assistant: the agent list and the boxes under the switcher keep the panel's margin (#10172) (#10179)

* Assistant: the agent list and the boxes under the switcher keep the panel's margin (#10172)

The agent switcher above them sits in the panel's side margin, but what
the panel draws under it before a connection (the Agent row with Add
agent and Refresh, the agents found, what isn't installed, the New chat
confirmation and the sign-in box) started at the panel's very edge, and
Refresh was cut off at the right. They now keep the same side margin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Assistant: test that the agent list keeps the panel's side margin (#10172)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Assistant: the margin test passes the labels without a needless borrow (#10172)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
semmelrinde
2026-10-31 18:31:55 +00:00
committed by GitHub
parent 85197c1224
commit 6541a4e980
2 changed files with 56 additions and 12 deletions
+27 -12
View File
@@ -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| {
+29
View File
@@ -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;