feat(tasks): 图节点改为双段式卡片 + 折叠聚合 + 窄栏可读性
图模式(主显示模式)换成新的卡片语言,树模式保持不变: - 卡片 = 上段(类型徽章 + 相位徽标 + 名称两行 + mono 元信息 + 团队任务行) + 下段小条(状态点 + 状态词 + 主 Agent 同款合并活动 + 完成后的折叠 chevron)。 类型徽章用页面自己的词汇(主代理 / 子代理 / 成员 / 工作流 / ✓N 已完成)。 - 分组色(层级):按树深度取 4 档令牌色阶(color-mix 混 --dsw-alias-state-business-primary), 作用于左描边与上段极淡底色;相位徽标走 ink 色族,两套分组不撞色。 相位虚线框保留但改用同色极淡描边,卡片徽标承担「这是哪个阶段」。 - 执行态:小条 `data-running` + 从左到右扫光(1.5s,末 1/3 停顿, prefers-reduced-motion 关闭);合并活动行来自宿主 chat 词条,缺失时回退插件文案。 - 折叠:已完成节点的 chevron 把该节点「收进已完成聚合」(模型新增 foldedIds, 与全局 folded 走同一组守卫:只在已结算叶子、非当前会话、非团队成员时生效); 聚合节点点击 = 全部展开(清空手动集 + 关闭全局折叠);控制条仍只管全局规则。 - 布局与窄栏(用户反馈 a–f):卡片高度预算按新行重算(徽章 + 两行标题 + 元信息 + 小条 = 103px,任务行 +18),宽度 176 → 190;fit 按内容包围盒双轴居中、 FIT_MAX_SCALE 1.15 → 1.30;缩放范围 0.4–2.0 并归一化 wheel deltaMode; 平移加边界夹取(至少 72px 内容留在视口内);空画布双击重新适配并恢复自动 fit; 连线改「垂直出线 stub + 贝塞尔」并加粗到 1.5px。 验证:typecheck / lint 通过;pnpm test 1253 passed / 9 skipped(含新增双段结构、 data-running、chevron → 聚合、聚合 → 全部展开、工作流相位徽标 5 例)。 (cherry picked from commit aee571e50beb5dc979995f0841cffd0a575f2173)
This commit is contained in:
1 parent
a454cfc9fe
commit
f584b67813
29 files changed
+999
-212
No files matched your search
@@ -7,11 +7,7 @@
|
||||
* the width-aware solver.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { SidebarChildLiveView } from '../src/context-types.ts'
|
||||
import {
|
||||
GRAPH_GAP_Y,
|
||||
GRAPH_LIVE_H,
|
||||
GRAPH_LIVE_TAIL_H,
|
||||
GRAPH_NODE_H,
|
||||
GRAPH_NODE_W,
|
||||
GRAPH_PAD,
|
||||
@@ -38,12 +34,19 @@ function agent(
|
||||
): TasksAgentNode {
|
||||
return {
|
||||
kind: 'agent', id, ...(parentId === undefined ? {} : { parentId }),
|
||||
depth: parentId === undefined ? 0 : 1,
|
||||
label: id, state: 'running', activity: 'running', current: false,
|
||||
...(live ? { live: { text: 'x' } } : {}),
|
||||
...(live ? { live: { running: true, text: 'x' } } : {}),
|
||||
...extra,
|
||||
}
|
||||
}
|
||||
|
||||
/** One running node's live view: a merged activity row (the bar's text). */
|
||||
const ACTIVITY = {
|
||||
running: true,
|
||||
summary: { counts: [{ kind: 'read' as const, count: 1 }], running: 'read' as const, runningDetail: 'x' },
|
||||
}
|
||||
|
||||
/** The row index of one laid-out node. */
|
||||
function layoutRow(layout: ReturnType<typeof layoutTasksGraph>, id: string): number {
|
||||
const box = layout.boxes.get(id)
|
||||
@@ -51,77 +54,25 @@ function layoutRow(layout: ReturnType<typeof layoutTasksGraph>, id: string): num
|
||||
return (box.y - GRAPH_PAD) / GRAPH_ROW_STRIDE
|
||||
}
|
||||
|
||||
/** One running node's live view: a merged activity row, no text tail. */
|
||||
const ACTIVITY: SidebarChildLiveView = {
|
||||
running: true,
|
||||
summary: { counts: [{ kind: 'read', count: 1 }], running: 'read', runningDetail: 'x' },
|
||||
}
|
||||
|
||||
describe('layoutTasksGraph', () => {
|
||||
it('places the root on row 0 and children one row below', () => {
|
||||
const nodes: TasksNode[] = [agent('root'), agent('a', 'root'), agent('b', 'root')]
|
||||
const layout = layoutTasksGraph(nodes)
|
||||
// A running agent reserves the live-line row (its "thinking" fallback).
|
||||
expect(layout.boxes.get('root')).toMatchObject({ y: GRAPH_PAD, h: GRAPH_NODE_H + GRAPH_LIVE_H })
|
||||
expect(layout.boxes.get('a')?.y).toBe(GRAPH_PAD + GRAPH_ROW_STRIDE)
|
||||
expect(layout.boxes.get('b')?.y).toBe(GRAPH_PAD + GRAPH_ROW_STRIDE)
|
||||
})
|
||||
|
||||
it('centers a parent over its children band', () => {
|
||||
const nodes: TasksNode[] = [agent('root'), agent('a', 'root'), agent('b', 'root')]
|
||||
const layout = layoutTasksGraph(nodes)
|
||||
const a = layout.boxes.get('a')
|
||||
const b = layout.boxes.get('b')
|
||||
const root = layout.boxes.get('root')
|
||||
expect(a).toBeDefined(); expect(b).toBeDefined(); expect(root).toBeDefined()
|
||||
const bandCenter = (a!.x + b!.x + GRAPH_NODE_W) / 2
|
||||
expect(root!.x + GRAPH_NODE_W / 2).toBeCloseTo(bandCenter, 5)
|
||||
})
|
||||
|
||||
it('grows live rows and widens the canvas for deep/wide forests', () => {
|
||||
const nodes: TasksNode[] = [
|
||||
agent('root'), agent('a', 'root', true),
|
||||
agent('a1', 'a'), agent('a2', 'a'), agent('a3', 'a'),
|
||||
]
|
||||
const layout = layoutTasksGraph(nodes)
|
||||
expect(layout.boxes.get('a')?.h).toBe(GRAPH_NODE_H + GRAPH_LIVE_H)
|
||||
expect(layout.width).toBeGreaterThan(3 * GRAPH_NODE_W)
|
||||
expect(layout.height).toBeGreaterThan(2 * (GRAPH_NODE_H + GRAPH_GAP_Y))
|
||||
})
|
||||
|
||||
it('reserves the shared-task row a teammate card renders', () => {
|
||||
// A non-running teammate with a task line renders two title lines + the
|
||||
// meta line + the task row; the base card alone reserves 16px less, and
|
||||
// the card (height auto) renders that much outside its own box — which is
|
||||
// what the edges and the phase frames are placed from.
|
||||
describe('layout: card heights', () => {
|
||||
it('reserves the state bar for every node kind, and the task row only for team members', () => {
|
||||
const nodes: TasksNode[] = [
|
||||
agent('root'),
|
||||
agent('mate', 'root', false, { state: 'idle', tasks: [task('t1')] }),
|
||||
agent('busy', 'root', false, { live: ACTIVITY }),
|
||||
agent('owner', 'root', false, { tasks: [task('t1')] }),
|
||||
]
|
||||
const layout = layoutTasksGraph(nodes)
|
||||
expect(layout.boxes.get('mate')?.h).toBe(GRAPH_NODE_H + GRAPH_TASK_H)
|
||||
// Without tasks the card keeps the base shape.
|
||||
const plain = layoutTasksGraph([agent('root'), agent('mate', 'root', false, { state: 'idle' })])
|
||||
expect(plain.boxes.get('mate')?.h).toBe(GRAPH_NODE_H)
|
||||
})
|
||||
|
||||
it('reserves the live tail row only when the tail carries activity AND text', () => {
|
||||
const nodes: TasksNode[] = [
|
||||
agent('root'),
|
||||
agent('tool-only', 'root', false, { live: ACTIVITY }),
|
||||
agent('both', 'root', false, { live: { ...ACTIVITY, text: 'y' } }),
|
||||
]
|
||||
const layout = layoutTasksGraph(nodes)
|
||||
// One live row either way (the tool row, or the meta-styled thinking
|
||||
// fallback); the flattened text row is the second one.
|
||||
expect(layout.boxes.get('tool-only')?.h).toBe(GRAPH_NODE_H + GRAPH_LIVE_H)
|
||||
expect(layout.boxes.get('both')?.h).toBe(GRAPH_NODE_H + GRAPH_LIVE_H + GRAPH_LIVE_TAIL_H)
|
||||
// The merged activity lives in the bar, which every card renders: a
|
||||
// running node and a settled one reserve exactly the same base height.
|
||||
expect(layout.boxes.get('root')?.h).toBe(GRAPH_NODE_H)
|
||||
expect(layout.boxes.get('busy')?.h).toBe(GRAPH_NODE_H)
|
||||
expect(layout.boxes.get('owner')?.h).toBe(GRAPH_NODE_H + GRAPH_TASK_H)
|
||||
})
|
||||
|
||||
it('keeps every card shape inside one row stride', () => {
|
||||
// The stride is the row pitch: a card taller than it would overlap the
|
||||
// next row (and its phase frame).
|
||||
const tallest = GRAPH_NODE_H + GRAPH_LIVE_H + GRAPH_LIVE_TAIL_H + GRAPH_TASK_H
|
||||
const tallest = GRAPH_NODE_H + GRAPH_TASK_H
|
||||
expect(GRAPH_ROW_STRIDE).toBeGreaterThanOrEqual(tallest)
|
||||
const nodes: TasksNode[] = [
|
||||
agent('root'),
|
||||
|
||||
Reference in new issue
Block a user