diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs index 33027076effb12e45c58de274c7ff70b1dc9587f..7a4b8b02e20c6b7757ad1e7048c9c739d339f734 100644 --- a/crates/agent_ui/src/conversation_view.rs +++ b/crates/agent_ui/src/conversation_view.rs @@ -234,6 +234,10 @@ impl ProfileProvider for Entity { .model() .is_some_and(|model| model.supports_tools()) } + + fn model_selected(&self, cx: &App) -> bool { + self.read(cx).model().is_some() + } } #[derive(Default)] diff --git a/crates/agent_ui/src/profile_selector.rs b/crates/agent_ui/src/profile_selector.rs index a73f78b1a5a91a7cd564fd498ad3932019c18821..2b62b3121f80d0a3e9f463c71f2c0abf5a380e5b 100644 --- a/crates/agent_ui/src/profile_selector.rs +++ b/crates/agent_ui/src/profile_selector.rs @@ -7,7 +7,7 @@ use agent_settings::{ use fs::Fs; use fuzzy::{StringMatch, StringMatchCandidate, match_strings}; use gpui::{ - Action, AnyElement, AnyView, App, BackgroundExecutor, Context, DismissEvent, Entity, + Action, AnyElement, AnyView, App, BackgroundExecutor, Context, DismissEvent, Empty, Entity, FocusHandle, Focusable, ForegroundExecutor, SharedString, Subscription, Task, Window, }; use picker::{Picker, PickerDelegate, popover_menu::PickerPopoverMenu}; @@ -31,6 +31,9 @@ pub trait ProfileProvider { /// Check if profiles are supported in the current context (e.g. if the model that is selected has tool support) fn profiles_supported(&self, cx: &App) -> bool; + + /// Check if there is a model selected in the current context. + fn model_selected(&self, cx: &App) -> bool; } pub struct ProfileSelector { @@ -152,6 +155,10 @@ impl Focusable for ProfileSelector { impl Render for ProfileSelector { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + if !self.provider.model_selected(cx) { + return Empty.into_any_element(); + } + if !self.provider.profiles_supported(cx) { return Button::new("tools-not-supported-button", "Tools Unsupported") .disabled(true) @@ -792,11 +799,15 @@ mod tests { struct TestProfileProvider { profile_id: AgentProfileId, + has_model: bool, } impl TestProfileProvider { fn new(profile_id: AgentProfileId) -> Self { - Self { profile_id } + Self { + profile_id, + has_model: true, + } } } @@ -810,5 +821,9 @@ mod tests { fn profiles_supported(&self, _cx: &App) -> bool { true } + + fn model_selected(&self, _cx: &App) -> bool { + self.has_model + } } }