DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(desktop): restore main window hide and release v0.24.5 (#1148)
Hairye73c747b2a0b
diff --git a/app.json b/app.jsonindex 1baa310a..d0caa43b 100644--- a/app.json+++ b/app.json@@ -2,14 +2,14 @@"expo": {"name": "DSH Mobile","slug": "dsh-bridge",- "version": "0.24.4",+ "version": "0.24.5","scheme": "dshbridge","orientation": "portrait","userInterfaceStyle": "automatic","icon": "./assets/native/icon.png","android": {"package": "com.dshtauri.dshbridge",- "versionCode": 21017,+ "versionCode": 21018,"adaptiveIcon": {"foregroundImage": "./assets/native/adaptive-icon.png","backgroundColor": "#ffffff"diff --git a/package.json b/package.jsonindex 965d589c..1c4ddbd6 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "deepseek-harness-desktop","type": "module",- "version": "0.24.4",+ "version": "0.24.5","private": true,"packageManager": "[email protected]","description": "Desktop application for DeepSeek Harness (dsh) — one-click local install and launch, no Node.js setup required.",diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 1d15ce3a..c44421b0 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -1031,7 +1031,7 @@ dependencies = [[[package]]name = "deepseek-harness-desktop"-version = "0.24.4"+version = "0.24.5"dependencies = ["arboard","async-trait",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 8f52cf85..53b11fe2 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "deepseek-harness-desktop"-version = "0.24.4"+version = "0.24.5"description = "Desktop application for DeepSeek Harness (dsh)"authors = [ "deepseek-harness-desktop contributors" ]edition = "2021"diff --git a/src-tauri/capabilities/window-close.json b/src-tauri/capabilities/window-close.jsonnew file mode 100644index 00000000..9fe57559--- /dev/null+++ b/src-tauri/capabilities/window-close.json@@ -0,0 +1,13 @@+{+ "$schema": "../gen/schemas/desktop-schema.json",+ "identifier": "window-close",+ "description": "Allows only local attached shell windows to close themselves. Main and embedded loopback Harness pages do not receive this permission.",+ "local": true,+ "windows": [+ "window-*",+ "remote-*"+ ],+ "permissions": [+ "core:window:allow-close"+ ]+}diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 0bf9585a..0b4e7eba 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://schema.tauri.app/config/2","productName": "DSH Tauri",- "version": "0.24.4",+ "version": "0.24.5","identifier": "dsh-tauri","build": {"beforeDevCommand": "pnpm dev",diff --git a/src/layout/components/navbar-window-close.test.tsx b/src/layout/components/navbar-window-close.test.tsxindex bc47c836..96bd3b72 100644--- a/src/layout/components/navbar-window-close.test.tsx+++ b/src/layout/components/navbar-window-close.test.tsx@@ -63,16 +63,39 @@ afterAll(() => {})describe('navbar window close', () => {- it('closes an extra window through the native close path instead of hiding it', async () => {- mockWindows('window-2')+ it.each(['window-2', 'remote-2'])('closes the %s attached window instead of hiding it', async (label) => {+ mockWindows(label)render(<Navbar onRemoteChange={vi.fn()} />)fireEvent.click(screen.getByLabelText('nav.close'))- await waitFor(() => expect(native).toHaveBeenCalledWith('plugin:window|close', expect.objectContaining({ label: 'window-2' })))+ await waitFor(() => expect(native).toHaveBeenCalledWith('plugin:window|close', expect.objectContaining({ label })))expect(native).not.toHaveBeenCalledWith('plugin:window|hide', expect.anything())})+ it('hides the main window when its background button is clicked without requesting close', async () => {+ mockWindows('main')+ render(<Navbar onRemoteChange={vi.fn()} />)++ fireEvent.click(screen.getByLabelText('nav.background'))++ await waitFor(() => expect(native).toHaveBeenCalledWith('plugin:window|hide', expect.objectContaining({ label: 'main' })))+ expect(native).not.toHaveBeenCalledWith('plugin:window|close', expect.anything())+ })++ it.each(['main', 'window-2', 'remote-2'])('routes the File close action for %s to the matching native operation', async (label) => {+ mockWindows(label)+ render(<Navbar onRemoteChange={vi.fn()} />)++ fireEvent.click(screen.getByTestId('dsh-navbar-menu-file'))+ fireEvent.click(await screen.findByTestId('dsh-navbar-item-close'))++ const command = label === 'main' ? 'plugin:window|hide' : 'plugin:window|close'+ const otherCommand = label === 'main' ? 'plugin:window|close' : 'plugin:window|hide'+ await waitFor(() => expect(native).toHaveBeenCalledWith(command, expect.objectContaining({ label })))+ expect(native).not.toHaveBeenCalledWith(otherCommand, expect.anything())+ })+it('keeps the main window close labeled as backgrounding to the tray', () => {mockWindows('main')render(<Navbar onRemoteChange={vi.fn()} />)diff --git a/src/layout/components/navbar.tsx b/src/layout/components/navbar.tsxindex 53459b18..f03983a1 100644--- a/src/layout/components/navbar.tsx+++ b/src/layout/components/navbar.tsx@@ -53,7 +53,7 @@ import { RemoteSwitcher } from './remote-switcher'* 与切换器共用服务可用门槛(见 `remote-share.tsx`);齿轮入口经 `onOpenRemoteAccess` 定位到本机访问页。* - 文件:新建窗口(Tauri 再开一个 webview)/ 新聊天、打开文件夹(经协议调用 dsh 官方* 「新建会话」「添加工作区」,接收方是 dsh-tauri 的 `client/register/navigation.ts`)/- * 关闭(主窗口按设置驻留托盘,附加窗口直接销毁)/ 退出(完整退出)。两条依赖 iframe+ * 关闭(主窗口隐藏到托盘,附加窗口直接销毁)/ 退出(完整退出)。两条依赖 iframe* 的项在回调缺席时禁用。* - 运行:应用 / 档案 / 插件 / 核心,直接打开配置对话框并定位到对应面板* (对话框与角标见 `ui/dialog/config.tsx`);「应用」项右侧另挂一个快捷重启图标按钮,@@ -279,8 +279,6 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSidebconst tauriEnabled = plugins.some(plugin => plugin.id === TAURI_PLUGIN_ID)const isNightly = appIdentifier === 'dsh-tauri-nightly'const showUpdateAvailable = appIdentifier != null && !isNightly && updateInfo != null- // 关闭语义由 Rust 按 label 决定(见 src-tauri/src/desktop/builder.rs 的 CloseRequested):- // 主窗口按设置驻留托盘或退出,附加窗口直接销毁。这里只在文案上区分两者。const isMainWindow = getCurrentWindow().label === 'main'function handleWindowAction(action: 'minimize' | 'maximize' | 'close') {const appWindow = getCurrentWindow()@@ -292,9 +290,10 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSidebvoid appWindow.toggleMaximize()breakcase 'close':- // 走原生 close 而不是 hide:附加窗口关闭就该销毁,隐藏会留下没有恢复入口、- // 却仍在监听通知的窗口(点击通知时它们会一起冒出来)。- void appWindow.close()+ if (isMainWindow)+ void appWindow.hide()+ else+ void appWindow.close()break}}@@ -339,7 +338,6 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSidebonOpenFolder?.()breakcase 'close':- // 关闭当前窗口:主窗口驻留托盘,附加窗口直接销毁(由 Rust 按 label 决定)。handleWindowAction('close')breakcase 'quit':diff --git a/test/window-close-capability.test.ts b/test/window-close-capability.test.tsnew file mode 100644index 00000000..472ee813--- /dev/null+++ b/test/window-close-capability.test.ts@@ -0,0 +1,48 @@+import { readdirSync, readFileSync } from 'node:fs'+import { describe, expect, it } from 'vitest'++interface Capability {+ identifier: string+ local?: boolean+ remote?: { urls: string[] }+ windows?: string[]+ webviews?: string[]+ permissions: Array<string | { identifier: string }>+}++const capabilitiesDirectory = new URL('../src-tauri/capabilities/', import.meta.url)+const capabilities = readdirSync(capabilitiesDirectory)+ .filter(name => name.endsWith('.json'))+ .map(name => JSON.parse(readFileSync(new URL(name, capabilitiesDirectory), 'utf8')) as Capability)+const closeCapabilities = capabilities.filter(capability => capability.permissions.some(permission =>+ (typeof permission === 'string' ? permission : permission.identifier) === 'core:window:allow-close',+))++const config = JSON.parse(readFileSync(new URL('../src-tauri/tauri.conf.json', import.meta.url), 'utf8')) as {+ app: { security: { capabilities?: Array<string | Capability> } }+}++describe('window close capability', () => {+ it('grants close through exactly one dedicated capability loaded by the real Tauri configuration', () => {+ expect(closeCapabilities.map(capability => capability.identifier)).toEqual(['window-close'])+ const enabled = config.app.security.capabilities+ if (enabled !== undefined)+ expect(enabled).toContain('window-close')+ })++ it('limits close to local attached shell windows without granting it to main or pet', () => {+ const capability = closeCapabilities.find(capability => capability.identifier === 'window-close')+ expect(capability).toMatchObject({+ local: true,+ windows: ['window-*', 'remote-*'],+ permissions: ['core:window:allow-close'],+ })+ expect(capability).not.toHaveProperty('webviews')+ })++ it('does not expose close to loopback iframe origins in any capability', () => {+ for (const capability of closeCapabilities)+ expect(capability, capability.identifier).not.toHaveProperty('remote')+ expect(closeCapabilities).toHaveLength(1)+ })+})