Files
apes-sidebar/tests/activity-icons.spec.ts
T
Menghuan1918 79ee383c5e 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)。
2026-10-11 22:04:28 +08:00

53 lines
2.1 KiB
TypeScript

/**
* 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)
}
})
})