feat(agent): reprise des sessions au redémarrage (B2) — commande + ResumeProjectPanel

- Tauri : commande list_resumable_agents (projectId) + ResumableAgentListDto
  { resumable } / ResumableAgentDto (camelCase, conversationId omis si None),
  câblage state.rs (réutilise stores + ProfileStore, aucun nouveau port).
- Front : gateway listResumableAgents, ResumeProjectPanel monté à l'ouverture
  de projet (opt-in, FR) : Reprendre (launch_agent nodeId+conversationId),
  Nouvelle conversation (setCellConversation(null) puis launch), Ignorer,
  Tout reprendre/ignorer. resumeSupported=false ⇒ « relance à neuf ».
- doc : §15.2 coquille agents→resumable (alignée use case/back/front).

Tests : app-tauri dto 9/9 ; vitest 324 (+10) ; workspace Rust 0 échec. 0 régression.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 13:04:41 +02:00
parent b82e3e1a40
commit 7375f706da
15 changed files with 992 additions and 6 deletions

View File

@ -16,7 +16,8 @@ use application::{
DetectAgentDriftInput, GetMemoryInput, GitBranchesInput, GitCheckoutInput, GitCommitInput,
GitGraphInput, GitInitInput, GitLogInput, GitStagePathInput, GitStatusInput,
InspectConversationInput, LaunchAgentInput, ListAgentsInput, ListLayoutsInput,
ListMemoriesInput, ListSkillsInput, LoadLayoutInput, MutateLayoutInput, OpenProjectInput,
ListMemoriesInput, ListResumableAgentsInput, ListSkillsInput, LoadLayoutInput, MutateLayoutInput,
OpenProjectInput,
ReadAgentContextInput, ReadMemoryIndexInput, ReadProjectContextInput, RecallMemoryInput,
RenameLayoutInput, ResolveMemoryLinksInput, SetActiveLayoutInput, SnapshotRunningAgentsInput,
SyncAgentWithTemplateInput, UnassignSkillFromAgentInput, UpdateAgentContextInput,
@ -40,7 +41,7 @@ use crate::dto::{
LaunchAgentRequestDto, LayoutDto, LayoutOperationDto, ListLayoutsDto, LiveAgentListDto,
MemoryDto, MemoryIndexDto, MemoryLinksDto, MemoryListDto, OpenTerminalRequestDto, ProfileDto,
ProfileListDto, ProjectDto, ProjectListDto, ReadAgentContextResponseDto, ReattachResultDto,
RecallMemoryRequestDto, RenameLayoutRequestDto, ResizeTerminalRequestDto,
RecallMemoryRequestDto, RenameLayoutRequestDto, ResizeTerminalRequestDto, ResumableAgentListDto,
SaveEmbedderProfileRequestDto, SaveProfileRequestDto, SetActiveLayoutRequestDto, SkillDto,
SkillListDto, SyncAgentWithTemplateRequestDto, SyncResultDto, TemplateDto, TemplateListDto,
TerminalClosedDto, TerminalSessionDto, UnassignSkillRequestDto, UpdateAgentContextRequestDto,
@ -1075,6 +1076,32 @@ pub async fn change_agent_profile(
.map_err(ErrorDto::from)
}
/// `list_resumable_agents` — read-only inventory of an open project's resumable
/// agent cells (§15.2). Each entry carries the agent + its host cell, the CLI
/// conversation id to resume (absent ⇒ fresh relaunch), the `was_running` flag
/// frozen at close, and whether the profile can resume a conversation.
///
/// Best-effort by contract: an unreadable project/layout/manifest degrades to an
/// empty list, never an error. Drives the reopen panel, which reuses
/// `launch_agent` for the actual resume (no new resume command).
///
/// # Errors
/// Returns an [`ErrorDto`] (`INVALID` for a malformed id, `NOT_FOUND` if the
/// project is unknown, `STORE` on a project-registry failure).
#[tauri::command]
pub async fn list_resumable_agents(
project_id: String,
state: State<'_, AppState>,
) -> Result<ResumableAgentListDto, ErrorDto> {
let project = resolve_project(&project_id, &state).await?;
state
.list_resumable_agents
.execute(ListResumableAgentsInput { project })
.await
.map(ResumableAgentListDto::from)
.map_err(ErrorDto::from)
}
// ---------------------------------------------------------------------------
// Templates & sync (L7)
// ---------------------------------------------------------------------------

View File

@ -1305,6 +1305,72 @@ pub fn parse_agent_id(raw: &str) -> Result<AgentId, ErrorDto> {
})
}
// ---------------------------------------------------------------------------
// Resumable agents (§15.2 — Chantier B2)
// ---------------------------------------------------------------------------
use application::{ListResumableAgentsOutput, ResumableAgent};
/// One resumable agent cell, as seen by the frontend (§15.2).
///
/// Mirrors [`ResumableAgent`]: the agent's identity + its host cell, the CLI
/// conversation id to resume (absent ⇒ fresh relaunch), the `was_running` flag
/// frozen at close, and whether the agent's profile can resume a CLI
/// conversation. `conversationId` is **omitted from the wire when `None`**
/// (`skip_serializing_if`), so the TypeScript side sees an absent key — not
/// `null`.
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ResumableAgentDto {
/// The resumable agent's id (UUID string).
pub agent_id: String,
/// The agent's display name (resolved from the manifest).
pub name: String,
/// The host layout leaf where the agent is relaunched/resumed (UUID string).
pub node_id: String,
/// Persistent CLI conversation id carried by the cell. Absent ⇒ fresh
/// relaunch (no history to resume).
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
/// The `agent_was_running` flag frozen at the cell's close.
pub was_running: bool,
/// `true` when the agent's profile carries a usable resume strategy.
pub resume_supported: bool,
}
impl From<ResumableAgent> for ResumableAgentDto {
fn from(r: ResumableAgent) -> Self {
Self {
agent_id: r.agent_id.to_string(),
name: r.name,
node_id: r.node_id.to_string(),
conversation_id: r.conversation_id,
was_running: r.was_running,
resume_supported: r.resume_supported,
}
}
}
/// Response DTO for `list_resumable_agents` (§15.2).
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ResumableAgentListDto {
/// The resumable agent cells, in layout-traversal order.
pub resumable: Vec<ResumableAgentDto>,
}
impl From<ListResumableAgentsOutput> for ResumableAgentListDto {
fn from(out: ListResumableAgentsOutput) -> Self {
Self {
resumable: out
.resumable
.into_iter()
.map(ResumableAgentDto::from)
.collect(),
}
}
}
// ---------------------------------------------------------------------------
// Templates & sync (L7)
// ---------------------------------------------------------------------------

View File

@ -127,6 +127,7 @@ pub fn run() {
commands::delete_agent,
commands::launch_agent,
commands::change_agent_profile,
commands::list_resumable_agents,
commands::inspect_conversation,
commands::create_template,
commands::update_template,

View File

@ -18,7 +18,8 @@ use application::{
DetectAgentDrift, DetectProfiles, DismissEmbedderSuggestion, FirstRunState, GetMemory,
GitBranches, GitCheckout, GitCommit, GitGraph, GitInit, GitLog, GitStage, GitStatus,
GitUnstage, HealthUseCase, InspectConversation, LaunchAgent, ListAgents, ListEmbedderProfiles,
ListLayouts, ListMemories, ListProfiles, ListProjects, ListSkills, ListTemplates,
ListLayouts, ListMemories, ListProfiles, ListProjects, ListResumableAgents, ListSkills,
ListTemplates,
LiveAgentRegistry, LoadLayout, MoveTabToNewWindow, MutateLayout, OnnxModelView, OpenProject,
OpenTerminal, OrchestratorService, ReadAgentContext, ReadMemoryIndex, ReadProjectContext,
RecallMemory, ReferenceProfiles, RenameLayout, ResizeTerminal, ResolveMemoryLinks,
@ -131,6 +132,9 @@ pub struct AppState {
pub launch_agent: Arc<LaunchAgent>,
/// Hot-swap an agent's runtime profile, relaunching its live session in place (§15.1).
pub change_agent_profile: Arc<ChangeAgentProfile>,
/// Read-only inventory of a project's resumable agent cells, for the reopen
/// panel (§15.2).
pub list_resumable_agents: Arc<ListResumableAgents>,
/// 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
@ -531,6 +535,15 @@ impl AppState {
Arc::clone(&events_port),
));
// Read-only inventory of resumable agent cells (§15.2). Reuses the shared
// project/fs/context/profile stores already injected above — no new port.
let list_resumable_agents = Arc::new(ListResumableAgents::new(
Arc::clone(&store_port),
Arc::clone(&fs_port),
Arc::clone(&contexts_port),
Arc::clone(&profile_store_port),
));
// --- Conversation inspection (T7) ---
// Best-effort, optional, extensible: a `Vec` of SessionInspectors routed
// by profile. Adding an inspectable CLI = pushing one more adapter here.
@ -717,6 +730,7 @@ impl AppState {
delete_agent,
launch_agent,
change_agent_profile,
list_resumable_agents,
inspect_conversation,
project_store,
create_template,