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
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* 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).
|
||||
*
|
||||
* 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
|
||||
* graph-only. Its two pieces are separate components because every node kind
|
||||
* (agent / workflow run / fold aggregate) composes them differently while the
|
||||
* geometry stays identical — the layout reserves the height of exactly these
|
||||
* rows (`tasks-graph-layout.ts`).
|
||||
*
|
||||
* Colour: the group colour of a node is its tree DEPTH, from the plugin's own
|
||||
* token-only ramp (`.depth0…3` in tasks-graph.module.css). The host ships no
|
||||
* chart palette and the skin contract forbids literal colours, so the ramp is
|
||||
* mixed from `--dsw-alias-state-business-primary`; a workflow member's PHASE
|
||||
* badge uses the ink family instead, so the two groupings never share a hue.
|
||||
*/
|
||||
import type { ReactNode } from 'react'
|
||||
import clsx from 'clsx'
|
||||
import { IconChevronDownOutlineRegular, StateDot } from '@deepseek-ai/dsh-client-ui-primitives'
|
||||
import type { TasksNodeState } from './tasks-model.ts'
|
||||
import { nodeDotState, stateLabel } from './tasks-shared.tsx'
|
||||
import { t } from './locales.ts'
|
||||
import css from './tasks-graph.module.css'
|
||||
|
||||
/** The five kinds of card the graph draws. */
|
||||
export type CardKind = 'main' | 'subagent' | 'teammate' | 'workflow' | 'fold'
|
||||
|
||||
/**
|
||||
* The kind badge's word: the SAME vocabulary the rest of the page uses (the
|
||||
* header already calls the root "主代理"), so no sixth word is invented for it.
|
||||
* @param kind - card kind.
|
||||
* @param count - folded member count (the fold aggregate's badge only).
|
||||
*/
|
||||
export function cardKindLabel(kind: CardKind, count = 0): string {
|
||||
switch (kind) {
|
||||
case 'main': return t('subagentMainAgent')
|
||||
case 'subagent': return t('tasksKindSubagent')
|
||||
case 'teammate': return t('tasksKindTeammate')
|
||||
case 'workflow': return t('tasksKindWorkflow')
|
||||
case 'fold': return t('tasksFoldCompleted', { count })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The depth class of a node's group colour (levels past 3 share the last one).
|
||||
* Typed `string | undefined` because the CSS-module map is an open record: a
|
||||
* typo'd class name would otherwise pass `tsc` as a `string`.
|
||||
*/
|
||||
export function depthClass(depth: number): string | undefined {
|
||||
if (depth <= 0) return css.depth0
|
||||
if (depth === 1) return css.depth1
|
||||
if (depth === 2) return css.depth2
|
||||
return css.depth3
|
||||
}
|
||||
|
||||
/** The phase class of a workflow member's badge (phases past 3 share the last one). */
|
||||
export function phaseClass(index: number): string | undefined {
|
||||
if (index <= 0) return css.phase0
|
||||
if (index === 1) return css.phase1
|
||||
if (index === 2) return css.phase2
|
||||
return css.phase3
|
||||
}
|
||||
|
||||
/** The top segment: the node's identity. */
|
||||
export function CardTop(props: {
|
||||
kind: CardKind
|
||||
/** Folded member count, for the aggregate's badge. */
|
||||
count?: number
|
||||
/** Tree depth → the group colour of the badge and the card's left edge. */
|
||||
depth: number
|
||||
/** Workflow phase (a member's badge). */
|
||||
phase?: { index: number; title?: string }
|
||||
/** The node's name (already resolved by the model). */
|
||||
name: string
|
||||
/** The mono meta line under the name. */
|
||||
meta?: string
|
||||
/** Extra class for the name (the aggregate recedes one rung). */
|
||||
extraClass?: string
|
||||
/** Extra rows the caller appends (the team task line). */
|
||||
children?: ReactNode
|
||||
}): ReactNode {
|
||||
const { kind, count, depth, phase } = props
|
||||
return (
|
||||
<span className={clsx(css.cardTop, depthClass(depth))}>
|
||||
<span className={css.cardBadges}>
|
||||
<span className={css.kindBadge} data-card-kind={kind}>
|
||||
{cardKindLabel(kind, count ?? 0)}
|
||||
</span>
|
||||
{phase !== undefined && (
|
||||
<span
|
||||
className={clsx(css.phaseBadge, phaseClass(phase.index))}
|
||||
title={phase.title ?? t('workflowPhaseUnnamed')}
|
||||
>
|
||||
{phase.title ?? t('workflowPhaseUnnamed')}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className={clsx(css.cardName, props.extraClass)} title={props.name}>{props.name}</span>
|
||||
{props.meta !== undefined && <span className={css.cardMeta} title={props.meta}>{props.meta}</span>}
|
||||
{props.children}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/** The bottom bar: the node's state, its merged activity, and its fold chevron. */
|
||||
export function CardBar(props: {
|
||||
state: TasksNodeState
|
||||
/** The merged process activity line (running nodes and settled summaries). */
|
||||
activity?: string
|
||||
/** Whether the node is executing (drives the sweep). */
|
||||
running?: boolean
|
||||
/** Fold the node into its parent's completed aggregate (settled nodes only). */
|
||||
onFold?: (event: { stopPropagation(): void }) => void
|
||||
/** The chevron's accessible name (defaults to the per-node fold word). */
|
||||
foldLabel?: string
|
||||
/** Render the state WORD next to the dot (off for the aggregate's action bar). */
|
||||
stateWord?: boolean
|
||||
/** Replace the whole bar's content (the aggregate's action row). */
|
||||
children?: ReactNode
|
||||
}): ReactNode {
|
||||
const { state, activity, running } = props
|
||||
return (
|
||||
<span
|
||||
className={css.cardBar}
|
||||
data-running={running === true ? 'true' : undefined}
|
||||
data-state={state}
|
||||
>
|
||||
{props.children ?? (
|
||||
<>
|
||||
<StateDot state={nodeDotState(state)} size={6} className={css.barDot} />
|
||||
{props.stateWord !== false && <span className={css.barState}>{stateLabel(state)}</span>}
|
||||
{activity !== undefined && activity !== '' && (
|
||||
<span className={css.barActivity} title={activity}>{activity}</span>
|
||||
)}
|
||||
{props.onFold !== undefined && (
|
||||
<button
|
||||
type="button"
|
||||
className={css.barFold}
|
||||
aria-label={props.foldLabel ?? t('tasksFoldOne')}
|
||||
title={props.foldLabel ?? t('tasksFoldOne')}
|
||||
onClick={(event) => {
|
||||
// The card's own click opens the detail popover: folding must
|
||||
// never do both.
|
||||
event.stopPropagation()
|
||||
props.onFold?.(event)
|
||||
}}
|
||||
>
|
||||
<IconChevronDownOutlineRegular size={12} />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user