Add files via upload

This commit is contained in:
公明
2026-05-20 17:48:42 +08:00
committed by GitHub
parent 05ca0c1480
commit b9bf8f62d4
6 changed files with 77 additions and 16 deletions
+26
View File
@@ -3064,6 +3064,27 @@ function getConversationGroup(dateObj, todayStart, sevenDaysCutoff, yesterdaySta
}
// 加载对话
/** 轻量加载会话后,拉取最后一条助手消息的 process_details(机器人等无 SSE 场景) */
async function prefetchLastAssistantProcessDetails() {
const nodes = document.querySelectorAll('#chat-messages .message.assistant');
if (!nodes.length) return;
const last = nodes[nodes.length - 1];
if (!last || !last.id) return;
const container = document.getElementById('process-details-' + last.id);
if (!container || container.dataset.lazyNotLoaded !== '1') return;
const backendId = last.dataset && last.dataset.backendMessageId;
if (!backendId || typeof apiFetch !== 'function') return;
const res = await apiFetch('/api/messages/' + encodeURIComponent(String(backendId)) + '/process-details');
const j = await res.json().catch(() => ({}));
if (!res.ok || !Array.isArray(j.processDetails) || j.processDetails.length === 0) return;
if (typeof renderProcessDetails === 'function') {
renderProcessDetails(last.id, j.processDetails);
}
if (typeof window.expandProcessDetailsTimeline === 'function') {
window.expandProcessDetailsTimeline(last.id);
}
}
async function loadConversation(conversationId) {
const seq = ++loadConversationRequestSeq;
try {
@@ -3283,6 +3304,11 @@ async function loadConversation(conversationId) {
.catch((e) => {
console.warn('attachRunningTaskEventStream on loadConversation failed', e);
});
} else if (seq === loadConversationRequestSeq && currentConversationId === conversationId) {
// 机器人等非 Web 流式来源:会话已结束或未注册任务时,按需拉取最后一条助手消息的过程详情
prefetchLastAssistantProcessDetails().catch((e) => {
console.warn('prefetchLastAssistantProcessDetails failed', e);
});
}
} catch (error) {
console.error('加载对话失败:', error);