Skip to content

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

chore(hygiene): P3 housekeeping — AGENTS fixes, dead code, i18n, tests

[email protected]e4304068e0cd
diff --git a/AGENTS.md b/AGENTS.md
index 0695e65c..a1739779 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,6 +1,6 @@
# Development Specification Document
-DeepSeek Harness desktop (Tauri 2 + React 18), embeds the Harness UI served at `http://127.0.0.1:3080`.
+DeepSeek Harness desktop (Tauri 2 + React 19), embeds the Harness UI served at `http://127.0.0.1:3080`.
- **端口隔离**:release 默认 `3080`,debug(`pnpm tauri dev` / `cargo build`)默认 `3081`,由 `config::setting::default_port()` 用 `cfg!(debug_assertions)` 区分,避免开发时与已运行的桌面端争用端口。
- **数据隔离(核心共用、数据不共用)**:node/`dependencies/dsh`/`dependencies/pnpm` 为共用核心(AppData);debug 构建的 `$DSH_HOME` 默认为 `~/.dsh.dev`(`config::runtime::get_dsh_data_path` 用 `cfg!(debug_assertions)` 区分)且 store 用独立文件 `.store.dev.dat`(`config::setting::store_dat_file_name`),避免开发版与生产版会话/档案/端口状态互相污染,也防止 dev 版热重启把 release 的服务进程杀掉(`service/workflow::terminate_stale_harness_processes` 在 debug 下为 no-op,改由 `.dsh.dev/.harness.pid` 精确回收)。debug 构建不迁移旧数据(`service/migrate`)、不注册/注销 PATH、不写烘焙 DSH_HOME 的 `dsh` shim(`service/cli`)。
@@ -10,13 +10,13 @@ DeepSeek Harness desktop (Tauri 2 + React 18), embeds the Harness UI served at `
- This will help minimize the need for writing custom classes.
- If you write new content, you need to handle i18n en keys
- i18n keys must be flat (no nesting), use dot-notation flat keys only
-- No hardcoded strings; sync `src/i18n/zh.ts`, `en.ts` and `types.ts`
+- No hardcoded strings; sync i18n locale files (`src/i18n/locales/en-US.json` / `zh-CN.json`)
- If the component you write/modify is too complex, you need to split it into multiple components
- Repeated logic should be encapsulated into methods/components
## Tech Stack
-- **Frontend**: React 18 + TS + Tailwind 4 (no plain CSS), Vite (`src/`)
+- **Frontend**: React 19 + TS + Tailwind 4 (no plain CSS), Vite (`src/`)
- **Backend**: Rust / Tauri 2 (`src-tauri/src/`)
- `bridge/cmd.rs`: Tauri commands (register in `lib.rs` `generate_handler!`)
- `config/`: constants, paths (`runtime.rs`), settings (`setting.rs`), i18n & theme
@@ -36,7 +36,7 @@ cargo check && cargo test # Rust check & unit tests (run in src-tauri)
## Basics
-- No `useCallback` / `useMemo` — project has `react-compiler` built in
+- No `useCallback` / `useMemo` — Vite 当前未启用 `react-compiler` 插件,依赖「组件保持轻量、每次渲染重建 inline 函数可接受」的约定,而非编译器自动记忆化
- Component functions use `function` declaration; inline events/callbacks use arrow functions
## Function Declaration Specification
@@ -78,6 +78,10 @@ function MyPage() {
### Create files in services directory
+> 注:本仓库当前**没有** `src/services/` 目录,也没有 `@/apis` API 层(数据访问
+> 统一走 Tauri `invoke('command')`)。以下为该模板的用意说明;如未来引入 REST
+> API 层再按此惯例建目录。
+
**Use case:** Backend type error handling, parameter processing, composite requests, polling, data caching, etc.
**File naming:** `use-get-{resource}.ts`, `use-post-{resource}.ts`, `use-put-{resource}.ts`, `use-delete-{resource}.ts`
@@ -123,26 +127,11 @@ Use `If`, `Then`, `Else` components by `react-if-lite` package instead of ternar
## State Management Specification
-### Single module page shared data: defineScope + useScope
-
-```tsx
-// 1. Create scope
-export const TradingScope = defineScope(() => {
- const [count, setCount] = useState(0);
- // any hooks or functions
- return { count, setCount };
-});
-
-// 2. Use Provider
-<TradingScope.Provider>
- <Page> {/* or ({ count }) => <Page>...</Page> */}
- <TradingTable />
- </Page>
-</TradingScope.Provider>;
+### Single module page shared data: defineScope + useScope(已弃用)
-// 3. Use in child components
-const { filters, setFilters } = useScope(TradingScope);
-```
+> `defineScope`/`useScope`(src/hooks/define-scope.ts、use-scope.ts)已在仓库中删除,
+> 全项目改用 `defineStore + useStore`(见下)。新代码一律使用 store 模块,勿再引入
+> scope 模式。
### Multiple module pages shared data: defineStore
@@ -259,8 +248,8 @@ export function FooComponent(props: FooProps) {
## Summary
-- **API Import**: Import APIs from `@/apis`, types from `@/apis/index.type`
+- **API Import**: 直接 `import { invoke } from '@tauri-apps/api/core'`(本仓库没有 `@/apis` 层);类型就近定义在 hooks/组件文件中
- **Function Declaration**: Use `function`, not arrow functions
- **Conditional Rendering**: Use `If`, `Then`, `Else` components instead of ternary operators and `&&` operators
- **Data Processing**: Simple scenarios use `useQuery`/`useMutation` directly, complex scenarios create service files
-- **State Management**: Single module use `defineScope + useScope`, multiple modules use `defineStore + useStore`
+- **State Management**: Multi-module shared state uses `defineStore + useStore`(valtio-define);`defineScope`/`useScope` 已弃用(无引用),新代码勿用
diff --git a/src-tauri/src/service/cli/shim.rs b/src-tauri/src/service/cli/shim.rs
index 05182312..df58b70c 100644
--- a/src-tauri/src/service/cli/shim.rs
+++ b/src-tauri/src/service/cli/shim.rs
@@ -578,6 +578,28 @@ mod tests {
use super::*;
use std::path::PathBuf;
+ // ------------------------------------------------------------------
+ // escape_path_* 纯函数基线(与 shim 内嵌路径的场景一致)
+ // ------------------------------------------------------------------
+
+ #[test]
+ fn escape_path_cmd_doubles_percent() {
+ assert_eq!(escape_path_cmd(Path::new(r"C:\Users\%test%\x")), r"C:\Users\%%test%%\x");
+ assert_eq!(escape_path_cmd(Path::new("/tmp/a b")), "/tmp/a b");
+ }
+
+ #[test]
+ fn escape_path_ps1_doubles_single_quotes() {
+ assert_eq!(escape_path_ps1(Path::new(r"C:\Users\o'brien")), r"C:\Users\o''brien");
+ assert_eq!(escape_path_ps1(Path::new("/plain/path")), "/plain/path");
+ }
+
+ #[test]
+ fn escape_path_sh_escapes_single_quotes() {
+ assert_eq!(escape_path_sh(Path::new("/home/o'brien/.dsh")), r"/home/o'\''brien/.dsh");
+ assert_eq!(escape_path_sh(Path::new("/plain/.dsh")), "/plain/.dsh");
+ }
+
fn sample_app_dir() -> PathBuf {
if cfg!(windows) {
PathBuf::from(r"C:\Users\test\AppData\Roaming\io.github.hairyf.deepseek-harness-desktop")
@@ -596,6 +618,7 @@ mod tests {
}
#[test]
+ #[cfg(windows)]
fn cmd_shim_contains_baked_paths() {
let content = build_cmd_shim(&sample_app_dir(), &sample_dsh_home());
assert!(content.contains(r"C:\Users\test\AppData\Roaming"));
@@ -653,6 +676,7 @@ mod tests {
}
#[test]
+ #[cfg(windows)]
fn ps1_shim_escapes_quotes() {
let dir = PathBuf::from(r"C:\Users\o'brien\AppData\Roaming\io.github.hairyf.deepseek-harness-desktop");
let content = build_ps1_shim(&dir, &sample_dsh_home());
diff --git a/src-tauri/src/service/scheduler/mod.rs b/src-tauri/src/service/scheduler/mod.rs
index d37d3c3d..c09b2d37 100644
--- a/src-tauri/src/service/scheduler/mod.rs
+++ b/src-tauri/src/service/scheduler/mod.rs
@@ -11,7 +11,9 @@ pub fn start(app_handle: &AppHandle) {
}
async fn scheduler_permanent_loop(app_handle: AppHandle) {
- let mut interval = time::interval(Duration::from_secs(1));
+ // 兜底健康检查轮询:1s 偏激进(每轮 spawn 子进程探测、读文件指纹),
+ // 降为 5s,应用内状态推送仍即时(event-driven),轮询仅兜底。
+ let mut interval = time::interval(Duration::from_secs(5));
loop {
if let Err(e) = crate::task::tick_check_dsh_process::trigger(app_handle.clone()).await {
diff --git a/src/components/config-debug.tsx b/src/components/config-debug.tsx
index a33df275..25955716 100644
--- a/src/components/config-debug.tsx
+++ b/src/components/config-debug.tsx
@@ -201,7 +201,7 @@ export function ConfigDebug() {
</Info>
<Info term={t('ui.node_version')}>{info?.node_version ? `v${info.node_version}` : '-'}</Info>
- <Info term="Platform">
+ <Info term={t('ui.platform')}>
{info ? `${info.platform} / ${info.arch}` : '-'}
</Info>
<div className="flex items-center justify-between gap-2 text-xs">
diff --git a/src/components/logs.tsx b/src/components/logs.tsx
index ddc7f081..213d9151 100644
--- a/src/components/logs.tsx
+++ b/src/components/logs.tsx
@@ -2,20 +2,7 @@ import type { ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
import { If } from 'react-if-lite'
import { cn } from 'tailwind-variants'
-
-/** DSH 发行版 GitHub Release 下载 URL 前缀:日志展示时剥离,避免整段长 URL 占满一行 */
-const DSH_RELEASE_URL_PREFIX = 'https://github.com/hairyf/deepseek-harness-pkg/releases/download/'
-/** ghfast.top 镜像透传包装前缀(与官方 URL 拼接),同样剥离 */
-const DSH_MIRROR_URL_PREFIX = 'https://ghfast.top/'
-
-/**
- * 精简下载日志行:把 GitHub Release 下载 URL 缩短为「版本 tag / 文件名」,
- * 让日志里"正在下载的是什么"一目了然(如 `Download dsh-0.1.1-rc.1-32457794457/deepseek-harness-pkg-windows.zip`)。
- * 用 split/join 代替 replaceAll 以保证各构建目标下行为一致。
- */
-function formatLogLine(line: string): string {
- return line.split(DSH_RELEASE_URL_PREFIX).join('').replace(DSH_MIRROR_URL_PREFIX, '')
-}
+import { formatLogLine } from '@/utils/log-utils'
/**
* 日志面板:带边框的「› + 行」日志容器 + 空日志占位。
diff --git a/src/components/modal.tsx b/src/components/modal.tsx
index 3b2e9bea..c3b8a91c 100644
--- a/src/components/modal.tsx
+++ b/src/components/modal.tsx
@@ -1,10 +1,12 @@
import type { PropsWithOverlays } from '@overlastic/react'
-import type { AlertDialogStatus } from 'node_modules/@heroui/react/dist/components/alert-dialog/alert-dialog'
import type { ReactNode } from 'react'
import { AlertDialog, Button } from '@heroui/react'
import { useDisclosure } from '@overlastic/react'
import { useTranslation } from 'react-i18next'
+/** AlertDialog 状态色:库内 AlertDialogStatus 未从子包 re-export,本地保持同步定义 */
+export type AlertDialogStatus = 'default' | 'accent' | 'success' | 'warning' | 'danger'
+
export interface ModalProps extends PropsWithOverlays {
status: AlertDialogStatus
title?: string
diff --git a/src/components/panel-progress.tsx b/src/components/panel-progress.tsx
index ae9b054f..1c7a4f2d 100644
--- a/src/components/panel-progress.tsx
+++ b/src/components/panel-progress.tsx
@@ -37,7 +37,7 @@ export function PanelProgress({ percentage, logs }: PanelProgressProps) {
</div>
)}
{hasLogs && (
- <Logs logs={logs!} limit={LOG_LIMIT} bodyClassName="max-h-[184px]" />
+ <Logs logs={logs ?? []} limit={LOG_LIMIT} bodyClassName="max-h-[184px]" />
)}
</div>
)
diff --git a/src/hooks/define-scope.ts b/src/hooks/define-scope.ts
deleted file mode 100644
index f9eef8e6..00000000
--- a/src/hooks/define-scope.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { createContext, createElement } from 'react'
-
-export interface Scope<T> {
- Provider: React.FC<{
- children: React.ReactNode | ((value: T) => React.ReactNode)
- }>
- Context: React.Context<T | undefined>
-}
-
-export function defineScope<T>(useSetup: () => T): Scope<T> {
- const Context = createContext<T | undefined>(undefined)
-
- function Provider({ children }: any) {
- const value = useSetup()
- const child = typeof children === 'function' ? children(value) : children
- return createElement(Context.Provider, { value }, child)
- }
-
- return { Provider, Context }
-}
diff --git a/src/hooks/use-iframe-shim.ts b/src/hooks/use-iframe-shim.ts
index e59c2cfd..17d75ed7 100644
--- a/src/hooks/use-iframe-shim.ts
+++ b/src/hooks/use-iframe-shim.ts
@@ -231,6 +231,6 @@ export function useIframeShim(iframeRef: RefObject<HTMLIFrameElement | null>) {
// eslint-disable-next-line react/exhaustive-deps
}, [])
- // 兜底轮询:覆盖监听不到的状态变化(如任务栏切换)
- useInterval(syncVisibility, 1000)
+ // 兜底轮询:覆盖监听不到的状态变化(如任务栏切换);主路径是文档可见性事件,5s 足够
+ useInterval(syncVisibility, 5000)
}
diff --git a/src/hooks/use-scope.ts b/src/hooks/use-scope.ts
deleted file mode 100644
index 894b105a..00000000
--- a/src/hooks/use-scope.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/* eslint-disable react/no-use-context */
-import type { Scope } from './define-scope'
-import { useContext } from 'react'
-
-export function useScope<T>(scope: Scope<T>) {
- const value = useContext(scope.Context)
- if (!value)
- throw new Error('Scope not found')
- return value
-}
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index db3c6f85..d2461422 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -1,24 +1,14 @@
{
- "app.title": "DeepSeek Harness Desktop",
"app.wordmark": "HARNESS",
"app.retry": "Retry",
- "app.ready": "DeepSeek Harness is ready!",
"app.open_editor": "Open DeepSeek Harness",
"app.expand_sidebar": "Expand sidebar",
"app.restart": "Restart",
"app.shutdown": "Stop",
"app.open_browser": "Open in Browser",
- "app.copy_url": "Copy URL",
"app.reveal_dir": "Open Data Folder",
- "app.refresh": "Refresh",
- "status.checking": "Checking system environment...",
"status.installing": "Installing dependencies...",
"status.updating": "Updating DeepSeek Harness...",
- "status.preparing_engine": "Preparing Node.js runtime... {{progress}}%",
- "status.downloading_harness": "Downloading DeepSeek Harness... {{progress}}%",
- "status.extracting": "Extracting resource package...",
- "status.starting": "Starting DeepSeek Harness service...",
- "status.ready": "Service is ready",
"status.error": "Startup failed",
"status.loading": "Loading plugins…",
"status.loading_plugins": "Loading plugins…",
@@ -37,12 +27,12 @@
"preinstall.empty": "No preinstalled plugins available.",
"preinstall.settings_title": "Recommended Plugins",
"preinstall.settings_hint": "Reopen the preset wizard to re-select or install recommended plugins.",
+ "preinstall.restarting_hint": "[harness] Restarting the service, please wait…",
"preinstall.open_preset": "Open Preset",
"plugins.title": "Installed Plugins",
"plugins.empty": "No plugins installed",
"plugins.loading": "Loading plugins…",
"plugins.error": "Failed to load plugins",
- "plugins.bundled": "Loaded",
"update.available": "A new DSH version {{tag}} is available. Update now?",
"update.now": "Update Now",
"update.later": "Later",
@@ -73,55 +63,34 @@
"download.show_in_folder": "Open",
"errors.service_start_timeout": "DeepSeek Harness startup timeout. Please check whether port {{port}} is occupied or the startup is too slow.",
"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.install_verify_failed": "Package downloaded but installation verification failed.",
- "errors.network_timeout": "Network download timeout. Please check your network connection.",
- "errors.unknown": "Unknown error",
"ui.service_url": "Service URL",
"ui.port": "Port",
- "ui.auto_start": "Auto-start on launch",
"ui.cli_link": "CLI Integration",
"ui.cli_link_enabled": "Enable dsh command",
- "ui.cli_link_status_ok": "Enabled — type dsh in a new terminal",
- "ui.cli_link_status_partial": "Enabled but PATH registration incomplete — try saving again",
- "ui.cli_link_status_unknown": "Status unknown",
"ui.cli_link_hint": "Run dsh --help in a new terminal",
"ui.cli_link_user_dsh_preserved": "A dsh you installed yourself was detected and preserved — the dsh command still points to your own install and config",
- "ui.app_info": "App Information",
"ui.current_version": "Current Version",
"ui.dsh_version": "Harness Version",
"ui.node_version": "Node.js Runtime",
+ "ui.platform": "Platform",
"ui.data_dir": "Data Directory",
"ui.logs": "Service Logs",
"ui.no_logs": "(no logs yet)",
- "ui.save": "Save",
- "ui.saved": "Saved",
- "ui.loading_interface": "Loading DeepSeek Harness interface...",
"ui.iframe_error": "Cannot load the DeepSeek Harness interface.",
"ui.ensure_running": "Please make sure the service is running at {{url}}.",
"ui.language": "Language",
- "ui.actions": "Actions",
"ui.connection_status": "Connection",
"ui.running": "Running",
"ui.stopped": "Stopped",
- "ui.settings": "Settings",
"ui.waiting_logs": "Waiting for installation logs...",
"ui.install_log": "Installation log",
- "buttons.retry": "Retry",
"buttons.save": "Save",
"buttons.copy": "Copy",
- "buttons.clear_logs": "Clear Logs",
- "buttons.refresh_logs": "Refresh",
"messages.copy_success": "URL copied to clipboard",
"messages.log_copied": "Logs copied to clipboard",
"messages.copy_failed": "Failed to copy URL",
"messages.port_changed": "Port changed",
"messages.port_restart_hint": "It takes effect after the service restarts. Restart now?",
- "messages.save_failed": "Failed to save configuration",
- "messages.cli_link_enabled": "dsh command enabled — open a new terminal to use it",
- "messages.cli_link_disabled": "dsh command removed",
- "messages.start_failed": "Failed to start service",
- "messages.stop_failed": "Failed to stop service",
- "messages.restarting": "Restarting service...",
"messages.logs_cleared": "Logs cleared",
"nav.sidebar_expand": "Expand sidebar",
"nav.sidebar_collapse": "Collapse sidebar",
@@ -130,14 +99,10 @@
"nav.minimize": "Minimize",
"nav.maximize": "Maximize",
"nav.background": "Background",
- "app.debug_sidebar_title": "Application Debug",
"messages.logs_copied": "Logs copied to clipboard",
- "app.debug": "Debug",
"app.help": "Help",
- "app.application": "Application",
"profiles.title": "Profiles",
"profiles.tooltip": "Profiles are isolated bundles of plugins, patches and settings in dsh. The desktop runs in the default web profile; create new profiles to trial different plugin combinations without affecting the current setup.",
- "profiles.active": "Active",
"profiles.default_desc": "Desktop's default profile",
"profiles.new_profile": "New Profile",
"profiles.name_placeholder": "Profile name",
@@ -157,24 +122,17 @@
"plugins.panel_tooltip": "Installed plugins, read-only. Plugins normally need no management here — upgrade or uninstall one only when it is causing problems.",
"plugins.uninstall": "Uninstall",
"plugins.upgrade": "Upgrade",
- "plugins.open_repo": "Open repository",
"plugins.abnormal_tooltip": "This plugin is running abnormally. Click to view details.",
- "plugins.error_parse": "Failed to read the plugin's metadata (package.json is missing or corrupt).",
"plugins.abnormal_desc": "Plugin {{name}} is abnormal and may be corrupted or incompatible with the current environment.",
- "plugins.error_log": "Error log",
"plugins.remove_confirm_title": "Uninstall plugin",
"plugins.remove_confirm_desc": "Uninstall {{name}}? Its features will no longer be available after removal.",
"plugins.remove_failed": "Failed to uninstall {{name}}",
"plugins.upgrade_failed": "Failed to upgrade {{name}}",
"plugins.updated_toast": "Plugin {{name}} updated",
"plugins.removed_toast": "Plugin {{name}} uninstalled",
- "plugins.close": "Close",
- "plugins.copy_failed": "Failed to copy the error log",
"core.title": "Harness Core",
"core.tooltip": "Harness Core is the dsh engine powering the desktop. Manage local copies of each version here — switch the running version, or uninstall ones you no longer need.",
"core.local": "Local",
- "core.local_hint": "installed via CLI before Desktop was set up",
- "core.in_use": "In use",
"core.uninstall": "Uninstall",
"core.not_downloaded": "not downloaded",
"core.switch_confirm_title": "Switch version",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 9e75c66b..71b9a8c9 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -1,24 +1,14 @@
{
- "app.title": "DeepSeek Harness 桌面版",
"app.wordmark": "HARNESS",
"app.retry": "重试",
- "app.ready": "DeepSeek Harness 已就绪!",
"app.open_editor": "打开 DeepSeek Harness",
"app.expand_sidebar": "展开侧边栏",
"app.restart": "重启",
"app.shutdown": "停止",
"app.open_browser": "在浏览器中打开",
- "app.copy_url": "复制地址",
"app.reveal_dir": "打开数据目录",
- "app.refresh": "刷新",
- "status.checking": "正在检查系统环境...",
"status.installing": "正在安装依赖...",
"status.updating": "正在更新 DeepSeek Harness...",
- "status.preparing_engine": "正在准备 Node.js 运行时... {{progress}}%",
- "status.downloading_harness": "正在下载 DeepSeek Harness... {{progress}}%",
- "status.extracting": "正在解压资源包...",
- "status.starting": "正在启动 DeepSeek Harness 服务...",
- "status.ready": "服务已就绪",
"status.error": "启动失败",
"status.loading": "Loading plugins…",
"status.loading_plugins": "Loading plugins…",
@@ -37,12 +27,12 @@
"preinstall.empty": "暂无可预装的插件。",
"preinstall.settings_title": "预装插件",
"preinstall.settings_hint": "重新打开预设引导,可重新选择或安装推荐的插件。",
+ "preinstall.restarting_hint": "[harness] 正在重启服务,请稍候…",
"preinstall.open_preset": "打开预设",
"plugins.title": "已安装插件",
"plugins.empty": "暂无已安装插件",
"plugins.loading": "正在读取插件…",
"plugins.error": "插件读取失败",
- "plugins.bundled": "已加载",
"update.available": "发现 DSH 新版本 {{tag}},是否立即更新?",
"update.now": "立即更新",
"update.later": "稍后",
@@ -73,55 +63,34 @@
"download.show_in_folder": "打开",
"errors.service_start_timeout": "DeepSeek Harness 启动超时,请检查端口 {{port}} 是否被占用或启动过慢。",
"errors.plugin_route_conflict": "检测到插件路由冲突:两个插件重复注册了同一路由。请在「插件」面板卸载最近安装的插件(如 dsh-web-ui-all / dsh-better-sidebar),或在终端对当前档案执行 dsh plugin --profile <档案名> remove <包名> 后重试。",
- "errors.install_verify_failed": "资源包已下载,但安装校验失败。",
- "errors.network_timeout": "网络下载超时,请检查网络连接后重试。",
- "errors.unknown": "未知错误",
"ui.service_url": "服务地址",
"ui.port": "端口",
- "ui.auto_start": "启动时自动运行",
"ui.cli_link": "命令行集成",
"ui.cli_link_enabled": "启用 dsh 命令",
- "ui.cli_link_status_ok": "已启用 — 新开终端后输入 dsh 即可使用",
- "ui.cli_link_status_partial": "已开启,但 PATH 注册不完整,请重新保存",
- "ui.cli_link_status_unknown": "状态未知",
"ui.cli_link_hint": "在新终端中运行 dsh --help 查看用法",
"ui.cli_link_user_dsh_preserved": "检测到你已自行安装 dsh,已保留未覆盖;终端中的 dsh 仍指向你自己的安装与配置",
- "ui.app_info": "应用信息",
"ui.current_version": "当前版本",
"ui.dsh_version": "Harness 版本",
"ui.node_version": "Node.js 运行时",
+ "ui.platform": "平台",
"ui.data_dir": "数据目录",
"ui.logs": "服务日志",
"ui.no_logs": "(暂无日志)",
- "ui.save": "保存",
- "ui.saved": "已保存",
- "ui.loading_interface": "正在加载 DeepSeek Harness 界面...",
"ui.iframe_error": "无法加载 DeepSeek Harness 界面。",
"ui.ensure_running": "请确认服务正在 {{url}} 运行。",
"ui.language": "语言",
- "ui.actions": "操作",
"ui.connection_status": "连接状态",
"ui.running": "运行中",
"ui.stopped": "已停止",
- "ui.settings": "设置",
"ui.waiting_logs": "等待安装日志...",
"ui.install_log": "安装日志",
- "buttons.retry": "重试",
"buttons.save": "保存",
"buttons.copy": "复制",
- "buttons.clear_logs": "清空日志",
- "buttons.refresh_logs": "刷新",
"messages.copy_success": "地址已复制到剪贴板",
"messages.log_copied": "日志已复制到剪贴板",
"messages.copy_failed": "复制地址失败",
"messages.port_changed": "端口已更改",
"messages.port_restart_hint": "重启服务后生效,是否立即重启?",
- "messages.save_failed": "保存配置失败",
- "messages.cli_link_enabled": "已启用 dsh 命令,新开终端后生效",
- "messages.cli_link_disabled": "已移除 dsh 命令",
- "messages.start_failed": "启动服务失败",
- "messages.stop_failed": "停止服务失败",
- "messages.restarting": "正在重启服务...",
"messages.logs_cleared": "日志已清空",
"nav.sidebar_expand": "展开侧边栏",
"nav.sidebar_collapse": "收起侧边栏",
@@ -130,14 +99,10 @@
"nav.minimize": "最小化",
"nav.maximize": "最大化",
"nav.background": "后台化",
- "app.debug_sidebar_title": "应用调试",
"messages.logs_copied": "日志已复制到剪贴板",
- "app.debug": "调试",
"app.help": "帮助",
- "app.application": "应用",
"profiles.title": "档案",
"profiles.tooltip": "档案是 dsh 中一组相互隔离的配置集合,包含各自的插件、补丁与设置。桌面端运行在默认的 web 档案中;新建档案可试用不同的插件组合而不影响当前配置。",
- "profiles.active": "使用中",
"profiles.default_desc": "默认档案",
"profiles.new_profile": "新建档案",
"profiles.name_placeholder": "档案名称",
@@ -157,24 +122,17 @@
"plugins.panel_tooltip": "该面板只读展示已安装插件。插件通常无需在此管理;仅当某个插件出现问题时,才需要在这里升级或卸载它。",
"plugins.uninstall": "卸载",
"plugins.upgrade": "升级",
- "plugins.open_repo": "打开仓库",
"plugins.abnormal_tooltip": "此插件运行异常,点击查看详情。",
- "plugins.error_parse": "读取插件元信息失败(package.json 缺失或损坏)。",
"plugins.abnormal_desc": "插件 {{name}} 运行异常,可能已损坏或与当前环境不兼容。",
- "plugins.error_log": "错误日志",
"plugins.remove_confirm_title": "卸载插件",
"plugins.remove_confirm_desc": "确定卸载插件 {{name}} 吗?卸载后其功能将不可用。",
"plugins.remove_failed": "卸载插件 {{name}} 失败",
"plugins.upgrade_failed": "升级插件 {{name}} 失败",
"plugins.updated_toast": "插件 {{name}} 已更新",
"plugins.removed_toast": "插件 {{name}} 已卸载",
- "plugins.close": "关闭",
- "plugins.copy_failed": "复制错误日志失败",
"core.title": "核心引擎",
"core.tooltip": "Harness Core 是驱动桌面端的 dsh 引擎。这里管理各版本的本地副本:切换到指定版本运行,或卸载不再需要的版本。",
"core.local": "本地",
- "core.local_hint": "未安装桌面端前由 CLI 安装的版本",
- "core.in_use": "使用中",
"core.uninstall": "卸载",
"core.not_downloaded": "未下载",
"core.switch_confirm_title": "切换版本",
diff --git a/src/layout/components/loadable.tsx b/src/layout/components/loadable.tsx
index 75c535c5..36b61245 100644
--- a/src/layout/components/loadable.tsx
+++ b/src/layout/components/loadable.tsx
@@ -1,5 +1,6 @@
import type { ComponentType, ReactNode, SVGProps } from 'react'
import { useTranslation } from 'react-i18next'
+import { If } from 'react-if-lite'
import { PanelProgress } from '@/components/panel-progress'
import { button } from '@/components/primitives'
@@ -58,36 +59,40 @@ export function Loadable({
<div className="flex h-full items-center justify-center bg-load-bg -mt-[1px]">
<div className="flex w-[min(460px,88vw)] flex-col items-center gap-4 text-center">
{/* 加载态显示 spinner 时隐藏图标(官方 boot 页即无图标),避免与 spinner 重复突兀;仅失败态显示 */}
- {error && Icon && <Icon className="size-7 text-load-ink" />}
+ {/* 加载态显示 spinner 时隐藏图标(官方 boot 页即无图标),避免与 spinner 重复突兀;仅失败态显示 */}
+ <If cond={error && Icon != null}>
+ {Icon != null && <Icon className="size-7 text-load-ink" />}
+ </If>
<span className="text-base leading-6 font-semibold tracking-[0.08em] text-load-ink truncate">{wordmark}</span>
- {error
- ? (
- // 失败态:官方 failed 展示样式(代码字体错误信息)
- <p className="min-h-[18px] max-w-full font-mono text-xs leading-[18px] break-all text-load-muted">{hint}</p>
- )
- : (
- <>
- <span className="h-5 w-5 animate-load-spin rounded-full border-2 border-load-ring border-t-load-ink" />
- <p className="min-h-[18px] text-xs leading-[18px] break-all text-load-muted">{hint}</p>
- </>
- )}
+ <If
+ cond={error}
+ else={(
+ <>
+ <span className="h-5 w-5 animate-load-spin rounded-full border-2 border-load-ring border-t-load-ink" />
+ <p className="min-h-[18px] text-xs leading-[18px] break-all text-load-muted">{hint}</p>
+ </>
+ )}
+ >
+ {/* 失败态:官方 failed 展示样式(代码字体错误信息) */}
+ <p className="min-h-[18px] max-w-full font-mono text-xs leading-[18px] break-all text-load-muted">{hint}</p>
+ </If>
- {onRetry && (
+ <If cond={onRetry != null}>
<button
className={button({ tone: 'primary' })}
onClick={onRetry}
>
{t('app.retry')}
</button>
- )}
+ </If>
- {showPanel && (
+ <If cond={showPanel}>
<div className="flex w-full flex-col gap-4">
- <PanelProgress percentage={percentage} logs={hasLogs ? logs! : undefined} />
+ <PanelProgress percentage={percentage} logs={logs} />
</div>
- )}
+ </If>
{children}
</div>
diff --git a/src/layout/components/webview.tsx b/src/layout/components/webview.tsx
index 8d09ff65..182604d7 100644
--- a/src/layout/components/webview.tsx
+++ b/src/layout/components/webview.tsx
@@ -77,25 +77,24 @@ export function Webview() {
{/* iframe 区域:加载失败时用覆盖层展示重试(iframe 保持挂载,重试复用) */}
<div className="relative min-h-0 flex-1">
- {serviceHealthy
- ? (
- <iframe
- key={iframeKey}
- ref={iframeRef}
- className="block h-full w-full border-none bg-load-bg"
- src={iframeSrc}
- allow="clipboard-read; clipboard-write; fullscreen"
- sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-downloads allow-storage-access-by-user-activation"
- onLoad={store.harness.markIframeLoaded}
- onError={store.harness.markIframeError}
- title={t('app.open_editor')}
- />
- )
- : (
- <Loadable subtitle={t('status.loading')} />
- )}
+ <If
+ cond={serviceHealthy}
+ else={<Loadable subtitle={t('status.loading')} />}
+ >
+ <iframe
+ key={iframeKey}
+ ref={iframeRef}
+ className="block h-full w-full border-none bg-load-bg"
+ src={iframeSrc}
+ allow="clipboard-read; clipboard-write; fullscreen"
+ sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-downloads allow-storage-access-by-user-activation"
+ onLoad={store.harness.markIframeLoaded}
+ onError={store.harness.markIframeError}
+ title={t('app.open_editor')}
+ />
+ </If>
- {serviceHealthy && iframeError && (
+ <If cond={serviceHealthy && iframeError}>
<div className="absolute inset-0 z-[1]">
<Loadable
icon={CircleExclamation}
@@ -104,7 +103,7 @@ export function Webview() {
onRetry={store.harness.refreshIframe}
/>
</div>
- )}
+ </If>
</div>
</main>
)
diff --git a/src/layout/index.tsx b/src/layout/index.tsx
index 792c589f..94685f3f 100644
--- a/src/layout/index.tsx
+++ b/src/layout/index.tsx
@@ -1,4 +1,5 @@
import { useEffect } from 'react'
+import { If } from 'react-if-lite'
import { useStore } from 'valtio-define'
import { PluginRecovery } from '../components/plugin-recovery'
import { useDshTheme } from '../hooks/use-dsh-theme'
@@ -59,10 +60,16 @@ export function App() {
return (
<div className="flex h-screen w-screen">
<Webview />
- {status === 'ready' && <HarnessUpdater />}
- {status === 'ready' && <DownloadToast />}
+ <If cond={status === 'ready'}>
+ <HarnessUpdater />
+ </If>
+ <If cond={status === 'ready'}>
+ <DownloadToast />
+ </If>
{/* 运行期插件异常:应用仍在运行,弹醒目对话框(启动崩溃走 webview 的全屏恢复页) */}
- {status === 'ready' && <PluginRecovery />}
+ <If cond={status === 'ready'}>
+ <PluginRecovery />
+ </If>
<DesktopUpdater />
</div>
)
diff --git a/src/store/modules/harness/store.ts b/src/store/modules/harness/store.ts
index b51e638d..3b3781d5 100644
--- a/src/store/modules/harness/store.ts
+++ b/src/store/modules/harness/store.ts
@@ -17,13 +17,12 @@ import i18next from 'i18next'
import { defineStore } from 'valtio-define'
import { queryClient } from '@/config/client'
import { harnessUpdater } from '../harness-updater'
+import { pickErrorLines } from '@/utils/log-utils'
const MAX_RETRIES = 8
const IFRAME_LOAD_TIMEOUT = 20000
/** 启动失败时从服务日志尾部挑选的原始行上限(ANSI 清洗后按行截断) */
const LOG_TAIL_MAX_BYTES = 16 * 1024
-/** 日志中常见的错误标记,用于失败时挑出真正的问题行而不是整个堆栈 */
-const ERROR_LINE_MARKERS = /error|duplicate|fatal|panic|throw|✖|exception|failed/i
/** 启动失败错误:附带从 dsh 服务日志中读取的真实错误行与可选的冲突提示 */
interface StartupError extends Error {
@@ -121,12 +120,6 @@ async function readServiceLogTail(): Promise<string[]> {
}
}
-/** 从日志行中挑出真正的错误行(命中错误标记,最多 8 行);没有命中则退回最后 8 行 */
-function pickErrorLines(lines: string[]): string[] {
- const errored = lines.filter(line => ERROR_LINE_MARKERS.test(line)).slice(0, 8)
- return errored.length > 0 ? errored : lines.slice(-8)
-}
-
/** 失败时把服务日志的真实错误行与冲突提示挂到错误对象上 */
async function attachStartupDiagnostics(err: unknown): Promise<StartupError> {
const startupError = err as StartupError
@@ -583,7 +576,7 @@ export const harness = defineStore({
await invoke('install_preinstall_plugins', { ids })
// 后端装完已把服务停掉,这里在日志面板讲清接下来的重启(issue #48),
// 避免用户把"插件安装后的自动重启"误认为崩溃/故障。
- this.preinstall.logs = [...this.preinstall.logs, '[harness] 正在重启服务,请稍候…'].slice(-200)
+ this.preinstall.logs = [...this.preinstall.logs, i18next.t('preinstall.restarting_hint')].slice(-200)
await this.continueAfterPreinstall()
}
catch (err) {
diff --git a/src/utils/log-utils.ts b/src/utils/log-utils.ts
new file mode 100644
index 00000000..ac88b9e9
--- /dev/null
+++ b/src/utils/log-utils.ts
@@ -0,0 +1,28 @@
+/** DSH 发行版 GitHub Release 下载 URL 前缀:日志展示时剥离,避免整段长 URL 占满一行 */
+const DSH_RELEASE_URL_PREFIX = 'https://github.com/hairyf/deepseek-harness-pkg/releases/download/'
+/** ghfast.top 镜像透传包装前缀(与官方 URL 拼接),同样剥离 */
+const DSH_MIRROR_URL_PREFIX = 'https://ghfast.top/'
+
+/** 日志中认定为「错误行」的标记(大小写不敏感) */
+const ERROR_LINE_MARKERS = /error|duplicate|fatal|panic|throw|✖|exception|failed/i
+
+/**
+ * 精简下载日志行:把 GitHub Release 下载 URL 缩短为「版本 tag / 文件名」,
+ * 让日志里"正在下载的是什么"一目了然(如 `Download dsh-0.1.1-rc.1-32457794457/...zip`)。
+ * 用 split/join 代替 replaceAll 以保证各构建目标下行为一致。
+ */
+export function formatLogLine(line: string): string {
+ return line
+ .split(DSH_RELEASE_URL_PREFIX)
+ .join('')
+ .replace(DSH_MIRROR_URL_PREFIX, '')
+}
+
+/**
+ * 从日志行中挑出真正的错误行(命中错误标记,最多 8 行);没有命中则退回最后 8 行。
+ * 纯函数:仅依赖字符串输入,便于单元测试。
+ */
+export function pickErrorLines(lines: readonly string[]): string[] {
+ const errored = lines.filter(line => ERROR_LINE_MARKERS.test(line)).slice(0, 8)
+ return errored.length > 0 ? errored : lines.slice(-8)
+}
\ No newline at end of file
diff --git a/src/utils/toast.ts b/src/utils/toast.ts
index ba23eab6..4b8b7403 100644
--- a/src/utils/toast.ts
+++ b/src/utils/toast.ts
@@ -1,7 +1,10 @@
import type { ToastVariants } from '@heroui/styles'
-import type { HeroUIToastOptions } from 'node_modules/@heroui/react/dist/components/toast/toast-queue'
+import type { ToastContentValue } from '@heroui/react/toast'
import { ToastQueue } from '@heroui/react'
+/** toast() 可选项:库内未暴露的 HeroUIToastOptions(toast-queue 收敛的 content + 超时回调),这里用公开的 ToastContentValue 组合 */
+export type ToastOptions = Partial<ToastContentValue & { timeout?: number, onClose?: () => void }> & { placement?: Placement }
+
export type Placement = NonNullable<ToastVariants['placement']>
export const placements = [
'top start',
@@ -20,7 +23,7 @@ const placementsKeys = new Map<string, Placement>()
export function toast(
message: string,
- options?: HeroUIToastOptions & { placement?: Placement },
+ options?: ToastOptions,
) {
// 默认右下角;个别调用方需要其他位置时显式传 placement
const { placement = 'bottom end', ...rest } = options || {}
diff --git a/test/index.test.ts b/test/index.test.ts
index 401553c6..1895b1b0 100644
--- a/test/index.test.ts
+++ b/test/index.test.ts
@@ -1,7 +1,43 @@
import { describe, expect, it } from 'vitest'
+import { formatLogLine, pickErrorLines } from '../src/utils/log-utils'
-describe('should', () => {
- it('exported', () => {
- expect(1).toEqual(1)
+describe('formatLogLine', () => {
+ it('strips the official GitHub release download prefix', () => {
+ const url = 'https://github.com/hairyf/deepseek-harness-pkg/releases/download/dsh-0.1.1-rc.1-32457794457/deepseek-harness-pkg-windows.zip'
+ expect(formatLogLine(`Download ${url}`)).toBe(
+ 'Download dsh-0.1.1-rc.1-32457794457/deepseek-harness-pkg-windows.zip',
+ )
+ })
+
+ it('strips the ghfast.top mirror wrapper prefix', () => {
+ const url = 'https://ghfast.top/https://github.com/hairyf/deepseek-harness-pkg/releases/download/dsh-0.1.x-x/deepseek-harness-pkg-linux.zip'
+ expect(formatLogLine(`Download ${url}`)).toContain('deepseek-harness-pkg-linux.zip')
+ expect(formatLogLine(`Download ${url}`)).not.toContain('ghfast.top')
+ })
+
+ it('leaves ordinary log lines untouched', () => {
+ expect(formatLogLine('[info] task 1 completed')).toBe('[info] task 1 completed')
})
})
+
+describe('pickErrorLines', () => {
+ it('picks lines matching error markers, capped at 8', () => {
+ const lines = Array.from({ length: 12 }, (_, i) => `line ${i}`)
+ lines[1] = 'fatal: something broke'
+ lines[9] = 'Error: ENOENT'
+ const picked = pickErrorLines(lines)
+ expect(picked).toContain('fatal: something broke')
+ expect(picked).toContain('Error: ENOENT')
+ expect(picked.length).toBeLessThanOrEqual(8)
+ })
+
+ it('falls back to the last 8 lines when nothing matches', () => {
+ const lines = Array.from({ length: 20 }, (_, i) => `plain log ${i}`)
+ const picked = pickErrorLines(lines)
+ expect(picked).toEqual(lines.slice(-8))
+ })
+
+ it('handles empty input', () => {
+ expect(pickErrorLines([])).toEqual([])
+ })
+})
\ No newline at end of file