dsh-desktop-notify: Windows desktop notifications when DSH loses focus

Preface

When running long tasks with DSH, the browser is often not in the foreground: you switch to other tabs, minimize the window, or have multiple DSH pages open simultaneously. At this point, if the model stops to wait for your decision, requests tool authorization, or if a turn is unexpectedly interrupted or finishes normally, the frontend lacks focus, making it easy to miss these events.

A common approach is to keep an eye on the page or rely on the browser’s own notifications. However, DSH decisions, authorizations, and turn endings are protocol events that do not necessarily map one-to-one with “whether a specific tab is visible.” The following introduces the community plugin dsh-desktop-notify (maintainer CarbonZhao-02692): it pushes decisions, authorizations, unexpected interruptions, and task completions to the Windows Notification Center (or optional self-drawn cards) when all open DSH frontends are unfocused. The notification title uses the session title, and clicking it attempts to reuse an existing page to switch back to the corresponding conversation.

What is this

  • Name: @carbonzhao/dsh-desktop-notify (Repository CarbonZhao-02692/dsh-desktop-notify)
  • Category: Client (Classified as “Client” in the SkillHub directory)
  • Platform: Windows 10 / 11 only; on other systems, it only writes logs and does not send notifications.
  • Positioning: A DSH web profile plugin that listens to session events and sends Windows toasts or WPF cards in the bottom right corner via a local host and PowerShell helper.

The plugin runs with the current DSH process privileges. It writes registry keys, starts local HTTP routes, and temporary PowerShell scripts. Before installation, it is recommended to review the source code and the MIT License on GitHub.

Which events are notified

The events and trigger points from the README are as follows (the body text represents the notification content template):

Event Trigger Point Notification Content
Need you to select a decision user-questions/request (including plan-review) 需要你选择决策:<问题> (Decision needed: )
Need you to authorize approval/request 需要你授权:<工具名> — <原因> (Authorization needed: — )
Unexpected interruption, please retry turn/end reason=error / interrupted / max-tokens, and api-session/error 任务意外中断:<错误>,请重试 (Task interrupted unexpectedly: , please retry)
Task completed turn/end reason=completed 任务已完成(用时 X) (Task completed (Time: X))

The notification title comes from the title of the corresponding session (generated by the sessionTitle service); if the title has not yet been generated, it falls back to the first user message of that session.

You can toggle individual items via loader configuration (e.g., notifyOnDecision, notifyOnApproval, etc.) and set minTurnDurationMs to filter out completion reminders for turns that are too short. By default, ignoreSubagent: true, meaning background subagent sessions will not trigger separate notifications.

Focus Gating: Only send when “All Frontends are Unfocused”

Each DSH page reports its status to /dsh-desktop-notify/focus approximately every 3 seconds, for example:

{ "id": "Page ID", "focused": true, "visible": true }

focused is defined as document.visibilityState === 'visible' && document.hasFocus(). focused is false when the window loses focus, you switch to other tabs, or the focus is on the address bar.

The host rules are simple:

  1. Any page has focused=true → Considered as having a focused frontend, silently do not send (unless forced via the test interface).
  2. All reported pages have focused=false → Gating condition met, notifications can be sent.
  3. When a page is closed, it reports closed: true via sendBeacon and is immediately removed from the summary; background tab timers may be throttled, so no heartbeat for 3 minutes is treated as closed; if all pages are closed, it is treated as all unfocused.

visible is only for status display and is not involved in the decision to send. If the config item onlyWhenUnfocused: false is set, notifications will be sent even if the page is focused.

Notification Form and Clicking Back to Conversation

enableCard determines two mutually exclusive modes (default false).

Windows Toast (enableCard: false)

Uses WinRT toast with a custom protocol dsh-desktop-notify://open?session=<id>&origin=<origin>. The helper assets/open.ps1 POSTs the session id to the host’s /dsh-desktop-notify/activate, restores the Edge/Chrome window (using SW_RESTORE only if minimized), and matches the DSH tab by title using UI Automation; opened pages poll /dsh-desktop-notify/activation and then call uiWorkspace.openSession(sessionId). The host delivers the activation only to the last page used by the user.

Self-Drawn Card (enableCard: true)

Only displays a native WPF card in the bottom right corner (auto-closes in about 20 seconds) and does not send Windows toasts, leaving no record in the Notification Center. The activation flow after clicking the card is the same as the toast mode.

If there are no connected DSH pages at that time, the helper will open a guide page in the default browser, write the session id to localStorage, and redirect back to DSH; after the new page loads, it will automatically open the corresponding conversation.

If clickToOpen: false, the notification cannot be clicked to return to the session.

Installation and Activation

Run the official installation command in PowerShell:

dsh plugin --profile web add @carbonzhao/dsh-desktop-notify

After installation, restart dsh web and hard refresh the browser (Ctrl+Shift+R). You can also install from source:

dsh plugin --profile web add github:CarbonZhao-02692/dsh-desktop-notify

Runtime Requirements (see README): DSH web profile, tested version 0.2.1-rc.2; Windows PowerShell 5.1; Node.js >= 20. Pages must remain open to report focus; the system must allow Windows notifications, and “Focus Assist” may block them.

Settings Page and Testing

Path: DSH Settings → General → Desktop Notifications.

  • Displays the current number of reporting pages and focus summary (Frontend focused = Silent / All unfocused = Will notify).
  • The “Self-Drawn Card” toggle corresponds to enableCard, takes effect immediately, and writes to %DSH_HOME%\super-injector\dsh-desktop-notify-config.json.
  • “Send Test Notification” ignores focus gating and is used to verify mode, app name, icon, and click behavior.

You can also debug via local HTTP interfaces:

# View focus status and recent notifications
Invoke-WebRequest -UseBasicParsing http://127.0.0.1:3080/dsh-desktop-notify/status

# Force send a test notification (force ignores focus gating; with sessionId, clicking will return to that conversation)
$body = @{ kind='complete'; force=$true; sessionId='session-...'; body='Test Notification' } | ConvertTo-Json -Compress
Invoke-WebRequest -UseBasicParsing -Method POST -ContentType 'application/json' `
  -Body ([Text.Encoding]::UTF8.GetBytes($body)) `
  http://127.0.0.1:3080/dsh-desktop-notify/test

Configuration Example

Default values are in DEFAULTS of lib/index.js; they can be overridden in the plugin loader’s config, for example:

- id: dsh-desktop-notify
  name: '@carbonzhao/dsh-desktop-notify'
  config:
    onlyWhenUnfocused: true   # false = Send even when page is focused
    clickToOpen: true         # false = Notification cannot be clicked to return to session
    enableCard: false         # true = Only self-drawn cards; false = Only standard Windows toasts
    ignoreSubagent: true      # No notification for background subagent sessions
    notifyOnDecision: true
    notifyOnApproval: true
    notifyOnInterruption: true
    notifyOnComplete: true
    minTurnDurationMs: 0      # Minimum turn duration for completion reminders (milliseconds)
    toastAppId: 'DeepSeek.DSH.Notify'
    toastAppName: 'Deepseek Harness Notification'
    toastIconPath: ''         # Default assets/deepseek-harness.png
    toastAppIconPath: ''      # Default assets/deepseek-harness.ico

Use Cases and Notes

Suitable for: Long-term use of DSH web on Windows, frequent multi-tab usage or window switching, and needing external reminders for “decisions needed, authorizations needed, task finished or broken,” with one-click return to the corresponding conversation.

Permissions and Local Behavior (README “Permissions and External Services”): Writes to HKCU for custom protocols and AppUserModelId; registers dsh-desktop-notify protocol in toast mode; displays notifications via powershell.exe; local routes include /focus, /status, /test, /activate, /activation, /open, etc., with no external uploads. The plugin is not an official DSH product.

Known Limitations (Excerpts): Tab auto-switching targets Edge / Chrome; it will not auto-switch back in Firefox; multiple tabs with the same title may match a different page with the same title; in some Windows 10 environments, toast clicks may not trigger the protocol; card mode auto-closes after 20 seconds. Helper logs are located at paths like %TEMP%\dsh-desktop-notify-helper.log.

The DSH ecosystem emphasizes “Everything is a plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer.

Links

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

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

Xiaoye