Preface¶
On the DSH desktop app (Windows), after you change a profile, swap a plugin bundle, or when the Host is in an abnormal state, you often need to quit the entire application and reopen it—Electron shell, DSH Host, renderer process, and the plugin daemon must all restart together. Electron’s built-in “Restart App & Host” menu item is blocked by a development gate in the production installer, so you don’t see it day-to-day; moreover, DSH plugins run inside the Host subprocess, so they can’t call app.relaunch(), nor can they insert items into the native menu or request the main process to restart via IPC. The community plugin dsh-restart-button (maintainer: wangbofan; category: client) works from the title bar menu and the Host side to provide “one click, full-app shutdown and automatic reopen,” without modifying app.asar or depending on a specific desktop version.
What this is¶
dsh-restart-button adds a third button labeled “Restart” to the DSH desktop (Windows) title bar menu bar. After clicking and confirming, the entire app (Electron shell + DSH Host + renderer + plugin daemon) exits and automatically restarts. The implementation is entirely within the plugin; it does not patch app.asar inside the installer.
- Repository: wangbofan/dsh-restart-button
- Directory page: SkillHub plugin page
- Current version (package.json): 1.0.2
- License: MIT
Why the plugin can only restart “from the outside”¶
The DSH desktop “App” menu is created by the Electron main process using the native Menu, and the menu item list is hard-coded in the main process. The Host subprocess is loaded by DeepSeek Harness.exe with --expose-internals and similar flags to run @deepseek-ai/dsh-desktop-host, and the IPC between the main process and the Host is mostly one-way (main → Host, e.g., shutdown). There is no extension point for “ask the main process to restart.” Therefore, this plugin’s strategy is: inside the Host, schedule a one-shot external helper script, return the HTTP response immediately, then terminate all processes related to this app by exe path, and finally use WMI to relaunch the same exe.
Core features¶
Host-side HTTP API¶
Route prefix is /restart-button (in-code constant ROUTE_PREFIX).
| Method | Path | Description |
|---|---|---|
| GET | /restart-button/status |
Availability, exe, working directory, main process and Host PIDs, Electron version, log path, etc. |
| POST | /restart-button/restart |
Schedule a restart; immediately returns { ok, via, dryRun, delayMs, scriptPath, logPath } |
Restart sequence overview: the plugin writes a VBScript helper to %TEMP%\dsh-restart-button-<random>.vbs; it launches the helper via WMI using wscript.exe (so the helper is not under this app’s process tree, avoiding being killed by the kill step); after about 1500ms (HELPER_DELAY_MS), the helper terminates all relevant processes by exe path and relaunches; the decision trail is written to %TEMP%\dsh-restart-button.log.
Both routes are restricted to loopback Host, non-cross-site, and origin same-origin or dsh-app://app, with the same trust criteria as the official plugin’s isTrustedApiRequest.
Client-side UI¶
The Windows title bar “App / Edit” area is drawn by the preload into the page DOM (div[data-windows-menu], open shadow root). The client side adds a “Restart” button to that menu bar: clicking it shows a bilingual confirmation (following document.documentElement.lang); after confirming, it POST /restart-button/restart, shows a full-screen overlay, and polls /status every 2s (if it can’t reach it, that indicates the Host has exited and restart is in progress). If it’s still reachable after 25s, it shows a failure and allows retry. If the menu bar can’t be found within about 2.5s (e.g., in dsh web), it falls back to a floating button at the bottom-right: #dsh-restart-button-floating.
The dialog, overlay, and button use DSH semantic tokens (--dsw-alias-*) and switch with light/dark themes; no hard-coded colors.
Dry-run mode¶
Don’t kill processes; only write logs. Useful for troubleshooting:
- Environment variable:
DSH_RESTART_BUTTON_DRY_RUN=1 - Or single request:
POST /restart-button/restart?dryRun=1
Installation and activation¶
Prerequisites: DSH desktop (Windows). Default profile directory: %USERPROFILE%\.dsh\profiles\desktop.
Option A: dsh-super-injector (hot assembly, may avoid restarting the app)¶
If dsh-super-injector is installed, you can inject this plugin by absolute directory path:
dev_inject_plugin dir=<absolute path to this plugin directory>
Or write it into the profile (persists after restart):
dev_install_package dir=<absolute path to this plugin directory> profile=desktop
Note: Do not have both the above injection entries and the formal bundle patch entry present simultaneously; otherwise you may get webserver: duplicate prefix route "/restart-button". You need to clean up the temporary entry or restart the app once.
Option B: Manually install into the profile¶
- Link the plugin directory into the profile’s
node_modules(directory copy or junction both work):
mklink /J "%USERPROFILE%\.dsh\profiles\desktop\node_modules\dsh-restart-button" "C:\path\to\dsh-restart-button"
-
Edit
%USERPROFILE%\.dsh\profiles\desktop\package.json, add alink:dependency underdependencies, and add"dsh-restart-button"underdsh.profile.bundles. -
Restart DSH (close and reopen the desktop, or restart
dsh web).
Option C: Install from GitHub or a tgz¶
In the profile directory, use the pnpm bundled with DSH; after installing, add the package name to dsh.profile.bundles, then restart:
pnpm add "dsh-restart-button@github:wangbofan/dsh-restart-button"
Or:
pnpm add "file:C:\path\to\dsh-restart-button-1.0.0.tgz"
Uninstall¶
Remove dsh-restart-button from dsh.profile.bundles and dependencies, delete the corresponding link or directory under node_modules, and restart DSH. The plugin does not write anywhere else besides the script and log under %TEMP%.
Typical usage¶
Title bar menu: App | Edit | Restart → click “Restart” → confirm → the app closes and automatically reopens. The button is placed on the menu bar next to “App” because the plugin cannot insert items into the native “App” dropdown inside the Electron main process.
Example of viewing Host status (from a trusted origin):
GET http://127.0.0.1:<host-port>/restart-button/status
When to use and caveats¶
Who it’s for: Those who frequently adjust profiles, bundles, or plugins on the Windows desktop and need a full-app restart rather than just a page refresh; and want an experience close to “Restart App & Host” without modifying app.asar.
Limitations (documented in the README):
- Only on Windows desktop; under
dsh web,capabilities()returnsavailable: false(reason: "not-supervised"). The floating button is present, but clicking it will show an unavailable notice. - Not a graceful shutdown: It terminates processes by exe path, so running tasks will be interrupted (the confirmation bubble notes this).
- After restart, sessions and window positions are restored by the desktop app itself; the plugin does not save state.
- Node engine requirement:
>=22(see package.json).
Security and trust: The plugin runs with Host process privileges; the restart logic will terminate and relaunch the local DSH executable. Before installing, read the source code and LICENSE (MIT) and confirm you accept its WMI/VBScript helper behavior. The community directory SkillHub is an independent site and has no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem emphasizes “everything is a plugin,” and this plugin is a community-contributed client-side capability extension.
Conclusion¶
dsh-restart-button uses a Host HTTP endpoint plus a page menu bar button to fill in the full-app restart path that’s invisible in the production package, and deliberately avoids pitfalls like patching the installer or spawning console windows. For installation steps and self-testing details, refer to the GitHub README; you can view the entry summary on the directory page: https://www.skillhub.cn/plugins/wangbofan/dsh-restart-button.