agent: Add newtype for profile IDs (#27939)

This PR adds an `AgentProfileId` newtype for profile IDs that we can use
instead of `Arc<str>` everywhere.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-04-02 13:12:52 -04:00 committed by GitHub
parent b2904e5d9f
commit 646f65511c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 59 additions and 27 deletions

View file

@ -2,6 +2,29 @@ use std::sync::Arc;
use gpui::SharedString;
use indexmap::IndexMap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[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)]