From be2800c2482bad309048e72b694de896070a96f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E6=98=8E?= <83812544+Ed1s0nZ@users.noreply.github.com> Date: Mon, 6 Jul 2026 10:39:55 +0800 Subject: [PATCH] Add files via upload --- web/static/i18n/en-US.json | 1 + web/static/i18n/zh-CN.json | 1 + web/static/js/chat.js | 21 +++++++++++++++++++++ web/static/js/monitor.js | 8 ++++++-- web/static/js/workflows.js | 11 +++++++---- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json index 109be1e6..d196e988 100644 --- a/web/static/i18n/en-US.json +++ b/web/static/i18n/en-US.json @@ -597,6 +597,7 @@ "knowledgeRetrievalTag": "Knowledge retrieval", "error": "Error", "streamNetworkErrorHint": "Connection lost ({{detail}}). A long task may still be running on the server; check running tasks at the top or refresh this conversation later.", + "streamEndedWithoutDone": "The connection ended before a completion signal was received. The task may still be running on the server; check running tasks at the top or refresh this conversation.", "taskCancelled": "Task cancelled", "userInterruptContinueTitle": "⏸️ User interrupt & continue", "unknownTool": "Unknown tool", diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json index 040ff776..c8b097a2 100644 --- a/web/static/i18n/zh-CN.json +++ b/web/static/i18n/zh-CN.json @@ -585,6 +585,7 @@ "knowledgeRetrievalTag": "知识检索", "error": "错误", "streamNetworkErrorHint": "连接已中断({{detail}})。长时间任务可能仍在后端执行,请查看顶部「运行中」任务或稍后刷新本对话。", + "streamEndedWithoutDone": "连接提前结束,未收到任务完成信号。任务可能仍在后端执行,请查看顶部「运行中」任务或刷新当前对话。", "taskCancelled": "任务已取消", "userInterruptContinueTitle": "⏸️ 用户中断并继续", "unknownTool": "未知工具", diff --git a/web/static/js/chat.js b/web/static/js/chat.js index 9f7b1c40..82fbc951 100644 --- a/web/static/js/chat.js +++ b/web/static/js/chat.js @@ -1105,7 +1105,11 @@ async function sendMessage() { const reader = response.body.getReader(); const decoder = new TextDecoder(); let buffer = ''; + let streamSawDone = false; const dispatchStreamEvent = function (eventData) { + if (eventData && eventData.type === 'done') { + streamSawDone = true; + } handleStreamEvent(eventData, progressElement, progressId, () => assistantMessageId, (id) => { assistantMessageId = id; }, () => mcpExecutionIds, (ids) => { mcpExecutionIds = ids; }); @@ -1142,6 +1146,23 @@ async function sendMessage() { const lines = buffer.split('\n'); await processSseLines(lines, dispatchStreamEvent); } + if (!streamSawDone) { + if (typeof loadActiveTasks === 'function') { + loadActiveTasks(); + } + const convId = currentConversationId || (body && body.conversationId) || null; + let attached = false; + if (convId && typeof window.attachRunningTaskEventStream === 'function') { + window.__csAgentLiveStream = { active: false, conversationId: null, progressId: null }; + attached = await window.attachRunningTaskEventStream(convId).catch(() => false); + } + if (!attached) { + const hint = typeof window.t === 'function' + ? window.t('chat.streamEndedWithoutDone') + : '连接提前结束,未收到任务完成信号。任务可能仍在后端执行,请查看顶部运行中任务或刷新当前对话。'; + addMessage('system', hint); + } + } } finally { window.__csAgentLiveStream = { active: false, conversationId: null, progressId: null }; if (window.CyberStrikeChatScroll) { diff --git a/web/static/js/monitor.js b/web/static/js/monitor.js index 56b84360..8ffbbeab 100644 --- a/web/static/js/monitor.js +++ b/web/static/js/monitor.js @@ -3331,7 +3331,11 @@ async function attachRunningTaskEventStream(conversationId) { const reader = response.body.getReader(); const decoder = new TextDecoder(); let buffer = ''; + let replaySawDone = false; const dispatchTaskEvent = function (eventData) { + if (eventData && eventData.type === 'done') { + replaySawDone = true; + } handleStreamEvent(eventData, null, progressId, getAssistantIdFn, setAssistantIdFn, function () { return mcpIds; }, function (ids) { mcpIds = mergeMcpExecutionIDLists(mcpIds, ids || []); }); }; while (true) { @@ -3351,14 +3355,14 @@ async function attachRunningTaskEventStream(conversationId) { if (window.csTaskReplay && window.csTaskReplay.progressId === progressId) { clearCsTaskReplay(); } - if (progressTaskState.has(progressId)) { + if (replaySawDone && progressTaskState.has(progressId)) { finalizeProgressTask(progressId, typeof window.t === 'function' ? window.t('tasks.statusCompleted') : '已完成'); } if (window.CyberStrikeChatScroll && typeof window.CyberStrikeChatScroll.onTaskEventStreamEnd === 'function') { window.CyberStrikeChatScroll.onTaskEventStreamEnd(); } if (typeof loadActiveTasks === 'function') loadActiveTasks(); - if (typeof window.loadConversation === 'function' && window.currentConversationId === conversationId) { + if (replaySawDone && typeof window.loadConversation === 'function' && window.currentConversationId === conversationId) { await window.loadConversation(conversationId); } return true; diff --git a/web/static/js/workflows.js b/web/static/js/workflows.js index 3192f491..50324aec 100644 --- a/web/static/js/workflows.js +++ b/web/static/js/workflows.js @@ -805,7 +805,7 @@ } else if (workflows.length) { fillWorkflowForm(workflows[0]); } else { - newWorkflowDraft(); + newWorkflowDraft({ openMeta: false }); return; } renderWorkflowList(); @@ -815,7 +815,8 @@ } }; - window.newWorkflowDraft = function () { + window.newWorkflowDraft = function (options) { + const shouldOpenMeta = !options || options.openMeta !== false; currentWorkflowId = ''; fillWorkflowForm({ id: '', @@ -825,7 +826,9 @@ graph_json: defaultGraph() }); syncWorkflowMetaIdField(false, ''); - openWorkflowMetaModal(); + if (shouldOpenMeta) { + openWorkflowMetaModal(); + } }; window.selectWorkflow = function (id) { @@ -1032,7 +1035,7 @@ } currentWorkflowId = ''; showNotification(_t('workflows.deleted'), 'success'); - newWorkflowDraft(); + newWorkflowDraft({ openMeta: false }); await refreshWorkflows(); };