feat: finalise multi-profil Codex/Claude avec catalogue de modèles
- Backend : clone_profile_from_seed généralisé (non OpenCode) - Backend : catalogue static Claude/Codex (3 modèles chacun, 1 recommandé) - Backend : commandes Tauri list_claude_models/list_codex_models - Frontend : ProfilesSettings refonte en onglets Codex/Claude + create/duplicate/edit/delete - Frontend : ModelSelect searchable partagé + fallback saisie manuelle - Frontend : assignation agent nom · modèle - Tests QA : 4 profils modèles distincts (2 Claude, 2 Codex) assignés à agents
This commit is contained in:
@ -146,6 +146,92 @@ pub struct SaveProfileOutput {
|
||||
pub profile: AgentProfile,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CloneProfileFromSeed
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Input for [`CloneProfileFromSeed::execute`].
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CloneProfileFromSeedInput {
|
||||
/// Id of the persisted or reference profile to clone.
|
||||
pub seed_profile_id: ProfileId,
|
||||
/// Optional display name for the cloned profile. When absent, a copy label is
|
||||
/// derived from the seed name.
|
||||
pub name: Option<String>,
|
||||
/// Optional model override. When absent, the seed model is copied as-is.
|
||||
pub model: Option<String>,
|
||||
}
|
||||
|
||||
/// Output of [`CloneProfileFromSeed::execute`].
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CloneProfileFromSeedOutput {
|
||||
/// The newly persisted profile.
|
||||
pub profile: AgentProfile,
|
||||
}
|
||||
|
||||
/// Creates a new profile instance from an existing persisted/reference seed.
|
||||
///
|
||||
/// Persisted profiles are preferred over reference seeds so user edits to the
|
||||
/// seed are preserved. The clone always receives a fresh [`ProfileId`] from the
|
||||
/// backend [`IdGenerator`]; callers can override the display name and model
|
||||
/// without minting ids client-side.
|
||||
pub struct CloneProfileFromSeed {
|
||||
store: Arc<dyn ProfileStore>,
|
||||
ids: Arc<dyn IdGenerator>,
|
||||
}
|
||||
|
||||
impl CloneProfileFromSeed {
|
||||
/// Builds the use case from the profile store and id generator ports.
|
||||
#[must_use]
|
||||
pub fn new(store: Arc<dyn ProfileStore>, ids: Arc<dyn IdGenerator>) -> Self {
|
||||
Self { store, ids }
|
||||
}
|
||||
|
||||
/// Clones the requested seed into a new persisted profile.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`AppError::NotFound`] if no persisted/reference profile has the seed id,
|
||||
/// [`AppError::Invalid`] if `name` or `model` is blank, [`AppError::Store`]
|
||||
/// on persistence failure.
|
||||
pub async fn execute(
|
||||
&self,
|
||||
input: CloneProfileFromSeedInput,
|
||||
) -> Result<CloneProfileFromSeedOutput, AppError> {
|
||||
let existing = self.store.list().await?;
|
||||
let seed = existing
|
||||
.iter()
|
||||
.find(|profile| profile.id == input.seed_profile_id)
|
||||
.cloned()
|
||||
.or_else(|| {
|
||||
reference_profiles()
|
||||
.into_iter()
|
||||
.find(|profile| profile.id == input.seed_profile_id)
|
||||
})
|
||||
.ok_or(AppError::NotFound("profile seed not found".into()))?;
|
||||
|
||||
let mut profile = seed;
|
||||
profile.id = fresh_profile_id(&*self.ids, &existing)?;
|
||||
profile.name = match input.name {
|
||||
Some(name) => {
|
||||
if name.trim().is_empty() {
|
||||
return Err(AppError::Invalid("profile.name must not be empty".into()));
|
||||
}
|
||||
name
|
||||
}
|
||||
None => format!("{} copy", profile.name),
|
||||
};
|
||||
if let Some(model) = input.model {
|
||||
if model.trim().is_empty() {
|
||||
return Err(AppError::Invalid("profile.model must not be empty".into()));
|
||||
}
|
||||
profile.model = Some(model);
|
||||
}
|
||||
|
||||
self.store.save(&profile).await?;
|
||||
Ok(CloneProfileFromSeedOutput { profile })
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CloneOpenCodeProfileFromSeed
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user