fix(chat): capture du final et cause réelle des fins de tour « Le modèle n'a renvoyé aucune réponse. » — #231

This commit is contained in:
2026-08-21 20:45:50 +02:00
parent c1d7f6dd27
commit 3f3eb5938a
4 changed files with 44 additions and 38 deletions

View File

@ -35,6 +35,11 @@ use domain::ports::{
};
use crate::dto::{ReplyChunk, ReplyProgressDto, ReplyProgressKindDto, ReplyProgressStageDto};
/// Visible terminal message when a structured stream ends without the authoritative
/// `ReplyEvent::Final`.
pub const MODEL_RESPONSE_NOT_FINALIZED_MESSAGE: &str =
"La réponse du modèle n'a pas pu être finalisée.";
use crate::stream::TauriChannelSink;
/// Maximum number of recent chat chunks retained for transport reattach replay.
@ -338,3 +343,12 @@ pub fn chunk_from_event(event: ReplyEvent) -> Option<ReplyChunk> {
ReplyEvent::RateLimited { .. } => None,
}
}
/// Terminal wire chunk for an exhausted structured stream that never produced the
/// authoritative `ReplyEvent::Final`.
#[must_use]
pub fn unfinished_turn_chunk() -> ReplyChunk {
ReplyChunk::Error {
message: MODEL_RESPONSE_NOT_FINALIZED_MESSAGE.to_owned(),
}
}