feat(backend,frontend): lot utilisateur #310 #311 #312 #313 — horodatage conversation, stop agent robuste, préférence terminal par défaut, paramètres projet (QA verte)

- #310: horodatage de tous les messages et événements de conversation visibles — composant partagé EntryTimestamp, timestamps propagés dans le transcript chat, les annonces inter-agent et le viewer de conversation, normalisation côté domain/adapters (conversation_log, paginate).
- #311: stop d'agent robuste pour PTY non monté, sessions headless et CLI custom — lifecycle/orchestrator durcis, ponts chat app-tauri/web-server alignés, arrêt fiable sans session orpheline.
- #312: préférence globale d'interface terminal par défaut — nouveau store settings (domain/application/infrastructure + tests), DTO et commandes backend, adapter frontend userSettings, panneau TerminalSettings dans les paramètres globaux.
- #313: Paramètres du projet — contexte de projet éditable et couleur de thème par projet (ProjectSettingsPanel + projectTheme), teinte des onglets projet, persistance via DTO projet.

QA verte (GO QA sur feature/batch-310-311-312-313-chat-stop-prefs-theme) — vérifications Git: git diff --cached --check OK; staging borné à crates/ et frontend/ (74 fichiers, +2105/-531), commit unique de lot conforme à la convention des lots (précédents batch-151/158/159, batch-210/211/212) car les fichiers partagés (dto.rs, commands.rs, CustomAgentChatView) entrelacent les 4 tickets.

fichiers .ideai/* (agents/test.md, chat-drafts.json, system-permissions.json, tickets/counter.json, tickets/index.json, tickets/308-313/), attachments/ et scripts/ hors périmètre et préservés en worktree ; aucun push.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-09-10 21:26:16 +02:00
parent fc45594d9a
commit 402a60f213
74 changed files with 2105 additions and 531 deletions

View File

@ -120,8 +120,9 @@ pub use store::{
AdaptiveMemoryRecall, BackgroundTaskReconcileReport, EmbedderEnvProbe, FsBackgroundTaskStore,
FsDeviceSessionStore, FsEmbedderProfileStore, FsEmbedderPromptStore, FsLiveStateStore,
FsMcpToolPermissionStore, FsMemoryStore, FsOpenProjectRestoreStore, FsPermissionStore,
FsProfileStore, FsProjectStore, FsSecretStore, FsSkillStore, FsSystemPermissionStore,
FsTemplateStore, FsWindowStateStore, HashEmbedder, IdeaiContextStore, NaiveMemoryRecall,
OnnxModelInfo, StubEmbedder, VectorMemoryRecall, DEFAULT_OLLAMA_BASE_URL, ONNX_CACHE_SUBDIR,
RECOMMENDED_ONNX_MODELS, VECTOR_HTTP_ENABLED, VECTOR_ONNX_ENABLED,
FsProfileStore, FsProjectSettingsStore, FsProjectStore, FsSecretStore, FsSkillStore,
FsSystemPermissionStore, FsTemplateStore, FsUserSettingsStore, FsWindowStateStore,
HashEmbedder, IdeaiContextStore, NaiveMemoryRecall, OnnxModelInfo, StubEmbedder,
VectorMemoryRecall, DEFAULT_OLLAMA_BASE_URL, ONNX_CACHE_SUBDIR, RECOMMENDED_ONNX_MODELS,
VECTOR_HTTP_ENABLED, VECTOR_ONNX_ENABLED,
};

View File

@ -17,6 +17,7 @@ mod profile;
mod project;
mod project_plugin;
mod secrets;
mod settings;
mod skill;
mod system_permission;
mod template;
@ -44,6 +45,7 @@ pub use profile::{FsEmbedderProfileStore, FsProfileStore};
pub use project::FsProjectStore;
pub use project_plugin::FsProjectPluginSettingsStore;
pub use secrets::FsSecretStore;
pub use settings::{FsProjectSettingsStore, FsUserSettingsStore};
pub use skill::FsSkillStore;
pub use system_permission::FsSystemPermissionStore;
pub use template::FsTemplateStore;

View File

@ -0,0 +1,104 @@
//! JSON persistence for global user settings and project-owned settings.
use async_trait::async_trait;
use domain::{
FileSystem, FsError, IdeaUserSettings, ProjectPath, ProjectSettings, ProjectSettingsStore,
RemotePath, StoreError, UserSettingsStore,
};
use std::sync::Arc;
#[derive(Clone)]
/// File-backed global user-settings adapter.
pub struct FsUserSettingsStore {
fs: Arc<dyn FileSystem>,
app_data_dir: String,
}
impl FsUserSettingsStore {
/// Builds an adapter rooted in the machine-local application data directory.
#[must_use]
pub fn new(fs: Arc<dyn FileSystem>, app_data_dir: impl Into<String>) -> Self {
Self {
fs,
app_data_dir: app_data_dir.into(),
}
}
fn path(&self) -> RemotePath {
RemotePath::new(format!(
"{}/settings.json",
self.app_data_dir.trim_end_matches(['/', '\\'])
))
}
}
#[async_trait]
impl UserSettingsStore for FsUserSettingsStore {
async fn load(&self) -> Result<IdeaUserSettings, StoreError> {
match self.fs.read(&self.path()).await {
Ok(bytes) => {
serde_json::from_slice(&bytes).map_err(|e| StoreError::Serialization(e.to_string()))
}
Err(FsError::NotFound(_)) => Ok(IdeaUserSettings::default()),
Err(error) => Err(StoreError::Io(error.to_string())),
}
}
async fn save(&self, settings: &IdeaUserSettings) -> Result<(), StoreError> {
self.fs
.create_dir_all(&RemotePath::new(self.app_data_dir.clone()))
.await
.map_err(|e| StoreError::Io(e.to_string()))?;
let mut bytes = serde_json::to_vec_pretty(settings)
.map_err(|e| StoreError::Serialization(e.to_string()))?;
bytes.push(b'\n');
self.fs
.write(&self.path(), &bytes)
.await
.map_err(|e| StoreError::Io(e.to_string()))
}
}
#[derive(Clone)]
/// File-backed project-settings adapter.
pub struct FsProjectSettingsStore {
fs: Arc<dyn FileSystem>,
}
impl FsProjectSettingsStore {
/// Builds an adapter over the location-neutral filesystem port.
#[must_use]
pub fn new(fs: Arc<dyn FileSystem>) -> Self {
Self { fs }
}
fn path(root: &ProjectPath) -> RemotePath {
RemotePath::new(format!(
"{}/.ideai/project-settings.json",
root.as_str().trim_end_matches(['/', '\\'])
))
}
}
#[async_trait]
impl ProjectSettingsStore for FsProjectSettingsStore {
async fn load(&self, root: &ProjectPath) -> Result<ProjectSettings, StoreError> {
match self.fs.read(&Self::path(root)).await {
Ok(bytes) => {
serde_json::from_slice(&bytes).map_err(|e| StoreError::Serialization(e.to_string()))
}
Err(FsError::NotFound(_)) => Ok(ProjectSettings::default()),
Err(error) => Err(StoreError::Io(error.to_string())),
}
}
async fn save(&self, root: &ProjectPath, settings: &ProjectSettings) -> Result<(), StoreError> {
let dir = RemotePath::new(format!(
"{}/.ideai",
root.as_str().trim_end_matches(['/', '\\'])
));
self.fs
.create_dir_all(&dir)
.await
.map_err(|e| StoreError::Io(e.to_string()))?;
let mut bytes = serde_json::to_vec_pretty(settings)
.map_err(|e| StoreError::Serialization(e.to_string()))?;
bytes.push(b'\n');
self.fs
.write(&Self::path(root), &bytes)
.await
.map_err(|e| StoreError::Io(e.to_string()))
}
}

View File

@ -133,6 +133,26 @@ async fn append_writes_one_valid_json_line_per_turn() {
}
}
#[tokio::test]
async fn legacy_line_without_timestamp_remains_readable_without_backfill() {
let tmp = TempDir::new();
let c = conv_id(91);
std::fs::create_dir_all(tmp.conversation_dir(c)).unwrap();
let raw = format!(
"{{\"id\":\"{}\",\"conversation\":\"{}\",\"source\":{{\"kind\":\"human\"}},\"role\":\"prompt\",\"text\":\"legacy\"}}\n",
turn_id(1), c
);
std::fs::write(tmp.log_path(c), &raw).unwrap();
let turns = FsConversationLog::new(&tmp.project_path())
.read(c, None)
.await
.unwrap();
assert_eq!(turns.len(), 1);
assert_eq!(turns[0].at_ms, None);
assert_eq!(std::fs::read_to_string(tmp.log_path(c)).unwrap(), raw);
}
// ---------------------------------------------------------------------------
// survives a "restart" — a fresh instance on the same root relits everything
// ---------------------------------------------------------------------------

View File

@ -0,0 +1,74 @@
use std::path::PathBuf;
use std::sync::Arc;
use domain::{
DefaultAgentTerminalInterface, FileSystem, IdeaUserSettings, ProjectPath, ProjectSettings,
ProjectSettingsStore, ThemeColor, UserSettingsStore,
};
use infrastructure::{FsProjectSettingsStore, FsUserSettingsStore, LocalFileSystem};
use uuid::Uuid;
struct TempDir(PathBuf);
impl TempDir {
fn new() -> Self {
let path = std::env::temp_dir().join(format!("idea-settings-{}", Uuid::new_v4()));
std::fs::create_dir_all(&path).unwrap();
Self(path)
}
fn root(&self) -> ProjectPath {
ProjectPath::new(self.0.to_string_lossy().into_owned()).unwrap()
}
}
impl Drop for TempDir {
fn drop(&mut self) {
let _ = std::fs::remove_dir_all(&self.0);
}
}
fn fs() -> Arc<dyn FileSystem> {
Arc::new(LocalFileSystem::new())
}
#[tokio::test]
async fn global_user_preference_persists_outside_project() {
let tmp = TempDir::new();
let store = FsUserSettingsStore::new(fs(), tmp.0.to_string_lossy());
assert_eq!(store.load().await.unwrap(), IdeaUserSettings::default());
let settings = IdeaUserSettings {
default_agent_terminal_interface: Some(DefaultAgentTerminalInterface::IdeaCli),
};
store.save(&settings).await.unwrap();
assert_eq!(
FsUserSettingsStore::new(fs(), tmp.0.to_string_lossy())
.load()
.await
.unwrap(),
settings
);
assert!(tmp.0.join("settings.json").is_file());
assert!(!tmp.0.join(".ideai").exists());
}
#[tokio::test]
async fn project_settings_missing_then_valid_round_trip() {
let tmp = TempDir::new();
let store = FsProjectSettingsStore::new(fs());
assert_eq!(
store.load(&tmp.root()).await.unwrap(),
ProjectSettings::default()
);
assert!(!tmp.0.join(".ideai/project-settings.json").exists());
let settings = ProjectSettings {
theme_color: Some(ThemeColor::new("#12AbEF").unwrap()),
};
store.save(&tmp.root(), &settings).await.unwrap();
assert_eq!(store.load(&tmp.root()).await.unwrap(), settings);
assert!(!tmp.0.join(".ideai/CONTEXT.md").exists());
}
#[test]
fn theme_color_validation_is_strict() {
assert!(ThemeColor::new("#112233").is_ok());
for invalid in ["112233", "#123", "#GG0000", "#11223344", "# 12233"] {
assert!(ThemeColor::new(invalid).is_err(), "accepted {invalid}");
}
}