Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

chore(ui): simplify component and extension internals (#817)

Mao Mra908eaae8066
diff --git a/docs/audit/pkg-ui-extension.md b/docs/audit/pkg-ui-extension.md
index 72290e41..b34020e9 100644
--- a/docs/audit/pkg-ui-extension.md
+++ b/docs/audit/pkg-ui-extension.md
@@ -72,3 +72,15 @@ Over-engineering only. Protocol/bridge surface (`useListen*`, `useInvoke*`, `def
## net: -265 lines, -1 dependency possible.
> Lead 复核修正:原 net -285 含 `Card.*` 五成员删除(-20),已按协议面出口契约降级为 `keep:`(见上),不计入 net。findings 计数相应为 17 条裁剪 + 5 条 `keep:`(原 18 + 4)。
+
+## 执行复核(2026-09-30)
+
+以下执行结论覆盖原审计建议;原 net 为估计,不是实际删除承诺。
+
+- 已执行:20 条(原报告误记 19 条)refork 元数据行改成现有函数的紧凑参数行,不增加中间表;保留全部字段、版本、顺序和 primitive 行。两组新建会话监听共用内部工厂,仍在点击时探测能力,每次注册独立抑制告警。`useMountStyle` 直接使用 effect cleanup,保留样式引用计数和 owner 隔离。
+- 已执行:复用 `HostPluginLoader`,保留原 `PlatformModuleLoader` / `PlatformPluginLoader` interface 名称及声明合并能力;内联私有 `MarketTab` / `startProvider`,共享九处相同错误文案;移除 extension 无引用的 cordis devDependency 和 lock importer 声明,保留 bundle patch 与真实传递依赖。
+- 已执行:仅 Cursor/Gemini 共用 JSON 扫描;Claude 必须先按文件顺序合并原始配置再校验,较晚无效条目仍覆盖较早有效条目,不能统一成逐文件过滤后合并。保留映射差异、agent 顺序及原有异常语义。
+- `keep:` `clearReadOnly`。原建议 `chmodSync(path, mode, { recursive: true })` 不是 Node API;逐路径 chmod、文件/目录模式与 best-effort 错误处理不删。
+- `keep:` Card 全部成员、SettingsSidebar/SettingsTrigger 槽位 props、异步 Query 签名、生成 DTO、restartHost 返回契约、profile.peek 服务方法、scope/layer 兼容字段、Button 由 tv 派生的尺寸类型及公共常量/类型出口。
+- 未新增 `useRemoteResource` / `pollUntil` / `OutcomeNotice`:生命周期、轮询与标记并不完全相同;仅复用实际相同的文案,避免为预计几行收益引入抽象或行为变化。
+- 验证:UI metadata、style cleanup/refcount、点击时能力检查和独立注册告警回归;extension 配置合并/扫描、市场参数、provider 生命周期、loader 契约及文案回归。各范围至少五次乱序通过并做变异验证;最终五包汇总 52 文件 / 386 用例通过,限定真实源码别名类型检查通过,Lint 零错误(仅既有警告)。
diff --git a/packages/dsh-tauri-extension/package.json b/packages/dsh-tauri-extension/package.json
index 5f1f4233..0e0e8b30 100644
--- a/packages/dsh-tauri-extension/package.json
+++ b/packages/dsh-tauri-extension/package.json
@@ -68,7 +68,6 @@
"yaml": "catalog:testing"
},
"devDependencies": {
- "@deepseek-ai/cordis": "catalog:dsh",
"@deepseek-ai/dsh-skill-filesystem": "catalog:dsh",
"@types/lodash-es": "catalog:types",
"dompurify": "catalog:ui",
diff --git a/packages/dsh-tauri-extension/src/client/components/extension-panel.test.tsx b/packages/dsh-tauri-extension/src/client/components/extension-panel.test.tsx
new file mode 100644
index 00000000..92f68f96
--- /dev/null
+++ b/packages/dsh-tauri-extension/src/client/components/extension-panel.test.tsx
@@ -0,0 +1,30 @@
+import type { MarketFace } from '../service/market.types'
+import { renderToStaticMarkup } from 'react-dom/server'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { ExtensionPanel } from './extension-panel'
+
+vi.mock('dsh-tauri-ui/client', () => ({ SegmentedControl: () => null }))
+vi.mock('../locales', () => ({ locale: { text: (key: string) => key } }))
+vi.mock('./skills-tab', () => ({ SkillsTab: () => <section>skills-content</section> }))
+vi.mock('./mcp-tab', () => ({ McpTab: () => <section>mcp-content</section> }))
+
+afterEach(() => vi.restoreAllMocks())
+
+describe('extension panel market composition', () => {
+ it('renders the market element with the installed subsection preference', () => {
+ const render = vi.fn(() => <section>installed-market-content</section>)
+ const market: MarketFace = { version: 1, render, setSettingsVisible: vi.fn(), settingsVisible: () => false }
+ const markup = renderToStaticMarkup(<ExtensionPanel market={market} createSkill={async () => {}} />)
+ expect(render).toHaveBeenCalledExactlyOnceWith({ preferredSubsectionId: 'installed' })
+ expect(markup).toContain('installed-market-content')
+ expect(markup).not.toContain('skills-content')
+ expect(markup).not.toContain('mcp-content')
+ })
+
+ it('renders skills when the optional market service is missing', () => {
+ const markup = renderToStaticMarkup(<ExtensionPanel market={undefined} createSkill={async () => {}} />)
+ expect(markup).toContain('skills-content')
+ expect(markup).not.toContain('installed-market-content')
+ expect(markup).not.toContain('mcp-content')
+ })
+})
diff --git a/packages/dsh-tauri-extension/src/client/components/extension-panel.tsx b/packages/dsh-tauri-extension/src/client/components/extension-panel.tsx
index 999d2d4c..5345edaf 100644
--- a/packages/dsh-tauri-extension/src/client/components/extension-panel.tsx
+++ b/packages/dsh-tauri-extension/src/client/components/extension-panel.tsx
@@ -4,7 +4,6 @@ import { SegmentedControl } from 'dsh-tauri-ui/client'
import { useEffect, useId, useState } from 'react'
import { locale } from '../locales'
import { resolveActiveTab } from './extension-panel.utils'
-import { MarketTab } from './market-tab'
import { McpTab } from './mcp-tab'
import { SkillsTab } from './skills-tab'
@@ -27,7 +26,7 @@ export function ExtensionPanel({ createSkill, market }: ExtensionPanelProps): Re
const rows: ExtensionTab[] = [
...(marketFace === undefined
? []
- : [{ id: 'market', label: t('marketTab'), render: () => <MarketTab market={marketFace} /> }]),
+ : [{ id: 'market', label: t('marketTab'), render: () => <>{marketFace.render({ preferredSubsectionId: 'installed' })}</> }]),
{ id: 'skills', label: t('skillsTab'), render: () => <SkillsTab t={t} createSkill={createSkill} /> },
{ id: 'mcp', label: t('mcpTab'), render: () => <McpTab t={t} /> },
]
diff --git a/packages/dsh-tauri-extension/src/client/components/market-tab.tsx b/packages/dsh-tauri-extension/src/client/components/market-tab.tsx
deleted file mode 100644
index f347605b..00000000
--- a/packages/dsh-tauri-extension/src/client/components/market-tab.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { ReactElement } from 'react'
-import type { MarketFace } from '../service/market.types'
-
-export interface MarketTabProps {
- market: MarketFace
-}
-
-/**
- * 市场面板:直接渲染 `market.render()` 交出的 element。
- *
- * 市场的客户端 bundle 与宿主共用同一个 React 实例(经宿主的模块表解析 react),
- * 因此这个 element 挂在面板树的任何位置都能正常工作;它自带错误边界,弹层
- * portal 到 `document.body`,跨容器没有问题。
- */
-export function MarketTab({ market }: MarketTabProps): ReactElement {
- return <>{market.render({ preferredSubsectionId: 'installed' })}</>
-}
diff --git a/packages/dsh-tauri-extension/src/client/components/mcp-tab.tsx b/packages/dsh-tauri-extension/src/client/components/mcp-tab.tsx
index 1ebe1340..9108b99d 100644
--- a/packages/dsh-tauri-extension/src/client/components/mcp-tab.tsx
+++ b/packages/dsh-tauri-extension/src/client/components/mcp-tab.tsx
@@ -13,6 +13,7 @@ import { isDesktopHost } from '../service/restart.utils'
import { McpEditorForm } from './mcp-editor-form'
import { McpImportDialog } from './mcp-import-dialog'
import { mapToPairs, parseMcpJson, parsePairs } from './mcp-tab.utils'
+import { failText } from './outcome.utils'
export function McpTab({ t }: McpTabProps): ReactElement {
const [servers, setServers] = useState<McpRow[] | null>(null)
@@ -70,7 +71,7 @@ export function McpTab({ t }: McpTabProps): ReactElement {
}
catch (error) {
setImportItems([])
- setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ setOutcome({ ok: false, text: failText(t, error) })
}
}
@@ -90,7 +91,7 @@ export function McpTab({ t }: McpTabProps): ReactElement {
setReload(value => value + 1)
}
catch (error) {
- setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ setOutcome({ ok: false, text: failText(t, error) })
}
finally {
setBusy(false)
@@ -234,7 +235,7 @@ export function McpTab({ t }: McpTabProps): ReactElement {
reloadList(true)
}
catch (error) {
- setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ setOutcome({ ok: false, text: failText(t, error) })
}
finally {
setBusy(false)
@@ -251,7 +252,7 @@ export function McpTab({ t }: McpTabProps): ReactElement {
reloadList(true)
}
catch (error) {
- setOutcome({ ok: false, text: `${t('failed')}: ${String(error instanceof Error ? error.message : error)}` })
+ setOutcome({ ok: false, text: failText(t, error) })
}
finally {
setBusy(false)
diff --git a/packages/dsh-tauri-extension/src/client/components/outcome.utils.test.ts b/packages/dsh-tauri-extension/src/client/components/outcome.utils.test.ts
new file mode 100644
index 00000000..67398d98
--- /dev/null
+++ b/packages/dsh-tauri-extension/src/client/components/outcome.utils.test.ts
@@ -0,0 +1,21 @@
+import type { Translate } from '../locales/index.types'
+import { describe, expect, it } from 'vitest'
+import { failText } from './outcome.utils'
+
+const t: Translate = key => key === 'failed' ? '失败' : key
+
+describe('failText', () => {
+ it('uses the localized failure label and Error message without its class prefix', () => {
+ expect(failText(t, new TypeError('cannot load'))).toBe('失败: cannot load')
+ })
+
+ it.each([
+ ['offline', '失败: offline'],
+ [null, '失败: null'],
+ [undefined, '失败: undefined'],
+ [0, '失败: 0'],
+ [{ message: 'plain object' }, '失败: [object Object]'],
+ ])('stringifies the non-Error rejection %j', (error, expected) => {
+ expect(failText(t, error)).toBe(expected)
+ })
+})
diff --git a/packages/dsh-tauri-extension/src/client/components/outcome.utils.ts b/packages/dsh-tauri-extension/src/client/components/outcome.utils.ts
new file mode 100644
index 00000000..7565aff8
--- /dev/null
+++ b/packages/dsh-tauri-extension/src/client/components/outcome.utils.ts
@@ -0,0 +1,5 @@
+import type { Translate } from '../locales/index.types'
+
+export function failText(t: Translate, error: unknown): string {
+ return `${t('failed')}: ${error instanceof Error ? error.message : String(error)}`
+}
diff --git a/packages/dsh-tauri-extension/src/client/components/skills-tab.tsx b/packages/dsh-tauri-extension/src/client/components/skills-tab.tsx
index 84cc436d..67e6f936 100644
--- a/packages/dsh-tauri-extension/src/client/components/skills-tab.tsx
+++ b/packages/dsh-tauri-extension/src/client/components/skills-tab.tsx
@@ -8,6 +8,7 @@ import { deleteSkill, getSkill, getSkills, postOpenDir, postRoots, postSkill, po
import { MarkdownPreview } from '../components/markdown'
import { IMPORT_REFRESH_DELAYS_MS, SKILL_REFRESH_INTERVAL_MS, SKILL_REFRESH_TIMEOUT_MS, SOURCE_LOCALE_KEYS } from '../constants'
import { useTimers } from '../hooks/use-timers'
+import { failText } from './outcome.utils'
import { normalizeRepository, policyTag } from './skills-tab.utils'
export interface SkillEditorState {
@@ -52,7 +53,7 @@ export function SkillsTab({ t, createSkill }: SkillsTabProps): ReactElement {
(error: unknown) => {
if (current) {
setSkills([])
- setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` })
+ setOutcome({ ok: false, text: failText(t, error) })
}
},
)
@@ -97,7 +98,7 @@ export function SkillsTab({ t, createSkill }: SkillsTabProps): ReactElement {
setPreview(!skill.editable)
setEditor({ mode: skill.editable ? 'edit' : 'view', name: skill.name, description: skill.description, whenToUse: skill.whenToUse ?? '', modelInvocable: skill.invocation.modelInvocable, userInvocable: skill.invocation.userInvocable, content: body.content })
}
- catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ catch (error) { setOutcome({ ok: false, text: failText(t, error) }) }
finally { setBusy(false) }
}
@@ -127,7 +128,7 @@ export function SkillsTab({ t, createSkill }: SkillsTabProps): ReactElement {
setOutcome({ ok: true, text: t('saved') })
refreshUntil(rows => !rows.some(row => row.name === name))
}
- catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ catch (error) { setOutcome({ ok: false, text: failText(t, error) }) }
finally {
setBusy(false)
setConfirmName(null)
@@ -145,7 +146,7 @@ export function SkillsTab({ t, createSkill }: SkillsTabProps): ReactElement {
return row !== undefined && row.invocation.modelInvocable === !enabled && row.invocation.userInvocable === !enabled
})
}
- catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ catch (error) { setOutcome({ ok: false, text: failText(t, error) }) }
finally { setBusy(false) }
}
@@ -153,7 +154,7 @@ export function SkillsTab({ t, createSkill }: SkillsTabProps): ReactElement {
try {
await postOpenDir(target)
}
- catch (error) { setOutcome({ ok: false, text: `${t('failed')}: ${error instanceof Error ? error.message : String(error)}` }) }
+ catch (error) { setOutcome({ ok: false, text: failText(t, error) }) }
}
const doCreate = async (): Promise<void> => {
diff --git a/packages/dsh-tauri-extension/src/host/apply.test.ts b/packages/dsh-tauri-extension/src/host/apply.test.ts
new file mode 100644
index 00000000..fb655d21
--- /dev/null
+++ b/packages/dsh-tauri-extension/src/host/apply.test.ts
@@ -0,0 +1,44 @@
+import type { HostContext } from 'dsh-tauri'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { apply, inject, packagedSkillsDir } from './apply'
+import { clearHostRuntime, getCurrentHostInstance, providerRuntime } from './config/runtime'
+
+vi.mock('./routes', () => ({ routes: vi.fn(() => () => {}) }))
+vi.mock('./service/provider', () => ({ provider: { start: vi.fn().mockResolvedValue(undefined) } }))
+vi.mock('./service/profile', () => ({ profile: { resolve: () => null, peek: (name: string) => `/profiles/${name}` } }))
+
+const { provider } = await import('./service/provider')
+const { routes } = await import('./routes')
+
+afterEach(() => {
+ clearHostRuntime()
+ vi.clearAllMocks()
+})
+
+describe('apply provider lifecycle', () => {
+ it('starts packaged skills only when the registered effect runs and returns runtime cleanup', async () => {
+ const effects = new Map<string, () => (() => void)>()
+ const host = { marker: 'host' }
+ const ctx = {
+ inject: vi.fn((_names: string[], callback: (context: unknown) => unknown) => callback(host)),
+ effect: vi.fn((effect: () => (() => void), label: string) => effects.set(label, effect)),
+ }
+ apply(ctx as unknown as HostContext, { profile: 'chosen' })
+ expect(ctx.inject).toHaveBeenCalledWith(inject, expect.any(Function))
+ expect(provider.start).not.toHaveBeenCalled()
+ expect(providerRuntime.disposed).toBe(false)
+ expect(getCurrentHostInstance()).toBe(host)
+ const start = effects.get('dsh-tauri-extension: skill provider')!
+ const dispose = start()
+ expect(provider.start).toHaveBeenCalledExactlyOnceWith(packagedSkillsDir())
+ expect(dispose).toBe(clearHostRuntime)
+ effects.get('dsh-tauri-extension: routes')!()
+ expect(routes).toHaveBeenCalledWith(host, { profileDirPath: '/profiles/chosen', remountProvider: expect.any(Function) })
+ await vi.mocked(routes).mock.calls[0][1].remountProvider()
+ expect(provider.start).toHaveBeenCalledTimes(2)
+ dispose()
+ expect(providerRuntime.disposed).toBe(true)
+ expect(providerRuntime.fiber).toBeUndefined()
+ expect(() => getCurrentHostInstance()).toThrow()
+ })
+})
diff --git a/packages/dsh-tauri-extension/src/host/apply.ts b/packages/dsh-tauri-extension/src/host/apply.ts
index d6d4e5b0..4e2b612a 100644
--- a/packages/dsh-tauri-extension/src/host/apply.ts
+++ b/packages/dsh-tauri-extension/src/host/apply.ts
@@ -29,7 +29,10 @@ export function apply(ctx: HostContext, config?: Config): void {
resetProviderRuntime()
const remountProvider = (): Promise<void> => provider.start(packagedSkillsDir())
const profileDirPath = profile.peek(config?.profile ?? profile.resolve() ?? DEFAULT_PROFILE)
- ctx.effect(() => startProvider(remountProvider), 'dsh-tauri-extension: skill provider')
+ ctx.effect(() => {
+ void remountProvider()
+ return clearHostRuntime
+ }, 'dsh-tauri-extension: skill provider')
ctx.effect(
() => routes(hostCtx as unknown as HostContext, { profileDirPath, remountProvider }),
'dsh-tauri-extension: routes',
@@ -37,8 +40,3 @@ export function apply(ctx: HostContext, config?: Config): void {
return clearHostRuntime
})
}
-
-function startProvider(remountProvider: () => Promise<void>): () => void {
- void remountProvider()
- return clearHostRuntime
-}
diff --git a/packages/dsh-tauri-extension/src/host/service/agents.test.ts b/packages/dsh-tauri-extension/src/host/service/agents.test.ts
new file mode 100644
index 00000000..8d47e1ea
--- /dev/null
+++ b/packages/dsh-tauri-extension/src/host/service/agents.test.ts
@@ -0,0 +1,99 @@
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { dirname, join } from 'node:path'
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { agents } from './agents'
+
+let home: string
+
+beforeEach(() => {
+ home = mkdtempSync(join(tmpdir(), 'dsh-extension-agents-'))
+})
+
+afterEach(() => {
+ if (!home.startsWith(join(tmpdir(), 'dsh-extension-agents-')))
+ throw new Error(`Unexpected scratch path: ${home}`)
+ rmSync(home, { recursive: true, force: true })
+})
+
+function writeConfig(file: string, content: unknown): void {
+ const path = join(home, file)
+ mkdirSync(dirname(path), { recursive: true })
+ writeFileSync(path, JSON.stringify(content))
+}
+
+describe('agents.resolve', () => {
+ it('returns no servers for an empty isolated home', () => {
+ expect(agents.resolve(home)).toEqual([])
+ })
+
+ it('maps Cursor stdio and HTTP entries with filtered string fields', () => {
+ writeConfig('.cursor/mcp.json', { mcpServers: {
+ local: { command: 'node', args: ['server.js', 7], env: { TOKEN: 'value', invalid: 7 } },
+ remote: { type: 'http', url: 'https://cursor.test/mcp', headers: { Authorization: 'token', invalid: false } },
+ invalid: { command: '' },
+ unsupported: { type: 'sse', url: 'https://cursor.test/sse' },
+ missing: null,
+ } })
+ expect(agents.resolve(home)).toEqual([
+ { agent: 'cursor', name: 'local', transport: 'stdio', command: 'node', args: ['server.js'], env: { TOKEN: 'value' } },
+ { agent: 'cursor', name: 'remote', transport: 'streamable-http', url: 'https://cursor.test/mcp', headers: { Authorization: 'token' } },
+ ])
+ })
+
+ it('uses Gemini httpUrl and gives its command precedence over the URL', () => {
+ writeConfig('.gemini/settings.json', { mcpServers: {
+ remote: { httpUrl: 'https://gemini.test/mcp' },
+ local: { command: 'gemini-server', httpUrl: 'https://ignored.test', args: [], env: {} },
+ wrongKey: { url: 'https://ignored.test' },
+ } })
+ expect(agents.resolve(home)).toEqual([
+ { agent: 'gemini', name: 'remote', transport: 'streamable-http', url: 'https://gemini.test/mcp' },
+ { agent: 'gemini', name: 'local', transport: 'stdio', command: 'gemini-server', args: undefined, env: undefined },
+ ])
+ })
+
+ it('keeps Claude later invalid entries shadowing earlier valid entries', () => {
+ writeConfig('.claude/settings.json', { mcpServers: { duplicate: { command: 'earlier' }, retained: { command: 'keep' } } })
+ writeConfig('.claude.json', { mcpServers: { duplicate: { command: '' }, added: { command: 'later' } } })
+ expect(agents.resolve(home)).toEqual([
+ { agent: 'claude-code', name: 'retained', transport: 'stdio', command: 'keep', args: undefined, env: undefined },
+ { agent: 'claude-code', name: 'added', transport: 'stdio', command: 'later', args: undefined, env: undefined },
+ ])
+ })
+
+ it('keeps equal server names from distinct agents in source order', () => {
+ writeConfig('.claude.json', { mcpServers: { shared: { command: 'claude' } } })
+ writeConfig('.cursor/mcp.json', { mcpServers: { shared: { command: 'cursor' } } })
+ writeConfig('.gemini/settings.json', { mcpServers: { shared: { command: 'gemini' } } })
+ expect(agents.resolve(home).map(({ agent, name, command }) => ({ agent, name, command }))).toEqual([
+ { agent: 'claude-code', name: 'shared', command: 'claude' },
+ { agent: 'cursor', name: 'shared', command: 'cursor' },
+ { agent: 'gemini', name: 'shared', command: 'gemini' },
+ ])
+ })
+
+ it.each(['.cursor/mcp.json', '.gemini/settings.json'])('ignores malformed JSON in %s', (file) => {
+ writeConfig(file, {})
+ writeFileSync(join(home, file), '{')
+ expect(agents.resolve(home)).toEqual([])
+ })
+
+ it.each(['.cursor/mcp.json', '.gemini/settings.json'])('ignores non-object mcpServers in %s', (file) => {
+ writeConfig(file, { mcpServers: 'invalid' })
+ expect(agents.resolve(home)).toEqual([])
+ })
+
+ it.each(['.cursor/mcp.json', '.gemini/settings.json'])('preserves the null-root rejection in %s', (file) => {
+ writeConfig(file, null)
+ expect(() => agents.resolve(home)).toThrow(TypeError)
+ })
+
+ it('continues past a null Claude root before reading its later file', () => {
+ writeConfig('.claude/settings.json', null)
+ writeConfig('.claude.json', { mcpServers: { valid: { command: 'later' } } })
+ expect(agents.resolve(home)).toEqual([
+ { agent: 'claude-code', name: 'valid', transport: 'stdio', command: 'later', args: undefined, env: undefined },
+ ])
+ })
+})
diff --git a/packages/dsh-tauri-extension/src/host/service/agents.ts b/packages/dsh-tauri-extension/src/host/service/agents.ts
index c48933e9..2f3c3530 100644
--- a/packages/dsh-tauri-extension/src/host/service/agents.ts
+++ b/packages/dsh-tauri-extension/src/host/service/agents.ts
@@ -19,7 +19,12 @@ const AGENT_SKILL_DIRECTORIES = ['.claude/skills', '.codex/skills'] as const
export const agents = defineService({
resolve(home: string = homedir()): ImportedServer[] {
return uniqBy(
- [...scanClaudeMcp(home), ...scanCodexMcp(home), ...scanCursorMcp(home), ...scanGeminiMcp(home)],
+ [
+ ...scanClaudeMcp(home),
+ ...scanCodexMcp(home),
+ ...scanJsonMcp(home, CURSOR_MCP_FILE, (name, entry) => mapMcpServersEntry('cursor', name, entry)),
+ ...scanJsonMcp(home, GEMINI_MCP_FILE, (name, entry) => mapAgentEntry('gemini', name, entry, 'httpUrl')),
+ ],
server => `${server.agent}/${server.name}`,
)
},
@@ -121,8 +126,8 @@ function scanClaudeMcp(home: string): ImportedServer[] {
return compact(Object.entries(merged).map(([name, entry]) => mapMcpServersEntry('claude-code', name, entry)))
}
-function scanCursorMcp(home: string): ImportedServer[] {
- const file = join(home, CURSOR_MCP_FILE)
+function scanJsonMcp(home: string, filename: string, mapEntry: (name: string, entry: unknown) => ImportedServer | null): ImportedServer[] {
+ const file = join(home, filename)
if (!existsSync(file))
return []
let parsed: { mcpServers?: unknown }
@@ -134,23 +139,7 @@ function scanCursorMcp(home: string): ImportedServer[] {
}
if (!isObject(parsed.mcpServers))
return []
- return compact(Object.entries(parsed.mcpServers).map(([name, entry]) => mapMcpServersEntry('cursor', name, entry)))
-}
-
-function scanGeminiMcp(home: string): ImportedServer[] {
- const file = join(home, GEMINI_MCP_FILE)
- if (!existsSync(file))
- return []
- let parsed: { mcpServers?: unknown }
- try {
- parsed = JSON.parse(readFileSync(file, 'utf8')) as { mcpServers?: unknown }
- }
- catch {
- return []
- }
- if (!isObject(parsed.mcpServers))
- return []
- return compact(Object.entries(parsed.mcpServers).map(([name, entry]) => mapAgentEntry('gemini', name, entry, 'httpUrl')))
+ return compact(Object.entries(parsed.mcpServers).map(([name, entry]) => mapEntry(name, entry)))
}
function scanCodexMcp(home: string): ImportedServer[] {
diff --git a/packages/dsh-tauri-extension/src/host/service/provider.types.ts b/packages/dsh-tauri-extension/src/host/service/provider.types.ts
index a4ee6ac5..a975a482 100644
--- a/packages/dsh-tauri-extension/src/host/service/provider.types.ts
+++ b/packages/dsh-tauri-extension/src/host/service/provider.types.ts
@@ -1,7 +1,6 @@
-export interface PlatformPluginLoader {
- import: (name: string) => Promise<unknown>
- unwrapExports: (exports: unknown) => unknown
-}
+import type { HostPluginLoader } from 'dsh-tauri'
+
+export interface PlatformPluginLoader extends HostPluginLoader {}
export interface FilesystemSkillPlugin {
name: string
diff --git a/packages/dsh-tauri-extension/src/host/service/provider.utils.test.ts b/packages/dsh-tauri-extension/src/host/service/provider.utils.test.ts
new file mode 100644
index 00000000..17999a60
--- /dev/null
+++ b/packages/dsh-tauri-extension/src/host/service/provider.utils.test.ts
@@ -0,0 +1,24 @@
+import type { HostPluginLoader } from 'dsh-tauri'
+import type { PlatformPluginLoader } from './provider.types'
+import { afterEach, describe, expect, expectTypeOf, it, vi } from 'vitest'
+import { loadFilesystemSkillPlugin } from './provider.utils'
+
+afterEach(() => vi.restoreAllMocks())
+
+describe('loadFilesystemSkillPlugin', () => {
+ it('accepts the host loader contract through its existing exported type name', async () => {
+ expectTypeOf<PlatformPluginLoader>().toEqualTypeOf<HostPluginLoader>()
+ const exports = { default: { name: 'filesystem', apply: vi.fn() } }
+ const loader: HostPluginLoader = { import: vi.fn().mockResolvedValue(exports), unwrapExports: vi.fn(() => exports.default) }
+ await expect(loadFilesystemSkillPlugin(loader)).resolves.toBe(exports.default)
+ expect(loader.import).toHaveBeenCalledExactlyOnceWith('@deepseek-ai/dsh-skill-filesystem')
+ expect(loader.unwrapExports).toHaveBeenCalledExactlyOnceWith(exports)
+ })
+
+ it('propagates import failures without trying to unwrap exports', async () => {
+ const error = new Error('missing filesystem plugin')
+ const loader: HostPluginLoader = { import: vi.fn().mockRejectedValue(error), unwrapExports: vi.fn() }
+ await expect(loadFilesystemSkillPlugin(loader)).rejects.toBe(error)
+ expect(loader.unwrapExports).not.toHaveBeenCalled()
+ })
+})
diff --git a/packages/dsh-tauri-ui/src/client/components/registry.test.ts b/packages/dsh-tauri-ui/src/client/components/registry.test.ts
new file mode 100644
index 00000000..ed992381
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/registry.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, it } from 'vitest'
+import { UI_COMPONENT_REGISTRY } from './registry'
+
+const reforks = [
+ ['Checkbox', 'default', 'ui-primitives', '0.1.7-rc.2', 'ui-primitives/src/Checkbox.tsx', 'checkbox'],
+ ['StateDot', 'dot', 'ui-primitives', '0.1.7-rc.2', 'ui-primitives/src/StateDot.module.css', 'dot'],
+ ['Button', 'elevated', 'ui-sidebar', 'both', 'ui-sidebar/src/client/SidebarRoot.module.css', 'newSession'],
+ ['Button', 'add', 'ui-plugin-manager', '0.1.7-rc.2', 'ui-plugin-manager/src/client/PluginManagerPage.module.css', 'addButton'],
+ ['Button', 'addGhost', 'ui-plugin-manager', '0.1.7-rc.2', 'ui-plugin-manager/src/client/PluginManagerPage.module.css', 'addButton'],
+ ['Button', 'danger', 'ui-plugin-manager', '0.1.7-rc.2', 'ui-plugin-manager/src/client/PluginManagerPage.module.css', 'danger'],
+ ['Action', 'search', 'ui-workspace', 'both', 'ui-workspace/src/client/rows/WorkspaceBrowser.module.css', 'searchButton'],
+ ['Action', 'toolbar', 'ui-plugin-manager', '0.1.7-rc.2', 'ui-plugin-manager/src/client/PluginManagerPage.module.css', 'iconButton'],
+ ['Action', 'model', 'ui-settings-models', 'both', 'ui-settings-models/src/client/ModelsSection.module.css', 'iconButton'],
+ ['Action', 'round', 'ui-sidebar', 'both', 'ui-sidebar/src/client/SidebarRoot.module.css', 'iconButton'],
+ ['Action', 'row', 'ui-workspace', 'both', 'ui-workspace/src/client/rows/Rows.module.css', 'iconButton'],
+ ['Action', 'help', 'ui-primitives', '0.1.7-rc.2', 'ui-primitives/src/settings-form/fields.module.css', 'helpButton'],
+ ['Action', 'action', 'ui-chat', 'both', 'ui-chat/src/client/chat/MessageIconActions.module.css', 'action'],
+ ['Chip', 'seat', 'ui-agent-preset', 'both', 'ui-agent-preset/src/client/AgentPresetSeat.module.css', 'seat'],
+ ['Chip', 'composerTrigger', 'ui-permission-presets', '0.1.7-rc.2', 'ui-permission-presets/src/client/PermissionSelect.module.css', 'trigger'],
+ ['Chip', 'selector', 'ui-permission-presets', 'both', 'ui-permission-presets/src/client/PermissionRow.module.css', 'selector'],
+ ['ConversationBar', 'bar', 'ui-goal', 'both', 'ui-goal/src/client/GoalBar.module.css', 'bar'],
+ ['ConversationBar', 'action', 'ui-goal', 'both', 'ui-goal/src/client/GoalBar.module.css', 'iconBtn'],
+ ['Tag', 'version', 'ui-plugin-manager', '0.1.7-rc.2', 'ui-plugin-manager/src/client/PluginManagerPage.module.css', 'versionTag'],
+ ['Tag', 'status', 'ui-plugin-manager', '0.1.7-rc.2', 'ui-plugin-manager/src/client/PluginManagerPage.module.css', 'statusTag'],
+]
+
+describe('ui component registry', () => {
+ it('preserves the refork ordering and upstream metadata', () => {
+ const rows = UI_COMPONENT_REGISTRY.filter(entry => entry.source.kind === 'refork')
+ expect(rows.map(({ source }) => [
+ source.component,
+ source.variant,
+ source.package.replace('@deepseek-ai/dsh-client-', ''),
+ source.availableAt.length === 2 ? 'both' : source.availableAt[0],
+ source.upstreamPath.replace('packages/client/', ''),
+ source.mappedClass,
+ ])).toEqual(reforks)
+ expect(rows.every(entry => entry.source.version === '0.1.7-rc.2')).toBe(true)
+ expect(rows.map(entry => entry.id)).toEqual([
+ 'checkbox-default',
+ 'state-dot-dot',
+ 'button-elevated',
+ 'button-add',
+ 'button-add-ghost',
+ 'button-danger',
+ 'action-search',
+ 'action-toolbar',
+ 'action-model',
+ 'action-round',
+ 'action-row',
+ 'action-help',
+ 'action-action',
+ 'chip-seat',
+ 'chip-composer-trigger',
+ 'chip-selector',
+ 'conversation-bar-bar',
+ 'conversation-bar-action',
+ 'tag-version',
+ 'tag-status',
+ ])
+ expect(UI_COMPONENT_REGISTRY).toHaveLength(48)
+ })
+})
diff --git a/packages/dsh-tauri-ui/src/client/components/registry.ts b/packages/dsh-tauri-ui/src/client/components/registry.ts
index 172dfea7..17377a51 100644
--- a/packages/dsh-tauri-ui/src/client/components/registry.ts
+++ b/packages/dsh-tauri-ui/src/client/components/registry.ts
@@ -42,7 +42,10 @@ function primitives(component: string, file: string): UiComponentEntry {
function reforkVariant(
component: string,
variant: string,
- source: Omit<UiComponentSource, 'kind' | 'component' | 'variant' | 'version'>,
+ packageName: string,
+ availableAt: readonly string[],
+ upstreamPath: string,
+ mappedClass: string,
): UiComponentEntry {
return {
id: `${slug(component)}-${slug(variant)}`,
@@ -52,7 +55,10 @@ function reforkVariant(
component,
variant,
version: VERSION,
- ...source,
+ package: packageName,
+ availableAt,
+ upstreamPath,
+ mappedClass,
},
}
}
@@ -87,124 +93,24 @@ export const UI_COMPONENT_REGISTRY: readonly UiComponentEntry[] = [
primitives('FISH_LOGO_PATH', 'FishLogo'),
primitives('FISH_LOGO_VIEWBOX', 'FishLogo'),
- reforkVariant('Checkbox', 'default', {
- package: PRIMITIVES,
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-primitives/src/Checkbox.tsx',
- mappedClass: 'checkbox',
- }),
- reforkVariant('StateDot', 'dot', {
- package: PRIMITIVES,
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-primitives/src/StateDot.module.css',
- mappedClass: 'dot',
- }),
- reforkVariant('Button', 'elevated', {
- package: '@deepseek-ai/dsh-client-ui-sidebar',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-sidebar/src/client/SidebarRoot.module.css',
- mappedClass: 'newSession',
- }),
- reforkVariant('Button', 'add', {
- package: '@deepseek-ai/dsh-client-ui-plugin-manager',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
- mappedClass: 'addButton',
- }),
- reforkVariant('Button', 'addGhost', {
- package: '@deepseek-ai/dsh-client-ui-plugin-manager',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
- mappedClass: 'addButton',
- }),
- reforkVariant('Button', 'danger', {
- package: '@deepseek-ai/dsh-client-ui-plugin-manager',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
- mappedClass: 'danger',
- }),
- reforkVariant('Action', 'search', {
- package: '@deepseek-ai/dsh-client-ui-workspace',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.module.css',
- mappedClass: 'searchButton',
- }),
- reforkVariant('Action', 'toolbar', {
- package: '@deepseek-ai/dsh-client-ui-plugin-manager',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
- mappedClass: 'iconButton',
- }),
- reforkVariant('Action', 'model', {
- package: '@deepseek-ai/dsh-client-ui-settings-models',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-settings-models/src/client/ModelsSection.module.css',
- mappedClass: 'iconButton',
- }),
- reforkVariant('Action', 'round', {
- package: '@deepseek-ai/dsh-client-ui-sidebar',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-sidebar/src/client/SidebarRoot.module.css',
- mappedClass: 'iconButton',
- }),
- reforkVariant('Action', 'row', {
- package: '@deepseek-ai/dsh-client-ui-workspace',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-workspace/src/client/rows/Rows.module.css',
- mappedClass: 'iconButton',
- }),
- reforkVariant('Action', 'help', {
- package: PRIMITIVES,
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-primitives/src/settings-form/fields.module.css',
- mappedClass: 'helpButton',
- }),
- reforkVariant('Action', 'action', {
- package: '@deepseek-ai/dsh-client-ui-chat',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-chat/src/client/chat/MessageIconActions.module.css',
- mappedClass: 'action',
- }),
- reforkVariant('Chip', 'seat', {
- package: '@deepseek-ai/dsh-client-ui-agent-preset',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-agent-preset/src/client/AgentPresetSeat.module.css',
- mappedClass: 'seat',
- }),
- reforkVariant('Chip', 'composerTrigger', {
- package: '@deepseek-ai/dsh-client-ui-permission-presets',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-permission-presets/src/client/PermissionSelect.module.css',
- mappedClass: 'trigger',
- }),
- reforkVariant('Chip', 'selector', {
- package: '@deepseek-ai/dsh-client-ui-permission-presets',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-permission-presets/src/client/PermissionRow.module.css',
- mappedClass: 'selector',
- }),
- reforkVariant('ConversationBar', 'bar', {
- package: '@deepseek-ai/dsh-client-ui-goal',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-goal/src/client/GoalBar.module.css',
- mappedClass: 'bar',
- }),
- reforkVariant('ConversationBar', 'action', {
- package: '@deepseek-ai/dsh-client-ui-goal',
- availableAt: AVAILABLE_BOTH,
- upstreamPath: 'packages/client/ui-goal/src/client/GoalBar.module.css',
- mappedClass: 'iconBtn',
- }),
- reforkVariant('Tag', 'version', {
- package: '@deepseek-ai/dsh-client-ui-plugin-manager',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
- mappedClass: 'versionTag',
- }),
- reforkVariant('Tag', 'status', {
- package: '@deepseek-ai/dsh-client-ui-plugin-manager',
- availableAt: AVAILABLE_LATEST,
- upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
- mappedClass: 'statusTag',
- }),
+ reforkVariant('Checkbox', 'default', PRIMITIVES, AVAILABLE_LATEST, 'packages/client/ui-primitives/src/Checkbox.tsx', 'checkbox'),
+ reforkVariant('StateDot', 'dot', PRIMITIVES, AVAILABLE_LATEST, 'packages/client/ui-primitives/src/StateDot.module.css', 'dot'),
+ reforkVariant('Button', 'elevated', '@deepseek-ai/dsh-client-ui-sidebar', AVAILABLE_BOTH, 'packages/client/ui-sidebar/src/client/SidebarRoot.module.css', 'newSession'),
+ reforkVariant('Button', 'add', '@deepseek-ai/dsh-client-ui-plugin-manager', AVAILABLE_LATEST, 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css', 'addButton'),
+ reforkVariant('Button', 'addGhost', '@deepseek-ai/dsh-client-ui-plugin-manager', AVAILABLE_LATEST, 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css', 'addButton'),
+ reforkVariant('Button', 'danger', '@deepseek-ai/dsh-client-ui-plugin-manager', AVAILABLE_LATEST, 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css', 'danger'),
+ reforkVariant('Action', 'search', '@deepseek-ai/dsh-client-ui-workspace', AVAILABLE_BOTH, 'packages/client/ui-workspace/src/client/rows/WorkspaceBrowser.module.css', 'searchButton'),
+ reforkVariant('Action', 'toolbar', '@deepseek-ai/dsh-client-ui-plugin-manager', AVAILABLE_LATEST, 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css', 'iconButton'),
+ reforkVariant('Action', 'model', '@deepseek-ai/dsh-client-ui-settings-models', AVAILABLE_BOTH, 'packages/client/ui-settings-models/src/client/ModelsSection.module.css', 'iconButton'),
+ reforkVariant('Action', 'round', '@deepseek-ai/dsh-client-ui-sidebar', AVAILABLE_BOTH, 'packages/client/ui-sidebar/src/client/SidebarRoot.module.css', 'iconButton'),
+ reforkVariant('Action', 'row', '@deepseek-ai/dsh-client-ui-workspace', AVAILABLE_BOTH, 'packages/client/ui-workspace/src/client/rows/Rows.module.css', 'iconButton'),
+ reforkVariant('Action', 'help', PRIMITIVES, AVAILABLE_LATEST, 'packages/client/ui-primitives/src/settings-form/fields.module.css', 'helpButton'),
+ reforkVariant('Action', 'action', '@deepseek-ai/dsh-client-ui-chat', AVAILABLE_BOTH, 'packages/client/ui-chat/src/client/chat/MessageIconActions.module.css', 'action'),
+ reforkVariant('Chip', 'seat', '@deepseek-ai/dsh-client-ui-agent-preset', AVAILABLE_BOTH, 'packages/client/ui-agent-preset/src/client/AgentPresetSeat.module.css', 'seat'),
+ reforkVariant('Chip', 'composerTrigger', '@deepseek-ai/dsh-client-ui-permission-presets', AVAILABLE_LATEST, 'packages/client/ui-permission-presets/src/client/PermissionSelect.module.css', 'trigger'),
+ reforkVariant('Chip', 'selector', '@deepseek-ai/dsh-client-ui-permission-presets', AVAILABLE_BOTH, 'packages/client/ui-permission-presets/src/client/PermissionRow.module.css', 'selector'),
+ reforkVariant('ConversationBar', 'bar', '@deepseek-ai/dsh-client-ui-goal', AVAILABLE_BOTH, 'packages/client/ui-goal/src/client/GoalBar.module.css', 'bar'),
+ reforkVariant('ConversationBar', 'action', '@deepseek-ai/dsh-client-ui-goal', AVAILABLE_BOTH, 'packages/client/ui-goal/src/client/GoalBar.module.css', 'iconBtn'),
+ reforkVariant('Tag', 'version', '@deepseek-ai/dsh-client-ui-plugin-manager', AVAILABLE_LATEST, 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css', 'versionTag'),
+ reforkVariant('Tag', 'status', '@deepseek-ai/dsh-client-ui-plugin-manager', AVAILABLE_LATEST, 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css', 'statusTag'),
]
diff --git a/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.test.tsx b/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.test.tsx
new file mode 100644
index 00000000..025ca815
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.test.tsx
@@ -0,0 +1,45 @@
+// @vitest-environment jsdom
+import { cleanup, renderHook } from '@testing-library/react'
+import { StrictMode } from 'react'
+import { afterEach, describe, expect, it } from 'vitest'
+import { cssr } from '../utils/cssr'
+import { useMountStyle } from './use-mount-style'
+
+afterEach(cleanup)
+
+describe('useMountStyle', () => {
+ it('replaces the previous style when node, id or owner changes', () => {
+ const first = cssr.c('.first', { color: 'red' })
+ const second = cssr.c('.second', { color: 'blue' })
+ const view = renderHook(({ node, id, owner }) => useMountStyle(node, id, owner), {
+ initialProps: { node: first, id: 'first-style', owner: 'first-plugin' },
+ })
+ expect(document.querySelector('style[cssr-id="first-style"]')?.getAttribute('data-plugin')).toBe('first-plugin')
+ view.rerender({ node: second, id: 'second-style', owner: 'second-plugin' })
+ expect(document.querySelector('style[cssr-id="first-style"]')).toBeNull()
+ expect(document.querySelector('style[cssr-id="second-style"]')?.textContent).toContain('blue')
+ view.rerender({ node: second, id: 'second-style', owner: 'updated-plugin' })
+ expect(document.querySelector('style[cssr-id="second-style"]')?.getAttribute('data-plugin')).toBe('updated-plugin')
+ view.unmount()
+ expect(document.querySelector('style[cssr-id="second-style"]')).toBeNull()
+ })
+
+ it('keeps a shared style until the final consumer unmounts', () => {
+ const node = cssr.c('.shared', { color: 'green' })
+ const first = renderHook(() => useMountStyle(node, 'shared-style', 'test-plugin'))
+ const second = renderHook(() => useMountStyle(node, 'shared-style', 'test-plugin'))
+ expect(document.querySelectorAll('style[cssr-id="shared-style"]')).toHaveLength(1)
+ first.unmount()
+ expect(document.querySelectorAll('style[cssr-id="shared-style"]')).toHaveLength(1)
+ second.unmount()
+ expect(document.querySelector('style[cssr-id="shared-style"]')).toBeNull()
+ })
+
+ it('balances StrictMode setup and cleanup without leaving a style behind', () => {
+ const node = cssr.c('.strict', { color: 'black' })
+ const view = renderHook(() => useMountStyle(node, 'strict-style'), { wrapper: StrictMode })
+ expect(document.querySelectorAll('style[cssr-id="strict-style"]')).toHaveLength(1)
+ view.unmount()
+ expect(document.querySelector('style[cssr-id="strict-style"]')).toBeNull()
+ })
+})
diff --git a/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts b/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts
index 3ea969c5..07028f56 100644
--- a/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts
+++ b/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts
@@ -1,14 +1,8 @@
import type { CNode } from 'css-render'
-import { useEffect, useRef } from 'react'
+import { useEffect } from 'react'
import { mountStyle } from '../utils/style'
export function useMountStyle(cnode: CNode, id?: string, owner?: string): void {
- const disposerRef = useRef<(() => void) | null>(null)
- useEffect(() => {
- disposerRef.current = mountStyle(cnode, id, owner)
- return () => {
- disposerRef.current?.()
- disposerRef.current = null
- }
- }, [cnode, id, owner])
+ // keep:effect cssr 挂载是外部资源,随 React 生命周期释放。
+ useEffect(() => mountStyle(cnode, id, owner), [cnode, id, owner])
}
diff --git a/packages/dsh-tauri-ui/src/client/register/new-session.test.ts b/packages/dsh-tauri-ui/src/client/register/new-session.test.ts
index 6fb6d577..38e23415 100644
--- a/packages/dsh-tauri-ui/src/client/register/new-session.test.ts
+++ b/packages/dsh-tauri-ui/src/client/register/new-session.test.ts
@@ -118,6 +118,37 @@ afterEach(() => {
})
describe('sidebarNewSessionFeature', () => {
+ it('rechecks composer capability on each click after a previous fallback', () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
+ mocks.composerWorkspaceLess = false
+ const dispose = sidebarNewSessionFeature.call(ctx)
+ const controller = mocks.controller as ControllerStub
+ controller.click(clickEvent(buttonTarget('新建会话')))
+ mocks.composerWorkspaceLess = true
+ const event = clickEvent(buttonTarget('新建会话'))
+ controller.click(event)
+ expect(event.preventDefault).toHaveBeenCalledTimes(1)
+ expect(event.stopImmediatePropagation).toHaveBeenCalledTimes(1)
+ expect(mocks.startUngroupedSession).toHaveBeenCalledTimes(1)
+ expect(warn).toHaveBeenCalledTimes(1)
+ dispose()
+ })
+
+ it('keeps warning suppression local to each registration', () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
+ mocks.composerWorkspaceLess = false
+ const first = sidebarNewSessionFeature.call(ctx)
+ const firstController = mocks.controller as ControllerStub
+ const second = sidebarNewSessionFeature.call(ctx)
+ const secondController = mocks.controller as ControllerStub
+ firstController.click(clickEvent(buttonTarget('新建会话')))
+ firstController.click(clickEvent(buttonTarget('新建会话')))
+ secondController.click(clickEvent(buttonTarget('新建会话')))
+ expect(warn).toHaveBeenCalledTimes(2)
+ first()
+ second()
+ })
+
it('捕获阶段吞掉官方「新建会话」点击并改走未分组新建', () => {
const dispose = sidebarNewSessionFeature.call(ctx)
const controller = mocks.controller as ControllerStub
diff --git a/packages/dsh-tauri-ui/src/client/register/new-session.ts b/packages/dsh-tauri-ui/src/client/register/new-session.ts
index 295bac52..9176abf0 100644
--- a/packages/dsh-tauri-ui/src/client/register/new-session.ts
+++ b/packages/dsh-tauri-ui/src/client/register/new-session.ts
@@ -4,63 +4,35 @@ import { PLUGIN_ID } from '../../shared/constants'
import { startUngroupedSession } from '../service/ungrouped-session'
import { newSessionButtonFrom, ungroupedCreateButtonFrom } from './new-session.utils'
-/**
- * 官方侧边栏「新建会话」默认落到未分组:官方 onClick 挂在 React 根容器上,document 捕获阶段的
- * 监听先于它执行,`stopImmediatePropagation()` 即可让官方的 `startSession()` 分支整条不跑。
- *
- * 能力探测在**点击时**做(不是装配时):composer 补丁的能力标记由官方 conversation 产物在
- * 求值时写下,装配顺序不保证它已经到位。缺补丁时放行官方分支(退级第 4 级),只告警一次。
- */
-export const sidebarNewSessionFeature = defineRegister<ClientContext>((controller, ctx, adapter) => {
- if (typeof document === 'undefined')
- return
-
- let warned = false
-
- controller.listen('click', (event) => {
- if (newSessionButtonFrom(event.target) === null)
- return
- if (!adapter.has('composer.workspace-less')) {
- if (!warned) {
- warned = true
- console.warn(
- `[${PLUGIN_ID}] 「未分组」新建会话不可用:缺少桌面壳 composer 补丁(composer.workspace-less),沿用官方工作区选择。`,
- )
- }
+function newSessionFeature(matcher: (target: unknown) => Element | null, warnText: string) {
+ return defineRegister<ClientContext>((controller, ctx, adapter) => {
+ if (typeof document === 'undefined')
return
- }
- event.preventDefault()
- event.stopImmediatePropagation()
- startUngroupedSession(ctx, adapter)
- }, { capture: true })
-})
-/**
- * 官方「未分组」分组行的「+」在未分组桶里是空实现(`group.workspaceId === undefined`),
- * 点击没有任何效果。这里按与侧边栏「新建会话」完全相同的路径接管:切到会话并选中「未分组」。
- *
- * 能力探测同样在**点击时**做,缺补丁时放行官方分支(即空实现),只告警一次。
- */
-export const ungroupedNewSessionFeature = defineRegister<ClientContext>((controller, ctx, adapter) => {
- if (typeof document === 'undefined')
- return
+ let warned = false
+ controller.listen('click', (event) => {
+ if (matcher(event.target) === null)
+ return
+ if (!adapter.has('composer.workspace-less')) {
+ if (!warned) {
+ warned = true
+ console.warn(warnText)
+ }
+ return
+ }
+ event.preventDefault()
+ event.stopImmediatePropagation()
+ startUngroupedSession(ctx, adapter)
+ }, { capture: true })
+ })
+}
- let warned = false
+export const sidebarNewSessionFeature = newSessionFeature(
+ newSessionButtonFrom,
+ `[${PLUGIN_ID}] 「未分组」新建会话不可用:缺少桌面壳 composer 补丁(composer.workspace-less),沿用官方工作区选择。`,
+)
- controller.listen('click', (event) => {
- if (ungroupedCreateButtonFrom(event.target) === null)
- return
- if (!adapter.has('composer.workspace-less')) {
- if (!warned) {
- warned = true
- console.warn(
- `[${PLUGIN_ID}] 「未分组」分组行新建会话不可用:缺少桌面壳 composer 补丁(composer.workspace-less),沿用官方行为。`,
- )
- }
- return
- }
- event.preventDefault()
- event.stopImmediatePropagation()
- startUngroupedSession(ctx, adapter)
- }, { capture: true })
-})
+export const ungroupedNewSessionFeature = newSessionFeature(
+ ungroupedCreateButtonFrom,
+ `[${PLUGIN_ID}] 「未分组」分组行新建会话不可用:缺少桌面壳 composer 补丁(composer.workspace-less),沿用官方行为。`,
+)
diff --git a/packages/dsh-tauri-ui/src/host/types/index.ts b/packages/dsh-tauri-ui/src/host/types/index.ts
index 5dd44396..f01d11ae 100644
--- a/packages/dsh-tauri-ui/src/host/types/index.ts
+++ b/packages/dsh-tauri-ui/src/host/types/index.ts
@@ -1,11 +1,10 @@
+import type { HostPluginLoader } from 'dsh-tauri'
+
export type HostContext = any
export type SessionResumeOutcome = { ok: true } | { ok: false, code: number, error: string }
-export interface PlatformModuleLoader {
- import: (name: string) => Promise<unknown>
- unwrapExports: (exports: unknown) => unknown
-}
+export interface PlatformModuleLoader extends HostPluginLoader {}
export interface SessionResumeResponse {
ok?: boolean
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1a6a5ee5..6fe44a2e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -739,9 +739,6 @@ importers:
specifier: catalog:testing
version: 2.9.0
devDependencies:
- '@deepseek-ai/cordis':
- specifier: catalog:dsh
- version: 4.0.4(@deepseek-ai/[email protected])(@deepseek-ai/[email protected])
'@deepseek-ai/dsh-skill-filesystem':
specifier: catalog:dsh
version: 0.2.0-rc.2(@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))))(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))(@deepseek-ai/[email protected](@deepseek-ai/[email protected])(@deepseek-ai/[email protected](@deepseek-ai/[email protected]))))