Skip to content

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

feat(ssh-ui+shell): 打磨集——探测不回退连接态、notice 本地化、脏态高亮、桥探测不闪现、切换器 pending 反馈

Menghuan19188713baf3ff19
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 b85f7f3e..617c33cf 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/locales/index.ts
@@ -23,9 +23,8 @@ export const zh = {
'secret.unset': '未设置',
'error.banner': '错误:',
'loadFailed': '面板数据加载失败。',
- 'notice.testOk': '连接正常:',
- 'notice.disconnected': '已断开。',
- 'notice.connected': '已连接:',
+ 'notice.connected': '已连接:{url}',
+ 'notice.disconnected': '已断开',
'field.id': 'ID',
'field.name': '名称',
'field.host': '主机(或 config 别名)',
@@ -71,6 +70,9 @@ export const zh = {
'progress.handshake': '正在建立 SSH 连接…',
'progress.starting': '正在启动远端实例…',
'progress.probing': '健康检查 {attempt}/{total}…',
+ 'open.probing': '正在探测桌面环境…',
+ 'notice.probe_ok': '探测通过',
+ 'notice.probe_failed': '探测失败',
'progress.installing': '正在安装 dsh(下载并校验官方打包运行时,通常 1–3 分钟)…',
'install.action': '一键安装 dsh',
'install.hint': '远端未检测到 dsh。将下载官方打包运行时(Node + DSH,版本钉定 + SHA-256 校验)并部署到远端 ~/.dsh-desktop;如需使用自己的发行仓,请在插件配置中设置 installRepo。安装完成后自动连接。',
@@ -105,9 +107,8 @@ export const en = {
'secret.unset': 'not set',
'error.banner': 'Error: ',
'loadFailed': 'The panel failed to load.',
- 'notice.testOk': 'Probe ok: ',
- 'notice.disconnected': 'Disconnected.',
- 'notice.connected': 'Connected: ',
+ 'notice.connected': 'Connected: {url}',
+ 'notice.disconnected': 'Disconnected',
'field.id': 'ID',
'field.name': 'Name',
'field.host': 'Host or config alias',
@@ -153,6 +154,9 @@ export const en = {
'progress.handshake': 'Connecting over SSH…',
'progress.starting': 'Starting the remote instance…',
'progress.probing': 'Health check {attempt}/{total}…',
+ 'open.probing': 'Probing the desktop bridge…',
+ 'notice.probe_ok': 'Probe passed',
+ 'notice.probe_failed': 'Probe failed',
'progress.installing': 'Installing dsh (downloading and verifying the official packaged runtime, usually 1–3 min)…',
'install.action': 'Install dsh',
'install.hint': 'No dsh found on the remote. This downloads the official packaged runtime (Node + DSH, version-pinned and SHA-256 verified) and deploys it to ~/.dsh-desktop on the remote; set installRepo in the plugin config to use your own release repository. Auto-connects when done.',
diff --git a/packages/dsh-tauri-ssh-ui/src/client/store/index.test.ts b/packages/dsh-tauri-ssh-ui/src/client/store/index.test.ts
index c2a5d0ec..3d5e11a4 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/store/index.test.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/store/index.test.ts
@@ -235,7 +235,7 @@ describe('machinesStore', () => {
fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { ok: true, banner: 'Linux alpha' } }) } as unknown as Response)
await store.test('a')
const state = store.getSnapshot()
- expect(state.notice).toBe('Linux alpha')
+ expect(state.notice).toEqual({ kind: 'text', text: 'Linux alpha' })
expect(state.busy).toEqual({})
const [, init] = fetchFn.mock.calls[1] as [string, RequestInit]
expect(JSON.parse(String(init.body))).toEqual({ method: 'machine.test', payload: { machineId: 'a' } })
@@ -246,11 +246,11 @@ describe('machinesStore', () => {
await store.load()
fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { ok: true } }) } as unknown as Response)
await store.test('a')
- expect(store.getSnapshot().notice).toBe('ok')
+ expect(store.getSnapshot().notice).toEqual({ kind: 'key', key: 'notice.probe_ok' })
fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { ok: false } }) } as unknown as Response)
await store.test('a')
const state = store.getSnapshot()
- expect(state.notice).toBe('failed')
+ expect(state.notice).toEqual({ kind: 'key', key: 'notice.probe_failed' })
expect(state.statuses.a).toEqual({ state: 'disconnected', lastError: 'failed' })
})
@@ -260,10 +260,27 @@ describe('machinesStore', () => {
fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { ok: false, message: 'auth failed' } }) } as unknown as Response)
await store.test('a')
const state = store.getSnapshot()
- expect(state.notice).toBe('auth failed')
+ expect(state.notice).toEqual({ kind: 'text', text: 'auth failed' })
expect(state.statuses.a).toEqual({ state: 'disconnected', lastError: 'auth failed' })
})
+ it('never downgrades a live connection after a probe (regression)', async () => {
+ // 探测是旁路健康检查,不触碰连接面:已连接的机器被点「测试」后必须
+ // 保持 connected/tunnelBaseUrl,否则 UI 会把一条活连接显示成断开。
+ const { store, fetchFn } = boot()
+ await store.load()
+ fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { tunnelBaseUrl: 'http://127.0.0.1:49152' } }) } as unknown as Response)
+ await store.connect('a')
+ fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { ok: true, banner: 'Linux alpha' } }) } as unknown as Response)
+ await store.test('a')
+ expect(store.getSnapshot().statuses.a).toEqual({ state: 'connected', tunnelBaseUrl: 'http://127.0.0.1:49152' })
+ fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: { ok: false, message: 'auth failed' } }) } as unknown as Response)
+ await store.test('a')
+ const state = store.getSnapshot()
+ expect(state.statuses.a?.state).toBe('connected')
+ expect(state.statuses.a?.lastError).toBe('auth failed')
+ })
+
it('connects, disconnects, and tracks busy state', async () => {
const { store, fetchFn } = boot()
await store.load()
@@ -273,7 +290,7 @@ describe('machinesStore', () => {
fetchFn.mockResolvedValueOnce({ json: async () => ({ ok: true, value: {} }) } as unknown as Response)
await store.disconnect('a')
expect(store.getSnapshot().statuses.a).toEqual({ state: 'disconnected' })
- expect(store.getSnapshot().notice).toBe('disconnected')
+ expect(store.getSnapshot().notice).toEqual({ kind: 'key', key: 'notice.disconnected' })
})
it('marks a machine busy while a connection-plane op is in flight', async () => {
diff --git a/packages/dsh-tauri-ssh-ui/src/client/store/index.ts b/packages/dsh-tauri-ssh-ui/src/client/store/index.ts
index 7a9213ac..c05ca621 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/store/index.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/store/index.ts
@@ -10,9 +10,19 @@
*/
import type { MachineLifecycleState, SshMachineEvent, SyncApplyResult, SyncItemResult, SyncPreview } from '../types/index'
+import type { SshKey } from '../locales/index'
import { SSH_API_PATH } from '../constants/index'
import { isLifecycleState } from '../types/index'
+/**
+ * A published notice: `text` carries host-provided words verbatim (banner /
+ * failure message); `key` is a store-generated literal rendered through the
+ * locale table (params folded by `{name}` replacement at render time).
+ */
+export type MachinesNotice
+ = | { kind: 'text', text: string }
+ | { kind: 'key', key: SshKey, params?: Record<string, string> }
+
/** One redacted machine row (secret fields live only in the form). */
export interface MachineRow {
id: string
@@ -92,7 +102,7 @@ export interface MachinesPageState {
/** One in-flight connection-plane op per machine id. */
busy: Record<string, 'test' | 'connect' | 'disconnect' | 'install'>
/** The latest connection-plane outcome, shown in the banner. */
- notice: string | null
+ notice: MachinesNotice | null
/** The latest install outcome per machine id (shown under the card). */
installResults: Record<string, InstallResult>
/** The sync-to-remote panel state. */
@@ -522,14 +532,25 @@ export class MachinesStore {
const result = await this.callApi<{ ok: boolean, banner?: string, message?: string }>('machine.test', { machineId: id })
if (result.ok) {
this.store.update((state) => {
- state.notice = result.banner ?? 'ok'
- state.statuses[id] = { state: 'disconnected' }
+ state.notice = result.banner === undefined || result.banner === ''
+ ? { kind: 'key', key: 'notice.probe_ok' }
+ : { kind: 'text', text: result.banner }
+ // 探测是旁路健康检查:只在还没有状态记录时落 disconnected,
+ // 绝不把一条已建立/进行中的连接打回断开(连接面由轮询真值维护)。
+ if (state.statuses[id] === undefined)
+ state.statuses[id] = { state: 'disconnected' }
})
}
else {
this.store.update((state) => {
- state.notice = result.message ?? 'failed'
- state.statuses[id] = { state: 'disconnected', lastError: result.message ?? 'failed' }
+ state.notice = result.message === undefined || result.message === ''
+ ? { kind: 'key', key: 'notice.probe_failed' }
+ : { kind: 'text', text: result.message }
+ const current = state.statuses[id]
+ // 失败只追加 lastError;已有的连接态原样保留(真断开由轮询呈现)。
+ state.statuses[id] = current === undefined || current.state === 'disconnected'
+ ? { state: 'disconnected', lastError: result.message ?? 'failed' }
+ : { ...current, lastError: result.message ?? 'failed' }
})
}
})
@@ -541,7 +562,7 @@ export class MachinesStore {
const link = await this.callApi<{ tunnelBaseUrl: string }>('machine.connect', { machineId: id })
this.store.update((state) => {
state.statuses[id] = { state: 'connected', tunnelBaseUrl: link.tunnelBaseUrl }
- state.notice = link.tunnelBaseUrl
+ state.notice = { kind: 'key', key: 'notice.connected', params: { url: link.tunnelBaseUrl } }
})
})
}
@@ -552,7 +573,7 @@ export class MachinesStore {
await this.callApi<Record<string, never>>('machine.disconnect', { machineId: id })
this.store.update((state) => {
state.statuses[id] = { state: 'disconnected' }
- state.notice = 'disconnected'
+ state.notice = { kind: 'key', key: 'notice.disconnected' }
})
})
}
diff --git a/packages/dsh-tauri-ssh-ui/src/client/styles/index.cssr.ts b/packages/dsh-tauri-ssh-ui/src/client/styles/index.cssr.ts
index 2561cf38..e330e62c 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/styles/index.cssr.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/styles/index.cssr.ts
@@ -59,6 +59,11 @@ export default c([
borderStyle: 'dashed',
}),
+ /* Dirty form: ring the Save button so the staged-but-unsaved state is visible. */
+ c('.dshp-ssh-save-dirty', {
+ boxShadow: '0 0 0 2px var(--dsw-alias-state-warning-primary, #d48806)',
+ }),
+
/* The machine list: one hairline card per machine. */
c('.dshp-ssh-rows', {
listStyle: 'none',
diff --git a/packages/dsh-tauri-ssh-ui/src/client/styles/index.ts b/packages/dsh-tauri-ssh-ui/src/client/styles/index.ts
index 17e6da56..8a281cdf 100644
--- a/packages/dsh-tauri-ssh-ui/src/client/styles/index.ts
+++ b/packages/dsh-tauri-ssh-ui/src/client/styles/index.ts
@@ -26,6 +26,7 @@ export const cls = {
chrome: 'dshp-ssh-chrome',
dangerAction: 'dshp-ssh-danger-action',
addAction: 'dshp-ssh-add-action',
+ saveDirty: 'dshp-ssh-save-dirty',
rows: 'dshp-ssh-rows',
group: 'dshp-ssh-group',
groupTitle: 'dshp-ssh-group-title',
diff --git a/src/layout/components/remote-switcher.tsx b/src/layout/components/remote-switcher.tsx
index 0a2ddfa8..ddb1f699 100644
--- a/src/layout/components/remote-switcher.tsx
+++ b/src/layout/components/remote-switcher.tsx
@@ -24,7 +24,7 @@ import { toast } from '@/utils/toast'
export function RemoteSwitcher() {
const { t } = useTranslation()
useRemoteMachines()
- const { machines, activeId, available } = useStore(store.remote)
+ const { machines, activeId, available, pendingId } = useStore(store.remote)
const activeMachine = machines.find(machine => machine.id === activeId)
const activeColor = activeMachine?.color
@@ -85,7 +85,7 @@ export function RemoteSwitcher() {
className="rounded-md"
id={`remote-${machine.id}`}
textValue={machine.name}
- isDisabled={!available}
+ isDisabled={!available || pendingId !== null}
onAction={() => { store.remote.switchTo(machine.id) }}
>
<span
@@ -101,7 +101,11 @@ export function RemoteSwitcher() {
style={dotStyleOf(machine)}
/>
<Label className="min-w-0 truncate">{machine.name}</Label>
- <Description className="ml-auto shrink-0">{t(`remote.state.${machine.state}`)}</Description>
+ {/* 待切换的机器在首轮轮询回报前尚无 connecting 状态:由
+ pendingId 立即给出「连接中」反馈,避免点了没反应 */}
+ <Description className={cn('ml-auto shrink-0', pendingId === machine.id && 'text-warning')}>
+ {pendingId === machine.id ? t('remote.state.connecting') : t(`remote.state.${machine.state}`)}
+ </Description>
</span>
</Dropdown.Item>
))}