- [x] Separate MCP servers from tools in the profile customization modal view - [x] Group MCP tools in the MCP picker and add a heading - [x] Separate bult-in profiles from custom ones in the dropdown selector - [x] Separate bult-in profiles from custom ones in the modal - [ ] Enable looping through items via keybinding without opening the dropdown (will be done on a follow-up PR) - [ ] Stretch: Focus on the currently active item upon opening the dropdown (will be done on a follow-up PR) Release Notes: - N/A --------- Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com> Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de> Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
78 lines
2.0 KiB
Rust
78 lines
2.0 KiB
Rust
use std::sync::Arc;
|
|
|
|
use gpui::SharedString;
|
|
use indexmap::IndexMap;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
pub mod builtin_profiles {
|
|
use super::AgentProfileId;
|
|
|
|
pub const WRITE: &str = "write";
|
|
pub const ASK: &str = "ask";
|
|
pub const MANUAL: &str = "manual";
|
|
|
|
pub fn is_builtin(profile_id: &AgentProfileId) -> bool {
|
|
profile_id.as_str() == WRITE || profile_id.as_str() == ASK || profile_id.as_str() == MANUAL
|
|
}
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct GroupedAgentProfiles {
|
|
pub builtin: IndexMap<AgentProfileId, AgentProfile>,
|
|
pub custom: IndexMap<AgentProfileId, AgentProfile>,
|
|
}
|
|
|
|
impl GroupedAgentProfiles {
|
|
pub fn from_settings(settings: &crate::AssistantSettings) -> Self {
|
|
let mut builtin = IndexMap::default();
|
|
let mut custom = IndexMap::default();
|
|
|
|
for (profile_id, profile) in settings.profiles.clone() {
|
|
if builtin_profiles::is_builtin(&profile_id) {
|
|
builtin.insert(profile_id, profile);
|
|
} else {
|
|
custom.insert(profile_id, profile);
|
|
}
|
|
}
|
|
|
|
Self { builtin, custom }
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, JsonSchema)]
|
|
pub struct AgentProfileId(pub Arc<str>);
|
|
|
|
impl AgentProfileId {
|
|
pub fn as_str(&self) -> &str {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for AgentProfileId {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|
|
|
|
impl Default for AgentProfileId {
|
|
fn default() -> Self {
|
|
Self("write".into())
|
|
}
|
|
}
|
|
|
|
/// A profile for the Zed Agent that controls its behavior.
|
|
#[derive(Debug, Clone)]
|
|
pub struct AgentProfile {
|
|
/// The name of the profile.
|
|
pub name: SharedString,
|
|
pub tools: IndexMap<Arc<str>, bool>,
|
|
pub enable_all_context_servers: bool,
|
|
pub context_servers: IndexMap<Arc<str>, ContextServerPreset>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
pub struct ContextServerPreset {
|
|
pub tools: IndexMap<Arc<str>, bool>,
|
|
}
|