DeepSeek Harness Plugin

Arc-huangjingtong/dsh-restart

Stars ★ 0 Category UI Enhancements Added 2026-11-04

Adds a restart button to the macOS DSH desktop sidebar that fully quits and reopens the app; on other platforms the button hides itself.

Install

# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)

dsh plugin --profile web add github:Arc-huangjingtong/dsh-restart

Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).

README

简体中文 | English

A one-click restart button for the DeepSeek Harness desktop app.

A small pill sits in the sidebar header, immediately left of the sidebar-collapse button. Click it, confirm, and the app fully quits and reopens by itself — no more ⌘Q plus reopening from the Dock.

Restart button in the sidebar header

Features

  • One click, one restart: confirm dialog → the app quits → it comes back automatically (about 4–6 seconds).
  • Truly relaunched: waits for every DSH process (main, host, GPU/renderer helpers) to exit before opening, so the new instance cannot collide with a stale single-instance lock.
  • Correct environment: open(1) forwards the caller's environment. The DSH host runs the Electron binary with ELECTRON_RUN_AS_NODE=1, so the helper strips Electron/Node runtime variables before relaunching. Without that, the "app" starts in Node mode: the Dock bounces, no window appears, and the process exits.
  • Verified startup: after open, the helper checks that the new main process appears and survives a short stability window, activates the window, and retries up to three times.
  • Logs: every attempt is appended to ~/.dsh/restart.log.
  • Loopback only: the restart endpoint rejects cross-origin requests.
  • macOS only: on other hosts the button hides itself and the API returns 501.

Requirements

  • macOS (uses osascript, open, and process inspection through ps).
  • DeepSeek Harness desktop app. Tested against DSH 0.2.1-rc.5.

Install

The repository is a standard DSH bundle (dsh.bundle + dsh.client).

Option 1: Plugins page (recommended)

  1. Open DSH → Settings → Plugins → Add plugin.
  2. Choose this repository directory (the folder containing package.json).
  3. Fully quit and reopen DSH once. The plugin cannot load itself before it has been loaded.

Option 2: CLI

dsh plugin --profile desktop add /absolute/path/to/this/repo

Then fully quit DSH and reopen it.

The plugin is installed into the desktop profile as a link: dependency. Keep this directory in place; moving or deleting it will make DSH skip the plugin on the next boot.

Usage

After the first restart, a 72×28 pill with a refresh glyph and the label Restart appears in the sidebar header, left of the collapse button.

  1. Click Restart.
  2. Confirm in the dialog — running sessions and tasks will be interrupted.
  3. The window disappears and returns by itself in about 4–6 seconds.

The pill re-measures its position when the sidebar is resized, the window is resized, the sidebar collapses, or fullscreen changes. If there is no room to its left (fullscreen puts the collapse button on the left), it moves to the button's right.

How it works

Host half — index.js

Registers two same-origin routes through ctx.connection.fetch:

Route Purpose
GET /api/dsh-restart/status { canRestart, platform }; the client hides the pill when canRestart is false
POST /api/dsh-restart/restart Rejects cross-origin callers, then spawns the helper with detached: true and unref()

Helper — scripts/restart-dsh.sh

  1. Asks the app to quit with AppleScript.
  2. Waits until all app processes disappear (up to 10 s), then falls back to TERM, then KILL.
  3. Waits 1.5 s for LaunchServices and the old instance to unwind.
  4. Relaunches with ELECTRON_RUN_AS_NODE, NODE_OPTIONS, and the other Electron/Node variables unset.
  5. Verifies the new main process appears, activates the window, and checks it survives 1.5 s.
  6. Retries up to three times, waiting 2 s between attempts.

Client half — client.js

Registers a fixed-position button into shell.overlay. It finds the sidebar header row via its data-window-drag marker, measures the collapse toggle, and aligns the pill to its left. It also owns the confirmation dialog, busy state, error handling, and Chinese/English copy.

Configuration

The helper reads these environment variables:

Variable Default Meaning
DSH_RESTART_SETTLE_SECONDS 1.5 Wait after every app process exits, before open
DSH_RESTART_STABILITY_SECONDS 1.5 How long the new main process must stay alive
DSH_RESTART_RETRY_DELAY_SECONDS 2 Wait between launch attempts

To make restarts faster, lower the first two to 1. To make them more forgiving on a slow machine, raise them.

Troubleshooting

  • No pill after installing: the plugin loads only when the host starts. Fully quit and reopen DSH; a page refresh is not enough.

  • Restart does nothing: check ~/.dsh/restart.log. Each attempt records the main PIDs, ELECTRON_RUN_AS_NODE, open attempt …, and either relaunched (pids: …) or an error.

  • Dry run (prints the detected PIDs without quitting):

    DRY_RUN=1 bash scripts/restart-dsh.sh
    
  • pgrep -f caveat: on macOS, pgrep -f cannot see this Electron main process, so the helper identifies processes through ps -axo pid=,comm= instead. Do not replace it with pgrep.

  • Run directly from a terminal (same effect as the button):

    bash scripts/restart-dsh.sh
    

Development

npm run check    # syntax-check index.js, client.js and the helper
npm run dry-run  # helper dry run

Limitations

  • macOS only.
  • Restarting interrupts running sessions and tasks.
  • The plugin lives in the desktop profile; a different DSH profile needs its own install.
  • The button relies on the sidebar's data-window-drag header row. A future DSH layout change may require adjusting the selector.

License

MIT

Content from the project README on GitHub ↗

Links

More in this category

View the whole category →

Community comments

Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.