Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ feature-scoped token family:

### Agent avatars

All subagent surfaces (status capsule, conversation spawn row and Agent card icon, Agents
All subagent surfaces (status capsule, conversation subagent rows, spawn row and Agent card icon, Agents
section rows, subagent directory, side-pane detail header) share one avatar: the code-drawn
tile face (`WorkflowAgentFace`). Spec: [multi-agent display](docs/desktop/multi-agent-display-spec.md).

Expand All @@ -188,8 +188,8 @@ tile face (`WorkflowAgentFace`). Spec: [multi-agent display](docs/desktop/multi-
- **Sizes**: 16px in conversation rows and panel rows, 20px in the capsule stack and directory,
24px in the detail header. The workflow timeline keeps its own 20px minimum.
- **Stacks** overlap by 6px, at most three faces, separated by a ring in the host surface colour.
- **Motion**: idle face motion only in the detail header while running; still elsewhere; none
under `prefers-reduced-motion`, hidden tabs or off-screen.
- **Motion**: idle face motion in the detail header and in conversation subagent rows while
running; still elsewhere; none under `prefers-reduced-motion`, hidden tabs or off-screen.
- Per-type colours in `lib/subagentColors.ts` colour the agent type label text only, never avatars.
- A compile-feedback row (a script that did not compile, so nothing ran) uses a hollow lamp:
`--color-warning` while it is the latest draft, `--color-foreground-subtlest` once a newer
Expand Down
168 changes: 94 additions & 74 deletions docs/desktop/multi-agent-display-spec.md

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions docs/subagent-session-directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ Subagent directory(桌面 / 普通 Web)
stop/cancel 控件。
- live completion 由 V4 投影把同一项移出 running 并更新 `endedTotal`;目录随后按 ended-only
查询把该项合并到顶部,但保留已加载页面和滚动位置。
- 目录 tab 稳定身份为
`subagent-directory:{workspaceKey}:{rootSessionId}:{parentSessionId}`;child tab 为
`subagent-session:{workspaceKey}:{rootSessionId}:{childSessionId}`。
- 点击目录项复用统一 child 详情打开请求。同一 root 内重复点击复用;原 Session 与 fork
root 不同,因此可以各自持有指向同一历史 child 的 tab。
- edit/retry 使 child 失效时自动关闭对应详情 tab,不进入“最近关闭”;若当前激活的是该 tab,
优先回到已打开的目录,否则回到前一个可见 tab。compact 不关闭 tab。
- 1.4 起目录 tab 即唯一"子智能体"Tab,稳定身份为 `subagent-directory:{workspaceKey}:{rootSessionId}`
(按 workspace + root 查找,兼容旧的带 `parentSessionId` 后缀的 id);Tab 上的可选
`childSessionId` / `subagentType` / `title` 表示当前详情视图,缺席即目录视图。不再新建
`subagent-session:{workspaceKey}:{rootSessionId}:{childSessionId}` tab。
- 点击目录项复用统一 child 详情打开请求,在同一 Tab 内切到详情;详情左上角返回箭头回到目录。
原 Session 与 fork root 不同,因此各自持有一个"子智能体"Tab。
- edit/retry 使 child 失效时:"子智能体"Tab 若正显示该 child,清除选择回到目录(不关闭 Tab);
旧 `subagent-session` tab 仍自动关闭,不进入“最近关闭”,激活项优先回到目录。compact 不关闭 tab。
- 目录 tab 和 child tabs 都只保存在 renderer 内存,不跨刷新恢复。

## 多端边界

- 桌面端与普通 Web 提供目录及分页。
- 手机 `/remote` 不提供目录;Agent/Task 和 Running 行仍可在现有右侧抽屉打开 child 详情。
- 手机 `/remote` 在现有右侧抽屉中打开同一"子智能体"Tab 的详情;1.4 起可经返回箭头进入目录
(运行中分区来自投影;已结束分页不可用时显示既有"无法加载"提示)。输入区与状态面板的目录入口仍不在手机显示。
- 桌面继续使用 `desktop-continuous`,手机继续使用 `web-remote-replayable`;两端消费同一 V4
`snapshot.subagents`,手机重连仍由既有 snapshot/gap 恢复。ended-only 查询通过当前 trusted host
attachment 到同一 CLI/runtime,不在 relay、desktop main 或 Host 增加状态。
Expand Down
14 changes: 8 additions & 6 deletions docs/subagent-session-side-tabs.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Subagent Session Side Tabs

> **1.4 更新(单一"子智能体"Tab)**:右侧不再为每个 `childSessionId` 新开 tab。每个 root 会话只有一个"子智能体"Tab(`subagent-directory`),默认显示目录,打开某个子智能体即在同一 Tab 内切到其详情,左上角返回箭头回到目录。下文"每个 child 一个 tab"的稳定身份、关闭/最近关闭等规则只适用于升级前已存在的旧 `subagent-session` tab;新入口(摘要行、成员行、Running 行、目录项、嵌套 Agent 卡)全部走 `openSubagentSessionSidePane` 写入该 Tab 的选择字段,同 root 的旧 child tab 在下一次打开时并入并关闭。权威规则见 [多智能体展示规范](./desktop/multi-agent-display-spec.md)「右侧"子智能体"Tab」。

UX08:输入区活动汇总全部结束后自动退场,仅影响该入口渲染;已打开的只读 child tab 继续由既有 Side Pane owner 管理,不关闭、不取消。成功卡通过原有 onOpenSubagentSession 查看结果,复用完整 workspaceIdentity/remoteSessionId/root/parent/child 身份,刷新后仍读取持久化子会话。

## 目标
Expand Down Expand Up @@ -203,12 +205,12 @@ Host 使用同一 Agent 的只读 `session/list(sessionIds)` 查询持久化类
每个会话必须与当前 attachment 的 workspace identity 和 cwd 相符;父关系缺失、成环或跨工作区时拒绝。
普通远端主任务仍必须有项目,不按 ID 前缀或旧索引行识别子会话,不补建子会话 task 行,也不扩大目录范围。

| 持久化类型 | 项目解析 | 主列表 | 用户输入 |
| --- | --- | --- | --- |
| `interactive`、`fork`、`workflow_parent` | 自身任务的项目 | 可见 | 保持原有准入 |
| `subagent_child`、`workflow_child` | 校验父链后使用所属主任务项目 | 隐藏 | 只读 |
| `selection_side_chat` | 校验父链后使用所属主任务项目 | 隐藏 | 可聊天,保留辅助对话自己的命令限制 |
| `nested_workflow_child` | 按持久化工作流子会话处理;不新增创建入口 | 隐藏 | 只读 |
| 持久化类型 | 项目解析 | 主列表 | 用户输入 |
| ---------------------------------------- | ---------------------------------------- | ------ | ---------------------------------- |
| `interactive`、`fork`、`workflow_parent` | 自身任务的项目 | 可见 | 保持原有准入 |
| `subagent_child`、`workflow_child` | 校验父链后使用所属主任务项目 | 隐藏 | 只读 |
| `selection_side_chat` | 校验父链后使用所属主任务项目 | 隐藏 | 可聊天,保留辅助对话自己的命令限制 |
| `nested_workflow_child` | 按持久化工作流子会话处理;不新增创建入口 | 隐藏 | 只读 |

2026-10-19 回归:原修复仅识别 `subagent_child`,工作流与辅助对话仍以 child ID 查项目。
项目继承与只读准入分别判断类型,不能用 `parentID` 或同一个只读开关代替;混合父链逐层校验,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,12 @@ describe("后台 Bash 实时输出详情", () => {

// 旧任务由祖先 adapter 持有;必须实际释放 child publisher,再经普通订阅创建新 record。
// 保留输出 tab,但关闭 child conversation 的订阅,让现有 120s grace / 60s tick 自然淘汰。
await browser.execute((sessionId) => {
// 1.4 起 child 详情在该 root 唯一的"子智能体"Tab 内,关闭这个 Tab 即释放 child 订阅。
await browser.execute(() => {
document
.querySelector<HTMLButtonElement>(
`[data-side-pane-tab-id^="subagent-session:"][data-side-pane-tab-id$=":${sessionId}"] button`,
)!
.querySelector<HTMLButtonElement>('[data-side-pane-tab-id^="subagent-directory:"] button')!
.click();
}, childSessionId);
});
const releasedMessage = `release detached live child publisher session=${childSessionId}`;
await browser.waitUntil(async () => (await readAgentLogs()).includes(releasedMessage), {
timeout: 260000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ describe("SendMessage resume Stop", () => {
90000,
);
expect((await waitForToolCallBlockByToolName("SendMessage", 30000)).status).toBe("completed");
expect(await waitForSingleSubagentSummaryChildSessionId(30000)).toBe(
foregroundChildSessionId,
);
expect(await waitForSingleSubagentSummaryChildSessionId(30000)).toBe(foregroundChildSessionId);

await openV4RunningBackgroundWorks(90000);
const runningWork = await waitForSingleRunningBackgroundWork(30000);
Expand Down Expand Up @@ -146,9 +144,7 @@ async function readForegroundAgentId(runMarker: string): Promise<string> {
if (!capturePath) {
throw new Error("E2E_PROVIDER_CAPTURE_PATH 未配置,无法读取 foreground agentId");
}
const artifact = JSON.parse(
await readFile(capturePath, "utf8"),
) as E2ENetworkCaptureArtifact;
const artifact = JSON.parse(await readFile(capturePath, "utf8")) as E2ENetworkCaptureArtifact;
for (const record of artifact.records) {
const requestText = JSON.stringify(record.requestJson ?? null);
if (!requestText.includes(runMarker) || !requestText.includes(FOREGROUND_DONE)) continue;
Expand Down Expand Up @@ -248,6 +244,9 @@ async function readStatusPanelRunningAgentCount(): Promise<number> {

async function countVisibleSubagentTabs(): Promise<number> {
return browser.execute(
() => document.querySelectorAll('[data-side-pane-tab-id^="subagent-session:"]').length,
() =>
document.querySelectorAll(
'[data-side-pane-tab-id^="subagent-session:"], [data-side-pane-tab-id^="subagent-directory:"]',
).length,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ async function openSubagentSidePane(parentAgentToolCallId: string): Promise<void
(expectedChildSessionId) =>
Boolean(
document.querySelector(
'[data-side-pane-tab-id^="subagent-session:"][data-state="active"]',
'[data-side-pane-tab-id^="subagent-directory:"][data-state="active"]',
),
) &&
Array.from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,15 @@ describe("外部引擎原生子智能体(Codex AIR / Claude RFD)", () => {
`${paneSelector} [data-testid^="chat-assistant-history-trigger-"]`,
);
if ((await history.getAttribute("data-history-open")) === "false") await history.click();
const toggle = await displayed(
`${paneSelector} [data-testid^="v4-subagent-work-card-toggle-"]`,
);
if ((await toggle.getAttribute("aria-expanded")) === "false") await toggle.click();
const member = await displayed(`[data-testid="v4-subagent-open-side-pane-${childId}"]`);
await member.scrollIntoView({ block: "center" });
await member.waitForClickable({ timeout: 30000 });
await browser.waitUntil(async () => (await member.getText()).includes(finalText), {
// 1.4:成功行只显示"已完成",最终正文在右侧详情中查看。
await browser.waitUntil(async () => (await member.getText()).includes("已完成"), {
timeout: 30000,
timeoutMsg: "父成员行没有投影同一最终摘要",
timeoutMsg: "父成员行没有投影已完成",
});
expect(await member.getText()).toContain(`结果:${finalText}`);
expect(await member.getText()).not.toContain("原因:");
expect(await member.getText()).toContain("查看结果");
await member.click();
const child = await displayed(`[data-session-id="${childId}"]`);
await browser.waitUntil(async () => (await child.getText()).includes(finalText), {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
TID_CHAT_SUMMARY_RUNNING_AGENTS,
TID_V4_SUBAGENT_DIRECTORY,
TID_V4_SUBAGENT_DIRECTORY_ITEM,
TID_V4_SUBAGENT_OPEN_SIDE_PANE,
TID_V4_SUBAGENT_SESSION_BACK,
TID_V4_SUBAGENT_SESSION_HEADER,
TID_V4_SUBAGENT_WORK_CARD,
} from "@zcode/shared/test-ids";
Expand All @@ -11,8 +14,9 @@ import {
waitForV4Pane,
} from "../../../helpers/v4-conversation.js";

// MA01-MA04(docs/desktop/multi-agent-display-spec.md「验收场景」):同一轮并行 7 个 child,
// 时间线合并为一张 Subagent 工作卡(1.3 W8),胶囊显示 3 个头像与运行数,点击成员行打开带头部的右侧只读详情。
// MA01-MA04、MA16(docs/desktop/multi-agent-display-spec.md「验收场景」):同一轮并行 7 个 child,
// 时间线为连续 7 行子智能体行(1.4,无工作卡外框),胶囊显示 3 个头像与运行数;点击行打开右侧唯一
// "子智能体"Tab 并进入详情,切换另一行仍是同一个 Tab,返回箭头回到目录,目录项再次进入详情。
const TIMEOUT_MS = 180000;
const CHILD_COUNT = 7;
const PARENT_MARKER = "E2E_MULTI_AGENT_DISPLAY_PARENT";
Expand All @@ -28,6 +32,47 @@ interface SpawnRowState {
capsuleText: string;
}

interface SubagentTabState {
directoryTabs: number;
legacyChildTabs: number;
activeDirectoryTab: boolean;
}

async function readSubagentTabState(): Promise<SubagentTabState> {
return browser.execute(() => ({
directoryTabs: document.querySelectorAll('[data-side-pane-tab-id^="subagent-directory:"]')
.length,
legacyChildTabs: document.querySelectorAll('[data-side-pane-tab-id^="subagent-session:"]')
.length,
activeDirectoryTab: Boolean(
document.querySelector('[data-side-pane-tab-id^="subagent-directory:"][data-state="active"]'),
),
}));
}

async function readRowLayout() {
return browser.execute((groupPrefix) => {
const group = document.querySelector<HTMLElement>(
`[data-testid^="${groupPrefix}-"][data-member-count]`,
);
const style = group ? getComputedStyle(group) : null;
return {
tag: group?.tagName ?? "",
rows: group?.querySelectorAll(":scope > li").length ?? 0,
borderTopWidth: style?.borderTopWidth ?? "",
text: group?.textContent ?? "",
};
}, TID_V4_SUBAGENT_WORK_CARD);
}

async function waitForHeader(childSessionId: string, message: string) {
const header = await $(
`[data-testid="${TID_V4_SUBAGENT_SESSION_HEADER}"][data-child-session-id="${childSessionId}"]`,
);
await header.waitForDisplayed({ timeout: 15000, timeoutMsg: message });
return header;
}

async function readSpawnRowState(): Promise<SpawnRowState> {
return browser.execute(
(groupPrefix, openPrefix, capsuleTestId) => {
Expand Down Expand Up @@ -104,8 +149,19 @@ describe("多智能体展示 manual review", () => {
expect(live.capsuleFaces).toBe(3);
expect(live.capsuleText).toContain(String(CHILD_COUNT));

// 每个 child 只有一个直开入口(工作卡成员行)。
// 每个 child 只有一个直开入口(子智能体行)。
expect((await readSpawnRowState()).openActions).toBe(CHILD_COUNT);
// 1.4:连续 7 行,没有工作卡外框、标题或主 Agent 节点;运行中行带"运行中"。
const rowLayout = await readRowLayout();
expect(rowLayout).toMatchObject({ tag: "UL", rows: CHILD_COUNT, borderTopWidth: "0px" });
expect(rowLayout.text).not.toContain("Subagent 正在工作");
expect(rowLayout.text).not.toContain("主 Agent");
expect(rowLayout.text).toContain("运行中");
expect(await readSubagentTabState()).toEqual({
directoryTabs: 0,
legacyChildTabs: 0,
activeDirectoryTab: false,
});

const firstName = await $(`[data-testid^="${TID_V4_SUBAGENT_OPEN_SIDE_PANE}-"]`);
const childTestId = (await firstName.getAttribute("data-testid")) ?? "";
Expand All @@ -118,6 +174,51 @@ describe("多智能体展示 manual review", () => {
expect(await header.getAttribute("data-status")).toBe("running");
expect(await header.getAttribute("data-face-variant")).toBe("antenna");
expect(await header.getText()).toContain("E2E display child 01");
expect(await readSubagentTabState()).toEqual({
directoryTabs: 1,
legacyChildTabs: 0,
activeDirectoryTab: true,
});

// MA16:点另一行仍复用同一个"子智能体"Tab,只切换详情。
const members = await $$(`[data-testid^="${TID_V4_SUBAGENT_OPEN_SIDE_PANE}-"]`);
const secondChildId = ((await members[1]!.getAttribute("data-testid")) ?? "").slice(
`${TID_V4_SUBAGENT_OPEN_SIDE_PANE}-`.length,
);
await members[1]!.click();
await waitForHeader(secondChildId, "MA16 点第二行后详情没有切换");
expect(await header.isExisting()).toBe(false);
expect((await readSubagentTabState()).directoryTabs).toBe(1);

// 返回箭头回到目录:运行中 · 7,目录项可再次进入详情。
await $(`[data-testid="${TID_V4_SUBAGENT_SESSION_BACK}"]`).click();
const directory = await $(`[data-testid="${TID_V4_SUBAGENT_DIRECTORY}"]`);
await directory.waitForDisplayed({ timeout: 15000, timeoutMsg: "MA16 返回后没有显示目录" });
await browser.waitUntil(
async () =>
(await directory.$$(`[data-testid^="${TID_V4_SUBAGENT_DIRECTORY_ITEM}-"]`).length) >=
CHILD_COUNT,
{ timeout: 15000, timeoutMsg: "MA16 目录没有列出全部子智能体" },
);
expect(await directory.getText()).toContain(`· ${CHILD_COUNT}`);
const thirdItem = (
await directory.$$(`[data-testid^="${TID_V4_SUBAGENT_DIRECTORY_ITEM}-"]`)
)[2]!;
const thirdChildId = ((await thirdItem.getAttribute("data-testid")) ?? "").slice(
`${TID_V4_SUBAGENT_DIRECTORY_ITEM}-`.length,
);
await thirdItem.click();
await waitForHeader(thirdChildId, "MA16 目录项没有进入详情");
expect((await readSubagentTabState()).directoryTabs).toBe(1);
if (process.env.ZCODE_E2E_ARTIFACT_DIR) {
await browser.saveScreenshot(
`${process.env.ZCODE_E2E_ARTIFACT_DIR}/ma16-single-subagent-tab.png`,
);
}

// 回到第一个 child 继续观察收口。
await firstName.click();
const firstHeader = await waitForHeader(childSessionId, "MA16 回到第一行详情失败");

await waitForV4Pane(
(snapshot) => !snapshot.canStop,
Expand All @@ -128,6 +229,18 @@ describe("多智能体展示 manual review", () => {
timeout: 30000,
timeoutMsg: "MA07 工作卡没有收口为全部完成",
});
expect(await header.getAttribute("data-status")).toBe("done");
await browser.waitUntil(
async () => (await firstHeader.getAttribute("data-status")) === "done",
{ timeout: 30000, timeoutMsg: "MA07 详情头部没有变为已完成" },
);
// 全部成功结束的行组回到「已工作」折叠内(spec「对话行内子智能体行 · 折叠」),展开历史回看。
await $('[data-testid^="chat-assistant-history-trigger-"]').click();
await browser.waitUntil(async () => (await readRowLayout()).rows === CHILD_COUNT, {
timeout: 15000,
timeoutMsg: "MA07 展开历史后没有看到 7 行子智能体行",
});
const endedText = (await readRowLayout()).text;
expect(endedText).toContain("已完成");
expect(endedText).not.toContain("运行中");
});
});
Loading