Skip to content

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

fix(dsh-tauri-ui): 设置深链读平铺的 section——此前读错层级,定位静默失效

Menghuan191808a157c83084
diff --git a/packages/dsh-tauri-ui/src/client/register/settings-open.test.ts b/packages/dsh-tauri-ui/src/client/register/settings-open.test.ts
index 34717ac5..cc1724ac 100644
--- a/packages/dsh-tauri-ui/src/client/register/settings-open.test.ts
+++ b/packages/dsh-tauri-ui/src/client/register/settings-open.test.ts
@@ -24,23 +24,26 @@ describe('registerSettingsOpen', () => {
it('opens the settings overlay at the requested section on the host message', () => {
mocks.listenParent.mockImplementation((handler: (message: unknown) => void, types: unknown) => {
expect(types).toBe(SETTINGS_OPEN_MESSAGE)
- handler({ payload: { section: 'dsh-tauri-ssh' } })
+ handler({ type: SETTINGS_OPEN_MESSAGE, section: 'dsh-tauri-ssh-sync' })
return () => {}
})
const controller = { add: vi.fn() }
;(registerSettingsOpen as (controller: unknown) => void)(controller)
expect(mocks.listenParent).toHaveBeenCalledOnce()
- expect(mocks.openAt).toHaveBeenCalledWith('dsh-tauri-ssh')
+ expect(mocks.openAt).toHaveBeenCalledWith('dsh-tauri-ssh-sync')
})
it('ignores non-string sections and opens without a target', () => {
mocks.listenParent.mockImplementation((handler: (message: unknown) => void) => {
- handler({ payload: { section: 42 } })
- handler({})
+ handler({ type: SETTINGS_OPEN_MESSAGE, section: 42 })
+ handler({ type: SETTINGS_OPEN_MESSAGE })
+ // 旧形状(payload 包装)不再被识别:层级读错就是静默失效的根因
+ handler({ type: SETTINGS_OPEN_MESSAGE, payload: { section: 'dsh-tauri-ssh' } })
return () => {}
})
;(registerSettingsOpen as (controller: unknown) => void)({ add: vi.fn() })
expect(mocks.openAt).toHaveBeenNthCalledWith(1, undefined)
expect(mocks.openAt).toHaveBeenNthCalledWith(2, undefined)
+ expect(mocks.openAt).toHaveBeenNthCalledWith(3, undefined)
})
})
diff --git a/packages/dsh-tauri-ui/src/client/register/settings-open.ts b/packages/dsh-tauri-ui/src/client/register/settings-open.ts
index 305e0175..37ce1719 100644
--- a/packages/dsh-tauri-ui/src/client/register/settings-open.ts
+++ b/packages/dsh-tauri-ui/src/client/register/settings-open.ts
@@ -5,13 +5,17 @@ import { settings } from '../store/modules/settings'
export const SETTINGS_OPEN_MESSAGE = 'dsh://settings:open'
/**
- * 壳层 deep-link:宿主窗口 postMessage `dsh://settings:open`(payload
- * `{ section }`,可省略)→ 打开设置浮层并定位到对应分区。桌面壳的
- * 「管理机器」等入口经此直达插件的设置分区,替代壳内重复管理面板。
+ * 壳层 deep-link:宿主窗口 postMessage `dsh://settings:open`(`{ type, section }`,
+ * section 可省略)→ 打开设置浮层并定位到对应分区。桌面壳的「管理机器」「同步到
+ * 远端」等入口经此直达插件的设置分区,替代壳内重复管理面板。
+ *
+ * 消息体按宿主 → iframe 的既有约定平铺字段(同 `dsh://n` 的 `{ type,
+ * sessionId }`),**不是** `{ payload: { section } }`——读错层级会让定位静默
+ * 失效(浮层照开,但停在默认分区)。
*/
export const registerSettingsOpen = defineRegister<ClientContext>((controller) => {
controller.add(listenParent((message) => {
- const section = (message.payload as { section?: unknown } | undefined)?.section
+ const section = message.section
settings.openAt(typeof section === 'string' && section !== '' ? section : undefined)
}, SETTINGS_OPEN_MESSAGE))
})