diff --git a/apps/web/tests/agent-team-panel.e2e.ts b/apps/web/tests/agent-team-panel.e2e.ts index ff20d45178..320151dd1a 100644 --- a/apps/web/tests/agent-team-panel.e2e.ts +++ b/apps/web/tests/agent-team-panel.e2e.ts @@ -349,8 +349,8 @@ describe('web e2e: agent teamwork panel', () => { }))) expect(primaryStyles.map(style => style.fontSize)).toEqual(['13px', '13px']) expect(primaryStyles[1]).toEqual(primaryStyles[0]) - expect(await member.getByText('team-panel-researcher', { exact: true }) - .evaluate(element => getComputedStyle(element).fontSize)).toBe('12px') + // The member's name moves from the row to its hover card. + expect(await member.getByText('team-panel-researcher', { exact: true }).count()).toBe(0) const memberHover = member.locator(':scope > div') for (const target of [member, memberHover]) { expect(await target.evaluate((element) => { @@ -358,7 +358,7 @@ describe('web e2e: agent teamwork panel', () => { return [style.paddingTop, style.paddingBottom] })).toEqual(['4px', '4px']) } - expect(await member.evaluate(element => getComputedStyle(element).minHeight)).toBe('40px') + expect(await member.evaluate(element => getComputedStyle(element).minHeight)).toBe('28px') expect(await member.evaluate((element) => { const style = getComputedStyle(element) return { left: style.paddingLeft, right: style.paddingRight, gap: style.gap } @@ -371,8 +371,8 @@ describe('web e2e: agent teamwork panel', () => { expect(await taskHover.evaluate((element) => { const style = getComputedStyle(element) return [style.paddingTop, style.paddingBottom] - })).toEqual(['5px', '5px']) - expect(await taskHover.evaluate(element => element.getBoundingClientRect().height)).toBe(30) + })).toEqual(['4px', '4px']) + expect(await taskHover.evaluate(element => element.getBoundingClientRect().height)).toBe(28) expect(await taskHover.evaluate((element) => { const style = getComputedStyle(element) return { left: style.paddingLeft, right: style.paddingRight, gap: style.gap, margin: style.margin } @@ -500,27 +500,24 @@ describe('web e2e: agent teamwork panel', () => { } const row = section.getByRole('treeitem', { name: /Researcher/u }) const primary = row.getByText(RESEARCHER_DESCRIPTION, { exact: true }) - const secondary = row.getByText('team-panel-researcher', { exact: true }) expect(await row.getByRole('button').count()).toBe(0) - expect(await primary.evaluate((element) => { - const style = getComputedStyle(element) - return { - tag: element.tagName, clipped: element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight, - whiteSpace: style.whiteSpace, overflowWrap: style.overflowWrap, - } - })).toEqual({ tag: 'SPAN', clipped: false, whiteSpace: 'normal', overflowWrap: 'anywhere' }) - const primaryBounds = await primary.boundingBox() - const secondaryBounds = await secondary.boundingBox() - expect(primaryBounds).not.toBeNull() - expect(secondaryBounds).not.toBeNull() - expect(primaryBounds!.y + primaryBounds!.height).toBeLessThanOrEqual(secondaryBounds!.y) + // The row keeps one line at every width: the description clips, and the name shows in its hover card. + expect(await primary.evaluate(element => ({ tag: element.tagName, whiteSpace: getComputedStyle(element).whiteSpace }))) + .toEqual({ tag: 'SPAN', whiteSpace: 'nowrap' }) + expect(await row.getByText('team-panel-researcher', { exact: true }).count()).toBe(0) + expect(await panel.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true) + await primary.hover() + const card = page.locator('[data-hover-details]') + await card.waitFor() + expect(await card.evaluate(element => [...element.children].slice(0, 2).map(child => child.textContent))) + .toEqual([RESEARCHER_DESCRIPTION, 'Owner: team-panel-researcher']) + expect(await card.evaluate((element) => { + const rect = element.getBoundingClientRect() + return rect.left >= 0 && rect.right <= window.innerWidth + })).toBe(true) const beforeClick = page.url() await primary.click() expect(page.url()).toBe(beforeClick) - expect(await page.getByRole('tooltip', { name: RESEARCHER_DESCRIPTION, exact: true }).count()).toBe(0) - expect(await panel.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true) - expect(await secondary.evaluate(element => element.scrollWidth <= element.clientWidth)).toBe(true) - await secondary.hover() expect(await page.getByRole('tooltip').count()).toBe(0) await tasksHeading.click() expect(await panel.count()).toBe(1) @@ -575,7 +572,7 @@ describe('web e2e: agent teamwork panel', () => { const emptyRow = board.locator(`[data-team-task="${completed.id}"]`) onTestFinished(() => page.setViewportSize(viewport)) // Constrain the panel so closed and expanded task rows both exercise its scrollbar. - await page.setViewportSize({ width: viewport.width, height: 540 }) + await page.setViewportSize({ width: viewport.width, height: 500 }) await showSharedTasksSection(page) await row.waitFor() expect(await board.locator('[data-team-task-details], article').count()).toBe(0) diff --git a/apps/web/tests/expected/subagent-conversation/migration-required-child.expected.md b/apps/web/tests/expected/subagent-conversation/migration-required-child.expected.md index b86fcda5f5..11fe73c666 100644 --- a/apps/web/tests/expected/subagent-conversation/migration-required-child.expected.md +++ b/apps/web/tests/expected/subagent-conversation/migration-required-child.expected.md @@ -2,12 +2,12 @@ - tree "Subagent sessions": - treeitem "historical researcher migration-catalog-child · continuable · not running" [level=1]: - - text: historical researcher migration-catalog-child + - text: historical researcher - button "Open historical researcher in sidebar" # After opening the child - tree "Subagent sessions": - treeitem "historical editor migration-catalog-grandchild · continuable · not running" [level=1]: - - text: historical editor migration-catalog-grandchild + - text: historical editor - button "Open historical editor in sidebar" diff --git a/apps/web/tests/snapshots/agent-team-panel/task.expected.md b/apps/web/tests/snapshots/agent-team-panel/task.expected.md index d4d3c25939..95eaf1e73e 100644 --- a/apps/web/tests/snapshots/agent-team-panel/task.expected.md +++ b/apps/web/tests/snapshots/agent-team-panel/task.expected.md @@ -6,7 +6,7 @@ - heading "Subagents" [level=2] - text: 1 external - tree "Subagent sessions": - - 'treeitem "Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. team-panel-researcher · External task" [disabled] [level=1]': "Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. team-panel-researcher" + - 'treeitem "Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. team-panel-researcher · External task" [disabled] [level=1]': "Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result. Researcher: investigate the construction and verify every bound before reporting the result." - region "Shared tasks": - heading "Shared tasks" [level=2] - text: 1 in progress diff --git a/apps/web/tests/subagent-conversation.e2e.ts b/apps/web/tests/subagent-conversation.e2e.ts index ff94924927..74231d5888 100644 --- a/apps/web/tests/subagent-conversation.e2e.ts +++ b/apps/web/tests/subagent-conversation.e2e.ts @@ -481,37 +481,39 @@ describe('web e2e: persisted subagent conversation and human continuation', () = } }) - it('shows complete descriptions and names without hover at desktop and touch widths', async () => { + it('shows each subagent on one line and its name, state, and measures in a hover card', async () => { onTestFailed(() => saveFailureShot(page, 'web-e2e-subagent-catalog-labels')) - const originalViewport = page.viewportSize()! const originalUrl = page.url() try { - for (const width of [originalViewport.width, 390]) { - await page.setViewportSize({ ...originalViewport, width }) - const panel = await showSubagentsSection(page) - const row = panel.getByRole('treeitem', { name: new RegExp(LABEL) }) - const primary = row.getByText(LABEL, { exact: true }) - const secondary = row.getByText(CHILD_NAME, { exact: true }) - const primaryBounds = await primary.boundingBox() - const secondaryBounds = await secondary.boundingBox() - expect(primaryBounds).not.toBeNull() - expect(secondaryBounds).not.toBeNull() - expect(primaryBounds!.y + primaryBounds!.height).toBeLessThanOrEqual(secondaryBounds!.y) - for (const label of [primary, secondary]) { - expect(await label.evaluate(element => element.scrollWidth <= element.clientWidth - && element.scrollHeight <= element.clientHeight)).toBe(true) - } - expect(await row.getAttribute('aria-label')).toContain(`${LABEL} ${CHILD_NAME} `) - expect(await row.getByRole('button', { name: /description/u }).count()).toBe(0) - await row.getByRole('button', { name: `Expand ${LABEL} descendants`, exact: true }).waitFor() - expect(await row.getByRole('button', { name: `Open ${LABEL} in sidebar`, exact: true }).count()).toBe(1) - expect(page.url()).toBe(originalUrl) - expect(await page.getByRole('tooltip').filter({ hasText: LABEL }).count()).toBe(0) - expect(scaffold.ctx.agents.get(childId)).toBeUndefined() - await dismissSessionPanel(page) - } + const panel = await showSubagentsSection(page) + const row = panel.getByRole('treeitem', { name: new RegExp(LABEL) }) + const primary = row.getByText(LABEL, { exact: true }) + // The row holds one 28px line; the name stays in its accessible name. + expect(await row.evaluate(element => element.getBoundingClientRect().height)).toBe(28) + expect(await primary.evaluate(element => getComputedStyle(element).whiteSpace)).toBe('nowrap') + expect(await row.getByText(CHILD_NAME, { exact: true }).count()).toBe(0) + expect(await row.getAttribute('aria-label')).toContain(`${LABEL} ${CHILD_NAME} `) + expect(await row.getByRole('button', { name: /description/u }).count()).toBe(0) + await row.getByRole('button', { name: `Expand ${LABEL} descendants`, exact: true }).waitFor() + expect(await row.getByRole('button', { name: `Open ${LABEL} in sidebar`, exact: true }).count()).toBe(1) + await primary.hover() + const card = page.locator('[data-hover-details]') + await card.waitFor() + expect(await card.evaluate(element => [...element.children].map(child => child.textContent).slice(0, 3))) + .toEqual([LABEL, `Owner: ${CHILD_NAME}`, 'completed · continuable']) + // The panel sits at the window's end, so the card opens on the row's start side, inside the viewport. + const placement = await card.evaluate((element) => { + const bounds = element.getBoundingClientRect() + const row = document.querySelector('[data-subagents-section] [role="treeitem"]')!.getBoundingClientRect() + return { left: bounds.left >= 0, beforeRow: bounds.right <= row.left } + }) + expect(placement).toEqual({ left: true, beforeRow: true }) + expect(page.url()).toBe(originalUrl) + expect(scaffold.ctx.agents.get(childId)).toBeUndefined() + await page.locator('[data-composer-input]').first().hover() + await card.waitFor({ state: 'detached' }) + await dismissSessionPanel(page) } finally { - await page.setViewportSize(originalViewport) await page.locator('[data-composer-input]').first().hover() } }) @@ -624,7 +626,8 @@ describe('web e2e: persisted subagent conversation and human continuation', () = const dotBounds = dot.getBoundingClientRect() const slot = dot.parentElement!.getBoundingClientRect() const horizontal = getComputedStyle(row, '::before') - const node = row.parentElement! + // The row sits in its hover card's anchor wrapper inside the tree node. + const node = row.closest('[role="group"] > *')! const spine = getComputedStyle(node, '::before') const stroke = Number.parseFloat(horizontal.borderTopWidth) const colorProbe = document.createElement('span') @@ -671,7 +674,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = ) await compareOrRefreshGolden(TREE_EXPECTED, snapshot, MODE) expect(apiCalls.filter(path => path === '/api/session/projections')).toHaveLength(catalogReads) - await page.getByRole('treeitem', { name: new RegExp(NESTED_LABEL) }).getByText(grandchildId, { exact: true }).click() + await page.getByRole('treeitem', { name: new RegExp(NESTED_LABEL) }).getByText(NESTED_LABEL, { exact: true }).click() await page.getByText(NESTED_PROMPT).waitFor() await hierarchy.getByRole('button', { name: `Switch subagent: ${LABEL}`, exact: true }).waitFor() expect(scaffold.ctx.agents.get(childId)).toBeUndefined() @@ -847,7 +850,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = await captureStableAria(page, '[role="tree"][aria-label="Subagent sessions"]', scaffold.workspaceCwd), MODE, ) - await nestedRow.getByText(grandchildId, { exact: true }).click() + await nestedRow.getByText(NESTED_LABEL, { exact: true }).click() await page.getByText(NESTED_PROMPT).waitFor() expect(await page.getByRole('textbox', { name: 'Message or run a task, / commands, @ files or sessions' }).isEnabled()).toBe(true) const hierarchy = page.getByRole('navigation', { name: 'Session hierarchy' }) @@ -868,7 +871,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = .getByRole('treeitem', { name: /Ask a research subagent to/ }) await parentSession.click() await (await showSubagentsSection(page)).getByRole('treeitem', { name: new RegExp(ONE_SHOT_LABEL) }) - .getByText(oneShotId, { exact: true }).click() + .getByText(ONE_SHOT_LABEL, { exact: true }).click() await page.getByText('One-shot tasks do not accept follow-ups; review the full execution record here.').waitFor() expect(scaffold.ctx.agents.get(oneShotId)).toBeUndefined() }) @@ -879,7 +882,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = .getByRole('treeitem', { name: /Ask a research subagent to/ }) .click() await (await showSubagentsSection(page)).getByRole('treeitem', { name: new RegExp(LABEL) }) - .getByText(CHILD_NAME, { exact: true }).click() + .getByText(LABEL, { exact: true }).click() await page.getByRole('textbox', { name: 'Message or run a task, / commands, @ files or sessions' }).waitFor() const forkResponse = page.waitForResponse(response => new URL(response.url()).pathname === '/api/session/fork') @@ -908,7 +911,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = const sessions = page.getByRole('tree', { name: 'Sessions' }) await sessions.getByRole('treeitem', { name: /Ask a research subagent to/ }).click() await (await showSubagentsSection(page)).getByRole('treeitem', { name: new RegExp(LABEL) }) - .getByText(CHILD_NAME, { exact: true }).click() + .getByText(LABEL, { exact: true }).click() await page.locator('[data-composer-input][contenteditable="true"]').first().waitFor() expect(scaffold.ctx.agents.get(childId)).toBeUndefined() @@ -926,7 +929,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = await sessions.getByRole('treeitem', { name: /Ask a research subagent to/ }).click() await sessionPanelToggle(page).press('Enter') await page.locator(SUBAGENTS_SECTION).getByRole('treeitem', { name: new RegExp(LABEL) }) - .getByText(CHILD_NAME, { exact: true }).click() + .getByText(LABEL, { exact: true }).click() const input = page.locator('[data-composer-input][contenteditable="true"]').first() await input.waitFor() const promptResponse = page.waitForResponse(response => @@ -972,7 +975,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = await page.getByRole('button', { name: `Expand ${LABEL} descendants`, exact: true }).click() await page.getByRole('treeitem', { name: new RegExp(NESTED_LABEL) }).waitFor() expect(await rootHeader.textContent()).toBe(progress) - await page.getByRole('treeitem', { name: new RegExp(LABEL) }).getByText(CHILD_NAME, { exact: true }).click() + await page.getByRole('treeitem', { name: new RegExp(LABEL) }).getByText(LABEL, { exact: true }).click() const switcher = page.getByRole('button', { name: `Switch subagent: ${LABEL}`, exact: true }) await switcher.click() const panel = page.locator('[data-subagent-panel]') @@ -1110,7 +1113,7 @@ describe('web e2e: migration-required subagent catalog', () => { expect(observe.mock.calls.some(([id]) => id === childId || id === grandchildId)).toBe(false) expect(projections).not.toHaveBeenCalled() - await childRow.getByText(childId, { exact: true }).click() + await childRow.getByText(childLabel, { exact: true }).click() await page.getByRole('button', { name: `Switch subagent: ${childLabel}`, exact: true }).waitFor() await showSessionPanel(page) const grandchildRow = tree.getByRole('treeitem', { name: new RegExp(grandchildLabel) }) diff --git a/packages/client/ui-agent-team/README.i18n.yaml b/packages/client/ui-agent-team/README.i18n.yaml index e368b00657..c3c977eea7 100644 --- a/packages/client/ui-agent-team/README.i18n.yaml +++ b/packages/client/ui-agent-team/README.i18n.yaml @@ -18,8 +18,8 @@ en: d198b75bb9d239ec zh: 7a40a8a125948dfa /deepseek-ai-dsh-client-ui-agent-team/use-this-package/inspect-the-task-board: - en: 0a5f4d064e4e9863 - zh: 22801b884e8508b2 + en: 49312c9357e23060 + zh: ce1a9b52667977e8 /deepseek-ai-dsh-client-ui-agent-team/understand-the-implementation: en: 44618947bf773a42 zh: b336de11f525ce07 diff --git a/packages/client/ui-agent-team/README.md b/packages/client/ui-agent-team/README.md index a35e984699..ffeaf89a6f 100644 --- a/packages/client/ui-agent-team/README.md +++ b/packages/client/ui-agent-team/README.md @@ -37,7 +37,7 @@ The [Web bundle](../../bundle/web-app/README.md) loads this package by default. Ready pending tasks use idle, blocked pending tasks use warning, in-progress tasks use ongoing, and completed tasks use done. -The panel draws the section title, and the title control (`conversation.session.panel.section.actions`, key `shared-tasks`) shows completed, in-progress, and pending counts, with zero counts omitted and wording and separators matching the input task list. Compact read-only rows show the subject, status, and a chevron, with 13px primary titles; expanded details use 12px text and start at the title's edge. Task rows follow the panel's columns, like subagent rows: the status glyph's center 14px from the row start, titles at 30px, and the chevron's center 14px from the row end. All task details start closed; opening one closes the previous task. Details show only the full description when present, followed by a single-line owner label and owner name in the same color with a 4px gap. Long owner names are ellipsized and reveal their full text in a tooltip only when clipped. Task-text and owner tooltips appear after 500ms of hover. Owners display the task's saved `ownerName`, such as `lead` or `reviewer/checker`, independently of loaded subagent catalogs. A task without `ownerName` displays its `ownerId`; a task without either field displays the localized unowned label. The Session panel scrolls the board; task lists and details have no nested scrolling. Agents mutate tasks through tools; the panel provides no mutation controls. A projection failure appears separately above any retained tasks and remains visible when no tasks exist. +The panel draws the section title, and the title control (`conversation.session.panel.section.actions`, key `shared-tasks`) shows completed, in-progress, and pending counts, with zero counts omitted and wording and separators matching the input task list. Compact read-only rows show the subject, status, and a chevron on one 28px line, with 13px primary titles; expanded details use 12px text and start at the title's edge. Resting the pointer on a collapsed row for 500ms opens a hover card with the full subject, the owner, the description, and the status. Task rows follow the panel's columns, like subagent rows: the status glyph's center 14px from the row start, titles at 30px, and the chevron's center 14px from the row end. All task details start closed; opening one closes the previous task. Details show only the full description when present, followed by a single-line owner label and owner name in the same color with a 4px gap. Long owner names are ellipsized and reveal their full text in a tooltip only when clipped. Owner tooltips appear after 500ms of hover. Owners display the task's saved `ownerName`, such as `lead` or `reviewer/checker`, independently of loaded subagent catalogs. A task without `ownerName` displays its `ownerId`; a task without either field displays the localized unowned label. The Session panel scrolls the board; task lists and details have no nested scrolling. Agents mutate tasks through tools; the panel provides no mutation controls. A projection failure appears separately above any retained tasks and remains visible when no tasks exist. ----- diff --git a/packages/client/ui-agent-team/README.zh.md b/packages/client/ui-agent-team/README.zh.md index 6dff7196b3..494c548184 100644 --- a/packages/client/ui-agent-team/README.zh.md +++ b/packages/client/ui-agent-team/README.zh.md @@ -37,7 +37,7 @@ Chat 隐藏历史 `/team on` 和 `/team off` 记录中尚未完成或执行成 可开始的 pending 任务使用 idle 灰点,被依赖阻塞的 pending 任务使用 warning 橙点,in-progress 任务使用 ongoing loading,completed 任务使用 done 绿点。 -分栏标题由面板绘制,标题控件(`conversation.session.panel.section.actions`,键为 `shared-tasks`)显示已完成、进行中和待处理数量;省略零值,文案和分隔符与输入区任务列表一致。紧凑只读行显示主题、状态和展开箭头,主标题 13px;展开详情使用 12px 文字,并从标题边缘开始。任务行与子智能体行一样遵循面板的列:状态图标中心距行起始 14px,标题从 30px 开始,箭头中心距行末端 14px。所有任务详情初始关闭,打开一项会关闭上一项。详情仅显示完整描述(如有),下方以单行显示负责人标签和负责人名称,两者使用相同颜色,间距为 4px。过长的负责人名称以省略号截断,仅在被截断时通过工具提示显示完整内容。任务文字和负责人的工具提示在悬停 500ms 后显示。负责人显示任务保存的 `ownerName`,例如 `lead` 或 `reviewer/checker`,不依赖已加载的 subagent 目录。缺少 `ownerName` 时显示 `ownerId`;两个字段都没有时显示本地化的无负责人标签。会话面板负责任务板滚动,任务列表与详情不单独滚动。Agent 通过工具修改任务;面板不提供修改控件。投影失败以独立警告显示在保留的任务上方,即使没有任务也保持可见。 +分栏标题由面板绘制,标题控件(`conversation.session.panel.section.actions`,键为 `shared-tasks`)显示已完成、进行中和待处理数量;省略零值,文案和分隔符与输入区任务列表一致。紧凑只读行在 28px 的一行中显示主题、状态和展开箭头,主标题 13px;展开详情使用 12px 文字,并从标题边缘开始。指针在收起的行上停留 500ms 后,悬停卡片显示完整主题、负责人、描述和状态。任务行与子智能体行一样遵循面板的列:状态图标中心距行起始 14px,标题从 30px 开始,箭头中心距行末端 14px。所有任务详情初始关闭,打开一项会关闭上一项。详情仅显示完整描述(如有),下方以单行显示负责人标签和负责人名称,两者使用相同颜色,间距为 4px。过长的负责人名称以省略号截断,仅在被截断时通过工具提示显示完整内容。负责人的工具提示在悬停 500ms 后显示。负责人显示任务保存的 `ownerName`,例如 `lead` 或 `reviewer/checker`,不依赖已加载的 subagent 目录。缺少 `ownerName` 时显示 `ownerId`;两个字段都没有时显示本地化的无负责人标签。会话面板负责任务板滚动,任务列表与详情不单独滚动。Agent 通过工具修改任务;面板不提供修改控件。投影失败以独立警告显示在保留的任务上方,即使没有任务也保持可见。 ----- diff --git a/packages/client/ui-agent-team/src/client/TeamBoard.module.css b/packages/client/ui-agent-team/src/client/TeamBoard.module.css index a40ddffc16..d810d35351 100644 --- a/packages/client/ui-agent-team/src/client/TeamBoard.module.css +++ b/packages/client/ui-agent-team/src/client/TeamBoard.module.css @@ -34,7 +34,8 @@ gap: 8px; width: 100%; min-width: 0; - padding: 5px 6px; + min-height: 28px; + padding: 4px 6px; border: 0; border-radius: var(--dsw-radius-sm); background: transparent; diff --git a/packages/client/ui-agent-team/src/client/TeamBoard.tsx b/packages/client/ui-agent-team/src/client/TeamBoard.tsx index dcb2e92f84..71eb758ab1 100644 --- a/packages/client/ui-agent-team/src/client/TeamBoard.tsx +++ b/packages/client/ui-agent-team/src/client/TeamBoard.tsx @@ -4,7 +4,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session/types' import type { TeamProjection, TeamTaskView, TeamTaskId } from '@deepseek-ai/dsh-agent-team/client' import type {} from '@deepseek-ai/dsh-api-session-controller/client' import { - IconChevronDownOutlineRegular, + HoverCard, HoverCardGroup, HoverDetails, IconChevronDownOutlineRegular, StateDot, Tooltip, type StateDotState, } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' @@ -55,23 +55,37 @@ function TaskRow({ task, rootId, expanded, onToggle, t }: Pick - - - + + + + + {task.subject} + + + )} + content={( + + )} + /> {expanded && (
{task.description &&

{task.description}

} @@ -105,16 +119,19 @@ export function TeamBoard({ sessionId, useProjection, t }: TeamBoardProps) {
{t('failure', { message: team.failure })}
)} {tasks.length > 0 && ( -
    - {tasks.map(task => ( - { setExpandedTaskId(current => current === task.id ? null : task.id) }} - t={t} - /> - ))} -
+ // Moving between rows swaps their hover cards without another dwell. + +
    + {tasks.map(task => ( + { setExpandedTaskId(current => current === task.id ? null : task.id) }} + t={t} + /> + ))} +
+
)}
) diff --git a/packages/client/ui-agent-team/src/client/locales.ts b/packages/client/ui-agent-team/src/client/locales.ts index 04718b046b..1dc6bbae73 100644 --- a/packages/client/ui-agent-team/src/client/locales.ts +++ b/packages/client/ui-agent-team/src/client/locales.ts @@ -30,6 +30,7 @@ export const zh = { tasks: '共享任务', owner: '负责人', unowned: '未分配', + 'hover.owner': '负责人:{name}', blocked: '被依赖阻塞', 'status.pending': '待处理', 'status.in_progress': '进行中', @@ -66,6 +67,7 @@ export const en = { tasks: 'Shared tasks', owner: 'Owner', unowned: 'Unowned', + 'hover.owner': 'Owner: {name}', blocked: 'Blocked by dependencies', 'status.pending': 'Pending', 'status.in_progress': 'In progress', @@ -99,6 +101,7 @@ export const ja = { 'tasks': '共有タスク', 'owner': 'オーナー', 'unowned': 'オーナーなし', + 'hover.owner': '担当:{name}', 'blocked': '依存関係によりブロック中', 'status.pending': '保留中', 'status.in_progress': '進行中', @@ -132,6 +135,7 @@ export const es = { tasks: 'Tareas compartidas', owner: 'propietario', unowned: 'Sin dueño', + 'hover.owner': 'Responsable: {name}', blocked: 'Bloqueado por dependencias', 'status.pending': 'Pendiente', 'status.in_progress': 'En progreso', @@ -165,6 +169,7 @@ export const fr = { tasks: 'Tâches partagées', owner: 'Propriétaire', unowned: 'Sans propriétaire', + 'hover.owner': 'Responsable : {name}', blocked: 'Bloqué par les dépendances', 'status.pending': 'En attente', 'status.in_progress': 'En cours', @@ -198,6 +203,7 @@ export const de = { tasks: 'Geteilte Aufgaben', owner: 'Besitzer', unowned: 'Unbesessen', + 'hover.owner': 'Zuständig: {name}', blocked: 'Blockiert durch Abhängigkeiten', 'status.pending': 'Ausstehend', 'status.in_progress': 'In Bearbeitung', @@ -231,6 +237,7 @@ export const ru = { tasks: 'Общие задачи', owner: 'Владелец', unowned: 'Невладеющий', + 'hover.owner': 'Ответственный: {name}', blocked: 'Заблокировано зависимостями', 'status.pending': 'Ожидается', 'status.in_progress': 'В процессе', @@ -264,6 +271,7 @@ export const pt = { tasks: 'Tarefas compartilhadas', owner: 'Proprietário', unowned: 'Sem dono', + 'hover.owner': 'Responsável: {name}', blocked: 'Bloqueado por dependências', 'status.pending': 'Pendente', 'status.in_progress': 'Em andamento', diff --git a/packages/client/ui-agent-team/tests/team-board.client.spec.tsx b/packages/client/ui-agent-team/tests/team-board.client.spec.tsx index 7b6267bedf..5edde82e37 100644 --- a/packages/client/ui-agent-team/tests/team-board.client.spec.tsx +++ b/packages/client/ui-agent-team/tests/team-board.client.spec.tsx @@ -377,36 +377,28 @@ describe('TeamBoard', () => { expect(ownerValue()).toBeNull() }) - it('delays clipped collapsed subject hover by 500ms while keeping keyboard focus immediate', () => { + it('shows the subject, owner, description, and state in a hover card after 500ms, and none while the row is expanded', () => { vi.useFakeTimers() - enableTooltips() - const view = render() + vi.stubGlobal('matchMedia', vi.fn((query: string) => ({ matches: query === '(any-hover: hover)' }))) + render() const button = row() - const subject = screen.getByText(task.subject) - const scrollWidth = vi.spyOn(Element.prototype, 'scrollWidth', 'get').mockReturnValue(80) - vi.spyOn(Element.prototype, 'clientWidth', 'get').mockReturnValue(80) - fireEvent.pointerEnter(button) - act(() => { vi.advanceTimersByTime(500) }) - expect(screen.queryByRole('tooltip')).toBeNull() - fireEvent.pointerLeave(button) - scrollWidth.mockImplementation(function (this: Element) { return this === subject ? 180 : 80 }) - fireEvent.pointerEnter(button) + const anchor = button.parentElement as HTMLElement + const details = (): string[] | null => { + const card = document.querySelector('[data-hover-details]') + return card === null ? null : [...card.children].map(child => child.textContent ?? '') + } + fireEvent.pointerEnter(anchor, { pointerType: 'mouse' }) act(() => { vi.advanceTimersByTime(499) }) - expect(screen.queryByRole('tooltip')).toBeNull() + expect(details()).toBeNull() act(() => { vi.advanceTimersByTime(1) }) - expect(screen.getByRole('tooltip').textContent).toBe(task.subject) - expect(view.container.contains(screen.getByRole('tooltip'))).toBe(false) + expect(details()).toEqual([task.subject, '负责人:lead', task.description, '进行中']) + // Expanding the row shows the same details in place, so the card closes and stays closed. fireEvent.click(button) - expect(row()).toBe(button) - expect(screen.queryByRole('tooltip')).toBeNull() - fireEvent.pointerLeave(button) - fireEvent.pointerEnter(button) + act(() => { vi.advanceTimersByTime(200) }) + expect(details()).toBeNull() + fireEvent.pointerLeave(anchor, { pointerType: 'mouse' }) + fireEvent.pointerEnter(anchor, { pointerType: 'mouse' }) act(() => { vi.advanceTimersByTime(500) }) - expect(screen.queryByRole('tooltip')).toBeNull() - fireEvent.click(button) - fireEvent.pointerLeave(button) - fireEvent.keyDown(document.body, { key: 'Tab' }) - fireEvent.focus(button) - expect(screen.getByRole('tooltip').textContent).toBe(task.subject) + expect(details()).toBeNull() }) }) diff --git a/packages/client/ui-jobs/README.i18n.yaml b/packages/client/ui-jobs/README.i18n.yaml index fd5f76dd9d..3305911220 100644 --- a/packages/client/ui-jobs/README.i18n.yaml +++ b/packages/client/ui-jobs/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-jobs/use-this-package: - en: 8c559d52a6171f6a - zh: bfbcea232714ca7d + en: 3c7f25a350b5d390 + zh: b4658e8e4ae778d9 /deepseek-ai-dsh-client-ui-jobs/use-this-package/one-row-per-job: en: 2070f740163c524a zh: 2910dea28ce1b8b3 diff --git a/packages/client/ui-jobs/README.md b/packages/client/ui-jobs/README.md index 59d677d6c0..2530c7d3df 100644 --- a/packages/client/ui-jobs/README.md +++ b/packages/client/ui-jobs/README.md @@ -27,7 +27,7 @@ English | [中文](README.zh.md) Load the plugin through the web-app manifest. It registers the [Session panel](../ui-session-panel/README.md#contribute-a-section) section `background-jobs` at order 300, after Subagents, titled “Background jobs”. While jobs run and the panel does not show, a blue dot on the panel toggle (`conversation.session.panel.indicator`) says so and names their number for assistive technology; it keeps the Session's roster stream open while the toggle is mounted. The section renders nothing until the session can see at least one job, so the panel hides it together with its title and an ordinary conversation shows no section for a capability it is not using. -Live rows come first in start order; settled rows follow newest-first under a “Finished {count}” toggle, whose chevron follows the text, with a “Clear” action. The toggle starts folded while a job is live and open otherwise; the user's choice holds for the Session, also after the panel is hidden and shown again. Each row shows the command above the job kind and the status or terminal detail, with the duration and a chevron at its end, in the Session panel's columns; the whole row, chevron included, expands and collapses it. A command the row clips crawls into view while the pointer rests on the row, and the stop control names its action after 500ms of hover. A job that finished with a nonzero exit code shows the warning dot, like a stopped one, and a `failed` job the error dot. The settled list folds while any job is live and opens when only settled jobs remain; pressing the toggle overrides that default. Clear hides the current settled rows in this client while the Session stays open, also after the panel is hidden and shown again; the registry keeps their records, a job that settles later appears normally, and the section hides when no rows remain. +Live rows come first in start order; settled rows follow newest-first under a “Finished {count}” toggle, whose chevron follows the text, with a “Clear” action. The toggle starts folded while a job is live and open otherwise; the user's choice holds for the Session, also after the panel is hidden and shown again. Each row is one 28px line with the command, then the duration, the stop control while the job runs, and a chevron at its end, in the Session panel's columns; the whole row, chevron included, expands and collapses it. A command the row clips crawls into view while the pointer rests on the row, and the stop control names its action after 500ms of hover. Resting the pointer on a row for 500ms opens a hover card with the full command, the job kind, the status or terminal detail, and the duration; assistive technology reads the kind and status as the row's description. A job that finished with a nonzero exit code shows the warning dot, like a stopped one, and a `failed` job the error dot. The settled list folds while any job is live and opens when only settled jobs remain; pressing the toggle overrides that default. Clear hides the current settled rows in this client while the Session stays open, also after the panel is hidden and shown again; the registry keeps their records, a job that settles later appears normally, and the section hides when no rows remain. Pressing an observable row expands its output panel, and pressing it again collapses it; one row expands at a time. Each duration has a tooltip, “Running for {duration}” on live rows and “Took {duration}” on settled rows, and live durations advance once per second while any job is live. diff --git a/packages/client/ui-jobs/README.zh.md b/packages/client/ui-jobs/README.zh.md index d8a0552fdc..a2b88b993f 100644 --- a/packages/client/ui-jobs/README.zh.md +++ b/packages/client/ui-jobs/README.zh.md @@ -27,7 +27,7 @@ kind: "package-reference" 通过 web-app 清单加载本插件。它在 order 300 注册[会话面板](../ui-session-panel/README.zh.md#contribute-a-section)分栏 `background-jobs`,位于「子智能体」之后,标题为「后台任务」。任务运行中且面板未显示时,面板开关上的蓝点(`conversation.session.panel.indicator`)会提示这一状态,并向辅助技术说明数量;开关挂载期间它保持该会话的任务列表订阅。在会话看得到至少一个 job 之前,该分栏不渲染任何东西,面板因此连同标题一起隐藏它,普通对话不会为未使用的能力显示分栏。 -进行中的行按开始顺序排在最前;已结束的行按结束时间从新到旧排在「已结束 {count}」切换按钮之下,箭头紧跟文字,旁边有「清空」操作。有进行中的任务时默认折叠,否则默认展开;用户的选择在 Session 内保持,隐藏后再次显示面板也不变。每行在命令下方显示任务类型和状态或结束详情,行尾是时长和箭头,遵循会话面板的列;点整行(包括箭头)都能展开或收起。命令放不下时,指针停在这一行上会滚动显示全文;停止按钮悬停 500ms 后显示其操作说明。以非 0 退出码结束的任务显示警告色圆点,与被停止的任务相同;`failed` 的任务显示错误色圆点。有任务进行中时已结束列表折叠,只剩已结束任务时展开;按下切换按钮会覆盖该默认状态。「清空」在本客户端中隐藏当前已结束的行,Session 保持打开期间一直有效,隐藏后再次显示面板也不变;注册表保留其记录,之后结束的 job 照常出现,没有剩余行时分栏隐藏。 +进行中的行按开始顺序排在最前;已结束的行按结束时间从新到旧排在「已结束 {count}」切换按钮之下,箭头紧跟文字,旁边有「清空」操作。有进行中的任务时默认折叠,否则默认展开;用户的选择在 Session 内保持,隐藏后再次显示面板也不变。每行只占 28px 一行:命令,行尾依次是时长、运行时的停止按钮和箭头,遵循会话面板的列;点整行(包括箭头)都能展开或收起。命令放不下时,指针停在这一行上会滚动显示全文;停止按钮悬停 500ms 后显示其操作说明。指针在行上停留 500ms 后,悬停卡片显示完整命令、任务类型、状态或结束详情以及时长;辅助技术把任务类型和状态作为该行的描述读出。以非 0 退出码结束的任务显示警告色圆点,与被停止的任务相同;`failed` 的任务显示错误色圆点。有任务进行中时已结束列表折叠,只剩已结束任务时展开;按下切换按钮会覆盖该默认状态。「清空」在本客户端中隐藏当前已结束的行,Session 保持打开期间一直有效,隐藏后再次显示面板也不变;注册表保留其记录,之后结束的 job 照常出现,没有剩余行时分栏隐藏。 按下可观察的行会展开其输出面板,再次按下则收起;同一时间只展开一行。每个时长都带工具提示:进行中的行为「已运行 {duration}」,已结束的行为「耗时 {duration}」;有任务进行中时,进行中的时长每秒更新一次。 diff --git a/packages/client/ui-jobs/src/client/JobsSection.module.css b/packages/client/ui-jobs/src/client/JobsSection.module.css index bf7bdd234f..47e850c2d6 100644 --- a/packages/client/ui-jobs/src/client/JobsSection.module.css +++ b/packages/client/ui-jobs/src/client/JobsSection.module.css @@ -81,13 +81,17 @@ flex-direction: column; } -/* The row button's overlay covers the whole line, so the line highlights as one - row; the stop control sits above the overlay and the chevron reads through it. */ +/* One 28px line per job: the command, its duration, the stop control, and the + chevron; the kind and state show in the row's hover card. The row button's + overlay covers the whole line, so the line highlights as one row; the stop + control sits above the overlay and the chevron reads through it. */ .rowLine { position: relative; display: flex; - align-items: flex-start; + align-items: center; gap: 8px; + min-height: 28px; + box-sizing: border-box; padding: 4px 6px; border-radius: var(--dsw-radius-sm); } @@ -106,7 +110,7 @@ .row { display: flex; flex: 1; - align-items: flex-start; + align-items: center; gap: 8px; min-width: 0; padding: 0; @@ -137,41 +141,21 @@ button.row:focus-visible { flex: none; place-items: center; width: 16px; - height: 18px; -} - -.main { - display: flex; - flex: 1; - flex-direction: column; - min-width: 0; -} - -.label, -.secondary { - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + height: 20px; } .label { + flex: 1; font-size: 13px; - line-height: 18px; -} - -.secondary { - color: var(--dsw-alias-label-tertiary); - font-size: 12px; - line-height: 17px; + line-height: 20px; } .duration { flex: none; color: var(--dsw-alias-label-tertiary); - font-size: 10px; + font-size: 12px; font-variant-numeric: tabular-nums; - line-height: 18px; + line-height: 20px; } /* The trailing column; a row without output keeps it empty so the durations @@ -192,7 +176,8 @@ button.row:focus-visible { transform: rotate(180deg); } -/* Two-press kill: a plain glyph like the row's other trailing icons, with a 24px target. */ +/* Two-press kill: a plain glyph like the row's other trailing icons, with a 24px + target that overhangs the 20px line, so a running row keeps its 28px. */ .stop { position: relative; z-index: 1; @@ -203,7 +188,7 @@ button.row:focus-visible { justify-content: center; min-width: 24px; height: 24px; - margin: 0 -4px; + margin: -2px -4px; padding: 0; border: 0; border-radius: var(--dsw-radius-xs); diff --git a/packages/client/ui-jobs/src/client/JobsSection.tsx b/packages/client/ui-jobs/src/client/JobsSection.tsx index 1d0dd10c54..5adba096cb 100644 --- a/packages/client/ui-jobs/src/client/JobsSection.tsx +++ b/packages/client/ui-jobs/src/client/JobsSection.tsx @@ -1,9 +1,9 @@ -import { useEffect, useMemo, useRef, useState } from 'react' +import { useEffect, useId, useMemo, useRef, useState } from 'react' import type { JobsSnapshot, JobView, ObservedJob } from '@deepseek-ai/dsh-api-job-controller/client' import type { SessionId } from '@deepseek-ai/dsh-session/types' import { - IconChevronDownOutlineRegular, IconStopFillRegular, MarqueeText, StateDot, type StateDotState, TerminalBlock, - type TerminalBlockLabels, Tooltip, useHoverMarquee, + HoverCard, HoverCardGroup, HoverDetails, IconChevronDownOutlineRegular, IconClockOutlineRegular, IconStopFillRegular, MarqueeText, + StateDot, type StateDotState, TerminalBlock, type TerminalBlockLabels, Tooltip, useHoverMarquee, } from '@deepseek-ai/dsh-client-ui-primitives' import type { InjectFace, PropsLocale, PropsRuntime, PropsStore, TranslateNS } from '@deepseek-ai/dsh-client-ui-slots' import type { createJobsSectionStore } from './jobs-store.ts' @@ -205,13 +205,14 @@ function JobItem({ job, view, expanded, now, onToggle, kill, t }: { const duration = formatDuration(elapsed, t) const labelRef = useRef(null) const marquee = useHoverMarquee(labelRef) + const summaryId = useId() + const state = detail ?? status + // The row shows the command alone; the kind and state reach assistive technology here and sighted users in the hover card. const body = ( <> - - {job.label} - {`${job.kind} · ${detail ?? status}`} - + {job.label} + {`${job.kind} · ${state}`} {duration} ) @@ -220,49 +221,68 @@ function JobItem({ job, view, expanded, now, onToggle, kill, t }: { : kill?.state === 'failed' ? t('kill.failed') : t('kill.stop', { label: job.label }) return (
  • - {/* A command its cell clips crawls into view while the pointer rests on the row. */} -
    - {observable - ? ( - - ) - : {body}} - {kill !== undefined - ? ( - - - - ) - : null} - {/* The row button's overlay takes presses here too; a row without output keeps the column empty. */} - -
    + , label: duration }]} + /> + )} + anchor={( + // A command its cell clips crawls into view while the pointer rests on the row. +
    + {observable + ? ( + + ) + : {body}} + {kill !== undefined + ? ( + + + + ) + : null} + {/* The row button's overlay takes presses here too; a row without output keeps the column empty. */} + +
    + )} + /> {expanded && view !== undefined ? (
    @@ -414,29 +434,32 @@ export function JobsSection({ sessionId, useJobs, watchRows, observe, killJob, u ) return ( - // The section's heading names the region; a list name would repeat it. -
      - {liveRows.map(item)} - {settledRows.length > 0 - ? ( -
    • - - -
    • - ) - : null} - {settledExpanded ? settledRows.map(item) : null} -
    + // Moving between rows swaps their hover cards without another dwell. + + {/* The section's heading names the region; a list name would repeat it. */} +
      + {liveRows.map(item)} + {settledRows.length > 0 + ? ( +
    • + + +
    • + ) + : null} + {settledExpanded ? settledRows.map(item) : null} +
    +
    ) } diff --git a/packages/client/ui-jobs/tests/jobs-section.client.spec.tsx b/packages/client/ui-jobs/tests/jobs-section.client.spec.tsx index bb8de85c75..fd38e7a782 100644 --- a/packages/client/ui-jobs/tests/jobs-section.client.spec.tsx +++ b/packages/client/ui-jobs/tests/jobs-section.client.spec.tsx @@ -328,7 +328,7 @@ describe('JobsSection rows', () => { it('keeps the trailing column on a row without output, with no chevron and no row button', () => { const view = render() - const line = view.container.querySelector('li > div') as HTMLElement + const line = view.container.querySelector('[data-job-row]') as HTMLElement expect(within(line).queryByRole('button')).toBeNull() expect(line.lastElementChild?.getAttribute('aria-hidden')).toBe('true') expect(line.lastElementChild?.childElementCount).toBe(0) @@ -539,6 +539,26 @@ it('renders the Russian settled-count copy', () => { }) describe('JobsSection hover', () => { + it('shows the command, kind, state, and duration in a hover card after 500ms, and the kind and state to assistive technology', () => { + vi.useFakeTimers({ now: 1_700_000_010_000 }) + vi.stubGlobal('matchMedia', vi.fn((query: string) => ({ matches: query === '(any-hover: hover)' }))) + try { + const view = render() + const row = view.container.querySelector('[data-job-row]')! + const button = within(row).getByRole('button', { name: zh['row.expandAria'].replace('{label}', 'pnpm run build') }) + expect(document.getElementById(button.getAttribute('aria-describedby') ?? '')?.textContent).toBe('bash · 运行中') + const anchor = row.parentElement as HTMLElement + fireEvent.pointerEnter(anchor, { pointerType: 'mouse' }) + act(() => { vi.advanceTimersByTime(499) }) + expect(document.querySelector('[data-hover-details]')).toBeNull() + act(() => { vi.advanceTimersByTime(1) }) + const card = document.querySelector('[data-hover-details]') as HTMLElement + expect([...card.children].map(child => child.textContent)).toEqual(['pnpm run build', 'bash', '运行中', '10秒']) + } finally { + vi.useRealTimers() + } + }) + it('reveals a clipped command on row hover instead of native titles, and names the stop control after 500ms', () => { vi.useFakeTimers() try { @@ -547,7 +567,7 @@ describe('JobsSection hover', () => { const label = view.container.querySelector('[data-job-label]')! Object.defineProperty(label, 'scrollWidth', { value: 300, configurable: true }) Object.defineProperty(label, 'clientWidth', { value: 200, configurable: true }) - const row = label.closest('li')!.firstElementChild as HTMLElement + const row = label.closest('[data-job-row]')! fireEvent.pointerEnter(row) // The suite's matchMedia answers reduced motion, so the command jumps to its far edge. expect(label.scrollLeft).toBe(100) diff --git a/packages/client/ui-jobs/tests/jobs-styles.client.spec.ts b/packages/client/ui-jobs/tests/jobs-styles.client.spec.ts index 4b1f97a3ff..56ecb7a1a6 100644 --- a/packages/client/ui-jobs/tests/jobs-styles.client.spec.ts +++ b/packages/client/ui-jobs/tests/jobs-styles.client.spec.ts @@ -1,7 +1,8 @@ /** * Job row geometry as CSS text: CSS Modules resolve to class-name maps in the * component suite, so only the stylesheet proves that the chevron leaves its - * presses to the row button, including once the open chevron rotates. + * presses to the row button, including once the open chevron rotates, and that + * a row keeps one 28px line. */ import { readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' @@ -20,4 +21,12 @@ describe('JobsSection.module.css', () => { expect(rule('.chevron')).toMatch(/pointer-events:\s*none/) expect(rule('.chevronOpen')).toMatch(/transform:\s*rotate\(180deg\)/) }) + + it('keeps a job on one 28px line, with the stop target overhanging it', () => { + expect(rule('.rowLine')).toMatch(/min-height:\s*28px/) + expect(rule('.rowLine')).toMatch(/padding:\s*4px 6px/) + expect(rule('.label')).toMatch(/line-height:\s*20px/) + expect(rule('.stop')).toMatch(/height:\s*24px/) + expect(rule('.stop')).toMatch(/margin:\s*-2px -4px/) + }) }) diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index 40142f81f4..f1d666aca5 100644 --- a/packages/client/ui-subagent/README.i18n.yaml +++ b/packages/client/ui-subagent/README.i18n.yaml @@ -18,8 +18,8 @@ en: 49aa081e1dbae290 zh: 1493da9b1ecb49ae /deepseek-ai-dsh-client-ui-subagent/use-this-package/browsing-the-tree: - en: e9690820232037fd - zh: e120395b655c3850 + en: da87d582146106c4 + zh: f640b3a3fcc11209 /deepseek-ai-dsh-client-ui-subagent/use-this-package/continuing-a-conversation: en: e4ec261d3b122eb5 zh: 320bb2efc93dccdc diff --git a/packages/client/ui-subagent/README.md b/packages/client/ui-subagent/README.md index 2f8e131b3f..a3aedb7b7b 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -39,7 +39,7 @@ The switcher title is at most 244px wide, ellipsizes, and is followed by an up-d The sidebar-action tooltip appears after 500ms of hover. Hovering a switcher with a non-touch pointer opens its menu after 150ms; leaving both the switcher and its menu closes it after 120ms. Clicking the current Session's title opens and pins the menu and moves focus into it, and a pinned menu ignores pointer leave; clicking an ancestor's title navigates to that ancestor instead. ArrowDown on a switcher opens its menu and focuses the first row; on an open menu it moves focus into the menu, to the first row once the rows have loaded. An outside press or Escape closes the menu, and Escape returns focus to the switcher when focus was inside the menu. -Rows show the creation description, or an available Session title, above the agent name, which is unique among its siblings. Entries recorded without a name show the Session id in its place. Without either description, the row shows only the name or Session id. Navigation, row identity, and Sidebar addresses always use the Session id. Local rows use compact 4px vertical padding. In the Session panel they follow the panel's columns: the status glyph's center 14px from the row start, titles at 30px, and the sidebar arrow's center 14px from the row end. In switcher menus, their clickable content uses 6px horizontal padding and 7px gaps while retaining the tree's left offset. A decorative trailing check marks the current conversation and is not an action; other local rows retain the sidebar arrow, a 24px target whose glyph darkens on hover without a fill in the panel and in switcher menus alike. Primary titles use 13px text and secondary names use 12px. All rows wrap descriptions and names in full, including on touch screens. Running uses the shared ongoing loader, an inactive child whose latest closed turn completed normally uses the shared success dot, and other inactive children use the shared idle dot. Every row reserves the same status column, 16px in the panel and 14px in switcher menus, centering smaller dots so titles align with the loader state. The trailing column stacks total durable provider usage above active-turn duration. In the tree, Enter or Space opens the focused row, ArrowRight/ArrowLeft expand and collapse branches, and ArrowUp/ArrowDown, Home, and End move between rows. An unlabeled one-shot row falls back to its session id. Only rows with confirmed children show an expansion arrow. Preparing a level reads its catalog and its direct children sequentially through the existing projection reader, which reuses completed reads and merges in-flight requests; it does not recursively discover deeper descendants. Once started, a level read may finish after the panel hides or the menu closes. Missing catalogs show no expansion arrow or unknown marker; shared projection updates reveal confirmed branches while preserving the agent activity marker. Failed reads keep navigation available and offer Retry. +Rows show the creation description, or an available Session title, with the agent name, which is unique among its siblings: in switcher menus the name sits below the title, and in the Session panel each row is one 28px line whose hover card, after 500ms of hover, shows the title, the name as its owner, the activity with the mode, and the token total and exact duration. Entries recorded without a name show the Session id in its place. Without either description, the row shows only the name or Session id. Navigation, row identity, and Sidebar addresses always use the Session id. Local rows use compact 4px vertical padding. In the Session panel they follow the panel's columns: the status glyph's center 14px from the row start, titles at 30px, and the sidebar arrow's center 14px from the row end. In switcher menus, their clickable content uses 6px horizontal padding and 7px gaps while retaining the tree's left offset. A decorative trailing check marks the current conversation and is not an action; other local rows retain the sidebar arrow, a 24px target whose glyph darkens on hover without a fill in the panel and in switcher menus alike. Primary titles use 13px text and secondary names use 12px. Switcher rows wrap descriptions and names in full, including on touch screens; panel titles clip with an ellipsis, and the row's accessible name keeps the name, mode, activity, and measures. Running uses the shared ongoing loader, an inactive child whose latest closed turn completed normally uses the shared success dot, and other inactive children use the shared idle dot. Every row reserves the same status column, 16px in the panel and 14px in switcher menus, centering smaller dots so titles align with the loader state. In switcher menus the trailing column stacks total durable provider usage above active-turn duration; panel rows show only the compact duration, in 12px text. In the tree, Enter or Space opens the focused row, ArrowRight/ArrowLeft expand and collapse branches, and ArrowUp/ArrowDown, Home, and End move between rows. An unlabeled one-shot row falls back to its session id. Only rows with confirmed children show an expansion arrow. Preparing a level reads its catalog and its direct children sequentially through the existing projection reader, which reuses completed reads and merges in-flight requests; it does not recursively discover deeper descendants. Once started, a level read may finish after the panel hides or the menu closes. Missing catalogs show no expansion arrow or unknown marker; shared projection updates reveal confirmed branches while preserving the agent activity marker. Failed reads keep navigation available and offer Retry. ### Continuing a conversation diff --git a/packages/client/ui-subagent/README.zh.md b/packages/client/ui-subagent/README.zh.md index 00b8bcefdb..7516bc8031 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -39,7 +39,7 @@ kind: "package-reference" 侧边栏操作的工具提示在悬停 500ms 后显示。非触摸指针悬停切换器 150ms 后打开其菜单;指针离开切换器和菜单后,经过 120ms 关闭。点击当前 Session 的标题会打开并固定菜单,并将焦点移入菜单,已固定的菜单不因指针离开而关闭;点击祖先标题则导航至该祖先。在切换器上按 ArrowDown 会打开菜单,并将焦点移至首行;菜单已打开时,焦点移入菜单,行加载完成后移至首行。点击外部或按 Escape 可关闭菜单;焦点原本位于菜单内时,Escape 将焦点送回切换器。 -目录行在智能体名称上方显示创建描述,缺少创建描述时使用可用的 Session title;名称在同级子智能体中唯一。没有名称的历史目录项在相同位置显示 Session id。两者均缺少时,该行仅显示名称或 Session id。导航、行身份与 Sidebar 地址始终使用 Session id。本地行使用紧凑的 4px 垂直内边距。在会话面板中,它们遵循面板的列:状态图标中心距行起始 14px,标题从 30px 开始,侧边栏箭头中心距行末端 14px。在切换器菜单中,可点击内容使用 6px 水平内边距和 7px 间距,同时保留树的左侧偏移。当前对话在行尾显示装饰性对勾,该对勾不是操作控件;其他本地行保留侧边栏箭头:点击区域 24px,在面板和切换器菜单中都是悬停时箭头变深、没有底色。主标题使用 13px 文字,次级名称使用 12px。所有行均将描述与名称换行完整展示,包括在触屏上。running 使用共享 ongoing loading,最近一个已结束轮次正常完成的 inactive child 使用共享 success 绿点,其他 inactive child 使用共享 idle 灰点。每行都为状态图标预留相同的列宽(面板中 16px,切换器菜单中 14px),并将较小的圆点居中,使 title 与 loading 状态对齐。尾随列在上行显示提供方的持久化 token 用量总计,在下行显示活跃轮次耗时。在目录树中,Enter 或 Space 打开获得焦点的行,ArrowRight/ArrowLeft 展开和折叠分支,ArrowUp/ArrowDown、Home 与 End 在行间移动。没有 label 的 one-shot 行回退到其会话 id。只有确认存在下级的行才显示展开箭头。准备一层时,通过现有投影读取器依次读取其目录及直接子节点的目录,复用已完成的读取并合并进行中的请求,不递归发现更深层后代。已开始的单层读取可能在面板隐藏或菜单关闭后完成。缺少目录的行不显示展开箭头或未知标记;共享投影更新确认存在下级后显示箭头,并保持 agent 活动状态图标。读取失败时保留导航操作并提供重试。 +目录行显示创建描述(缺少时使用可用的 Session title)和智能体名称,名称在同级子智能体中唯一:切换器菜单中名称位于标题下方;会话面板中每行只占 28px 一行,悬停 500ms 后的悬停卡片显示标题、作为负责人的名称、活动状态与模式,以及 token 总计和精确耗时。没有名称的历史目录项在相同位置显示 Session id。两者均缺少时,该行仅显示名称或 Session id。导航、行身份与 Sidebar 地址始终使用 Session id。本地行使用紧凑的 4px 垂直内边距。在会话面板中,它们遵循面板的列:状态图标中心距行起始 14px,标题从 30px 开始,侧边栏箭头中心距行末端 14px。在切换器菜单中,可点击内容使用 6px 水平内边距和 7px 间距,同时保留树的左侧偏移。当前对话在行尾显示装饰性对勾,该对勾不是操作控件;其他本地行保留侧边栏箭头:点击区域 24px,在面板和切换器菜单中都是悬停时箭头变深、没有底色。主标题使用 13px 文字,次级名称使用 12px。切换器菜单中的行将描述与名称换行完整展示,包括在触屏上;面板中的标题以省略号截断,行的无障碍名称仍包含名称、模式、活动状态与度量。running 使用共享 ongoing loading,最近一个已结束轮次正常完成的 inactive child 使用共享 success 绿点,其他 inactive child 使用共享 idle 灰点。每行都为状态图标预留相同的列宽(面板中 16px,切换器菜单中 14px),并将较小的圆点居中,使 title 与 loading 状态对齐。切换器菜单中,尾随列在上行显示提供方的持久化 token 用量总计,在下行显示活跃轮次耗时;面板中的行只以 12px 文字显示简短耗时。在目录树中,Enter 或 Space 打开获得焦点的行,ArrowRight/ArrowLeft 展开和折叠分支,ArrowUp/ArrowDown、Home 与 End 在行间移动。没有 label 的 one-shot 行回退到其会话 id。只有确认存在下级的行才显示展开箭头。准备一层时,通过现有投影读取器依次读取其目录及直接子节点的目录,复用已完成的读取并合并进行中的请求,不递归发现更深层后代。已开始的单层读取可能在面板隐藏或菜单关闭后完成。缺少目录的行不显示展开箭头或未知标记;共享投影更新确认存在下级后显示箭头,并保持 agent 活动状态图标。读取失败时保留导航操作并提供重试。 ### 续接对话 diff --git a/packages/client/ui-subagent/src/client/SubagentCatalog.module.css b/packages/client/ui-subagent/src/client/SubagentCatalog.module.css index 7377053cf1..86cc042428 100644 --- a/packages/client/ui-subagent/src/client/SubagentCatalog.module.css +++ b/packages/client/ui-subagent/src/client/SubagentCatalog.module.css @@ -154,8 +154,10 @@ min-width: 0; } +/* One 28px line per row: the name clips, and its owner, state, and tokens show in the row's hover card. */ .sectionBody .row { gap: 8px; + min-height: 28px; padding: 4px 6px; } @@ -166,52 +168,64 @@ .sectionBody .rowActivitySlot { width: 16px; - height: 18px; + height: 20px; } .sectionBody .disclosure, .sectionBody .disclosureSpace { width: 16px; - height: 18px; -} - -/* The tree's spine sits on the status column's center. */ -.sectionBody .children { - --branch-anchor-y: 13px; - margin-left: 14px; -} - -.sectionBody .children > .node > .row::before { - width: 9px; -} - -.sectionBody .children > .node > .row:has(> .disclosureSpace)::before { - width: 33px; + height: 20px; } .sectionBody .label { - line-height: 18px; + overflow: hidden; + line-height: 20px; + text-overflow: ellipsis; + white-space: nowrap; } -.sectionBody .metrics { - grid-template-rows: 18px 17px; +.sectionBody .duration { + flex: none; + color: var(--dsw-alias-label-tertiary); + font-size: 12px; + font-variant-numeric: tabular-nums; + line-height: 20px; + white-space: nowrap; } -.sectionBody .metricToken { - line-height: 18px; +/* The tree's spine sits on the status column's center, and leaves a parent row + just below its 6px dot. Each row sits in its hover card's anchor wrapper. */ +.sectionBody .children { + --branch-anchor-y: 14px; + margin-left: 14px; } -.sectionBody .metricDuration { - line-height: 17px; +.sectionBody .children::before { + top: -10px; + height: 10px; } -/* In the panel's columns the arrow's 24px target centers on the trailing column. */ +.sectionBody .children > .node > :first-child > .row::before { + content: ''; + position: absolute; + top: calc(var(--branch-anchor-y) - 0.25px); + left: -3px; + width: 9px; + border-top: 0.5px solid var(--dsw-alias-border-l3); +} + +.sectionBody .children > .node > :first-child > .row:has(> .disclosureSpace)::before { + width: 33px; +} + +/* In the panel's columns the arrow's 24px target centers on the trailing column + and overhangs the 20px line, so the row keeps its 28px. */ .sectionBody .sidebarButton, .sectionBody .sidebarSpace { align-self: center; width: 24px; height: 24px; - margin: 0 -4px; + margin: -2px -4px; } .node { diff --git a/packages/client/ui-subagent/src/client/SubagentCatalog.tsx b/packages/client/ui-subagent/src/client/SubagentCatalog.tsx index a0481934a0..d8af2b4e1b 100644 --- a/packages/client/ui-subagent/src/client/SubagentCatalog.tsx +++ b/packages/client/ui-subagent/src/client/SubagentCatalog.tsx @@ -7,7 +7,8 @@ import type { SessionStatusSnapshot } from '@deepseek-ai/dsh-client-ui-session/c import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client' import type { SessionId } from '@deepseek-ai/dsh-session/types' import { - IconChevronRightOutlineRegular, IconRefreshOutlineRegular, IconCheckOutlineRegular, StateDot, Tooltip, + HoverCard, HoverDetails, IconCheckOutlineRegular, IconChevronRightOutlineRegular, IconClockOutlineRegular, IconDatabaseOutlineRegular, + IconRefreshOutlineRegular, StateDot, Tooltip, } from '@deepseek-ai/dsh-client-ui-primitives' import type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots' import type { NS } from './locales.ts' @@ -45,6 +46,8 @@ interface CatalogRowsProps { refreshProjection: (parentSessionId: SessionId) => void toggleBranch: (childSessionId: SessionId) => void closeCatalog: () => void + /** One-line rows whose name, owner, state, and measures show in a hover card. */ + dense: boolean } /** @@ -218,7 +221,7 @@ function catalogProgress(entries: SubagentCatalogSnapshot['entries'], summaries: /** Render one catalog level and recurse only through explicitly expanded rows. */ function CatalogRows({ parentSessionId, currentSessionId, catalog, catalogs, summaries, expanded, level, - openChild, openChildAside, refreshProjection, toggleBranch, closeCatalog, t, + openChild, openChildAside, refreshProjection, toggleBranch, closeCatalog, dense, t, }: CatalogRowsProps & { t: TranslateNS }) { const [now, setNow] = useState(() => Date.now()) const running = catalog.entries.some(entry => entry.activity === 'running') @@ -292,6 +295,7 @@ function CatalogRows({ const metrics = [tokenMetric, durationMetric?.exact] .filter(value => value !== undefined) .join(' · ') + const dotState = entry.activity === 'running' ? 'ongoing' : completed ? 'done' : 'idle' const open = (): void => { if (external) return @@ -322,44 +326,45 @@ function CatalogRows({ toggleBranch(entry.id) } - return ( -
    -
    value !== '').join(' ')} - {...canExpand ? { 'aria-expanded': isExpanded } : {}} - className={css.row} - onClick={open} - onKeyDown={handleKey} - > - {!canExpand - ? reserveDisclosure && - : ( - + const row = ( +
    value !== '').join(' ')} + {...canExpand ? { 'aria-expanded': isExpanded } : {}} + className={css.row} + onClick={open} + onKeyDown={handleKey} + > + {!canExpand + ? reserveDisclosure && + : ( + + )} +
    + + + + + {primaryLabel} + {!dense && secondaryLabel !== undefined && ( + {secondaryLabel} )} -
    - - - - - {primaryLabel} - {secondaryLabel !== undefined && ( - {secondaryLabel} - )} - - {metrics !== '' && ( + + {dense + ? durationMetric !== undefined && {durationMetric.compact} + : metrics !== '' && ( {tokenMetric !== undefined && {tokenMetric}} {durationMetric !== undefined && ( @@ -367,32 +372,48 @@ function CatalogRows({ )} )} - {isCurrent - ? ( - - - - ) - : external ? : ( - - - - )} -
    + {isCurrent + ? ( + + + + ) + : external ? : ( + + + + )}
    +
    + ) + const details = ( + value !== undefined).join(' · ') }} + facts={[ + ...tokenMetric === undefined ? [] : [{ icon: , label: tokenMetric }], + ...durationMetric === undefined ? [] : [{ icon: , label: durationMetric.exact }], + ]} + /> + ) + + return ( +
    + {dense ? : row} {!isExpanded && !external && !requiresOpening && childCatalog?.state === 'error' && (
    {t('load.error')} @@ -417,6 +438,7 @@ function CatalogRows({ refreshProjection={refreshProjection} toggleBranch={toggleBranch} closeCatalog={closeCatalog} + dense={dense} t={t} />
    @@ -499,6 +521,8 @@ export interface CatalogTreeProps { onOpened: () => void /** Focus the first row on mount, as a keyboard-opened popover does. */ focusFirst?: boolean + /** One-line rows whose name, owner, state, and measures show in a hover card, as the Session panel lists them. */ + dense?: boolean t: TranslateNS } @@ -511,7 +535,7 @@ export interface CatalogTreeProps { */ export function CatalogTree({ rootSessionId, currentSessionId, catalog, catalogs, summaries, - openChild, openChildAside, prepareLevel, onOpened, focusFirst = false, t, + openChild, openChildAside, prepareLevel, onOpened, focusFirst = false, dense = false, t, }: CatalogTreeProps) { const [expanded, setExpanded] = useState>(() => new Set()) const treeRef = useRef(null) @@ -568,6 +592,7 @@ export function CatalogTree({ refreshProjection={prepareLevel} toggleBranch={toggleBranch} closeCatalog={onOpened} + dense={dense} t={t} />
    diff --git a/packages/client/ui-subagent/src/client/SubagentsSection.tsx b/packages/client/ui-subagent/src/client/SubagentsSection.tsx index 217a8dc60b..6bff1d011f 100644 --- a/packages/client/ui-subagent/src/client/SubagentsSection.tsx +++ b/packages/client/ui-subagent/src/client/SubagentsSection.tsx @@ -1,5 +1,6 @@ /** Session panel section listing the current Session's subagents. */ import { useMemo } from 'react' +import { HoverCardGroup } from '@deepseek-ai/dsh-client-ui-primitives' import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' import type { NS } from './locales.ts' import type {} from '@deepseek-ai/dsh-client-ui-session-panel/client' @@ -60,17 +61,21 @@ export function SubagentsSection({ if (catalog === undefined || (catalog.state !== 'error' && catalog.entries.length === 0)) return null return (
    - + {/* Moving between rows swaps their hover cards without another dwell. */} + + +
    ) } diff --git a/packages/client/ui-subagent/src/client/locales.ts b/packages/client/ui-subagent/src/client/locales.ts index ba63537c1b..747962ae15 100644 --- a/packages/client/ui-subagent/src/client/locales.ts +++ b/packages/client/ui-subagent/src/client/locales.ts @@ -24,6 +24,7 @@ export const zh = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': '{value} tok', + 'hover.owner': '负责人:{name}', 'loading.label': '正在加载子智能体…', 'load.idle': '尚未加载子智能体', 'load.error': '无法加载子智能体', @@ -70,6 +71,7 @@ export const en: Record = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': '{value} tok', + 'hover.owner': 'Owner: {name}', 'loading.label': 'Loading subagents…', 'load.idle': 'Subagents not loaded', 'load.error': 'Unable to load subagents', @@ -119,6 +121,7 @@ export const ja = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': '{value} tok', + 'hover.owner': '担当:{name}', 'loading.label': 'サブエージェントを読み込み中…', 'load.idle': 'サブエージェントは未読み込みです', 'load.error': 'サブエージェントを読み込めません', @@ -165,6 +168,7 @@ export const es = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': 'Tok {value}', + 'hover.owner': 'Responsable: {name}', 'loading.label': 'Cargando subagentes…', 'load.idle': 'Subagentes sin cargar', 'load.error': 'No se pueden cargar subagentes', @@ -211,6 +215,7 @@ export const fr = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': 'Jeton {value}', + 'hover.owner': 'Responsable : {name}', 'loading.label': 'Chargement des sous-agents…', 'load.idle': 'Sous-agents non chargés', 'load.error': 'Impossible de charger les sous-agents', @@ -257,6 +262,7 @@ export const de = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': '{value}-Token', + 'hover.owner': 'Zuständig: {name}', 'loading.label': 'Subagenten werden geladen…', 'load.idle': 'Subagenten nicht geladen', 'load.error': 'Subagenten können nicht geladen werden', @@ -303,6 +309,7 @@ export const ru = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': '{value} ток', + 'hover.owner': 'Ответственный: {name}', 'loading.label': 'Загрузка субагентов…', 'load.idle': 'Субагенты не загружены', 'load.error': 'Невозможно загрузить субагенты', @@ -349,6 +356,7 @@ export const pt = { 'tokens.thousand': '{value}K', 'tokens.million': '{value}M', 'tokens.total': '{value} valor', + 'hover.owner': 'Responsável: {name}', 'loading.label': 'Carregando subagentes…', 'load.idle': 'Subagentes não carregados', 'load.error': 'Não foi possível carregar subagentes', diff --git a/packages/client/ui-subagent/tests/conversation-ui.client.spec.tsx b/packages/client/ui-subagent/tests/conversation-ui.client.spec.tsx index 7c19ae93e6..1a606f683c 100644 --- a/packages/client/ui-subagent/tests/conversation-ui.client.spec.tsx +++ b/packages/client/ui-subagent/tests/conversation-ui.client.spec.tsx @@ -172,6 +172,24 @@ function enableTooltips(): void { vi.stubGlobal('matchMedia', vi.fn(() => ({ matches: true }))) } +/** + * Rest the pointer on a Session panel row past the hover card's 500ms dwell and + * read the card's parts in order, then leave it. + * @param row - the row's treeitem. + * @returns the card's lines, or null while no card shows. + */ +async function hoverDetailsOf(row: HTMLElement): Promise { + vi.stubGlobal('matchMedia', vi.fn((query: string) => ({ matches: query === '(any-hover: hover)' }))) + const anchor = row.parentElement as HTMLElement + fireEvent.pointerEnter(anchor, { pointerType: 'mouse' }) + await act(async () => { await vi.advanceTimersByTimeAsync(500) }) + const card = document.querySelector('[data-hover-details]') + const lines = card === null ? null : [...card.children].map(child => child.textContent ?? '') + fireEvent.pointerLeave(anchor, { pointerType: 'mouse' }) + await act(async () => { await vi.advanceTimersByTimeAsync(400) }) + return lines +} + /** * The two surfaces as the real page composes them: the breadcrumb switcher * (child sessions, lineage slot) and the Session panel section listing the @@ -208,7 +226,8 @@ describe('SubagentHeaderLineage', () => { expect(row.getAttribute('aria-label')).toMatch(new RegExp(`^${CHILD}`)) }) - it('shows agent names in place of Session ids while navigation keeps the Session id', () => { + it('shows agent names in place of Session ids while navigation keeps the Session id', async () => { + vi.useFakeTimers() const external = 'external-id' as SessionId const input = props(catalog({ entries: [ @@ -219,9 +238,10 @@ describe('SubagentHeaderLineage', () => { }), {}, { [CHILD]: { ...summary(CHILD, 1), running: true } }) render() const named = screen.getByRole('treeitem', { name: /^Review the diff reviewer/ }) - expect(within(named).getByText('Review the diff').compareDocumentPosition(within(named).getByText('reviewer')) - & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy() + // The panel row shows one line; its hover card names the agent as the owner. + expect(within(named).queryByText('reviewer')).toBeNull() expect(within(named).queryByText(CHILD)).toBeNull() + expect(await hoverDetailsOf(named)).toEqual(['Review the diff', '负责人:reviewer', '正在运行 · 可继续']) const undescribed = screen.getByRole('treeitem', { name: /^checker/ }) expect(within(undescribed).getAllByText('checker')).toHaveLength(1) expect(within(undescribed).queryByText(GRANDCHILD)).toBeNull() @@ -714,7 +734,8 @@ describe('SubagentHeaderLineage', () => { describe('SubagentsSection', () => { - it('shows the description above the Session id and opens the row without a description toggle', () => { + it('shows the description on one line, the Session id in its hover card, and opens the row without a description toggle', async () => { + vi.useFakeTimers() const description = 'Check the construction and all bounds. '.repeat(20).trim() const input = props(catalog({ entries: [{ id: CHILD, mode: 'continuable', label: description, activity: 'running' }], @@ -723,8 +744,8 @@ describe('SubagentsSection', () => { render() const row = screen.getByRole('treeitem', { name: new RegExp(CHILD) }) const primary = within(row).getByText(description) - const id = within(row).getByText(CHILD) - expect(primary.compareDocumentPosition(id) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy() + expect(within(row).queryByText(CHILD)).toBeNull() + expect((await hoverDetailsOf(row))?.slice(0, 2)).toEqual([description, `负责人:${CHILD}`]) expect(row.getAttribute('aria-label')).toMatch(/^Check the construction/) expect(primary.tagName).toBe('SPAN') expect(primary.getAttribute('aria-expanded')).toBeNull() @@ -906,11 +927,9 @@ describe('SubagentsSection', () => { render() const runningRow = screen.getByRole('treeitem', { name: /running.*4\.6K tok · 1分10秒/ }) - const runningMetrics = within(runningRow) - const tokenMetric = runningMetrics.getByText('4.6K tok') - const durationMetric = runningMetrics.getByText('1分10秒') - expect(tokenMetric.parentElement).toBe(durationMetric.parentElement) - expect(tokenMetric.nextElementSibling).toBe(durationMetric) + // The row keeps only the compact duration; the tokens and exact duration show in its hover card. + expect(within(runningRow).queryByText('4.6K tok')).toBeNull() + expect(within(runningRow).getByText('1分10秒')).toBeTruthy() const finishedRow = screen.getByRole('treeitem', { name: /finished.*已完成.*123 tok · 1小时02分03秒/ }) expect(finishedRow.querySelector('[data-state="done"]')).not.toBeNull() const interruptedRow = screen.getByRole('treeitem', { name: /interrupted.*当前未运行.*123M tok · 6秒/ }) @@ -931,6 +950,11 @@ describe('SubagentsSection', () => { expect(screen.getByRole('treeitem', { name: /running.*4\.6K tok · 1分11秒/ })).toBeTruthy() expect(screen.getByRole('treeitem', { name: /finished.*已完成.*123 tok · 1小时02分03秒/ })).toBeTruthy() expect(screen.getByRole('treeitem', { name: /interrupted.*当前未运行.*123M tok · 6秒/ })).toBeTruthy() + // Hovering lets the clock run, so the running row's card is read last. + expect(await hoverDetailsOf(finishedRow)).toEqual(['finished', '负责人:finished', '已完成 · 可继续', '123 tok1小时02分03秒']) + const live = await hoverDetailsOf(screen.getByRole('treeitem', { name: /^running/ })) + expect(live?.slice(0, 3)).toEqual(['running', '负责人:running', '正在运行 · 可继续']) + expect(live?.[3]).toMatch(/^4\.6K tok1分1\d秒$/) }) @@ -1443,6 +1467,37 @@ describe('breadcrumb switcher', () => { expect(document.activeElement).toBe(switcher) }) + it('keeps the two-line rows in the menu, with whichever measures each child has', async () => { + const tokensOnly = 'tokens-only' as SessionId + const durationOnly = 'duration-only' as SessionId + const input = props(catalog({ + entries: [ + { id: CHILD, mode: 'continuable', label: 'worker', name: 'worker-agent', activity: 'inactive' }, + { id: tokensOnly, mode: 'continuable', label: 'tokens', activity: 'inactive' }, + { id: durationOnly, mode: 'continuable', label: 'duration', activity: 'inactive' }, + ], + }), {}, { + [CHILD]: { ...summary(CHILD, 1), parentId: PARENT, origin: 'subagent' }, + [tokensOnly]: { ...summary(tokensOnly, 1), parentId: PARENT, origin: 'subagent', projectionValues: { + tokenUsage: { uncachedInputTokens: 1_200, outputTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, + } }, + [durationOnly]: { ...summary(durationOnly, 1), parentId: PARENT, origin: 'subagent', projectionValues: { + subagentTiming: { settledMs: 3_000 }, + } }, + }) + render() + fireEvent.click(screen.getByRole('button', { name: /^切换子智能体:/ })) + await act(async () => { await Promise.resolve() }) + const menu = within(screen.getByRole('dialog')) + const worker = menu.getByRole('treeitem', { name: /^worker/ }) + expect(within(worker).getByText('worker-agent')).toBeTruthy() + expect(within(worker).queryByText(/tok|秒/)).toBeNull() + const tokens = menu.getByRole('treeitem', { name: /^tokens/ }) + expect([within(tokens).getByText('1.2K tok').nextElementSibling]).toEqual([null]) + const duration = menu.getByRole('treeitem', { name: /^duration/ }) + expect(within(duration).getByText('3秒').previousElementSibling).toBeNull() + }) + it('moves focus into an open menu with ArrowDown once its rows have loaded', () => { const loading = { ...childInput(), ...props(catalog({ entries: [], state: 'loading' }), {}, { [CHILD]: { ...summary(CHILD, 1), parentId: PARENT, origin: 'subagent' as const }, diff --git a/snapshots/web/subagent-conversation/branchless.expected.md b/snapshots/web/subagent-conversation/branchless.expected.md index 7947f31aab..6e5e3369b5 100644 --- a/snapshots/web/subagent-conversation/branchless.expected.md +++ b/snapshots/web/subagent-conversation/branchless.expected.md @@ -1,4 +1,4 @@ - tree "Subagent sessions": - treeitem "example editor recorded-grandchild · continuable · completed 0 tok · {{duration}}" [level=1]: - - text: example editor recorded-grandchild 0 tok {{duration}} + - text: example editor {{duration}} - button "Open example editor in sidebar" diff --git a/snapshots/web/subagent-conversation/disclosures.expected.md b/snapshots/web/subagent-conversation/disclosures.expected.md index fa9997580d..c4a2d440a8 100644 --- a/snapshots/web/subagent-conversation/disclosures.expected.md +++ b/snapshots/web/subagent-conversation/disclosures.expected.md @@ -1,8 +1,8 @@ - tree "Subagent sessions": - treeitem "event-sourcing researcher agent-1 · continuable · completed 7.9K tok · {{duration}}" [level=1]: - button "Expand event-sourcing researcher descendants" - - text: event-sourcing researcher agent-1 7.9K tok {{duration}} + - text: event-sourcing researcher {{duration}} - button "Open event-sourcing researcher in sidebar" - treeitem "event-sourcing reviewer recorded-one-shot · one-shot · completed 0 tok · {{duration}}" [level=1]: - - text: event-sourcing reviewer recorded-one-shot 0 tok ~6mo 12d + - text: event-sourcing reviewer ~6mo 12d - button "Open event-sourcing reviewer in sidebar" diff --git a/snapshots/web/subagent-conversation/tree.expected.md b/snapshots/web/subagent-conversation/tree.expected.md index b1ccd511e5..9c7831f6b8 100644 --- a/snapshots/web/subagent-conversation/tree.expected.md +++ b/snapshots/web/subagent-conversation/tree.expected.md @@ -1,12 +1,12 @@ - tree "Subagent sessions": - treeitem "event-sourcing researcher agent-1 · continuable · completed 7.9K tok · {{duration}}" [expanded] [level=1]: - button "Collapse event-sourcing researcher descendants" - - text: event-sourcing researcher agent-1 7.9K tok {{duration}} + - text: event-sourcing researcher {{duration}} - button "Open event-sourcing researcher in sidebar" - group: - treeitem "example editor recorded-grandchild · continuable · completed 0 tok · {{duration}}" [level=2]: - - text: example editor recorded-grandchild 0 tok {{duration}} + - text: example editor {{duration}} - button "Open example editor in sidebar" - treeitem "event-sourcing reviewer recorded-one-shot · one-shot · completed 0 tok · {{duration}}" [level=1]: - - text: event-sourcing reviewer recorded-one-shot 0 tok ~6mo 12d + - text: event-sourcing reviewer ~6mo 12d - button "Open event-sourcing reviewer in sidebar"