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

@ -3252,6 +3252,59 @@ pub struct UpdateProjectContextRequestDto {
pub content: String,
}
/// Global machine-local user settings wire contract.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserSettingsDto {
/// Default interface for newly opened agent terminals.
#[serde(default)]
pub default_agent_terminal_interface: Option<domain::DefaultAgentTerminalInterface>,
}
impl From<domain::IdeaUserSettings> for UserSettingsDto {
fn from(value: domain::IdeaUserSettings) -> Self {
Self {
default_agent_terminal_interface: value.default_agent_terminal_interface,
}
}
}
impl From<UserSettingsDto> for domain::IdeaUserSettings {
fn from(value: UserSettingsDto) -> Self {
Self {
default_agent_terminal_interface: value.default_agent_terminal_interface,
}
}
}
/// Project-owned settings wire contract.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProjectSettingsDto {
/// Optional validated project theme colour.
#[serde(default)]
pub theme_color: Option<String>,
}
impl From<domain::ProjectSettings> for ProjectSettingsDto {
fn from(value: domain::ProjectSettings) -> Self {
Self {
theme_color: value.theme_color.map(|color| color.as_str().to_owned()),
}
}
}
/// Project settings update request.
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateProjectSettingsRequestDto {
/// Project registry id.
pub project_id: String,
/// New colour, or null to restore the product default.
#[serde(default)]
pub theme_color: Option<String>,
}
/// Request DTO for `launch_agent`.
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
@ -3747,6 +3800,9 @@ impl From<ReplyProgressStage> for ReplyProgressStageDto {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ReplyProgressDto {
/// Time at which the backend accepted this visible event.
#[serde(default)]
pub occurred_at_ms: Option<u64>,
/// Optional stable progress entity id for frontend upsert.
#[serde(skip_serializing_if = "Option::is_none")]
pub progress_id: Option<String>,
@ -3775,6 +3831,7 @@ pub struct ReplyProgressDto {
impl From<ReplyProgress> for ReplyProgressDto {
fn from(value: ReplyProgress) -> Self {
Self {
occurred_at_ms: None,
progress_id: value.progress_id,
source: value.source.into(),
kind: value.kind.into(),
@ -3804,6 +3861,9 @@ pub enum ReplyChunk {
/// The user's submitted prompt, retained in live scrollback for reattach.
#[serde(rename_all = "camelCase")]
UserPrompt {
/// Time at which the backend accepted this prompt.
#[serde(default)]
at_ms: Option<u64>,
/// Submitted prompt text.
text: String,
/// Display labels for attachments submitted with the prompt.
@ -3816,12 +3876,18 @@ pub enum ReplyChunk {
/// An assistant text fragment (incremental chat rendering).
#[serde(rename_all = "camelCase")]
TextDelta {
/// Time at which the backend accepted this fragment.
#[serde(default)]
at_ms: Option<u64>,
/// The text fragment.
text: String,
},
/// A human-readable tool-activity badge (best-effort observability).
#[serde(rename_all = "camelCase")]
ToolActivity {
/// Time at which the backend accepted this activity.
#[serde(default)]
at_ms: Option<u64>,
/// The human-readable activity label.
label: String,
},
@ -3834,12 +3900,18 @@ pub enum ReplyChunk {
/// The deterministic end-of-turn chunk carrying the aggregated final content.
#[serde(rename_all = "camelCase")]
Final {
/// Time at which the backend accepted the terminal response.
#[serde(default)]
at_ms: Option<u64>,
/// The aggregated final content of the turn.
content: String,
},
/// A visible terminal fallback when the model stream produced no usable answer.
#[serde(rename_all = "camelCase")]
Error {
/// Time at which the backend accepted the terminal error.
#[serde(default)]
at_ms: Option<u64>,
/// Human-readable explanation to render in the chat cell.
message: String,
},
@ -4210,7 +4282,7 @@ pub struct ConversationTurnWorkPreviewDto {
/// Origin of the turn (human operator or a delegating agent).
pub source: TicketWorkSourceDto,
/// Timestamp (epoch milliseconds) of the turn.
pub at_ms: u64,
pub at_ms: Option<u64>,
/// Bounded excerpt of the turn text.
pub text_preview: String,
/// Character length of the original (un-truncated) turn text.
@ -4469,6 +4541,9 @@ pub struct StopLiveAgentRequestDto {
pub project_id: String,
/// Id of the running agent to stop.
pub agent_id: String,
/// Optional human-readable reason for the stop.
#[serde(default)]
pub reason: Option<String>,
}
/// Response DTO for `stop_live_agent`: the torn-down session's coordinates.
@ -4477,11 +4552,23 @@ pub struct StopLiveAgentRequestDto {
pub struct StopLiveAgentResponseDto {
/// The stopped agent's id.
pub agent_id: String,
/// The id of the session that was torn down.
/// Every runtime actually torn down by this request.
pub stopped: Vec<StoppedAgentRuntimeDto>,
/// True when the operation was an idempotent no-op.
pub already_stopped: bool,
}
/// One stopped runtime in an agent-level stop response.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StoppedAgentRuntimeDto {
/// Removed runtime session id.
pub session_id: String,
/// Runtime family that owned the session (`pty`/`structured`).
/// Last hosting layout node id.
pub node_id: String,
/// Runtime family.
pub kind: LiveWorkSessionKindDto,
/// Runtime lifecycle projection after the stop request.
/// Terminal lifecycle state.
pub runtime_state: LiveRuntimeStateDto,
}
@ -4489,9 +4576,17 @@ impl From<StopLiveAgentOutput> for StopLiveAgentResponseDto {
fn from(out: StopLiveAgentOutput) -> Self {
Self {
agent_id: out.agent_id.to_string(),
session_id: out.session_id.to_string(),
kind: out.kind.into(),
runtime_state: out.runtime_state.into(),
stopped: out
.stopped
.into_iter()
.map(|item| StoppedAgentRuntimeDto {
session_id: item.session_id.to_string(),
node_id: item.node_id.to_string(),
kind: item.kind.into(),
runtime_state: item.state.into(),
})
.collect(),
already_stopped: out.already_stopped,
}
}
}
@ -5552,7 +5647,7 @@ pub struct TurnViewDto {
/// Stable turn id (also the pagination anchor).
pub id: String,
/// Timestamp (epoch milliseconds).
pub at_ms: u64,
pub at_ms: Option<u64>,
/// Turn nature (prompt, response, tool activity).
pub role: TurnRole,
/// Origin (human or delegating agent).

View File

@ -44,27 +44,28 @@ use application::{
PluginToolchainDiagnostics, PluginWorkspaceAccess, ProjectPluginResolver, ProposeContext,
PurgeManagedTemp, QueryProjectStructure, ReadAgentContext, ReadChatDraft, ReadContext,
ReadConversationPage, ReadIssue, ReadIssueAttachment, ReadIssueCarnet, ReadMcpToolPermissions,
ReadMemory, ReadMemoryIndex, ReadOpenProjectRestoreState, ReadProjectContext, ReadSkill,
ReadTemplate, RecallMemory, ReconcileLayouts, ReconcileLiveState, ReconcileLiveStateInput,
ReconcilePluginMcpServers, RecordProjectClosedForRestore, RecordProjectOpenedForRestore,
RecordTurn, RecordTurnProvider, ReferenceProfiles, ReleaseManagedTemp, ReloadPlugin,
ReloadPluginInput, RemoveProjectFromRegistry, RenameDevice, RenameLayout, RenameSprint,
ReorderSprints, ResizeTerminal, ResolveAgentCapabilities, ResolveAgentPermissions,
ReadMemory, ReadMemoryIndex, ReadOpenProjectRestoreState, ReadProjectContext,
ReadProjectSettings, ReadSkill, ReadTemplate, ReadUserSettings, RecallMemory, ReconcileLayouts,
ReconcileLiveState, ReconcileLiveStateInput, ReconcilePluginMcpServers,
RecordProjectClosedForRestore, RecordProjectOpenedForRestore, RecordTurn, RecordTurnProvider,
ReferenceProfiles, ReleaseManagedTemp, ReloadPlugin, ReloadPluginInput,
RemoveProjectFromRegistry, RenameDevice, RenameLayout, RenameSprint, ReorderSprints,
ResizeTerminal, ResolveAgentCapabilities, ResolveAgentPermissions,
ResolveAgentSystemPermissions, ResolveManagedTemp, ResolveMemoryLinks, RestoreOpenProjects,
RestoreOpenProjectsOutput, RestoreOpenWindows, RetryBackgroundTask, RetryOpenProjectRestore,
ReviewPluginPackage, RevokeAllDevices, RevokeDevice, RotateConversationLog, SaveChatDraft,
SaveEmbedderProfile, SaveModelServer, SaveOpenCodeProviderProfile, SaveOpenProjectRestoreOrder,
SaveProfile, SessionLimitService, SetActiveLayout, SetAgentMcpToolAllowed, SetPluginEnabled,
SetProjectPluginEnabled, SlashCommandRegistry, SnapshotOpenWindows, SnapshotRunningAgents,
SnapshotRunningAgentsInput, SpawnBackgroundCommand, StopLiveAgent, StructuredRoutingMode,
SnapshotRunningAgentsInput, SpawnBackgroundCommand, StopAgentRuntime, StructuredRoutingMode,
StructuredSessions, SuggestedThisSession, SyncAgentWithTemplate, TerminalSessions, TouchDevice,
UnassignSkillFromAgent, UnassignTicketFromSprint, UninstallPlugin, UnlinkIssues,
UpdateAgentContactable, UpdateAgentContext, UpdateAgentEffort, UpdateAgentMcpToolPermissions,
UpdateAgentPermissions, UpdateAgentSystemPermissions, UpdateIssue, UpdateIssueCarnet,
UpdateLiveState, UpdateMemory, UpdateProjectContext, UpdateProjectMcpToolPermissions,
UpdateProjectOrchestrator, UpdateProjectPermissions, UpdateProjectSystemPermissions,
UpdateSkill, UpdateTemplate, WakeSessionProvider, WriteMemory, WriteToTerminal,
AGENT_MEMORY_RECALL_BUDGET,
UpdateProjectOrchestrator, UpdateProjectPermissions, UpdateProjectSettings,
UpdateProjectSystemPermissions, UpdateSkill, UpdateTemplate, UpdateUserSettings,
WakeSessionProvider, WriteMemory, WriteToTerminal, AGENT_MEMORY_RECALL_BUDGET,
};
use async_trait::async_trait;
use domain::events::AgentRestartPhase;
@ -77,10 +78,10 @@ use domain::ports::{
McpToolPermissionStore, MemoryRecall, MemoryStore, ModelArtifactDownloader,
OpenProjectRestoreStore, PermissionStore, PluginManifestValidator, PluginMcpSupervisor,
PluginPackageStore, PluginRegistryStore, PluginStorageStore, ProcessSpawner, ProfileStore,
ProjectPluginSettingsStore, ProjectStore, PtyHandle, PtyPort, RuntimePermissionProbe,
ScheduledTask, Scheduler, SecretStore, SkillStore, SprintStore,
ProjectPluginSettingsStore, ProjectSettingsStore, ProjectStore, PtyHandle, PtyPort,
RuntimePermissionProbe, ScheduledTask, Scheduler, SecretStore, SkillStore, SprintStore,
StructuredSessionEnvironmentPreparer, SystemPermissionStore, TemplateStore, ToolInvoker,
WakeError, WakeReason, WindowStateStore,
UserSettingsStore, WakeError, WakeReason, WindowStateStore,
};
use domain::profile::{
AgentProfile, ContextInjection, McpConfigStrategy, McpTransport, StructuredAdapter,
@ -105,19 +106,19 @@ use infrastructure::{
FsHandoffStore, FsIssueNumberAllocator, FsIssueStore, FsLiveStateStore, FsManagedTempStore,
FsMcpToolPermissionStore, FsMemoryStore, FsModelServerRegistry, FsOpenProjectRestoreStore,
FsOrchestratorWatcher, FsPermissionStore, FsPluginPackageStore, FsPluginRegistryStore,
FsPluginStorageStore, FsProfileStore, FsProjectPluginSettingsStore, FsProjectStore,
FsProviderSessionStore, FsSecretStore, FsSkillStore, FsSprintStore, FsSystemPermissionStore,
FsTemplateStore, FsWindowStateStore, Git2Repository, HeuristicHandoffSummarizer,
HfModelArtifactDownloader, HttpOpenAiCompatibleProbe, HttpProviderModelCatalogue,
IdeaiContextStore, InMemoryConversationRegistry, InMemoryMailbox, InMemoryPairAttemptLimiter,
LlamaCppRuntime, LocalEnvironmentReader, LocalFileSystem, LocalManagedProcess,
LocalProcessSpawner, ManagedTempToolProvider, McpServer, MediatedInbox, NaiveMemoryRecall,
OrchestratorWatchHandle, PortablePtyAdapter, ProcessCliVersionReader,
ReadOnlyRuntimePermissionProbe, RwFileGuard, StructuredSessionFactory, SystemClock,
SystemMillisClock, TemplateToolProvider, TicketAssistantEnvironmentPreparer,
TicketToolProvider, TokioBroadcastEventBus, TokioScheduler, ToolPolicyRegistry, UuidGenerator,
VectorMemoryRecall, DEFAULT_OLLAMA_BASE_URL, ONNX_CACHE_SUBDIR, RECOMMENDED_ONNX_MODELS,
VECTOR_HTTP_ENABLED, VECTOR_ONNX_ENABLED,
FsPluginStorageStore, FsProfileStore, FsProjectPluginSettingsStore, FsProjectSettingsStore,
FsProjectStore, FsProviderSessionStore, FsSecretStore, FsSkillStore, FsSprintStore,
FsSystemPermissionStore, FsTemplateStore, FsUserSettingsStore, FsWindowStateStore,
Git2Repository, HeuristicHandoffSummarizer, HfModelArtifactDownloader,
HttpOpenAiCompatibleProbe, HttpProviderModelCatalogue, IdeaiContextStore,
InMemoryConversationRegistry, InMemoryMailbox, InMemoryPairAttemptLimiter, LlamaCppRuntime,
LocalEnvironmentReader, LocalFileSystem, LocalManagedProcess, LocalProcessSpawner,
ManagedTempToolProvider, McpServer, MediatedInbox, NaiveMemoryRecall, OrchestratorWatchHandle,
PortablePtyAdapter, ProcessCliVersionReader, ReadOnlyRuntimePermissionProbe, RwFileGuard,
StructuredSessionFactory, SystemClock, SystemMillisClock, TemplateToolProvider,
TicketAssistantEnvironmentPreparer, TicketToolProvider, TokioBroadcastEventBus, TokioScheduler,
ToolPolicyRegistry, UuidGenerator, VectorMemoryRecall, DEFAULT_OLLAMA_BASE_URL,
ONNX_CACHE_SUBDIR, RECOMMENDED_ONNX_MODELS, VECTOR_HTTP_ENABLED, VECTOR_ONNX_ENABLED,
};
pub mod dto;
@ -992,6 +993,7 @@ impl WakeSessionProvider for AppWakeSessionProvider {
mcp_runtime: None,
allow_structured_alongside_pty: true,
require_structured: false,
terminal_interface: None,
fresh_start: false,
managed_temp_exposure: application::ManagedTempExposureRequest::default(),
})
@ -1102,6 +1104,11 @@ fn self_restart_launch_input(
mcp_runtime,
allow_structured_alongside_pty: false,
require_structured: context.require_structured,
terminal_interface: Some(if context.require_structured {
domain::DefaultAgentTerminalInterface::IdeaCli
} else {
domain::DefaultAgentTerminalInterface::NativeTui
}),
fresh_start: false,
managed_temp_exposure: application::ManagedTempExposureRequest::default(),
}
@ -1124,6 +1131,11 @@ fn automatic_resume_launch_input(
mcp_runtime,
allow_structured_alongside_pty: false,
require_structured: context.require_structured,
terminal_interface: Some(if context.require_structured {
domain::DefaultAgentTerminalInterface::IdeaCli
} else {
domain::DefaultAgentTerminalInterface::NativeTui
}),
fresh_start: false,
managed_temp_exposure: application::ManagedTempExposureRequest::default(),
}
@ -1835,6 +1847,8 @@ pub struct RemoveProjectResult {
/// types — downstream code only sees the `Arc<dyn Port>` held inside the use
/// cases.
pub struct BackendCore {
/// Shared business clock used to stamp transport events at acceptance.
pub clock: Arc<dyn Clock>,
/// Trivial health use case validating the end-to-end wiring.
pub health: Arc<HealthUseCase>,
/// List/filter the unified slash-command registry.
@ -2095,7 +2109,7 @@ pub struct BackendCore {
/// Rebinds an already-running agent's live session to a visible cell (Lot D).
pub attach_live_agent: Arc<AttachLiveAgent>,
/// Tears down an already-running agent's live session by agent id (Lot D).
pub stop_live_agent: Arc<StopLiveAgent>,
pub stop_live_agent: Arc<StopAgentRuntime>,
/// Best-effort inspection of a conversation (last topic + token indicator)
/// for the resume popup (T7). Optional/extensible: backed by a `Vec` of
/// [`domain::ports::SessionInspector`]s; an empty/missing match yields empty
@ -2103,6 +2117,14 @@ pub struct BackendCore {
pub inspect_conversation: Arc<InspectConversation>,
/// Project registry — used by agent commands to resolve a `Project` from an id.
pub project_store: Arc<dyn ProjectStore>,
/// Reads global machine-local preferences.
pub read_user_settings: Arc<ReadUserSettings>,
/// Updates global machine-local preferences.
pub update_user_settings: Arc<UpdateUserSettings>,
/// Reads settings owned by the active project.
pub read_project_settings: Arc<ReadProjectSettings>,
/// Updates settings owned by the active project.
pub update_project_settings: Arc<UpdateProjectSettings>,
/// Read the project permission document.
pub get_project_permissions: Arc<GetProjectPermissions>,
/// Update project-level default permissions.
@ -2455,6 +2477,26 @@ impl BackendCore {
// Port-typed handles for injection.
let fs_port = Arc::clone(&fs) as Arc<dyn FileSystem>;
let store_port = Arc::clone(&store) as Arc<dyn ProjectStore>;
let user_settings_store = Arc::new(FsUserSettingsStore::new(
Arc::clone(&fs_port),
app_data_dir.to_string_lossy().into_owned(),
));
let user_settings_store_port =
Arc::clone(&user_settings_store) as Arc<dyn UserSettingsStore>;
let project_settings_store = Arc::new(FsProjectSettingsStore::new(Arc::clone(&fs_port)));
let project_settings_store_port =
Arc::clone(&project_settings_store) as Arc<dyn ProjectSettingsStore>;
let read_user_settings =
Arc::new(ReadUserSettings::new(Arc::clone(&user_settings_store_port)));
let update_user_settings = Arc::new(UpdateUserSettings::new(Arc::clone(
&user_settings_store_port,
)));
let read_project_settings = Arc::new(ReadProjectSettings::new(Arc::clone(
&project_settings_store_port,
)));
let update_project_settings = Arc::new(UpdateProjectSettings::new(Arc::clone(
&project_settings_store_port,
)));
let open_project_restore_store_port =
Arc::clone(&open_project_restore_store) as Arc<dyn OpenProjectRestoreStore>;
let window_state_port = Arc::clone(&window_state_store) as Arc<dyn WindowStateStore>;
@ -3207,6 +3249,7 @@ impl BackendCore {
.with_assigned_skill_resolver(Arc::clone(&assigned_skill_resolver))
.with_plugin_mcp_resolver(Arc::clone(&project_plugin_resolver))
.with_structured_routing_mode(StructuredRoutingMode::HumanPtyFallback)
.with_user_settings(Arc::clone(&user_settings_store_port))
.with_permission_store(Arc::clone(&permission_store_port))
.with_system_permission_store(Arc::clone(&system_permission_store_port))
// Reprise conversationnelle (lot P7) : à chaque (re)lancement, si la cellule
@ -4100,14 +4143,17 @@ impl BackendCore {
)) as Arc<dyn ToolInvoker>);
let stop_live_agent = Arc::new(
StopLiveAgent::new(Arc::clone(&live_sessions), Arc::clone(&close_terminal))
StopAgentRuntime::new(Arc::clone(&live_sessions), Arc::clone(&close_terminal))
.with_cascade(
Arc::clone(&input_mediator),
Arc::clone(&orchestrator_service),
)
.with_execution_cascade(Arc::clone(&orchestrator_service)
as Arc<dyn application::StopAgentExecutionCascade>)
.with_restart_rendezvous(Arc::clone(&restart_rendezvous)),
.with_restart_rendezvous(Arc::clone(&restart_rendezvous))
.with_live_state(Arc::new(AppLiveStateProvider {
clock: Arc::clone(&clock) as Arc<dyn Clock>,
}) as Arc<dyn LiveStateProvider>),
);
// --- Windows (L10) ---
@ -4131,6 +4177,7 @@ impl BackendCore {
));
Self {
clock: Arc::clone(&clock) as Arc<dyn Clock>,
health,
list_slash_commands,
execute_slash_command,
@ -4257,6 +4304,10 @@ impl BackendCore {
stop_live_agent,
inspect_conversation,
project_store,
read_user_settings,
update_user_settings,
read_project_settings,
update_project_settings,
get_project_permissions,
update_project_permissions,
update_agent_permissions,