From e7070e072f2781148688264ab0dc4b8b7674a38d Mon Sep 17 00:00:00 2001 From: cepvor Date: Thu, 14 May 2026 20:45:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20showSpinnerTree=20=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E4=BF=9D=E7=95=99=20local-agent=20token=20=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #1226 的 CodeRabbit 审查指出:当 spinner-tree 模式开启时, local-agent(后台代理)的 token 消耗完全不可见,因为它们没有 在树中有独立行,但被 showSpinnerTree 的 guard 排除了。 修复:将 guard 从循环外移到循环内,仅对 in_process_teammate 任务在 tree 模式下跳过(它们有独立树行),local-agent 任务 始终计入 teammateTokens。 Closes: review comment from PR #1226 (originally belongs to PR #1225) Co-Authored-By: deepseek-v4-pro[1m] --- src/components/Spinner.tsx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/components/Spinner.tsx b/src/components/Spinner.tsx index 5d8e156224..33a82a460f 100644 --- a/src/components/Spinner.tsx +++ b/src/components/Spinner.tsx @@ -210,15 +210,22 @@ function SpinnerWithVerbInner({ const hasRunningTeammates = runningTeammates.length > 0; const allIdle = hasRunningTeammates && runningTeammates.every(t => t.isIdle); - // Gather aggregate token stats from all running swarm teammates - // In spinner-tree mode, skip aggregation (teammates have their own lines in the tree) + // Gather aggregate token stats from all running agents. + // In spinner-tree mode, skip in-process teammates (they have their own + // per-teammate lines in the tree) but still count local-agent tasks + // (background agents) which have no dedicated tree rows. let teammateTokens = 0; - if (!showSpinnerTree) { - for (const task of Object.values(tasks)) { - if (task.status === 'running' && (isInProcessTeammateTask(task) || isLocalAgentTask(task))) { - if (task.progress?.tokenCount) { - teammateTokens += task.progress.tokenCount; - } + for (const task of Object.values(tasks)) { + if (task.status !== 'running') continue; + if (isInProcessTeammateTask(task)) { + if (!showSpinnerTree && task.progress?.tokenCount) { + teammateTokens += task.progress.tokenCount; + } + continue; + } + if (isLocalAgentTask(task)) { + if (task.progress?.tokenCount) { + teammateTokens += task.progress.tokenCount; } } }