DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(desktop): restart in safe mode from the error screen
hairyf95851299ceb0
diff --git a/src-tauri/src/bridge/lifecycle.rs b/src-tauri/src/bridge/lifecycle.rsindex eacc698f..a1e7eeec 100644--- a/src-tauri/src/bridge/lifecycle.rs+++ b/src-tauri/src/bridge/lifecycle.rs@@ -361,6 +361,18 @@ pub async fn restart_harness(app_handle: AppHandle) -> Result<(), String> {workflow::restart(app_handle).await}+/// 进入安全模式:确保安全档案存在并切换为当前档案(不重启,由前端走标准重启链路)。+///+/// 错误界面「安全模式」按钮的入口:安全档案只含 web 模板核心 bundles、不带+/// 用户插件/补丁层,启动失败的插件(如 pending waiting for service)被隔离,+/// 应用先恢复可用;用户在档案列表切回原档案即退出安全模式。+#[tauri::command]+pub async fn enter_safe_mode(app_handle: AppHandle) -> Result<(), String> {+ crate::service::profile::ensure_safe_profile(&app_handle)?;+ crate::service::profile::set_active(&app_handle, crate::service::profile::SAFE_PROFILE)?;+ Ok(())+}+/// 获取当前 Harness 服务状态#[tauri::command]pub fn get_dsh_status() -> workflow::status::Status {diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rsindex fcbb348a..d60a2617 100644--- a/src-tauri/src/desktop/builder.rs+++ b/src-tauri/src/desktop/builder.rs@@ -516,6 +516,7 @@ pub fn handler() -> impl Fn(Invoke<Wry>) -> bool + Send + Sync + 'static {crate::bridge::launch_harness,crate::bridge::shutdown_harness,crate::bridge::restart_harness,+ crate::bridge::enter_safe_mode,crate::bridge::get_dsh_status,crate::bridge::get_preinstall_plugins,crate::bridge::get_preinstall_pending,diff --git a/src-tauri/src/service/profile/mod.rs b/src-tauri/src/service/profile/mod.rsindex 7fec95a0..3a57346c 100644--- a/src-tauri/src/service/profile/mod.rs+++ b/src-tauri/src/service/profile/mod.rs@@ -30,6 +30,11 @@ pub const DEFAULT_PROFILE: &str = "web";/// 档案隔离;用户新建同 id 档案被 `PROFILE_EXISTS` 拦截,此名仅由本引导占用)。pub const DESKTOP_PROFILE: &str = "desktop";+/// 安全模式档案:仅加载 web 模板核心 bundles、不带任何用户插件/补丁层。+/// 错误界面「安全模式」按钮切到此档案重启(`--profile safe`),隔离问题插件+/// 让应用先可用,用户随后在档案列表切回原档案即退出安全模式。+pub const SAFE_PROFILE: &str = "safe";+/// 新建档案的初始 bundles:web 模板(`@deepseek-ai/dsh-base` +/// `@deepseek-ai/dsh-web-app`,与 dsh-app-boot `PROFILE_TEMPLATES.web` 一致)。/// 桌面端内嵌的是 dsh web 应用,新档案不带 `dsh-web-app` 将无法渲染任何界面。@@ -304,6 +309,21 @@ pub fn ensure_first_run_desktop_profile(app_handle: &AppHandle) {log::info!("First-run bootstrap: Desktop profile created and activated ({DESKTOP_PROFILE})");}+/// 确保安全模式档案目录存在(幂等,绝不覆盖)。+///+/// 与 `ensure_desktop_profile_with_root` 同构:缺失时按官方 `initProfile` 形态+/// 初始化(web 模板 bundles,可正常渲染桌面内嵌的 web UI),已存在时直接复用。+/// 安全档案只含核心 bundles 与空 patch 层——不装任何用户插件,用于错误界面+/// 「安全模式」按钮把问题插件隔离在启动链路之外。+pub fn ensure_safe_profile(app_handle: &AppHandle) -> Result<(), String> {+ let profiles_root = config::get_dsh_data_path(app_handle).join("profiles");+ let dir = profiles_root.join(SAFE_PROFILE);+ if dir.is_dir() {+ return Ok(());+ }+ init_profile_dir(&dir, SAFE_PROFILE)+}+/// 删除档案(默认档案与使用中的档案不可删除)。pub fn remove(app_handle: &AppHandle, id: &str) -> Result<(), String> {if id == DEFAULT_PROFILE {diff --git a/src/components/plugin-recovery.tsx b/src/components/plugin-recovery.tsxindex 76b2d2b3..036a5b67 100644--- a/src/components/plugin-recovery.tsx+++ b/src/components/plugin-recovery.tsx@@ -1,4 +1,4 @@-import { CircleExclamation } from '@gravity-ui/icons'+import { CircleExclamation, ShieldCheck } from '@gravity-ui/icons'import { Button, Chip, Description, Spinner } from '@heroui/react'import { invoke } from '@tauri-apps/api/core'import { useEffect, useState } from 'react'@@ -165,6 +165,12 @@ export function PluginRecovery({ fullScreen = false }: { fullScreen?: boolean })<Button className="rounded-md" variant="tertiary" onPress={() => store.harness.restart()}>{t('recovery.restart')}</Button>+ <Button className="rounded-md" variant="ghost" onPress={() => store.harness.enterSafeMode()}>+ <span className="flex items-center gap-1">+ <ShieldCheck className="size-4" />+ {t('buttons.safe_mode')}+ </span>+ </Button><Button className="rounded-md" variant="ghost" onPress={() => store.harness.dismissRecovery()}>{t('recovery.dismiss')}</Button>diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.jsonindex 320a6704..b7694bd7 100644--- a/src/i18n/locales/en-US.json+++ b/src/i18n/locales/en-US.json@@ -86,6 +86,7 @@"errors.process_exited_without_code": "Harness stopped unexpectedly. Restart to continue.","errors.no_readiness_reason": "No readiness reason was reported.","errors.client_boot_stalled": "The client remained on Loading plugins after all bounded reload attempts.",+ "errors.client_boot_failed": "The client reported a failure while loading plugins.","errors.plugin_route_conflict": "Detected a plugin route conflict: two plugins registered the same route twice. Uninstall the recently added plugin (e.g. dsh-web-ui-all / dsh-better-sidebar) from the Plugins panel, or run dsh plugin --profile <profile> remove <package> for the active profile and retry.","errors.inotify_limit": "The Harness service crashed on startup: your system reached the limit for file watchers (inotify ENOSPC). Increase the watcher limit and restart — e.g. run `sudo sysctl fs.inotify.max_user_watches=524288` (and add `fs.inotify.max_user_watches=524288` to `/etc/sysctl.conf` to persist), then restart the app.","ui.service_url": "Service URL",@@ -121,6 +122,8 @@"buttons.save": "Save","buttons.copy": "Copy","buttons.copy_logs": "Copy Logs",+ "buttons.safe_mode": "Safe Mode",+ "hints.safe_mode": "Restart with only the core bundles, isolating plugins that fail to start. Switch back to your profile in the sidebar to exit safe mode.","messages.copy_success": "URL copied to clipboard","messages.log_copied": "Logs copied to clipboard","messages.copy_failed": "Failed to copy URL",diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.jsonindex 4d8472a5..d25279fd 100644--- a/src/i18n/locales/zh-CN.json+++ b/src/i18n/locales/zh-CN.json@@ -86,6 +86,7 @@"errors.process_exited_without_code": "Harness 意外停止。请重新启动以继续。","errors.no_readiness_reason": "后端未报告就绪原因。","errors.client_boot_stalled": "客户端在全部有界刷新尝试后仍停留在 Loading plugins。",+ "errors.client_boot_failed": "客户端加载插件时报告了失败。","errors.plugin_route_conflict": "检测到插件路由冲突:两个插件重复注册了同一路由。请在「插件」面板卸载最近安装的插件(如 dsh-web-ui-all / dsh-better-sidebar),或在终端对当前档案执行 dsh plugin --profile <档案名> remove <包名> 后重试。","errors.inotify_limit": "Harness 服务启动即崩溃:系统文件监视(inotify)数量达到上限。请调高监视上限后重试——例如执行 `sudo sysctl fs.inotify.max_user_watches=524288`(并将 `fs.inotify.max_user_watches=524288` 写入 `/etc/sysctl.conf` 以持久化),然后重启应用。","ui.service_url": "服务地址",@@ -121,6 +122,8 @@"buttons.save": "保存","buttons.copy": "复制","buttons.copy_logs": "复制日志",+ "buttons.safe_mode": "安全模式",+ "hints.safe_mode": "仅加载核心组件重启,隔离启动失败的插件。在侧边栏切回原档案即可退出安全模式。","messages.copy_success": "地址已复制到剪贴板","messages.log_copied": "日志已复制到剪贴板","messages.copy_failed": "复制地址失败",diff --git a/src/layout/components/setup.tsx b/src/layout/components/setup.tsxindex 03e6b0f0..ab505d9a 100644--- a/src/layout/components/setup.tsx+++ b/src/layout/components/setup.tsx@@ -1,6 +1,6 @@import type { IconComponent } from './loadable'import type { SetupStatus } from '@/store/modules/harness'-import { ArrowDownToLine, CircleCheck, CircleExclamation, CircleInfo, Copy, Magnifier, Rocket } from '@gravity-ui/icons'+import { ArrowDownToLine, CircleCheck, CircleExclamation, CircleInfo, Copy, Magnifier, Rocket, ShieldCheck } from '@gravity-ui/icons'import { invoke } from '@tauri-apps/api/core'import { useTranslation } from 'react-i18next'import { If, Then } from 'react-if-lite'@@ -82,6 +82,18 @@ export function Setup() {<Copy className="size-4" />{t('buttons.copy_logs')}</button>+ <button+ className={button({ tone: 'primary', size: 'sm' })}+ onClick={() => {+ void store.harness.enterSafeMode()+ }}+ >+ <ShieldCheck className="size-4" />+ {t('buttons.safe_mode')}+ </button>+ <p className="m-0 text-xs leading-[18px] break-all text-load-muted">+ {t('hints.safe_mode')}+ </p></Then></If></Loadable>