DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(desktop): add launch at login (#190)
exoticknight5cf4f660e323
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 10baefe9..6c1ce1e1 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -283,6 +283,17 @@ version = "1.1.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"+[[package]]+name = "auto-launch"+version = "0.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471"+dependencies = [+ "dirs 4.0.0",+ "thiserror 1.0.69",+ "winreg 0.10.1",+]+[[package]]name = "autocfg"version = "1.5.1"@@ -818,6 +829,7 @@ version = "0.9.2"dependencies = ["arboard","async-trait",+ "auto-launch","base64 0.22.1","dunce","flate2",@@ -837,6 +849,7 @@ dependencies = ["tar","tauri","tauri-build",+ "tauri-plugin-autostart","tauri-plugin-clipboard-manager","tauri-plugin-fs","tauri-plugin-notification",@@ -852,6 +865,7 @@ dependencies = ["webview2-com","windows-core 0.61.2","windows-sys 0.61.2",+ "winreg 0.55.0","zip",]@@ -927,13 +941,33 @@ dependencies = ["subtle",]+[[package]]+name = "dirs"+version = "4.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"+dependencies = [+ "dirs-sys 0.3.7",+]+[[package]]name = "dirs"version = "6.0.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"dependencies = [- "dirs-sys",+ "dirs-sys 0.5.0",+]++[[package]]+name = "dirs-sys"+version = "0.3.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"+dependencies = [+ "libc",+ "redox_users 0.4.6",+ "winapi",][[package]]@@ -944,7 +978,7 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"dependencies = ["libc","option-ext",- "redox_users",+ "redox_users 0.5.2","windows-sys 0.61.2",]@@ -1086,7 +1120,7 @@ dependencies = ["rustc_version","toml 1.1.4+spec-1.1.0","vswhom",- "winreg",+ "winreg 0.55.0",][[package]]@@ -3340,6 +3374,17 @@ dependencies = ["bitflags 2.13.1",]+[[package]]+name = "redox_users"+version = "0.4.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"+dependencies = [+ "getrandom 0.2.17",+ "libredox",+ "thiserror 1.0.69",+]+[[package]]name = "redox_users"version = "0.5.2"@@ -4256,7 +4301,7 @@ dependencies = ["anyhow","bytes","cookie",- "dirs",+ "dirs 6.0.0","dunce","embed_plist","getrandom 0.3.4",@@ -4307,7 +4352,7 @@ checksum = "bc9ce40b16101cb6ea63d3e221567affd1c3a9205f95d7bc574941a10636b632"dependencies = ["anyhow","cargo_toml",- "dirs",+ "dirs 6.0.0","glob","heck 0.5.0","json-patch",@@ -4377,6 +4422,20 @@ dependencies = ["walkdir",]+[[package]]+name = "tauri-plugin-autostart"+version = "2.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "459383cebc193cdd03d1ba4acc40f2c408a7abce419d64bdcd2d745bc2886f70"+dependencies = [+ "auto-launch",+ "serde",+ "serde_json",+ "tauri",+ "tauri-plugin",+ "thiserror 2.0.20",+]+[[package]]name = "tauri-plugin-clipboard-manager"version = "2.3.2"@@ -5049,7 +5108,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "045979e3f037cd18ad1cb2a419dfda133c5c29c9f3453370079f2255d46c257e"dependencies = ["crossbeam-channel",- "dirs",+ "dirs 6.0.0","libappindicator","muda","objc2",@@ -6027,6 +6086,15 @@ dependencies = ["memchr",]+[[package]]+name = "winreg"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"+dependencies = [+ "winapi",+]+[[package]]name = "winreg"version = "0.55.0"@@ -6077,7 +6145,7 @@ dependencies = ["block2","cookie","crossbeam-channel",- "dirs",+ "dirs 6.0.0","dom_query","dpi","dunce",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 7f0d4cce..b6f89378 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -31,6 +31,7 @@ tauri-plugin-fs = "2"tauri-plugin-store = "2"tauri-plugin-clipboard-manager = "2"tauri-plugin-notification = "2"+tauri-plugin-autostart = "2"image = { version = "0.25", default-features = false, features = [ "png" ] }arboard = { version = "3", features = [ "wayland-data-control" ] }base64 = "0.22"@@ -62,6 +63,9 @@ tokio = { version = "1", features = [ "full" ] }semver = "1"dunce = "1.0.5"+[dev-dependencies]+auto-launch = "0.5"+[target.'cfg(target_os = "macos")'.dependencies]objc2-foundation = { version = "=0.3.2", default-features = false, features = ["std",@@ -76,6 +80,7 @@ libc = "0.2"rfd = "0.16"webview2-com = "0.38"windows-core = "0.61"+winreg = "0.55"windows-sys = { version = "0.61", features = ["Win32_Foundation","Win32_Globalization",diff --git a/src-tauri/src/bridge/config.rs b/src-tauri/src/bridge/config.rsindex 0e99969e..d03bb92b 100644--- a/src-tauri/src/bridge/config.rs+++ b/src-tauri/src/bridge/config.rs@@ -98,6 +98,21 @@ pub async fn update_app_config(Ok(setting)}+/// 查询桌面应用是否已注册为随当前用户登录启动。+///+/// 系统启动项才是真实来源:用户可能在 Windows 任务管理器或其它平台的系统设置中+/// 改动它,因此不能用应用 store 中的布尔值代替实际状态。+#[tauri::command]+pub fn get_launch_on_login(app_handle: AppHandle) -> Result<bool, String> {+ crate::desktop::autostart::is_enabled(&app_handle)+}++/// 启用或移除桌面应用的系统登录启动项,并复查系统中的最终状态。+#[tauri::command]+pub fn set_launch_on_login(app_handle: AppHandle, enabled: bool) -> Result<bool, String> {+ crate::desktop::autostart::set_enabled(&app_handle, enabled)+}+/// 把设置面板选择的缩放比例立即应用到主 WebView 并持久化。#[tauri::command]pub fn set_webview_zoom(app_handle: AppHandle, zoom_factor: f64) -> Result<f64, String> {diff --git a/src-tauri/src/desktop/autostart.rs b/src-tauri/src/desktop/autostart.rsnew file mode 100644index 00000000..cb1b2e9b--- /dev/null+++ b/src-tauri/src/desktop/autostart.rs@@ -0,0 +1,387 @@+//! 桌面应用的系统登录启动集成。+//!+//! 跨平台注册交给 Tauri 官方插件;Windows 只补齐其底层库对缺失注册表键和+//! 重复禁用不幂等的问题,并清理由任务管理器维护的残留状态。++use tauri::{AppHandle, Runtime};+use tauri_plugin_autostart::ManagerExt;++#[cfg(windows)]+use std::io::ErrorKind;+#[cfg(windows)]+use winreg::enums::{HKEY_CURRENT_USER, KEY_READ, KEY_SET_VALUE};+#[cfg(windows)]+use winreg::RegKey;++#[cfg(windows)]+const RUN_REGISTRY_KEY: &str = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";+#[cfg(windows)]+const STARTUP_APPROVED_REGISTRY_KEY: &str =+ "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartupApproved\\Run";++/// 返回系统启动项名称;开发版独立命名,避免覆盖正式版的可执行文件路径。+pub fn app_name() -> &'static str {+ if cfg!(debug_assertions) {+ "Deepseek Harness Desktop Dev"+ } else {+ "Deepseek Harness Desktop"+ }+}++#[cfg(windows)]+fn windows_run_entry_exists(name: &str) -> Result<bool, String> {+ let current_user = RegKey::predef(HKEY_CURRENT_USER);+ let run_key = match current_user.open_subkey_with_flags(RUN_REGISTRY_KEY, KEY_READ) {+ Ok(key) => key,+ Err(error) if error.kind() == ErrorKind::NotFound => return Ok(false),+ Err(error) => return Err(format!("AUTOSTART_REGISTRY_FAILED: {error}")),+ };+ match run_key.get_raw_value(name) {+ Ok(_) => Ok(true),+ Err(error) if error.kind() == ErrorKind::NotFound => Ok(false),+ Err(error) => Err(format!("AUTOSTART_REGISTRY_FAILED: {error}")),+ }+}++#[cfg(windows)]+fn ensure_windows_run_key() -> Result<(), String> {+ RegKey::predef(HKEY_CURRENT_USER)+ .create_subkey(RUN_REGISTRY_KEY)+ .map(|_| ())+ .map_err(|error| format!("AUTOSTART_REGISTRY_FAILED: {error}"))+}++#[cfg(windows)]+fn remove_windows_startup_approval(name: &str) -> Result<(), String> {+ let current_user = RegKey::predef(HKEY_CURRENT_USER);+ let key =+ match current_user.open_subkey_with_flags(STARTUP_APPROVED_REGISTRY_KEY, KEY_SET_VALUE) {+ Ok(key) => key,+ Err(error) if error.kind() == ErrorKind::NotFound => return Ok(()),+ Err(error) => return Err(format!("AUTOSTART_REGISTRY_FAILED: {error}")),+ };+ match key.delete_value(name) {+ Ok(()) => Ok(()),+ Err(error) if error.kind() == ErrorKind::NotFound => Ok(()),+ Err(error) => Err(format!("AUTOSTART_REGISTRY_FAILED: {error}")),+ }+}++/// 从系统读取当前登录启动状态,允许用户在系统设置中直接修改它。+pub fn is_enabled<R: Runtime>(app_handle: &AppHandle<R>) -> Result<bool, String> {+ #[cfg(windows)]+ if !windows_run_entry_exists(app_name())? {+ return Ok(false);+ }++ app_handle+ .autolaunch()+ .is_enabled()+ .map_err(|error| format!("AUTOSTART_STATUS_FAILED: {error}"))+}++/// 写入登录启动状态并复查结果,禁用操作保持幂等。+pub fn set_enabled<R: Runtime>(app_handle: &AppHandle<R>, enabled: bool) -> Result<bool, String> {+ let manager = app_handle.autolaunch();+ if enabled {+ #[cfg(windows)]+ ensure_windows_run_key()?;+ manager+ .enable()+ .map_err(|error| format!("AUTOSTART_ENABLE_FAILED: {error}"))?;+ } else {+ #[cfg(windows)]+ {+ if windows_run_entry_exists(app_name())? {+ manager+ .disable()+ .map_err(|error| format!("AUTOSTART_DISABLE_FAILED: {error}"))?;+ }+ remove_windows_startup_approval(app_name())?;+ }+ #[cfg(not(windows))]+ manager+ .disable()+ .map_err(|error| format!("AUTOSTART_DISABLE_FAILED: {error}"))?;+ }++ let actual = is_enabled(app_handle)?;+ if actual != enabled {+ return Err(format!(+ "AUTOSTART_STATE_MISMATCH: requested {enabled}, actual {actual}"+ ));+ }+ Ok(actual)+}++#[cfg(test)]+mod tests {+ use auto_launch::{AutoLaunch, AutoLaunchBuilder};+ use std::path::PathBuf;++ #[cfg(windows)]+ use super::{+ ensure_windows_run_key, remove_windows_startup_approval, windows_run_entry_exists,+ RUN_REGISTRY_KEY, STARTUP_APPROVED_REGISTRY_KEY,+ };+ #[cfg(windows)]+ use winreg::enums::{RegType, HKEY_CURRENT_USER, KEY_READ};+ #[cfg(windows)]+ use winreg::{RegKey, RegValue};++ const TEST_APP_NAME: &str = "Deepseek Harness Desktop Autostart Test";+ const SYSTEM_TEST_ENV: &str = "DSH_RUN_AUTOSTART_TESTS";+ #[cfg(windows)]+ const STARTUP_APPROVED_ENABLED_VALUE: [u8; 12] = [+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,+ ];++ struct AutostartCleanup {+ manager: AutoLaunch,+ }++ impl Drop for AutostartCleanup {+ fn drop(&mut self) {+ let _ = clear_test_entry(&self.manager);+ }+ }++ fn test_manager() -> (AutoLaunch, PathBuf) {+ let executable = std::env::current_exe().expect("test executable path should be available");+ let manager = AutoLaunchBuilder::new()+ .set_app_name(TEST_APP_NAME)+ .set_app_path(executable.to_string_lossy().as_ref())+ .set_use_launch_agent(true)+ .build()+ .expect("test autostart manager should build");+ (manager, executable)+ }++ /// 系统级测试只在 CI 或显式启用时运行,避免受限环境误报失败。+ fn system_test_enabled() -> bool {+ std::env::var_os("CI").is_some() || std::env::var_os(SYSTEM_TEST_ENV).is_some()+ }++ fn is_restricted_error(error: &str) -> bool {+ let error = error.to_ascii_lowercase();+ error.contains("access is denied")+ || error.contains("permission denied")+ || error.contains("operation not permitted")+ || error.contains("os error 5")+ || error.contains("os error 13")+ }++ /// 权限受限时跳过系统集成测试,其它错误仍视为真实失败。+ fn system_test_result<T, E: std::fmt::Display>(+ result: Result<T, E>,+ action: &str,+ ) -> Option<T> {+ match result {+ Ok(value) => Some(value),+ Err(error) if is_restricted_error(&error.to_string()) => {+ eprintln!("skipped: {action} is unavailable in this environment: {error}");+ None+ }+ Err(error) => panic!("{action} failed: {error}"),+ }+ }++ #[cfg(windows)]+ fn clear_test_entry(manager: &AutoLaunch) -> Result<(), String> {+ ensure_windows_run_key()?;+ if windows_run_entry_exists(TEST_APP_NAME)? {+ manager+ .disable()+ .map_err(|error| format!("AUTOSTART_TEST_CLEANUP_FAILED: {error}"))?;+ }+ remove_windows_startup_approval(TEST_APP_NAME)+ }++ #[cfg(not(windows))]+ fn clear_test_entry(manager: &AutoLaunch) -> Result<(), String> {+ manager+ .disable()+ .map_err(|error| format!("AUTOSTART_TEST_CLEANUP_FAILED: {error}"))+ }++ fn enable_test_entry() -> Option<(AutostartCleanup, PathBuf)> {+ let (manager, executable) = test_manager();+ system_test_result(+ clear_test_entry(&manager),+ "removing the stale test autostart entry",+ )?;+ let cleanup = AutostartCleanup { manager };++ let initially_enabled = system_test_result(+ cleanup.manager.is_enabled(),+ "reading the disabled autostart state",+ )?;+ assert!(+ !initially_enabled,+ "test autostart entry should start disabled"+ );+ system_test_result(+ cleanup.manager.enable(),+ "enabling the test autostart entry",+ )?;+ let enabled = system_test_result(+ cleanup.manager.is_enabled(),+ "reading the enabled autostart state",+ )?;+ assert!(enabled, "test autostart entry should be enabled");++ Some((cleanup, executable))+ }++ fn assert_disable_is_idempotent(cleanup: &AutostartCleanup) {+ clear_test_entry(&cleanup.manager).expect("test autostart entry should disable");+ assert!(+ !cleanup+ .manager+ .is_enabled()+ .expect("disabled state should be readable"),+ "test autostart entry should be disabled"+ );+ clear_test_entry(&cleanup.manager).expect("repeated disable should be idempotent");+ }++ #[cfg(windows)]+ #[test]+ fn windows_autostart_registration_round_trip() {+ if !system_test_enabled() {+ eprintln!("skipped: set {SYSTEM_TEST_ENV}=1 to run the Windows autostart system test");+ return;+ }++ let startup_approved = system_test_result(+ RegKey::predef(HKEY_CURRENT_USER).create_subkey(STARTUP_APPROVED_REGISTRY_KEY),+ "opening the StartupApproved Run key",+ );+ let Some((startup_approved, _)) = startup_approved else {+ return;+ };+ if system_test_result(+ startup_approved.set_raw_value(+ TEST_APP_NAME,+ &RegValue {+ vtype: RegType::REG_BINARY,+ bytes: vec![0x03; 12],+ },+ ),+ "writing the disabled test approval value",+ )+ .is_none()+ {+ return;+ }++ let Some((cleanup, executable)) = enable_test_entry() else {+ return;+ };+ let value: String = RegKey::predef(HKEY_CURRENT_USER)+ .open_subkey_with_flags(RUN_REGISTRY_KEY, KEY_READ)+ .expect("Windows Run key should be readable")+ .get_value(TEST_APP_NAME)+ .expect("test Run value should exist");+ assert!(+ value.contains(executable.to_string_lossy().as_ref()),+ "Run value should contain the current test executable"+ );+ let approval = startup_approved+ .get_raw_value(TEST_APP_NAME)+ .expect("enabled StartupApproved value should exist");+ assert_eq!(approval.vtype, RegType::REG_BINARY);+ assert_eq!(approval.bytes, STARTUP_APPROVED_ENABLED_VALUE);++ assert_disable_is_idempotent(&cleanup);+ assert!(+ startup_approved.get_raw_value(TEST_APP_NAME).is_err(),+ "StartupApproved value should be removed after disabling"+ );+ }++ #[cfg(target_os = "macos")]+ #[test]+ fn macos_autostart_registration_round_trip() {+ if !system_test_enabled() {+ eprintln!("skipped: set {SYSTEM_TEST_ENV}=1 to run the macOS autostart system test");+ return;+ }++ let Some(home) = std::env::var_os("HOME").map(PathBuf::from) else {+ eprintln!("skipped: HOME is unavailable in this environment");+ return;+ };+ if system_test_result(+ std::fs::create_dir_all(home.join("Library")),+ "preparing the macOS user Library directory",+ )+ .is_none()+ {+ return;+ }+ let Some((cleanup, executable)) = enable_test_entry() else {+ return;+ };+ let plist = home+ .join("Library")+ .join("LaunchAgents")+ .join(format!("{TEST_APP_NAME}.plist"));+ let Some(content) = system_test_result(+ std::fs::read_to_string(&plist),+ "reading the LaunchAgent plist",+ ) else {+ return;+ };+ assert!(content.contains(&format!("<string>{TEST_APP_NAME}</string>")));+ assert!(content.contains(&format!("<string>{}</string>", executable.display())));+ let Some(status) = system_test_result(+ std::process::Command::new("plutil")+ .args(["-lint", plist.to_string_lossy().as_ref()])+ .status(),+ "running plutil",+ ) else {+ return;+ };+ assert!(status.success(), "LaunchAgent plist should be valid");+ assert_disable_is_idempotent(&cleanup);+ }++ #[cfg(target_os = "linux")]+ #[test]+ fn linux_autostart_registration_round_trip() {+ if !system_test_enabled() {+ eprintln!("skipped: set {SYSTEM_TEST_ENV}=1 to run the Linux autostart system test");+ return;+ }++ let Some(home) = std::env::var_os("HOME").map(PathBuf::from) else {+ eprintln!("skipped: HOME is unavailable in this environment");+ return;+ };+ if system_test_result(+ std::fs::create_dir_all(home.join(".config")),+ "preparing the Linux user config directory",+ )+ .is_none()+ {+ return;+ }+ let Some((cleanup, executable)) = enable_test_entry() else {+ return;+ };+ let desktop_entry = home+ .join(".config")+ .join("autostart")+ .join(format!("{TEST_APP_NAME}.desktop"));+ let Some(content) = system_test_result(+ std::fs::read_to_string(desktop_entry),+ "reading the Linux desktop entry",+ ) else {+ return;+ };+ assert!(content.contains(&format!("Name={TEST_APP_NAME}")));+ assert!(content.contains(&format!("Exec={}", executable.display())));+ assert_disable_is_idempotent(&cleanup);+ }+}diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rsindex 5370c9da..67c48975 100644--- a/src-tauri/src/desktop/builder.rs+++ b/src-tauri/src/desktop/builder.rs@@ -529,6 +529,8 @@ pub fn handler() -> impl Fn(Invoke<Wry>) -> bool + Send + Sync + 'static {crate::bridge::runtime_ready,crate::bridge::get_app_config,crate::bridge::update_app_config,+ crate::bridge::get_launch_on_login,+ crate::bridge::set_launch_on_login,crate::bridge::set_webview_zoom,crate::bridge::adjust_webview_zoom,crate::bridge::get_cli_link_status,@@ -608,6 +610,12 @@ pub fn builder() -> tauri::Builder<tauri::Wry> {}));builder+ // 官方跨平台登录启动实现:Windows HKCU Run、macOS LaunchAgent、Linux XDG。+ .plugin(+ tauri_plugin_autostart::Builder::new()+ .app_name(crate::desktop::autostart::app_name())+ .build(),+ )// Opener plugin.plugin(tauri_plugin_opener::init())// Notification plugin(Windows 上以 tauri-winrt-notification 实现点击回调,diff --git a/src-tauri/src/desktop/mod.rs b/src-tauri/src/desktop/mod.rsindex 1f6cc61b..08bab606 100644--- a/src-tauri/src/desktop/mod.rs+++ b/src-tauri/src/desktop/mod.rs@@ -1,3 +1,4 @@+pub mod autostart;pub mod builder;pub mod compat;pub mod nav;diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex 17cd5432..7e31e5b6 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -43,7 +43,8 @@"uninstallerIcon": "icons/icon.ico"},"wix": {- "language": ["en-US", "zh-CN"]+ "language": ["en-US", "zh-CN"],+ "fragmentPaths": ["./windows/fragments/autostart-cleanup.wxs"]}},"shortDescription": "Desktop application for DeepSeek Harness",diff --git a/src-tauri/templates/installer.nsi b/src-tauri/templates/installer.nsiindex ba583152..e524fc45 100644--- a/src-tauri/templates/installer.nsi+++ b/src-tauri/templates/installer.nsi@@ -885,6 +885,7 @@ Section Uninstall; We do this when not updating (to preserve the registry value on updates)${If} $UpdateMode <> 1DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}"+ DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" "${PRODUCTNAME}"${EndIf}; Delete app data if the checkbox is selecteddiff --git a/src-tauri/windows/fragments/autostart-cleanup.wxs b/src-tauri/windows/fragments/autostart-cleanup.wxsnew file mode 100644index 00000000..1cd6e124--- /dev/null+++ b/src-tauri/windows/fragments/autostart-cleanup.wxs@@ -0,0 +1,30 @@+<?xml version="1.0" encoding="utf-8"?>+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">+ <Fragment>+ <CustomAction+ Id="RemoveAutostartRunValue"+ Directory="SystemFolder"+ ExeCommand="reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "Deepseek Harness Desktop" /f"+ Execute="immediate"+ Impersonate="yes"+ Return="ignore"+ />+ <CustomAction+ Id="RemoveAutostartApprovalValue"+ Directory="SystemFolder"+ ExeCommand="reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" /v "Deepseek Harness Desktop" /f"+ Execute="immediate"+ Impersonate="yes"+ Return="ignore"+ />+ <InstallExecuteSequence>+ <!-- 真正卸载时清理登录启动项;重大升级卸载旧版本时保留用户选择。 -->+ <Custom Action="RemoveAutostartRunValue" Before="RemoveFiles">+ REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE+ </Custom>+ <Custom Action="RemoveAutostartApprovalValue" After="RemoveAutostartRunValue">+ REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE+ </Custom>+ </InstallExecuteSequence>+ </Fragment>+</Wix>diff --git a/src/components/config-debug.tsx b/src/components/config-debug.tsxindex db51d20d..74939cb9 100644--- a/src/components/config-debug.tsx+++ b/src/components/config-debug.tsx@@ -9,6 +9,7 @@ import { useStore } from 'valtio-define'import { store } from '@/store'import { writeClipboardText } from '@/utils/clipboard'import { toast } from '@/utils/toast'+import { ConfigLaunchOnLogin } from './config-launch-on-login'import { Info } from './info'const ZOOM_OPTIONS = Array.from({ length: 16 }, (_, index) => Number((0.5 + index * 0.1).toFixed(1)))@@ -281,6 +282,7 @@ export function ConfigDebug() {</div><div className="border-t border-line/30" /><div className="space-y-1.5">+ <ConfigLaunchOnLogin /><div><div className="flex items-center justify-between"><span className="text-xs font-medium text-ink">{t('ui.cli_link_enabled')}</span>diff --git a/src/components/config-launch-on-login.tsx b/src/components/config-launch-on-login.tsxnew file mode 100644index 00000000..6778642b--- /dev/null+++ b/src/components/config-launch-on-login.tsx@@ -0,0 +1,46 @@+import { Description, Switch } from '@heroui/react'+import { useMutation, useQuery } from '@tanstack/react-query'+import { invoke } from '@tauri-apps/api/core'+import { useTranslation } from 'react-i18next'+import { toast } from '@/utils/toast'++export function ConfigLaunchOnLogin() {+ const { t } = useTranslation()+ const { data: enabled, refetch, isFetching } = useQuery({+ queryKey: ['launch_on_login'],+ queryFn: () => invoke<boolean>('get_launch_on_login'),+ })+ const { mutate: setEnabled, isPending } = useMutation({+ mutationFn: (nextEnabled: boolean) => invoke<boolean>('set_launch_on_login', { enabled: nextEnabled }),+ onSuccess: () => {+ void refetch()+ },+ onError: (error: unknown) => {+ console.error('[ConfigLaunchOnLogin] update failed:', error)+ toast(t('messages.launch_on_login_failed'), { variant: 'danger' })+ },+ })++ return (+ <div>+ <div className="flex items-center justify-between gap-2">+ <span className="text-xs font-medium text-ink">{t('ui.launch_on_login')}</span>+ <Switch+ isSelected={enabled ?? false}+ isDisabled={isFetching || isPending}+ onChange={setEnabled}+ aria-label={t('ui.launch_on_login')}+ >+ <Switch.Content>+ <Switch.Control>+ <Switch.Thumb />+ </Switch.Control>+ </Switch.Content>+ </Switch>+ </div>+ <Description className="text-[10px] text-muted/70">+ {t('ui.launch_on_login_hint')}+ </Description>+ </div>+ )+}diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.jsonindex 0bfd40ed..89c1c88d 100644--- a/src/i18n/locales/en-US.json+++ b/src/i18n/locales/en-US.json@@ -87,6 +87,8 @@"ui.service_url": "Service URL","ui.port": "Port","ui.zoom": "Zoom",+ "ui.launch_on_login": "Launch app at login",+ "ui.launch_on_login_hint": "Starts the desktop app after you sign in. Harness service startup is configured separately.","ui.cli_link": "CLI Integration","ui.cli_link_enabled": "Enable dsh command","ui.cli_link_hint": "Run dsh --help in a new terminal",@@ -115,6 +117,7 @@"messages.port_changed": "Port changed","messages.port_restart_hint": "It takes effect after the service restarts. Restart now?","messages.zoom_failed": "Failed to update zoom",+ "messages.launch_on_login_failed": "Failed to update launch at login","messages.logs_cleared": "Logs cleared","nav.sidebar_expand": "Expand sidebar","nav.sidebar_collapse": "Collapse sidebar",diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.jsonindex 1a5ed735..169ed2fd 100644--- a/src/i18n/locales/zh-CN.json+++ b/src/i18n/locales/zh-CN.json@@ -87,6 +87,8 @@"ui.service_url": "服务地址","ui.port": "端口","ui.zoom": "界面缩放",+ "ui.launch_on_login": "开机自启动",+ "ui.launch_on_login_hint": "登录系统后启动桌面应用;Harness 服务的自动运行配置与此项相互独立。","ui.cli_link": "命令行集成","ui.cli_link_enabled": "启用 dsh 命令","ui.cli_link_hint": "在新终端中运行 dsh --help 查看用法",@@ -115,6 +117,7 @@"messages.port_changed": "端口已更改","messages.port_restart_hint": "重启服务后生效,是否立即重启?","messages.zoom_failed": "界面缩放更新失败",+ "messages.launch_on_login_failed": "更新开机自启动设置失败","messages.logs_cleared": "日志已清空","nav.sidebar_expand": "展开侧边栏","nav.sidebar_collapse": "收起侧边栏",