fix: showSpinnerTree 模式下保留 local-agent token 显示

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] <deepseek-ai@claude-code-best.win>
This commit is contained in:
cepvor
2026-05-14 20:45:24 +08:00
parent 80b46d2221
commit e7070e072f

View File

@@ -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;
}
}
}