In DSH’s plugin-based architecture, upgrading the host or fixing a plugin typically requires restarting the service. Previously, this required manually running a kill command in the terminal, and running sessions would be interrupted. The dsh-web-restart plugin provides a restart entry point through the UI, works with an independent supervisor process to perform the actual service restart, and supports automatically resuming interrupted sessions.

Core Features

  • UI Restart: Provides a restart button at the bottom of the sidebar, supporting any layout.
  • Status Monitoring: Uses dot color to indicate service and supervisor process status (green=running, yellow=queued, red=not running).
  • Confirmation Mechanism: Clicking the button displays a centered confirmation dialog to prevent accidental activation.
  • Automatic Resume: After restart, automatically scans for and resumes interrupted sessions (requires configuration to enable).
  • Crash Self-Healing: If the service exits unexpectedly, the supervisor process can automatically start the service.

Installation and Enablement

1. Install the Plugin

Run the following command in the terminal to install the plugin:

dsh plugin --profile web add dsh-web-restart

After installation, restart the DSH web service to take effect.

2. Deploy the Supervisor Process

The plugin itself only sends the restart request; the actual kill + start operations are performed by an independent supervisor process. After installing the plugin, you must manually deploy the supervisor process; otherwise, the button will display red status.

  1. Copy script:
    mkdir -p ~/.dsh/scripts
    cp scripts/dsh-web-supervisor.sh ~/.dsh/scripts/ && chmod +x ~/.dsh/scripts/dsh-web-supervisor.sh
  1. Configure launchd:
    cp scripts/com.dsh.web-supervisor.plist.example ~/Library/LaunchAgents/com.dsh.web-supervisor.plist
    # 编辑 plist 文件,将 YOUR_USER 替换为实际用户名
    launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.dsh.web-supervisor.plist
  1. Verify status:
    Wait about 5 seconds, then run the following command to check status:
    ~/.dsh/scripts/dsh-web-supervisor.sh status
Output `running` and the UI button turns into a green dot indicates successful deployment.

3. Configure Automatic Resume

In Settings → Plugins → Plugin Configuration, find the “Restart Service Settings” card, enable the “Automatically resume interrupted sessions after restart” switch, and save.

Supervisor Process Mechanism

The plugin runs inside the DSH web process and cannot kill the host process directly (which would cause itself to exit along with the host). Therefore, the plugin acts only as the requester, and the actual service restart is performed by a launchd-managed supervisor process.

The supervisor script (dsh-web-supervisor.sh) is responsible for polling the request file, executing stop and start, handling port release, and automatically restarting the service when it crashes. If startup fails, it writes error logs to the supervisor log file for troubleshooting.

Automatic Resume Logic

After enabling automatic resume, once the service restart completes (after about 2 seconds), a scan is performed:

  1. Scan Scope: Only resume sessions interrupted after the last startup marker.
  2. Resume Conditions: Identify sessions that were force-terminated (process killed) or aborted for reasons other than the user. Sessions actively stopped by the user will not be resumed.
  3. Resume Behavior:
    • Top-level sessions and their sub-agents are resumed.
    • If there is an active goal, it is automatically rearmed and continues running.
    • If there is no active goal, a synthetic message is injected to prompt continuation of the previous work.
  • Request File: ~/.dsh/dsh-web.restart-request
  • Running Status: ~/.dsh/dsh-web-restart.json
  • Supervisor Log: ~/.dsh/dsh-web-restart.log
  • Service Log: ~/.dsh/dsh-web.log

Common Commands:

# 查看监督进程状态
~/.dsh/scripts/dsh-web-supervisor.sh status

# 彻底停止守护进程
~/.dsh/scripts/dsh-web-supervisor.sh halt

Known Limitations

  • For deployments mounted via include (such as repository link: workspace plugins), plugin configuration cards may not appear in the UI due to namespace-related reasons. In this case, you can use the switch in the restart popup, or directly edit the ~/.dsh/settings.yaml file.