|
157 | 157 | /** @type {import('$conversationTypes').ConversationStateLogModel[]} */ |
158 | 158 | let convStateLogs = []; |
159 | 159 |
|
160 | | - /** @type {import('$conversationTypes').ConversationStateLogModel?} */ |
| 160 | + // /** @type {import('$conversationTypes').ConversationStateLogModel?} */ |
| 161 | + /** @type {Object?} */ |
161 | 162 | let latestStateLog; |
162 | 163 |
|
163 | 164 | /** @type {import('$conversationTypes').MessageStateLogModel[]} */ |
|
219 | 220 | |
220 | 221 | onMount(async () => { |
221 | 222 | disableSpeech = navigator.userAgent.includes('Firefox'); |
222 | | - conversation = await getConversation(params.conversationId); |
| 223 | + conversation = await getConversation(params.conversationId, true); |
223 | 224 | dialogs = await getDialogs(params.conversationId, dialogCount); |
224 | 225 | conversationUser = await getConversationUser(params.conversationId); |
225 | 226 | selectedTags = conversation?.tags || []; |
| 227 | + latestStateLog = conversation?.states; |
226 | 228 | initUserSentMessages(dialogs); |
227 | 229 | initChatView(); |
228 | 230 | handlePaneResize(); |
|
469 | 471 | /** @param {import('$conversationTypes').ChatResponseModel} message */ |
470 | 472 | function onMessageReceivedFromClient(message) { |
471 | 473 | autoScrollLog = true; |
472 | | - clearInstantLogs(); |
473 | 474 | dialogs.push({ |
474 | 475 | ...message, |
475 | 476 | is_chat_message: true |
|
484 | 485 | ...message, |
485 | 486 | is_chat_message: true |
486 | 487 | }); |
| 488 | + latestStateLog = message.states; |
487 | 489 | refresh(); |
488 | 490 | } |
489 | 491 |
|
|
504 | 506 | function onConversationStateLogGenerated(log) { |
505 | 507 | if (!isLoadPersistLog) return; |
506 | 508 |
|
507 | | - latestStateLog = log; |
508 | 509 | convStateLogs.push({ ...log, uid: uuidv4() }); |
509 | 510 | convStateLogs = convStateLogs.map(x => { return { ...x }; }); |
510 | 511 | } |
|
514 | 515 | if (!isLoadInstantLog || log == null) return; |
515 | 516 |
|
516 | 517 | msgStateLogs.push({ ...log }); |
517 | | - msgStateLogs = msgStateLogs.map(x => { return { ...x }; }); |
| 518 | + msgStateLogs = msgStateLogs.map(x => { return { ...x, uid: uuidv4() }; }); |
518 | 519 | } |
519 | 520 |
|
520 | 521 | /** @param {import('$conversationTypes').AgentQueueLogModel} log */ |
521 | 522 | function onAgentQueueChanged(log) { |
522 | 523 | if (!isLoadInstantLog || log == null) return; |
523 | 524 |
|
524 | 525 | agentQueueLogs.push({ ...log }); |
525 | | - agentQueueLogs = agentQueueLogs.map(x => { return { ...x }; }); |
| 526 | + agentQueueLogs = agentQueueLogs.map(x => { return { ...x, uid: uuidv4() }; }); |
526 | 527 | } |
527 | 528 |
|
528 | 529 | /** @param {import('$conversationTypes').ConversationSenderActionModel} data */ |
|
1053 | 1054 |
|
1054 | 1055 | targetIdx = convStateLogs.findIndex(x => x.message_id === messageId); |
1055 | 1056 | convStateLogs = convStateLogs.filter((x, idx) => idx < targetIdx); |
1056 | | - latestStateLog = convStateLogs.slice(-1)[0]; |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 |
|
|
1483 | 1483 | <InstantLog |
1484 | 1484 | bind:msgStateLogs={msgStateLogs} |
1485 | 1485 | bind:agentQueueLogs={agentQueueLogs} |
1486 | | - latestStateLog={latestStateLog?.message_id === lastMsg?.message_id ? latestStateLog : null} |
| 1486 | + latestStateLog={latestStateLog} |
1487 | 1487 | agent={agent} |
1488 | 1488 | closeWindow={() => closeInstantLog()} |
1489 | 1489 | /> |
|
1917 | 1917 | <PersistLog |
1918 | 1918 | bind:contentLogs={contentLogs} |
1919 | 1919 | bind:convStateLogs={convStateLogs} |
1920 | | - bind:lastestStateLog={latestStateLog} |
1921 | 1920 | bind:autoScroll={autoScrollLog} |
1922 | 1921 | closeWindow={() => closePersistLog()} |
1923 | 1922 | cleanScreen={() => cleanPersistLogScreen()} |
|
0 commit comments