refactor(ui): trim team menu guards and align row styling

This commit is contained in:
Yif committed 2026-11-06 22:27:32 +08:00
1 parent 38870162a1
commit de91b109bb
16 files changed
+96 -152

No files matched your search

+28 -2
View File
@@ -134,6 +134,16 @@ describe('web e2e: agent teamwork panel', () => {
const menu = page.getByRole('menu')
const summary = menu.getByRole('menuitem', { name: 'Agent teamwork Off', exact: true })
await summary.waitFor()
const stateColor = await summary.getByText('Off', { exact: true }).evaluate(element => getComputedStyle(element).color)
const modelColor = await menu.getByRole('menuitem', { name: 'Model DeepSeek-V4-Flash', exact: true })
.getByText('DeepSeek-V4-Flash', { exact: true }).evaluate(element => getComputedStyle(element).color)
expect(stateColor).toBe(modelColor)
const inspectArrow = (element: HTMLElement | SVGElement) => {
const { left, right, width, height } = element.getBoundingClientRect()
return { left, right, width, height, color: getComputedStyle(element).color, glyph: element.innerHTML }
}
const peerArrow = menu.getByRole('menuitem', { name: 'Model DeepSeek-V4-Flash', exact: true }).locator('svg').last()
expect(await summary.locator('svg').evaluate(inspectArrow)).toEqual(await peerArrow.evaluate(inspectArrow))
expect(await menu.getByRole('switch').count()).toBe(0)
expect(await page.getByRole('button', { name: 'About agent teamwork', exact: true }).count()).toBe(0)
const rootSnapshot = await captureStableAria(page, '[role="menu"]', scaffold.workspaceCwd)
@@ -147,6 +157,15 @@ describe('web e2e: agent teamwork panel', () => {
await menu.getByText('Coordinate work and progress across agents with a shared task board for better results on complex tasks, with correspondingly higher token costs.', { exact: true }).waitFor()
expect(await page.getByRole('tooltip').count()).toBe(0)
expect(await toggle.getAttribute('aria-checked')).toBe('false')
await page.mouse.move(0, 0)
await toggle.press('ArrowDown')
expect(await toggle.evaluate(element => ({
rowBackground: getComputedStyle(element.parentElement!).backgroundColor,
focusVisible: element.matches(':focus-visible'),
outline: getComputedStyle(element).outlineStyle,
descriptionGap: element.parentElement!.nextElementSibling!.getBoundingClientRect().top
- element.parentElement!.getBoundingClientRect().bottom,
}))).toEqual({ rowBackground: 'rgba(0, 0, 0, 0)', focusVisible: true, outline: 'solid', descriptionGap: 0 })
const settingsSnapshot = await captureStableAria(page, '[role="menu"]', scaffold.workspaceCwd)
await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'info.expected.md'),
`## Root\n\n${rootSnapshot}\n\n## Team settings\n\n${settingsSnapshot}`, MODE)
@@ -208,12 +227,19 @@ describe('web e2e: agent teamwork panel', () => {
&& element.scrollHeight <= element.clientHeight && style.textOverflow !== 'ellipsis'
})).toBe(true)
}
await toggle.click()
const labelBounds = await menu.getByText('Enable agent teamwork', { exact: true }).boundingBox()
if (labelBounds === null) throw new Error('Team label is not visible')
await page.mouse.click(labelBounds.x + labelBounds.width / 2, labelBounds.y + labelBounds.height / 2)
await expect.poll(() => toggle.getAttribute('aria-checked')).toBe('true')
await expect.poll(() => toggle.isEnabled()).toBe(true)
await toggle.press('Escape')
await menu.getByRole('menuitem', { name: 'Agent teamwork On', exact: true }).click()
await toggle.click()
const gap = await toggle.evaluate((element) => {
const control = element.getBoundingClientRect()
const label = element.parentElement!.querySelector('span')!.getBoundingClientRect()
return { x: (label.right + control.left) / 2, y: control.top + control.height / 2 }
})
await page.mouse.click(gap.x, gap.y)
await expect.poll(() => toggle.getAttribute('aria-checked')).toBe('false')
expect(await page.getByRole('tooltip').count()).toBe(0)
expect(tripwire.pageErrors).toEqual([])
@@ -15,8 +15,8 @@
en: d152484eb41ac6b4
zh: 09388d293f9be9cb
/deepseek-ai-dsh-client-ui-agent-team/use-this-package:
en: 4b66566b2e676572
zh: 57e6096591983a3c
en: c5fe6c80b2979db7
zh: 6f4640b369c9d22a
/deepseek-ai-dsh-client-ui-agent-team/use-this-package/inspect-the-task-board:
en: 2f606827b3ab14bc
zh: 7f713d10268e7498
+1 -1
View File
@@ -25,7 +25,7 @@ This package displays shared tasks below the Subagent tree in one header panel.
<a id="use-this-package"></a>
## Use this package
In the root conversation’s model and reasoning menu, select **Agent teamwork** to open its settings page, then turn on **Enable agent teamwork**. The root row shows only the saved On/Off state and opens the page without changing the selection; the settings page places the switch above the full explanation. New Sessions default to off. While enabled, open the root conversation’s Subagent control to see members above shared tasks. Child conversations keep subagent navigation without a task board or Team switch, including before their subagent address is discovered. The entry is hidden when both the subagent catalog and shared tasks are empty; catalog and task-record errors remain accessible. Section headers appear only when Team mode is enabled, at least one nondeleted shared task exists, and the task footer is available. In that case, the noncollapsible Subagents section remains above shared tasks even when its catalog is empty. Otherwise, the menu shows only subagent navigation, without section headers, a shared-task module, empty-state copy, or a divider. Turning it off retains tasks and subagents. The settings page shows the shared-task coordination, complex-task results, and token-cost explanation as ordinary text, without an information tooltip. Its entire switch row highlights on hover and toggles the selection when clicked. The switch calls `remote.agentTeams.setEnabled`, waits for the saved projection and reports failures through the menu host; the row cannot toggle while locked or saving.
In the root conversation’s model and reasoning menu, select **Agent teamwork** to open its settings page, then turn on **Enable agent teamwork**. The root row shows the saved On/Off state without changing it. The settings page shows the switch above the shared-task coordination, complex-task results, and token-cost explanation as ordinary text, without an information tooltip. New Sessions default to off. While enabled, open the root conversation’s Subagent control to see members above shared tasks. Child conversations keep subagent navigation without a task board or Team switch, including before their subagent address is discovered. The entry is hidden when both the subagent catalog and shared tasks are empty; catalog and task-record errors remain accessible. Section headers appear only when Team mode is enabled, at least one nondeleted shared task exists, and the task footer is available. In that case, the noncollapsible Subagents section remains above shared tasks even when its catalog is empty. Otherwise, the menu shows only subagent navigation, without section headers, a shared-task module, empty-state copy, or a divider. Turning it off retains tasks and subagents. The entire switch row highlights on hover and toggles the selection when clicked. The switch calls `remote.agentTeams.setEnabled`, waits for the saved projection and reports failures through the menu host; the row cannot toggle while locked or saving.
Turning off the menu switch requires confirmation after the Session records a model request; a model choice alone does not require it. The switch waits while request history is unavailable. The dialog explains the tool, coordination, and possible cache effects without deleting task records. Cancel, Escape, or closing the dialog leaves Team mode unchanged. Dismissing the dialog returns focus to the model selector. Confirmation targets the originating Session, waits for the save, and keeps failures visible for retry; it does not depend on the model menu remaining open. Team mode has no slash command; menu changes create no `command/run` or `command/done` records.
+1 -1
View File
@@ -25,7 +25,7 @@ kind: "package-reference"
<a id="use-this-package"></a>
## 使用本包
在根会话的模型与推理等级菜单中选择**智能体团队协作**,进入二级设置页后打开**开启智能体团队协作**。一级行只显示已保存的开启/关闭状态,点击仅进入页面,不改变选择;二级页面将开关放在完整说明文字上方。新 Session 默认关闭。开启后,通过根会话的 Subagent 入口同时查看上方的成员树和下方的共享任务。子会话保留子智能体导航,不显示任务板或 Team 开关,包括尚未发现子代理地址时。子智能体目录和共享任务都为空时隐藏入口;目录或任务记录错误仍保留查看入口。仅当 Team 模式已开启、存在至少一个未删除的共享任务且任务 footer 可用时,才显示区域标题。此时即使目录为空,共享任务上方仍保留不可折叠的“子智能体”区域。其他情况下,菜单仅显示 subagent 导航,不显示区域标题、共享任务模块、空状态文案或分隔线。关闭后保留任务和子代理。设置页以普通正文显示共享任务协调、复杂任务效果与 token 开销的说明,不使用信息 tooltip。开关所在整行在悬停时高亮,点击可切换状态。开关调用 `remote.agentTeams.setEnabled`,等待保存后的投影更新,失败由菜单宿主提示;锁定或保存中不能通过整行切换。
在根会话的模型与推理等级菜单中选择**智能体团队协作**,进入二级设置页后打开**开启智能体团队协作**。一级行显示已保存的开启/关闭状态,不改变选择。设置页将开关放在共享任务协调、复杂任务效果与 token 开销的说明上方;说明使用普通正文,不使用信息 tooltip。新 Session 默认关闭。开启后,通过根会话的 Subagent 入口同时查看上方的成员树和下方的共享任务。子会话保留子智能体导航,不显示任务板或 Team 开关,包括尚未发现子代理地址时。子智能体目录和共享任务都为空时隐藏入口;目录或任务记录错误仍保留查看入口。仅当 Team 模式已开启、存在至少一个未删除的共享任务且任务 footer 可用时,才显示区域标题。此时即使目录为空,共享任务上方仍保留不可折叠的“子智能体”区域。其他情况下,菜单仅显示 subagent 导航,不显示区域标题、共享任务模块、空状态文案或分隔线。关闭后保留任务和子代理。开关所在整行在悬停时高亮,点击可切换状态。开关调用 `remote.agentTeams.setEnabled`,等待保存后的投影更新,失败由菜单宿主提示;锁定或保存中不能通过整行切换。
会话记录过模型请求后,从菜单开关关闭团队需要确认;仅选择模型不会触发确认。请求历史尚未加载时,开关暂不可操作。弹窗说明工具、协作与可能的缓存影响,不会删除任务记录。取消、按 Escape 或关闭弹窗都保持团队状态不变。弹窗关闭后,焦点回到模型选择按钮。确认操作绑定到最初的会话,等待保存完成,失败时保留错误供重试,不依赖模型菜单保持打开。Team 模式没有斜杠命令;菜单切换不会生成 `command/run` 或 `command/done` 记录。
@@ -1,11 +1,11 @@
.summary {
display: flex;
align-items: center;
gap: 8px;
gap: 6px;
box-sizing: border-box;
width: 100%;
min-height: 34px;
padding: 7px 8px;
height: 34px;
padding: 0 8px;
border: 0;
border-radius: var(--dsw-radius-md);
background: transparent;
@@ -39,13 +39,22 @@
.state,
.chevron {
flex: none;
color: var(--dsw-alias-label-secondary);
}
.state {
color: var(--dsw-alias-label-tertiary);
}
.chevron {
width: 12px;
height: 12px;
color: var(--dsw-alias-menu-icon);
}
.page {
display: flex;
flex-direction: column;
gap: 4px;
gap: 0;
min-width: 0;
}
@@ -90,10 +99,6 @@
border-radius: var(--dsw-radius-md);
}
.row:has(.toggle:focus-visible) {
background: var(--dsw-alias-interactive-bg-hover);
}
@media (hover: hover) {
.summary:not(:disabled):hover,
.row:has(.toggle:not(:disabled)):hover {
@@ -46,11 +46,11 @@ function RootTeamModeSummary({ useProjection, locked, openPage, t }: TeamModeTog
className={css.summary}
data-model-menu-page="agent-team"
disabled={locked}
onClick={() => { if (!locked) openPage({ key: 'agent-team', title: t('command.title') }) }}
onClick={() => { openPage({ key: 'agent-team', title: t('command.title') }) }}
>
<span className={css.summaryLabel}>{t('command.title')}</span>
<span className={css.state}>{t(mode.enabled ? 'mode.on' : 'mode.off')}</span>
<IconChevronRightOutlineRegular size={14} className={css.chevron} aria-hidden="true" />
<IconChevronRightOutlineRegular className={css.chevron} aria-hidden="true" />
</button>
)
}
@@ -76,8 +76,7 @@ function RootTeamModePage({
const [pending, setPending] = useState(false)
if (mode === undefined) return null
const select = (enabled: boolean): void => {
if (locked || pending || modelSelection === undefined) return
if (!enabled && modelSelection.lastUsed !== null) {
if (!enabled && modelSelection !== undefined && modelSelection.lastUsed !== null) {
dismiss()
requestDisableConfirmation()
return
@@ -1,85 +0,0 @@
// @vitest-environment jsdom
import { isValidElement, type ComponentProps, type FunctionComponent } from 'react'
import { afterEach, expect, it, onTestFinished, vi } from 'vitest'
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import type { Switch } from '@deepseek-ai/dsh-client-ui-primitives'
import { SessionId } from '@deepseek-ai/dsh-session'
import { makeTranslate } from '@deepseek-ai/dsh-client-test-runtime'
import { TeamModePage, TeamModeToggle, type TeamModePageProps, type TeamModeToggleProps } from '../src/client/TeamModeToggle.tsx'
import { zh } from '../src/client/locales.ts'
vi.mock('@deepseek-ai/dsh-client-ui-primitives', async (importOriginal) => {
const actual = await importOriginal<typeof import('@deepseek-ai/dsh-client-ui-primitives')>()
return {
...actual,
// Deliver callbacks even when the native control would suppress activation.
Switch: (props: ComponentProps<typeof Switch>) => (
<button type="button" role="switch" aria-label={props.label} aria-checked={props.checked}
aria-disabled={props.disabled} onClick={() => { props.onChange(!props.checked) }} />
),
}
})
afterEach(cleanup)
type TestProps = TeamModePageProps & TeamModeToggleProps
function props(locked = false, loading = false): TestProps {
return {
sessionId: SessionId('root'),
useSession: (select: (value: { subagent: null }) => unknown) => select({ subagent: null }),
useSessions: (select: (value: { byId: object }) => unknown) => select({ byId: {} }),
useProjection: (key: string) => key === 'modelSelection'
? loading ? undefined : { lastUsed: null, next: { provider: 'mock', model: 'mock' } }
: { enabled: false, tasks: [] },
locked, openPage: vi.fn(), dismiss: vi.fn(), reportFailure: vi.fn(),
selectTeamMode: vi.fn(async () => null), requestDisableConfirmation: vi.fn(),
t: makeTranslate(zh),
} as TestProps
}
it('does not navigate when a locked summary callback is delivered', () => {
const input = props(true)
const root = TeamModeToggle(input)
if (!isValidElement<TeamModeToggleProps>(root) || typeof root.type !== 'function') throw new Error('Expected the root summary component')
// The summary is a pure component; invoke its callback without native disabled-button filtering.
const summary = (root.type as FunctionComponent<TeamModeToggleProps>)(root.props)
if (!isValidElement<{ disabled: boolean; onClick: () => void }>(summary)) throw new Error('Expected the summary button')
expect(summary.props.disabled).toBe(true)
summary.props.onClick()
expect(input.openPage).not.toHaveBeenCalled()
expect(input.selectTeamMode).not.toHaveBeenCalled()
})
it.each([
{ name: 'locked', locked: true, loading: false },
{ name: 'model history loading', locked: false, loading: true },
])('does not save when a settings callback is delivered while $name', ({ locked, loading }) => {
const input = props(locked, loading)
render(<TeamModePage {...input} />)
const toggle = screen.getByRole('switch')
expect(toggle.getAttribute('aria-disabled')).toBe('true')
fireEvent.click(toggle)
expect(input.selectTeamMode).not.toHaveBeenCalled()
expect(input.requestDisableConfirmation).not.toHaveBeenCalled()
expect(input.dismiss).not.toHaveBeenCalled()
expect(toggle.getAttribute('aria-checked')).toBe('false')
})
it('keeps one pending save when the settings callback is delivered repeatedly', async () => {
const pending = Promise.withResolvers<string | null>()
onTestFinished(async () => { await act(async () => { pending.resolve(null) }) })
const input = props()
const selectTeamMode = vi.fn(() => pending.promise)
render(<TeamModePage {...input} selectTeamMode={selectTeamMode} />)
const toggle = screen.getByRole('switch')
fireEvent.click(toggle)
expect(toggle.getAttribute('aria-disabled')).toBe('true')
fireEvent.click(toggle)
expect(selectTeamMode).toHaveBeenCalledExactlyOnceWith(true)
expect(toggle.getAttribute('aria-checked')).toBe('false')
await act(async () => { pending.resolve(null) })
expect(toggle.getAttribute('aria-disabled')).toBe('false')
expect(input.reportFailure).not.toHaveBeenCalled()
})
@@ -27,11 +27,12 @@ function props(enabled: boolean | undefined, selectTeamMode = vi.fn(async () =>
it.each(Object.entries({ zh, en, ja, es, fr, de, ru, pt }).flatMap(([locale, dictionary]) =>
[false, true].map(enabled => ({ locale, dictionary, enabled })),
))('opens Team settings from the $locale summary without changing mode (enabled: $enabled)', ({ dictionary, enabled }) => {
))('opens Team settings from the $locale summary without changing mode (enabled: $enabled)', ({ locale, dictionary, enabled }) => {
const input = props(enabled)
render(<TeamModeToggle {...input} t={makeTranslate(dictionary)} />)
const summary = screen.getByRole('menuitem', { name: new RegExp(dictionary['command.title']) })
expect(summary.textContent).toBe(dictionary['command.title'] + dictionary[enabled ? 'mode.on' : 'mode.off'])
if (locale === 'zh') expect(summary.textContent).toBe(`智能体团队协作${enabled ? '开启' : '关闭'}`)
expect(summary.getAttribute('data-model-menu-page')).toBe('agent-team')
expect(screen.queryByRole('switch')).toBeNull()
expect(screen.queryByRole('tooltip', { hidden: true })).toBeNull()
@@ -43,17 +44,6 @@ it.each(Object.entries({ zh, en, ja, es, fr, de, ru, pt }).flatMap(([locale, dic
expect(input.dismiss).not.toHaveBeenCalled()
})
it.each([
{ enabled: false, state: '关闭' },
{ enabled: true, state: '开启' },
])('shows the full Chinese saved state $state in the summary', ({ enabled, state }) => {
const input = props(enabled)
render(<TeamModeToggle {...input} />)
const summary = screen.getByRole('menuitem', { name: `智能体团队协作${state}` })
expect(summary.textContent).toBe(`智能体团队协作${state}`)
expect(input.selectTeamMode).not.toHaveBeenCalled()
})
it('keeps summary state projection-owned and blocks navigation while locked', () => {
const input = props(false)
const view = render(<TeamModeToggle {...input} />)
@@ -27,8 +27,8 @@
en: 7f20428c747ff052
zh: 975e6de728e02fa0
/deepseek-ai-dsh-client-ui-model-selection/use-this-package/selection-failures:
en: ccbf30a02bf1b456
zh: c5331d5379d91d5d
en: 6f790bbbca533c64
zh: c46d46a94a34dc2c
/deepseek-ai-dsh-client-ui-model-selection/understand-the-implementation:
en: c1d14a925c92950f
zh: f80f8169bc283c60
+1 -1
View File
@@ -61,7 +61,7 @@ Catalog availability does not block sending with a saved selection; request exec
When another writer owns the Session, model-selection failures tell the user to quit other running DSH instances and retry.
The session-scoped `conversation.input.model.options` list appends root controls below model and reasoning options. Its owner supplies `locked`, `reportFailure(message)`, `dismiss()`, and `openPage({ key, title })`. Register detail content in the session-scoped keyed `conversation.input.model.page` slot and mark the invoking button with `data-model-menu-page` equal to that key. The root menu and detail pages share a 240px width within the viewport's 12px edge insets; model and effort lists retain content-sized widths. The menu uses `title` as the accessible page name, focuses its first enabled switch on entry, and restores the invoking row on Escape; Tab closes a detail page without activating its switch. Detail pages receive `locked`, `reportFailure`, and `dismiss`; the owning plugin retains settings and confirmation logic. `locked` includes a model or effort save in flight. `dismiss()` closes the menu and focuses its trigger before another overlay opens.
The session-scoped `conversation.input.model.options` list appends root controls below model and reasoning options. Entries call `openPage({ key, title })` to show content registered in the session-scoped keyed `conversation.input.model.page` slot; the invoking button's `data-model-menu-page` must match the key. Root and detail entries receive `locked`, `reportFailure(message)`, and `dismiss()`: the lock includes model or effort saves, failures use the menu owner's toast, and dismissal focuses its trigger synchronously before another overlay opens. Contributing plugins own settings and confirmation logic. Root and detail pages share a 240px width within 12px viewport insets; model and effort lists remain content-sized. The menu uses `title` as the accessible page name and focuses its first enabled switch on entry. Escape returns focus to the invoking row; Tab closes a detail page without activating its switch.
-----
@@ -61,7 +61,7 @@ composer 菜单中的模型名称和推理等级均使用 400(regular)字重
当会话被其他写句柄占用时,模型选择失败提示用户退出其他正在运行的 DSH 后重试。
会话级列表 slot `conversation.input.model.options` 在模型与推理等级选项下方追加控件。Owner 提供 `locked`、`reportFailure(message)`、`dismiss()` 和 `openPage({ key, title })`。二级内容注册到会话级 keyed slot `conversation.input.model.page`;入口按钮的 `data-model-menu-page` 与注册键一致。一级菜单与二级页共用 240px 宽度,并保持视口两侧的 12px 边距;模型与推理等级列表仍按内容定宽。菜单以 `title` 作为页面无障碍名称,进入时聚焦首个可用开关,Escape 返回入口行;Tab 关闭二级页而不激活开关。二级页收到 `locked`、`reportFailure` 和 `dismiss`,设置与确认逻辑仍由贡献插件负责。`locked` 包含模型或推理等级保存中状态。`dismiss()` 关闭菜单并同步聚焦触发按钮,供贡献方随后打开其他浮层。
会话级列表 slot `conversation.input.model.options` 在模型与推理等级选项下方追加控件。贡献项调用 `openPage({ key, title })`,显示注册到会话级 keyed slot `conversation.input.model.page` 的内容;入口按钮的 `data-model-menu-page` 必须与注册键一致。一级与二级贡献项均收到 `locked`、`reportFailure(message)` 和 `dismiss()`:锁定包含模型或推理等级保存中状态,失败由菜单宿主的 toast 提示,关闭时同步聚焦触发按钮,供贡献方随后打开其他浮层。设置与确认逻辑由贡献插件负责。一级与二级页共用 240px 宽度,并保持视口两侧的 12px 边距;模型与推理等级列表仍按内容定宽。菜单以 `title` 作为页面无障碍名称,进入时聚焦首个可用开关。Escape 将焦点还给入口行;Tab 关闭二级页而不激活开关。
-----
@@ -40,7 +40,7 @@ import {
IconDataOutlineRegular, IconWarningOutlineRegular, Input, isMobileDevice, rankByName, StateDot, Tag, Toast,
} from '@deepseek-ai/dsh-client-ui-primitives'
import type { PropsLocale, PropsRenderSlots, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
import type { ModelLabelOwner, ModelMenuPage, ModelSelectInjected } from './slots.ts'
import type { ModelLabelOwner, ModelMenuControls, ModelMenuPage, ModelSelectInjected } from './slots.ts'
import css from './ModelSelect.module.css'
import { orderModelProviders } from './provider-order.ts'
@@ -264,6 +264,15 @@ export function ModelSelect(
setPane('root')
}
const controls: ModelMenuControls = {
locked: locked || busy,
dismiss: () => {
close()
triggerRef.current?.focus()
},
reportFailure: (message) => { setToast({ seq: ++toastSeq.current, text: message }) },
}
const moveFocus = (offset: number): void => {
const items = Array.from(menuRef.current?.querySelectorAll<HTMLButtonElement>(
'button[role="menuitem"]:not([disabled]), button[role="menuitemradio"]:not([disabled]), button[role="switch"]:not([disabled])',
@@ -317,7 +326,7 @@ export function ModelSelect(
if (event.key === 'Tab') {
if (event.shiftKey) {
event.preventDefault()
if (typeof pane === 'object' || (pane !== 'root' && currentChoice !== undefined)) back(pane)
if (pane !== 'root' && currentChoice !== undefined) back(pane)
else close(true)
return
}
@@ -518,15 +527,7 @@ export function ModelSelect(
<IconChevronRightOutlineRegular className={css.cellChevron} />
</button>
)}
{renderSlot('conversation.input.model.options', {
locked: locked || busy,
openPage: (page) => { drill(page) },
dismiss: () => {
close()
triggerRef.current?.focus()
},
reportFailure: (message) => { setToast({ seq: ++toastSeq.current, text: message }) },
})}
{renderSlot('conversation.input.model.options', { ...controls, openPage: drill })}
</>
)}
@@ -671,14 +672,7 @@ export function ModelSelect(
)}
{typeof pane === 'object' && (
<div className={clsx(css.groups, 'scrollable')}>
{renderSlot('conversation.input.model.page', {
locked: locked || busy,
dismiss: () => {
close()
triggerRef.current?.focus()
},
reportFailure: (message) => { setToast({ seq: ++toastSeq.current, text: message }) },
}, { entryKey: pane.key })}
{renderSlot('conversation.input.model.page', controls, { entryKey: pane.key })}
</div>
)}
</MenuSurface>,
@@ -35,16 +35,22 @@ export interface ModelMenuControls {
reportFailure: (message: string) => void
}
/** Root-menu controls for opening plugin-owned settings pages. */
export type ModelMenuOptions = ModelMenuControls & {
/**
* Open page.key in conversation.input.model.page with page.title as its localized accessible name.
* The root button's data-model-menu-page must match page.key for focus return.
*/
openPage: (page: ModelMenuPage) => void
}
declare module '@deepseek-ai/dsh-client-ui-slots' {
interface SlotMap {
/** Session options appended after model and reasoning controls in the root menu. */
'conversation.input.model.options': {
kind: 'list'
scope: 'session'
owner: ModelMenuControls & {
/** Open a keyed detail page inside this menu; its root button supplies data-model-menu-page for focus return. */
openPage: (page: ModelMenuPage) => void
}
owner: ModelMenuOptions
}
/** Plugin-owned content displayed as a model-menu detail page. */
'conversation.input.model.page': {
@@ -11,7 +11,7 @@ import { en } from '../src/client/locales.ts'
afterEach(cleanup)
function setup(locked = false) {
function setup() {
const directory = createSnapshotStore<ModelDirectoryState>({
current: { provider: 'fixture', model: 'fixture' }, routable: true,
groups: [{ id: 'fixture', name: 'Fixture', models: [{ id: 'fixture', name: 'Fixture' }] }],
@@ -33,7 +33,7 @@ function setup(locked = false) {
}
return options?.fallback ?? null
}
render(<ModelSelect locked={locked} available directory={directory} load={vi.fn()} select={select}
render(<ModelSelect locked={false} available directory={directory} load={vi.fn()} select={select}
resolveText={text => typeof text === 'string' ? text : text.en} t={makeTranslate(en)} renderSlot={renderSlot} />)
const trigger = screen.getByRole('button', { name: /^Select model/ })
fireEvent.click(trigger)
@@ -1619,7 +1619,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
occupants: [],
replaceRisk: 'none',
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.model.label\', () => ctx.slots.register(\n { name: \'conversation.input.model.label\' },\n ({ provider, model }) => React.createElement(\'span\', { title: provider.name }, model.name),\n ))\n },\n}',
source: 'packages/client/ui-model-selection/src/client/slots.ts:70',
source: 'packages/client/ui-model-selection/src/client/slots.ts:76',
},
{
key: 'conversation.input.model.options',
@@ -1649,9 +1649,11 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
],
ownerProps: [
'/** Selection state and feedback shared by menu option entries and detail pages. */\nexport interface ModelMenuControls {\n /** Whether the composer refuses changes, including while a model selection is saving. */\n locked: boolean\n /** Close the menu and focus its trigger synchronously before opening another overlay. */\n dismiss: () => void\n /** Report a failed selection through the menu owner\'s persistent toast. */\n reportFailure: (message: string) => void\n}',
'/** A keyed contribution displayed as a second page of the model menu. */\nexport interface ModelMenuPage {\n /** Registration key in conversation.input.model.page; also marks its root button\'s data-model-menu-page. */\n key: string\n /** Localized accessible name of the detail page. */\n title: string\n}',
'/** Root-menu controls for opening plugin-owned settings pages. */\nexport type ModelMenuOptions = ModelMenuControls & {\n /**\n * Open page.key in conversation.input.model.page with page.title as its localized accessible name.\n * The root button\'s data-model-menu-page must match page.key for focus return.\n */\n openPage: (page: ModelMenuPage) => void\n}',
],
ownerPropsReferences: [
'ModelMenuPage',
],
ownerPropsReferences: [],
standardProps: [
'useRemoteAccess: (action: RemoteEndpoint) => boolean',
'useResource: UseResource',
@@ -1682,7 +1684,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
],
replaceRisk: 'none',
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.model.options\', () => ctx.slots.register(\n { name: \'conversation.input.model.options\', id: \'my-entry\', order: 100, label: \'My entry\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
source: 'packages/client/ui-model-selection/src/client/slots.ts:41',
source: 'packages/client/ui-model-selection/src/client/slots.ts:50',
},
{
key: 'conversation.input.model.page',
@@ -1732,7 +1734,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
],
replaceRisk: 'shadows-shipped-ui',
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'conversation.input.model.page\', () => ctx.slots.register(\n { name: \'conversation.input.model.page\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
source: 'packages/client/ui-model-selection/src/client/slots.ts:50',
source: 'packages/client/ui-model-selection/src/client/slots.ts:56',
},
{
key: 'conversation.input.overlay',
@@ -7,7 +7,7 @@ import { clientInspectProviders } from '../src/client/providers.ts'
const Component = () => null
describe('Client inspect providers', () => {
it('exposes Tool owner fields and phases through the live slot lookup', async () => {
it('exposes Tool and model-menu owner fields through the live slot lookup', async () => {
const ctx = new Context()
const fiber = ctx.plugin(SlotRegistry)
try {
@@ -15,7 +15,10 @@ describe('Client inspect providers', () => {
const slots = ctx.slots as { registerFactory(options: object, component: unknown): () => void }
slots.registerFactory({
name: 'provider.tool-owner', scope: 'root',
children: { 'tool.call.toolview': { kind: 'keyed', scope: 'session' } },
children: {
'tool.call.toolview': { kind: 'keyed', scope: 'session' },
'conversation.input.model.options': { kind: 'list', scope: 'session' },
},
}, Component)
const provider = clientInspectProviders(ctx).find(item => item.manifest.id === 'Slots')!
const result = await provider.query('listSubTree', { root: 'tool.call.toolview' }, {} as never)
@@ -26,6 +29,10 @@ describe('Client inspect providers', () => {
}
for (const phase of ['preparing', 'start', 'result']) expect(owner).toContain(`phase: '${phase}'`)
expect(owner).not.toContain('truncated')
const options = await provider.query('listSubTree', { root: 'conversation.input.model.options' }, {} as never)
const menuOwner = (options as typeof selected).selected.catalog.ownerProps.join('\n')
expect(menuOwner).toContain('ModelMenuOptions')
expect(menuOwner).toContain('openPage: (page: ModelMenuPage) => void')
} finally {
await fiber.dispose()
}