diff --git a/crates/assistant2/src/assistant2.rs b/crates/assistant2/src/assistant2.rs index cee26a0830..ae5d9d6feb 100644 --- a/crates/assistant2/src/assistant2.rs +++ b/crates/assistant2/src/assistant2.rs @@ -595,7 +595,6 @@ impl AssistantChat { if self.editing_message_id() == Some(*id) { element.child(Composer::new( body.clone(), - self.user_store.read(cx).current_user(), self.project_index_button.clone(), crate::ui::ModelSelector::new( cx.view().downgrade(), @@ -773,7 +772,6 @@ impl Render for AssistantChat { .child(list(self.list_state.clone()).flex_1()) .child(Composer::new( self.composer_editor.clone(), - self.user_store.read(cx).current_user(), self.project_index_button.clone(), crate::ui::ModelSelector::new(cx.view().downgrade(), self.model.clone()) .into_any_element(), diff --git a/crates/assistant2/src/ui/composer.rs b/crates/assistant2/src/ui/composer.rs index b094b3e8ce..4bd75ecb68 100644 --- a/crates/assistant2/src/ui/composer.rs +++ b/crates/assistant2/src/ui/composer.rs @@ -1,16 +1,13 @@ use crate::{ui::ProjectIndexButton, AssistantChat, CompletionProvider}; -use client::User; use editor::{Editor, EditorElement, EditorStyle}; use gpui::{AnyElement, FontStyle, FontWeight, TextStyle, View, WeakView, WhiteSpace}; use settings::Settings; -use std::sync::Arc; use theme::ThemeSettings; -use ui::{popover_menu, prelude::*, Avatar, ButtonLike, ContextMenu, Tooltip}; +use ui::{popover_menu, prelude::*, ButtonLike, ContextMenu, Tooltip}; #[derive(IntoElement)] pub struct Composer { editor: View, - player: Option>, project_index_button: Option>, model_selector: AnyElement, } @@ -18,13 +15,11 @@ pub struct Composer { impl Composer { pub fn new( editor: View, - player: Option>, project_index_button: Option>, model_selector: AnyElement, ) -> Self { Self { editor, - player, project_index_button, model_selector, } @@ -41,72 +36,59 @@ impl Composer { impl RenderOnce for Composer { fn render(mut self, cx: &mut WindowContext) -> impl IntoElement { - let mut player_avatar = div().size(rems_from_px(20.)).into_any_element(); - if let Some(player) = self.player.clone() { - player_avatar = Avatar::new(player.avatar_uri.clone()) - .size(rems_from_px(20.)) - .into_any_element(); - } - let font_size = rems(0.875); let line_height = font_size.to_pixels(cx.rem_size()) * 1.3; - h_flex() - .w_full() - .items_start() - .mt_4() - .gap_3() - .child(player_avatar) - .child( - v_flex().size_full().gap_1().child( - v_flex() - .w_full() - .p_4() - .bg(cx.theme().colors().editor_background) - .rounded_lg() - .child( - v_flex() - .justify_between() - .w_full() - .gap_2() - .child({ - let settings = ThemeSettings::get_global(cx); - let text_style = TextStyle { - color: cx.theme().colors().editor_foreground, - font_family: settings.buffer_font.family.clone(), - font_features: settings.buffer_font.features.clone(), - font_size: font_size.into(), - font_weight: FontWeight::NORMAL, - font_style: FontStyle::Normal, - line_height: line_height.into(), - background_color: None, - underline: None, - strikethrough: None, - white_space: WhiteSpace::Normal, - }; + h_flex().w_full().items_start().mt_2().child( + v_flex().size_full().gap_1().child( + v_flex() + .w_full() + .p_3() + .bg(cx.theme().colors().editor_background) + .rounded_lg() + .child( + v_flex() + .justify_between() + .w_full() + .gap_2() + .child({ + let settings = ThemeSettings::get_global(cx); + let text_style = TextStyle { + color: cx.theme().colors().editor_foreground, + font_family: settings.buffer_font.family.clone(), + font_features: settings.buffer_font.features.clone(), + font_size: font_size.into(), + font_weight: FontWeight::NORMAL, + font_style: FontStyle::Normal, + line_height: line_height.into(), + background_color: None, + underline: None, + strikethrough: None, + white_space: WhiteSpace::Normal, + }; - EditorElement::new( - &self.editor, - EditorStyle { - background: cx.theme().colors().editor_background, - local_player: cx.theme().players().local(), - text: text_style, - ..Default::default() - }, - ) - }) - .child( - h_flex() - .flex_none() - .gap_2() - .justify_between() - .w_full() - .child(h_flex().gap_1().child(self.render_tools(cx))) - .child(h_flex().gap_1().child(self.model_selector)), - ), - ), - ), - ) + EditorElement::new( + &self.editor, + EditorStyle { + background: cx.theme().colors().editor_background, + local_player: cx.theme().players().local(), + text: text_style, + ..Default::default() + }, + ) + }) + .child( + h_flex() + .flex_none() + .gap_2() + .justify_between() + .w_full() + .child(h_flex().gap_1().child(self.render_tools(cx))) + .child(h_flex().gap_1().child(self.model_selector)), + ), + ), + ), + ) } } diff --git a/crates/assistant2/src/ui/project_index_button.rs b/crates/assistant2/src/ui/project_index_button.rs index a34a3639d8..6d7cb08187 100644 --- a/crates/assistant2/src/ui/project_index_button.rs +++ b/crates/assistant2/src/ui/project_index_button.rs @@ -34,7 +34,6 @@ impl ProjectIndexButton { } impl Render for ProjectIndexButton { - // Expanded information on ToolView fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { let status = self.project_index.read(cx).status(); let is_enabled = self.tool_registry.is_tool_enabled::(); @@ -82,13 +81,17 @@ impl Render for ProjectIndexButton { ) .tooltip({ move |cx| { - let (tooltip, meta) = match status { - Status::Idle => ( + let (tooltip, meta) = match (is_enabled, status) { + (false, _) => ( + "Project index disabled".to_string(), + Some("Click to enable".to_string()), + ), + (_, Status::Idle) => ( "Project index ready".to_string(), Some("Click to disable".to_string()), ), - Status::Loading => ("Project index loading...".to_string(), None), - Status::Scanning { remaining_count } => ( + (_, Status::Loading) => ("Project index loading...".to_string(), None), + (_, Status::Scanning { remaining_count }) => ( "Project index scanning...".to_string(), Some(format!("{} remaining...", remaining_count)), ),