fix(console): 侧栏项目 agent 徽标改用 s.running,修复 planner/spec 阶段徽标缺失 (tsk_0u7OP3RFBAqr)
侧栏项目 agent 计数徽标原绑定 s.executing(仅统计任务恰处 executing 状态), 与「运行中」青点(s.running)及 tooltip『N agents running』语义不一致。 当 Hard(analyzing/planner) 或 Medium(speccing) 任务有在途 agent 时,s.executing=0 导致徽标缺失(如 maestro 项目)。改取 s.running(runs.status=started,覆盖各阶段)。 新增 test/adapt.test.ts 锁定该映射。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+4
-1
@@ -25,7 +25,10 @@ export function adaptProject(p) {
|
||||
return {
|
||||
id: p.id, name: p.name, path: shortPath(p.repoPath), branch: p.defaultBranch,
|
||||
autonomy: p.autonomy, concurrency: p.concurrency, hue: hueFor(p.name),
|
||||
state, pending: s.attention || 0, agents: s.executing || 0, blocked: s.blocked || 0,
|
||||
// agents 徽标 = 实际在途 agent 数(runs.status='started',含 planner/spec/executor 各阶段),
|
||||
// 与「运行中」青点同源(s.running);不可用 s.executing——那只统计任务恰处 executing 状态,
|
||||
// 会漏掉 analyzing(planner)/speccing(spec) 阶段正在跑的 agent,导致徽标缺失。
|
||||
state, pending: s.attention || 0, agents: s.running || 0, blocked: s.blocked || 0,
|
||||
// 透传给 ConfigPanel 用的原始字段
|
||||
model: p.model, verifyCmd: p.verifyCmd, maxRetries: p.maxRetries, repoPath: p.repoPath,
|
||||
logo: p.logo, budgetUsd: p.budgetUsd ?? null, budgetPeriod: p.budgetPeriod ?? 'month',
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
// adapt.js 是前端纯函数适配层(app/src),用 node:test 直接校验项目摘要映射。
|
||||
import { adaptProject } from '../app/src/adapt.js';
|
||||
|
||||
const baseProject = {
|
||||
id: 'p1', name: 'maestro', repoPath: '/Users/x/dev/maestro', defaultBranch: 'main',
|
||||
autonomy: 'auto-easy', concurrency: 2, status: 'active',
|
||||
};
|
||||
|
||||
test('adaptProject: agents 徽标取 s.running(实际在途 agent),而非 s.executing', () => {
|
||||
// planner/spec 阶段:有真实在途 run(running>0)但没有 executing 任务 → 徽标必须仍显示 agent 数
|
||||
const p = adaptProject({ ...baseProject, summary: { running: 1, executing: 0, blocked: 0, attention: 0 } });
|
||||
assert.equal(p.agents, 1, 'analyzing/speccing 阶段也应计入 agent 徽标');
|
||||
assert.equal(p.state, 'running');
|
||||
});
|
||||
|
||||
test('adaptProject: 无在途 run 时 agents 徽标为 0(即使有 executing 任务计数错位)', () => {
|
||||
const p = adaptProject({ ...baseProject, summary: { running: 0, executing: 0, blocked: 2, attention: 1 } });
|
||||
assert.equal(p.agents, 0);
|
||||
assert.equal(p.blocked, 2);
|
||||
assert.equal(p.pending, 1);
|
||||
assert.equal(p.state, 'blocked');
|
||||
});
|
||||
|
||||
test('adaptProject: summary 缺省时各计数回退 0', () => {
|
||||
const p = adaptProject({ ...baseProject });
|
||||
assert.equal(p.agents, 0);
|
||||
assert.equal(p.pending, 0);
|
||||
assert.equal(p.blocked, 0);
|
||||
});
|
||||
Reference in New Issue
Block a user