feat(tasks): 小条只说原生状态、聚合按组展开、浮窗活动行移到标题下

用户 brief:下方条不再显示「运行中」而是原生状态;「最近活动」以小字号写到
标题下方;展开不要点一个全开;顺带修其他的。

四条用户确认的口径:

- 小条(图模式 CardBar):运行中/已结算都由**活动行取代状态词**,措辞取宿主
  `chat` 命名空间(正在分析请求 / 正在读取文件 · main.ts / 正在准备读取文件 /
  正在运行命令 · npm run build),与主对话逐字一致。**`空闲` 与 `出错` 保留
  状态词**(不被任何活动措辞蕴含),**没有活动数据时回退状态词**,小条不空。
  状态点、执行扫光、折叠 chevron、22px 高度全不变 → 画布几何零改动。
- 根节点接上 live:live 路由一直把拓扑根的 fold 放进 `live[rootSessionId]`,而
  模型从未挂到根节点上——主代理卡片的状态文本因此恒为 thinking 兜底(这就是
  「大部分时间一直显示正在分析请求」的真因),树模式根行也恒为「思考中…」。
- 节点详情:删掉「最近活动 | 值」那一行(键值格的值列在 280px 被省略、标签又
  占三分之一宽),改为标题下的 10px 活动行 + 夹两行的实时文本;**无数据不渲染
  这一块**(此前每个浮窗都显示「最近活动:正在分析请求」,已结算节点也一样)。
  新增共享规则 `activityLine(node)`:running → 宿主 live 措辞,其余 → 宿主
  done.* 措辞,无 summary → undefined(调用方回退状态词,不谎报)。删 `tasksNodeActivity`(20 份词典)。
- 按组展开:模型新增 `expandedGroups`(键 = 新增的导出 `foldGroupId`,哈希
  `fold:<parentId>[:idle]`),只覆盖「本来就要折」的分支——点聚合只开该组,兄弟组/
  页级规则/手工折叠都不动。页面侧 `expandGroup` 同时把该组成员从 `foldedIds` 摘掉,
  **控制条收起时清空按组展开**(判据写在收起分支,自查时抓到一次反了并补了判别性
  用例:翻回去即红)。树里的聚合行同一语义,行内副文案固定为「展开」。
- 聚合卡计数只说一次:待命组徽标此前印**字面量字母 N**(`tasksFoldIdleGroup` 在 20 份
  词典里都没有 `{count}` 插值),现在插值真实计数;小条只留 `出错 N` 尾注 + 展开箭头,
  完整 tally 仍是 `aria-label` 与 tooltip(屏幕阅读器看不到徽标)。
- 树模式实时行图标按活动类别取:`tool-icons.tsx`(工具名映射,只有一处写死 bash 的
  调用)换成 `activity-icons.tsx` 的 `activityGlyph(kind)`,`Record<ProcessActivity, …>`
  让上游新增类别编译失败而不是静默兜底。

测试 2227 passed / 17 skipped(190 文件)、tsc 0 错误、eslint 0 错误、构建通过。
tasks-page 新增 FakeChatLocale(挂宿主 chat 命名空间,否则只能断言到 fallback 的
detail,钉不住契约)。设计文档 docs/plans/2026-10-11-tasks-status-and-group-fold.md,
其中记录了「README 的 v0.22.0 发布说明不改」的偏差理由(git log -L 显示那四条自发布
提交后再未被碰过,进行中通道是 CHANGELOG 的 Unreleased)。
This commit is contained in:
Menghuan1918 committed 2026-10-11 22:04:28 +08:00
1 parent 64a61ccfe4
commit 79ee383c5e
35 files changed
+934 -218

No files matched your search

+10
View File
@@ -2,6 +2,16 @@
> 本文档收录 dsh-better-sidebar 的完整发布历史(最新版摘要见 [README](README.md);同步发布于 [GitHub Releases](https://github.com/omdsh-dev/DSH-better-sidebar/releases))。
### Unreleased
- 🃏 **任务卡小条只说原生状态**:运行中小条不再是「● 运行中 正在读取文件」这样把状态念两遍,而是**活动行取代状态词**——`正在分析请求` / `正在读取文件 · main.ts` / `正在准备读取文件` / `正在运行命令 · npm run build` 等措辞全部来自宿主 `chat` 命名空间,与主对话逐字一致;已结算小条同理(只留 `已读取文件、执行了命令`,不重复「已完成」)。**`空闲` 与 `出错` 保留状态词**(「待命」「失败」不被任何活动措辞蕴含),**完全没有活动数据时回退状态词**,小条永不空着。状态点、执行扫光与折叠 chevron 不变,小条仍是 22px——画布几何与卡片高度预算零改动。
- 🧩 **主代理卡片接上自己的实时数据**:`subagents.live` 路由一直把拓扑根的 fold 结果放在 `live[rootSessionId]`,而模型从未把它挂到根节点上——于是**主代理卡片的状态文本恒为 thinking 兜底**(「正在分析请求」),与主会话在做什么无关。现在根卡显示真实状态,树模式根行的实时行也从恒定的「思考中…」变成真实活动。
- 🔎 **节点详情浮窗的活动行移到标题下方**:那行原来在键值格里(`最近活动 | 值`),右对齐的值列在 280px 里被省略,标签又占掉三分之一宽;现在它是标题下的一行 10px 小字(宿主措辞),实时文本尾行紧接其下并夹到两行。**没有活动数据就不渲染这一块**——此前每个节点浮窗都会显示「最近活动:正在分析请求」,已结算节点也不例外。词条 `tasksNodeActivity` 随这一行从 20 份词典删除。
- 🗂 **聚合卡改为「按组展开」**:点一个聚合卡只展开**该组**(`fold:<parentId>` / `fold:<parentId>:idle`),兄弟组、页级折叠与手工折叠都不受影响——此前一次点击会清空手工折叠集并关掉全局规则,等于**点一个全开**。控制条按钮仍是页级展开/折叠,且**收起时清掉按组展开**(全局收起必须真的收起);树里的聚合行同一语义,行内副文案固定为「展开」(该行只在折叠态存在)。
- 🔢 **聚合卡不再两处写计数**:待命组的徽标此前印的是**字面量字母 N**(`tasksFoldIdleGroup` 在 20 份词典里都是 `'N waiting' / 'N 个待命'`,没有 `{count}` 插值)——现在插值出真实计数,小条只保留`出错 N` 尾注与展开箭头;完整 tally 仍是卡片的 `aria-label` 与 tooltip。
- 🎨 **树模式实时行的图标按活动类别取**:`tool-icons.tsx`(工具名映射,只有一处写死的调用)换成 `activity-icons.tsx` 的 `activityGlyph(kind)`——读文件 / 搜索 / 编辑 / 命令 / 网页 / 子代理 / 计划 / 提问 / 通用工具各用自己的宿主图标,尚未派发时是思考图标;`Record<ProcessActivity, …>` 让上游新增类别编译失败而不是静默兜底。
- 🧪 测试:`tests/tasks-page.spec.tsx` 新增一个 `FakeChatLocale`(挂宿主 `chat` 命名空间,否则只能断言到 fallback 的 detail)并补 5 条(原生状态取代状态词、无数据回退、根卡真实状态、浮窗活动块位置与「无数据不渲染」、一次只开一组+全局收起折回、徽标真实计数);`tests/tasks-model.spec.ts` 补 4 条(按组展开的双向隔离、组 id、`expandedGroups` 盖过残留手工折叠、根节点带 live);新增 `tests/activity-icons.spec.ts`(类别全覆盖 + 读/命令/搜索/网页互不同型 + `undefined` 走思考图标)。[设计文档](docs/plans/2026-10-11-tasks-status-and-group-fold.md)。
### v0.25.0
> 📦 **支持线前移:仅适配 DSH `0.2.0-rc.2+`**(peer 下限 `^0.2.0-rc.2`,CI 与挂载 lane 钉 `@deepseek-ai/dsh@0.2.0-rc.2`)。DSH 的 npm `latest` 现在正是 **0.2.0-rc.2**(不再停在 0.1.7-rc.2),本版就钉在它上面。**0.2.0-rc.1 及更早(含 0.1.7 线)请固定 v0.24.1**——`^0.2.0-rc.2` 对 rc.1 判定为 false,会被宿主的启动兼容性预检整行静默禁用;0.1.7 线的最后支持版是 v0.22.1。本次前移是一次纯声明与钉版变更:0.2.0-rc.2 对本插件消费的宿主面仍是纯增量,运行时零改动。
@@ -0,0 +1,142 @@
# 任务管理页:小条只说原生状态 + 按组展开 + 浮窗活动行
日期:2026-10-11 分支:`feat/tasks-status-and-group-fold`(自 `dev` 顶端 `64a61cc` 切出)
## 背景:用户 brief(原文)
> 优化任务管理面板:
> - 下方条不再显示运行中,进行中时直接写为:正在分析请求/正在准备读取文件/正在更新计划等待这个原生的状态,现在往往大部分时间是一直显示正在分析请求
> - 最近活动的内容可以以小字号的形式写到标题下方
> - 优化下展开/折叠的逻辑,不要点一个展开就把全部都展开
> - 其他你认为需要优化的UI部分
>
> 保持KISS原则,如有任意不清楚的地方,都向我详细确认
「下方条」经确认 = 图模式卡片的下方小条(`src/client/tasks-card.tsx` 的 `CardBar`),它当时的真机读数见
[2026-09-27-tasks-graph-polish.md](2026-09-27-tasks-graph-polish.md) G1:根卡 `主代理 / … / 运行中 / 正在分析请求`。
## 用户确认的决策(问答摘要)
| # | 问题 | 结论 |
|---|---|---|
| 1 | 「下方条」范围 | **图模式小条**:状态点 + 原生状态,不再出现「运行中」;**树模式行内 meta 保持现状**(仍是「一次性 · 运行中」),本轮不动 |
| 2 | 「一直是正在分析请求」怎么处理 | **两处都修**:① 根卡接上 live 数据;② 浮窗按节点状态取措辞、无数据就不显示该行 |
| 3 | 「最近活动」写到哪里 | 节点详情浮窗**去掉「最近活动」标签**,内容以 10px 小字写在标题下方(对应词条一并删除) |
| 4 | 展开/折叠语义 | **点聚合卡只展开该组**;控制条按钮仍是全局展开/折叠 |
| 5 | 其它 UI 优化(多选) | ✅ 树模式实时行图标按活动类别取 ✅ 已结算小条同样去重(不显示「已完成」) ✅ 聚合卡不再两处都写计数 |
## 现状与根因(读码核实,非推测)
1. **小条渲染两段**:`CardBar` = `[状态点] 状态词 + 活动行`。运行中卡片因此是「● 运行中 正在运行命令 · npm run build」——状态词与活动行说了同一件事。
2. **根节点没有 live**:`buildTasksModel` 的根节点字面量不含 `live` 字段(子节点有),而 `subagent-live-route.ts` 早已把根的 fold 结果放进 `live[rootSessionId]`。于是**主代理卡片的状态文本恒为 `liveActivityLabel(undefined)` 的 thinking 兜底**,它与主会话在做什么无关——这就是「大部分时间一直显示正在分析请求」的第一处真因。
3. **浮窗的活动行恒有话说**:`AgentNodePopover` 用 `liveActivityLabel(node.live?.summary)`;`summary` 为 undefined 时宿主词典在真实部署里存在,函数返回 `message.stepProcess.thinking`(正在分析请求)。于是**每个节点的详情浮窗几乎恒显示「最近活动:正在分析请求」**,已结算节点也走运行中措辞——第二处真因。
4. **聚合点击 = 全部展开**:`SubagentView.expandFold()` 清空 `foldedIds` 并 `setFolded(false)`;树里的聚合行也是 `onToggleFold`(全局)。两处都是「点一个,全开」。
5. **聚合徽标印的是字母 N**:`tasksFoldIdleGroup` 在 20 份词典里都是字面量 `'N waiting' / 'N 个待命'`(无 `{count}` 插值),徽标因此永远显示「N 个待命」。
6. **树模式实时行恒画终端图标**:`LiveLine` 写死 `toolGlyph('bash')`,而 `tool-icons.tsx` 的工具名映射其余部分是死代码(该函数只有这一个调用点)。
## 关键设计
### 1. 状态词让位活动行(`CardBar`)
```
运行中卡片 ● 正在读取文件 · main.ts ← 活动行取代状态词(原生措辞)
已结算卡片 ● 已读取文件、执行了命令 ← 同为活动行
空闲 / 出错 ● 空闲 … ● 出错 已调用工具 ← 保留状态词
无任何数据 ● 运行中 / 已完成 ← 回退状态词,小条不空
```
- 判据:`activity` 非空且 `state` 不是 `idle` / `error` 时不渲染状态词。**`idle` 与 `error` 刻意保留**:「待命」「失败」不被任何活动措辞蕴含,去掉就是把那条小条唯一该说的话藏起来(这条写进了 `CardBar` 的 docstring)。
- 状态点、`data-running` 扫光、折叠 chevron 全部不变;卡片高度预算(小条恒 22px)不变,所以 `tasks-graph-layout.ts` 与画布几何零改动。
### 2. 一条共享的活动规则 `activityLine(node)`
`tasks-shared.tsx` 新增(卡片小条与详情浮窗共用,两处不可能再各说各话):
```
summary === undefined → undefined(调用方回退状态词,绝不谎报)
state === 'running' → liveActivityLabel(summary) // 宿主 message.stepProcess.*
否则(done / idle / error) → doneActivityTitle(summary) // 宿主 message.stepProcess.done.*
```
它替掉了 `TasksGraph` 里私有的 `barActivity`,也修掉了浮窗对已结算节点用运行中措辞的问题。
### 3. 根节点接上 live
`buildTasksModel` 的根节点 push 带上 `live: childLive(live, rootId)`(缺失时不挂字段)。
由此:主代理卡片显示真实状态;树模式根行的实时行也从恒定的「思考中…」变成真实活动。
`live[rootId]` 为空对象时行为退回状态词——这是**有意的**:不知道的事不说。
### 4. 按组展开
- 模型新增入参 `expandedGroups?: ReadonlySet<string>`,键是**组 id**:`foldGroupId(foldKind, parentId)` →
`fold:<parentId>`(已完成组)/ `fold:<parentId>:idle`(待命组),`foldNode()` 与页面共用它,一处定义。
- 折叠判定只在「本来要折」的分支上追加一次询问:组被展开 → 该成员落回 `kept`(保持目录顺序),
兄弟组、页级规则与逐节点手动折叠**都不受影响**。
- 页面:`expandGroup(node)` 把组 id 入集,并把 `node.memberIds` 从 `foldedIds` 摘掉
(聚合点击的含义是「现在给我看这些节点」,不该被手工折叠留在里面);
**控制条收起时清空 `expandedGroups`**(全局收起必须真的收起),展开时不动它。
- 树里的聚合行同一语义,行内副文案固定为「展开」——该行只在折叠态存在,旧实现按页级 `folded` 写「折叠」是自相矛盾的。
### 5. 聚合卡计数只说一次
徽标是计数的家:待命组徽标改为 `tasksFoldIdleGroup` 的**真实插值**(`{count} 个待命`),小条只保留
`foldErrorTally(node)`(`出错 N`,无出错则空)+展开箭头。完整 tally(`foldTally`)仍是卡片的
`aria-label` 与 tooltip —— 屏幕阅读器看不到徽标,只有这一条路。
### 6. 实时行图标按活动类别
`tool-icons.tsx` → `activity-icons.tsx`:`activityGlyph(kind: ProcessActivity | undefined)`,
`Record<ProcessActivity, Glyph>`(**类型强制全覆盖**,上游加类别会编译失败而不是静默兜底)。
`undefined`(尚未派发,宿主措辞就是「正在分析请求」)→ 思考图标。已删除无消费者的工具名映射。
## 实施偏差记录(写给复审)
1. **README 的 v0.22.0 发布说明没有改**(计划里原写「同步 4 条」)。`git log -L` 显示
`README.md` 的「最近更新 → v0.22.0」下那四条自 2026-09-27 的发布提交后再未被任何提交碰过——
它们是**冻结的发布历史**,而仓库的进行中通道是 `CHANGELOG.md` 的 `### Unreleased`(先例:`2f66c92`
的 #774 批次)。因此本轮把变更写进 **CHANGELOG 的 Unreleased 段 + 本文档**;若维护者希望 README
的发布说明也按当前行为改写,这是一次单文件改写,随时可加。
2. **`idle` / `error` 保留状态词**:用户选项只点名了「运行中」与「已完成」。这两个状态的活动措辞
(子代理的 `done.*` 摘要)读起来都像「刚做完事」,去掉状态词会把「在等下一轮」「失败了」藏起来。
3. **`tasksFoldIdleGroup` 是插值改动而不是删词条**:它本来就是给徽标用的键,只是值写成了占位符
`N`。改为 `{count} …`(zh/en/zh-HK/zh-MO/zh-TW/ja 各自保留自己的语序),20 份同批改。
4. **`tasksNodeActivity` 从 20 份词典删除**(不是留着不用):浮窗那一行没了,留着就是死词条;
`tests/locales.spec.ts` 的键集合相等守护要求这一次同批改完。
5. **`CardBar` 的判定写在组件里而不是调用方**:`stateWord` 是调用方参数(聚合卡传 false),
「活动行取代状态词」是同一条呈现规则的内部细节,让每个调用点各判一次只会让两处漂移。
6. **树模式行内 meta 不动**(用户明确选择)。它仍是「一次性 · 运行中」+下方实时行,
与图模式小条的读法不同是有意保留的差异。
7. **自查抓到并修掉的一处判据反了**:按组展开的清空时机最初写在**展开**分支上
(`if (folded) setExpandedGroups(∅)`),应该写在**收起**分支(`if (!folded) …`)——否则
「页级展开 → 手工折一个 → 打开该聚合 → 点控制条收起」会留下那个组仍然展开,而兄弟节点全折了。
已补 `tests/tasks-page.spec.tsx` 的「drops the per-group openings when the CLUSTER collapses the page」
用例;把判据翻回去即红(实测),这条用例是判别性的。
## 验证证据
| 项 | 结果 |
|---|---|
| `tsc --noEmit`(等价 `pnpm typecheck`) | ✅ 0 错误 |
| `eslint .` | ✅ 0 错误 |
| `vitest run`(全套) | ✅ **2227 passed / 17 skipped / 0 failed**(190 文件) |
| `tsc -p tsconfig.build.json` + `tsdown` | ✅ 构建通过(核心 bundle 与三个 chunk 正常产出) |
本轮新增/改写的守护:
| 文件 | 内容 |
|---|---|
| `tests/tasks-model.spec.ts` | 按组展开(done 组开了、idle 组仍折叠;反向亦然)、组 id 就是聚合行 id、`expandedGroups` 盖过残留的手工折叠、run 成员组的展开、根节点带 live(含「无数据即无字段」) |
| `tests/tasks-page.spec.tsx` | 运行中小条 = 原生状态且**不含**「运行中」;无 summary 回退「运行中」;已结算小条不含「已完成」;根卡显示主会话真实状态;浮窗活动块位置/文案/无数据不渲染且不含「最近活动」「正在分析请求」;**一次点击只开一组、兄弟组仍折叠**,控制条全局收起把展开过的组重新折回(含那条判别性用例);待命徽标真实计数、小条不再重复计数 |
| `tests/activity-icons.spec.ts`(新) | 13 个类别各渲染出元素;`read` / `commands` / `search` / `webSearch` 互不同型(钉住「不再恒画终端图标」);`undefined` 走思考图标且不等于任何类别 |
| 既有期望跟随设计 | 待命聚合的 `'3 待命' / 'N 个待命'` → `'3 个待命'`(徽标插值) |
`tests/tasks-page.spec.tsx` 新增一个 `FakeChatLocale`(`active: 'zh'` + `bind('chat')` 供
`message.stepProcess.*`),`afterEach` 里 `attachLocale(undefined)`:**活动行的字来自宿主 `chat`
命名空间**,不挂这个假 locale 就只能断言到 fallback 的 detail,钉不住真正的契约。
## 未验证项(如实记录)
- **没有跑真机**:本 worktree 未装进任何 DSH profile,也没有起服务器。上面全部结论来自 jsdom 单测与构建产物;
卡片小条的实际观感(原生状态与状态点/扫光的搭配、260px 窄栏下的省略行为)、浮窗那两行小字的真实换行
都需要真机或截图复核。
- 因此也没有 `pnpm test:mount` 记录。
+49 -12
View File
@@ -20,8 +20,9 @@
*
* Node click jumps straight into the transcript (root → main session); the
* ⓘ button opens the detail popover. Completed leaf agents fold into one
* aggregate node per parent (click it or the control-cluster toggle to
* expand/collapse).
* aggregate node per GROUP (finished work / waiting members); clicking an
* aggregate reveals THAT group, while the control cluster's switch keeps the
* page-level expand/collapse.
*
* The shell itself is the page's own module stylesheet plus host primitives:
* the header's refresh and the failure banner's retry are host `Button`s, the
@@ -57,7 +58,7 @@ import {
clientJobs, collectRows, useJobObservation, useJobWatchers, useJobsSnapshot,
} from './jobs-client.ts'
import { t } from './locales.ts'
import { buildTasksModel, type TasksAgentNode, type TasksWorkflowNode } from './tasks-model.ts'
import { buildTasksModel, type TasksAgentNode, type TasksFoldNode, type TasksWorkflowNode } from './tasks-model.ts'
import { TasksGraph } from './TasksGraph.tsx'
import { TasksTree } from './TasksTree.tsx'
import { JobsDrawer, JobOutputWindow } from './JobsDrawer.tsx'
@@ -242,9 +243,17 @@ export function SubagentView(props: {
/**
* Nodes the reader folded by hand from their own card bar. Kept apart from
* `folded` (the global rule) so the control cluster and a single card never
* fight: the aggregate's click clears BOTH, which is what "expand" means.
* fight.
*/
const [foldedIds, setFoldedIds] = useState<ReadonlySet<string>>(() => new Set())
/**
* The fold GROUPS the reader opened by clicking one aggregate card. Expanding
* an aggregate reveals that group ONLY — it used to clear the manual folds and
* switch the global rule off, so one click unfolded the whole page. The
* control cluster keeps the page-level expand/collapse; collapsing there drops
* these per-group openings (a global collapse must really collapse).
*/
const [expandedGroups, setExpandedGroups] = useState<ReadonlySet<string>>(() => new Set())
const [teamBoardCollapsed, setTeamBoardCollapsed] = useState(false)
const [popover, setPopover] = useState<PagePopover | null>(null)
@@ -262,8 +271,9 @@ export function SubagentView(props: {
teamTasks: team?.tasks ?? [],
folded,
foldedIds,
expandedGroups,
})),
[byId, catalogs, rootId, sessionId, live, runs, teamMembers, team, folded, foldedIds],
[byId, catalogs, rootId, sessionId, live, runs, teamMembers, team, folded, foldedIds, expandedGroups],
)
/**
@@ -336,12 +346,38 @@ export function SubagentView(props: {
})
}, [])
/** Expand every fold: the global rule off AND the manual folds cleared. */
const expandFold = useCallback((): void => {
setFolded(false)
setFoldedIds(current => (current.size === 0 ? current : new Set()))
/**
* Expand ONE aggregate: the group the reader clicked shows its members while
* every other group stays folded. The members it held are also released from
* the manual per-node set — clicking an aggregate means "show me these nodes
* now", and a hand-folded member left in `foldedIds` would stay hidden inside
* a group the reader just opened.
*/
const expandGroup = useCallback((node: TasksFoldNode): void => {
setExpandedGroups(current => {
if (current.has(node.id)) return current
const next = new Set(current)
next.add(node.id)
return next
})
setFoldedIds(current => {
if (!node.memberIds.some(id => current.has(id))) return current
const next = new Set(current)
for (const id of node.memberIds) next.delete(id)
return next
})
}, [])
/**
* The control cluster's page-level switch. COLLAPSING there re-folds every
* group, so the per-group openings are dropped with it; expanding leaves them
* (an unfolded page already shows everything they would reveal).
*/
const toggleFold = useCallback((): void => {
if (!folded) setExpandedGroups(current => (current.size === 0 ? current : new Set()))
setFolded(!folded)
}, [folded])
/** Open the shared task window from a board row (undefined = create). */
const openTaskFromBoard = useCallback((
task: { id: string } | undefined,
@@ -557,8 +593,8 @@ export function SubagentView(props: {
onNodeInfo={(node, anchor) => { setPopover({ kind: 'node', nodeId: node.id, anchor }) }}
onWorkflowInfo={(node, anchor) => { setPopover({ kind: 'workflow', nodeId: node.id, anchor }) }}
onOpenTask={openTaskById}
onToggleFold={() => { setFolded(current => !current) }}
onExpandFold={expandFold}
onToggleFold={toggleFold}
onExpandGroup={expandGroup}
onFoldNode={foldNode}
mode={mode}
onModeChange={setModeOverride}
@@ -572,7 +608,8 @@ export function SubagentView(props: {
onNodeInfo={(node, anchor) => { setPopover({ kind: 'node', nodeId: node.id, anchor }) }}
onWorkflowInfo={(node, anchor) => { setPopover({ kind: 'workflow', nodeId: node.id, anchor }) }}
onOpenTask={openTaskById}
onToggleFold={() => { setFolded(current => !current) }}
onToggleFold={toggleFold}
onExpandGroup={expandGroup}
mode={mode}
onModeChange={setModeOverride}
/>
+24 -28
View File
@@ -41,10 +41,10 @@ import {
type GraphBox,
} from './tasks-graph-layout.ts'
import {
agentIdentity, agentMeta, foldPreviews, foldTally, TaskLine, WorkflowGlyph, workflowMeta,
activityLine, agentIdentity, agentMeta, foldErrorTally, foldPreviews, foldTally,
TaskLine, WorkflowGlyph, workflowMeta,
} from './tasks-shared.tsx'
import { CardBar, CardTop, phaseClass, type CardKind } from './tasks-card.tsx'
import { doneActivityTitle, liveActivityLabel } from './process-labels.ts'
import { t } from './locales.ts'
import css from './tasks-graph.module.css'
import canvasCss from './tasks-canvas.module.css'
@@ -77,18 +77,6 @@ function agentCardKind(node: TasksAgentNode): CardKind {
return node.parentId === undefined ? 'main' : 'subagent'
}
/**
* The bar's activity line. A running node shows the LIVE merged activity; a
* settled one shows the same merged wording in its completed form (the host's
* own `done.*` phrasing) — a settled card whose bar read only "已完成" would
* throw away the one thing the fold is for.
*/
function barActivity(node: TasksAgentNode): string | undefined {
const summary = node.live?.summary
if (node.state === 'running') return liveActivityLabel(summary)
return summary === undefined ? undefined : doneActivityTitle(summary)
}
/** Members of one run that already reported an outcome. */
function doneMembers(node: TasksWorkflowNode): number {
let done = 0
@@ -129,8 +117,8 @@ export interface TasksGraphProps {
onOpenTask(taskId: string, anchor: HTMLElement): void
/** The control cluster's global fold switch (settled leaves). */
onToggleFold(): void
/** The fold AGGREGATE's click: expand everything (global + manual folds). */
onExpandFold(): void
/** The fold AGGREGATE's click: reveal THIS group's members only. */
onExpandGroup(node: TasksFoldNode): void
/** Fold ONE settled node into its parent's aggregate (the bar's chevron). */
onFoldNode(node: TasksAgentNode): void
mode: 'graph' | 'tree'
@@ -193,7 +181,7 @@ export function FoldToggleButton(props: { folded: boolean; onToggleFold(): void
export function TasksGraph(props: TasksGraphProps): ReactNode {
const {
nodes, folded, rootId, onNodeInfo, onWorkflowInfo, onOpenTask, onToggleFold, onExpandFold,
nodes, folded, rootId, onNodeInfo, onWorkflowInfo, onOpenTask, onToggleFold, onExpandGroup,
onFoldNode, mode, onModeChange, loading,
} = props
const containerRef = useRef<HTMLDivElement>(null)
@@ -502,7 +490,7 @@ export function TasksGraph(props: TasksGraphProps): ReactNode {
const box = layout.boxes.get(node.id)
if (box === undefined) return null
const style = { left: box.x, top: box.y, width: GRAPH_NODE_W, minHeight: box.h }
if (node.kind === 'fold') return renderFoldNode(node, style, onExpandFold, clickAllowed)
if (node.kind === 'fold') return renderFoldNode(node, style, onExpandGroup, clickAllowed)
if (node.kind === 'workflow') {
return renderWorkflowNode(node, style, onWorkflowInfo, clickAllowed)
}
@@ -572,6 +560,8 @@ function renderAgentNode(
* and only there.
*/
const foldable = (settled || node.state === 'idle') && node.parentId !== undefined
/** The merged process line the bar shows in place of the state word. */
const activity = activityLine(node)
return (
<div
key={node.id}
@@ -606,7 +596,7 @@ function renderAgentNode(
<CardBar
state={node.state}
running={node.state === 'running'}
{...(barActivity(node) === undefined ? {} : { activity: barActivity(node) })}
{...(activity === undefined ? {} : { activity })}
{...(foldable && !node.current && onFold !== undefined
? { onFold: () => { onFold(node) } }
: {})}
@@ -655,15 +645,23 @@ function renderWorkflowNode(
}
/**
* One fold aggregate node: the completed leaves of one parent, collapsed. Its
* bar is the action row (expand), so the whole card stays one click target.
* One fold aggregate node: the finished or the waiting members of one parent,
* collapsed. Its bar is the action row (expand THIS group), so the whole card
* stays one click target.
*
* The count is printed ONCE: the badge names it, so the bar only carries what
* the badge cannot say — a stray failure ("出错 N" would otherwise hide inside
* the ✓) — beside the expand chevron. The full tally stays the card's
* accessible name and tooltip, which a screen reader reads instead of the
* badge's inner text.
*/
function renderFoldNode(
node: TasksFoldNode,
style: { left: number; top: number; width: number; minHeight: number },
onToggleFold: () => void,
onExpandGroup: (node: TasksFoldNode) => void,
clickAllowed: () => boolean,
): ReactNode {
const errors = foldErrorTally(node)
return (
<div
key={node.id}
@@ -676,7 +674,7 @@ function renderFoldNode(
style={style}
onClick={() => {
if (!clickAllowed()) return
onToggleFold()
onExpandGroup(node)
}}
>
<CardTop
@@ -688,11 +686,9 @@ function renderFoldNode(
extraClass={css.cardNamePlain}
/>
<CardBar state={node.foldKind === 'idle' ? 'idle' : 'done'} stateWord={false}>
{/* The bar SAYS what the row holds — "✓ N 已完成 · 出错 N" for finished
work (a stray failure would otherwise hide inside the ✓) and
"N 待命" for the waiting members. No action word: the tally needs
the room and the chevron already points at 展开. */}
<span className={css.barActivity} title={foldTally(node)}>{foldTally(node)}</span>
{errors !== undefined && (
<span className={css.barActivity} title={foldTally(node)}>{errors}</span>
)}
<span className={css.barFold} aria-hidden="true">
<IconChevronDownOutlineRegular size={12} />
</span>
+26 -13
View File
@@ -2,8 +2,8 @@
* The anchored-popover CONTENTS of the Tasks page (geometry and dismissal
* live in AnchoredPopover): the agent node detail with a transcript jump and
* the workflow run detail with clickable member rows. Both share one grammar:
* a letter-spaced uppercase head, a dt/dd key/value grid, a titled well and
* one full-width jump action.
* a letter-spaced uppercase head, a [glyph][title] title row, a dt/dd
* key/value grid, a titled well and one full-width jump action.
*
* The two cards are ONE skeleton: the same head band, the same [glyph][title]
* title row (the card's own host glyph, never a typed character), the same
@@ -30,10 +30,9 @@ import { Button, IconRightUpOutlineRegular, StateDot, Tag } from '@deepseek-ai/d
import type { SidebarSubagentAddress } from '../context-types.ts'
import type { TasksAgentNode, TasksWorkflowNode } from './tasks-model.ts'
import {
AgentGlyph, WorkflowGlyph, flatten, modeLabel, nodeDotState, taskDotState,
activityLine, AgentGlyph, WorkflowGlyph, flatten, modeLabel, nodeDotState, taskDotState,
taskStatusLabel, taskTone, workflowStatusKey,
} from './tasks-shared.tsx'
import { liveActivityLabel } from './process-labels.ts'
import { t, type CopyKey } from './locales.ts'
import css from './tasks-graph.module.css'
@@ -72,7 +71,16 @@ function PopTitleRow(props: { glyph: ReactNode; title: string }): ReactNode {
)
}
/** The agent node detail popover. */
/**
* The agent node detail popover.
*
* The merged activity is a SUBTITLE, not a fact: it sits under the title in
* the card's smallest voice instead of filling a row of the key/value grid
* (where the right-aligned value column ellipsised it at 280px and the label
* "最近活动" spent a third of the width saying what the position already says).
* With no process data at all the block renders nothing — a settled node must
* never claim to be analysing a request.
*/
export function AgentNodePopover(props: {
node: TasksAgentNode
onJump(node: TasksAgentNode): void
@@ -84,14 +92,25 @@ export function AgentNodePopover(props: {
const nodeMode = modeLabel(node.mode)
const liveText = node.live?.text !== undefined ? flatten(node.live.text) : undefined
// The merged activity the main conversation would show for this node's
// newest range (category wording + the running call's detail).
const liveTool = liveActivityLabel(node.live?.summary)
// newest range — the host's own wording, in its running or settled form
// (see activityLine).
const activity = activityLine(node)
return (
<div className={css.popCard}>
<div className={css.popHead}>
<span>{t('tasksNodeDetail')}</span>
</div>
<PopTitleRow glyph={<AgentGlyph node={node} />} title={node.label} />
{(activity !== undefined || liveText !== undefined) && (
<div className={css.popActivityBlock} data-node-activity>
{activity !== undefined && (
<span className={css.popActivity} title={activity}>{activity}</span>
)}
{liveText !== undefined && (
<span className={css.popHint} title={liveText}>{liveText}</span>
)}
</div>
)}
<PopRows>
<PopRow label={t('tasksNodeState')}>
<StateDot state={nodeDotState(node.state)} size={6} /> {t(stateKey(node.state))}
@@ -104,13 +123,7 @@ export function AgentNodePopover(props: {
{node.team.role === 'lead' ? 'lead' : node.team.name}
</PopRow>
)}
{(liveTool !== undefined || liveText !== undefined) && (
<PopRow label={t('tasksNodeActivity')} mono>{liveTool ?? liveText}</PopRow>
)}
</PopRows>
{liveText !== undefined && liveTool !== undefined && (
<div className={css.popHint}>{liveText}</div>
)}
{(node.tasks?.length ?? 0) > 0 && (
<div className={css.popSection}>
<div className={css.popGroup}>{t('tasksNodeTasks')}</div>
+15 -9
View File
@@ -7,8 +7,8 @@
*
* Behaviour contract: `role="tree"` / `role="treeitem"` + `aria-level`, a
* `[data-tasks-row]` focus order, ArrowUp / ArrowDown / Home / End focus moves,
* Enter / Space activation, and the global fold aggregate (a fold row toggles
* the whole page's fold state).
* Enter / Space activation, and the fold rows (a fold row reveals its OWN
* group; the control cluster keeps the page-level switch).
*
* Readability: rows sit on the page's 32px rhythm (a 2px accent bar marks the
* current session, hover is the native fill, settled rows recede), and every
@@ -18,7 +18,7 @@
import { useCallback, useMemo, useRef, type KeyboardEvent, type ReactNode } from 'react'
import clsx from 'clsx'
import { IconLoadingOutlineRegular, StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
import type { TasksAgentNode, TasksNode, TasksWorkflowNode } from './tasks-model.ts'
import type { TasksAgentNode, TasksFoldNode, TasksNode, TasksWorkflowNode } from './tasks-model.ts'
import {
AgentGlyph, agentMeta, FoldGlyph, foldPreviews, foldTally, LiveLine, nodeDotState,
TaskLine, WorkflowGlyph, workflowMeta,
@@ -34,7 +34,10 @@ export interface TasksTreeProps {
onWorkflowInfo(node: TasksWorkflowNode, anchor: HTMLElement): void
/** Open the shared task window for one task id. */
onOpenTask(taskId: string, anchor: HTMLElement): void
/** The control cluster's page-level fold switch. */
onToggleFold(): void
/** A fold row's own click: reveal THIS group's members only. */
onExpandGroup(node: TasksFoldNode): void
mode: 'graph' | 'tree'
onModeChange(mode: 'graph' | 'tree'): void
/** Fallback loading row while the root catalog hydrates. */
@@ -43,7 +46,8 @@ export interface TasksTreeProps {
export function TasksTree(props: TasksTreeProps): ReactNode {
const {
nodes, folded, onNodeInfo, onWorkflowInfo, onOpenTask, onToggleFold, mode, onModeChange, loading,
nodes, folded, onNodeInfo, onWorkflowInfo, onOpenTask, onToggleFold, onExpandGroup,
mode, onModeChange, loading,
} = props
const bodyRef = useRef<HTMLDivElement>(null)
@@ -106,16 +110,18 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
aria-level={depth + 1}
aria-label={`${foldTally(node)} · ${t('tasksFoldExpand')}`}
className={clsx(css.treeRow, css.treeFoldRow)}
onClick={onToggleFold}
onKeyDown={(event) => { activateOnKey(event, onToggleFold) }}
onClick={() => { onExpandGroup(node) }}
onKeyDown={(event) => { activateOnKey(event, () => { onExpandGroup(node) }) }}
>
<span className={css.treeGlyph} aria-hidden="true"><FoldGlyph /></span>
<span className={css.treeContent}>
<span className={css.treeTitle}>
{foldTally(node)}
<span className={css.treeMeta}>
{t(folded ? 'tasksFoldExpand' : 'tasksFoldCollapse')}
</span>
{/* The row only EXISTS while its group is folded, so its action is
always "expand" — the old reading followed the page-level
`folded` flag, which said "collapse" on a row that offers to do
the opposite. */}
<span className={css.treeMeta}>{t('tasksFoldExpand')}</span>
</span>
<span className={css.treeMeta} title={foldPreviews(node.previews, node.count)}>
{foldPreviews(node.previews, node.count)}
+61
View File
@@ -0,0 +1,61 @@
/**
* The glyph of one MERGED ACTIVITY line on the Tasks page — the icon the tree
* mode's live row draws beside the host's own wording ("正在读取文件",
* "正在运行命令 · npm run build", …).
*
* The key is the host's `ProcessActivity` category (the same union
* `process-activity.ts` reproduces from the chat bundle), not a tool name: the
* row shows a MERGED summary of the newest range, which is a category, and the
* previous fixed terminal glyph made every row claim to be running a shell
* command. The `Record` type keeps the map TOTAL — a category added upstream
* fails the build here instead of silently falling back.
*
* All icons are the host's own components (currentColor — zero color literals,
* the theme contract stays intact).
*/
import type { ReactNode } from 'react'
import {
IconCodeOutlineRegular,
IconEditOutlineRegular,
IconEllipsisOutlineRegular,
IconGlobeOutlineRegular,
IconPlanOutlineRegular,
IconPlayOutlineRegular,
IconQuestionOutlineRegular,
IconSearchOutlineRegular,
IconThinkOutlineRegular,
IconUsersOutlineRegular,
} from '@deepseek-ai/dsh-client-ui-primitives'
import type { ProcessActivity } from '../process-activity.ts'
/** One glyph renderer (host icon components accept a pixel size). */
type Glyph = (size: number) => ReactNode
/** The explicit category map, one family per kind of work. */
const ACTIVITY_GLYPHS: Record<ProcessActivity, Glyph> = {
read: size => <IconCodeOutlineRegular size={size} />,
readImage: size => <IconCodeOutlineRegular size={size} />,
search: size => <IconSearchOutlineRegular size={size} />,
write: size => <IconEditOutlineRegular size={size} />,
edit: size => <IconEditOutlineRegular size={size} />,
commands: size => <IconPlayOutlineRegular size={size} />,
code: size => <IconPlayOutlineRegular size={size} />,
webSearch: size => <IconGlobeOutlineRegular size={size} />,
webFetch: size => <IconGlobeOutlineRegular size={size} />,
subagents: size => <IconUsersOutlineRegular size={size} />,
plan: size => <IconPlanOutlineRegular size={size} />,
questions: size => <IconQuestionOutlineRegular size={size} />,
tools: size => <IconEllipsisOutlineRegular size={size} />,
}
/**
* The glyph of one activity line.
*
* @param kind - the newest range's running category, or undefined while
* nothing is dispatched (the host's "thinking" wording, which is what the
* live line prints in that case).
*/
export function activityGlyph(kind: ProcessActivity | undefined): Glyph {
if (kind === undefined) return size => <IconThinkOutlineRegular size={size} />
return ACTIVITY_GLYPHS[kind]
}
+1 -2
View File
@@ -447,7 +447,7 @@ export const ar: Record<string, string> = {
settingsViewModeGraphDesc: 'مخطط عُقد متدرج مع تكبير وتحريك',
settingsViewModeTree: 'شجرة',
settingsViewModeTreeDesc: 'شجرة كلاسيكية بمسافات بادئة، قابلة للتنقل بلوحة المفاتيح',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} مكتمل',
tasksFoldOne: 'الطي مع المكتملة',
@@ -463,7 +463,6 @@ export const ar: Record<string, string> = {
tasksNodeMode: 'الوضع',
tasksNodeModel: 'الطراز',
tasksNodeTeamRole: 'دور الفريق',
tasksNodeActivity: 'آخر نشاط',
tasksStateRunning: 'قيد التشغيل',
tasksStateIdle: 'خامل',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -432,7 +432,7 @@ export const de: Record<string, string> = {
settingsViewModeGraphDesc: 'Geschichtetes Knotendiagramm mit Zoom und Schwenken',
settingsViewModeTree: 'Baum',
settingsViewModeTreeDesc: 'Klassischer Einrückungsbaum, per Tastatur navigierbar',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} abgeschlossen',
tasksFoldOne: 'Zu Erledigten falten',
@@ -448,7 +448,6 @@ export const de: Record<string, string> = {
tasksNodeMode: 'Modus',
tasksNodeModel: 'Modell',
tasksNodeTeamRole: 'Teamrolle',
tasksNodeActivity: 'Letzte Aktivität',
tasksStateRunning: 'Läuft',
tasksStateIdle: 'Bereit',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -439,7 +439,7 @@ export const fr: Record<string, string> = {
settingsViewModeGraphDesc: 'Graphe de nœuds en couches, avec zoom et panoramique',
settingsViewModeTree: 'Arbre',
settingsViewModeTreeDesc: 'Arbre à indentation classique, navigable au clavier',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} terminés',
tasksFoldOne: 'Replier avec les terminés',
@@ -455,7 +455,6 @@ export const fr: Record<string, string> = {
tasksNodeMode: 'Mode',
tasksNodeModel: 'Modèle',
tasksNodeTeamRole: 'Rôle dans l’équipe',
tasksNodeActivity: 'Dernière activité',
tasksStateRunning: 'En cours',
tasksStateIdle: 'Inactif',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -446,7 +446,7 @@ export const hi: Record<string, string> = {
settingsViewModeGraphDesc: 'स्तरित नोड ग्राफ़, ज़ूम और पैन के साथ',
settingsViewModeTree: 'ट्री',
settingsViewModeTreeDesc: 'क्लासिक इंडेंटेड ट्री, कीबोर्ड से नेविगेट करने योग्य',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} पूर्ण',
tasksFoldOne: 'पूर्ण में समेटें',
@@ -462,7 +462,6 @@ export const hi: Record<string, string> = {
tasksNodeMode: 'मोड',
tasksNodeModel: 'मॉडल',
tasksNodeTeamRole: 'टीम भूमिका',
tasksNodeActivity: 'नवीनतम गतिविधि',
tasksStateRunning: 'चल रहा है',
tasksStateIdle: 'निष्क्रिय',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -444,7 +444,7 @@ export const id: Record<string, string> = {
settingsViewModeGraphDesc: 'Graf node berlapis dengan zoom dan pan',
settingsViewModeTree: 'Pohon',
settingsViewModeTreeDesc: 'Pohon indentasi klasik, dapat dinavigasi dengan keyboard',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} selesai',
tasksFoldOne: 'Lipat ke selesai',
@@ -460,7 +460,6 @@ export const id: Record<string, string> = {
tasksNodeMode: 'Mode',
tasksNodeModel: 'Model',
tasksNodeTeamRole: 'Peran tim',
tasksNodeActivity: 'Aktivitas terbaru',
tasksStateRunning: 'Berjalan',
tasksStateIdle: 'Siaga',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -437,7 +437,7 @@ export const it: Record<string, string> = {
settingsViewModeGraphDesc: 'Grafo di nodi a livelli, con zoom e pan',
settingsViewModeTree: 'Albero',
settingsViewModeTreeDesc: 'Albero a rientri classico, navigabile da tastiera',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} completati',
tasksFoldOne: 'Raggruppa nei completati',
@@ -453,7 +453,6 @@ export const it: Record<string, string> = {
tasksNodeMode: 'Modalità',
tasksNodeModel: 'Modello',
tasksNodeTeamRole: 'Ruolo nel team',
tasksNodeActivity: 'Ultima attività',
tasksStateRunning: 'In esecuzione',
tasksStateIdle: 'In attesa',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -446,7 +446,7 @@ export const ja: Record<string, string> = {
settingsViewModeGraphDesc: '階層ノードグラフ(ズーム・パン対応)',
settingsViewModeTree: 'ツリー',
settingsViewModeTreeDesc: '従来のインデントツリー(キーボード操作可)',
tasksFoldIdleGroup: 'N 件待機',
tasksFoldIdleGroup: '{count} 件待機',
tasksFoldIdle: '待機 {count}',
tasksFoldCompleted: '✓ {count} 件完了',
tasksFoldOne: '完了済みにまとめる',
@@ -462,7 +462,6 @@ export const ja: Record<string, string> = {
tasksNodeMode: 'モード',
tasksNodeModel: 'モデル',
tasksNodeTeamRole: 'チーム役割',
tasksNodeActivity: '最新アクティビティ',
tasksStateRunning: '実行中',
tasksStateIdle: '待機',
tasksStateProvisioning: '準備中',
+1 -2
View File
@@ -438,7 +438,7 @@ export const ko: Record<string, string> = {
settingsViewModeGraphDesc: '계층형 노드 그래프, 확대/이동 가능',
settingsViewModeTree: '트리',
settingsViewModeTreeDesc: '클래식 들여쓰기 트리, 키보드 탐색 지원',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} 완료됨',
tasksFoldOne: '완료 항목으로 접기',
@@ -454,7 +454,6 @@ export const ko: Record<string, string> = {
tasksNodeMode: '모드',
tasksNodeModel: '모델',
tasksNodeTeamRole: '팀 역할',
tasksNodeActivity: '최근 활동',
tasksStateRunning: '실행 중',
tasksStateIdle: '대기 중',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -444,7 +444,7 @@ export const nl: Record<string, string> = {
settingsViewModeGraphDesc: 'Gelaagde knoppengrafiek met in- en uitzoomen en pannen',
settingsViewModeTree: 'Boom',
settingsViewModeTreeDesc: 'Klassieke inspringboom, navigeerbaar met het toetsenbord',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} voltooid',
tasksFoldOne: 'Vouwen bij afgerond',
@@ -460,7 +460,6 @@ export const nl: Record<string, string> = {
tasksNodeMode: 'Modus',
tasksNodeModel: 'Model',
tasksNodeTeamRole: 'Teamrol',
tasksNodeActivity: 'Laatste activiteit',
tasksStateRunning: 'Bezig',
tasksStateIdle: 'Inactief',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -448,7 +448,7 @@ export const pl: Record<string, string> = {
settingsViewModeGraphDesc: 'Warstwowy graf węzłów ze zoomowaniem i przesuwaniem',
settingsViewModeTree: 'Drzewo',
settingsViewModeTreeDesc: 'Klasyczne drzewo wcięć, nawigowalne z klawiatury',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} ukończonych',
tasksFoldOne: 'Zwiń do ukończonych',
@@ -464,7 +464,6 @@ export const pl: Record<string, string> = {
tasksNodeMode: 'Tryb',
tasksNodeModel: 'Model',
tasksNodeTeamRole: 'Rola w zespole',
tasksNodeActivity: 'Ostatnia aktywność',
tasksStateRunning: 'Działa',
tasksStateIdle: 'Gotowe',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -429,7 +429,7 @@ export const pt: Record<string, string> = {
settingsViewModeGraphDesc: 'Grafo de nós em camadas, com zoom e deslocamento',
settingsViewModeTree: 'Árvore',
settingsViewModeTreeDesc: 'Árvore com indentação clássica, navegável pelo teclado',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} concluídos',
tasksFoldOne: 'Dobrar nos concluídos',
@@ -445,7 +445,6 @@ export const pt: Record<string, string> = {
tasksNodeMode: 'Modo',
tasksNodeModel: 'Modelo',
tasksNodeTeamRole: 'Função na equipe',
tasksNodeActivity: 'Atividade recente',
tasksStateRunning: 'Em execução',
tasksStateIdle: 'Em espera',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -444,7 +444,7 @@ export const ru: Record<string, string> = {
settingsViewModeGraphDesc: 'Многоуровневый граф узлов с масштабированием и панорамированием',
settingsViewModeTree: 'Дерево',
settingsViewModeTreeDesc: 'Классическое дерево с отступами, навигация с клавиатуры',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} завершено',
tasksFoldOne: 'Свернуть в завершённые',
@@ -460,7 +460,6 @@ export const ru: Record<string, string> = {
tasksNodeMode: 'Режим',
tasksNodeModel: 'Модель',
tasksNodeTeamRole: 'Роль в команде',
tasksNodeActivity: 'Последняя активность',
tasksStateRunning: 'Выполняется',
tasksStateIdle: 'Ожидает',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -429,7 +429,7 @@ export const sv: Record<string, string> = {
settingsViewModeGraphDesc: 'Lagerindelad nodgraf med zoom och panorering',
settingsViewModeTree: 'Träd',
settingsViewModeTreeDesc: 'Klassiskt indragsträd, navigerbart med tangentbord',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} klara',
tasksFoldOne: 'Vik ihop med klara',
@@ -445,7 +445,6 @@ export const sv: Record<string, string> = {
tasksNodeMode: 'Läge',
tasksNodeModel: 'Modell',
tasksNodeTeamRole: 'Teamroll',
tasksNodeActivity: 'Senaste aktivitet',
tasksStateRunning: 'Körs',
tasksStateIdle: 'Vilar',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -446,7 +446,7 @@ export const th: Record<string, string> = {
settingsViewModeGraphDesc: 'กราฟโหนดแบบชั้น ซูมและเลื่อนได้',
settingsViewModeTree: 'มุมมองต้นไม้',
settingsViewModeTreeDesc: 'ต้นไม้แบบเยื้องคลาสสิก นำทางด้วยคีย์บอร์ดได้',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ เสร็จแล้ว {count}',
tasksFoldOne: 'พับรวมกับที่เสร็จแล้ว',
@@ -462,7 +462,6 @@ export const th: Record<string, string> = {
tasksNodeMode: 'โหมด',
tasksNodeModel: 'โมเดล',
tasksNodeTeamRole: 'บทบาทในทีม',
tasksNodeActivity: 'กิจกรรมล่าสุด',
tasksStateRunning: 'กำลังทำงาน',
tasksStateIdle: 'พร้อม',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -446,7 +446,7 @@ export const tr: Record<string, string> = {
settingsViewModeGraphDesc: 'Yakınlaştırma ve kaydırma ile katmanlı düğüm grafiği',
settingsViewModeTree: 'Ağaç',
settingsViewModeTreeDesc: 'Klasik girintili ağaç, klavye ile gezilebilir',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} tamamlandı',
tasksFoldOne: 'Tamamlananlara katla',
@@ -462,7 +462,6 @@ export const tr: Record<string, string> = {
tasksNodeMode: 'Mod',
tasksNodeModel: 'Model',
tasksNodeTeamRole: 'Takım rolü',
tasksNodeActivity: 'Son etkinlik',
tasksStateRunning: 'Çalışıyor',
tasksStateIdle: 'Beklemede',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -446,7 +446,7 @@ export const vi: Record<string, string> = {
settingsViewModeGraphDesc: 'Đồ thị nút phân tầng với thu phóng và di chuyển',
settingsViewModeTree: 'Cây',
settingsViewModeTreeDesc: 'Cây thụt lề cổ điển, điều hướng được bằng bàn phím',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} hoàn thành',
tasksFoldOne: 'Gộp vào đã xong',
@@ -462,7 +462,6 @@ export const vi: Record<string, string> = {
tasksNodeMode: 'Chế độ',
tasksNodeModel: 'Mô hình',
tasksNodeTeamRole: 'Vai trò trong nhóm',
tasksNodeActivity: 'Hoạt động gần đây',
tasksStateRunning: 'Đang chạy',
tasksStateIdle: 'Nhàn rỗi',
tasksStateProvisioning: 'Provisioning',
+1 -2
View File
@@ -461,7 +461,7 @@ export const zhHK: Record<string, string> = {
settingsViewModeGraphDesc: '分層節點圖,可縮放平移',
settingsViewModeTree: '樹狀圖',
settingsViewModeTreeDesc: '經典縮排樹,可用鍵盤導航',
tasksFoldIdleGroup: 'N 個待命',
tasksFoldIdleGroup: '{count} 個待命',
tasksFoldIdle: '{count} 待命',
tasksFoldCompleted: '✓ {count} 已完成',
tasksFoldOne: '收進已完成聚合',
@@ -477,7 +477,6 @@ export const zhHK: Record<string, string> = {
tasksNodeMode: '模式',
tasksNodeModel: '模型',
tasksNodeTeamRole: '團隊角色',
tasksNodeActivity: '最近活動',
tasksStateRunning: '執行中',
tasksStateIdle: '閒置',
tasksStateProvisioning: '部署中',
+1 -2
View File
@@ -461,7 +461,7 @@ export const zhMO: Record<string, string> = {
settingsViewModeGraphDesc: '分層節點圖,可縮放平移',
settingsViewModeTree: '樹狀圖',
settingsViewModeTreeDesc: '經典縮排樹,可用鍵盤導航',
tasksFoldIdleGroup: 'N 個待命',
tasksFoldIdleGroup: '{count} 個待命',
tasksFoldIdle: '{count} 待命',
tasksFoldCompleted: '✓ {count} 已完成',
tasksFoldOne: '收進已完成聚合',
@@ -477,7 +477,6 @@ export const zhMO: Record<string, string> = {
tasksNodeMode: '模式',
tasksNodeModel: '模型',
tasksNodeTeamRole: '團隊角色',
tasksNodeActivity: '最近活動',
tasksStateRunning: '執行中',
tasksStateIdle: '閒置',
tasksStateProvisioning: '部署中',
+1 -2
View File
@@ -461,7 +461,7 @@ export const zhTW: Record<string, string> = {
settingsViewModeGraphDesc: '分層節點圖,可縮放平移',
settingsViewModeTree: '樹狀圖',
settingsViewModeTreeDesc: '經典縮排樹,可用鍵盤導航',
tasksFoldIdleGroup: 'N 個待命',
tasksFoldIdleGroup: '{count} 個待命',
tasksFoldIdle: '{count} 待命',
tasksFoldCompleted: '✓ {count} 已完成',
tasksFoldOne: '收進已完成聚合',
@@ -477,7 +477,6 @@ export const zhTW: Record<string, string> = {
tasksNodeMode: '模式',
tasksNodeModel: '模型',
tasksNodeTeamRole: '團隊角色',
tasksNodeActivity: '最近活動',
tasksStateRunning: '執行中',
tasksStateIdle: '閒置',
tasksStateProvisioning: '部署中',
+2 -4
View File
@@ -458,7 +458,7 @@ export const zh = {
settingsViewModeGraphDesc: '分层节点图,可缩放平移',
settingsViewModeTree: '树状图',
settingsViewModeTreeDesc: '经典缩进树,键盘可导航',
tasksFoldIdleGroup: 'N 个待命',
tasksFoldIdleGroup: '{count} 个待命',
tasksFoldIdle: '{count} 待命',
tasksFoldCompleted: '✓ {count} 已完成',
tasksFoldOne: '收进已完成聚合',
@@ -474,7 +474,6 @@ export const zh = {
tasksNodeMode: '模式',
tasksNodeModel: '模型',
tasksNodeTeamRole: '团队角色',
tasksNodeActivity: '最近活动',
tasksStateRunning: '运行中',
tasksStateIdle: '待命',
tasksStateProvisioning: '部署中',
@@ -1029,7 +1028,7 @@ export const en: Record<keyof typeof zh, string> = {
settingsViewModeGraphDesc: 'Layered node graph with zoom and pan',
settingsViewModeTree: 'Tree',
settingsViewModeTreeDesc: 'Classic indentation tree, keyboard navigable',
tasksFoldIdleGroup: 'N waiting',
tasksFoldIdleGroup: '{count} waiting',
tasksFoldIdle: 'Idle {count}',
tasksFoldCompleted: '✓ {count} completed',
tasksFoldOne: 'Fold into completed',
@@ -1045,7 +1044,6 @@ export const en: Record<keyof typeof zh, string> = {
tasksNodeMode: 'Mode',
tasksNodeModel: 'Model',
tasksNodeTeamRole: 'Team role',
tasksNodeActivity: 'Latest activity',
tasksStateRunning: 'Running',
tasksStateIdle: 'Idle',
tasksStateProvisioning: 'Provisioning',
+34 -10
View File
@@ -1,8 +1,15 @@
/**
* The two-segment node card of the Tasks graph: a TOP segment that says WHAT
* the node is (kind badge, name, mono meta, optional task line) and a BOTTOM
* bar that says WHAT IT IS DOING (state dot + state word + the merged process
* activity, plus the fold chevron once the node has settled).
* bar that says WHAT IT IS DOING (state dot + the merged process activity —
* or, when there is no activity to show, the state word — plus the fold
* chevron once the node has settled).
*
* The state word YIELDS to the activity line: "运行中 · 正在读取文件" and
* "已完成 · 已读取文件" both printed the state twice inside one 22px strip,
* and the dot beside them already carries it. `idle` and `error` keep their
* word — neither "waiting for a turn" nor "failed" is implied by any activity
* wording, so dropping them would hide the one thing that bar has to say.
*
* Both modes share the model but NOT the card: the TREE keeps its compact
* indent row (its own disclosure, its own keyboard recipe), so this module is
@@ -35,9 +42,13 @@ export type CardFoldKind = 'done' | 'idle'
* header already calls the root "主代理"), so no sixth word is invented for it.
*
* The two aggregates say different things, because they hold different work:
* `done` keeps "✓ N 已完成" (finished and failed rows alike) while `idle` says
* "N 个待命". One mixed row could only have hedged ("✓ 2 已完成 · 3 待命"),
* which is exactly what splitting them removed.
* `done` keeps "✓ N 已完成" (finished and failed rows alike) while `idle`
* counts its waiting members. One mixed row could only have hedged
* ("✓ 2 已完成 · 3 待命"), which is exactly what splitting them removed.
*
* The badge is where an aggregate's COUNT lives, so it interpolates the real
* number: the idle branch used to print the literal copy 'N 个待命', which
* read as an unfilled placeholder on every idle aggregate.
* @param kind - card kind.
* @param count - folded member count (the fold aggregate's badge only).
* @param foldKind - which aggregate (`done` unless stated).
@@ -49,7 +60,7 @@ export function cardKindLabel(kind: CardKind, count = 0, foldKind: CardFoldKind
case 'teammate': return t('tasksKindTeammate')
case 'workflow': return t('tasksKindWorkflow')
case 'fold': return foldKind === 'idle'
? t('tasksFoldIdleGroup')
? t('tasksFoldIdleGroup', { count })
: t('tasksFoldCompleted', { count })
}
}
@@ -119,7 +130,7 @@ export function CardTop(props: {
)
}
/** The bottom bar: the node's state, its merged activity, and its fold chevron. */
/** The bottom bar: the node's activity (or its state word), dot and chevron. */
export function CardBar(props: {
state: TasksNodeState
/** The merged process activity line (running nodes and settled summaries). */
@@ -136,6 +147,19 @@ export function CardBar(props: {
children?: ReactNode
}): ReactNode {
const { state, activity, running } = props
// An empty string is not an activity line: it would print a gap where the
// state word used to be.
const line = activity === undefined || activity === '' ? undefined : activity
/**
* Which states still print their word. The activity line REPLACES it for
* work that the line already describes — a running node's own native status
* and a settled node's completed summary. `idle` and `error` keep the word:
* a teammate between turns and a failed node both read as "finished
* something" from their summary alone, which is exactly the misreading the
* two states must not allow.
*/
const showStateWord = props.stateWord !== false
&& (line === undefined || state === 'idle' || state === 'error')
return (
<span
className={css.cardBar}
@@ -145,9 +169,9 @@ export function CardBar(props: {
{props.children ?? (
<>
<StateDot state={nodeDotState(state)} size={6} className={css.barDot} />
{props.stateWord !== false && <span className={css.barState}>{stateLabel(state)}</span>}
{activity !== undefined && activity !== '' && (
<span className={css.barActivity} title={activity}>{activity}</span>
{showStateWord && <span className={css.barState}>{stateLabel(state)}</span>}
{line !== undefined && (
<span className={css.barActivity} title={line}>{line}</span>
)}
{props.onFold !== undefined && (
<button
+41 -9
View File
@@ -370,15 +370,17 @@
}
/* The merged activity: the main agent's own wording for the node's newest
range. It deliberately keeps the BAR's font — no mono family. The state word
beside it is UI copy, and the two stacks do not share metrics: measured at
11px, the sans stack reports ascent/descent 11/2 against the mono stack's
10/3, so a mono activity line sits 1px LOWER than the state word it follows
(the reader reported exactly that misalignment). The mono face bought
nothing here either: every CJK glyph in this line comes from the same
fallback family, so only the Latin fragments changed face — half a sentence
in mono, one pixel off. Machine text keeps its mono voice where it belongs
(the meta row above, the job rows, the terminal well). */
range, and the bar's primary content — it takes the state word's place for a
running node's native status and a settled node's summary. It deliberately
keeps the BAR's font — no mono family. Where the state word DOES stay beside
it (`空闲` / `出错`) the two stacks do not share metrics: measured at 11px,
the sans stack reports ascent/descent 11/2 against the mono stack's 10/3, so
a mono activity line sits 1px LOWER than the state word it follows (the
reader reported exactly that misalignment). The mono face bought nothing here
either: every CJK glyph in this line comes from the same fallback family, so
only the Latin fragments changed face — half a sentence in mono, one pixel
off. Machine text keeps its mono voice where it belongs (the meta row above,
the job rows, the terminal well). */
.barActivity {
flex: 1;
min-width: 0;
@@ -1012,6 +1014,36 @@
white-space: nowrap;
}
/* The node's merged activity, set under the title instead of in the key/value
grid: it says what the node is DOING (a subtitle), and the grid's
right-aligned value column ellipsised it at the popover's 280px while its
"最近活动" key spent a third of the width naming the position. */
.popActivityBlock {
display: flex;
flex-direction: column;
gap: 1px;
min-width: 0;
}
.popActivity {
font-size: 10px;
line-height: 1.45;
color: var(--dsw-alias-state-business-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* The streamed text tail under it keeps the card's smallest voice, clamped to
two lines: the tail is capped at 400 characters upstream, which would
otherwise push the state rows out of the card. */
.popActivityBlock .popHint {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
/* The card's smallest voice (the empty-description line, the drag hint, the
invalid-subject rule). Doubled so that a container rule — the markdown well's
body ink, the meta line — can never lift it a rung. */
+62 -22
View File
@@ -17,7 +17,10 @@
* the lead's roster row lands on the root node;
* - fold: per parent, settled agent LEAVES (state done/error, never the
* current session, never a workflow member's run node) collapse into one
* trailing `fold` node carrying the member ids and label previews.
* trailing `fold` node per GROUP (finished work / waiting members) carrying
* the member ids and label previews; a group the reader opened
* ({@link TasksModelInput.expandedGroups}) keeps its members visible while
* its sibling group stays folded.
*/
import type {
SidebarSessionSummary,
@@ -154,6 +157,14 @@ export interface TasksModelInput {
* trigger that cannot fire is a dead control.
*/
foldedIds?: ReadonlySet<string>
/**
* The fold GROUPS the reader expanded by clicking their aggregate card
* ({@link foldGroupId}). A group listed here shows its members while every
* other group stays folded — expanding one aggregate must never unfold the
* page. It is consulted only where a member would otherwise be folded, so
* the global rule and the manual per-node folds are untouched underneath.
*/
expandedGroups?: ReadonlySet<string>
}
/** Human label of one catalog child (the classic rule). */
@@ -229,6 +240,19 @@ function tally(folded: readonly TasksAgentNode[]): FoldTally {
return counts
}
/**
* The id of one fold GROUP (the aggregate card a set of folded members
* collapses into). Derived from the parent and the group kind only, so the id
* is stable while membership changes underneath it — the page keys the
* reader's per-group expansions by exactly this string.
*
* @param foldKind - which group (`done` = finished/failed, `idle` = waiting).
* @param parentId - the parent whose children were folded.
*/
export function foldGroupId(foldKind: TasksFoldKind, parentId: string): string {
return foldKind === 'idle' ? `fold:${parentId}:idle` : `fold:${parentId}`
}
/**
* Build one aggregate row for the given group of children.
*
@@ -241,20 +265,18 @@ function tally(folded: readonly TasksAgentNode[]): FoldTally {
* @param parentId - the row's parent (its tree position).
* @param depth - the row's tree depth.
* @param members - the children this group swallowed, in page order.
* @param idSuffix - disambiguates the two rows of one parent (`''` / `':idle'`).
*/
function foldNode(
foldKind: TasksFoldKind,
parentId: string,
depth: number,
members: readonly TasksAgentNode[],
idSuffix: string,
): TasksFoldNode {
const counts = tally(members)
return {
kind: 'fold',
foldKind,
id: `fold:${parentId}${idSuffix}`,
id: foldGroupId(foldKind, parentId),
parentId,
depth,
count: members.length,
@@ -300,6 +322,7 @@ export function buildTasksModel(input: TasksModelInput): TasksNode[] {
const {
byId, catalogs, rootId, currentSessionId, live, runs, teamMembers, folded, foldedIds,
} = input
const expandedGroups = input.expandedGroups
const teamTasks = input.teamTasks ?? []
const teamById = new Map(teamMembers.map(member => [member.id, member]))
/** Owner display name → node id (the board assigns by member name). */
@@ -459,10 +482,12 @@ export function buildTasksModel(input: TasksModelInput): TasksNode[] {
// Fold: this parent's non-executing children collapse into one aggregate
// PER GROUP — finished/failed work in one row, waiting members in another,
// so the badge can say what it holds and a reader can sweep one without
// the other. Two triggers, two guard sets: the page-level `folded` rule
// the other. Three triggers, three guard sets: the page-level `folded` rule
// also spares branching nodes and (below the idle head count) teammates; a
// manual `foldedIds` fold is the reader asking for THAT node, so it only
// spares running/current work.
// spares running/current work; and `expandedGroups` is the reader having
// opened ONE aggregate, which keeps that group's members out of the fold
// while every other group stays exactly as it was.
const idleMembers = visibleAgentChildren
.filter(child => child.state === 'idle' && child.team !== undefined).length
const foldIdleMembers = idleMembers >= FOLD_IDLE_MIN
@@ -473,9 +498,13 @@ export function buildTasksModel(input: TasksModelInput): TasksNode[] {
const foldable = nodeFoldable(child, currentSessionId)
const auto = folded && foldable && isAutoFoldable(child, runsByOrigin, foldIdleMembers)
const manual = foldedIds?.has(child.id) === true && foldable
if (!auto && !manual) {
// The group a member belongs to decides which aggregate claims it — and
// therefore which expansion could have revealed it.
const group: TasksFoldKind = child.state === 'idle' ? 'idle' : 'done'
const expanded = expandedGroups?.has(foldGroupId(group, parentId)) === true
if ((!auto && !manual) || expanded) {
kept.push(child)
} else if (child.state === 'idle') {
} else if (group === 'idle') {
idleFold.push(child)
} else {
doneFold.push(child)
@@ -486,21 +515,22 @@ export function buildTasksModel(input: TasksModelInput): TasksNode[] {
out.push(child)
appendChildren(child.id, child.depth)
}
if (doneFold.length > 0) out.push(foldNode('done', parentId, depth + 1, doneFold, ''))
if (idleFold.length > 0) out.push(foldNode('idle', parentId, depth + 1, idleFold, ':idle'))
if (doneFold.length > 0) out.push(foldNode('done', parentId, depth + 1, doneFold))
if (idleFold.length > 0) out.push(foldNode('idle', parentId, depth + 1, idleFold))
for (let index = 0; index < runNodes.length; index += 1) {
const runNode = runNodes[index]
if (runNode === undefined) continue
out.push(runNode)
const members = memberNodes[index] ?? []
// The run's own members fold under the same two triggers and the same two
// groups. The AUTOMATIC trigger applies the same STRUCTURAL guards as the
// parent's children — a member is often a RE-PARENTED catalog node (a real
// directory with `hasChildren`, team enrichment and its own run), not the
// synthetic leaf this loop used to assume, and folding one hid its whole
// branch (issue #784). The roster guard does not apply here: the member is
// not a roster row of this parent, and the idle head count is a
// roster-scanning rule — run members keep their own container's rule.
// The run's own members fold under the same triggers, the same two groups
// and the same per-group expansion. The AUTOMATIC trigger applies the same
// STRUCTURAL guards as the parent's children — a member is often a
// RE-PARENTED catalog node (a real directory with `hasChildren`, team
// enrichment and its own run), not the synthetic leaf this loop used to
// assume, and folding one hid its whole branch (issue #784). The roster
// guard does not apply here: the member is not a roster row of this
// parent, and the idle head count is a roster-scanning rule — run members
// keep their own container's rule.
const keptMembers: TasksAgentNode[] = []
const runDone: TasksAgentNode[] = []
const runIdle: TasksAgentNode[] = []
@@ -508,18 +538,27 @@ export function buildTasksModel(input: TasksModelInput): TasksNode[] {
const foldable = nodeFoldable(member, currentSessionId)
const auto = folded && foldable && isAutoFoldable(member, runsByOrigin, true)
const manual = foldedIds?.has(member.id) === true && foldable
if (!auto && !manual) keptMembers.push(member)
else if (member.state === 'idle') runIdle.push(member)
const group: TasksFoldKind = member.state === 'idle' ? 'idle' : 'done'
const expanded = expandedGroups?.has(foldGroupId(group, runNode.id)) === true
if ((!auto && !manual) || expanded) keptMembers.push(member)
else if (group === 'idle') runIdle.push(member)
else runDone.push(member)
}
out.push(...keptMembers)
if (runDone.length > 0) out.push(foldNode('done', runNode.id, runNode.depth + 1, runDone, ''))
if (runIdle.length > 0) out.push(foldNode('idle', runNode.id, runNode.depth + 1, runIdle, ':idle'))
if (runDone.length > 0) out.push(foldNode('done', runNode.id, runNode.depth + 1, runDone))
if (runIdle.length > 0) out.push(foldNode('idle', runNode.id, runNode.depth + 1, runIdle))
}
}
const rootSummary = byId[rootId]
const rootTeam = teamOf(rootId)
// The topology root carries its live view like every child: the live route
// folds the root's own range into the same map (the `subagents` service
// cannot classify an agent it did not spawn, so its `running` flag is absent
// there — the summary and text are not). Without it the main agent's card and
// tree row fell back to the hardcoded thinking wording no matter what the
// session was actually doing.
const rootLive = childLive(live, rootId)
out.push({
kind: 'agent',
id: rootId,
@@ -530,6 +569,7 @@ export function buildTasksModel(input: TasksModelInput): TasksNode[] {
state: rootSummary?.running === true ? 'running' : 'done',
activity: rootSummary?.running === true ? 'running' : 'inactive',
current: rootId === currentSessionId,
...(rootLive !== undefined ? { live: rootLive } : {}),
...(rootTeam !== undefined ? { team: rootTeam } : {}),
...(tasksByNode.get(rootId) !== undefined ? { tasks: tasksByNode.get(rootId) } : {}),
})
+62 -14
View File
@@ -2,14 +2,18 @@
* Shared presentation bits of the Tasks page's two modes (graph + tree):
* the state dot, the agent/workflow/task GLYPHS (host primitive icons — the
* page draws no glyphs of its own), the short mono meta line, the node task
* line, and the iconified live activity row ("tool icon + tool + args").
* line, and the iconified live activity row ("activity glyph + wording").
*
* Card content contract (the page's answer to "everything is ellipsized"):
* line 1 state dot + agent icon + name (11px semibold, one line)
* line 2 mode/model · activity (9px mono, one line)
* line 3 live tool line (running nodes only)
* line 3 live activity line (running nodes only)
* line 4 owned shared task (team members only)
* Everything else lives in the popovers.
*
* {@link activityLine} is the ONE rule that resolves a node's merged activity
* wording: the card's bottom bar and the node detail popover both read it, so
* the two surfaces can never disagree about what a node is doing.
*/
import type { ReactNode } from 'react'
import {
@@ -17,11 +21,11 @@ import {
type StateDotState,
} from '@deepseek-ai/dsh-client-ui-primitives'
import type { SidebarChildLiveView } from '../context-types.ts'
import { liveActivityLabel } from './process-labels.ts'
import { doneActivityTitle, liveActivityLabel } from './process-labels.ts'
import type {
TasksAgentNode, TasksFoldNode, TasksNodeState, TasksNodeTask, TasksWorkflowNode,
} from './tasks-model.ts'
import { toolGlyph } from './tool-icons.tsx'
import { activityGlyph } from './activity-icons.tsx'
import { t, type CopyKey } from './locales.ts'
import css from './tasks-graph.module.css'
@@ -50,6 +54,27 @@ export function stateLabel(state: TasksNodeState): string {
return t(key)
}
/**
* The merged activity line of one agent node — the ONE rule both surfaces
* read (the card's bottom bar and the node detail popover).
*
* - a RUNNING node shows the host's own live wording for its newest range
* ("正在读取文件 · main.ts"), which is what the main conversation shows for
* the same work;
* - a settled one shows the same summary in its completed form (the host's
* `done.*` phrasing) — running wording on a finished node would claim it is
* analysing something it already answered;
* - a node the live channel carries NO summary for answers undefined, and the
* callers fall back to the state word. That case must stay distinguishable:
* the host's `thinking` wording is what a range with nothing dispatched
* reads as, not what "we know nothing about this node" reads as.
*/
export function activityLine(node: TasksAgentNode): string | undefined {
const summary = node.live?.summary
if (summary === undefined) return undefined
return node.state === 'running' ? liveActivityLabel(summary) : doneActivityTitle(summary)
}
/**
* The two facts every task display rule reads. Deliberately NARROWER than
* either carrier (`TasksNodeTask` on the graph, `SidebarTeamTaskView` in the
@@ -165,11 +190,11 @@ export function agentMeta(node: TasksAgentNode): string {
/**
* The CARD's mono meta line: WHO the node is, never its state.
*
* The state belongs to the card's bottom bar (the state word sits next to the
* state dot there), so repeating it here would print "已完成" twice inside one
* 190px card — the densest complaint the readability pass had to fix. The
* accessible name keeps {@link agentMeta} (state included), because a screen
* reader never sees the bar's dot.
* The state belongs to the card's bottom bar (the state dot there, and the
* state word whenever no activity line takes its place), so repeating it here
* would print "已完成" twice inside one 190px card — the densest complaint the
* readability pass had to fix. The accessible name keeps {@link agentMeta}
* (state included), because a screen reader never sees the bar's dot.
*/
export function agentIdentity(node: TasksAgentNode): string {
// The root's badge already reads 主代理: an identity line would repeat it.
@@ -260,6 +285,10 @@ export function TaskLine(props: {
* main conversation would show for the child's newest range (category wording
* + the running call's detail), plus the flattened last text line underneath.
* A running node with neither reads as thinking.
*
* The glyph follows the summary's own CATEGORY (the host's `ProcessActivity`),
* so "正在读取文件" is prefixed by the read family and "正在运行命令" by the
* command one — one fixed glyph made every row claim to be a shell command.
*/
export function LiveLine(props: { live: SidebarChildLiveView | undefined }): ReactNode {
const { live } = props
@@ -271,7 +300,9 @@ export function LiveLine(props: { live: SidebarChildLiveView | undefined }): Rea
<>
{activity !== undefined && (
<span className={css.live}>
<span className={css.liveGlyph} aria-hidden="true">{toolGlyph('bash')(9)}</span>
<span className={css.liveGlyph} aria-hidden="true">
{activityGlyph(live?.summary?.running)(9)}
</span>
<span className={css.liveTool} title={activity}>{activity}</span>
</span>
)}
@@ -289,8 +320,8 @@ export function LiveLine(props: { live: SidebarChildLiveView | undefined }): Rea
* A roster aggregate can swallow dozens of members, and the card has one line
* for them. Naming two and saying how many are left over is what keeps that
* line honest at any size — the exact `+N` the team task line already uses,
* not a second convention. The group's total is also on the badge and the bar,
* so `+N` is a tail, never the only count.
* not a second convention. The group's total is also on the badge, so `+N` is
* a tail, never the only count.
*
* @param previews - member labels, in page order (see {@link TasksFoldNode.previews}).
* @param count - how many members the group holds in total.
@@ -301,18 +332,35 @@ export function foldPreviews(previews: readonly string[], count: number): string
}
/**
* The fold aggregate's bar text.
* The fold aggregate's failures, as its own line: `出错 N`, or undefined when
* the group has none. The `done` row's bottom bar prints exactly this and
* nothing else, because the badge above it already carries the count
* (`✓ N 已完成`) — the same number twice on a 190px card was one of them
* saying it again.
*/
export function foldErrorTally(node: TasksFoldNode): string | undefined {
return node.errorCount > 0 ? `${t('tasksStateError')} ${node.errorCount}` : undefined
}
/**
* The fold aggregate's full tally (its accessible name and tooltip).
*
* The two groups read differently on purpose. The `done` row counts its
* finished members and calls out failures beside them (`✓ 4 已完成 · 出错 1`
* — a row of nothing but failures is `出错 N`), because "✓ N 已完成" alone
* would quietly include them. The `idle` row says what the members are doing
* now: nothing (`N 待命`), which is why they were swept away.
*
* The VISIBLE surfaces split this differently: the graph card's badge carries
* the count and its bar carries {@link foldErrorTally}, so the tally's count
* half is printed once. This full string stays the accessible name — a screen
* reader never sees the badge.
*/
export function foldTally(node: TasksFoldNode): string {
if (node.foldKind === 'idle') return t('tasksFoldIdle', { count: node.count })
const parts: string[] = []
if (node.doneCount > 0) parts.push(t('tasksFoldCompleted', { count: node.doneCount }))
if (node.errorCount > 0) parts.push(`${t('tasksStateError')} ${node.errorCount}`)
const errors = foldErrorTally(node)
if (errors !== undefined) parts.push(errors)
return parts.join(' · ')
}
-54
View File
@@ -1,54 +0,0 @@
/**
* Tool-call glyphs for the live activity lines of the Tasks page (the
* "icon + tool + args" row on running agent nodes). A small explicit map of
* the common tool families onto host primitive icons; anything unmapped
* gets the generic ellipsis glyph. All icons are the host's own components
* (currentColor — zero color literals, the theme contract stays intact).
*/
import type { ReactNode } from 'react'
import {
IconCodeOutlineRegular,
IconEditOutlineRegular,
IconEllipsisOutlineRegular,
IconGlobeOutlineRegular,
IconPlayOutlineRegular,
IconSearchOutlineRegular,
IconThinkOutlineRegular,
} from '@deepseek-ai/dsh-client-ui-primitives'
/** One glyph renderer (host icon components accept a pixel size). */
type Glyph = (size: number) => ReactNode
/** The explicit tool-family map (longest-prefix wins at lookup). */
const TOOL_GLYPHS: ReadonlyArray<readonly [string, Glyph]> = [
['read', size => <IconCodeOutlineRegular size={size} />],
['write', size => <IconEditOutlineRegular size={size} />],
['edit', size => <IconEditOutlineRegular size={size} />],
['glob', size => <IconSearchOutlineRegular size={size} />],
['grep', size => <IconSearchOutlineRegular size={size} />],
['search', size => <IconSearchOutlineRegular size={size} />],
['bash', size => <IconPlayOutlineRegular size={size} />],
['shell', size => <IconPlayOutlineRegular size={size} />],
['web', size => <IconGlobeOutlineRegular size={size} />],
['fetch', size => <IconGlobeOutlineRegular size={size} />],
['think', size => <IconThinkOutlineRegular size={size} />],
]
/** The fallback glyph for unmapped tools. */
const FALLBACK_GLYPH: Glyph = size => <IconEllipsisOutlineRegular size={size} />
/**
* The glyph of one tool name: exact match first, then a prefix match so
* `mcp__fs__read_file`-style names still land on their family glyph. The
* lookup is case-insensitive.
*/
export function toolGlyph(toolName: string): Glyph {
const name = toolName.toLowerCase()
for (const [key, glyph] of TOOL_GLYPHS) {
if (name === key) return glyph
}
for (const [key, glyph] of TOOL_GLYPHS) {
if (name.includes(key)) return glyph
}
return FALLBACK_GLYPH
}
+52
View File
@@ -0,0 +1,52 @@
/**
* Unit tests for the merged-activity glyph map (the tree mode's live row).
*
* The row used to draw ONE fixed terminal glyph whatever the wording said, so
* "正在读取文件" was prefixed by the icon for running a shell command. The map is
* total by type, and these cases pin the two facts a type cannot: every kind
* renders something, and the kinds the reader sees side by side do NOT share a
* glyph.
*/
import { describe, expect, it } from 'vitest'
import { activityGlyph } from '../src/client/activity-icons.tsx'
import type { ProcessActivity } from '../src/process-activity.ts'
/** The host's category union, spelled out (see src/process-activity.ts). */
const KINDS: readonly ProcessActivity[] = [
'read', 'readImage', 'search', 'write', 'edit', 'commands', 'code',
'webSearch', 'webFetch', 'subagents', 'plan', 'questions', 'tools',
]
/** The rendered icon's element type — what the reader actually sees. */
function glyphType(kind: ProcessActivity | undefined): unknown {
const element = activityGlyph(kind)(9) as { type?: unknown } | null
expect(element).toBeTruthy()
return element?.type
}
describe('activityGlyph', () => {
it('renders a glyph for every category', () => {
for (const kind of KINDS) {
expect(glyphType(kind)).toBeTypeOf('function')
}
})
it('gives the reading and the command categories DIFFERENT glyphs', () => {
// The reader's report: every live row wore the terminal icon. These two
// sit next to each other in a real session, so sharing one would bring the
// bug straight back.
expect(glyphType('read')).not.toBe(glyphType('commands'))
expect(glyphType('search')).not.toBe(glyphType('read'))
expect(glyphType('webSearch')).not.toBe(glyphType('commands'))
})
it('draws a category glyph for the running family and the think glyph when nothing is dispatched', () => {
// `undefined` is the "nothing running yet" case (the host's thinking
// wording), which must not read as any concrete kind of work.
const thinking = glyphType(undefined)
expect(thinking).toBeTypeOf('function')
for (const kind of KINDS) {
expect(glyphType(kind)).not.toBe(thinking)
}
})
})
+84
View File
@@ -358,6 +358,90 @@ describe('buildTasksModel', () => {
})
expect(buildTasksModel(base).map(node => node.id)).toEqual(['root', 'done-1'])
})
it('expands ONE group per reader click, leaving the sibling aggregate folded', () => {
// Two groups of one parent at once: finished work (`done-1` / `failed-1`)
// and three waiting teammates. Opening the finished group must reveal those
// two nodes and NOTHING else — the page used to clear every fold it had.
const base = input({
catalogs: {
root: catalog([child('m1'), child('m2'), child('m3'), child('done-1'), child('failed-1')]),
...Object.fromEntries(
['m1', 'm2', 'm3', 'done-1', 'failed-1'].map(id => [id, catalog([])]),
),
},
byId: Object.fromEntries(
[['root', summary('root')], ...['m1', 'm2', 'm3', 'done-1', 'failed-1'].map(id => [id, summary(id)])],
),
teamMembers: [
...['m1', 'm2', 'm3'].map(id => member({ id, name: id, status: 'idle' })),
member({ id: 'failed-1', name: 'failed-1', phase: 'failed', status: 'failed' }),
],
})
expect(buildTasksModel({ ...base, expandedGroups: new Set(['fold:root']) })
.map(node => node.id)).toEqual(['root', 'done-1', 'failed-1', 'fold:root:idle'])
// …and the idle group's own opening leaves the finished one folded. Kept
// children keep the catalog order; the aggregates trail whatever stays
// folded (the model's one ordering rule).
expect(buildTasksModel({ ...base, expandedGroups: new Set(['fold:root:idle']) })
.map(node => node.id)).toEqual(['root', 'm1', 'm2', 'm3', 'fold:root'])
// The group ids are the aggregate row ids the page hands back.
expect(buildTasksModel(base).filter(node => node.kind === 'fold').map(node => node.id))
.toEqual(['fold:root', 'fold:root:idle'])
})
it('keeps a member released while its group is open, even with a stale manual fold', () => {
// `foldedIds` is a per-node request; the aggregate's click means "show me
// these now", so an open group wins over a hand-folded member the page has
// not finished dropping.
const model = buildTasksModel(input({
catalogs: { root: catalog([child('done-1')]) },
byId: { root: summary('root'), 'done-1': summary('done-1') },
folded: true,
foldedIds: new Set(['done-1']),
expandedGroups: new Set(['fold:root']),
}))
expect(model.map(node => node.id)).toEqual(['root', 'done-1'])
})
it('expands a RUN member group by its own aggregate id', () => {
const audit = run({
originSessionId: 'root',
phases: [{
title: '侦察',
members: [
{ seq: 1, label: 'existing', phase: '侦察', childId: 'm1', outcome: 'completed' },
{ seq: 2, label: 'synthesized', phase: '侦察', childId: 'm2', outcome: 'completed' },
],
}],
})
const base = input({
catalogs: { root: catalog([child('m1')]), m1: catalog([]) },
byId: { root: summary('root'), m1: summary('m1') },
runs: [audit],
})
// Folded by default: both settled members collapse under the run node.
expect(buildTasksModel(base).map(node => node.id)).toEqual(['root', 'run:run-1', 'fold:run:run-1'])
// Opening that aggregate reveals the run's own members, in phase order.
expect(buildTasksModel({ ...base, expandedGroups: new Set(['fold:run:run-1']) })
.map(node => node.id)).toEqual(['root', 'run:run-1', 'm1', 'm2'])
})
it('carries the topology ROOT\'s own live view (the card and the row read it)', () => {
const live: Record<string, SidebarChildLiveView> = {
root: {
summary: {
counts: [{ kind: 'commands', count: 1 }], running: 'commands', runningDetail: 'npm run build',
},
},
}
const node = agents(buildTasksModel(input({ live }))).find(candidate => candidate.id === 'root')
expect(node?.live?.summary?.running).toBe('commands')
// A root the live channel reported nothing for keeps the field absent — the
// bar then falls back to the state word instead of inventing copy.
expect(agents(buildTasksModel(input({ live: {} }))).find(candidate => candidate.id === 'root')?.live)
.toBeUndefined()
})
})
describe('tasksEdges', () => {
+251 -5
View File
@@ -11,6 +11,7 @@ import { act } from 'react-dom/test-utils'
import { renderRoot } from './test-utils.ts'
import { SubagentView } from '../src/client/SubagentView.tsx'
import { createSidebarStore } from '../src/client/state.ts'
import { attachLocale } from '../src/client/locales.ts'
import type {
Context,
SidebarClientJobsService,
@@ -123,6 +124,44 @@ let runsPayload: unknown[] = []
/** A write rejection the stub answers `teams.taskUpdate` with (undefined = ok). */
let writeRejection: { status: number; code: string; message: string } | undefined
/**
* The host's `chat` namespace, as the plugin reads it through `chatT`. The
* Tasks page deliberately borrows the HOST's wording for the merged activity
* (see process-labels.ts), so a suite that asserts the bar's copy has to serve
* those keys — without this the wording falls back to the call's own detail and
* the assertions would pin the fallback instead of the contract.
*
* The subset is the host's real zh copy, plus the separator key the labels
* join with; `active: 'zh'` keeps the plugin's own dictionaries on the zh
* chain the rest of this file asserts against.
*/
class FakeChatLocale {
active = 'zh'
private readonly dicts: Record<string, Record<string, string>> = {
chat: {
'message.turnProcess.separator': ' · ',
'message.stepProcess.thinking': '正在分析请求',
'message.stepProcess.read': '正在读取文件',
'message.stepProcess.commands': '正在运行命令',
'message.stepProcess.prepare.read': '准备读取文件',
'message.stepProcess.done.read': '已读取文件',
'message.stepProcess.done.thinking': '已完成分析',
},
}
getSnapshot(): { active: string } {
return { active: this.active }
}
bind(ns: string): (key: string) => string {
const dict = this.dicts[ns] ?? {}
return (key: string) => dict[key] ?? key
}
}
/** Attach the host `chat` wording for one test. */
function attachChatLocale(): void {
attachLocale(new FakeChatLocale())
}
beforeEach(() => {
teamProjection = undefined
livePayload = {}
@@ -163,6 +202,7 @@ beforeEach(() => {
})
afterEach(() => {
attachLocale(undefined)
vi.unstubAllGlobals()
for (const el of document.querySelectorAll('body > div')) el.remove()
})
@@ -894,7 +934,9 @@ describe('Tasks page: the shared task window', () => {
expect(aggregate).not.toBeNull()
expect(aggregate.textContent).toContain('1')
// Clicking the aggregate expands EVERYTHING (manual + global folds).
// Clicking the aggregate reveals THAT group: the manual fold is released
// (the reader asked to see these nodes) while every other group keeps its
// own state.
await act(async () => { aggregate.click() })
expect(container.querySelector('[data-graph-node="child-0"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="fold:root"]')).toBeNull()
@@ -904,7 +946,8 @@ describe('Tasks page: the shared task window', () => {
it('gives the waiting members their own aggregate row, and folds one by its chevron', async () => {
// Three idle teammates meet the idle head count, so they fold — into a row
// of their OWN: the finished work keeps its "✓ N 已完成" badge and the
// waiting members say "N 个待命" instead of hiding inside a ✓ count.
// waiting members count themselves on the badge, instead of hiding inside
// a ✓ count.
const mate = (index: number): SidebarTeamMemberProjection => ({
id: `child-${index}`, name: `mate-${index}`, role: 'teammate', phase: 'active',
})
@@ -916,7 +959,10 @@ describe('Tasks page: the shared task window', () => {
await flushJobs()
const aggregate = container.querySelector('[data-graph-node="fold:root:idle"]') as HTMLElement
expect(aggregate).not.toBeNull()
expect(aggregate.textContent).toContain('3 待命')
// The badge carries the REAL count (it used to print the literal copy "N"),
// and the bar does not print it a second time.
expect(aggregate.querySelector('[data-card-kind="fold"]')?.textContent).toBe('3 个待命')
expect(aggregate.querySelector('[data-card-bar]')?.textContent).toBe('')
expect(aggregate.textContent).not.toContain('已完成')
// The finished group is a DIFFERENT row (empty here: nothing is done).
expect(container.querySelector('[data-graph-node="fold:root"]')).toBeNull()
@@ -943,9 +989,9 @@ describe('Tasks page: the shared task window', () => {
await act(async () => { chevron.click() })
const aggregate = container.querySelector('[data-graph-node="fold:root:idle"]') as HTMLElement
expect(aggregate).not.toBeNull()
expect(aggregate.textContent).toContain('1 待命')
expect(aggregate.textContent).toContain('1 个待命')
// The aggregate's badge says 待命 too, so the row never reads as finished.
expect(aggregate.querySelector('[data-card-kind="fold"]')?.textContent).toBe('N 个待命')
expect(aggregate.querySelector('[data-card-kind="fold"]')?.textContent).toBe('1 个待命')
expect(container.querySelector('[data-graph-node="child-0"]')).toBeNull()
unmount()
})
@@ -1094,3 +1140,203 @@ describe('Tasks page: the shared task window', () => {
unmount()
})
})
/**
* The bar and the node detail read the SAME merged-activity rule, and that
* rule follows the node's own state: a running node prints the host's live
* wording in place of the state word, a settled one prints the completed
* wording, and a node the live channel says nothing about falls back to its
* state word instead of claiming to be analysing a request.
*/
describe('Tasks page: the node status line and per-group expansion', () => {
/** Render the page and unfold the page-level rule, so cards are on screen. */
async function renderUnfolded(snapshot: SidebarSessionList): Promise<{
container: HTMLElement
unmount(): void
}> {
const store = makeStore(snapshot)
const rendered = renderRoot(
createElement(SubagentView, { sessionId: 'root', active: true, ctx: makeCtx(store) }),
)
await flushJobs()
const foldToggle = rendered.container.querySelector(
'button[aria-label="展开已完成的节点"]',
) as HTMLButtonElement | null
if (foldToggle !== null) await act(async () => { foldToggle.click() })
return rendered
}
it('prints the running native status instead of the state word', async () => {
attachChatLocale()
livePayload = {
'child-0': {
running: true,
summary: { counts: [{ kind: 'read', count: 2 }], running: 'read', runningDetail: 'main.ts' },
},
}
const snapshot = snapshotWithChildren(2)
snapshot.byId['child-0']!.running = true
const { container, unmount } = await renderUnfolded(snapshot)
const bar = container.querySelector('[data-graph-node="child-0"] [data-card-bar]') as HTMLElement
expect(bar.getAttribute('data-running')).toBe('true')
expect(bar.textContent).toBe('正在读取文件 · main.ts')
expect(bar.textContent).not.toContain('运行中')
// The settled sibling keeps its word: it has no summary to speak with.
const settled = container.querySelector('[data-graph-node="child-1"] [data-card-bar]') as HTMLElement
expect(settled.textContent).toBe('已完成')
unmount()
})
it('falls back to the state word when the node has no activity data at all', async () => {
attachChatLocale()
// The live channel reports the node as running but folds nothing for it:
// the bar must not invent "正在分析请求" out of the host's thinking wording.
livePayload = { 'child-0': { running: true } }
const snapshot = snapshotWithChildren(2)
snapshot.byId['child-0']!.running = true
const { container, unmount } = await renderUnfolded(snapshot)
const bar = container.querySelector('[data-graph-node="child-0"] [data-card-bar]') as HTMLElement
expect(bar.textContent).toBe('运行中')
unmount()
})
it('prints a settled node the completed wording, and the ROOT its own live status', async () => {
attachChatLocale()
livePayload = {
// The root's fold is computed by the live route like every child's; the
// page used to drop it, so the main agent's card read the fallback text
// whatever the session was doing.
root: {
summary: { counts: [{ kind: 'commands', count: 1 }], running: 'commands', runningDetail: 'npm run build' },
},
'child-0': {
running: false,
summary: { counts: [{ kind: 'read', count: 1 }], runningDetail: '' },
},
}
const { container, unmount } = await renderUnfolded(snapshotWithChildren(2))
const rootBar = container.querySelector('[data-graph-node="root"] [data-card-bar]') as HTMLElement
expect(rootBar.textContent).toBe('正在运行命令 · npm run build')
const settledBar = container.querySelector('[data-graph-node="child-0"] [data-card-bar]') as HTMLElement
expect(settledBar.textContent).toBe('已读取文件')
expect(settledBar.textContent).not.toContain('已完成')
unmount()
})
it('sets the node detail activity under the title, and claims nothing without data', async () => {
attachChatLocale()
livePayload = {
'child-0': {
running: true,
text: 'half-finished line',
summary: { counts: [{ kind: 'read', count: 1 }], running: 'read', runningDetail: 'main.ts' },
},
}
const snapshot = snapshotWithChildren(2)
snapshot.byId['child-0']!.running = true
const { container, unmount } = await renderUnfolded(snapshot)
await act(async () => {
(container.querySelector('[data-graph-node="child-0"]') as HTMLElement).click()
})
const dialog = document.querySelector('[role="dialog"]') as HTMLElement
// The label row is gone: the position under the title says what it is.
expect(dialog.textContent).not.toContain('最近活动')
const block = dialog.querySelector('[data-node-activity]') as HTMLElement
expect(block.textContent).toContain('正在读取文件 · main.ts')
expect(block.textContent).toContain('half-finished line')
// …and it sits directly under the title, above the key/value grid.
const card = dialog.firstElementChild as HTMLElement
const parts = Array.from(card.children)
expect(parts.indexOf(block)).toBeLessThan(parts.indexOf(card.querySelector('dl') as Element))
// A node with no live data shows no activity block at all — the detail used
// to print "正在分析请求" for every node in the tree.
await act(async () => {
(container.querySelector('[data-graph-node="child-1"]') as HTMLElement).click()
})
const settledDialog = document.querySelector('[role="dialog"]') as HTMLElement
expect(settledDialog.querySelector('[data-node-activity]')).toBeNull()
expect(settledDialog.textContent).not.toContain('正在分析请求')
unmount()
})
it('expands ONE aggregate group per click; the cluster still folds the page', async () => {
// Two settled subagents (the `done` group) plus three waiting teammates
// (the `idle` group): both aggregates exist at once, which is exactly what
// makes "one click unfolded everything" observable.
const mate = (index: number): SidebarTeamMemberProjection => ({
id: `child-${index}`, name: `mate-${index}`, role: 'teammate', phase: 'active',
})
withTeam({
members: [{ id: 'root', name: 'lead', role: 'lead', phase: 'active' }, ...[2, 3, 4].map(mate)],
})
const store = makeStore(snapshotWithChildren(5))
const { container, unmount } = renderRoot(
createElement(SubagentView, { sessionId: 'root', active: true, ctx: makeCtx(store) }),
)
await flushJobs()
expect(container.querySelector('[data-graph-node="fold:root"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="fold:root:idle"]')).not.toBeNull()
// One click on the finished group reveals ITS members only.
await act(async () => {
(container.querySelector('[data-graph-node="fold:root"]') as HTMLElement).click()
})
expect(container.querySelector('[data-graph-node="child-0"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="child-1"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="fold:root"]')).toBeNull()
expect(container.querySelector('[data-graph-node="fold:root:idle"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="child-2"]')).toBeNull()
// The cluster keeps the page-level switch: unfolding the page shows every
// node, and collapsing it re-folds every group — including the one the
// reader had opened by hand.
await act(async () => {
(container.querySelector('button[aria-label="展开已完成的节点"]') as HTMLButtonElement).click()
})
expect(container.querySelector('[data-graph-node="child-2"]')).not.toBeNull()
await act(async () => {
(container.querySelector('button[aria-label="折叠已完成的节点"]') as HTMLButtonElement).click()
})
expect(container.querySelector('[data-graph-node="fold:root"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="fold:root:idle"]')).not.toBeNull()
expect(container.querySelector('[data-graph-node="child-0"]')).toBeNull()
unmount()
})
it('drops the per-group openings when the CLUSTER collapses the page', async () => {
// The polarity that matters: a group opened from its aggregate must not
// survive the reader asking the whole page to collapse. Driven from the
// unfolded state, where a fold could otherwise be remembered as "opened"
// while every sibling folds around it.
const store = makeStore(snapshotWithChildren(3))
const { container, unmount } = renderRoot(
createElement(SubagentView, { sessionId: 'root', active: true, ctx: makeCtx(store) }),
)
await flushJobs()
// Unfold the page, fold ONE card back in, then open that aggregate.
await act(async () => {
(container.querySelector('button[aria-label="展开已完成的节点"]') as HTMLButtonElement).click()
})
await act(async () => {
(container.querySelector(
'[data-graph-node="child-0"] button[aria-label="收进已完成聚合"]',
) as HTMLButtonElement).click()
})
await act(async () => {
(container.querySelector('[data-graph-node="fold:root"]') as HTMLElement).click()
})
expect(container.querySelector('[data-graph-node="child-0"]')).not.toBeNull()
// Now collapse the page from the cluster: the opened group goes with it.
await act(async () => {
(container.querySelector('button[aria-label="折叠已完成的节点"]') as HTMLButtonElement).click()
})
expect(container.querySelector('[data-graph-node="child-0"]')).toBeNull()
const aggregate = container.querySelector('[data-graph-node="fold:root"]') as HTMLElement
expect(aggregate).not.toBeNull()
expect(aggregate.textContent).toContain('✓ 3 已完成')
unmount()
})
})