From ee8f1d8dabf08bd2bb63667d0f578c0e7cc1708b Mon Sep 17 00:00:00 2001 From: Dudu-0223 Date: Sat, 7 Nov 2026 12:24:27 +0800 Subject: [PATCH] fix(ui-subagent): prepare child catalogs on retry --- apps/web/tests/subagent-conversation.e2e.ts | 11 ++++++++++- packages/client/ui-subagent/README.i18n.yaml | 4 ++-- packages/client/ui-subagent/README.md | 2 +- packages/client/ui-subagent/README.zh.md | 2 +- .../ui-subagent/src/client/SubagentHeaderLineage.tsx | 6 +++--- .../ui-subagent/tests/conversation-ui.client.spec.tsx | 6 ++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/web/tests/subagent-conversation.e2e.ts b/apps/web/tests/subagent-conversation.e2e.ts index 71993bbe52..018f5e3f18 100644 --- a/apps/web/tests/subagent-conversation.e2e.ts +++ b/apps/web/tests/subagent-conversation.e2e.ts @@ -365,7 +365,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = if (failures.length > 1) throw new AggregateError(failures, 'subagent Web teardown failed') }) - it('discovers cold descendants one level at a time without leaving the parent conversation', async () => { + it('retries a failed cold catalog and discovers descendants without reopening the menu', async () => { onTestFailed(() => saveFailureShot(page, 'web-e2e-subagent-unread-catalog')) const reads = apiCalls.filter(path => path === '/api/session/projections').length const observe = vi.spyOn(scaffold.ctx.sessionQuery, 'observeSession') @@ -383,7 +383,15 @@ describe('web e2e: persisted subagent conversation and human continuation', () = expect(apiCalls.filter(path => path === '/api/session/projections')).toHaveLength(reads) expect(observe).not.toHaveBeenCalled() const parentUrl = page.url() + await page.route('**/api/session/projections', route => route.abort('failed'), { times: 1 }) await trigger.click() + const retry = tree.getByRole('button', { name: 'Retry', exact: true }) + await retry.waitFor() + expect(await tree.getByRole('button', { name: /^(Expand|Collapse) /u }).count()).toBe(0) + expect(apiCalls.filter(path => path === '/api/session/projections')).toHaveLength(reads + 1) + expect(projections).not.toHaveBeenCalled() + await retry.click() + await retry.waitFor({ state: 'detached' }) const expand = page.getByRole('button', { name: `Expand ${LABEL} descendants`, exact: true }) await expand.waitFor() await expect.poll(() => projections.mock.calls.map(([request]) => request.sessionId)).toEqual([parentId, childId, oneShotId]) @@ -408,6 +416,7 @@ describe('web e2e: persisted subagent conversation and human continuation', () = await page.keyboard.press('Escape') await page.locator('[data-subagent-panel]').waitFor({ state: 'detached' }) } finally { + await page.unroute('**/api/session/projections') observe.mockRestore() projections.mockRestore() } diff --git a/packages/client/ui-subagent/README.i18n.yaml b/packages/client/ui-subagent/README.i18n.yaml index ae80fd109c..e4ce63e820 100644 --- a/packages/client/ui-subagent/README.i18n.yaml +++ b/packages/client/ui-subagent/README.i18n.yaml @@ -30,8 +30,8 @@ en: c158f12dcaed87b7 zh: e5d315e7b1fb4fa9 /deepseek-ai-dsh-client-ui-subagent/understand-the-implementation/catalog-derivation: - en: c7a6ed23ce7ec331 - zh: 92b60359a490b270 + en: 08735d4cc7569cfa + zh: 517309ca6a540adf /deepseek-ai-dsh-client-ui-subagent/understand-the-implementation/duration-completion-and-tokens: en: dcbc58d4cad47fa8 zh: e962a8cbdfd4a914 diff --git a/packages/client/ui-subagent/README.md b/packages/client/ui-subagent/README.md index 325dde5777..357453d99e 100644 --- a/packages/client/ui-subagent/README.md +++ b/packages/client/ui-subagent/README.md @@ -65,7 +65,7 @@ The header lineage renderer reads `subagentCatalog` only from `projectionsBySess Each header entry declares a footer slot below its tree. Optional UI contributes there within the same scroll container; the catalog owns opening and dismissal. CSS anchors keep the panel attached to its trigger within layout-viewport size limits. Browser zoom and panning move it with the page, so it may extend beyond the visual viewport. Internal scrolling, hover behavior, pinned opening, and focus restoration remain independent. -Explicit menu activation and branch expansion call `prepareCatalog` to read the current catalog and its direct children. Ancestor-title clicks navigate to that Session. Failed-read retry buttons call `refreshProjection`; the Session object layer deduplicates reads and refreshes previously requested projections after reconnect. +Explicit menu activation, branch expansion, and failed-read retries call `prepareCatalog` to read the current catalog and its direct children. Ancestor-title clicks navigate to that Session. The Session object layer deduplicates reads and refreshes previously requested projections after reconnect. Breadcrumb addresses derive from the Provider-bound Session address, loaded parent catalogs, or already-listed subagent lineage, including never-selected ancestors. diff --git a/packages/client/ui-subagent/README.zh.md b/packages/client/ui-subagent/README.zh.md index fea6f5d76c..5498652e1b 100644 --- a/packages/client/ui-subagent/README.zh.md +++ b/packages/client/ui-subagent/README.zh.md @@ -65,7 +65,7 @@ kind: "package-reference" 每个页头入口在树下方声明 footer 插槽。可选 UI 通过该插槽加入同一滚动容器;目录负责打开和关闭。CSS 锚点让面板跟随触发器,并按布局视口限制尺寸。浏览器缩放和平移时面板随页面移动,因此可以超出视觉视口。内部滚动、悬停行为、点击固定展开和焦点恢复保持独立。 -显式激活菜单或展开分支时,`prepareCatalog` 读取当前目录及其直接子节点。点击祖先标题会导航到该 Session。失败读取的重试按钮调用 `refreshProjection`;Session 对象层合并重复读取,并在重连后刷新之前请求过的投影。 +显式激活菜单、展开分支或重试失败读取时,`prepareCatalog` 读取当前目录及其直接子节点。点击祖先标题会导航到该 Session。Session 对象层合并重复读取,并在重连后刷新之前请求过的投影。 面包屑地址从 Provider 所绑定的 Session 地址、已加载的 parent 目录或已列出的 subagent 谱系推导,也包括从未选中过的祖先。 diff --git a/packages/client/ui-subagent/src/client/SubagentHeaderLineage.tsx b/packages/client/ui-subagent/src/client/SubagentHeaderLineage.tsx index ab2b6e6a4b..cffac90f99 100644 --- a/packages/client/ui-subagent/src/client/SubagentHeaderLineage.tsx +++ b/packages/client/ui-subagent/src/client/SubagentHeaderLineage.tsx @@ -29,7 +29,7 @@ export type SubagentCatalogInjected = { openChild: (address: SubagentAddress) => void openChildAside: (address: SubagentAddress) => void refreshProjection: (parentSessionId: SessionId) => void - /** Read this catalog and its direct children after explicit activation. */ + /** Read this catalog and its direct children after explicit activation or retry. */ prepareCatalog: (parentSessionId: SessionId) => Promise } @@ -498,7 +498,7 @@ type CatalogDropdownProps = CatalogDropdownSharedProps & ( function CatalogDropdown(props: CatalogDropdownProps) { const { rootSessionId, currentSessionId, displayTitle, openTitle, variant, - useSessions, useSessionStatus, openChild, openChildAside, refreshProjection, prepareCatalog, t, hasSharedTasks = false, + useSessions, useSessionStatus, openChild, openChildAside, prepareCatalog, t, hasSharedTasks = false, } = props const ancestorSwitcher = variant === 'switcher' && openTitle !== undefined const projections = useSessions(state => state.projectionsBySession) @@ -812,7 +812,7 @@ function CatalogDropdown(props: CatalogDropdownProps) { level={1} openChild={openChild} openChildAside={openChildAside} - refreshProjection={refreshProjection} + refreshProjection={prepareLevel} toggleBranch={toggleBranch} closeCatalog={() => { changeOpen(false) }} t={t} 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 ea189bcd8e..e3234cfef1 100644 --- a/packages/client/ui-subagent/tests/conversation-ui.client.spec.tsx +++ b/packages/client/ui-subagent/tests/conversation-ui.client.spec.tsx @@ -1297,7 +1297,8 @@ describe('SubagentHeaderLineage', () => { expect(screen.queryByRole('status')).toBeNull() expect(input.refreshProjection).not.toHaveBeenCalled() fireEvent.click(screen.getByRole('button', { name: '重试' })) - expect(input.refreshProjection).toHaveBeenCalledExactlyOnceWith(CHILD) + expect(input.prepareCatalog.mock.calls).toEqual([[PARENT], [CHILD]]) + expect(input.refreshProjection).not.toHaveBeenCalled() expect(input.openChild).not.toHaveBeenCalled() state = { ...state, projectionsBySession: { ...state.projectionsBySession, [CHILD]: { state: 'ready', values: { subagentCatalog: [] }, error: null }, @@ -1638,7 +1639,8 @@ describe('SubagentHeaderLineage', () => { hoverCatalog(screen.getByRole('button', { name: /0 个子智能体/ })) expect(screen.getByText('index down')).toBeTruthy() fireEvent.click(screen.getByRole('button', { name: /重试/ })) - expect(failed.refreshProjection).toHaveBeenCalledWith(PARENT) + expect(failed.prepareCatalog).toHaveBeenCalledExactlyOnceWith(PARENT) + expect(failed.refreshProjection).not.toHaveBeenCalled() }) it.each(['absent', 'idle', 'loading', 'ready'] as const)('does not expose header-only descendants when the projection read is %s', (state) => {