dsh-restart-dock: One-Click Restart Host or Refresh Page in DSH Web Interface

Introduction

When developing plugins or modifying host-side code in DSH, you often encounter two types of “activation” methods: changes to browser client scripts take effect upon page refresh; however, changes to host modules already loaded in the process require restarting the DSH process, otherwise the new files on disk will not replace the versions in memory. The daily workflow often involves closing the window, finding the shortcut, and launching it again—multiple steps that disrupt the debugging rhythm.

Here we introduce the community plugin dsh-restart-dock (often referred to as “Restart Dock” in the interface): it provides a small floating layer in the bottom right corner of the Web UI with two buttons to handle “Page Refresh Only” and “Restart DSH Host with original command line” respectively. Maintained by 7gzgn, categorized as a client-side plugin; see GitHub for the repository and SkillHub for the directory page.

What is this

In one sentence: One-click Restart / Reload dock on the DSH Web interface—“Restart” stops the host and launches it with original parameters; “Refresh” only triggers location.reload() without touching the process.

It does not inject business functionality into DSH; it only provides a fixed “door handle” specifically designed to solve the division of labor where host changes require a restart while client changes only require a page refresh.

Core Features

Interface and Interaction

After installation and a DSH restart, a small box appears in the bottom right corner with two buttons:

  • Restart: Suitable for scenarios requiring host reloads, such as modifying plugins, client.js, or profiles.
  • Refresh: Only reloads the current page; works on any platform.

Clicking Restart triggers a selection prompt: Immediate / 30s / 60s / 2m / Cancel; selecting a delay starts a countdown in place, which can be withdrawn. There is an additional anti-mistouch mechanism in the confirmation flow: after the first click, the button changes to “Confirm Restart?”, and it only executes if clicked again within 4 seconds.

The floating layer is draggable and always edge-attached: press and hold for about 0.3 seconds to drag (README mentions 320ms hold to drag), it snaps to the nearest edge upon release; it remains draggable even when collapsed into a small dot. The position is recorded as “which edge + distance from edge”, ensuring it stays attached to the border during window resizing or fullscreen, preventing it from drifting out of the viewport.

What Restart Does in the Background (Windows)

The host side launches an independent PowerShell process detached from the host via lib/relaunch.ps1 to execute the restart, ensuring the helper can complete the launch even after the host is stopped. Rough steps:

  1. Trace up from the host pid to locate the DSH process, then find the top-level instance of the same executable (skipping Chromium --type= child processes); if detection fails, it refuses to proceed and does not guess based on process names to kill.
  2. Wait approximately 2 seconds to allow the HTTP response to return to the interface first.
  3. Stop the process tree (leaves first, then root), waiting up to 20 seconds; also clean up any stray processes corresponding to parent pids in the current list to prevent residual web hosts from occupying ports, which causes the new instance to report desktop welcome: Web authentication failed.
  4. Restart using the target process’s original command line, preserving parameters.
  5. Write the result to ~/.dsh/dsh-restart-dock/last.json.

The interface polls GET /dsh-restart-dock/status: first confirming host disconnection, then waiting for recovery to automatically refresh the page (more noticeable in browser-based DSH; the desktop version closes the window on restart, and the window returns automatically).

Refresh

Pure frontend location.reload(), not going through the host. The README states that it checks the plugin bundle before refreshing; if it is still rebuilding or corrupted, it refuses, preventing a reload from freezing the application.

Security Boundaries (Summary)

Restart interrupts everything, so the HTTP entry is tightened: Cross-origin requests must depend on the custom header x-dsh-restart-dock: 1 and the plugin does not respond to CORS preflight; rejects Sec-Fetch-Site: cross-site; performs same-origin validation when Origin is present (127.0.0.1 / localhost / 0.0.0.0 on the same port are considered same-origin). Desktop dsh-app:// pages may not include Origin, so the implementation relies on actual testing. The status read-only interface is also only open to same-origin. Responses do not contain credentials, returning only pid / port / last restart report.

Installation and Activation

Install the local directory bundle in DSH (command from the repository README):

# Let the agent install the local directory in DSH
plugin_manager install_bundle target=D:\path\to\dsh-restart-dock

It can also be installed via the plugin market (after release). After installation, a DSH restart is required again for the small box to appear in the bottom right corner.

Compatibility (README): DSH >=0.2.1-rc.2 <0.3.0-0 (verified on real machines with 0.2.1-rc.2); Node >=18; Client side has no build step. The current version in package.json is 0.1.3, License MIT.

The plugin runs with the current DSH process permissions; please review the repository source code and license before installation to ensure the restart behavior meets your environment expectations.

Typical Usage

  1. After modifying client-side scripts or styles: Click Refresh, or rely on the automatic refresh after restart completion.
  2. After modifying host-side plugins or profiles: Click Restart, choose immediate or delayed as needed, wait for the helper to complete after confirmation; check ~/.dsh/dsh-restart-dock/last.json and helper.log when verifying results.
  3. If you only want to see which processes will be affected without actually killing them (Windows PowerShell):
powershell -NoProfile -ExecutionPolicy Bypass `
  -File lib\relaunch.ps1 -CallerPid <host_pid> -StateDir D:\tmp\rd -DryRun

-DryRun only probes and writes a report; you can also use -TargetPid <pid> to explicitly specify a target for testing.

Scenarios and Notes

Who it is for: Developers on Windows who frequently modify DSH plugins or host configurations and want to avoid the “close window and reopen” routine; people who need controllable delayed restarts within the interface.

Platform: Restart is implemented only for Windows; clicking restart on non-Windows returns 501, prompting to use refresh; UI and refresh are available on all platforms. Restart relies on Windows PowerShell 5.1+, and lib/relaunch.ps1 must have a UTF-8 BOM (otherwise PS 5.1 may decode Chinese comments as ANSI causing syntax errors).

Behavior trade-offs: Restart interrupts running tasks; it does not do “wait until this round finishes” scheduling—it can coexist with dsh-restart-planner (one for humans to click, one for agents). It will not automatically continue the conversation after restart; if the host is managed by job objects in some terminals, the detached helper may also be taken away (desktop version launched from shortcuts tested as normal).

Troubleshooting Files:

Path Function
~/.dsh/dsh-restart-dock/last.json Last restart result (relaunched / failed / armed / dry-run, etc.)
~/.dsh/dsh-restart-dock/helper.log Helper step-by-step log
~/.dsh/dsh-restart-dock/pending.json Scheduling from click to helper execution

Structure Overview

lib/index.js       Host side: Routes + spawn helper
lib/relaunch.ps1   Executor: Detect → Stop → Launch → Report
client.js          Client side: Small box in bottom right (shell.overlay)
locale/{zh,en}.json  Plugin list title and description
icon.svg           Icon

Conclusion

dsh-restart-dock separates “host changes require restart, client changes require refresh” into two clear actions. On Windows, it uses an independent helper to safely launch DSH with the original command line, while limiting mistouches and cross-site calls via same-origin checks and custom headers. If you mainly tinker with DSH plugins in the browser or desktop, install it, restart DSH once, and the dock in the bottom right corner is ready for long-term use.

  • Directory Page: https://www.skillhub.cn/plugins/7gzgn/dsh-restart-dock
  • GitHub: https://github.com/7gzgn/dsh-restart-dock

The community plugin directory is an independent site with no official affiliation with DeepSeek / High-Flyer; “Everything is a plugin” is a common practice in the DSH ecosystem, subject to the documentation of the DSH version you are using.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye