diff --git a/apps/web/tests/agent-preset-selection.e2e.ts b/apps/web/tests/agent-preset-selection.e2e.ts
index 8fe0080707..714407c69e 100644
--- a/apps/web/tests/agent-preset-selection.e2e.ts
+++ b/apps/web/tests/agent-preset-selection.e2e.ts
@@ -430,3 +430,72 @@ describe('web e2e: agent-preset selection', () => {
expect(tripwire.warnings).toEqual([])
})
})
+
+it.each([false, true])('starts Creator from Plugins with Coding Tools=%s without changing drafts or defaults', async (developerTools) => {
+ const scaffold = await launchWebScaffold({ developerTools, agentPresets: { default: 'standard' } })
+ let browser: Browser | undefined
+ try {
+ browser = await chromium.launch()
+ const page = await newEnglishPage(browser)
+ const tripwire = watchConsole(page)
+ onTestFailed(() => saveFailureShot(page, 'web-e2e-plugin-creator'))
+ await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
+ await connectFreshWorkspace(page, scaffold.workspaceCwd)
+ const creator = scaffold.ctx.agents.list()[0]
+ if (creator === undefined) throw new Error('Connecting the workspace did not create a Session')
+ expect(scaffold.ctx.agentPresets.composedPreset(creator.ctx)).toBe('standard')
+ await page.getByRole('button', { name: 'Standard mode', exact: true }).waitFor()
+ const composer = page.locator('[data-composer-input][contenteditable="true"]').last()
+ const draft = 'Keep this unsent plugin idea.'
+ await writeComposerDraft(page, composer, draft)
+
+ await page.getByRole('navigation', { name: 'Global panels' }).getByRole('button', { name: 'Plugins', exact: true }).click()
+ await page.getByRole('button', { name: 'Choose how to add a plugin', exact: true }).click()
+ await Promise.all([
+ page.waitForResponse('**/api/agentPresets/select'),
+ page.getByRole('menuitem', { name: /^Let the agent create a plugin/ }).click(),
+ ])
+ const picker = page.getByTitle('Choose the agent preset for your new task', { exact: true }).filter({ hasText: 'Creator mode' })
+ await picker.waitFor()
+ await composer.filter({ hasText: draft }).waitFor()
+ expect(await composer.innerText()).toBe(draft)
+ expect(await picker.getAttribute('aria-haspopup')).toBe('menu')
+ expect(await page.getByRole('dialog', { name: 'Add plugin', exact: true }).count()).toBe(0)
+ expect(scaffold.ctx.sessionProjections.stateOf(creator.session, 'agentPreset')).toBe('cordis')
+ expect(scaffold.ctx.agentPresets.composedPreset(creator.ctx)).toBe('cordis')
+ expect(scaffold.ctx.tools.schemas(creator).map(tool => tool.name))
+ .toEqual(expect.arrayContaining(['cordis_inspect_list', 'cordis_inspect_query', 'plugin_manager']))
+ expect(creator.session.snapshotEvents().some(event => event.type === 'agent-preset/selected'
+ && event.data.agentPreset === 'cordis')).toBe(true)
+ expect(creator.session.snapshotEvents().some(event => event.type === 'user/message' || event.type === 'turn/start')).toBe(false)
+ expect(scaffold.ctx.settings.describe().find(row => row.ns === 'ui-settings')?.value).toMatchObject({ enabled: developerTools })
+ expect(scaffold.ctx.agentPresets.defaultId).toBe('standard')
+
+ // Close a fixture turn on the real Creator Session without requesting a model.
+ await writeComposerDraft(page, composer, '')
+ creator.session.append('turn/start', { turn: 1 })
+ creator.session.append('user/message', createUserMessage({
+ content: [{ type: 'text', text: 'Creator fixture completed without a model call.' }], source: { kind: 'user' },
+ }), { surfaceOp: 'append' })
+ creator.session.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
+ await scaffold.ctx.sessions.flush(creator.session)
+ await page.getByText('Creator fixture completed without a model call.', { exact: true }).waitFor()
+ const newSession = page.getByRole('button', { name: 'New session', exact: true }).filter({ hasText: 'New Session' })
+ await Promise.all([page.waitForResponse('**/api/session/create'), newSession.click()])
+ expect(scaffold.ctx.agents.list().find(agent => agent.id !== creator.id)).toBeDefined()
+ const next = scaffold.ctx.agents.list().find(agent => agent.id !== creator.id)!
+ expect(next.id).not.toBe(creator.id)
+ expect(next.session.header.agentPreset).toBe('standard')
+ expect(scaffold.ctx.sessionProjections.stateOf(next.session, 'agentPreset')).toBe('standard')
+ expect(scaffold.ctx.agentPresets.composedPreset(next.ctx)).toBe('standard')
+ expect(scaffold.ctx.sessionProjections.stateOf(creator.session, 'agentPreset')).toBe('cordis')
+ await page.getByRole('button', { name: 'Standard mode', exact: true }).waitFor()
+ expect(scaffold.ctx.settings.describe().find(row => row.ns === 'ui-settings')?.value).toMatchObject({ enabled: developerTools })
+ expect(scaffold.ctx.agentPresets.defaultId).toBe('standard')
+ expect(tripwire.pageErrors).toEqual([])
+ expect(tripwire.warnings).toEqual([])
+ } finally {
+ await browser?.close()
+ await scaffold.close()
+ }
+})
diff --git a/apps/web/tests/expected/plugin-config/official.expected.md b/apps/web/tests/expected/plugin-config/official.expected.md
index 3906b58624..f4b2293eb0 100644
--- a/apps/web/tests/expected/plugin-config/official.expected.md
+++ b/apps/web/tests/expected/plugin-config/official.expected.md
@@ -2,7 +2,9 @@
- text: 安装、启用和配置插件
- button "插件说明"
- button "刷新"
-- button "添加插件"
+- group "添加插件":
+ - button "添加插件"
+ - button "选择添加插件方式"
- heading "官方" [level=3]
- text: "8"
- list:
diff --git a/apps/web/tests/expected/plugin-manager/live-enabled.expected.md b/apps/web/tests/expected/plugin-manager/live-enabled.expected.md
index 23d74b2077..fa9fd12631 100644
--- a/apps/web/tests/expected/plugin-manager/live-enabled.expected.md
+++ b/apps/web/tests/expected/plugin-manager/live-enabled.expected.md
@@ -2,7 +2,9 @@
- text: 安装、启用和配置插件
- button "插件说明"
- button "刷新"
-- button "添加插件"
+- group "添加插件":
+ - button "添加插件"
+ - button "选择添加插件方式"
- heading "官方" [level=3]
- text: "8"
- list:
diff --git a/apps/web/tests/expected/plugin-manager/loading.expected.md b/apps/web/tests/expected/plugin-manager/loading.expected.md
index 9c6fea0d43..4cf8d9ea23 100644
--- a/apps/web/tests/expected/plugin-manager/loading.expected.md
+++ b/apps/web/tests/expected/plugin-manager/loading.expected.md
@@ -2,7 +2,9 @@
- text: 安装、启用和配置插件
- button "插件说明"
- button "刷新" [disabled]
-- button "添加插件" [disabled]
+- group "添加插件":
+ - button "添加插件" [disabled]
+ - button "选择添加插件方式" [disabled]
- status "正在读取插件…"
1680px: 4 rows; page/group headers, rows, icons, text lines and blank action spaces align within 0.1px
diff --git a/apps/web/tests/expected/plugin-manager/manager.expected.md b/apps/web/tests/expected/plugin-manager/manager.expected.md
index 7e126cd61b..89ca0d1416 100644
--- a/apps/web/tests/expected/plugin-manager/manager.expected.md
+++ b/apps/web/tests/expected/plugin-manager/manager.expected.md
@@ -2,7 +2,9 @@
- text: 安装、启用和配置插件
- button "插件说明"
- button "刷新"
-- button "添加插件"
+- group "添加插件":
+ - button "添加插件"
+ - button "选择添加插件方式"
- heading "官方" [level=3]
- text: "8"
- list:
diff --git a/apps/web/tests/plugin-manager.e2e.ts b/apps/web/tests/plugin-manager.e2e.ts
index 6a0da11f0f..39ae03e691 100644
--- a/apps/web/tests/plugin-manager.e2e.ts
+++ b/apps/web/tests/plugin-manager.e2e.ts
@@ -124,7 +124,7 @@ describe('web e2e: plugin manager', () => {
expect(await skeleton.getAttribute('aria-label')).toBe('正在读取插件…')
expect(await panel.getAttribute('aria-busy')).toBe('true')
const actions = panel.locator(':scope > header > div:last-child button')
- expect(await actions.count()).toBe(2)
+ expect(await actions.count()).toBe(3)
for (const action of await actions.all()) expect(await action.isDisabled()).toBe(true)
expect(await panel.getByRole('button', { name: '插件说明' }).isEnabled()).toBe(true)
const loadingAria = await captureStableAria(probe, '[data-plugin-panel]', scaffold.workspaceCwd)
@@ -832,6 +832,16 @@ describe('web e2e: plugin manager', () => {
const dialog = page.getByRole('dialog', { name: '添加插件' })
await dialog.waitFor({ timeout: 10_000 })
const field = dialog.getByRole('textbox', { name: '包名或地址' })
+ expect(await page.getByRole('menu').count()).toBe(0)
+ await expect.poll(() => field.evaluate(element => document.activeElement === element)).toBe(true)
+ await dialog.getByRole('button', { name: '关闭', exact: true }).click()
+ await dialog.waitFor({ state: 'hidden' })
+ await panel.getByRole('button', { name: '选择添加插件方式', exact: true }).click()
+ const menu = page.getByRole('menu')
+ await menu.getByRole('menuitem', { name: /^安装第三方插件/ }).click()
+ await menu.waitFor({ state: 'hidden' })
+ await dialog.waitFor({ state: 'visible' })
+ await expect.poll(() => field.evaluate(element => document.activeElement === element)).toBe(true)
const install = dialog.getByRole('button', { name: '安装', exact: true })
expect(await install.isDisabled()).toBe(true)
expect(await dialog.getByRole('note').textContent()).toContain('请确认插件来源可信')
diff --git a/docs/subsystems/slots.i18n.yaml b/docs/subsystems/slots.i18n.yaml
index a78b1185a1..aec206af8c 100644
--- a/docs/subsystems/slots.i18n.yaml
+++ b/docs/subsystems/slots.i18n.yaml
@@ -3,8 +3,8 @@
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write docs/subsystems/slots.md
/web-client-slots:
- en: bda026282132e290
- zh: 3e3faf96c72420d6
+ en: 8d33b164230344fa
+ zh: 13a930ab96280744
/web-client-slots/declaration-and-lifecycle:
en: f2d2c0d3b8f14ec7
zh: 441ed13ff3f81d2a
diff --git a/docs/subsystems/slots.md b/docs/subsystems/slots.md
index 13b47b7460..42da307ddd 100644
--- a/docs/subsystems/slots.md
+++ b/docs/subsystems/slots.md
@@ -8,6 +8,8 @@ This page documents slot ownership, component inputs, extension APIs, and the sh
`plugins.bundle.config` supplies bundle detail configuration, keyed by npm package name. `plugins.bundle.activation` renders optional guidance after user-requested enablement, with owner callbacks to dismiss or open that bundle’s details. `conversation.input.activity` supplies one action between the model selector and Send, with toolbar expansion released on unmount.
+The plugin catalog declares `plugins.add.actions`, a root-scoped list for `MenuItemButton` rows after installation in the Add plugin menu. Its owner supplies `onDismiss()` to close the menu before starting an action. The slot follows the owning Plugins page declaration lifetime.
+
## Declaration and lifecycle
`SlotMap` is the compile-time registry. A package declaration-merges the key, cardinality, scope, owner props, keyed props, and optional slot-level inject face. The runtime declaration is the matching `children` entry on the component that owns the render location.
@@ -133,6 +135,7 @@ root
│ ├─ settings.models.footer
│ └─ settings.plugins.tab
├─ main
+│ ├─ plugins.add.actions
│ ├─ plugins.item
│ ├─ plugins.bundle.config
│ ├─ plugins.row.config
diff --git a/docs/subsystems/slots.zh.md b/docs/subsystems/slots.zh.md
index 42bf724545..10e6338d0f 100644
--- a/docs/subsystems/slots.zh.md
+++ b/docs/subsystems/slots.zh.md
@@ -8,6 +8,8 @@ Slots 是 Web Client 的类型化 React 组合系统。[`dsh-client-ui-slots`](.
`plugins.bundle.config` 以 npm 包名为 key,提供 Bundle 详情配置。`plugins.bundle.activation` 在用户显式启用后渲染可选引导,由拥有者提供关闭引导和打开该 Bundle 详情的回调。`conversation.input.activity` 提供模型选择器与发送按钮之间的单个活动控件,可展开工具栏并在卸载时释放展开状态。
+插件目录声明 `plugins.add.actions`,它是 root 作用域的 list,在添加插件菜单的安装项之后提供 `MenuItemButton` 行。owner 提供 `onDismiss()`,用于开始动作前关闭菜单。该 slot 遵循所属插件页面声明的生命周期。
+
## 声明与生命周期
`SlotMap` 是编译期注册表。包通过声明合并写入 key、cardinality(基数)、scope、owner props、keyed props 与可选的 slot 级 inject face。运行时声明则是拥有该渲染位置的组件在 `children` 中给出的对应条目。
@@ -133,6 +135,7 @@ root
│ ├─ settings.models.footer
│ └─ settings.plugins.tab
├─ main
+│ ├─ plugins.add.actions
│ ├─ plugins.item
│ ├─ plugins.bundle.config
│ ├─ plugins.row.config
diff --git a/packages/client/ui-agent-preset/README.i18n.yaml b/packages/client/ui-agent-preset/README.i18n.yaml
index 14bb9ffa04..a1086951fe 100644
--- a/packages/client/ui-agent-preset/README.i18n.yaml
+++ b/packages/client/ui-agent-preset/README.i18n.yaml
@@ -15,11 +15,11 @@
en: d152484eb41ac6b4
zh: b3ad7867f23dad1c
/deepseek-ai-dsh-client-ui-agent-preset/use-this-package:
- en: fb8633d84f7ae9df
- zh: 85dddc83f4abe686
+ en: abb24ddb24f5588d
+ zh: 2c58c8cd0e2a335e
/deepseek-ai-dsh-client-ui-agent-preset/understand-the-implementation:
- en: 7813f0063c15e241
- zh: 6eabc242edfc45ec
+ en: 4c88c83529317389
+ zh: 5125122bdacfa3da
/deepseek-ai-dsh-client-ui-agent-preset/further-exploration:
en: bbae8d79844bc481
zh: 4302107fd1f460e6
diff --git a/packages/client/ui-agent-preset/README.md b/packages/client/ui-agent-preset/README.md
index 3c8ed422c3..b66072911d 100644
--- a/packages/client/ui-agent-preset/README.md
+++ b/packages/client/ui-agent-preset/README.md
@@ -33,6 +33,10 @@ Turning Coding Tools off clears all unapplied choices through the existing Devel
Known shipped presets offer mode details and usage examples in a read-only dialog. Its tabs preserve each page's scroll position; closing returns focus to the opening action. Help does not change the new-task default. The default badge replaces the card's group badge, and the preset id appears beside the title. Guide copy and examples belong to this package.
+**Let the agent create a plugin** in the Plugins page's **Add plugin** arrow menu enters the same Creator flow as Settings. It submits no message and preserves unsent drafts. While the roster loads or Creator is unavailable, the menu item is disabled with an explanation. Both entries show a Toast with the reason if the Host refuses the preset switch.
+
+Entering Creator selects `cordis` for the receiving blank Session without changing the new-task default or Coding Tools setting. If no workspace or blank Session is bound yet, the choice waits for that binding. After the choice is applied, the Creator Session keeps its preset; a later newly created Session uses the configured default, such as Standard.
+
## Understand the implementation
@@ -41,6 +45,8 @@ Known shipped presets offer mode details and usage examples in a read-only dialo
`agentPresets/list` supplies the roster and marks the current default, and `agentPresets/read` one declaration's YAML for the viewer; default changes write the `agent-preset-registry` settings namespace. The picker, blank-session synchronization and read-only session label use recorded preset identities. Connection resets and settings updates refresh the roster.
+`CreatePluginMenuItem` contributes to `plugins.add.actions` using the shared roster store. Its selection calls the owner's `onDismiss()` before the same `startCreatorDraft` callback exposed to Settings as `creatorDraft`. That callback stages `cordis` through `AgentPresetSeatController` and opens the task through `uiWorkspace.startSession`; it can reuse a blank Session and applies the staged choice when a Session binding becomes available. The choice is consumed once applied. Both Coding Tools states use the same picker and selection store, and `AgentPresetSeat` renders refusals through the shared `Toast` component.
+
diff --git a/packages/client/ui-agent-preset/README.zh.md b/packages/client/ui-agent-preset/README.zh.md
index a6f2d97f44..434b74e026 100644
--- a/packages/client/ui-agent-preset/README.zh.md
+++ b/packages/client/ui-agent-preset/README.zh.md
@@ -33,6 +33,10 @@ kind: "package-reference"
已知的内置预设提供只读的模式说明与使用示例对话框。各页签保留各自的滚动位置;关闭后焦点回到打开它的操作。帮助不会改变新任务默认值。默认徽标取代卡片的分组徽标,预设 id 显示在标题旁。指南文案与示例归本包所有。
+插件页**添加插件**箭头菜单中的**让 Agent 创建插件**进入与设置页相同的创造流程,不发送消息,并保留未发送的草稿。读取预设列表或创造模式不可用时,菜单项禁用并说明原因。Host 拒绝切换预设时,两处入口均通过 Toast 显示原因。
+
+进入创造模式会为接收该选择的空白 Session 选择 `cordis`,不改变新任务默认值或代码工作工具设置。尚未绑定工作区或空白 Session 时,选择等待绑定完成后应用。应用后,创造 Session 保留该预设;之后真正创建的新 Session 使用配置的默认值,例如标准模式。
+
## 理解实现
@@ -41,6 +45,8 @@ kind: "package-reference"
`agentPresets/list` 提供列表并标记当前默认值,`agentPresets/read` 为查看器提供一条声明的 YAML;默认值的修改写入 `agent-preset-registry` settings 命名空间。选择器、空白会话同步和只读会话标签使用记录的 preset 标识。连接重置和设置更新会刷新列表。
+`CreatePluginMenuItem` 使用共享的预设列表 store,向 `plugins.add.actions` 贡献菜单项。选择时先调用页面传入的 `onDismiss()`,再调用与设置页 `creatorDraft` 相同的 `startCreatorDraft` 回调。该回调通过 `AgentPresetSeatController` 暂存 `cordis`,再通过 `uiWorkspace.startSession` 打开任务;它可以复用空白 Session,并在 Session 绑定可用时应用暂存选择。暂存选择应用后即清除。代码工作工具开启或关闭时均使用同一个选择器和选择 store,`AgentPresetSeat` 通过共享的 `Toast` 组件显示拒绝原因。
+
diff --git a/packages/client/ui-agent-preset/package.json b/packages/client/ui-agent-preset/package.json
index be4ef13690..2f5bc155e6 100644
--- a/packages/client/ui-agent-preset/package.json
+++ b/packages/client/ui-agent-preset/package.json
@@ -58,6 +58,7 @@
"@deepseek-ai/dsh-client-store": "workspace:*",
"@deepseek-ai/dsh-client-test-runtime": "workspace:*",
"@deepseek-ai/dsh-client-ui-conversation": "workspace:*",
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "workspace:*",
"@deepseek-ai/dsh-client-ui-primitives": "workspace:*",
"@deepseek-ai/dsh-client-ui-renderer": "workspace:*",
"@deepseek-ai/dsh-client-ui-session": "workspace:*",
diff --git a/packages/client/ui-agent-preset/src/client/AgentPresetSeat.tsx b/packages/client/ui-agent-preset/src/client/AgentPresetSeat.tsx
index afa2b5a2ad..07e4aa84c8 100644
--- a/packages/client/ui-agent-preset/src/client/AgentPresetSeat.tsx
+++ b/packages/client/ui-agent-preset/src/client/AgentPresetSeat.tsx
@@ -37,6 +37,8 @@ export interface AgentPresetSeatInjected {
load: () => Promise
/** Stage one preset for the next session; resolves to a refusal, or undefined. */
select: (id: string) => Promise
+ /** Acknowledge the refusal whose Toast finished. */
+ dismissRefusal: (error: AgentPresetSeatState['error']) => void
/** Clear the one-shot introduce cue once the chip has played it. */
introduced: () => void
}
@@ -74,10 +76,10 @@ export type AgentPresetSeatProps =
/**
* Render the new-session agent-preset chip.
* @param props - composed slot props.
- * @returns The chip, or null outside the main view or before the roster provides a preset choice.
+ * @returns The chip and any pending selection refusal, or null outside the main view.
*/
export function AgentPresetSeat({
- sessionId, useSessionRetainInfo, load, select, introduced, useAgentPresetSeat, useDeveloperTools, t,
+ sessionId, useSessionRetainInfo, load, select, dismissRefusal, introduced, useAgentPresetSeat, useDeveloperTools, t,
}: AgentPresetSeatProps) {
const developerTools = useDeveloperTools(value => value)
const state = useAgentPresetSeat(snapshot => snapshot)
@@ -87,7 +89,14 @@ export function AgentPresetSeat({
// The seq keys the banner, so picking the same broken preset twice replays
// it rather than leaving the first one silently in place.
const toastSeq = useRef(0)
- const [toast, setToast] = useState<{ seq: number; text: string } | null>(null)
+ const [toast, setToast] = useState<{ seq: number; error: Exclude } | null>(null)
+
+ useEffect(() => {
+ if (state.error !== null && typeof state.error === 'object') {
+ toastSeq.current += 1
+ setToast({ seq: toastSeq.current, error: state.error })
+ } else setToast(null)
+ }, [state.error])
useEffect(() => {
void load()
@@ -127,9 +136,8 @@ export function AgentPresetSeat({
return () => { window.clearTimeout(done) }
}, [state.introduce, ready, label, introduced])
- // Nothing to choose between: the deployment composes no presets and every
- // session shares the host composition.
- if (!main || !ready) return null
+ // A refused initial composition still needs its Toast when there is no chip to show.
+ if (!main) return null
// One wrapper span: the chip is a flex row with a gap, so loose character
// spans would each pick up the gap between them.
@@ -153,7 +161,7 @@ export function AgentPresetSeat({
return (
<>
-