dsh-tauri-notify-webhook: Push notifications to Email or PushPlus on task failure or completion

Introduction

The DSH Desktop Terminal displays a system-level Toast notification when a task ends. This notification has two drawbacks: first, if the window is in the foreground, it is disruptive noise; second, if you step away and return later, the Toast is already gone. Since the host only retains the latest turn/end record, the session conclusion becomes untraceable.

The dsh-tauri-notify-webhook plugin moves notifications off-screen, persisting them via channels such as Email (SMTP) or Pushplus. It only triggers when a task stops abnormally or completes, and the window is not in the foreground.

Installation & Enablement

This plugin requires the DSH Desktop Shell and Node.js >= 22.15.0.

Install using the following command:

dsh plugin --profile <name> add github:iuuuuuuuu/dsh-tauri-notify-webhook

After installation, DSH must be restarted to take effect. This is due to the Harness loader’s caching mechanism and the fact that hmr.root defaults to an empty array; newly installed modules are not automatically loaded into the running host process.

Usage

  1. Open Settings and navigate to the “Task Push” (任务推送) page.
  2. Select the push channel (Email or Pushplus) and fill in the corresponding fields.
  3. Click “Send Test” (发送测试) to verify the configuration.
  4. Click “Save” (保存) and restart DSH.

Configuration Fields

  • Email (SMTP): Requires SMTP Host, Port, Security Settings (e.g., TLS/SSL), Sender, and Recipient. Username and Password may be optional depending on the relay server.
  • Pushplus: Enter the Token obtained from pushplus.plus. The plugin sends requests directly to the official /send endpoint.

Features & Trigger Mechanism

Two Trigger Conditions

The plugin enables two trigger switches by default:

  • Task Completed (任务完成): Triggers when the task end reason is completed.
  • Task Abnormal Stop (任务异常停止): Triggers when the task end reason is aborted, error, blocked, max-tokens, interrupted, or forked.

Push Only When Window Loses Focus

The plugin determines this by listening for document.visibilityState === 'hidden'. The DSH Tauri shell patches document.hidden to reflect the real window focus state, so the logic effectively checks for “window not in foreground” rather than “tab in background.”

Push Decision Logic

The client cannot directly read the task’s end reason, necessitating a two-step interaction:

  1. Listen for the running: true to running: false state flip in the session list.
  2. Wait for a 250ms stability window (to prevent state flickering), then request GET /turn-end?sessionId=... to retrieve the reason recorded by the host.
  3. If the session state is confirmed as stopped and has not stopped again, the client initiates POST /delivery. The host re-reads the settings and sends the notification at this point.

The entire flow re-checks whether the plugin is still loaded to prevent data inconsistency caused by reloads.

Configuration Storage & Security

Configuration Storage

Settings files are stored locally at $DSH_HOME/notify-webhook/settings (default path is ~/.dsh).

Security

  • Settings files are saved via the Shell’s atomic write helper to prevent file corruption caused by crashes during the writing process.
  • Host routes are loopback and same-origin. Browser profiles cannot read these settings or force the plugin to send emails.

Applicable Scenarios & Notes

  • Desktop Profile Only: This plugin relies on DSH’s dsh-tauri and dsh-tauri-ui runtime plugins and is not applicable to browser profiles.
  • No Push When Window is in Foreground: If you are watching the session stream, the plugin remains silent.
  • Skip Sub-sessions: Sub-agent sessions are driven by parent tasks; the plugin does not trigger pushes for sub-sessions individually.
羽毛球分组比赛记分
小程序二维码

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

Xiaoye