dsh-shutdown-after-task: Automatic Shutdown Plugin After Task Completion (Windows)

Preface

When running long tasks in DeepSeek Harness (DSH), such as batch migration, model generation, or overnight tasks, it is common to forget to shut down the machine. The dsh-shutdown-after-task plugin provides a way to trigger automatic shutdown via a button in the bottom-right corner, resolving this pain point. The plugin is maintained by user virggle and is a zero-dependency, pure configuration-layer plugin in the DeepSeek Harness ecosystem.

Core Features

  • Bottom-right floating text button (draggable): Click to toggle the “Shut down after task completes” mode (off by default). The button can be dragged, and its position is saved automatically.
  • Automatic avoidance: When corner popups from other plugins (such as price notifications) overlap with the button, the button will avoid them automatically and return to its position after the popups disappear.
  • Cancellable countdown: After a task completes successfully, a 60-second countdown banner (showing the remaining seconds in real time) and a “Cancel shutdown” button appear. The shutdown can be cancelled through the GUI during the countdown.
  • Interruption by new tasks: If any session starts a new task during the countdown, the shutdown command is automatically revoked, but the mode remains enabled.
  • Cancel immediately exits: Clicking the “Cancel shutdown” button not only cancels the current shutdown, but also exits the mode (so the next task will not trigger it).
  • Shut down only on success: It can be configured to shut down only on success; if any session in the current batch has an error, it will not shut down and will explain the reason.
  • Multi-session judgment: The root session is the unit for statistics, and the task is considered complete only when all root sessions are idle.

Installation and Enablement

Install from the official catalog:

dsh plugin --profile web add dsh-shutdown-after-task

After installation, restart DSH. If the button does not appear in the bottom-right corner, refresh the page (Ctrl+R).

Configuration

Edit the profile’s cordis.patch.yml (or Settings > Plugin Configuration):

- id: dsh-shutdown-after-task
  config:
    countdownSec: 60      # 倒计时秒数(10–600,默认 60)
    marginSec: 5          # 系统 shutdown /t 额外余量(0–60,默认 5)
    onlyOnSuccess: true   # 仅成功时关机(false = 完成即关,含出错)

Typical Usage

  1. Click the “Shut down after task completes” button in the bottom-right corner. The button turns yellow when the mode is enabled.
  2. Run tasks normally.
  3. When all root sessions are idle and there are no errors, a countdown banner appears above the button.
  4. Click the “Cancel shutdown” button within the countdown to cancel this shutdown and exit the mode.

How It Works and Details

  • Trigger timing: After the mode is enabled, all root sessions return from running status to idle status.
  • Success judgment: No agent/error occurs in the current batch (only effective when onlyOnSuccess: true).
  • System command: When the countdown starts, it executes shutdown /s /t <countdownSec + marginSec>.
  • Log path: Runtime logs are recorded in $DSH_HOME/dsh-shutdown-after-task.log.
  • State query: The current state can be queried via GET http://127.0.0.1:<port>/api/dsh-shutdown-after-task/state.

Notes

  • Windows only: The plugin executes shutdown.exe; on other platforms, the plugin remains lazy and logs this.
  • In-memory state: The mode state is kept in memory. After DSH restarts, it is off by default and must be re-enabled by clicking the button.
  • Inbox queue judgment: If root sessions are idle but the inbox has queued messages, shutdown is still triggered (based on “all roots idle”).
  • Page refresh: The script is injected with the index response, so the page must be refreshed after installation for the button to appear.

Summary

dsh-shutdown-after-task is suitable for scenarios where the computer should automatically shut down after an overnight task or a long-running batch task. It provides intuitive control via the GUI and supports configuration options to adapt to different shutdown strategies. For more details, see: GitHub Repository.

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

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

Xiaoye