- Главная
- Плагины
- Разработка и инструменты плагинов
- dsh-tray-restart
dsh-tray-restart
g1111b/dsh-tray-restart
Adds a restart item to the DeepSeek Harness tray menu that relaunches the whole desktop app.
Установка
dsh plugin --profile web add github:g1111b/dsh-tray-restartREADME
dsh-tray-restart
Adds Restart DeepSeek Harness to the tray icon's right-click menu, so a wedged session can be restarted without hunting for the window.
Windows only · DSH desktop · MIT
中文
给 DeepSeek Harness 的托盘图标右键菜单加一条 重启 DeepSeek Harness,一键重启整个桌面应用——窗口最小化或收进托盘时也能用。
托盘菜单变成:
打开应用
重启 DeepSeek Harness
──────────────
退出应用
安装
dsh plugin add dsh-tray-restart
或在 DSH 的 Plugins → Add plugin 里填写 dsh-tray-restart。
装好后重启一次 DSH:托盘菜单在应用启动时构建,当前进程看不到新条目。
它做了什么
DSH 的托盘菜单是 Electron 主进程里的静态代码(app.asar 内 lib/main.js 的 DesktopTray#relabel)。插件运行在 Host 子进程里,那是一个纯 Node 进程,拿不到 Electron 的 Tray / Menu / app.relaunch,也没有向主进程请求重启的 IPC 通道,所以无法在运行期扩展菜单,只能改写那段模板本身。
改写方式是等长就地替换:app.asar 的文件头按 offset/size 索引每个文件,改变 lib/main.js 的字节数就要重写整个约 200 MB 归档;换成等长字节则所有偏移保持有效,写入是一次性、可回滚的定点写。补丁只碰托盘菜单模板,不动其他逻辑。
每次 Host 启动时检查一次:菜单里已有该条目就什么都不做;DSH 升级把 app.asar 换回原版后,下一次启动自动补回。
限制
- 仅 Windows。补丁对象是 DSH 桌面版的托盘实现。
- 安装后、以及 DSH 升级后,都需要再启动一次才看得到菜单项。
- 只改托盘图标的右键菜单;任务栏窗口按钮的右键菜单(Windows 的 jump list)不受影响。
- 会写入 DSH 安装目录下的
app.asar。写入前把原字节存到插件目录的backup/,用scripts/tray-restart-patch.cjs restore可还原。
验证
2026-11-26 在 Windows 桌面版 DSH 0.2.2-rc.5 上实测通过:托盘右键菜单为「打开应用 / 重启 DeepSeek Harness / 退出应用」;点「重启 DeepSeek Harness」后进程正常退出,数秒内拉起新实例(Web GUI 端口随之变化),无报错弹窗。
排查
node scripts/tray-restart-patch.cjs check # 是否已打补丁、补丁区长度
node scripts/tray-restart-patch.cjs apply # 手动应用
node scripts/tray-restart-patch.cjs restore # 还原原始字节
check 输出版本不匹配(regionBytes 不等于 438)说明 DSH 改过这段代码,此时脚本会中止而不写入。
English
Adds a Restart DeepSeek Harness item to the tray icon's context menu, restarting the whole desktop app in one click — usable while the window is minimized or hidden in the tray.
The menu becomes:
Open application
Restart DeepSeek Harness
──────────────
Quit application
Install
dsh plugin add dsh-tray-restart
Or add dsh-tray-restart from Plugins → Add plugin in DSH.
Then restart DSH once: the tray menu is built during app startup, so the running process cannot see the new item.
How it works
The tray menu is static code in the Electron main process (DesktopTray#relabel in lib/main.js inside app.asar). A plugin runs in the Host child process — plain Node, with no access to Electron's Tray / Menu / app.relaunch and no IPC channel to ask the main process for a restart. The menu therefore cannot be extended at runtime; the template itself has to be rewritten.
The rewrite is an equal-length in-place patch. The app.asar header indexes every file by offset and size, so changing the byte count of lib/main.js would mean rewriting the whole ~200 MB archive; substituting the same number of bytes keeps every offset valid, and the write is a single, revertible location. Only the tray menu template is touched.
The patch is checked once per Host start: if the menu already carries the item nothing happens; when a DSH upgrade replaces app.asar, the next start puts it back.
Limitations
- Windows only. The patch targets the desktop app's tray implementation.
- After install, and after every DSH upgrade, one more launch is needed before the item appears.
- Only the tray icon's context menu changes; the taskbar button's own right-click menu (the Windows jump list) is untouched.
- It writes to
app.asarinside the DSH installation directory. The original bytes are saved tobackup/first, andscripts/tray-restart-patch.cjs restoreputs them back.
Verified
Tested on 2026-11-26 with DSH desktop 0.2.2-rc.5 on Windows: the tray context menu reads Open application / Restart DeepSeek Harness / Quit application. Choosing Restart quits the app and a new instance comes up within a few seconds (the Web GUI port changes), with no error dialog.
Troubleshooting
node scripts/tray-restart-patch.cjs check # patched? region length?
node scripts/tray-restart-patch.cjs apply # apply manually
node scripts/tray-restart-patch.cjs restore # revert original bytes
If check reports a version mismatch (regionBytes other than 438), DSH has changed that code; the script aborts instead of writing.
License
MIT
Похожие плагины
deepseek-harness
deepseek-ai/deepseek-harness
dsh-market
dsh-market/dsh-market
dsh-web (dsh-plugin-manager)
zhu1090093659/dsh-web
dsh-web
zhu1090093659/dsh-web