团队功能在 0.1.7 上整条失效:team-routes.ts 当初镜像的是 0.1.6 的 Remote 词汇
(remoteView / remoteCreateTask / remoteUpdateTask),而 0.1.7 把这三个方法删掉了,
读路径改到 Lead Session 的 `agentTeam` Session projection。真机 3080 复现:
teams.view 对带团队的会话返回 400 "membership.svc.remoteView is not a function",
于是 TeamBoard 从不渲染、节点富化与任务窗连带失效。
- 读:删掉 teams.view 与 5s 轮询,改读 SessionListState.projectionsBySession[root]
.values.agentTeam(与 subagentCatalog 同源,推送式);新增 client/team-projection.ts
做纯适配器,成员运行状态由 subagents.live 的 running 叠加、Lead 回退 session list
(官方 README 的 "overlays activity from Session status")。projection 缺席 =
这里没有团队,与旧的 {available:false}/{team:null} 合并成同一静默降级。
- 写:taskCreate/taskUpdate 改调 0.1.7 的 createTask/updateTask(返回已提交的 view,
拒绝改为抛 TeamError),TEAM_TASK_STALE_REVISION → 409 team-conflict,其余 → 400
team-error(wire 新增 team-conflict)。api.ts 的 writeTask 把失败信封还原成
{ok:false,code,message} —— 原先窗口永远走不到该分支(readEnvelope 是抛)。
- 任务窗:外壳换成上一轮的 FloatingWindow(可拖拽/可拉伸/只在关闭或 Esc 时消失),
动作行下沉到 shell 的 footer,长描述不再把动作推出视野。
- 真机抓到的两个单测抓不到的问题:
1. 队列中任务的「完成」被宿主状态机拒绝(pending → claim → in_progress →
complete → completed → reopen)→ 动作行跟随状态,pending 出「认领」;
2. 认领后 Tag 变「阻塞」—— ready 的语义只是「pending 且无未完成 blocker」,
对所有非 pending 任务都是 false → 抽出唯一规则 taskBlocked/taskStatusLabel/
taskTone/taskDotState,四处展示点全部改走它。
- i18n:新增 teamTaskClaim / taskWindowCreate / taskWindowDetail /
tasksStateProvisioning 词条 ×20 词典。
验证:typecheck / lint 通过;pnpm test 1276 passed / 9 skipped;
pnpm test:mount 7/7(真实 DSH 0.1.7-rc.2 挂载 + tab 全扫无崩溃)。
真机 3080(0.1.7-rc.1 + Agent Teams 实验层):看板从 projection 渲染、
队列任务「认领」→「完成」全链路写通(负责人 lead / 进行中 / 已完成)、
外部点击不关窗、Escape 关窗,截图见 docs/plans/2026-09-27-agent-teams-dsh-0.1.7-adaptation.md。
(cherry picked from commit dbc524e0b350c5d3564843f4776cd15d797506d8)
225 lines
8.9 KiB
TypeScript
225 lines
8.9 KiB
TypeScript
/**
|
|
* 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.
|
|
*
|
|
* 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
|
|
* inset list well of 28px rows, and one l1 hairline around whatever closes the
|
|
* card. The only intended difference is where a group header sits: a single
|
|
* list keeps its label fixed above the well, while a multi-phase run scrolls
|
|
* each phase label with its own rows.
|
|
*
|
|
* Every control is a host primitive (`Button` / `StateDot` / `Tag`) — a row
|
|
* that opens something IS a `<button>`, so it is keyboard reachable — and the
|
|
* boxes around them are the page's own module classes (`popCard`, `popRows`,
|
|
* `popList*`). The card is the portal's content root, so it paints the floating
|
|
* surface itself: the popover shell only positions the box it portals.
|
|
*
|
|
* A member row with a child session jumps to that transcript; a member without
|
|
* one (a declaration that never spawned) stays a plain tally line.
|
|
*
|
|
* The team board is NOT here: it is always visible as a strip above the
|
|
* canvas (TeamBoard.tsx).
|
|
*/
|
|
import type { ReactNode } from 'react'
|
|
import clsx from 'clsx'
|
|
import { Button, IconRightUpOutlineRegular, StateDot, Tag } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
import type { SidebarSubagentAddress } from '../context-types.ts'
|
|
import type { TasksAgentNode, TasksWorkflowNode } from './tasks-model.ts'
|
|
import {
|
|
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'
|
|
|
|
/** The display-state label key. */
|
|
function stateKey(state: TasksAgentNode['state']): CopyKey {
|
|
switch (state) {
|
|
case 'running': return 'tasksStateRunning'
|
|
case 'idle': return 'tasksStateIdle'
|
|
case 'done': return 'tasksStateDone'
|
|
case 'error': return 'tasksStateError'
|
|
}
|
|
}
|
|
|
|
/** The popover's key/value grid. */
|
|
function PopRows(props: { children: ReactNode }): ReactNode {
|
|
return <dl className={css.popRows}>{props.children}</dl>
|
|
}
|
|
|
|
/** One key/value row of a popover. */
|
|
function PopRow(props: { label: string; mono?: boolean; children: ReactNode }): ReactNode {
|
|
return (
|
|
<>
|
|
<dt className={css.popKey}>{props.label}</dt>
|
|
<dd className={clsx(css.popValue, props.mono === true && css.popValueMono)}>{props.children}</dd>
|
|
</>
|
|
)
|
|
}
|
|
|
|
/** The title row both popovers open with: the card's host glyph, then the name. */
|
|
function PopTitleRow(props: { glyph: ReactNode; title: string }): ReactNode {
|
|
return (
|
|
<div className={css.popTitleRow}>
|
|
<span className={css.popGlyph} aria-hidden="true">{props.glyph}</span>
|
|
<span className={css.popTitle} title={props.title}>{props.title}</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** The agent node detail popover. */
|
|
export function AgentNodePopover(props: {
|
|
node: TasksAgentNode
|
|
onJump(node: TasksAgentNode): void
|
|
/** Open the shared task window for one of the node's tasks. */
|
|
onOpenTask(taskId: string, anchor: HTMLElement): void
|
|
}): ReactNode {
|
|
const { node, onJump, onOpenTask } = props
|
|
/** The row's mode word; `unknown` claims no mode and this row is omitted. */
|
|
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)
|
|
return (
|
|
<div className={css.popCard}>
|
|
<div className={css.popHead}>
|
|
<span>{t('tasksNodeDetail')}</span>
|
|
</div>
|
|
<PopTitleRow glyph={<AgentGlyph node={node} />} title={node.label} />
|
|
<PopRows>
|
|
<PopRow label={t('tasksNodeState')}>
|
|
<StateDot state={nodeDotState(node.state)} size={6} /> {t(stateKey(node.state))}
|
|
</PopRow>
|
|
{nodeMode !== undefined && (
|
|
<PopRow label={t('tasksNodeMode')}>{nodeMode}</PopRow>
|
|
)}
|
|
{node.team !== undefined && (
|
|
<PopRow label={t('tasksNodeTeamRole')}>
|
|
{node.team.role === 'lead' ? 'lead' : node.team.name}
|
|
</PopRow>
|
|
)}
|
|
{(liveTool !== undefined || liveText !== undefined) && (
|
|
<PopRow label={t('tasksNodeActivity')} mono>{liveTool ?? liveText}</PopRow>
|
|
)}
|
|
</PopRows>
|
|
{liveText !== undefined && liveTool !== undefined && (
|
|
<div className={css.popHint}>{liveText}</div>
|
|
)}
|
|
{(node.tasks?.length ?? 0) > 0 && (
|
|
<div className={css.popSection}>
|
|
<div className={css.popGroup}>{t('tasksNodeTasks')}</div>
|
|
<div className={css.popList}>
|
|
{(node.tasks ?? []).map(task => (
|
|
// The whole row opens the shared task window.
|
|
<Button
|
|
key={task.id}
|
|
variant="ghost"
|
|
size="sm"
|
|
className={css.popListRow}
|
|
title={task.subject}
|
|
onClick={(event) => { onOpenTask(task.id, event.currentTarget) }}
|
|
>
|
|
<StateDot state={taskDotState(task)} size={6} />
|
|
<span className={css.popListLabel}>{task.subject}</span>
|
|
<Tag tone={taskTone(task)}>{taskStatusLabel(task)}</Tag>
|
|
</Button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
{(node.childAddress !== undefined || node.parentId === undefined) && (
|
|
<div className={css.popFoot}>
|
|
<Button
|
|
variant="primary"
|
|
size="sm"
|
|
icon={<IconRightUpOutlineRegular size={12} />}
|
|
onClick={() => { onJump(node) }}
|
|
>
|
|
{t('tasksNodeJump')}
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
/** The workflow run detail popover (phases with clickable member rows). */
|
|
export function WorkflowNodePopover(props: {
|
|
node: TasksWorkflowNode
|
|
onJumpMember(address: SidebarSubagentAddress): void
|
|
}): ReactNode {
|
|
const { node, onJumpMember } = props
|
|
const { run } = node
|
|
/** A member with no outcome yet still runs; only completed/failed settle. */
|
|
const memberDot = (outcome: string | undefined): 'ongoing' | 'done' | 'error' | 'idle' => {
|
|
if (outcome === undefined) return 'ongoing'
|
|
if (outcome === 'completed') return 'done'
|
|
if (outcome === 'failed') return 'error'
|
|
return 'idle'
|
|
}
|
|
return (
|
|
<div className={css.popCard}>
|
|
<div className={css.popHead}>
|
|
<span>{t('workflowRun')}</span>
|
|
</div>
|
|
<PopTitleRow glyph={<WorkflowGlyph />} title={run.name} />
|
|
<PopRows>
|
|
<PopRow label={t('tasksNodeState')}>{t(workflowStatusKey(run.status))}</PopRow>
|
|
</PopRows>
|
|
{run.phases.length > 0 && (
|
|
<div className={css.popSection}>
|
|
<div className={css.popList}>
|
|
{run.phases.map((phase, phaseIndex) => (
|
|
<div key={`${phase.title ?? 'phase'}-${phaseIndex}`}>
|
|
<div className={css.popGroup}>{phase.title ?? t('workflowPhaseUnnamed')}</div>
|
|
{phase.members.length === 0 && (
|
|
<div className={css.popHint}>{t('subagentEmpty')}</div>
|
|
)}
|
|
{phase.members.map(member => {
|
|
const body = (
|
|
<>
|
|
<StateDot size={6} state={memberDot(member.outcome)} />
|
|
<span className={css.popListLabel}>{member.label}</span>
|
|
</>
|
|
)
|
|
// A member row IS a jump affordance when it has a child
|
|
// session (a real button, so it is keyboard reachable);
|
|
// without one it stays a plain tally line.
|
|
return member.childId === ''
|
|
? (
|
|
<div key={member.seq} className={css.popListRow} title={member.label}>{body}</div>
|
|
)
|
|
: (
|
|
<Button
|
|
key={member.seq}
|
|
variant="ghost"
|
|
size="sm"
|
|
className={css.popListRow}
|
|
title={member.label}
|
|
onClick={() => {
|
|
onJumpMember({
|
|
parentSessionId: run.originSessionId,
|
|
childSessionId: member.childId,
|
|
mode: 'one-shot',
|
|
})
|
|
}}
|
|
>
|
|
{body}
|
|
</Button>
|
|
)
|
|
})}
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|