fix(cli): arrêt du spinner Progress à l'état terminal — #157 (QA verte)

Ajoute completeRunningProgress() qui passe les stages started/delta à
completed lors des événements final/error. La ligne Progress conserve son
contenu statique utile mais n'affiche plus l'animation de chargement une
fois le tour terminé.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 14:29:39 +02:00
parent a9346476ee
commit 57ced6801b
2 changed files with 105 additions and 3 deletions

View File

@ -191,6 +191,24 @@ function appendProgress(turns: ChatTurn[], progress: ReplyProgress): ChatTurn[]
return [...turns, { role: "progress", progress }];
}
function completeRunningProgress(turns: ChatTurn[]): ChatTurn[] {
return turns.map((turn) => {
if (
turn.role !== "progress" ||
(turn.progress.stage !== "started" && turn.progress.stage !== "delta")
) {
return turn;
}
return {
...turn,
progress: {
...turn.progress,
stage: "completed",
},
};
});
}
function fileExtension(mime: string): string {
if (mime === "image/png") return "png";
if (mime === "image/jpeg") return "jpg";
@ -257,14 +275,14 @@ function foldChunk(turns: ChatTurn[], raw: unknown): ChatTurn[] {
}
case "final": {
const content = String(raw.content ?? "");
const next = [...turns];
const next = completeRunningProgress(turns);
const last = next[next.length - 1];
if (last?.role === "agent") next[next.length - 1] = { ...last, pending: false };
next.push({ role: "final", text: content });
return next;
}
case "error": {
const next = [...turns];
const next = completeRunningProgress(turns);
const last = next[next.length - 1];
if (last?.role === "agent") next[next.length - 1] = { ...last, pending: false };
next.push({ role: "error", text: String(raw.message ?? "Erreur agent") });