refac
This commit is contained in:
1 parent
0eba3df119
commit
edf2c6c8f7
1 file changed
+10
-2
@@ -603,6 +603,9 @@
|
|||||||
} else if (type === 'chat:active') {
|
} else if (type === 'chat:active') {
|
||||||
if (!data?.active) {
|
if (!data?.active) {
|
||||||
taskIds = null;
|
taskIds = null;
|
||||||
|
if (chatIdProp && !$temporaryChatEnabled && hasPendingAssistantLeaf()) {
|
||||||
|
await loadChat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (type === 'chat:completion') {
|
} else if (type === 'chat:completion') {
|
||||||
chatCompletionEventHandler(data, message, event.chat_id);
|
chatCompletionEventHandler(data, message, event.chat_id);
|
||||||
@@ -866,13 +869,18 @@
|
|||||||
} catch {}
|
} catch {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasPendingAssistantLeaf = () =>
|
||||||
|
Object.values(history.messages).some(
|
||||||
|
(message) =>
|
||||||
|
message?.role === 'assistant' && !message.done && (message.childrenIds?.length ?? 0) === 0
|
||||||
|
);
|
||||||
|
|
||||||
const handleSocketConnect = async () => {
|
const handleSocketConnect = async () => {
|
||||||
if (!chatIdProp || $temporaryChatEnabled) {
|
if (!chatIdProp || $temporaryChatEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentMessage = history.currentId ? history.messages[history.currentId] : null;
|
if (!hasPendingAssistantLeaf()) {
|
||||||
if (currentMessage?.role !== 'assistant' || currentMessage.done) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user