修复: BUG-260624-01残留(scrollToFirstPending return过早+listener props过滤)

This commit is contained in:
2026-06-24 17:38:40 +08:00
parent a7dbd50a4d
commit ebba9735ed
2 changed files with 8 additions and 4 deletions

View File

@@ -313,9 +313,11 @@ let _unlistenPending: UnlistenFn | null = null
let _disposed = false
onMounted(async () => {
const fn = await listen('ai-pending-arrived', () => {
// nextTick 等 pending_approval 类挂到 DOM 后再查(scrollToFirstPending 查 .ai-tool-card--pending_approval)。
// 多个 ToolCardList 实例(每条 AI 消息一个)各自 listen,querySelector 只命中自身 root 内的
// pending 卡,非含 pending 卡的实例查 null no-op,天然过滤不串扰。
// BUG-260624-01 残留优化:本实例无 pending 卡时短路返回,避免大列表 N 个 ToolCardList 实例
// 每次广播都跑 querySelector(N 实例 × M 次 emit = N×M 次 DOM 查询)。原靠 scrollToFirstPending
// 内 querySelector 返 null no-op 天然过滤(功能正确),此处显式 props 过滤把无 pending 实例挡在
// 进入函数前。含 pending 的实例再走 nextTick + scrollToFirstPending(展开折叠组 + scroll)。
if (!props.toolCalls.some(tc => tc.status === 'pending_approval')) return
nextTick(() => scrollToFirstPending())
})
// 解析时若已卸载(HMR/极速 mount/unmount),立即 unlisten 刚拿到的句柄,防孤儿监听器。