Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
assistant2: Show the popover keybinding when context is empty (#22452)
Danilo Leal56b425fcedc3
diff --git a/crates/assistant2/src/context_strip.rs b/crates/assistant2/src/context_strip.rsindex efcb9862cc9..7d7bda8b357 100644--- a/crates/assistant2/src/context_strip.rs+++ b/crates/assistant2/src/context_strip.rs@@ -9,6 +9,7 @@ use crate::context_store::ContextStore;use crate::thread_store::ThreadStore;use crate::ui::ContextPill;use crate::ToggleContextPicker;+use settings::Settings;pub struct ContextStrip {context_store: Model<ContextStore>,@@ -45,7 +46,7 @@ impl ContextStrip {impl Render for ContextStrip {fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {- let context = self.context_store.read(cx).context();+ let context = self.context_store.read(cx).context().clone();let context_picker = self.context_picker.clone();let focus_handle = self.focus_handle.clone();@@ -76,6 +77,29 @@ impl Render for ContextStrip {}).with_handle(self.context_picker_menu_handle.clone()),)+ .when(context.is_empty(), {+ |parent| {+ parent.child(+ h_flex()+ .id("no-content-info")+ .ml_1p5()+ .gap_2()+ .font(theme::ThemeSettings::get_global(cx).buffer_font.clone())+ .text_size(TextSize::Small.rems(cx))+ .text_color(cx.theme().colors().text_muted)+ .child("Add Context")+ .children(+ ui::KeyBinding::for_action_in(+ &ToggleContextPicker,+ &self.focus_handle,+ cx,+ )+ .map(|binding| binding.into_any_element()),+ )+ .opacity(0.5),+ )+ }+ }).children(context.iter().map(|context| {ContextPill::new(context.clone()).on_remove({let context = context.clone();@@ -88,19 +112,21 @@ impl Render for ContextStrip {}))})}))- .when(!context.is_empty(), |parent| {- parent.child(- IconButton::new("remove-all-context", IconName::Eraser)- .icon_size(IconSize::Small)- .tooltip(move |cx| Tooltip::text("Remove All Context", cx))- .on_click({- let context_store = self.context_store.clone();- cx.listener(move |_this, _event, cx| {- context_store.update(cx, |this, _cx| this.clear());- cx.notify();- })- }),- )+ .when(!context.is_empty(), {+ move |parent| {+ parent.child(+ IconButton::new("remove-all-context", IconName::Eraser)+ .icon_size(IconSize::Small)+ .tooltip(move |cx| Tooltip::text("Remove All Context", cx))+ .on_click({+ let context_store = self.context_store.clone();+ cx.listener(move |_this, _event, cx| {+ context_store.update(cx, |this, _cx| this.clear());+ cx.notify();+ })+ }),+ )+ }})}}diff --git a/crates/assistant2/src/message_editor.rs b/crates/assistant2/src/message_editor.rsindex 2b8fcd8c0d2..3f31552e463 100644--- a/crates/assistant2/src/message_editor.rs+++ b/crates/assistant2/src/message_editor.rs@@ -54,7 +54,7 @@ impl MessageEditor {let editor = cx.new_view(|cx| {let mut editor = Editor::auto_height(10, cx);- editor.set_placeholder_text("Ask anything, @ to add context", cx);+ editor.set_placeholder_text("Ask anything…", cx);editor.set_show_indent_guides(false, cx);editor