fix(domain,application,infrastructure,backend,app-tauri,frontend): Stop demande agent préserve la conversation ouverte — arrêt sans fermeture/clôture du chat, états cohérents après cancel sur les 3 adapters de session, cellule et workstate synchronisés — #343 (QA verte)

This commit is contained in:
2026-09-13 10:03:36 +02:00
parent a1e8a6466f
commit c37638ff24
26 changed files with 1210 additions and 232 deletions

View File

@ -117,11 +117,17 @@ impl AgentSession for FakeSession {
async fn send(&self, _prompt: &str) -> Result<ReplyStream, AgentSessionError> {
Ok(Box::new(std::iter::empty()))
}
async fn cancel_current_turn(&self) -> Result<(), AgentSessionError> {
async fn cancel_current_turn(
&self,
) -> Result<domain::ports::CancelCurrentTurnOutcome, AgentSessionError> {
self.cancel_called.store(true, Ordering::SeqCst);
Ok(())
Ok(domain::ports::CancelCurrentTurnOutcome::Cancelled)
}
async fn shutdown(&self) -> Result<(), AgentSessionError> {
assert!(
self.cancel_called.load(Ordering::SeqCst),
"shutdown must be preceded by cancel_current_turn"
);
self.shutdown_called.store(true, Ordering::SeqCst);
Ok(())
}
@ -530,7 +536,7 @@ async fn stop_structured_shuts_down_and_removes_session() {
assert_eq!(out.stopped[0].session_id, sid(2));
assert_eq!(out.stopped[0].kind, LiveSessionKind::Structured);
assert_eq!(out.stopped[0].state, LiveRuntimeState::Stopped);
assert!(!cancel_called.load(Ordering::SeqCst));
assert!(cancel_called.load(Ordering::SeqCst));
assert!(
shutdown_called.load(Ordering::SeqCst),
"session.shutdown() must be called"
@ -567,8 +573,8 @@ async fn stop_structured_runs_execution_cascade_before_shutdown() {
assert_eq!(out.stopped[0].session_id, sid(2));
assert_eq!(*cascade.calls.lock().unwrap(), vec![(project().id, a)]);
assert!(
!cancel_called.load(Ordering::SeqCst),
"session.cancel_current_turn() is not the runtime stop primitive"
cancel_called.load(Ordering::SeqCst),
"hard stop must cancel the current turn before shutdown"
);
assert!(
shutdown_called.load(Ordering::SeqCst),