Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add note about used context in the model selector (#15235)
Danilo Leal5e04753d1c7e
diff --git a/assets/icons/sliders-alt.svg b/assets/icons/sliders-alt.svgnew file mode 100644index 00000000000..36c3feccfed--- /dev/null+++ b/assets/icons/sliders-alt.svg@@ -0,0 +1,6 @@+<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M3 4H8" stroke="black" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/>+<path d="M6 10L11 10" stroke="black" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/>+<circle cx="4" cy="10" r="1.875" stroke="black" stroke-width="1.75"/>+<circle cx="10" cy="4" r="1.875" stroke="black" stroke-width="1.75"/>+</svg>diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rsindex 55c89f40285..307d2efe2c0 100644--- a/crates/assistant/src/inline_assistant.rs+++ b/crates/assistant/src/inline_assistant.rs@@ -1420,27 +1420,34 @@ impl Render for PromptEditor {.w(gutter_dimensions.full_width() + (gutter_dimensions.margin / 2.0)).justify_center().gap_2()- .child(ModelSelector::new(- self.fs.clone(),- IconButton::new("context", IconName::Settings)- .shape(IconButtonShape::Square)- .icon_size(IconSize::Small)- .icon_color(Color::Muted)- .tooltip(move |cx| {- Tooltip::with_meta(- format!(- "Using {}",- LanguageModelCompletionProvider::read_global(cx)- .active_model()- .map(|model| model.name().0)- .unwrap_or_else(|| "No model selected".into()),- ),- None,- "Change Model",- cx,- )- }),- ))+ .child(+ ModelSelector::new(+ self.fs.clone(),+ IconButton::new("context", IconName::SlidersAlt)+ .shape(IconButtonShape::Square)+ .icon_size(IconSize::Small)+ .icon_color(Color::Muted)+ .tooltip(move |cx| {+ Tooltip::with_meta(+ format!(+ "Using {}",+ LanguageModelCompletionProvider::read_global(cx)+ .active_model()+ .map(|model| model.name().0)+ .unwrap_or_else(|| "No model selected".into()),+ ),+ None,+ "Change Model",+ cx,+ )+ }),+ )+ .with_info_text(+ "Inline edits use context\n\+ from the currently selected\n\+ assistant panel tab.",+ ),+ ).children(if let CodegenStatus::Error(error) = &self.codegen.read(cx).status {let error_message = SharedString::from(error.to_string());diff --git a/crates/assistant/src/model_selector.rs b/crates/assistant/src/model_selector.rsindex 3847c7b29f5..fbf4eb7bd19 100644--- a/crates/assistant/src/model_selector.rs+++ b/crates/assistant/src/model_selector.rs@@ -2,6 +2,7 @@ use std::sync::Arc;use crate::{assistant_settings::AssistantSettings, LanguageModelCompletionProvider};use fs::Fs;+use gpui::SharedString;use language_model::LanguageModelRegistry;use settings::update_settings_file;use ui::{prelude::*, ContextMenu, PopoverMenu, PopoverMenuHandle, PopoverTrigger};@@ -11,6 +12,7 @@ pub struct ModelSelector<T: PopoverTrigger> {handle: Option<PopoverMenuHandle<ContextMenu>>,fs: Arc<dyn Fs>,trigger: T,+ info_text: Option<SharedString>,}impl<T: PopoverTrigger> ModelSelector<T> {@@ -19,6 +21,7 @@ impl<T: PopoverTrigger> ModelSelector<T> {handle: None,fs,trigger,+ info_text: None,}}@@ -26,6 +29,11 @@ impl<T: PopoverTrigger> ModelSelector<T> {self.handle = Some(handle);self}++ pub fn with_info_text(mut self, text: impl Into<SharedString>) -> Self {+ self.info_text = Some(text.into());+ self+ }}impl<T: PopoverTrigger> RenderOnce for ModelSelector<T> {@@ -35,8 +43,20 @@ impl<T: PopoverTrigger> RenderOnce for ModelSelector<T> {menu = menu.with_handle(handle);}+ let info_text = self.info_text.clone();+menu.menu(move |cx| {ContextMenu::build(cx, |mut menu, cx| {+ if let Some(info_text) = info_text.clone() {+ menu = menu+ .custom_row(move |_cx| {+ Label::new(info_text.clone())+ .color(Color::Muted)+ .into_any_element()+ })+ .separator();+ }+for (index, provider) in LanguageModelRegistry::global(cx).read(cx).providers()diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rsindex dd3db7e6dbe..c56c0415573 100644--- a/crates/ui/src/components/icon.rs+++ b/crates/ui/src/components/icon.rs@@ -228,6 +228,7 @@ pub enum IconName {Settings,Shift,Sliders,+ SlidersAlt,Snip,Space,Sparkle,@@ -382,6 +383,7 @@ impl IconName {IconName::Settings => "icons/file_icons/settings.svg",IconName::Shift => "icons/shift.svg",IconName::Sliders => "icons/sliders.svg",+ IconName::SlidersAlt => "icons/sliders-alt.svg",IconName::Snip => "icons/snip.svg",IconName::Space => "icons/space.svg",IconName::Sparkle => "icons/sparkle.svg",