dsh-tray-restart
Manifest validAdds a Restart item to the DeepSeek Harness desktop system-tray menu and re-applies the patch after every app update.
dsh-tray-restart
给 DeepSeek Harness 官方桌面端 的 Windows 系统托盘(任务栏通知区)右键菜单加两项:
「重启应用与 Host」 和 「刷新页面」(刷新前端),并在桌面端每次自动更新覆盖
app.asar 之后自动重打补丁。
Adds Restart App and Host and Reload Page (refresh the frontend) items to the Windows system-tray menu of the official DeepSeek Harness desktop shell, and re-applies the patch after every desktop update.
效果 / What you get
托盘菜单从:
打开 DeepSeek Harness
────────────
退出 DeepSeek Harness
变成:
打开 DeepSeek Harness
重启应用与 Host ← 新增
刷新页面 ← 新增(刷新前端,Host 不重启)
────────────
退出 DeepSeek Harness
- 重启应用与 Host:执行
app.relaunch(); quitWithoutConfirmation(),与官方开发版应用菜单 里的同名项一致——干净退出 Host、重启整个应用,不弹“任务仍在运行”的确认框。 - 刷新页面:对主窗口执行
webContents.reload(),等价于前台按Ctrl+R。只重载前端页面, Host、会话和正在跑的任务都不受影响;前端改坏了、白屏或要重新加载界面时用。
两项都复用官方已有的本地化文案(messages.restartAppHostMenu / messages.reloadPageMenu),
中英文随系统语言切换。
安装 / Install
需要 DSH 桌面端 0.2.x(Windows)。已在 @deepseek-ai/dsh-desktop 0.2.1-rc.2 +
Windows 11 + Node 24 上验证。
方式一:插件管理器(桌面端推荐)
- 把本仓库克隆到任意目录:
git clone https://github.com/QIRSHENG/dsh-tray-restart.git - 打开 DeepSeek Harness → 设置 → 插件,选择“从本地目录安装”,指向克隆下来的
dsh-tray-restart目录(就是含package.json的那一层)。 - 安装完成后 完全退出并重新打开 DeepSeek Harness。
桌面端 profile 由 Electron 应用独占管理,dsh plugin --profile desktop ... 会被拒绝,
所以桌面端请走插件管理器(或由 agent 调用 plugin_manager 的 install_bundle)。
方式二:CLI(非桌面端独占的 profile)
dsh plugin --profile <profile> add github:QIRSHENG/dsh-tray-restart
# 或本地目录
dsh plugin --profile <profile> add C:\path\to\dsh-tray-restart
安装完成后 完全退出并重新打开 DeepSeek Harness。桌面端主进程代码只在启动时加载, 所以托盘菜单会在下一次启动时出现。
安装后如果托盘还没变,先退出应用(托盘 → 退出),在 PowerShell 里运行一次
node lib/patcher.mjs status确认status: "patched",再启动应用。
为什么需要改 app.asar / Why an asar patch
DSH 插件跑在 Host 子进程里(Cordis),而系统托盘属于 Electron 主进程。官方没有暴露
托盘 / Electron 主进程的扩展点,所以插件只能给 resources/app.asar 里的
/lib/main.js 打一个最小补丁。
补丁的设计约束:
- 等长改写:托盘菜单模板被压紧,插入两项后用尾部空白补齐,
/lib/main.js的 字节数完全不变 → asar 头里其它文件的offset全部保持有效。 - 只改托盘这一处:仅
DesktopTray.relabel()的tray.setContextMenu(...)模板; 为腾出字节会同时压缩两段纯注释(不改变任何行为)。锚点不唯一、结构不认识或长度 会变大时 拒绝写入。 - 可升级旧补丁:1.0.x 只加了重启项;1.1.0 会把旧补丁原地升级成「重启 + 刷新」两项。
- 同步完整性摘要:同时刷新 asar 目录里
/lib/main.js的 SHA-256(等长 hex), 即使EnableEmbeddedAsarIntegrityValidation被打开也不会失配。 - 可回滚:首次写入前把原始
/lib/main.js保存到%USERPROFILE%\.dsh\dsh-tray-restart\main.original.js,restore命令可原样写回。 - 幂等:已经是补丁状态时只做只读检查。
插件在每次 Host 启动约 2 秒后运行一次检查,因此桌面端自动更新把 app.asar 换回官方版本后,
下一次启动会自动重打补丁(那一次启动看到的还是旧菜单,再启动一次即可)。
更新后的第一次启动只负责重打补丁;托盘菜单在下一次启动才出现。
手动命令 / Manual CLI
任何 Node.js ≥ 20 都可以直接运行补丁器(不需要安装插件):
node lib/patcher.mjs status # 只读检查
node lib/patcher.mjs apply # 需要时打补丁(幂等)
node lib/patcher.mjs apply --dry-run # 只检查能否安全打补丁
node lib/patcher.mjs restore # 写回安装前的原始 main.js
加 --json 输出机器可读结果,加 --asar <path> 指定别的 app.asar。
默认路径:%LOCALAPPDATA%\Programs\DeepSeek Harness\resources\app.asar;
也可用环境变量 DSH_DESKTOP_APP_ASAR 覆盖。
每次运行的记录在 %USERPROFILE%\.dsh\dsh-tray-restart\status.json。
卸载 / Uninstall
# 1. 先还原托盘菜单
node lib/patcher.mjs restore
# 2. 移除插件(桌面端:在插件管理器里移除;其它 profile 用 CLI)
dsh plugin --profile <profile> remove dsh-tray-restart
如果 restore 报 size-mismatch(桌面端版本已经变化),直接重新安装官方桌面端即可。
安全边界 / Safety
- 只支持 官方 Windows 桌面端(打包的 Electron 应用);开发模式、
dsh web、dsh --profile headless没有系统托盘,插件会安全跳过。 - 只改写
/lib/main.js中一段已知的托盘菜单模板;任何结构变化都会让补丁失败而不是写坏文件。 - 不改注册表、不加启动项、不联网。
- 桌面端升级后若补丁失败,菜单只是保持官方原样,不会影响应用启动。
- 如果应用因任何原因无法启动,先
node lib/patcher.mjs restore;仍不行则重装桌面端。
已知限制 / Limitations
- 需要重启应用才能看到菜单(主进程代码只在启动时读取)。
- 官方桌面端更新后需要启动两次:第一次重打补丁,第二次显示菜单。
- 与其它直接修改
app.asar的工具可能冲突;发现status: "unsupported"时不要强行写入。 - 非 Windows 平台不支持(macOS 的菜单栏与 Linux 的托盘实现不同)。
文件结构 / Layout
index.js Cordis Host 插件:每次 Host 启动检查/重打补丁
lib/patcher.mjs 等长改写补丁器 + CLI(status / apply / restore)
cordis.patch.yml bundle patch:插入插件行
locale/*.json 插件管理器展示文案
icon.svg 插件图标
开发 / Development
node --check index.js
node --test test/patcher.test.mjs # 用合成 asar 验证打补丁/还原
node lib/patcher.mjs apply --dry-run --json
补丁器是纯 ESM、零依赖;只使用 node:fs、node:crypto、node:path。
License
MIT License © 2026 Paint-RS
Comments
Loading…
Similar plugins
by IHS470
DeepSeek Harness restart button in the DSH desktop window title bar
★ 3
↓ 55/wk
MIT
JavaScript
Oct 3, 2026
dsh plugin --profile web add dsh-plugin-restartby StarMoon-win
Sidebar restart button for DeepSeek Harness Desktop: one click fully quits and reopens the app.
★ 0
MIT
JavaScript
Oct 19, 2026
dsh plugin --profile web add dsh-restartby wodongx123
Adds a system tray icon to DSH Desktop, with settings to hide the main window to the tray on minimize or close and self-healing after app updates.
★ 0
MIT
JavaScript
Aug 26, 2026
dsh plugin --profile web add dsh-desktop-trayby lux09947-cmyk
Adds a refresh button to the DeepSeek Harness desktop title bar next to the Edit menu, reloading the interface without restarting the app.
★ 1
MIT
JavaScript
Oct 1, 2026
dsh plugin --profile web add dsh-reby StabCut
DSH Desktop sidebar restart button: orderly relaunch of DSH Desktop from the sidebar settings row (based on desktopActions.requestRestart).
★ 0
MIT
JavaScript
Aug 21, 2026
dsh plugin --profile web add dsh-plugin-restart-desktopby csuwzw
一键重启 DeepSeek Harness 的插件:标题栏按钮,两次点击完成重启,让新装的插件立即生效。One-click restart for DeepSeek Harness.
★ 0
MIT
JavaScript
Oct 17, 2026
dsh plugin --profile web add dsh-restart