From 8b3eb98d8602e5f7d555f47add63aae11cb2939a Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Fri, 28 Mar 2025 19:34:16 -0300 Subject: [PATCH] assistant2: Adjust elements in the message editor (#27696) Most notable change in this PR is the changing the default profiles' names to just "Write" and "Ask". Everything else is mostly design-related. Here's how it looks like: Release Notes: - N/A --- assets/icons/user_round_pen.svg | 1 + assets/settings/default.json | 10 +-- crates/assistant2/src/profile_selector.rs | 74 ++++++++++++++--------- crates/assistant2/src/ui/context_pill.rs | 6 +- crates/icons/src/icons.rs | 1 + 5 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 assets/icons/user_round_pen.svg diff --git a/assets/icons/user_round_pen.svg b/assets/icons/user_round_pen.svg new file mode 100644 index 0000000000000000000000000000000000000000..e25bf104693bd5835a1d9065c4cb65cbad164c06 --- /dev/null +++ b/assets/icons/user_round_pen.svg @@ -0,0 +1 @@ + diff --git a/assets/settings/default.json b/assets/settings/default.json index 852fe1fdbcfa61836073c1d120a3f7020a6cbbd0..23ce584c96df9f631793debc519120db04e35b3c 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -633,10 +633,10 @@ // The model to use. "model": "claude-3-5-sonnet-latest" }, - "default_profile": "code-writer", + "default_profile": "write", "profiles": { - "read-only": { - "name": "Read-only", + "ask": { + "name": "Ask", "tools": { "diagnostics": true, "fetch": true, @@ -648,8 +648,8 @@ "thinking": true } }, - "code-writer": { - "name": "Code Writer", + "write": { + "name": "Write", "tools": { "bash": true, "batch-tool": true, diff --git a/crates/assistant2/src/profile_selector.rs b/crates/assistant2/src/profile_selector.rs index 762e5bee0d231a41cd0a1dfd497d7c5679d1dd8b..782773799f7e63a4910261839f47f98ed3f68ff2 100644 --- a/crates/assistant2/src/profile_selector.rs +++ b/crates/assistant2/src/profile_selector.rs @@ -5,7 +5,10 @@ use fs::Fs; use gpui::{prelude::*, Action, Entity, FocusHandle, Subscription, WeakEntity}; use indexmap::IndexMap; use settings::{update_settings_file, Settings as _, SettingsStore}; -use ui::{prelude::*, ContextMenu, ContextMenuEntry, PopoverMenu, PopoverMenuHandle, Tooltip}; +use ui::{ + prelude::*, ButtonLike, ContextMenu, ContextMenuEntry, KeyBinding, PopoverMenu, + PopoverMenuHandle, +}; use util::ResultExt as _; use crate::{ManageProfiles, ThreadStore, ToggleProfileSelector}; @@ -60,7 +63,7 @@ impl ProfileSelector { ) -> Entity { ContextMenu::build(window, cx, |mut menu, _window, cx| { let settings = AssistantSettings::get_global(cx); - let icon_position = IconPosition::Start; + let icon_position = IconPosition::End; menu = menu.header("Profiles"); for (profile_id, profile) in self.profiles.clone() { @@ -91,14 +94,11 @@ impl ProfileSelector { } menu = menu.separator(); - menu = menu.item( - ContextMenuEntry::new("Configure Profiles") - .icon(IconName::Pencil) - .icon_color(Color::Muted) - .handler(move |window, cx| { - window.dispatch_action(ManageProfiles.boxed_clone(), cx); - }), - ); + menu = menu.item(ContextMenuEntry::new("Configure Profiles").handler( + move |window, cx| { + window.dispatch_action(ManageProfiles.boxed_clone(), cx); + }, + )); menu }) @@ -106,33 +106,53 @@ impl ProfileSelector { } impl Render for ProfileSelector { - fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let settings = AssistantSettings::get_global(cx); - let profile = settings - .profiles - .get(&settings.default_profile) + let profile_id = &settings.default_profile; + let profile = settings.profiles.get(profile_id); + + let selected_profile = profile .map(|profile| profile.name.clone()) .unwrap_or_else(|| "Unknown".into()); + let icon = match profile_id.as_ref() { + "write" => IconName::Pencil, + "ask" => IconName::MessageBubbles, + _ => IconName::UserRoundPen, + }; + let this = cx.entity().clone(); let focus_handle = self.focus_handle.clone(); PopoverMenu::new("profile-selector") .menu(move |window, cx| { Some(this.update(cx, |this, cx| this.build_context_menu(window, cx))) }) - .trigger_with_tooltip( - Button::new("profile-selector-button", profile) - .style(ButtonStyle::Filled) - .label_size(LabelSize::Small), - move |window, cx| { - Tooltip::for_action_in( - "Change Profile", - &ToggleProfileSelector, - &focus_handle, - window, - cx, - ) - }, + .trigger( + ButtonLike::new("profile-selector-button").child( + h_flex() + .gap_1() + .child(Icon::new(icon).size(IconSize::XSmall).color(Color::Muted)) + .child( + Label::new(selected_profile) + .size(LabelSize::Small) + .color(Color::Muted), + ) + .child( + Icon::new(IconName::ChevronDown) + .size(IconSize::XSmall) + .color(Color::Muted), + ) + .child(div().opacity(0.5).children({ + let focus_handle = focus_handle.clone(); + KeyBinding::for_action_in( + &ToggleProfileSelector, + &focus_handle, + window, + cx, + ) + .map(|kb| kb.size(rems_from_px(10.))) + })), + ), ) .anchor(gpui::Corner::BottomLeft) .with_handle(self.menu_handle.clone()) diff --git a/crates/assistant2/src/ui/context_pill.rs b/crates/assistant2/src/ui/context_pill.rs index d2ec1d625f60531895dc7ea3bfd588bef0ff6ef4..bc37583a2f35ea466caf3abcad3542472901b584 100644 --- a/crates/assistant2/src/ui/context_pill.rs +++ b/crates/assistant2/src/ui/context_pill.rs @@ -175,10 +175,14 @@ impl RenderOnce for ContextPill { } => base_pill .cursor_pointer() .pr_1() + .when(*focused, |this| { + this.bg(color.element_background.opacity(0.5)) + }) + .border_dashed() .border_color(if *focused { color.border_focused } else { - color.border_variant.opacity(0.5) + color.border }) .hover(|style| style.bg(color.element_hover.opacity(0.5))) .child( diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs index 3f91caae68fc9419fc6a8541be7074b98c797708..31224cb37b77e21f8b38751b5386a2198b4c8f6c 100644 --- a/crates/icons/src/icons.rs +++ b/crates/icons/src/icons.rs @@ -225,6 +225,7 @@ pub enum IconName { Unpin, Update, UserGroup, + UserRoundPen, Visible, Wand, Warning,