diff --git a/crates/acp_thread/src/connection.rs b/crates/acp_thread/src/connection.rs index 598d0428174eb2fc124739a18ddeff1098521cb7..5a3bcbccf7ec5253b37410d641c64d1e59ce2bc2 100644 --- a/crates/acp_thread/src/connection.rs +++ b/crates/acp_thread/src/connection.rs @@ -3,11 +3,11 @@ use agent_client_protocol::{self as acp}; use anyhow::Result; use collections::IndexMap; use gpui::{Entity, SharedString, Task}; -use language_model::LanguageModelProviderId; +use language_model::{IconOrSvg, LanguageModelProviderId}; use project::Project; use serde::{Deserialize, Serialize}; use std::{any::Any, error::Error, fmt, path::Path, rc::Rc, sync::Arc}; -use ui::{App, IconName}; +use ui::App; use uuid::Uuid; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)] @@ -210,21 +210,12 @@ pub trait AgentModelSelector: 'static { } } -/// Icon for a model in the model selector. -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum AgentModelIcon { - /// A built-in icon from Zed's icon set. - Named(IconName), - /// Path to a custom SVG icon file. - Path(SharedString), -} - #[derive(Debug, Clone, PartialEq, Eq)] pub struct AgentModelInfo { pub id: acp::ModelId, pub name: SharedString, pub description: Option, - pub icon: Option, + pub icon: Option, } impl From for AgentModelInfo { diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 9a8d3bfca6d20269e99af9f36da2e1696357c39c..824790042ef09240a80a6f5aefbb7f6f81d92857 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -18,7 +18,7 @@ pub use templates::*; pub use thread::*; pub use tools::*; -use acp_thread::{AcpThread, AgentModelIcon, AgentModelSelector, UserMessageId}; +use acp_thread::{AcpThread, AgentModelSelector, UserMessageId}; use agent_client_protocol as acp; use anyhow::{Context as _, Result, anyhow}; use chrono::{DateTime, Utc}; @@ -30,7 +30,7 @@ use futures::{StreamExt, future}; use gpui::{ App, AppContext, AsyncApp, Context, Entity, SharedString, Subscription, Task, WeakEntity, }; -use language_model::{IconOrSvg, LanguageModel, LanguageModelProvider, LanguageModelRegistry}; +use language_model::{LanguageModel, LanguageModelProvider, LanguageModelRegistry}; use project::{Project, ProjectItem, ProjectPath, Worktree}; use prompt_store::{ ProjectContext, PromptStore, RULES_FILE_NAMES, RulesFileContext, UserRulesContext, @@ -149,16 +149,11 @@ impl LanguageModels { model: &Arc, provider: &Arc, ) -> acp_thread::AgentModelInfo { - let icon = if let Some(path) = provider.icon_path() { - Some(AgentModelIcon::Path(path)) - } else { - Some(AgentModelIcon::Named(provider.icon())) - }; acp_thread::AgentModelInfo { id: Self::model_id(model), name: model.name().0, description: None, - icon, + icon: Some(provider.icon()), } } @@ -1635,7 +1630,7 @@ mod internal_tests { id: acp::ModelId::new("fake/fake"), name: "Fake".into(), description: None, - icon: Some(AgentModelIcon::Named(ui::IconName::ZedAssistant)), + icon: Some(language_model::IconOrSvg::Icon(ui::IconName::ZedAssistant)), }] )]) ); diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/acp/model_selector.rs index 903d5fe425d99389aae0e2a8028d9a31b986fbb3..9faab51d51dee4959c48ad1cb5b0560eaf054613 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/acp/model_selector.rs @@ -1,6 +1,6 @@ use std::{cmp::Reverse, rc::Rc, sync::Arc}; -use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelList, AgentModelSelector}; +use acp_thread::{AgentModelInfo, AgentModelList, AgentModelSelector}; use agent_client_protocol::ModelId; use agent_servers::AgentServer; use agent_settings::AgentSettings; @@ -13,6 +13,7 @@ use gpui::{ Action, AsyncWindowContext, BackgroundExecutor, DismissEvent, FocusHandle, Task, WeakEntity, }; use itertools::Itertools; +use language_model::IconOrSvg; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; use settings::Settings; @@ -351,8 +352,8 @@ impl PickerDelegate for AcpModelPickerDelegate { .child( ModelSelectorListItem::new(ix, model_info.name.clone()) .map(|this| match &model_info.icon { - Some(AgentModelIcon::Path(path)) => this.icon_path(path.clone()), - Some(AgentModelIcon::Named(icon)) => this.icon(*icon), + Some(IconOrSvg::Svg(path)) => this.icon_path(path.clone()), + Some(IconOrSvg::Icon(icon)) => this.icon(*icon), None => this, }) .is_selected(is_selected) diff --git a/crates/agent_ui/src/acp/model_selector_popover.rs b/crates/agent_ui/src/acp/model_selector_popover.rs index a15c01445dd8e9845f6744e795ed90a1ede6c7fc..5356edf61efc94b7b05e289918c3c723e241960a 100644 --- a/crates/agent_ui/src/acp/model_selector_popover.rs +++ b/crates/agent_ui/src/acp/model_selector_popover.rs @@ -1,11 +1,12 @@ use std::rc::Rc; use std::sync::Arc; -use acp_thread::{AgentModelIcon, AgentModelInfo, AgentModelSelector}; +use acp_thread::{AgentModelInfo, AgentModelSelector}; use agent_servers::AgentServer; use agent_settings::AgentSettings; use fs::Fs; use gpui::{Entity, FocusHandle}; +use language_model::IconOrSvg; use picker::popover_menu::PickerPopoverMenu; use settings::Settings as _; use ui::{ButtonLike, KeyBinding, PopoverMenuHandle, TintColor, Tooltip, prelude::*}; @@ -127,8 +128,8 @@ impl Render for AcpModelSelectorPopover { .when_some(model_icon, |this, icon| { this.child( match icon { - AgentModelIcon::Path(path) => Icon::from_external_svg(path), - AgentModelIcon::Named(icon_name) => Icon::new(icon_name), + IconOrSvg::Svg(path) => Icon::from_external_svg(path), + IconOrSvg::Icon(icon_name) => Icon::new(icon_name), } .color(color) .size(IconSize::XSmall),