From 1d9c581ae0694a8027e2070eb9c8ffe141c38b06 Mon Sep 17 00:00:00 2001
From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Date: Wed, 26 Mar 2025 10:03:06 -0300
Subject: [PATCH] assistant2: Use different icons in the notification popover
depending on status (#27493)
Using a check green icon for "success, you're changes are applied" and
the info, muted icon for just "there are news".
Release Notes:
- N/A
---
crates/assistant2/src/active_thread.rs | 20 ++++++++++++++++---
crates/assistant2/src/ui/tool_ready_pop_up.rs | 12 +++++++----
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/crates/assistant2/src/active_thread.rs b/crates/assistant2/src/active_thread.rs
index 27c29e3fa8..8e66ea4046 100644
--- a/crates/assistant2/src/active_thread.rs
+++ b/crates/assistant2/src/active_thread.rs
@@ -376,11 +376,23 @@ impl ActiveThread {
}
ThreadEvent::DoneStreaming => {
if !self.thread().read(cx).is_generating() {
- self.show_notification("Your changes have been applied.", window, cx);
+ self.show_notification(
+ "Your changes have been applied.",
+ IconName::Check,
+ Color::Success,
+ window,
+ cx,
+ );
}
}
ThreadEvent::ToolConfirmationNeeded => {
- self.show_notification("There's a tool confirmation needed.", window, cx);
+ self.show_notification(
+ "There's a tool confirmation needed.",
+ IconName::Info,
+ Color::Muted,
+ window,
+ cx,
+ );
}
ThreadEvent::StreamedAssistantText(message_id, text) => {
if let Some(rendered_message) = self.rendered_messages_by_id.get_mut(&message_id) {
@@ -511,6 +523,8 @@ impl ActiveThread {
fn show_notification(
&mut self,
caption: impl Into,
+ icon: IconName,
+ icon_color: Color,
window: &mut Window,
cx: &mut Context<'_, ActiveThread>,
) {
@@ -525,7 +539,7 @@ impl ActiveThread {
if let Some(screen_window) = cx
.open_window(options, |_, cx| {
- cx.new(|_| ToolReadyPopUp::new(caption.clone()))
+ cx.new(|_| ToolReadyPopUp::new(caption.clone(), icon, icon_color))
})
.log_err()
{
diff --git a/crates/assistant2/src/ui/tool_ready_pop_up.rs b/crates/assistant2/src/ui/tool_ready_pop_up.rs
index 4a43e29113..4fc0b3b2c1 100644
--- a/crates/assistant2/src/ui/tool_ready_pop_up.rs
+++ b/crates/assistant2/src/ui/tool_ready_pop_up.rs
@@ -9,12 +9,16 @@ use ui::{prelude::*, Render};
pub struct ToolReadyPopUp {
caption: SharedString,
+ icon: IconName,
+ icon_color: Color,
}
impl ToolReadyPopUp {
- pub fn new(caption: impl Into) -> Self {
+ pub fn new(caption: impl Into, icon: IconName, icon_color: Color) -> Self {
Self {
caption: caption.into(),
+ icon,
+ icon_color,
}
}
@@ -82,9 +86,9 @@ impl Render for ToolReadyPopUp {
.gap_2()
.child(
h_flex().h(line_height).justify_center().child(
- Icon::new(IconName::Info)
- .size(IconSize::Small)
- .color(Color::Muted),
+ Icon::new(self.icon)
+ .color(self.icon_color)
+ .size(IconSize::Small),
),
)
.child(