keyiadiannao/dsh-restart-button ↗★ 0
dsh-restart-button
Self-contained power control for DSH: sidebar power button with an upward 重启/关机 menu plus a Windows-shutdown-style overlay. Own restart & shutdown engine (no dependency on other plugins), MIT licensed.
AI 分析
核心用途是为 DSH 提供侧边栏电源控制按钮,支持重启、关机操作及全屏过渡效果。适合需要便捷管理 DSH 服务启停的用户。无其他插件依赖,需要 Node ≥ 22.19。
インストール
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:keyiadiannao/dsh-restart-buttonドキュメント
README 全文を読む ↗dsh-restart-button
A self-contained power control plugin for DeepSeek Harness: a power button in the sidebar footer with an upward Restart / Shutdown menu and a full-screen transition overlay. The restart & shutdown engine is built into this plugin — no dependency on other plugins.
Developed with DeepSeek AI assistance, reviewed before release.
Features
- Power button in the sidebar footer (
sidebar.footer.action), styled to match the adjacent Settings trigger (34px row, theme tokens — follows light/dark). - Upward menu: Restart / Shutdown, closes on outside click or Esc.
- Restart: writes a
.cjshelper → spawnsnodedetached (no console window) → waits for the port to free → relaunches DSH with the sameexecPath/execArgv/argv/cwd, then terminates the old process after the response flushes. - Shutdown: terminates the process without relaunching.
- Overlay: Windows-shutdown-style transition screen with ring progress and stage captions; auto-reload after restart.
restart_harnessmodel tool: same name asanweat/dsh-restart, provided by this plugin when installed alone; skipped if another plugin already owns the name.
Install
dsh plugin --profile web add "github:keyiadiannao/dsh-restart-button#master"
Restart DSH; a power button appears in the sidebar footer. Requires Node ≥ 22.19.
How it works
click power → menu → Restart
[host] POST /api/dsh-restart-button/restart
→ write $USERPROFILE/.dsh/restart-helper-
-.cjs
→ spawn `node ` (detached, windowsHide)
[helper] wait for old PID to exit → wait for port to free
→ spawn DSH again with same execPath/argv/cwd → self-delete
[host] terminate after the HTTP response flushes
[client] poll health → confirm new instanceId → auto reload
Shutdown posts /api/dsh-restart-button/shutdown and terminates without relaunching.
Design notes (from real issues hit in development):
- The helper must be outside the process tree (
detached+unref), otherwise killing DSH kills the helper too. - The helper is a real
.cjsfile, notnode -e: multi-linenode -escripts get mangled by WindowsCreateProcessand die with a silentSyntaxError.
Safety
- Destructive POSTs are protected by a same-origin / loopback guard (CSRF).
- An at-most-once latch prevents duplicate restarts from concurrent requests (a second POST gets
409). - Restart success is confirmed by the per-process
instanceIdchanging (old → new), not just a transient down.
Development
npm run build # tsdown: host + client bundle
npm run typecheck # tsc --noEmit
Artifacts: host at lib/index.js, client bundle at lib/client.js (committed — git installs build-free).
License & Attribution
MIT. The "detached helper relaunch" idea follows anweat/dsh-restart (MIT); the implementation is independently written (real .cjs file, no PowerShell, dynamic port), no code copied.