Skip to content

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

feat(ssh-ui): 同步到远端侧边栏面板与 UX 打磨

Menghuan1918df87879df7d9
diff --git a/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx b/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx
index 5f1af11a..5996a375 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx
+++ b/packages/dsh-tauri-ssh-ui/src/client/components/machines-section.tsx
@@ -6,7 +6,6 @@ import { Button, Input, Modal, StateDot } from '@deepseek-ai/dsh-client-ui-primi
import { useEffect, useState, useSyncExternalStore } from 'react'
import { cls } from '../styles/index'
import { retrySecondsOf } from '../utils/retry'
-import { SyncPanel } from './sync-panel'
/** New-machine form defaults (ssh-ui 既有默认:SSH 22 / 远端 web 3080)。 */
const DEFAULT_PORT = 22
@@ -1013,7 +1012,6 @@ export function MachinesSection({ t, store, bridge }: MachinesSectionProps): Rea
</>
)
: null}
- <SyncPanel store={store} t={t} />
</>
)}
{addOpen
diff --git a/packages/dsh-tauri-ssh-ui/src/client/components/sync-panel.tsx b/packages/dsh-tauri-ssh-ui/src/client/components/sync-panel.tsx
index 2f2d6f92..c4f01203 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/components/sync-panel.tsx
+++ b/packages/dsh-tauri-ssh-ui/src/client/components/sync-panel.tsx
@@ -24,10 +24,12 @@ import { cls } from '../styles'
export interface SyncPanelProps {
store: MachinesStore
t: (key: SshKey) => string
+ /** 侧边栏面板内嵌形态:隐藏大标题/说明(面板标签已表意)。 */
+ embedded?: boolean
}
/** Render the sync panel over the store snapshot. */
-export function SyncPanel({ store, t }: SyncPanelProps): ReactNode {
+export function SyncPanel({ store, t, embedded = false }: SyncPanelProps): ReactNode {
const state = useSyncExternalStore(store.subscribe, store.getSnapshot)
const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set())
const [targetId, setTargetId] = useState<string | null>(null)
@@ -52,10 +54,10 @@ export function SyncPanel({ store, t }: SyncPanelProps): ReactNode {
return (
<section className={cls.syncPanel} data-testid="sync-panel">
- <h3 className={cls.groupTitle}>{t('sync.title')}</h3>
- <p className={cls.groupHint}>{t('sync.desc')}</p>
+ {embedded ? null : <h3 className={cls.groupTitle}>{t('sync.title')}</h3>}
+ {embedded ? null : <p className={cls.groupHint}>{t('sync.desc')}</p>}
{connected.length === 0
- ? <p className={cls.hint}>{t('sync.notConnected')}</p>
+ ? <p className={cls.hint}>{t('sync.notConnectedHint')}</p>
: (
<>
<div className={cls.syncTargets}>
diff --git a/packages/dsh-tauri-ssh-ui/src/client/index.test.ts b/packages/dsh-tauri-ssh-ui/src/client/index.test.ts
index 398846e5..7815b522 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/index.test.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/index.test.ts
@@ -10,7 +10,11 @@ import { MachinesStore } from './store/index'
// The desktop invoke bridge resolves through the runtime module table, which
// does not exist under vitest; the registrant tests only need its shape.
// (vitest hoists vi.mock above the imports, so placement here is safe.)
-vi.mock('dsh-tauri/client', () => ({ invoke: vi.fn(async () => undefined) }))
+vi.mock('dsh-tauri/client', () => ({
+ invoke: vi.fn(async () => undefined),
+ defineRegister: (feature: (controller: unknown) => void) => feature,
+ definePanel: (_ctx: unknown, entry: { id: string }) => ({ id: entry.id, dispose: () => {} }),
+}))
// dsh-tauri-ui/client 的 dist bundle 以 ModuleLoader 工厂包裹,脱离宿主加载器
// 无法在 node 求值;样式挂载只需要一个可观察的 mountStyle 桩,cssr 用源文件
@@ -50,13 +54,13 @@ describe('ui-ssh client plugin', () => {
})
it('declares its inject topology', () => {
- expect(inject).toEqual(['slots', 'locale'])
+ expect(inject).toEqual(['slots', 'locale', 'layout'])
})
it('registers the ssh dictionaries on activation', () => {
const { ctx, locale, effects } = scriptedCtx()
apply(ctx)
- expect(effects).toHaveLength(2)
+ expect(effects).toHaveLength(3)
effects[0]?.()
expect(locale.register).toHaveBeenCalledWith('ssh', { zh, en })
expect(locale.bind).toHaveBeenCalledWith('ssh')
diff --git a/packages/dsh-tauri-ssh-ui/src/client/index.ts b/packages/dsh-tauri-ssh-ui/src/client/index.ts
index fa8869f9..04535c61 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/index.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/index.ts
@@ -13,12 +13,13 @@ import { mountStyle } from 'dsh-tauri-ui/client'
import { MachinesSection } from './components/machines-section'
import { SETTINGS_SECTION_ID, SETTINGS_SECTION_ORDER, SETTINGS_SECTION_SLOT, SSH_LOCALE_NS } from './constants'
import { en, zh } from './locales'
+import { syncPanelFeature } from './register/sync-panel'
import { desktopBridge } from './service/bridge'
import { MachinesStore } from './store'
import { SSH_STYLE_ID, sshStyle } from './styles'
/** Required services: the settings slot seam and the locale seat. */
-export const inject = ['slots', 'locale']
+export const inject = ['slots', 'locale', 'layout']
/**
* Register the `ssh` dictionaries and the settings section, each once its
@@ -30,6 +31,7 @@ export function apply(ctx: UiContext): void {
ctx.effect(() => mountStyle(sshStyle, SSH_STYLE_ID), 'dsh-tauri-ssh-ui: styles')
const t = ctx.locale.bind(SSH_LOCALE_NS)
const store = new MachinesStore((url, init) => fetch(url, init))
+ ctx.effect(syncPanelFeature(store, t), 'dsh-tauri-ssh-ui: sync panel')
ctx.slots.inject(SETTINGS_SECTION_SLOT, () => ctx.slots.register({
name: SETTINGS_SECTION_SLOT,
id: SETTINGS_SECTION_ID,
diff --git a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts b/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
index 2812407c..0f1a84ee 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
@@ -32,6 +32,8 @@ export const zh = {
'field.port': '端口',
'field.user': '用户(可选)',
'session.remoteTitle': '目前正在 SSH 中',
+ 'sync.panelLabel': '同步到远端',
+ 'sync.notConnectedHint': '还没有已连接的机器——先在「SSH 远程机器」里连接一台,即可把插件和 Skill 同步过去。',
'session.remoteHintNamed': '此实例正通过 SSH 来自 {name} 的连接使用——机器管理请在发起 SSH 连接的机器上配置。',
'session.remoteHint': '此实例正通过 SSH 远程连接使用——机器管理请在发起 SSH 连接的机器上配置。',
'field.remotePort': '远端端口',
@@ -60,7 +62,6 @@ export const zh = {
'bridge.error': '打开远端窗口失败:',
'sync.title': '同步到远端',
'sync.desc': '把本机已安装的插件与用户级 skills 同步到已连接的机器:插件在远端执行 dsh plugin add;skills 经 tar 流式复制到远端 ~/.dsh/skills。可多选。',
- 'sync.notConnected': '没有已连接的机器。先连接一台,再回来同步。',
'sync.target': '目标机器:',
'sync.plugins': '插件',
'sync.skills': 'Skills',
@@ -135,6 +136,8 @@ export const en = {
'field.port': 'Port',
'field.user': 'User (optional)',
'session.remoteTitle': 'Currently in an SSH session',
+ 'sync.panelLabel': 'Sync to remote',
+ 'sync.notConnectedHint': 'No connected machines yet — connect one under “SSH machines” first, then sync plugins and skills to it.',
'session.remoteHintNamed': 'This instance is in use over SSH from {name} — manage machines on the machine that initiated the SSH connection.',
'session.remoteHint': 'This instance is in use over SSH — manage machines on the machine that initiated the SSH connection.',
'field.remotePort': 'Remote port',
@@ -163,7 +166,6 @@ export const en = {
'bridge.error': 'Failed to open the remote window: ',
'sync.title': 'Sync to remote',
'sync.desc': 'Copy this machine\'s installed plugins and user-level skills to a connected machine: plugins install remotely via dsh plugin add; skills stream as a tar into the remote ~/.dsh/skills. Multi-select.',
- 'sync.notConnected': 'No connected machines. Connect one first, then come back to sync.',
'sync.target': 'Target machine: ',
'sync.plugins': 'Plugins',
'sync.skills': 'Skills',
diff --git a/packages/dsh-tauri-ssh-ui/src/client/register/sync-panel.test.tsx b/packages/dsh-tauri-ssh-ui/src/client/register/sync-panel.test.tsx
new file mode 100644
index 00000000..7e6ef59c
--- /dev/null
+++ b/packages/dsh-tauri-ssh-ui/src/client/register/sync-panel.test.tsx
@@ -0,0 +1,26 @@
+import type { MachinesStore } from '../store/index'
+import { describe, expect, it, vi } from 'vitest'
+import { SYNC_PANEL_ID, syncPanelFeature } from './sync-panel'
+
+const mocks = vi.hoisted(() => ({
+ definePanel: vi.fn((_ctx: unknown, _entry: unknown) => ({ dispose: () => {} })),
+}))
+
+vi.mock('dsh-tauri/client', () => ({
+ defineRegister: (feature: (...args: never[]) => void) => feature,
+ definePanel: mocks.definePanel,
+}))
+
+describe('syncPanelFeature', () => {
+ it('registers the sidebar panel with an embedded SyncPanel render', () => {
+ const store = { subscribe: () => () => {}, getSnapshot: () => ({}) } as unknown as MachinesStore
+ const feature = syncPanelFeature(store, key => key)
+ const controller = { add: vi.fn() }
+ ;(feature as (controller: unknown, ctx: unknown) => void)(controller, {})
+ expect(controller.add).toHaveBeenCalledOnce()
+ const entry = mocks.definePanel.mock.calls[0]?.[1] as unknown as { id: string, render: () => unknown }
+ expect(entry.id).toBe(SYNC_PANEL_ID)
+ expect(typeof entry.render).toBe('function')
+ mocks.definePanel.mockClear()
+ })
+})
diff --git a/packages/dsh-tauri-ssh-ui/src/client/register/sync-panel.tsx b/packages/dsh-tauri-ssh-ui/src/client/register/sync-panel.tsx
new file mode 100644
index 00000000..3ad7d4f1
--- /dev/null
+++ b/packages/dsh-tauri-ssh-ui/src/client/register/sync-panel.tsx
@@ -0,0 +1,44 @@
+import type { ClientContext } from 'dsh-tauri/client'
+import type { SshKey } from '../locales/index'
+import type { MachinesStore } from '../store/index'
+import { definePanel, defineRegister } from 'dsh-tauri/client'
+import { SyncPanel } from '../components/sync-panel'
+
+export const SYNC_PANEL_ID = 'dsh-tauri-ssh-sync'
+export const SYNC_PANEL_ORDER = 45
+
+/**
+ * dsh 主侧边栏的「同步到远端」面板:definePanel 注册 sidebar.panellist 图标与
+ * main 槽内容,一处点击直达插件/Skill 同步(原先埋在设置页机器列表尾部)。
+ */
+export function syncPanelFeature(store: MachinesStore, t: (key: SshKey) => string) {
+ return defineRegister<ClientContext>((controller, ctx) => {
+ if (typeof window === 'undefined' || window.parent === window)
+ return
+ controller.add(
+ definePanel(ctx, {
+ id: SYNC_PANEL_ID,
+ order: SYNC_PANEL_ORDER,
+ label: () => t('sync.panelLabel'),
+ icon: ({ size, active }) => (
+ <svg
+ aria-hidden="true"
+ fill="none"
+ height={size}
+ stroke={active ? 'currentColor' : 'currentColor'}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1.6"
+ viewBox="0 0 16 16"
+ width={size}
+ >
+ <path d="M8 13V3" />
+ <path d="m3.5 7.5 4.5-4.5 4.5 4.5" />
+ <path d="M2.5 13.5h11" />
+ </svg>
+ ),
+ render: () => <SyncPanel embedded store={store} t={t} />,
+ }).dispose,
+ )
+ })
+}