When using DeepSeek Harness (DSH), ending the current session or shutting down the Web service requires a controllable approach. The dsh-web-close plugin solves a specific problem: it provides a persistent close button in the DSH Web interface, allowing users to perform a graceful shutdown through interactive confirmation.

This is a standard DSH bundle plugin, maintained by Aclguh and licensed under the MIT License. It does not depend on any image assets, implements its functionality with native DOM, and supports cross-platform operation.

Core Features

  • Persistent auto-start: As a standard DSH bundle plugin, once installed, it is automatically loaded every time dsh web starts.
  • UI design: A semi-transparent red circular button with a background color of rgba(220,38,38,.42), featuring a frosted-glass effect and a red border glow. The icon is a hand-drawn power symbol rendered as inline SVG, with no image assets.
  • Position memory: The button is displayed by default at top: 1234px / left: 306px in the viewport. Dragging is supported, and the position is written to localStorage (key dsh-web-close-pos), automatically restored after a page refresh or browser restart.
  • Secondary confirmation: After clicking the button, a confirmation dialog appears centered in the viewport, displaying the target process PID and address. It includes “Cancel” and “Confirm Close” options.
  • Graceful shutdown: It does not use kill -9 for force termination. Instead, it invokes DSH’s appExit mechanism or sends a SIGINT signal, first unloading the entire plugin tree and then exiting the process.
  • Close tab: After confirming shutdown, the browser side automatically executes window.close() to attempt to close the current tab. If browser security policy blocks it, the page is replaced with about:blank. This operation only affects the current tab.

Installation and Activation

Before installing, ensure that pnpm is installed.

  1. Clone the repository to a local directory.
  2. Change to the repository root directory.
  3. Run the installation command.
dsh plugin --profile web add link:.

Notes:
* The repository root itself is the plugin package. Do not include a subdirectory in the path (e.g., link:.\dsh-web-close), otherwise it will be treated as an ordinary dependency rather than a plugin.
* After installation, you must restart dsh web for the change to take effect.

Usage

  • Move position: Press and drag the button. The dragging logic is triggered only when the displacement exceeds 4px.
  • Restore default: If position memory is invalid or you need to reset it, run the following command in the browser console:
    localStorage.removeItem('dsh-web-close-pos')
After refreshing the page, the button will return to its default position.
  • Execute shutdown: Click the button → confirm in the dialog → wait about 0.9 seconds → the DSH process exits and attempts to close the current tab.

Technical Implementation and Routing

The plugin runs inside the DSH host process (the node process that hosts the Web service and the Agent). It achieves graceful shutdown through the following mechanisms:

  1. Calls ctx.get('appExit')(0), triggering DSH launcher’s exit logic, disposing the plugin tree before exiting.
  2. Triggers process.emit('SIGINT'), which is handled by the signal handler registered by DSH to execute the same flow.
  3. As a fallback, it calls process.exit(0).

The plugin registers three same-origin routes on the Web server:

Route Method Description
/dsh-web-close/info.json GET Returns current process information (PID, address, etc.).
/dsh-web-close/widget.js GET Browser-side script, read from disk on each request.
/dsh-web-close/shutdown POST Receives the shutdown request and triggers the shutdown logic after a 0.9-second delay.

Verify Installation

You can use the following commands to verify that the plugin is installed and running correctly.

  1. Check configuration:
    dsh --profile web --dump-config
The output should include `- id: dsh-web-close`.
  1. Check the service (default port 3080):
    curl http://127.0.0.1:3080/dsh-web-close/info.json
It returns JSON including `"ok":true`.

Notes

  • Profile limitation: It is valid only for the web profile and depends on the DSH Web server running.
  • Browser security policy: Due to security restrictions, a script can usually only close a window that it opened itself. If the browser refuses to automatically close the current tab, a “Close This Page” button appears in the dialog as a fallback.
  • Storage limitation: In incognito/private mode, localStorage is unavailable, so position memory is only valid for the current session.
  • Code hot reload: Modifying lib/widget.js only requires refreshing the page; modifying lib/index.js requires restarting dsh web.