diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rs index 05fa2d986..414aac8ba 100644 --- a/crates/ui-egui/src/agent_chat/panel.rs +++ b/crates/ui-egui/src/agent_chat/panel.rs @@ -702,15 +702,7 @@ fn strip(app: &mut SolveApp, ui: &mut egui::Ui) { ui.painter().circle_filled(pos2(r.center().x, button.bottom() + 10.0), 3.5, state_color(state)); let waiting = app.agent_chat.waiting(); if waiting > 0 { - let at = button.right_top() + vec2(-3.0, 3.0); - ui.painter().circle_filled(at, 6.5, t.warning); - ui.painter().text( - at, - Align2::CENTER_CENTER, - waiting.min(9).to_string(), - egui::FontId::proportional(crate::theme::Tokens::get().font_badge), - t.panel, - ); + ui_kit::attention_mark(ui.painter(), button, Some(waiting)); } ui.painter().line_segment( if app.preferences.agent_chat_side == "left" { [r.right_top(), r.right_bottom()] } else { [r.left_top(), r.left_bottom()] }, diff --git a/crates/ui-egui/src/ui_kit/attention.rs b/crates/ui-egui/src/ui_kit/attention.rs new file mode 100644 index 000000000..2909679eb --- /dev/null +++ b/crates/ui-egui/src/ui_kit/attention.rs @@ -0,0 +1,29 @@ +//! One "needs attention" mark: something waits for the user (the agent chat's questions today; +//! other things that wait can use it too). A small count, or a plain dot, on the top-right +//! corner of what it belongs to. +use crate::theme::Tokens; +use egui::{Align2, Painter, Pos2, Rect, vec2}; + +/// Where the mark sits on `target` (a button's or icon's rect): `space_3` in from its top-right +/// corner. Tokens: space_3. +pub(crate) fn attention_at(target: Rect) -> Pos2 { + let t = Tokens::get(); + target.right_top() + vec2(-t.space_3, t.space_3) +} + +/// The mark on `target`: a count when there is one (at most 9 shown), else a plain dot. +/// Tokens: warning (the mark), panel (the count's ink), font_badge. +pub(crate) fn attention_mark(painter: &Painter, target: Rect, count: Option) { + let t = Tokens::get(); + let at = attention_at(target); + match count { + Some(n) => { + painter.circle_filled(at, 6.5, t.warning); + painter.text(at, Align2::CENTER_CENTER, n.min(9).to_string(), egui::FontId::proportional(t.font_badge), t.panel); + } + None => { + painter.circle_filled(at, 4.0, t.warning); + painter.circle_stroke(at, 4.0, egui::Stroke::new(1.0, t.panel)); + } + } +} diff --git a/crates/ui-egui/src/ui_kit/mod.rs b/crates/ui-egui/src/ui_kit/mod.rs index ce2248db9..b5b8ad519 100644 --- a/crates/ui-egui/src/ui_kit/mod.rs +++ b/crates/ui-egui/src/ui_kit/mod.rs @@ -4,6 +4,7 @@ mod actions; mod assistant; mod assistant_entry; +mod attention; mod checks; mod choice; mod color; @@ -57,6 +58,7 @@ pub(crate) use actions::*; pub use actions::{Button, button}; pub(crate) use assistant::*; pub(crate) use assistant_entry::*; +pub(crate) use attention::*; #[cfg(test)] pub(crate) use checks::tests::{raster as raster_ui, textures_update as update_test_textures}; #[cfg(test)]