feat(domain,application,infrastructure,backend,web-server,app-tauri,frontend): lot utilisateur #325 #326 — icônes projet avec watermark CLI custom et localisation FR/EN (QA verte)
Lot en un seul commit: les deux features partagent les mêmes contrats (domain/settings.rs, DTO, commandes Tauri/HTTP, web-server) et les mêmes surfaces UI — la séparation par fichiers était impossible sans chirurgie de hunks risquant des états intermédiaires non compilables (convention lot des batches #310-#313 et #315). #325 — icône configurable par projet, watermark CLI custom: - domaine: ProjectIconSet (devicon, simple-icons, lucide, idea), ProjectIconRef validé (nom ASCII 1..=64, -_. internes), champ icon optionnel sur ProjectSettings; sérialisation camelCase et try_from strict - application: UpdateProjectSettings.execute accepte un patch theme_color OU icon (absent = inchangé, null = défaut produit), tests in-dependants avec store mémoire - backend/app-tauri/web-server: ProjectIconRefDto, UpdateProjectSettingsRequestDto avec icon optionnel (désérialisation additive), commandes update_project_settings alignées Tauri/HTTP, tests DTO et HTTP (défaut null, set, clear, nom invalide rejeté) - frontend: catalogue projectIcons (recherche EN), ProjectIconPicker en grille multi-lignes dans Paramètres projet, affichage de l'icône dans ProjectTabs et watermark grand format à faible opacité en fond de CLI custom; ports ProjectSettings.icon, Partial<ProjectSettings>, adapters tauri/mock/http et tests alignés #326 — localisation FR/EN et traduction des textes IdeA: - domaine: IdeaLanguage (fr | en), champ language optionnel sur IdeaUserSettings (absence = défaut produit, série additive validée) - backend/web-server: UserSettingsDto.language, update_user_settings accepte language, tests HTTP alignés; fixtures structured_launch_d3 mises à jour - frontend: i18n/ (catalogue FR/EN, I18nProvider, scan anti-régression des sources visibles), GeneralSettings avec sélecteur de langue dans les paramètres, setupI18n dans vitest; migration de l'ensemble des textes hardcodés vers le catalogue sur toutes les surfaces (agents, layout, projets, tickets, sprints, web, plugins, permissions, git, templates, skills, mémoire, model servers, embedder, first-run, devices, scheduled tasks, workstate, dialogs), FR conservé par défaut; recherche d'icônes #325 en anglais conformément au ticket QA verte sur feature/batch-325-326-project-icons-localisation. Aucun push.
This commit is contained in:
@ -267,7 +267,10 @@ pub use scheduled_task::{
|
||||
Weekday, MIN_SCHEDULE_INTERVAL_MINUTES,
|
||||
};
|
||||
|
||||
pub use settings::{DefaultAgentTerminalInterface, IdeaUserSettings, ProjectSettings, ThemeColor};
|
||||
pub use settings::{
|
||||
DefaultAgentTerminalInterface, IdeaLanguage, IdeaUserSettings, ProjectIconRef, ProjectIconSet,
|
||||
ProjectSettings, ThemeColor, MAX_PROJECT_ICON_NAME_LEN,
|
||||
};
|
||||
|
||||
pub use orchestrator::{
|
||||
OrchestratorCommand, OrchestratorError, OrchestratorRequest, OrchestratorVisibility,
|
||||
|
||||
@ -12,6 +12,16 @@ pub enum DefaultAgentTerminalInterface {
|
||||
IdeaCli,
|
||||
}
|
||||
|
||||
/// User-selected IdeA interface language.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum IdeaLanguage {
|
||||
/// French interface.
|
||||
Fr,
|
||||
/// English interface.
|
||||
En,
|
||||
}
|
||||
|
||||
/// Global, machine-local IdeA preferences.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -19,6 +29,83 @@ pub struct IdeaUserSettings {
|
||||
/// Default for newly launched human-facing agent terminals.
|
||||
#[serde(default)]
|
||||
pub default_agent_terminal_interface: Option<DefaultAgentTerminalInterface>,
|
||||
/// Preferred interface language. Absence preserves the product default.
|
||||
#[serde(default)]
|
||||
pub language: Option<IdeaLanguage>,
|
||||
}
|
||||
|
||||
/// Supported icon catalogue for project visual identity.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ProjectIconSet {
|
||||
/// Devicon language and platform catalogue.
|
||||
Devicon,
|
||||
/// Simple Icons brand catalogue.
|
||||
SimpleIcons,
|
||||
/// Lucide general-purpose icon catalogue.
|
||||
Lucide,
|
||||
/// IdeA-owned built-in icons.
|
||||
Idea,
|
||||
}
|
||||
|
||||
/// Maximum byte length of a stable project icon name.
|
||||
pub const MAX_PROJECT_ICON_NAME_LEN: usize = 64;
|
||||
|
||||
/// Validated reference to one icon in a known catalogue.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase", try_from = "UncheckedProjectIconRef")]
|
||||
pub struct ProjectIconRef {
|
||||
set: ProjectIconSet,
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct UncheckedProjectIconRef {
|
||||
set: ProjectIconSet,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl ProjectIconRef {
|
||||
/// Builds a validated stable icon reference.
|
||||
pub fn new(set: ProjectIconSet, name: impl Into<String>) -> Result<Self, String> {
|
||||
let name = name.into();
|
||||
let bytes = name.as_bytes();
|
||||
let valid_name = !name.is_empty()
|
||||
&& name.len() <= MAX_PROJECT_ICON_NAME_LEN
|
||||
&& bytes.first().is_some_and(u8::is_ascii_alphanumeric)
|
||||
&& bytes.last().is_some_and(u8::is_ascii_alphanumeric)
|
||||
&& bytes
|
||||
.iter()
|
||||
.copied()
|
||||
.all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'-' | b'_' | b'.'));
|
||||
if !valid_name {
|
||||
return Err(format!(
|
||||
"project icon name must be 1..={MAX_PROJECT_ICON_NAME_LEN} ASCII letters, digits, '-', '_' or '.', starting and ending with a letter or digit"
|
||||
));
|
||||
}
|
||||
Ok(Self { set, name })
|
||||
}
|
||||
|
||||
/// Returns the owning icon catalogue.
|
||||
#[must_use]
|
||||
pub const fn set(&self) -> ProjectIconSet {
|
||||
self.set
|
||||
}
|
||||
|
||||
/// Returns the stable catalogue icon name.
|
||||
#[must_use]
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<UncheckedProjectIconRef> for ProjectIconRef {
|
||||
type Error = String;
|
||||
|
||||
fn try_from(value: UncheckedProjectIconRef) -> Result<Self, Self::Error> {
|
||||
Self::new(value.set, value.name)
|
||||
}
|
||||
}
|
||||
|
||||
/// Strict project theme colour (`#RRGGBB`).
|
||||
@ -66,4 +153,7 @@ pub struct ProjectSettings {
|
||||
/// Optional visual theme colour; absence keeps the product fallback.
|
||||
#[serde(default)]
|
||||
pub theme_color: Option<ThemeColor>,
|
||||
/// Optional validated icon used as the project's visual identity.
|
||||
#[serde(default)]
|
||||
pub icon: Option<ProjectIconRef>,
|
||||
}
|
||||
|
||||
93
crates/domain/tests/settings.rs
Normal file
93
crates/domain/tests/settings.rs
Normal file
@ -0,0 +1,93 @@
|
||||
use domain::{
|
||||
DefaultAgentTerminalInterface, IdeaLanguage, IdeaUserSettings, ProjectIconRef, ProjectIconSet,
|
||||
ProjectSettings, ThemeColor, MAX_PROJECT_ICON_NAME_LEN,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn legacy_settings_documents_keep_additive_defaults() {
|
||||
let user: IdeaUserSettings =
|
||||
serde_json::from_str(r#"{"defaultAgentTerminalInterface":"ideaCli"}"#).unwrap();
|
||||
assert_eq!(
|
||||
user.default_agent_terminal_interface,
|
||||
Some(DefaultAgentTerminalInterface::IdeaCli)
|
||||
);
|
||||
assert_eq!(user.language, None);
|
||||
|
||||
let project: ProjectSettings = serde_json::from_str(r##"{"themeColor":"#123ABC"}"##).unwrap();
|
||||
assert_eq!(
|
||||
project.theme_color.as_ref().map(ThemeColor::as_str),
|
||||
Some("#123ABC")
|
||||
);
|
||||
assert_eq!(project.icon, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn language_roundtrips_as_stable_codes_and_rejects_unknown_values() {
|
||||
for (language, wire) in [(IdeaLanguage::Fr, "fr"), (IdeaLanguage::En, "en")] {
|
||||
let settings = IdeaUserSettings {
|
||||
default_agent_terminal_interface: None,
|
||||
language: Some(language),
|
||||
};
|
||||
let json = serde_json::to_string(&settings).unwrap();
|
||||
assert_eq!(
|
||||
serde_json::from_str::<serde_json::Value>(&json).unwrap()["language"],
|
||||
wire
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_str::<IdeaUserSettings>(&json).unwrap(),
|
||||
settings
|
||||
);
|
||||
}
|
||||
|
||||
assert!(serde_json::from_str::<IdeaUserSettings>(r#"{"language":"de"}"#).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_icon_roundtrips_for_every_known_set() {
|
||||
for (set, wire) in [
|
||||
(ProjectIconSet::Devicon, "devicon"),
|
||||
(ProjectIconSet::SimpleIcons, "simple-icons"),
|
||||
(ProjectIconSet::Lucide, "lucide"),
|
||||
(ProjectIconSet::Idea, "idea"),
|
||||
] {
|
||||
let settings = ProjectSettings {
|
||||
theme_color: None,
|
||||
icon: Some(ProjectIconRef::new(set, "arrow-up.circle_2").unwrap()),
|
||||
};
|
||||
let value = serde_json::to_value(&settings).unwrap();
|
||||
assert_eq!(value["icon"]["set"], wire);
|
||||
assert_eq!(value["icon"]["name"], "arrow-up.circle_2");
|
||||
assert_eq!(
|
||||
serde_json::from_value::<ProjectSettings>(value).unwrap(),
|
||||
settings
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_icon_rejects_unknown_sets_and_unstable_or_oversized_names() {
|
||||
assert!(
|
||||
serde_json::from_str::<ProjectIconRef>(r#"{"set":"font-awesome","name":"star"}"#).is_err()
|
||||
);
|
||||
|
||||
for invalid in [
|
||||
"",
|
||||
" leading",
|
||||
"two words",
|
||||
"étoile",
|
||||
"slash/name",
|
||||
".",
|
||||
"-star",
|
||||
"star-",
|
||||
] {
|
||||
assert!(
|
||||
ProjectIconRef::new(ProjectIconSet::Lucide, invalid).is_err(),
|
||||
"accepted {invalid:?}"
|
||||
);
|
||||
}
|
||||
assert!(ProjectIconRef::new(
|
||||
ProjectIconSet::Idea,
|
||||
"x".repeat(MAX_PROJECT_ICON_NAME_LEN + 1)
|
||||
)
|
||||
.is_err());
|
||||
}
|
||||
Reference in New Issue
Block a user