dsh-power-button: Draggable One-Click Service Stop and Restart for DSH Web GUI

Introduction

The dsh web process of DeepSeek Harness runs persistently until the process is explicitly stopped. If wrapped by an outer watchdog-like process, it often requires waiting for an idle window after the last browser tab is closed before the service is actually reclaimed, leaving the port occupied for a period. During this time, reopening the page might connect to an instance that is about to be shut down.

Seeing the liveness status directly in the Web interface and having a one-click option to stop or restart the local dsh web is a practical need for daily development. Here, we introduce the community plugin dsh-power-button (Maintainer: Neptune810, Category: Client): It places a draggable “Power” pill in the GUI with a real-time status dot, providing Stop and Restart service operations.

What is this

dsh-power-button is a DSH Web plugin that runs only on the host side: it has no additional dependencies and requires no build step. It injects a semi-transparent pill button into the Web carrier page, reflects whether the host is still responding via same-origin polling, and executes Stop Service and Restart Service via host routes.

Plugin Repository: https://github.com/Neptune810/dsh-power-button
Community Directory Page: https://www.skillhub.cn/plugins/Neptune810/dsh-power-button

Core Features

Interface and Interaction

Displays a small pill at the bottom right of the viewport by default (configurable):

  • Status Dot: Green indicates the last liveness probe received a response; red indicates no response. The probe is a same-origin GET, occurring every 5 seconds by default, consuming no model tokens.
  • Click Pill: Pops up a menu containing “Restart Service (Restart)” and “Stop Service (Stop)”. Clicking the pill again or clicking elsewhere on the page closes the menu. If configured with restart: false, a single click stops the service directly without a menu.
  • Drag: Movable via mouse or touch; the position is written to localStorage and restored on the next load. A pointer movement exceeding 4px is treated as a drag, and subsequent accidental clicks are suppressed to avoid triggering actions during a drag. The position is clamped within the viewport and re-clamped when the window shrinks. The pill is mounted outside the React root, so application re-renders will not unmount it.

Host-Side Behavior

The plugin does not build a client bundle nor import @deepseek-ai/* packages; it works via existing extension points in the Web carrier:

Extension Point Usage
webServer.tapIndex() Injects the pill’s markup, CSS, and scripts into index.html
webServer.register() Provides /dsh-power-button/status, /restart, /stop

Stop Service uses the launcher’s ctx.appExit (the same bounded shutdown as Ctrl+C): it disposes the application tree first and then exits the process. If the event loop is still occupied by other plugins, the plugin also sets a 2-second, unreferenced watchdog, which does not slow down normal exit but ensures the process eventually ends.

Restart Service cannot be completed within the host process that is about to exit. /restart spawns a detached Node helper process (running an inline module with the same Node binary). After the host disappears and the port stops responding, it uses the recorded startup command, environment, and working directory to relaunch the service; it can optionally automatically open the page once the port resumes responding. The helper process is detached + stdio: "ignore" + unref(), allowing it to continue and complete the relaunch after the host triggering the shutdown has exited. The README notes tests on Windows 11 / Node 24: Stop releases the port approximately 0.2–0.5 s after the POST returns 200; Restart restores the port within a few seconds; if the helper process fails to spawn, the route returns 500, and the service remains running.

Security

All three routes require the following conditions to be met simultaneously:

  1. Custom request header x-dsh-power-button: stop (Cross-site pages cannot attach this without a CORS preflight approval, and this service does not approve such preflights);
  2. Host is loopback (127.0.0.1 / localhost / [::1]);
  3. If the request carries an Origin, it must match the aforementioned Host.

Otherwise, it returns 403. status is limited to GET/HEAD; stop and restart are limited to POST. Mismatched methods return 405. The restart helper process only executes the startup call of the current process at that time, or the restartCommand you specified in the config, without altering other parts of the profile.

Installation and Activation

Add the plugin under the Web profile:

dsh plugin --profile web add dsh-power-button

After modifying the plugin list, you must restart dsh web; running processes will not hot-load plugin changes.

The current package version is 0.3.0, License MIT, requiring Node >= 20.

Configuration

All options are optional and placed under the config of the plugin entry. Example (excerpt from README):

- insert:
    - id: power-button
      name: dsh-power-button
      config:
        label: Stop Service            # Pill text and tooltip
        position: bottom-right     # Initial corner: bottom-right or bottom-left
        draggable: true            # If false, fixed at that corner
        status: true               # If false, remove status dot and stop polling
        statusPollMs: 5000         # Liveness polling interval, minimum 1000
        restart: true                # If false, remove restart item and no menu (click to stop)
        restartCommand: []         # argv; if empty, reuse current startup command
        restartOpenBrowser: true   # false means your command will open the browser itself
        restartWaitMs: 30000       # Max time helper process waits for port
        enabled: true              # If false, inject no UI

By default, restart reuses the current dsh web Node executable, script, and arguments. After relaunch, without an outer launcher watching, it will run until you stop it again. If the deployment is started by a launcher with an idle watchdog, you should point restartCommand back to the launcher and set restartOpenBrowser: false as appropriate:

- insert:
    - id: power-button
      name: dsh-power-button
      config:
        restartCommand:
          - 'C:\path\to\YourLauncher.exe'
        restartOpenBrowser: false

Typical Usage

  1. Install and restart dsh web as per the previous section. Open the Web GUI and confirm the pill and status dot appear in the bottom right (or configured corner).
  2. To stop the service cleanly and release the port immediately: Open the menu and select “Stop Service”, or set restart: false and click the pill directly.
  3. To restart in place with the same configuration: Select “Restart Service” and wait for the port to resume; if using a custom launcher, configure restartCommand first.
  4. Drag the pill to a position that doesn’t obstruct operations; the position is saved in the browser’s localStorage.

The repository provides the following command to run plugin tests (no extra test dependencies required):

node --test test/plugin.test.js

Use Cases and Notes

Suitable for developers running dsh web on their local machine or a trusted loopback environment who want to verify service liveness from the browser and quickly Stop/Restart. The plugin runs with the permissions of the current dsh process; stopping and restarting affect the Web service instance on the entire machine. It is recommended to read the source code and the MIT license before installation to ensure the routes and header constraints fit your threat model.

The DSH ecosystem emphasizes “Everything is a plugin”; community directories like SkillHub are independent of DeepSeek / High-Flyer and are not official app stores. Please refer to GitHub and the directory page for the plugin’s stars and maintenance rhythm.

Conclusion

dsh-power-button places Stop/Restart and liveness indicators into the Web GUI you already have open. It is host-only and zero-dependency, making it suitable for solving the operational inconveniences caused by dsh web persistence and port lingering. For details and updates, see the GitHub Repository and the SkillHub Directory Page.

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

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

Xiaoye