mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-22 09:58:06 +00:00
fix: output_send 气泡时序(chatFinalIdx 插入)与 channel_output 后流式丢失
This commit is contained in:
@ -1980,6 +1980,7 @@
|
||||
chatStick: true,
|
||||
pendingTools: [],
|
||||
eventSource: null,
|
||||
chatFinalIdx: -1,
|
||||
lang: localStorage.getItem("ha-lang") || "zh",
|
||||
};
|
||||
|
||||
@ -3296,6 +3297,7 @@
|
||||
var text = inp.value.trim();
|
||||
if (!text || state.chatLoading) return;
|
||||
state.chatStick = true;
|
||||
state.chatFinalIdx = -1;
|
||||
state.messages.push({ role: "user", content: text });
|
||||
inp.value = "";
|
||||
rerenderChat();
|
||||
@ -3348,6 +3350,7 @@
|
||||
_grow: true,
|
||||
});
|
||||
}
|
||||
state.chatFinalIdx = state.messages.length - 1;
|
||||
rerenderChat();
|
||||
} catch (e) {
|
||||
state.messages.push({
|
||||
@ -3739,13 +3742,22 @@
|
||||
if (!p.content) return;
|
||||
state.chatStage = __("AI 回复中...", "AI replying...");
|
||||
if (p.kind === "channel_output") {
|
||||
state.messages.push({
|
||||
var cm = {
|
||||
role: "assistant",
|
||||
content: p.content,
|
||||
source: p.channel || "",
|
||||
_final: true,
|
||||
_grow: true,
|
||||
});
|
||||
};
|
||||
if (
|
||||
state.chatFinalIdx >= 0 &&
|
||||
state.chatFinalIdx < state.messages.length
|
||||
) {
|
||||
state.messages.splice(state.chatFinalIdx, 0, cm);
|
||||
state.chatFinalIdx++;
|
||||
} else {
|
||||
state.messages.push(cm);
|
||||
}
|
||||
rerenderChat();
|
||||
return;
|
||||
}
|
||||
@ -3762,7 +3774,12 @@
|
||||
rerenderChat();
|
||||
return;
|
||||
}
|
||||
if (lastM2 && lastM2.role === "assistant" && lastM2._final) {
|
||||
if (
|
||||
lastM2 &&
|
||||
lastM2.role === "assistant" &&
|
||||
lastM2._final &&
|
||||
!lastM2.source
|
||||
) {
|
||||
return;
|
||||
}
|
||||
state.messages.push({
|
||||
|
||||
Reference in New Issue
Block a user