Introduction¶
In DSH’s plugin mechanism, both the Web sidebar and agent tools can be extended. For scenarios where dsh web is frequently run in the foreground terminal, a complete restart usually requires manually ending the current process and restarting with the original command; if the old process hasn’t exited yet, or the Web port is still occupied, the restart is prone to failure.
dsh-web-restart provides a sidebar button and an agent-callable tool for this process: terminate the current dsh web process, and relaunch it with the same command after the old process exits and the port is free. During the restart, the page does not refresh, and the UI is automatically restored in the same session tab.
What is this?¶
dsh-web-restart is a DSH Web plugin designed for a one-click, complete restart of the harness from the sidebar.
It does three things:
- End the current
dsh webprocess. - Wait for the old process to exit and the Web port to be free via a startup guard.
- Relaunch
dsh webwith the same command line and preserve original runtime parameters.
The repository path is csdjl88/dsh-web-restart with an MIT license. Since the npm name dsh-restart is already taken by a project with the same purpose, this plugin is published as dsh-web-restart.
Core Features¶
Sidebar Restart Button¶
The plugin provides a restart button in the sidebar.footer.action row. Clicking it triggers the restart directly without a confirmation dialog. This design is suitable for single-user and trusted-host scenarios.
Complete Process Restart¶
The plugin terminates the current dsh web process and relaunches it with the same command line. The restart preserves --profile, --patch, and internal parameters, and always ensures the new process has --no-open to prevent opening a new browser window.
Startup Guard¶
The new process does not start immediately. The plugin waits for the old process to exit and confirms the Web port is free before launching the new dsh web. Therefore, a controlled restart can be performed without needing systemd, Docker, pm2, or other daemon processes.
Automatic Page Recovery¶
During the restart, the button displays Restarting… and polls the health endpoint. The page does not perform a full page refresh, nor does it open a new tab. Once DSH WebSocket automatically reconnects, the UI is restored in the same session tab.
Agent-callable Tool¶
The plugin provides the dsh_restart tool, which can share the same restart core as the Web button.
Single Execution Protection¶
When a restart is in progress, clicking the button repeatedly or calling the tool again will be rejected to avoid triggering multiple restarts concurrently.
Bilingual Support¶
The plugin provides bilingual UI text and README in both Chinese and English.
Installation and Activation¶
The plugin requires DSH version 0.1.0-rc.7 or later.
The installation command is as follows:
dsh plugin --profile web add github:csdjl88/dsh-web-restart
After installation is complete, you need to restart DSH for the restart button to appear at the bottom of the sidebar.
Typical Usage¶
Web Button¶
After installing and restarting DSH, you can click the Restart DSH button at the bottom of the sidebar.
During the restart, the button displays Restarting… and polls automatically. The page does not refresh, and the UI is restored after DSH WebSocket automatically reconnects.
If the new process is not ready within 30 seconds, an error will be displayed on the interface. At this point, check the terminal running dsh.
Agent Tool¶
You can directly request a restart of DSH in the conversation. The corresponding tool is dsh_restart with an optional parameter reason.
For example, you can request in the conversation:
restart DSH
Please note: A single restart will interrupt all running agent tasks and background jobs.
Low-level Interfaces and Contracts¶
The plugin triggers and checks the restart status via the following HTTP endpoints:
POST /dsh-restart
GET /dsh-restart/health
POST /dsh-restart is used to trigger the restart, and GET /dsh-restart/health returns health information and the pid, facilitating frontend identification of the new process.
The plugin also uses the following environment contracts:
DSH_RESTARTED_BY
DSH_RESTART_OLD_PID
DSH_RESTART_PORT
Suitable Scenarios and Notes¶
Suitable Scenarios¶
This plugin is suitable for environments where dsh web is run in the foreground terminal without a supervisor auto-start strategy.
It is suitable for:
- Restarting the harness after modifying DSH Web plugins, patches, or related configurations.
- Triggering a complete process restart from the browser sidebar.
- Allowing agents to call the restart tool directly in a conversation.
Use with Supervisor with Caution¶
If the runtime environment already uses a supervisor like systemd, Docker, or pm2 and has configured an auto-restart strategy, the plugin’s startup guard and the supervisor may attempt to launch a new process simultaneously.
This will cause two instances to compete for the port, and one process may trigger an EADDRINUSE error.
In an environment managed by a supervisor, it is recommended to disable the supervisor’s auto-restart strategy or remove the dsh-web-restart plugin.
How to Stop DSH After Restart¶
The new dsh web after restart runs in its own session, meaning its own process group. After the old foreground process group exits, it may no longer receive Ctrl+C from the terminal.
To stop DSH after restart, you can use any of the following methods:
- Close the terminal window running
dsh. - Press
Ctrl+Din that terminal. - Execute in a new terminal:
pkill -f "dsh web"
Or:
kill <pid>
Permissions and Pre-installation Checks¶
This plugin terminates and relaunches the current dsh web process, equivalent to performing a complete restart on the current DSH runtime environment. Before installation, it is recommended to check the source code, dependencies, and MIT license to confirm its behavior meets the requirements of the current environment.
Conclusion¶
dsh-web-restart solves the complete restart problem when running dsh web in the foreground: preserving original command parameters, avoiding port conflicts, avoiding opening new tabs, and providing both a Web button and dsh_restart agent tool. It is suitable for foreground DSH Web environments without a supervisor, and also allows agents to trigger restarts directly in a conversation.
Directory Page:
https://www.skillhub.cn/plugins/csdjl88/dsh-web-restart
GitHub Repository:
https://github.com/csdjl88/dsh-web-restart