feat(tasks): 树模式补上单个收起 / 全部收起 / 全部展开
维护者反馈「树目录还缺单个收起/全部收起/全部展开的按钮」。读码确认:树**根本没有
按节点的展开收起**(只有页级的已结算聚合规则,aria-expanded 还是硬编码 true),
所以这三件事在树的语境里确实都不存在。
- 单个收起/展开:有子节点的行右侧一个 16px chevron(收起 →、展开 ⌄),位置与画布
卡片小条的 chevron 一致;叶子行不画(死控件);点它 stopPropagation,不会顺带
打开详情窗;行上补 aria-expanded。
- 全部收起/全部展开:控制条里两个**文字**单元格(与其它 28px 控件同形)。用文字而非
更多 chevron —— 旁边的「折叠已完成的节点」开关已经占了那套图形语汇,两套轴不能共用。
全部收敛到「有子节点」的节点(只留拓扑根),全部展清空该集合。
- 键盘补标准树绑定:→ 展开(已展开则进入子级)、← 收起(已收起则退回父级)。
- 折叠集存在 SubagentView,图/树切换不丢;与「已结算聚合」是两条互不干扰的轴。
词条 4 个 × 20 词典(tasksTree{Collapse,Expand}{All,Row})。测试 +4 条(单个收放、
叶子无控件、集群全收/全展、方向键收放)。全套 2260 passed / 17 skipped(194 文件)、
tsc 与 eslint 零告警、构建通过;新构建已装进 sidebar-test,:3080 挂载 0 pageerror。
This commit is contained in:
1 parent
48a8e9095c
commit
e849874673
27 files changed
+408
-6
No files matched your search
@@ -17,6 +17,7 @@
|
||||
- 🪶 **FLIP 库只留给流式布局**:树模式行与后台任务行的离场是「原地淡出 + 兄弟滑位」,那正是 FLIP 的语义且不受缩放影响;画布则明确排除(`tests/tasks-motion.spec.ts` 钉死:画布不得 import 它、树与抽屉必须有)。
|
||||
- 💬 **卡片标题下也写最新文本**:图模式卡片在名称下新增一行 10px 的**最新助手文本尾行**(此前只有详情弹窗里才看得到),小条继续写合并活动——两行各答一个问题。**行数按布局预算夹紧**:`textTailLines()` 按字符宽度估算折行、上限 3 行,并把估算值写进卡片的 `-webkit-line-clamp`,所以渲染永远不会超出布局给这个节点算好的盒子(也就不会把行距撑爆);行距 `rowStrideFor()` 改为**按模型里最高的一张卡**计算(工作流 run 的元信息行、成员的任务行、以及最多三行文本尾行都算进去)。详情弹窗的文本块同步从夹两行改为夹三行。
|
||||
- 🌲 **树模式对齐画布并补齐动效**:模式词从行内 mono 行搬成**标题旁的 chip**(与卡片徽标行同一处、同一个词),mono 行只留状态;**每个嵌套层级都有自己的 FLIP host**(`TreeLevel` 组件——库只看容器的直接子节点,单个 host 会让嵌套折叠硬闪);连线改成**每个子节点自己画的肘线**——竖线落在父行的标记列上、且最后一个兄弟的竖线**停在它自己的标记处**(不再拖出组外)。
|
||||
- 🌲 **树模式补上「收起 / 展开」整套**:此前树只有页级「已完成节点聚合」,**没有任何按节点的展开收起**。现在:每行右侧有一个**单个收起/展开**(有子节点的行才有,位置与画布卡片小条的 chevron 一致,16px 同一处);控制条新增 **全部收起 / 全部展开**(用文字而不是更多 chevron——旁边的已结算折叠开关已经占了那套图形语汇);键盘补上标准树行为:**→ 展开(已展开则进入子级)、← 收起(已收起则退回父级)**;行上带 `aria-expanded`,折叠状态跨图/树切换保留。它与「已结算聚合」是两条互不干扰的轴:一个收子树,一个收已完成的叶子。
|
||||
- 🧪 测试:新增 `tests/session-metrics.spec.ts`(5 条:四桶求和、空投影、运行中耗时按渲染时钟、0 不算工作、时钟回拨不显示负数)与 `tests/activity-icons.spec.ts`(3 条:13 个类别全覆盖、读 / 命令 / 搜索 / 网页互不同型、`undefined` 走思考图标);`tests/tasks-page.spec.tsx` 补 6 条(原生状态取代状态词、无数据回退、根卡真实状态、浮窗活动块位置、一次只开一组 + 判据极性的判别性用例、展开后成员仍可手工折回、Token / 耗时两行、侧栏打开地址 + 下拉在主窗打开 + 无宿主能力时单按钮、模式 chip 在徽标行);`tests/tasks-graph-layout.spec.ts` 的高度 / 行距断言跟随新的卡片预算。[设计文档](docs/plans/2026-10-11-tasks-status-and-group-fold.md)。
|
||||
|
||||
- 🃏 **任务卡小条只说原生状态**:运行中小条不再是「● 运行中 正在读取文件」这样把状态念两遍,而是**活动行取代状态词**——`正在分析请求` / `正在读取文件 · main.ts` / `正在准备读取文件` / `正在运行命令 · npm run build` 等措辞全部来自宿主 `chat` 命名空间,与主对话逐字一致;已结算小条同理(只留 `已读取文件、执行了命令`,不重复「已完成」)。**`空闲` 与 `出错` 保留状态词**(「待命」「失败」不被任何活动措辞蕴含),**完全没有活动数据时回退状态词**,小条永不空着。状态点、执行扫光与折叠 chevron 不变,小条仍是 22px——画布几何与卡片高度预算零改动。
|
||||
|
||||
@@ -166,6 +166,25 @@ state === 'running' → liveActivityLabel(summary) // 宿主 mess
|
||||
(不再拖出组外);
|
||||
- **密度刻意没有改**:树的 32px 行节奏(18px 标题 + 14px 元信息)与侧栏其它面同一套度量,压紧行高只会让它在面板里显得发紧。
|
||||
维护者若想要更密,给出目标值(例如 28px 节奏)即可单点调整。
|
||||
## 第四轮(同日,第三次真机反馈)
|
||||
|
||||
用户:「树目录还缺单个收起/全部收起/全部展开的按钮」。
|
||||
|
||||
读码确认:树**根本没有按节点的展开收起**——它只有页级的「已结算节点聚合」(`FoldToggleButton`),
|
||||
`aria-expanded="true"` 还是硬编码的,所以「全部收起/全部展开」在树的语境里也确实不存在。
|
||||
|
||||
实现(与既有折叠轴并存,互不干扰):
|
||||
- **单个收起/展开**:有子节点的行右侧一个 16px chevron(收起态 →、展开态 ⌄),位置与画布卡片小条的
|
||||
chevron 一致;叶子行不画(避免死控件);点它 `stopPropagation`,不会同时打开详情窗。
|
||||
- **全部收起 / 全部展开**:控制条里两个**文字**单元格(`controlText`,与集群里其它 28px 控件同形)。
|
||||
用文字而不是更多 chevron:旁边的「折叠已完成的节点」开关已经占了 chevron 的图形语汇,两套轴不能共用图形。
|
||||
「全部收」= 所有**有子节点**的节点(只留拓扑根);「全部展开」= 清空集合。
|
||||
- **键盘**:→ 展开折叠的行(已展开则进入子级)、← 收起展开的行(已收起则退回父级)——标准树绑定。
|
||||
- **状态归属**:折叠集存在 `SubagentView`(与图/树切换、页级折叠同一层),切模式来回不丢。
|
||||
- 与「已结算聚合」是两条独立的轴:一个收**子树**,一个把**已完成的叶子**收进聚合卡。
|
||||
|
||||
新词条 4 个 × 20 词典:`tasksTreeCollapseAll` / `tasksTreeExpandAll` / `tasksTreeCollapseRow` / `tasksTreeExpandRow`。
|
||||
测试:`tests/tasks-page.spec.tsx` 新增 4 条(单个收放 + 叶子无控件 + 集群全收/全展 + 方向键收放)。
|
||||
|
||||
## 验证证据
|
||||
|
||||
|
||||
@@ -260,6 +260,12 @@ export function SubagentView(props: {
|
||||
*/
|
||||
const [expandedGroups, setExpandedGroups] = useState<ReadonlySet<string>>(() => new Set())
|
||||
const [teamBoardCollapsed, setTeamBoardCollapsed] = useState(false)
|
||||
/**
|
||||
* Tree-mode SUBTREE disclosure: rows whose children the reader folded away.
|
||||
* Kept here (not inside TasksTree) so switching modes and coming back keeps
|
||||
* the shape the reader left, and cleared by 全部展开.
|
||||
*/
|
||||
const [collapsedIds, setCollapsedIds] = useState<ReadonlySet<string>>(() => new Set())
|
||||
const [popover, setPopover] = useState<PagePopover | null>(null)
|
||||
|
||||
const model = useMemo(
|
||||
@@ -359,6 +365,29 @@ export function SubagentView(props: {
|
||||
*/
|
||||
const asideAvailable = useMemo(() => hasTranscriptAside(ctx), [ctx])
|
||||
|
||||
/** One tree row's disclosure: show or hide that node's own subtree. */
|
||||
const toggleCollapse = useCallback((nodeId: string): void => {
|
||||
setCollapsedIds(current => {
|
||||
const next = new Set(current)
|
||||
if (!next.delete(nodeId)) next.add(nodeId)
|
||||
return next
|
||||
})
|
||||
}, [])
|
||||
|
||||
/** 全部收起: every node that HAS children, so only the roots stay visible. */
|
||||
const collapseAllTree = useCallback((): void => {
|
||||
const parents = new Set<string>()
|
||||
for (const node of model) if (node.parentId !== undefined) parents.add(node.parentId)
|
||||
setCollapsedIds(current => (current.size === parents.size && [...parents].every(id => current.has(id))
|
||||
? current
|
||||
: parents))
|
||||
}, [model])
|
||||
|
||||
/** 全部展开: forget every subtree fold. */
|
||||
const expandAllTree = useCallback((): void => {
|
||||
setCollapsedIds(current => (current.size === 0 ? current : new Set()))
|
||||
}, [])
|
||||
|
||||
/** Fold one settled node into its parent's aggregate (its card's chevron). */
|
||||
const foldNode = useCallback((node: TasksAgentNode): void => {
|
||||
setFoldedIds(current => {
|
||||
@@ -627,6 +656,10 @@ export function SubagentView(props: {
|
||||
<TasksTree
|
||||
nodes={model}
|
||||
folded={folded}
|
||||
collapsedIds={collapsedIds}
|
||||
onToggleCollapse={toggleCollapse}
|
||||
onCollapseAll={collapseAllTree}
|
||||
onExpandAll={expandAllTree}
|
||||
loading={summaryBackedLoading}
|
||||
onNodeInfo={(node, anchor) => { setPopover({ kind: 'node', nodeId: node.id, anchor }) }}
|
||||
onWorkflowInfo={(node, anchor) => { setPopover({ kind: 'workflow', nodeId: node.id, anchor }) }}
|
||||
|
||||
+118
-5
@@ -17,7 +17,10 @@
|
||||
*/
|
||||
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 {
|
||||
Button, IconChevronDownOutlineRegular, IconChevronRightOutlineRegular,
|
||||
IconLoadingOutlineRegular, StateDot,
|
||||
} from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { TasksAgentNode, TasksFoldNode, TasksNode, TasksWorkflowNode } from './tasks-model.ts'
|
||||
import {
|
||||
AgentGlyph, agentChip, agentMeta, FoldGlyph, foldPreviews, foldTally, LiveLine, nodeDotState,
|
||||
@@ -34,6 +37,13 @@ import css from './tasks-graph.module.css'
|
||||
* only, so a single host on the scroll container would animate the top level and
|
||||
* leave every nested fold to blink — the reader's "嵌套层级也要有动效".
|
||||
*/
|
||||
/** The human name of a row, whatever kind it is (the disclosure names it). */
|
||||
function nodeLabel(node: TasksNode): string {
|
||||
if (node.kind === 'agent') return node.label
|
||||
if (node.kind === 'workflow') return node.run.name
|
||||
return foldTally(node)
|
||||
}
|
||||
|
||||
function TreeLevel(props: { items: readonly ReactNode[] }): ReactNode {
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
useAutoAnimateRef(ref)
|
||||
@@ -43,6 +53,18 @@ function TreeLevel(props: { items: readonly ReactNode[] }): ReactNode {
|
||||
export interface TasksTreeProps {
|
||||
nodes: readonly TasksNode[]
|
||||
folded: boolean
|
||||
/**
|
||||
* Nodes whose SUBTREE the reader folded away (the tree's own disclosure, one
|
||||
* axis beside the page's settled-leaf rule). A parent not listed here shows
|
||||
* its children.
|
||||
*/
|
||||
collapsedIds: ReadonlySet<string>
|
||||
/** One row's disclosure control. */
|
||||
onToggleCollapse(nodeId: string): void
|
||||
/** 全部收起: hide every subtree. */
|
||||
onCollapseAll(): void
|
||||
/** 全部展开: show every subtree again. */
|
||||
onExpandAll(): void
|
||||
onNodeInfo(node: TasksAgentNode, anchor: HTMLElement): void
|
||||
onWorkflowInfo(node: TasksWorkflowNode, anchor: HTMLElement): void
|
||||
/** Open the shared task window for one task id. */
|
||||
@@ -59,7 +81,8 @@ export interface TasksTreeProps {
|
||||
|
||||
export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
const {
|
||||
nodes, folded, onNodeInfo, onWorkflowInfo, onOpenTask, onToggleFold, onExpandGroup,
|
||||
nodes, folded, collapsedIds, onToggleCollapse, onCollapseAll, onExpandAll,
|
||||
onNodeInfo, onWorkflowInfo, onOpenTask, onToggleFold, onExpandGroup,
|
||||
mode, onModeChange, loading,
|
||||
} = props
|
||||
const bodyRef = useRef<HTMLDivElement>(null)
|
||||
@@ -89,6 +112,28 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
const onTreeKeyDown = useCallback((event: KeyboardEvent<HTMLDivElement>): void => {
|
||||
const items = bodyRef.current?.querySelectorAll<HTMLElement>('[data-tasks-row]') ?? []
|
||||
const index = Array.prototype.indexOf.call(items, document.activeElement)
|
||||
if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
|
||||
// The standard disclosure bindings: Right opens a folded row (and then
|
||||
// walks into it with the next press), Left closes an open one (and then
|
||||
// walks back out to its parent). Rows that offer neither just move.
|
||||
const row = items[index]
|
||||
const nodeId = row?.getAttribute('data-tree-node') ?? undefined
|
||||
const expandable = row?.getAttribute('data-tree-expandable') === 'true'
|
||||
const collapsed = row?.getAttribute('aria-expanded') === 'false'
|
||||
event.preventDefault()
|
||||
if (event.key === 'ArrowRight') {
|
||||
if (nodeId !== undefined && expandable && collapsed) { onToggleCollapse(nodeId); return }
|
||||
focusAt(index + 1)
|
||||
return
|
||||
}
|
||||
if (nodeId !== undefined && expandable && !collapsed) { onToggleCollapse(nodeId); return }
|
||||
// Walk out: the nearest row above with a SHALLOWER aria-level.
|
||||
const level = Number(row?.getAttribute('aria-level') ?? '1')
|
||||
for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
|
||||
if (Number(items[cursor]?.getAttribute('aria-level') ?? '0') < level) { focusAt(cursor); return }
|
||||
}
|
||||
return
|
||||
}
|
||||
if (event.key === 'ArrowDown') {
|
||||
event.preventDefault()
|
||||
focusAt(index + 1)
|
||||
@@ -102,7 +147,7 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
event.preventDefault()
|
||||
focusAt(items.length - 1)
|
||||
}
|
||||
}, [focusAt])
|
||||
}, [focusAt, onToggleCollapse])
|
||||
|
||||
const activateOnKey = (event: KeyboardEvent, action: () => void): void => {
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
@@ -123,15 +168,46 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
* elbow that connects it to that level's thread, and the LAST sibling stops
|
||||
* its segment at the row's marker so the thread never hangs past the group.
|
||||
*/
|
||||
/** Whether this row's subtree is folded away right now. */
|
||||
const collapsed = children.length > 0 && collapsedIds.has(node.id)
|
||||
const wrap = (body: ReactNode): ReactNode => (
|
||||
<div
|
||||
key={node.id}
|
||||
className={clsx(css.treeChild, last && css.treeChildLast)}
|
||||
>
|
||||
{body}
|
||||
{children.length > 0 && <TreeLevel items={children.map(child => renderNode(child, depth + 1, child === children[children.length - 1]))} />}
|
||||
{children.length > 0 && !collapsed && (
|
||||
<TreeLevel
|
||||
items={children.map(child => renderNode(child, depth + 1, child === children[children.length - 1]))}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
/**
|
||||
* The row's own disclosure control, placed at the row's END like the canvas
|
||||
* card's own chevron (and measured the same 16px). Rendered only for a row
|
||||
* that has children: a leaf gets no dead control, and the reader can read
|
||||
* the row's shape from the chevron's direction alone.
|
||||
*/
|
||||
const disclosure = children.length === 0 ? null : (
|
||||
<button
|
||||
type="button"
|
||||
className={css.treeDisclosure}
|
||||
aria-label={`${t(collapsed ? 'tasksTreeExpandRow' : 'tasksTreeCollapseRow')} ${nodeLabel(node)}`}
|
||||
title={t(collapsed ? 'tasksTreeExpandRow' : 'tasksTreeCollapseRow')}
|
||||
onClick={(event) => {
|
||||
// The row's own click opens the detail window: the disclosure must
|
||||
// never do both.
|
||||
event.stopPropagation()
|
||||
onToggleCollapse(node.id)
|
||||
}}
|
||||
>
|
||||
{collapsed
|
||||
? <IconChevronRightOutlineRegular size={12} />
|
||||
: <IconChevronDownOutlineRegular size={12} />}
|
||||
</button>
|
||||
)
|
||||
const row = node.kind === 'fold'
|
||||
? (
|
||||
<div
|
||||
@@ -142,6 +218,9 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
aria-level={depth + 1}
|
||||
aria-label={`${foldTally(node)} · ${t('tasksFoldExpand')}`}
|
||||
className={clsx(css.treeRow, css.treeFoldRow)}
|
||||
data-tree-node={node.id}
|
||||
data-tree-expandable={children.length > 0 ? 'true' : undefined}
|
||||
aria-expanded={children.length === 0 ? undefined : !collapsed}
|
||||
onClick={() => { onExpandGroup(node) }}
|
||||
onKeyDown={(event) => { activateOnKey(event, () => { onExpandGroup(node) }) }}
|
||||
>
|
||||
@@ -159,6 +238,7 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
{foldPreviews(node.previews, node.count)}
|
||||
</span>
|
||||
</span>
|
||||
{disclosure}
|
||||
</div>
|
||||
)
|
||||
: node.kind === 'workflow'
|
||||
@@ -169,8 +249,10 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
role="treeitem"
|
||||
tabIndex={0}
|
||||
aria-level={depth + 1}
|
||||
aria-expanded="true"
|
||||
aria-label={`${node.run.name} ${workflowMeta(node)}`}
|
||||
data-tree-node={node.id}
|
||||
data-tree-expandable={children.length > 0 ? 'true' : undefined}
|
||||
aria-expanded={children.length === 0 ? undefined : !collapsed}
|
||||
className={clsx(css.treeRow, node.run.status !== 'running' && css.treeRowSettled)}
|
||||
onClick={(event) => { onWorkflowInfo(node, event.currentTarget) }}
|
||||
onKeyDown={(event) => {
|
||||
@@ -183,6 +265,7 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
<span className={css.treeTitle} title={node.run.name}>{node.run.name}</span>
|
||||
<span className={css.treeMeta}>{workflowMeta(node)}</span>
|
||||
</span>
|
||||
{disclosure}
|
||||
</div>
|
||||
)
|
||||
: (
|
||||
@@ -193,6 +276,9 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
tabIndex={0}
|
||||
aria-level={depth + 1}
|
||||
aria-label={`${node.label} ${agentMeta(node)}`}
|
||||
data-tree-node={node.id}
|
||||
data-tree-expandable={children.length > 0 ? 'true' : undefined}
|
||||
aria-expanded={children.length === 0 ? undefined : !collapsed}
|
||||
aria-current={node.current ? 'true' : undefined}
|
||||
className={clsx(
|
||||
css.treeRow,
|
||||
@@ -222,6 +308,7 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
{node.state === 'running' && <LiveLine live={node.live} />}
|
||||
<TaskLine tasks={node.tasks} onOpenTask={onOpenTask} />
|
||||
</span>
|
||||
{disclosure}
|
||||
</div>
|
||||
)
|
||||
return wrap(row)
|
||||
@@ -249,6 +336,32 @@ export function TasksTree(props: TasksTreeProps): ReactNode {
|
||||
<div className={css.controls} data-graph-controls>
|
||||
<ViewModeToggle mode={mode} onModeChange={onModeChange} />
|
||||
<FoldToggleButton folded={folded} onToggleFold={onToggleFold} />
|
||||
{/*
|
||||
The tree's OWN disclosure axis, beside the settled-leaf rule: every
|
||||
subtree out, or every subtree back in. Words rather than glyphs — the
|
||||
two axes would otherwise wear the same chevron vocabulary and the
|
||||
reader could not tell 折叠已完成的节点 from 收起所有子级.
|
||||
*/}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={css.controlText}
|
||||
aria-label={t('tasksTreeCollapseAll')}
|
||||
title={t('tasksTreeCollapseAll')}
|
||||
onClick={onCollapseAll}
|
||||
>
|
||||
{t('tasksTreeCollapseAll')}
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className={css.controlText}
|
||||
aria-label={t('tasksTreeExpandAll')}
|
||||
title={t('tasksTreeExpandAll')}
|
||||
onClick={onExpandAll}
|
||||
>
|
||||
{t('tasksTreeExpandAll')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -461,6 +461,10 @@ export const ar: Record<string, string> = {
|
||||
workflowRun: 'سير العمل',
|
||||
tasksNodeState: 'الحالة',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -446,6 +446,10 @@ export const de: Record<string, string> = {
|
||||
workflowRun: 'Workflow',
|
||||
tasksNodeState: 'Status',
|
||||
tasksFoldExpandShort: "Aufklappen",
|
||||
tasksTreeCollapseAll: "Alle einklappen",
|
||||
tasksTreeExpandAll: "Alle ausklappen",
|
||||
tasksTreeCollapseRow: "Unterknoten einklappen",
|
||||
tasksTreeExpandRow: "Unterknoten ausklappen",
|
||||
tasksNodeTokens: "Token-Nutzung",
|
||||
tasksNodeDuration: "Dauer",
|
||||
tasksNodeOpenMain: "Im Hauptfenster öffnen",
|
||||
|
||||
@@ -453,6 +453,10 @@ export const fr: Record<string, string> = {
|
||||
workflowRun: 'Workflow',
|
||||
tasksNodeState: 'État',
|
||||
tasksFoldExpandShort: "Développer",
|
||||
tasksTreeCollapseAll: "Tout réduire",
|
||||
tasksTreeExpandAll: "Tout développer",
|
||||
tasksTreeCollapseRow: "Réduire les enfants",
|
||||
tasksTreeExpandRow: "Développer les enfants",
|
||||
tasksNodeTokens: "Jetons",
|
||||
tasksNodeDuration: "Durée",
|
||||
tasksNodeOpenMain: "Ouvrir dans la fenêtre principale",
|
||||
|
||||
@@ -460,6 +460,10 @@ export const hi: Record<string, string> = {
|
||||
workflowRun: 'वर्कफ़्लो',
|
||||
tasksNodeState: 'स्थिति',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -458,6 +458,10 @@ export const id: Record<string, string> = {
|
||||
workflowRun: 'Alur kerja',
|
||||
tasksNodeState: 'Status',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -451,6 +451,10 @@ export const it: Record<string, string> = {
|
||||
workflowRun: 'Workflow',
|
||||
tasksNodeState: 'Stato',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -460,6 +460,10 @@ export const ja: Record<string, string> = {
|
||||
workflowRun: 'ワークフロー',
|
||||
tasksNodeState: '状態',
|
||||
tasksFoldExpandShort: "展開",
|
||||
tasksTreeCollapseAll: "すべて折りたたむ",
|
||||
tasksTreeExpandAll: "すべて展開",
|
||||
tasksTreeCollapseRow: "子を折りたたむ",
|
||||
tasksTreeExpandRow: "子を展開",
|
||||
tasksNodeTokens: "Token 使用量",
|
||||
tasksNodeDuration: "所要時間",
|
||||
tasksNodeOpenMain: "メインウィンドウで開く",
|
||||
|
||||
@@ -452,6 +452,10 @@ export const ko: Record<string, string> = {
|
||||
workflowRun: '워크플로',
|
||||
tasksNodeState: '상태',
|
||||
tasksFoldExpandShort: "펼치기",
|
||||
tasksTreeCollapseAll: "모두 접기",
|
||||
tasksTreeExpandAll: "모두 펼치기",
|
||||
tasksTreeCollapseRow: "하위 접기",
|
||||
tasksTreeExpandRow: "하위 펼치기",
|
||||
tasksNodeTokens: "토큰 사용량",
|
||||
tasksNodeDuration: "소요 시간",
|
||||
tasksNodeOpenMain: "메인 창에서 열기",
|
||||
|
||||
@@ -458,6 +458,10 @@ export const nl: Record<string, string> = {
|
||||
workflowRun: 'Workflow',
|
||||
tasksNodeState: 'Status',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -462,6 +462,10 @@ export const pl: Record<string, string> = {
|
||||
workflowRun: 'Przepływ pracy',
|
||||
tasksNodeState: 'Stan',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -443,6 +443,10 @@ export const pt: Record<string, string> = {
|
||||
workflowRun: 'Workflow',
|
||||
tasksNodeState: 'Estado',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -458,6 +458,10 @@ export const ru: Record<string, string> = {
|
||||
workflowRun: 'Рабочий процесс',
|
||||
tasksNodeState: 'Состояние',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -443,6 +443,10 @@ export const sv: Record<string, string> = {
|
||||
workflowRun: 'Arbetsflöde',
|
||||
tasksNodeState: 'Status',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -460,6 +460,10 @@ export const th: Record<string, string> = {
|
||||
workflowRun: 'เวิร์กโฟลว์',
|
||||
tasksNodeState: 'สถานะ',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -460,6 +460,10 @@ export const tr: Record<string, string> = {
|
||||
workflowRun: 'İş akışı',
|
||||
tasksNodeState: 'Durum',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -460,6 +460,10 @@ export const vi: Record<string, string> = {
|
||||
workflowRun: 'Quy trình',
|
||||
tasksNodeState: 'Trạng thái',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -475,6 +475,10 @@ export const zhHK: Record<string, string> = {
|
||||
workflowRun: '工作流',
|
||||
tasksNodeState: '狀態',
|
||||
tasksFoldExpandShort: "展開",
|
||||
tasksTreeCollapseAll: "全部收合",
|
||||
tasksTreeExpandAll: "全部展開",
|
||||
tasksTreeCollapseRow: "收合子層",
|
||||
tasksTreeExpandRow: "展開子層",
|
||||
tasksNodeTokens: "Token 用量",
|
||||
tasksNodeDuration: "耗時",
|
||||
tasksNodeOpenMain: "在主視窗中打開",
|
||||
|
||||
@@ -475,6 +475,10 @@ export const zhMO: Record<string, string> = {
|
||||
workflowRun: '工作流',
|
||||
tasksNodeState: '狀態',
|
||||
tasksFoldExpandShort: "展開",
|
||||
tasksTreeCollapseAll: "全部收合",
|
||||
tasksTreeExpandAll: "全部展開",
|
||||
tasksTreeCollapseRow: "收合子層",
|
||||
tasksTreeExpandRow: "展開子層",
|
||||
tasksNodeTokens: "Token 用量",
|
||||
tasksNodeDuration: "耗時",
|
||||
tasksNodeOpenMain: "在主視窗中打開",
|
||||
|
||||
@@ -475,6 +475,10 @@ export const zhTW: Record<string, string> = {
|
||||
workflowRun: '工作流',
|
||||
tasksNodeState: '狀態',
|
||||
tasksFoldExpandShort: "展開",
|
||||
tasksTreeCollapseAll: "全部收合",
|
||||
tasksTreeExpandAll: "全部展開",
|
||||
tasksTreeCollapseRow: "收合子層",
|
||||
tasksTreeExpandRow: "展開子層",
|
||||
tasksNodeTokens: "Token 用量",
|
||||
tasksNodeDuration: "耗時",
|
||||
tasksNodeOpenMain: "在主視窗中打開",
|
||||
|
||||
@@ -472,6 +472,10 @@ export const zh = {
|
||||
workflowRun: '工作流',
|
||||
tasksNodeState: '状态',
|
||||
tasksFoldExpandShort: "展开",
|
||||
tasksTreeCollapseAll: "全部收起",
|
||||
tasksTreeExpandAll: "全部展开",
|
||||
tasksTreeCollapseRow: "收起子级",
|
||||
tasksTreeExpandRow: "展开子级",
|
||||
tasksNodeTokens: "Token 用量",
|
||||
tasksNodeDuration: "耗时",
|
||||
tasksNodeOpenMain: "在主窗口中打开",
|
||||
@@ -1046,6 +1050,10 @@ export const en: Record<keyof typeof zh, string> = {
|
||||
workflowRun: 'Workflow',
|
||||
tasksNodeState: 'State',
|
||||
tasksFoldExpandShort: "Expand",
|
||||
tasksTreeCollapseAll: "Collapse all",
|
||||
tasksTreeExpandAll: "Expand all",
|
||||
tasksTreeCollapseRow: "Collapse children",
|
||||
tasksTreeExpandRow: "Expand children",
|
||||
tasksNodeTokens: "Tokens",
|
||||
tasksNodeDuration: "Duration",
|
||||
tasksNodeOpenMain: "Open in the main window",
|
||||
|
||||
@@ -696,6 +696,29 @@
|
||||
color: var(--dsw-alias-state-business-primary);
|
||||
}
|
||||
|
||||
/* A WORDED cell of the cluster (the tree's collapse/expand-all pair): the same
|
||||
28px control shape as the glyph cells, sized by its label. Words rather than
|
||||
more chevrons, because the settled-leaf switch beside them already wears that
|
||||
vocabulary. */
|
||||
.controlText {
|
||||
box-sizing: border-box;
|
||||
height: 28px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 8px;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
font: var(--dsw-font-xxxs-11);
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.controlText:hover {
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
/* The zoom readout is the cluster's one non-button cell: same 28px height,
|
||||
micro type, tabular figures so the row of numbers does not jitter. */
|
||||
.controlZoomLevel {
|
||||
@@ -778,6 +801,31 @@
|
||||
padding-left: 14px;
|
||||
}
|
||||
|
||||
/* The row's own disclosure control: at the row's END, the same 16px cell and
|
||||
the same chevron the canvas card's bar wears — one tree, one place to look for
|
||||
"open / close this node's children". A leaf renders none. */
|
||||
.treeDisclosure {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-self: flex-start;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 8px 0 0 auto;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.treeDisclosure:hover {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
/* One child wrapper: the elbow that ties it to its parent's thread. The segment
|
||||
spans the whole subtree of a middle sibling (so the thread stays continuous)
|
||||
and stops at the row's own marker for the LAST one, so a group's thread ends
|
||||
|
||||
@@ -92,7 +92,7 @@ describe('Tasks page motion', () => {
|
||||
const tree = code('src/client/TasksTree.tsx')
|
||||
expect(tree).toContain('function TreeLevel')
|
||||
expect(tree).toContain('useAutoAnimateRef')
|
||||
expect(tree).toContain('<TreeLevel items=')
|
||||
expect(tree).toContain('<TreeLevel')
|
||||
})
|
||||
|
||||
it('parks the motion host behind a WAAPI guard so tests and old hosts stay inert', () => {
|
||||
|
||||
@@ -1580,3 +1580,107 @@ describe('Tasks page: the card text tail and the tree chip', () => {
|
||||
unmount()
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* The tree's own disclosure axis: one row's children, every row's children, and
|
||||
* back again. It sits BESIDE the settled-leaf fold rule, so a reader can shrink
|
||||
* a big topology without folding work away.
|
||||
*/
|
||||
describe('Tasks page: the tree disclosure', () => {
|
||||
/** A snapshot with a nested child: root → child-0 → grandchild. */
|
||||
function snapshotWithGrandchild(): SidebarSessionList {
|
||||
const list = snapshotWithChildren(2)
|
||||
const projections = list.projectionsBySession as Record<string, SidebarProjectionSnapshot>
|
||||
const rootEntries = projections.root!.values.subagentCatalog as SidebarSubagentCatalogEntry[]
|
||||
const grandchild: SidebarSubagentCatalogEntry = {
|
||||
id: 'grand-0', createdAt: 9, mode: 'one-shot', label: '孙代理 0',
|
||||
}
|
||||
// `subagentCatalog` is a frozen tuple in the host's shape, so the grandchild
|
||||
// rides a FRESH array rather than a push into the fixture's.
|
||||
projections.root = {
|
||||
values: { subagentCatalog: [...rootEntries, grandchild] },
|
||||
state: 'ready',
|
||||
error: null,
|
||||
}
|
||||
list.byId['grand-0'] = {
|
||||
id: 'grand-0', displayTitle: 'grand-0', origin: 'subagent', parentId: 'child-0', running: false,
|
||||
}
|
||||
projections['child-0'] = {
|
||||
values: { subagentCatalog: [grandchild] },
|
||||
state: 'ready',
|
||||
error: null,
|
||||
}
|
||||
projections['grand-0'] = { values: { subagentCatalog: [] }, state: 'ready', error: null }
|
||||
return list
|
||||
}
|
||||
|
||||
/** Render the page in TREE mode with the page-level fold unfolded. */
|
||||
async function renderTree(snapshot: SidebarSessionList): Promise<{ container: HTMLElement, unmount(): void }> {
|
||||
const rendered = renderRoot(createElement(SubagentView, {
|
||||
sessionId: 'root', active: true, ctx: makeCtx(makeStore(snapshot)),
|
||||
}))
|
||||
await flushJobs()
|
||||
await act(async () => {
|
||||
(rendered.container.querySelector('button[aria-label="切换为树状图"]') as HTMLButtonElement).click()
|
||||
})
|
||||
await act(async () => {
|
||||
(rendered.container.querySelector('button[aria-label="展开已完成的节点"]') as HTMLButtonElement).click()
|
||||
})
|
||||
return rendered
|
||||
}
|
||||
|
||||
it('folds ONE row\'s subtree from its own control, and unfolds it again', async () => {
|
||||
const { container, unmount } = await renderTree(snapshotWithGrandchild())
|
||||
expect(container.textContent).toContain('孙代理 0')
|
||||
const row = [...container.querySelectorAll('[data-tasks-row]')]
|
||||
.find(candidate => candidate.textContent?.includes('子代理 0')) as HTMLElement
|
||||
expect(row.getAttribute('aria-expanded')).toBe('true')
|
||||
const control = row.querySelector('button[aria-label^="收起子级"]') as HTMLButtonElement
|
||||
expect(control).not.toBeNull()
|
||||
await act(async () => { control.click() })
|
||||
expect(container.textContent).not.toContain('孙代理 0')
|
||||
expect(row.getAttribute('aria-expanded')).toBe('false')
|
||||
const reopen = row.querySelector('button[aria-label^="展开子级"]') as HTMLButtonElement
|
||||
await act(async () => { reopen.click() })
|
||||
expect(container.textContent).toContain('孙代理 0')
|
||||
unmount()
|
||||
})
|
||||
|
||||
it('offers no disclosure on a leaf row', async () => {
|
||||
const { container, unmount } = await renderTree(snapshotWithChildren(1))
|
||||
const row = [...container.querySelectorAll('[data-tasks-row]')]
|
||||
.find(candidate => candidate.textContent?.includes('子代理 0')) as HTMLElement
|
||||
expect(row.querySelector('button[aria-label^="收起子级"]')).toBeNull()
|
||||
expect(row.getAttribute('aria-expanded')).toBeNull()
|
||||
unmount()
|
||||
})
|
||||
|
||||
it('collapses and expands EVERY subtree from the cluster', async () => {
|
||||
const { container, unmount } = await renderTree(snapshotWithGrandchild())
|
||||
expect(container.textContent).toContain('孙代理 0')
|
||||
await act(async () => {
|
||||
(container.querySelector('button[aria-label="全部收起"]') as HTMLButtonElement).click()
|
||||
})
|
||||
// Only the topology root is left: every parent folded its children away.
|
||||
const remaining = [...container.querySelectorAll('[data-tasks-row]')]
|
||||
expect(remaining).toHaveLength(1)
|
||||
expect(remaining[0]?.textContent).toContain('主会话')
|
||||
await act(async () => {
|
||||
(container.querySelector('button[aria-label="全部展开"]') as HTMLButtonElement).click()
|
||||
})
|
||||
expect(container.textContent).toContain('孙代理 0')
|
||||
unmount()
|
||||
})
|
||||
|
||||
it('opens a folded row with ArrowRight and closes it with ArrowLeft', async () => {
|
||||
const { container, unmount } = await renderTree(snapshotWithGrandchild())
|
||||
const rows = [...container.querySelectorAll('[data-tasks-row]')] as HTMLElement[]
|
||||
const row = rows.find(candidate => candidate.textContent?.includes('子代理 0')) as HTMLElement
|
||||
row.focus()
|
||||
await act(async () => { row.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', bubbles: true })) })
|
||||
expect(container.textContent).not.toContain('孙代理 0')
|
||||
await act(async () => { row.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true })) })
|
||||
expect(container.textContent).toContain('孙代理 0')
|
||||
unmount()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user