fix(webui): handle final stream image rewrites

This commit is contained in:
Xubin Ren
2026-05-24 19:43:20 +08:00
parent c9ff64fc0f
commit 8be258212e
6 changed files with 110 additions and 9 deletions
+21 -8
View File
@@ -520,15 +520,28 @@ export function useNanobotStream(
resolveActiveAssistantIndex(next)
?? findStreamingAssistantIndex(next, closedAssistantStreamIdsRef.current)
?? findLatestAssistantAnswerIndex(next);
if (targetIndex !== null) {
const target = next[targetIndex];
next = replaceMessageAt(next, targetIndex, {
...target,
content: finalAnswerText,
isStreaming: true,
});
if (targetIndex !== null) {
const target = next[targetIndex];
next = replaceMessageAt(next, targetIndex, {
...target,
content: finalAnswerText,
isStreaming: true,
});
} else {
const id = crypto.randomUUID();
closedAssistantStreamIdsRef.current.add(id);
next = [
...next,
{
id,
role: "assistant",
content: finalAnswerText,
isStreaming: true,
createdAt: Date.now(),
},
];
}
}
}
if (options?.closeAnswerSegment) closeActiveAssistantStream();
return next;
});