DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

dengnianchen /

dengnianchen/dsh-restart

Verified

DeepSeek Harness plugin: restart the Host from Settings → General or the sidebar account menu (systemd user service, with a standalone fallback).

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@153142de

@dyapple/dsh-restart

Restart the DeepSeek Harness Host from the Web GUI — one row in Settings → General and one entry in the sidebar account menu. Both surfaces restart the Host through its systemd user service when the process runs under one, and fall back to relaunching its own command line otherwise.

plugin_manager install_bundle  @dyapple/dsh-restart

Requires DeepSeek Harness ≥ 0.2.1-rc.3 (uses ctx.connection.requestRejection and the settings.general.item slot).

What it adds

Surface Where Implementation
Settings row Settings → General, after “Performance & usage” Official settings.general.item slot, order: 35. Row shell follows the host's own General rows.
Account menu entry Settings / Feedback / **Restart dsh** / Sign out DOM bridge — see limitations.
Agent tool dsh_restart({ delayMs? }) Same operation as both UI entries.

Sidebar footer icon, host files, and the profile's hand-written config are untouched: this is one ordinary bundle plugin (a Host half plus a Web half).

Interaction

  1. First click arms a warning state (Click again to confirm, auto-expires after 4.5 s).
  2. Second click schedules the restart and shows Restarting….
  3. The page polls /dsh-restart/status every 0.7 s and reloads itself only when the Host answers with a different pid — a brief disconnect during the restart is never mistaken for success.
  4. If no new process appears within 120 s, the control turns into an error state with a retry.

Running turns and terminals are interrupted; sessions, transcripts and settings persist.

How the restart happens (Host side)

  1. systemd (detected through INVOCATION_ID plus an ordinary .service in /proc/self/cgroup, and systemd-run --user available): a detached transient unit runs systemctl --user restart <unit> after the delay. Calling systemctl restart from inside the process does not work here: dsh-web is KillMode=control-group, so the restart would kill the helper itself. A transient unit lives in another cgroup.
  2. Standalone (no systemd, e.g. launched by hand): a detached /bin/sh waits for the old pid to disappear, lets the port settle, then execs the same command line while the old process exits.

Both paths delay first, so the HTTP response reaches the page before the Host goes down.

Routes

Route Method Purpose
/dsh-restart/status GET {ok, version, pid, mode, unit, command, startedAt, uptimeMs, restarting}
/dsh-restart/restart POST Body {delayMs?}, default 700 ms

Both first pass ctx.connection.requestRejection() — Connection's Host/Origin fence plus the signed browser cookie — and the POST additionally requires content-type: application/json, which a cross-site simple request cannot send. Without a cookie both answer 401.

Known limitations of the account-menu entry

The account menu's items are a hardcoded array inside @deepseek-ai/dsh-client-ui-settings-account; it exposes no slot for extra rows, and its only seat (settings.launcher) is single-valued — taking it would replace the entire account menu. So this entry is a DOM bridge: it watches [role="menu"] nodes, identifies the account menu by requiring both the Settings and Feedback labels, clones the shipped Settings row (inheriting its classes, geometry and hover styles), swaps the glyph and label, and inserts it before Sign out / Sign in.

  • It is outside that menu's React item list: Tab reaches it, arrow keys do not.
  • It depends on the shipped menu's labels and structure. If a future version changes them it silently does not appear — no error, no effect on other UI. The Settings row is unaffected because that is an official slot.
  • The node is re-created each time the menu opens (WeakSet prevents duplicates).

Development

git clone https://github.com/dengnianchen/dsh-restart.git
plugin_manager install_bundle  ./dsh-restart

The profile links the checkout, so client.js reloads through HMR while index.js needs a Host restart (which is what this plugin does). The Host half is a single ESM module — one import per process.

中文速览

  • 入口:设置 → 通用里的一行(官方槽位,order 35);账号弹窗菜单里一项(DOM 桥,因为官方菜单项写死、无插槽);另加 dsh_restart 工具。
  • 重启方式:有 systemd 时用独立 transient unit 延时执行 systemctl --user restart <unit>(服务是 KillMode=control-group,进程内直调会把自己一起杀掉);没有 systemd 时 detached /bin/sh 等旧进程退出后 exec 同一条命令行。
  • 判定成功:页面轮询 /dsh-restart/status,只有 pid 变了才 reload,120 秒没回来则报错并可重试。
  • 注意:正在跑的回合与终端会中断,会话/记录/设置都保留。

License

MIT © Nianchen Deng

—/ 5

No ratings yet

Verified DSH bundle

Commit 153142dea3f1

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout