From 5a4c821629d3f5512fef51a82cfa6e1259031b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Wed, 12 Aug 2026 01:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=20drainQueue=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E4=BA=92=E6=96=A5+deep=20watch=E6=8C=87=E7=BA=B9+?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=89=93=E7=A3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ai/MessageList.vue | 22 +++++++++++++--------- src/components/task/TaskOutputCard.vue | 1 - src/composables/ai/useAiSend.ts | 9 +++++++++ src/styles/components.css | 4 ++-- src/views/ProjectDetail.vue | 9 +++------ src/views/TaskDetail.vue | 18 ++---------------- src/views/Tasks.vue | 10 +++++++--- 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/components/ai/MessageList.vue b/src/components/ai/MessageList.vue index cbbd74e..3f78cd2 100644 --- a/src/components/ai/MessageList.vue +++ b/src/components/ai/MessageList.vue @@ -309,21 +309,25 @@ function scrollToFirstPending(): void { } } +/** + * 移除 deep:true,改在 watch source 中计算指纹(消息数 + toolCalls 的 id/status), + * 避免 deep 每帧全量深遍历长会话数组引起掉帧。流式 delta 只改 content 不影响指纹, + * 不触发无意义的收起重算。length 变化(新消息/截断)和 toolCall 状态翻转(新卡/完成/拒绝) + * 均能正确触发——与 body 的快照收缩逻辑等价,无需 deep 兜底。 + */ let lastMsgSnapshot = '' watch( - () => store.state.messages, - (msgs) => { - const snap = JSON.stringify({ - n: msgs.length, - tc: msgs.map(m => (m.toolCalls || []).map(t => ({ id: t.id, s: t.status }))), - }) + () => JSON.stringify({ + n: store.state.messages.length, + tc: store.state.messages.map(m => (m.toolCalls || []).map(t => ({ id: t.id, s: t.status }))), + }), + (snap) => { if (snap === lastMsgSnapshot) return const isFirst = lastMsgSnapshot === '' lastMsgSnapshot = snap - if (isFirst) return // 首次加载/切换对话不触发收起 - collapseAllToolLists(buildActiveToolIds(msgs)) + if (isFirst) return + collapseAllToolLists(buildActiveToolIds(store.state.messages)) }, - { deep: true }, ) // UX-260616-03: AiAgentRound 新轮次到达时收起上一轮工具卡(round 递增)。 diff --git a/src/components/task/TaskOutputCard.vue b/src/components/task/TaskOutputCard.vue index 77c1ed0..b786d1f 100644 --- a/src/components/task/TaskOutputCard.vue +++ b/src/components/task/TaskOutputCard.vue @@ -4,7 +4,6 @@