@@ -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<Self>) -> 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
+ }
}
}