diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e481c43..ecfcf9bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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:` / `fold::idle`),兄弟组、页级折叠与手工折叠都不受影响——此前一次点击会清空手工折叠集并关掉全局规则,等于**点一个全开**。控制条按钮仍是页级展开/折叠,且**收起时清掉按组展开**(全局收起必须真的收起);树里的聚合行同一语义,行内副文案固定为「展开」(该行只在折叠态存在)。 +- 🔢 **聚合卡不再两处写计数**:待命组的徽标此前印的是**字面量字母 N**(`tasksFoldIdleGroup` 在 20 份词典里都是 `'N waiting' / 'N 个待命'`,没有 `{count}` 插值)——现在插值出真实计数,小条只保留`出错 N` 尾注与展开箭头;完整 tally 仍是卡片的 `aria-label` 与 tooltip。 +- 🎨 **树模式实时行的图标按活动类别取**:`tool-icons.tsx`(工具名映射,只有一处写死的调用)换成 `activity-icons.tsx` 的 `activityGlyph(kind)`——读文件 / 搜索 / 编辑 / 命令 / 网页 / 子代理 / 计划 / 提问 / 通用工具各用自己的宿主图标,尚未派发时是思考图标;`Record` 让上游新增类别编译失败而不是静默兜底。 +- 🧪 测试:`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 对本插件消费的宿主面仍是纯增量,运行时零改动。 diff --git a/docs/plans/2026-10-11-tasks-status-and-group-fold.md b/docs/plans/2026-10-11-tasks-status-and-group-fold.md new file mode 100644 index 00000000..829ac39f --- /dev/null +++ b/docs/plans/2026-10-11-tasks-status-and-group-fold.md @@ -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`,键是**组 id**:`foldGroupId(foldKind, parentId)` → + `fold:`(已完成组)/ `fold::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`(**类型强制全覆盖**,上游加类别会编译失败而不是静默兜底)。 +`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` 记录。 diff --git a/src/client/SubagentView.tsx b/src/client/SubagentView.tsx index 888c6699..8e7805e8 100644 --- a/src/client/SubagentView.tsx +++ b/src/client/SubagentView.tsx @@ -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>(() => 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>(() => new Set()) const [teamBoardCollapsed, setTeamBoardCollapsed] = useState(false) const [popover, setPopover] = useState(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} /> diff --git a/src/client/TasksGraph.tsx b/src/client/TasksGraph.tsx index 62498687..f0973a33 100644 --- a/src/client/TasksGraph.tsx +++ b/src/client/TasksGraph.tsx @@ -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(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 (
{ 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 (
{ if (!clickAllowed()) return - onToggleFold() + onExpandGroup(node) }} > - {/* 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 展开. */} - {foldTally(node)} + {errors !== undefined && ( + {errors} + )} diff --git a/src/client/TasksPopovers.tsx b/src/client/TasksPopovers.tsx index 34607a12..e9f351c4 100644 --- a/src/client/TasksPopovers.tsx +++ b/src/client/TasksPopovers.tsx @@ -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 (
{t('tasksNodeDetail')}
} title={node.label} /> + {(activity !== undefined || liveText !== undefined) && ( +
+ {activity !== undefined && ( + {activity} + )} + {liveText !== undefined && ( + {liveText} + )} +
+ )} {t(stateKey(node.state))} @@ -104,13 +123,7 @@ export function AgentNodePopover(props: { {node.team.role === 'lead' ? 'lead' : node.team.name} )} - {(liveTool !== undefined || liveText !== undefined) && ( - {liveTool ?? liveText} - )} - {liveText !== undefined && liveTool !== undefined && ( -
{liveText}
- )} {(node.tasks?.length ?? 0) > 0 && (
{t('tasksNodeTasks')}
diff --git a/src/client/TasksTree.tsx b/src/client/TasksTree.tsx index a8778885..24f6a694 100644 --- a/src/client/TasksTree.tsx +++ b/src/client/TasksTree.tsx @@ -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(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) }) }} > {foldTally(node)} - - {t(folded ? 'tasksFoldExpand' : 'tasksFoldCollapse')} - + {/* 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. */} + {t('tasksFoldExpand')} {foldPreviews(node.previews, node.count)} diff --git a/src/client/activity-icons.tsx b/src/client/activity-icons.tsx new file mode 100644 index 00000000..c4069797 --- /dev/null +++ b/src/client/activity-icons.tsx @@ -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 = { + read: size => , + readImage: size => , + search: size => , + write: size => , + edit: size => , + commands: size => , + code: size => , + webSearch: size => , + webFetch: size => , + subagents: size => , + plan: size => , + questions: size => , + tools: 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 => + return ACTIVITY_GLYPHS[kind] +} diff --git a/src/client/locales-ar.ts b/src/client/locales-ar.ts index dbb1d0a9..77188a86 100644 --- a/src/client/locales-ar.ts +++ b/src/client/locales-ar.ts @@ -447,7 +447,7 @@ export const ar: Record = { settingsViewModeGraphDesc: 'مخطط عُقد متدرج مع تكبير وتحريك', settingsViewModeTree: 'شجرة', settingsViewModeTreeDesc: 'شجرة كلاسيكية بمسافات بادئة، قابلة للتنقل بلوحة المفاتيح', - tasksFoldIdleGroup: 'N waiting', + tasksFoldIdleGroup: '{count} waiting', tasksFoldIdle: 'Idle {count}', tasksFoldCompleted: '✓ {count} مكتمل', tasksFoldOne: 'الطي مع المكتملة', @@ -463,7 +463,6 @@ export const ar: Record = { tasksNodeMode: 'الوضع', tasksNodeModel: 'الطراز', tasksNodeTeamRole: 'دور الفريق', - tasksNodeActivity: 'آخر نشاط', tasksStateRunning: 'قيد التشغيل', tasksStateIdle: 'خامل', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-de.ts b/src/client/locales-de.ts index 4bb5367d..e9b4a37e 100644 --- a/src/client/locales-de.ts +++ b/src/client/locales-de.ts @@ -432,7 +432,7 @@ export const de: Record = { 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 = { tasksNodeMode: 'Modus', tasksNodeModel: 'Modell', tasksNodeTeamRole: 'Teamrolle', - tasksNodeActivity: 'Letzte Aktivität', tasksStateRunning: 'Läuft', tasksStateIdle: 'Bereit', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-fr.ts b/src/client/locales-fr.ts index 9939482f..0167ee2a 100644 --- a/src/client/locales-fr.ts +++ b/src/client/locales-fr.ts @@ -439,7 +439,7 @@ export const fr: Record = { 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 = { tasksNodeMode: 'Mode', tasksNodeModel: 'Modèle', tasksNodeTeamRole: 'Rôle dans l’équipe', - tasksNodeActivity: 'Dernière activité', tasksStateRunning: 'En cours', tasksStateIdle: 'Inactif', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-hi.ts b/src/client/locales-hi.ts index 690e8028..f25a5f91 100644 --- a/src/client/locales-hi.ts +++ b/src/client/locales-hi.ts @@ -446,7 +446,7 @@ export const hi: Record = { settingsViewModeGraphDesc: 'स्तरित नोड ग्राफ़, ज़ूम और पैन के साथ', settingsViewModeTree: 'ट्री', settingsViewModeTreeDesc: 'क्लासिक इंडेंटेड ट्री, कीबोर्ड से नेविगेट करने योग्य', - tasksFoldIdleGroup: 'N waiting', + tasksFoldIdleGroup: '{count} waiting', tasksFoldIdle: 'Idle {count}', tasksFoldCompleted: '✓ {count} पूर्ण', tasksFoldOne: 'पूर्ण में समेटें', @@ -462,7 +462,6 @@ export const hi: Record = { tasksNodeMode: 'मोड', tasksNodeModel: 'मॉडल', tasksNodeTeamRole: 'टीम भूमिका', - tasksNodeActivity: 'नवीनतम गतिविधि', tasksStateRunning: 'चल रहा है', tasksStateIdle: 'निष्क्रिय', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-id.ts b/src/client/locales-id.ts index 0401b0f7..d6b4b30f 100644 --- a/src/client/locales-id.ts +++ b/src/client/locales-id.ts @@ -444,7 +444,7 @@ export const id: Record = { 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 = { tasksNodeMode: 'Mode', tasksNodeModel: 'Model', tasksNodeTeamRole: 'Peran tim', - tasksNodeActivity: 'Aktivitas terbaru', tasksStateRunning: 'Berjalan', tasksStateIdle: 'Siaga', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-it.ts b/src/client/locales-it.ts index 5d6c1138..7ad46718 100644 --- a/src/client/locales-it.ts +++ b/src/client/locales-it.ts @@ -437,7 +437,7 @@ export const it: Record = { 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 = { tasksNodeMode: 'Modalità', tasksNodeModel: 'Modello', tasksNodeTeamRole: 'Ruolo nel team', - tasksNodeActivity: 'Ultima attività', tasksStateRunning: 'In esecuzione', tasksStateIdle: 'In attesa', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-ja.ts b/src/client/locales-ja.ts index 070e0ca4..99ecdb9f 100644 --- a/src/client/locales-ja.ts +++ b/src/client/locales-ja.ts @@ -446,7 +446,7 @@ export const ja: Record = { settingsViewModeGraphDesc: '階層ノードグラフ(ズーム・パン対応)', settingsViewModeTree: 'ツリー', settingsViewModeTreeDesc: '従来のインデントツリー(キーボード操作可)', - tasksFoldIdleGroup: 'N 件待機', + tasksFoldIdleGroup: '{count} 件待機', tasksFoldIdle: '待機 {count}', tasksFoldCompleted: '✓ {count} 件完了', tasksFoldOne: '完了済みにまとめる', @@ -462,7 +462,6 @@ export const ja: Record = { tasksNodeMode: 'モード', tasksNodeModel: 'モデル', tasksNodeTeamRole: 'チーム役割', - tasksNodeActivity: '最新アクティビティ', tasksStateRunning: '実行中', tasksStateIdle: '待機', tasksStateProvisioning: '準備中', diff --git a/src/client/locales-ko.ts b/src/client/locales-ko.ts index ec1705f1..797bd2c1 100644 --- a/src/client/locales-ko.ts +++ b/src/client/locales-ko.ts @@ -438,7 +438,7 @@ export const ko: Record = { settingsViewModeGraphDesc: '계층형 노드 그래프, 확대/이동 가능', settingsViewModeTree: '트리', settingsViewModeTreeDesc: '클래식 들여쓰기 트리, 키보드 탐색 지원', - tasksFoldIdleGroup: 'N waiting', + tasksFoldIdleGroup: '{count} waiting', tasksFoldIdle: 'Idle {count}', tasksFoldCompleted: '✓ {count} 완료됨', tasksFoldOne: '완료 항목으로 접기', @@ -454,7 +454,6 @@ export const ko: Record = { tasksNodeMode: '모드', tasksNodeModel: '모델', tasksNodeTeamRole: '팀 역할', - tasksNodeActivity: '최근 활동', tasksStateRunning: '실행 중', tasksStateIdle: '대기 중', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-nl.ts b/src/client/locales-nl.ts index d8d25dee..39bbb9e3 100644 --- a/src/client/locales-nl.ts +++ b/src/client/locales-nl.ts @@ -444,7 +444,7 @@ export const nl: Record = { 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 = { tasksNodeMode: 'Modus', tasksNodeModel: 'Model', tasksNodeTeamRole: 'Teamrol', - tasksNodeActivity: 'Laatste activiteit', tasksStateRunning: 'Bezig', tasksStateIdle: 'Inactief', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-pl.ts b/src/client/locales-pl.ts index 5be0fd3d..abe29a2f 100644 --- a/src/client/locales-pl.ts +++ b/src/client/locales-pl.ts @@ -448,7 +448,7 @@ export const pl: Record = { 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 = { tasksNodeMode: 'Tryb', tasksNodeModel: 'Model', tasksNodeTeamRole: 'Rola w zespole', - tasksNodeActivity: 'Ostatnia aktywność', tasksStateRunning: 'Działa', tasksStateIdle: 'Gotowe', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-pt.ts b/src/client/locales-pt.ts index e1fcc7a5..4213bd1e 100644 --- a/src/client/locales-pt.ts +++ b/src/client/locales-pt.ts @@ -429,7 +429,7 @@ export const pt: Record = { 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 = { tasksNodeMode: 'Modo', tasksNodeModel: 'Modelo', tasksNodeTeamRole: 'Função na equipe', - tasksNodeActivity: 'Atividade recente', tasksStateRunning: 'Em execução', tasksStateIdle: 'Em espera', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-ru.ts b/src/client/locales-ru.ts index 283dc3fd..6ba78726 100644 --- a/src/client/locales-ru.ts +++ b/src/client/locales-ru.ts @@ -444,7 +444,7 @@ export const ru: Record = { settingsViewModeGraphDesc: 'Многоуровневый граф узлов с масштабированием и панорамированием', settingsViewModeTree: 'Дерево', settingsViewModeTreeDesc: 'Классическое дерево с отступами, навигация с клавиатуры', - tasksFoldIdleGroup: 'N waiting', + tasksFoldIdleGroup: '{count} waiting', tasksFoldIdle: 'Idle {count}', tasksFoldCompleted: '✓ {count} завершено', tasksFoldOne: 'Свернуть в завершённые', @@ -460,7 +460,6 @@ export const ru: Record = { tasksNodeMode: 'Режим', tasksNodeModel: 'Модель', tasksNodeTeamRole: 'Роль в команде', - tasksNodeActivity: 'Последняя активность', tasksStateRunning: 'Выполняется', tasksStateIdle: 'Ожидает', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-sv.ts b/src/client/locales-sv.ts index 6ee6eece..0911cd8d 100644 --- a/src/client/locales-sv.ts +++ b/src/client/locales-sv.ts @@ -429,7 +429,7 @@ export const sv: Record = { 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 = { tasksNodeMode: 'Läge', tasksNodeModel: 'Modell', tasksNodeTeamRole: 'Teamroll', - tasksNodeActivity: 'Senaste aktivitet', tasksStateRunning: 'Körs', tasksStateIdle: 'Vilar', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-th.ts b/src/client/locales-th.ts index c3fd7573..87c75078 100644 --- a/src/client/locales-th.ts +++ b/src/client/locales-th.ts @@ -446,7 +446,7 @@ export const th: Record = { settingsViewModeGraphDesc: 'กราฟโหนดแบบชั้น ซูมและเลื่อนได้', settingsViewModeTree: 'มุมมองต้นไม้', settingsViewModeTreeDesc: 'ต้นไม้แบบเยื้องคลาสสิก นำทางด้วยคีย์บอร์ดได้', - tasksFoldIdleGroup: 'N waiting', + tasksFoldIdleGroup: '{count} waiting', tasksFoldIdle: 'Idle {count}', tasksFoldCompleted: '✓ เสร็จแล้ว {count}', tasksFoldOne: 'พับรวมกับที่เสร็จแล้ว', @@ -462,7 +462,6 @@ export const th: Record = { tasksNodeMode: 'โหมด', tasksNodeModel: 'โมเดล', tasksNodeTeamRole: 'บทบาทในทีม', - tasksNodeActivity: 'กิจกรรมล่าสุด', tasksStateRunning: 'กำลังทำงาน', tasksStateIdle: 'พร้อม', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-tr.ts b/src/client/locales-tr.ts index a9468d08..75307541 100644 --- a/src/client/locales-tr.ts +++ b/src/client/locales-tr.ts @@ -446,7 +446,7 @@ export const tr: Record = { 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 = { tasksNodeMode: 'Mod', tasksNodeModel: 'Model', tasksNodeTeamRole: 'Takım rolü', - tasksNodeActivity: 'Son etkinlik', tasksStateRunning: 'Çalışıyor', tasksStateIdle: 'Beklemede', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/locales-vi.ts b/src/client/locales-vi.ts index e8a29077..05af955e 100644 --- a/src/client/locales-vi.ts +++ b/src/client/locales-vi.ts @@ -446,7 +446,7 @@ export const vi: Record = { 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 = { 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', diff --git a/src/client/locales-zh-HK.ts b/src/client/locales-zh-HK.ts index 18ddbb62..3e0dce55 100644 --- a/src/client/locales-zh-HK.ts +++ b/src/client/locales-zh-HK.ts @@ -461,7 +461,7 @@ export const zhHK: Record = { settingsViewModeGraphDesc: '分層節點圖,可縮放平移', settingsViewModeTree: '樹狀圖', settingsViewModeTreeDesc: '經典縮排樹,可用鍵盤導航', - tasksFoldIdleGroup: 'N 個待命', + tasksFoldIdleGroup: '{count} 個待命', tasksFoldIdle: '{count} 待命', tasksFoldCompleted: '✓ {count} 已完成', tasksFoldOne: '收進已完成聚合', @@ -477,7 +477,6 @@ export const zhHK: Record = { tasksNodeMode: '模式', tasksNodeModel: '模型', tasksNodeTeamRole: '團隊角色', - tasksNodeActivity: '最近活動', tasksStateRunning: '執行中', tasksStateIdle: '閒置', tasksStateProvisioning: '部署中', diff --git a/src/client/locales-zh-MO.ts b/src/client/locales-zh-MO.ts index f62b1f8a..c9a4fdae 100644 --- a/src/client/locales-zh-MO.ts +++ b/src/client/locales-zh-MO.ts @@ -461,7 +461,7 @@ export const zhMO: Record = { settingsViewModeGraphDesc: '分層節點圖,可縮放平移', settingsViewModeTree: '樹狀圖', settingsViewModeTreeDesc: '經典縮排樹,可用鍵盤導航', - tasksFoldIdleGroup: 'N 個待命', + tasksFoldIdleGroup: '{count} 個待命', tasksFoldIdle: '{count} 待命', tasksFoldCompleted: '✓ {count} 已完成', tasksFoldOne: '收進已完成聚合', @@ -477,7 +477,6 @@ export const zhMO: Record = { tasksNodeMode: '模式', tasksNodeModel: '模型', tasksNodeTeamRole: '團隊角色', - tasksNodeActivity: '最近活動', tasksStateRunning: '執行中', tasksStateIdle: '閒置', tasksStateProvisioning: '部署中', diff --git a/src/client/locales-zh-TW.ts b/src/client/locales-zh-TW.ts index 3527d7b5..fcbce04f 100644 --- a/src/client/locales-zh-TW.ts +++ b/src/client/locales-zh-TW.ts @@ -461,7 +461,7 @@ export const zhTW: Record = { settingsViewModeGraphDesc: '分層節點圖,可縮放平移', settingsViewModeTree: '樹狀圖', settingsViewModeTreeDesc: '經典縮排樹,可用鍵盤導航', - tasksFoldIdleGroup: 'N 個待命', + tasksFoldIdleGroup: '{count} 個待命', tasksFoldIdle: '{count} 待命', tasksFoldCompleted: '✓ {count} 已完成', tasksFoldOne: '收進已完成聚合', @@ -477,7 +477,6 @@ export const zhTW: Record = { tasksNodeMode: '模式', tasksNodeModel: '模型', tasksNodeTeamRole: '團隊角色', - tasksNodeActivity: '最近活動', tasksStateRunning: '執行中', tasksStateIdle: '閒置', tasksStateProvisioning: '部署中', diff --git a/src/client/locales.ts b/src/client/locales.ts index abd6bd15..fd5c877f 100644 --- a/src/client/locales.ts +++ b/src/client/locales.ts @@ -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 = { 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 = { tasksNodeMode: 'Mode', tasksNodeModel: 'Model', tasksNodeTeamRole: 'Team role', - tasksNodeActivity: 'Latest activity', tasksStateRunning: 'Running', tasksStateIdle: 'Idle', tasksStateProvisioning: 'Provisioning', diff --git a/src/client/tasks-card.tsx b/src/client/tasks-card.tsx index 6563e5d9..12f296b2 100644 --- a/src/client/tasks-card.tsx +++ b/src/client/tasks-card.tsx @@ -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 ( - {props.stateWord !== false && {stateLabel(state)}} - {activity !== undefined && activity !== '' && ( - {activity} + {showStateWord && {stateLabel(state)}} + {line !== undefined && ( + {line} )} {props.onFold !== undefined && (