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:

<img
src="https://github.com/user-attachments/assets/791948c9-2d63-4523-9d54-08b63a00be6a"
width="600" />

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-03-28 19:34:16 -03:00 committed by GitHub
parent d912b0dd36
commit 8b3eb98d86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 59 additions and 33 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user-round-pen-icon lucide-user-round-pen"><path d="M2 21a8 8 0 0 1 10.821-7.487"/><path d="M21.378 16.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"/><circle cx="10" cy="8" r="5"/></svg>

After

Width:  |  Height:  |  Size: 461 B

View file

@ -633,10 +633,10 @@
// The model to use. // The model to use.
"model": "claude-3-5-sonnet-latest" "model": "claude-3-5-sonnet-latest"
}, },
"default_profile": "code-writer", "default_profile": "write",
"profiles": { "profiles": {
"read-only": { "ask": {
"name": "Read-only", "name": "Ask",
"tools": { "tools": {
"diagnostics": true, "diagnostics": true,
"fetch": true, "fetch": true,
@ -648,8 +648,8 @@
"thinking": true "thinking": true
} }
}, },
"code-writer": { "write": {
"name": "Code Writer", "name": "Write",
"tools": { "tools": {
"bash": true, "bash": true,
"batch-tool": true, "batch-tool": true,

View file

@ -5,7 +5,10 @@ use fs::Fs;
use gpui::{prelude::*, Action, Entity, FocusHandle, Subscription, WeakEntity}; use gpui::{prelude::*, Action, Entity, FocusHandle, Subscription, WeakEntity};
use indexmap::IndexMap; use indexmap::IndexMap;
use settings::{update_settings_file, Settings as _, SettingsStore}; 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 util::ResultExt as _;
use crate::{ManageProfiles, ThreadStore, ToggleProfileSelector}; use crate::{ManageProfiles, ThreadStore, ToggleProfileSelector};
@ -60,7 +63,7 @@ impl ProfileSelector {
) -> Entity<ContextMenu> { ) -> Entity<ContextMenu> {
ContextMenu::build(window, cx, |mut menu, _window, cx| { ContextMenu::build(window, cx, |mut menu, _window, cx| {
let settings = AssistantSettings::get_global(cx); let settings = AssistantSettings::get_global(cx);
let icon_position = IconPosition::Start; let icon_position = IconPosition::End;
menu = menu.header("Profiles"); menu = menu.header("Profiles");
for (profile_id, profile) in self.profiles.clone() { for (profile_id, profile) in self.profiles.clone() {
@ -91,14 +94,11 @@ impl ProfileSelector {
} }
menu = menu.separator(); menu = menu.separator();
menu = menu.item( menu = menu.item(ContextMenuEntry::new("Configure Profiles").handler(
ContextMenuEntry::new("Configure Profiles") move |window, cx| {
.icon(IconName::Pencil) window.dispatch_action(ManageProfiles.boxed_clone(), cx);
.icon_color(Color::Muted) },
.handler(move |window, cx| { ));
window.dispatch_action(ManageProfiles.boxed_clone(), cx);
}),
);
menu menu
}) })
@ -106,33 +106,53 @@ impl ProfileSelector {
} }
impl Render for ProfileSelector { impl Render for ProfileSelector {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement { fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let settings = AssistantSettings::get_global(cx); let settings = AssistantSettings::get_global(cx);
let profile = settings let profile_id = &settings.default_profile;
.profiles let profile = settings.profiles.get(profile_id);
.get(&settings.default_profile)
let selected_profile = profile
.map(|profile| profile.name.clone()) .map(|profile| profile.name.clone())
.unwrap_or_else(|| "Unknown".into()); .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 this = cx.entity().clone();
let focus_handle = self.focus_handle.clone(); let focus_handle = self.focus_handle.clone();
PopoverMenu::new("profile-selector") PopoverMenu::new("profile-selector")
.menu(move |window, cx| { .menu(move |window, cx| {
Some(this.update(cx, |this, cx| this.build_context_menu(window, cx))) Some(this.update(cx, |this, cx| this.build_context_menu(window, cx)))
}) })
.trigger_with_tooltip( .trigger(
Button::new("profile-selector-button", profile) ButtonLike::new("profile-selector-button").child(
.style(ButtonStyle::Filled) h_flex()
.label_size(LabelSize::Small), .gap_1()
move |window, cx| { .child(Icon::new(icon).size(IconSize::XSmall).color(Color::Muted))
Tooltip::for_action_in( .child(
"Change Profile", Label::new(selected_profile)
&ToggleProfileSelector, .size(LabelSize::Small)
&focus_handle, .color(Color::Muted),
window, )
cx, .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) .anchor(gpui::Corner::BottomLeft)
.with_handle(self.menu_handle.clone()) .with_handle(self.menu_handle.clone())

View file

@ -175,10 +175,14 @@ impl RenderOnce for ContextPill {
} => base_pill } => base_pill
.cursor_pointer() .cursor_pointer()
.pr_1() .pr_1()
.when(*focused, |this| {
this.bg(color.element_background.opacity(0.5))
})
.border_dashed()
.border_color(if *focused { .border_color(if *focused {
color.border_focused color.border_focused
} else { } else {
color.border_variant.opacity(0.5) color.border
}) })
.hover(|style| style.bg(color.element_hover.opacity(0.5))) .hover(|style| style.bg(color.element_hover.opacity(0.5)))
.child( .child(

View file

@ -225,6 +225,7 @@ pub enum IconName {
Unpin, Unpin,
Update, Update,
UserGroup, UserGroup,
UserRoundPen,
Visible, Visible,
Wand, Wand,
Warning, Warning,