Finalize assistant and dashboard health updates
This commit is contained in:
@@ -260,7 +260,7 @@
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (isOpen && initialized && conversationId) {
|
||||
if (isOpen && initialized && conversationId && !loading) {
|
||||
const currentFirstConversationId = messages.length
|
||||
? messages[0].conversation_id
|
||||
: conversationId;
|
||||
@@ -276,7 +276,7 @@
|
||||
* @PRE: text is non-empty command text.
|
||||
* @POST: user message appears at the end of messages list.
|
||||
*/
|
||||
function appendLocalUserMessage(text) {
|
||||
function appendLocalUserMessage(text, targetConversationId = conversationId) {
|
||||
console.log("[AssistantChatPanel][message][appendLocalUserMessage][START]");
|
||||
messages = [
|
||||
...messages,
|
||||
@@ -285,6 +285,7 @@
|
||||
role: "user",
|
||||
text,
|
||||
created_at: new Date().toISOString(),
|
||||
conversation_id: targetConversationId || null,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -296,7 +297,10 @@
|
||||
* @PRE: response follows assistant message response contract.
|
||||
* @POST: assistant message appended with state/task/actions metadata.
|
||||
*/
|
||||
function appendAssistantResponse(response) {
|
||||
function appendAssistantResponse(
|
||||
response,
|
||||
targetConversationId = conversationId,
|
||||
) {
|
||||
// prettier-ignore
|
||||
console.log("[AssistantChatPanel][message][appendAssistantResponse][START]");
|
||||
messages = [
|
||||
@@ -310,6 +314,7 @@
|
||||
confirmation_id: response.confirmation_id || null,
|
||||
actions: response.actions || [],
|
||||
created_at: response.created_at,
|
||||
conversation_id: response.conversation_id || targetConversationId || null,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -349,14 +354,15 @@
|
||||
console.log("[AssistantChatPanel][message][handleSend][START]");
|
||||
const text = input.trim();
|
||||
if (!text || loading) return;
|
||||
const requestConversationId = conversationId;
|
||||
|
||||
appendLocalUserMessage(text);
|
||||
appendLocalUserMessage(text, requestConversationId);
|
||||
input = "";
|
||||
loading = true;
|
||||
|
||||
try {
|
||||
const response = await sendAssistantMessage({
|
||||
conversation_id: conversationId,
|
||||
conversation_id: requestConversationId,
|
||||
message: text,
|
||||
});
|
||||
|
||||
@@ -364,7 +370,10 @@
|
||||
setAssistantConversationId(response.conversation_id);
|
||||
}
|
||||
|
||||
appendAssistantResponse(response);
|
||||
appendAssistantResponse(
|
||||
response,
|
||||
response.conversation_id || requestConversationId,
|
||||
);
|
||||
await loadConversations(true);
|
||||
} catch (err) {
|
||||
appendAssistantResponse({
|
||||
@@ -414,6 +423,7 @@
|
||||
typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
|
||||
? crypto.randomUUID()
|
||||
: `conv-${Date.now()}`;
|
||||
historyLoadVersion += 1;
|
||||
setAssistantConversationId(newId);
|
||||
messages = [];
|
||||
historyPage = 1;
|
||||
|
||||
Reference in New Issue
Block a user