dsh-plugin-notify-sounds 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # dsh-plugin-notify-sounds
2
2
 
3
+ [![awesome · DSH plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
4
+ [![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/plugins/billcx330/dsh-plugin-notify-sounds)
5
+ [![DeepSeek Harness plugin](https://img.shields.io/badge/dsh-plugin-8b5cf6.svg)](https://github.com/deepseek-ai/deepseek-harness)
3
6
  [![npm version](https://img.shields.io/npm/v/dsh-plugin-notify-sounds.svg)](https://www.npmjs.com/package/dsh-plugin-notify-sounds)
4
7
  [![npm downloads](https://img.shields.io/npm/dm/dsh-plugin-notify-sounds.svg)](https://www.npmjs.com/package/dsh-plugin-notify-sounds)
5
8
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
- [![DeepSeek Harness plugin](https://img.shields.io/badge/dsh-plugin-8b5cf6.svg)](https://github.com/deepseek-ai/deepseek-harness)
7
9
 
8
10
  English | [中文](README.zh.md)
9
11
 
@@ -74,7 +76,13 @@ The "install source" dropdown above the box picks the download mirror (mainland
74
76
 
75
77
  ### ⬆️ Upgrading
76
78
 
77
- DSH does not update plugins on its own, but this plugin **updates itself**: Settings → Sounds → Updates can check for a new version and install it in one click. Uninstalling and installing again also works.
79
+ **Upgrades are installed by the package manager**, so the profile's lockfile moves with the files — a DSH plugin cannot install its own update durably (the manager refuses a package that is already declared, and its remove-then-install step unloads the very code that would finish the install). The plugin therefore only *checks*, and tells you where to install:
80
+
81
+ - **Inside DSH (recommended)**: Settings → Plugins → remove this plugin → **Add plugin** → paste `dsh-plugin-notify-sounds` → Install → restart DSH.
82
+ - **With the marketplace plugin** ([dshmarket](https://www.npmjs.com/package/dshmarket)): update it in one click there.
83
+ - **On a `web` profile**: `dsh plugin --profile <your profile> add dsh-plugin-notify-sounds@<version>`.
84
+
85
+ The update row also warns when the running version is not what the profile's lockfile records — the state left behind by the pre-1.8.0 self-updater. One reinstall through the package manager fixes it for good.
78
86
 
79
87
  ### 🛠️ Other ways
80
88
 
@@ -87,7 +95,7 @@ dsh plugin --profile <your profile> add github:BillCx330/dsh-plugin-notify-sound
87
95
  **Release archive** — download the `.tgz` from [Releases](https://github.com/BillCx330/dsh-plugin-notify-sounds/releases) and install it by its **path on disk**:
88
96
 
89
97
  ```sh
90
- dsh plugin --profile <your profile> add ./dsh-plugin-notify-sounds-1.7.0.tgz
98
+ dsh plugin --profile <your profile> add ./dsh-plugin-notify-sounds-1.8.0.tgz
91
99
  ```
92
100
 
93
101
  (`dsh plugin add` hands its argument straight to the package manager, so it takes a local file path — a download URL will not work.)
@@ -105,8 +113,8 @@ The command line writes `dsh.profile.bundles` and installs the dependency for yo
105
113
  ## ⚠️ Known limitations
106
114
 
107
115
  - **Hand-edited config**: preferences live in the profile's `cordis.patch.yml`; values must match the schema (volume 0–100, a preset id, `HH:MM` times) or the plugin declines to load — just fix the value. The settings UI only ever writes valid values.
108
- - **One-click update only writes files**: it writes the files the new release carries — added ones included — into this package's own directory and **never touches the profile's configuration**. It never *deletes*: a file a later release drops stays behind on machines that updated into it (harmless, but only a reinstall removes it). Downloaded code is never executed — the new code loads on a **DSH restart**. Let the row report a result before closing the window (a failed update restores itself, and says what to do next); if a future release adds a dependency, that needs installing separately (this one has none).
109
- - **Versions up to 1.6.9 cannot update into a release that adds a file**: those builds carry a fixed list of seven filenames and refuse an archive containing anything else — **without damaging the installed version**, which keeps working as it did. Reinstalling once from npm or the repository's Releases fixes it permanently: 1.7.0 removed that limit, and from then on any release may add files.
116
+ - **Upgrades are installed by the package manager, not by the plugin**: 1.8.0 removed the self-installer (writing files in place never updated the profile's lockfile, so the next plugin install silently restored the old version). The update row still checks npm and reports a newer version, then points at the route that installs — Settings → Plugins (remove, then add again), the marketplace, or `dsh plugin add` on a web profile.
117
+ - **Versions up to 1.7.0** reach 1.8.0 through their own updater (1.8.0 keeps the same seven filenames), but that arrival is not registered with pnpm: reinstall once through the package manager as above and every later upgrade stays in place. Versions up to 1.6.9 cannot install a release that adds a file — their fixed whitelist refuses it safely; the same one-time reinstall fixes that too.
110
118
  - **Multiple windows** fire independently: the same event may chime once per window; turn on notify-only-when-hidden to avoid it.
111
119
  - **Click-to-return** is fully implemented and tested on Windows; macOS / Linux fall back to the system deep link and are unverified.
112
120
  - **The window is found by its title** — deliberately without inspecting other processes (that trips security software). If DSH ever changes its title format, click-to-return silently stops working; sounds and notifications are unaffected.
@@ -131,6 +139,7 @@ For anyone hacking on the code (exact details live in the source comments):
131
139
 
132
140
  ## 📜 Changelog
133
141
 
142
+ - **v1.8.0** (2026-10-20) **The plugin stops installing itself; the package manager owns upgrades.** Writing files in place never updated the profile's lockfile, so the next plugin install — or a market upgrade — silently restored the version pnpm had recorded: a 1.7.0 install could roll back to 1.6.9 with no warning. DSH 0.2.1 makes a durable self-install impossible from inside a plugin (the manager refuses a package that is already declared, and its remove-then-install step unloads the very code that would finish the install), so the self-installer is gone: the update row checks npm, reports the newer version, and points at the route that installs — Settings → Plugins (remove, then add again), the marketplace, or `dsh plugin add` on a web profile. It also compares the running version with the version the profile's lockfile would restore and **says so when they differ**, turning the silent rollback into a self-service fix. **New: goal-mode alerts wait for the goal to end** (issue #2) — a goal runs several automatic rounds and every round used to chime; the new switch **Only alert on the final goal round** stays silent on intermediate rounds and chimes once when the goal completes, pauses or blocks (ordinary sessions are unaffected; off by default). The release keeps the same seven filenames, so 1.6.9 / 1.7.0 installations still reach it through their own updater — after one reinstall through the package manager the upgrade is permanent.
134
143
  - **v1.7.0** (2026-10-16) **The update mechanism turns a corner**: one-click update is no longer limited by a fixed list of seven filenames. It now accepts any regular file inside the package directory, governed by rules instead of an inventory — path traversal, absolute paths, symlinks, non-file entries, reserved names (its own backup/temp names and its record file, `.git`, `node_modules`, `.npmrc`), paths containing `:`, names colliding only by case, and a file that differs from the entry point `package.json` declares only by case are all still refused, with the file count and the decompressed size capped (enforced while inflating). **1.7.0 and later update cleanly into a release that adds or drops any number of files**: a file a later release drops is now actually deleted, based on the `.update-manifest.json` record this updater leaves behind — **only files an update installed are ever deleted**, anything you put in that directory yourself is left alone, and installations older than the first record are never guessed at. **1.6.9 and earlier will fail** (safely — nothing is written, the installed version keeps working) if a newer release adds a file, and the README says to reinstall once. Fixed: turning auto-check off ended the daily check chain for good, even after turning it back on; clicking a notification did nothing when the window title changed between the two Win32 reads; prerelease versions compared as strings (`rc.10` looked older than `rc.9`); **two tabs — or two windows — of the same GUI each rang the sound, raised their own system notification and ran their own repeat reminder** (one page is now elected to speak, via BroadcastChannel plus a shared claim, and the others stay silent until it disappears; per-window title marks are unaffected); and custom-sound normalization now visits **every sample** (taking every 8th frame aliased against content near fs/8 and systematically underestimated the peak). A failed update now gives **stage-appropriate advice** — retry for network failures, and the repository plus the uninstall/reinstall steps when the payload itself could not be applied, naming both versions — `package.json` is written **last** (a crash mid-swap leaves the old version number over the new code, so the next check still offers the update instead of declaring success), and the archive's manifest is verified to be this package at the version the registry named. The custom-sound row moved to sit **directly under the three trigger sounds** it is used by, and the smaller fixes on top: the cooldown table is a real LRU rather than FIFO (the session that fired most often was evicted first), one session-list snapshot per pass instead of per session, the macOS Desktop's window-title switch is now disabled rather than merely re-described, the full-width punctuation that leaked into the English update message is gone, and the README's release-archive instructions now give a command that actually works.
135
144
  - **v1.6.9** (2026-10-12) Fixes a README filename compatibility issue in v1.6.8: reverted to `README.md` (English) + `README.zh.md` (Chinese) so the update whitelist in every prior version can recognise them. A new filename would be refused by old users' updates — the whitelist is one-directional because the update runs old code.
136
145
  - **v1.6.8** (2026-10-12) Review fixes and optimizations: the auto-check first-frame timing gap is closed (`undefined` is no longer treated as permission to reach out); an orphaned JSDoc is removed; the teardown assertion now actually verifies listener removal; `normalizedGain` samples every 8th frame (2.6M → 330K iterations for a 30-second upload); the master gain disconnects after playback ends (no more audio-node leak); `swapNavIcon` is wrapped in try/catch and preserves the original node for restore on dispose (React re-renders can no longer crash it); the cooldown table evicts the oldest entry instead of clearing all; and `sessionRows` caches one snapshot per synchronous block.
package/README.zh.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # dsh-plugin-notify-sounds
2
2
 
3
+ [![awesome · DSH plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
4
+ [![Listed on dsh-plugin.org](https://dsh-plugin.org/badges/listed.svg)](https://dsh-plugin.org/plugins/billcx330/dsh-plugin-notify-sounds)
5
+ [![DeepSeek Harness plugin](https://img.shields.io/badge/dsh-plugin-8b5cf6.svg)](https://github.com/deepseek-ai/deepseek-harness)
3
6
  [![npm version](https://img.shields.io/npm/v/dsh-plugin-notify-sounds.svg)](https://www.npmjs.com/package/dsh-plugin-notify-sounds)
4
7
  [![npm downloads](https://img.shields.io/npm/dm/dsh-plugin-notify-sounds.svg)](https://www.npmjs.com/package/dsh-plugin-notify-sounds)
5
8
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
- [![DeepSeek Harness plugin](https://img.shields.io/badge/dsh-plugin-8b5cf6.svg)](https://github.com/deepseek-ai/deepseek-harness)
7
9
 
8
10
  [English](README.md) | 中文
9
11
 
@@ -74,7 +76,13 @@ DSH 的状态提示只有视觉——状态点、侧栏标记。你一切到别
74
76
 
75
77
  ### ⬆️ 升级
76
78
 
77
- DSH 不会自动更新插件,但本插件**自带更新功能**:设置 → 提示音 →「更新」里可以检查新版并一键安装。想走手动路径也可以:在同一处先**卸载**旧版,再按上面的步骤装新版。
79
+ **升级由包管理器安装**,这样 profile 的 lockfile 会跟着一起更新——DSH 插件无法自己持久地更新自己(管理器拒绝已声明的包,而它的「先移除再安装」会先卸载掉正要完成安装的代码)。所以插件只负责**检查**,并告诉你从哪里装:
80
+
81
+ - **在 DSH 里(推荐)**:设置 → 插件 → 卸载本插件 → **添加插件** → 粘贴 `dsh-plugin-notify-sounds` → 安装 → 重启 DSH。
82
+ - **装了市场插件**([dshmarket](https://www.npmjs.com/package/dshmarket)):在市场里一键更新。
83
+ - **`web` profile**:`dsh plugin --profile <你的 profile> add dsh-plugin-notify-sounds@<版本>`。
84
+
85
+ 更新行还会提示「当前版本与 lockfile 记录不一致」——那是 1.8.0 之前的自更新留下的状态,按上面方式重装一次即可永久修好。
78
86
 
79
87
  ### 🛠️ 其他安装方式
80
88
 
@@ -87,7 +95,7 @@ dsh plugin --profile <你的 profile> add github:BillCx330/dsh-plugin-notify-sou
87
95
  **Release 压缩包** —— 从 [Releases](https://github.com/BillCx330/dsh-plugin-notify-sounds/releases) 下载 `.tgz`,用它**在磁盘上的路径**安装:
88
96
 
89
97
  ```sh
90
- dsh plugin --profile <你的 profile> add ./dsh-plugin-notify-sounds-1.7.0.tgz
98
+ dsh plugin --profile <你的 profile> add ./dsh-plugin-notify-sounds-1.8.0.tgz
91
99
  ```
92
100
 
93
101
  (`dsh plugin add` 把参数原样交给包管理器,所以要给本地文件路径,不能填下载地址。)
@@ -105,8 +113,8 @@ dsh plugin --profile <你的 profile> add ./dsh-plugin-notify-sounds
105
113
  ## ⚠️ 已知边界
106
114
 
107
115
  - **手改配置**:偏好写在 profile 的 `cordis.patch.yml`,值必须符合 schema(音量 0–100、音效为预设之一、时间 `HH:MM`);写错会让插件不加载,改回即可。设置界面只会写入合法值。
108
- - **一键更新只写文件**:把新版本带的文件写进本包目录(**新版新增的文件也会装上**),**不碰 profile 配置**;它只写不删——某个版本去掉的文件会留在更新过它的机器上(无害,但要重装才会彻底消失)。下载内容从不执行,新代码要等**重启 DSH** 才生效。更新过程请等状态行给出结果再关窗口(失败会自动还原,并告诉你下一步怎么做);若未来的新版引入了新依赖,需另行安装(当前零依赖)。
109
- - **1.6.9 及更早版本无法更新到「新增了文件」的新版**:那些版本内置的是固定文件清单,遇到清单外的文件会整包拒绝——**不会损坏已装版本**,插件照常工作。从 npm 或仓库 Releases 手动重装一次即可永久解决:1.7.0 已取消该限制,之后任何版本都可以自由增减文件。
116
+ - **升级由包管理器安装,不再由插件自己完成**:1.8.0 移除了自安装器(原地写文件从不会更新 profile 的 lockfile,于是下一次插件安装会静默把旧版本装回来)。更新行仍会检查 npm、报告新版,然后指向真正负责安装的入口——设置 → 插件(卸载后再装)、市场,或 web profile 上的 `dsh plugin add`。
117
+ - **1.7.0 及更早版本**可以通过它们自带的自更新到达 1.8.0(1.8.0 保持同样的七个文件名),但这次到达不会被 pnpm 登记:按上面的方式用包管理器重装一次,此后所有升级都会留下。1.6.9 及更早无法安装「新增了文件」的版本——固定白名单会安全拒绝;同样的一次性重装即可解决。
110
118
  - **多窗口**:各窗口独立触发,同一事件可能各响一次;打开「仅在页面不可见时提示」即可避免。
111
119
  - **点击通知回到窗口**:Windows 完整实现并实测;macOS / Linux 走系统深链,未验证。
112
120
  - **唤窗按窗口标题定位主窗口**:刻意不读取其他进程信息(那会触发杀软主动防御)。若将来 DSH 改变标题格式,唤窗会静默失效——提示音与通知本身不受影响。
@@ -130,6 +138,7 @@ dsh plugin --profile <你的 profile> add ./dsh-plugin-notify-sounds
130
138
 
131
139
  ## 📜 更新记录
132
140
 
141
+ - **v1.8.0**(2026-10-20)**插件不再自己安装更新,改由包管理器负责。** 原地写文件从不会更新 profile 的 lockfile,于是下一次插件安装(或市场升级)会静默把 pnpm 记录的版本装回来:1.7.0 的安装可能一声不响退回 1.6.9。DSH 0.2.1 让插件无法从内部持久地自安装(管理器拒绝已声明的包,而它的「先移除再安装」会先卸载掉正要完成安装的代码),所以自安装器被移除:更新行只检查 npm、报告新版,并指向真正负责安装的入口——设置 → 插件(卸载后再装)、市场,或 web profile 上的 `dsh plugin add`。它还会把「运行版本」与「lockfile 会恢复的版本」做比较,**不一致时明确提示**,把静默回退变成用户可自助修复的状态。**新增:目标模式下等目标结束再提醒**(issue #2)——目标模式会自动进行多轮,原先每轮结束都会响;新开关「目标模式下只在最终轮提醒」让中间轮保持安静,只在目标完成、暂停或受阻时响一次(普通对话不受影响;默认关闭)。本版保持同样的七个文件名,1.6.9 / 1.7.0 的安装仍可通过它们自带的自更新到达 1.8.0——之后用包管理器重装一次,升级即永久生效。
133
142
  - **v1.7.0**(2026-10-16)**更新机制的转折点**:一键更新不再受「固定七个文件名」的白名单约束,改为按规则接受包目录下的任何普通文件——路径穿越、绝对路径、符号链接、非普通文件、保留名字(更新器自己的备份/临时名与记录文件、`.git`、`node_modules`、`.npmrc`)、含 `:` 的路径段,以及只有大小写不同的重名或**与 `package.json` 声明的入口只差大小写**的文件,依然一律拒绝,文件数与解压体积也都有上限(解压时即受 `gunzip` 上限约束)。**1.7.0 及以后可以正常更新到任意增减文件的新版**:某个版本去掉的文件现在会真的被删掉(依据更新器自己留下的 `.update-manifest.json` 记录,**只删它自己装过的文件**,用户放进目录里的东西一律不动;第一条记录之前的安装不做任何猜测)。**1.6.9 及更早**遇到「新增了文件」的新版会更新失败(安全失败:一个字节都不写,已装版本继续正常工作),README 里说明了重装一次的办法。修复:关掉「自动检查更新」会让每日轮询永久停摆(重新打开也不恢复);窗口标题在两次 Win32 读取之间变短时,点通知唤窗会静默失效;预发布版本号按字符串比较(`rc.10` 被误判为比 `rc.9` 旧);**同一个 GUI 开多个标签页或多个窗口时提示音、系统通知、重复提醒全部翻倍**(现在由 BroadcastChannel + 本地记录选出一个「发声页」,其余页保持安静,只在发声页消失后接管;窗口标题标记各窗口独立,不受影响);自定义音效的峰值归一化改为**逐样本**扫描(原先每 8 帧抽样会与接近 fs/8 的高频混叠、系统性低估峰值)。更新失败时给出**按阶段区分的建议**(网络类提示重试;解包/替换类给出手动重装步骤与仓库地址,并列出失败的两个版本号),写入顺序改为**最后写 `package.json`**(中途崩溃时检查仍会提示更新,用户再点一次即可自愈),并会校验归档里的清单确实是本包、确实是 registry 报的那个版本。设置里「自定义音效」移到**三种提示音之后**(它们才是会用到它的三处);`settings` 相关的小修:冷却表改为真正的 LRU(原先是 FIFO,最常触发的会话反而最先被淘汰)、会话列表每轮只取一次快照、macOS 桌面版的「窗口标题提醒」开关改为**禁用**(原先能打开但标记无处显示)、英文界面更新提示里残留的全角标点修掉、README 的 Release 安装说明改为可照做的本地路径写法。
134
143
  - **v1.6.9**(2026-10-12)修正 v1.6.8 的 README 文件名兼容性:改回 `README.md`(英文默认)+ `README.zh.md`(中文),确保旧版本更新白名单能识别。新文件名会让旧用户的更新被拒——白名单是单向兼容的,更新时跑的是旧代码。
135
144
  - **v1.6.8**(2026-10-12)修复复核细节 + 优化:`autoCheck` 首帧时序补上(`undefined` 不再被当成允许联网);删孤立 JSDoc;teardown 断言改为真正验证监听器移除;`normalizedGain` 抽样(每 8 帧,260 万→33 万次);`master` gain 播完自动断连(不再泄漏音频节点);`swapNavIcon` try/catch + 保留原节点、dispose 时还原(React 重排不再炸);冷却表 LRU 淘汰(不再全清);`sessionRows` 同步块级快照缓存。
package/lib/client.js CHANGED
@@ -173,6 +173,8 @@ window.__ModuleLoader__.load({
173
173
  "question.description": "智能体向你提问时播放",
174
174
  "completion.title": "任务完成时",
175
175
  "completion.description": "会话由运行转为空闲时播放",
176
+ "goalFinalOnly.title": "目标模式下只在最终轮提醒",
177
+ "goalFinalOnly.description": "目标模式会自动进行多轮;开启后中间轮结束时保持安静,只在目标结束(或暂停、受阻)时响一次。普通对话不受影响",
176
178
  "subagent.title": "子智能体的提醒",
177
179
  "subagent.description": "子智能体(后台任务)完成或需要决策时也提醒;关闭后只提醒主对话",
178
180
  "onlyWhenHidden.title": "仅在页面不可见时提示",
@@ -231,6 +233,9 @@ window.__ModuleLoader__.load({
231
233
  "update.available": "有新版",
232
234
  "update.failed": "检查失败(网络不可用)",
233
235
  "update.apply": "立即更新",
236
+ "update.desktopGuidance": "升级请走包管理器:设置 → 插件 → 卸载本插件,再重新添加 dsh-plugin-notify-sounds。安装由包管理器完成,升级才能留在新版(本插件不再自己替换文件)",
237
+ "update.webGuidance": "在终端执行 dsh plugin --profile {profile} add dsh-plugin-notify-sounds@{version}",
238
+ "update.unregistered": "这个安装没有被包管理器登记(记录仍为 {recorded}),下次安装其他插件时可能被退回。请按上面的方式重新安装一次。",
234
239
  "update.updating": "更新中…",
235
240
  "update.doneDetail": "更新完成:{from} → {to},重启 DSH 后生效",
236
241
  "update.applyFailed": "更新失败({stage}),已恢复原状",
@@ -286,6 +291,8 @@ window.__ModuleLoader__.load({
286
291
  "renotify.interval": "Interval",
287
292
  "renotify.minutes": "{n} min",
288
293
  "quiet.title": "Quiet hours",
294
+ "goalFinalOnly.title": "Only alert on the final goal round",
295
+ "goalFinalOnly.description": "A goal runs several automatic rounds; with this on, intermediate rounds stay silent and one chime marks the end of the goal (or a pause or block). Ordinary sessions are unaffected",
289
296
  "quiet.description": "No alerts during this daily time range (may wrap past midnight, e.g. 22:00 to 08:00)",
290
297
  "quiet.start": "Start time",
291
298
  "quiet.end": "End time",
@@ -318,6 +325,9 @@ window.__ModuleLoader__.load({
318
325
  "update.available": "New version available",
319
326
  "update.failed": "Check failed (no network)",
320
327
  "update.apply": "Update now",
328
+ "update.desktopGuidance": "Update through the package manager: Settings → Plugins → remove this plugin, then add dsh-plugin-notify-sounds again. The installer keeps the upgrade (this plugin no longer replaces its own files)",
329
+ "update.webGuidance": "Run dsh plugin --profile {profile} add dsh-plugin-notify-sounds@{version} in a terminal",
330
+ "update.unregistered": "This install is not registered with the package manager (it still records {recorded}), so a later plugin install may roll it back. Reinstall it with the step above.",
321
331
  "update.updating": "Updating…",
322
332
  "update.doneDetail": "Updated: {from} → {to} — restart DSH to load it",
323
333
  "update.applyFailed": "Update failed ({stage}) — the previous version is intact",
@@ -864,8 +874,6 @@ window.__ModuleLoader__.load({
864
874
  /** Route the Host half answers the update check on; must match the Host half's UPDATE_CHECK_PATH. */
865
875
  const UPDATE_CHECK_PATH = "/notify-sounds/update/check";
866
876
 
867
- /** Route the Host half applies an update through; must match the Host half's UPDATE_APPLY_PATH. */
868
- const UPDATE_APPLY_PATH = "/notify-sounds/update/apply";
869
877
 
870
878
  /**
871
879
  * Where a user goes when the one-click update cannot finish.
@@ -1378,6 +1386,17 @@ window.__ModuleLoader__.load({
1378
1386
  failed: failedField === "subagentAlerts",
1379
1387
  onChange: (next) => write("subagentAlerts", next),
1380
1388
  }),
1389
+ h(SwitchRow, {
1390
+ key: "goalFinalOnly",
1391
+ t,
1392
+ title: t("goalFinalOnly.title"),
1393
+ description: t("goalFinalOnly.description"),
1394
+ label: t("goalFinalOnly.title"),
1395
+ checked: value?.goalFinalOnly === true,
1396
+ disabled,
1397
+ failed: failedField === "goalFinalOnly",
1398
+ onChange: (next) => write("goalFinalOnly", next),
1399
+ }),
1381
1400
  h(SystemNotifyRow, {
1382
1401
  key: "systemNotify",
1383
1402
  t,
@@ -1935,73 +1954,51 @@ window.__ModuleLoader__.load({
1935
1954
  setState({ phase: "failed" });
1936
1955
  }
1937
1956
  };
1938
- const apply = async () => {
1939
- setState({ phase: "updating" });
1940
- try {
1941
- const response = await fetch(UPDATE_APPLY_PATH, { method: "POST" });
1942
- const result = await response.json();
1943
- setState({ phase: result?.ok === true ? (result.upToDate === true ? "done" : "updated") : "applyFailed", result });
1944
- } catch {
1945
- setState({ phase: "applyFailed" });
1946
- }
1947
- };
1948
1957
  // A cached answer makes this free; only a cold Host reaches out.
1949
1958
  // Same guard as the notice: `=== true` (not `!== false`), because
1950
1959
  // during the loading frame `undefined` must not be treated as
1951
- // permission to reach out. The button below works regardless.
1960
+ // permission to reach out.
1952
1961
  useEffect(() => {
1953
1962
  if (autoCheck !== true) return;
1954
1963
  check(false)();
1955
1964
  }, [autoCheck]);
1956
1965
  const payload = state.payload;
1957
- // The Host remembers the last install and repeats it with every
1958
- // answer, and this row prefers that: an update swaps the client
1959
- // half's own file, so the page may reload and drop this row's
1960
- // state mid-message — the news has to survive that. The Host keeps
1961
- // it until DSH restarts, which is exactly as long as "restart to
1962
- // load it" is true.
1963
- const applied = payload?.applied ?? (state.phase === "updated" ? state.result : undefined);
1964
- const appliedDone = applied !== undefined && (applied.ok === true || typeof applied.to === "string");
1966
+ const latest = payload?.latest === undefined ? undefined : formatVersion(payload.latest);
1965
1967
  let status = payload === undefined
1966
1968
  ? t("update.idle")
1967
1969
  : payload.updateAvailable === true
1968
- ? `${t("update.available")} ${formatVersion(payload.latest)}`
1970
+ ? `${t("update.available")} ${latest}`
1969
1971
  : t("update.uptodate");
1970
1972
  if (state.phase === "checking") status = t("update.checking");
1971
- if (state.phase === "updating") status = t("update.updating");
1972
- let detail = payload === undefined ? status : `${t("update.current")} ${formatVersion(payload.current)} · ${status}`;
1973
- // Advice is a second line rather than more words in the first one:
1974
- // the failure line is the part a user scans, and the remedy only
1975
- // applies to some stages. `undefined` renders nothing at all.
1976
- let advice;
1977
- if (appliedDone) {
1978
- detail = updateAppliedText(t, applied);
1979
- } else if (state.phase === "applyFailed") {
1980
- const failure = updateFailureText(t, state.result, payload?.current);
1981
- detail = failure.detail;
1982
- advice = failure.advice;
1973
+ const detail = payload === undefined ? status : `${t("update.current")} ${formatVersion(payload.current)} · ${status}`;
1974
+ // The install belongs to the package manager now: this plugin only
1975
+ // checks, and every route below installs THROUGH pnpm so the
1976
+ // profile's lockfile moves with the files. The two shells reach it
1977
+ // differently, so the row spells out the one that applies here.
1978
+ const lines = [];
1979
+ if (payload?.unregistered === true) {
1980
+ lines.push(h("div", { className: css.hint, key: "unregistered" }, t("update.unregistered", {
1981
+ recorded: formatVersion(payload.recorded),
1982
+ })));
1983
+ }
1984
+ if (payload?.updateAvailable === true && latest !== undefined) {
1985
+ lines.push(h("div", { className: css.hint, key: "howto" }, isDesktopShell()
1986
+ ? t("update.desktopGuidance")
1987
+ : t("update.webGuidance", { profile: payload.profile ?? "web", version: latest })));
1983
1988
  }
1984
- const busy = state.phase === "checking" || state.phase === "updating";
1985
1989
  return h("div", { className: css.row }, [
1986
1990
  h("div", { key: "text" }, [
1987
1991
  h("div", { className: css.rowTitle, key: "title" }, t("update.title")),
1988
1992
  h("div", { className: css.rowDescription, key: "description" }, t("update.description")),
1989
1993
  h("div", { className: css.hint, key: "status" }, detail),
1990
- advice === undefined ? null : h("div", { className: css.hint, key: "advice" }, advice),
1994
+ ...lines,
1991
1995
  ]),
1992
1996
  h("div", { className: css.stackControl, key: "control" }, [
1993
- payload?.updateAvailable === true && !appliedDone ? h(Button, {
1994
- key: "apply",
1995
- variant: "outline",
1996
- size: "sm",
1997
- disabled: busy,
1998
- onClick: apply,
1999
- }, t("update.apply")) : null,
2000
1997
  h(Button, {
2001
1998
  key: "check",
2002
1999
  variant: "outline",
2003
2000
  size: "sm",
2004
- disabled: busy,
2001
+ disabled: state.phase === "checking",
2005
2002
  onClick: check(true),
2006
2003
  }, t("update.check")),
2007
2004
  ]),
@@ -2417,6 +2414,90 @@ window.__ModuleLoader__.load({
2417
2414
  }
2418
2415
  return false;
2419
2416
  };
2417
+ /**
2418
+ * The goal projection's phase for one session, when this runtime
2419
+ * carries the goal packages.
2420
+ *
2421
+ * DSH's goal mode drives several rounds inside one session, and
2422
+ * every round ends with a running→idle edge — so an unguarded
2423
+ * completion chime fires once per round. The phase is the host's
2424
+ * own vocabulary: `active` keeps going on its own, `complete`
2425
+ * finished, and `paused`/`blocked` wait for the user.
2426
+ *
2427
+ * Every step is optional: a runtime without the goal projection
2428
+ * simply answers `undefined`, which reads as "no goal".
2429
+ */
2430
+ const goalPhaseOf = (sessionId) => {
2431
+ try {
2432
+ const sessions = ctx.sessions ?? ctx.uiSession?.sessions;
2433
+ const store = sessions?.get?.(sessionId)?.projections;
2434
+ const snapshot = store?.get?.("goal") ?? store?.faceOf?.("goal")?.getSnapshot?.();
2435
+ const phase = snapshot?.goal?.phase;
2436
+ return typeof phase === "string" ? phase : undefined;
2437
+ } catch {
2438
+ return undefined;
2439
+ }
2440
+ };
2441
+ /** Whether the completion edge for a session is worth an alert now. */
2442
+ const completionIsFinal = (sessionId, value) => {
2443
+ if (value?.goalFinalOnly !== true) return true;
2444
+ // A session with no goal, or with one that will not continue on
2445
+ // its own (finished, paused, blocked), ends this edge for the
2446
+ // user; one that is still `active` drives another round.
2447
+ return goalPhaseOf(sessionId) !== "active";
2448
+ };
2449
+ /** Longest a goal may stay `active` before its watcher gives up. */
2450
+ const GOAL_SETTLE_TIMEOUT_MS = 30 * 60 * 1000;
2451
+ /** Settings whose session already has a watcher waiting for its goal. */
2452
+ const goalWatchers = new Map();
2453
+ /**
2454
+ * Serve the single completion chime a goal earns when it ends.
2455
+ *
2456
+ * The edge that armed this watcher was an intermediate round (the
2457
+ * phase was still `active`). The next round starts at quiescence,
2458
+ * so the projection is re-read on every change: running again means
2459
+ * the edge was intermediate and stays silent, while any non-active
2460
+ * phase means the goal ended and earns the one chime.
2461
+ */
2462
+ const watchGoalCompletion = (sessionId) => {
2463
+ if (goalWatchers.has(sessionId)) return;
2464
+ let settled = false;
2465
+ let subscriptionOff = () => {};
2466
+ let timer;
2467
+ const settle = (chime) => {
2468
+ if (settled) return;
2469
+ settled = true;
2470
+ goalWatchers.delete(sessionId);
2471
+ try {
2472
+ subscriptionOff();
2473
+ } catch {}
2474
+ clearTimeout(timer);
2475
+ if (!chime) return;
2476
+ if (!pageIsWatched() && !quietNow()) unreadCompletion = true;
2477
+ notify("completion", undefined, sessionId);
2478
+ refreshFlash();
2479
+ };
2480
+ try {
2481
+ const sessions = ctx.sessions ?? ctx.uiSession?.sessions;
2482
+ const face = sessions?.get?.(sessionId)?.projections?.faceOf?.("goal");
2483
+ if (typeof face?.subscribe === "function") {
2484
+ const subscription = face.subscribe(() => {
2485
+ if (source.getSnapshot().get(sessionId)?.running === true) {
2486
+ settle(false);
2487
+ return;
2488
+ }
2489
+ const phase = goalPhaseOf(sessionId);
2490
+ if (phase === undefined || phase !== "active") settle(true);
2491
+ });
2492
+ if (typeof subscription === "function") subscriptionOff = subscription;
2493
+ }
2494
+ } catch {}
2495
+ // A goal that never resolves must not pin this entry forever;
2496
+ // dropping it silently beats a stray chime minutes later.
2497
+ timer = setTimeout(() => settle(false), GOAL_SETTLE_TIMEOUT_MS);
2498
+ timer?.unref?.();
2499
+ goalWatchers.set(sessionId, () => settle(false));
2500
+ };
2420
2501
  /**
2421
2502
  * Which alert the title should carry, if any.
2422
2503
  *
@@ -2499,13 +2580,20 @@ window.__ModuleLoader__.load({
2499
2580
  notify(status.pendingInteraction.kind === "question" ? "question" : "decision", status.pendingInteraction, sessionId);
2500
2581
  }
2501
2582
  if (before !== undefined && before.running === true && status.running === false) {
2502
- // A finish that happens while the user is away is
2503
- // news; one they watch happen is not — and one
2504
- // that happens during quiet hours is forgotten
2505
- // rather than kept for later, so nothing about it
2506
- // shows up when the quiet window ends.
2507
- if (!pageIsWatched() && !quietNow()) unreadCompletion = true;
2508
- notify("completion", undefined, sessionId);
2583
+ const value = form.getSnapshot().value;
2584
+ if (!completionIsFinal(sessionId, value)) {
2585
+ // An intermediate goal round: stay silent and let
2586
+ // the goal's own end deliver the single chime.
2587
+ watchGoalCompletion(sessionId);
2588
+ } else {
2589
+ // A finish that happens while the user is away is
2590
+ // news; one they watch happen is not — and one
2591
+ // that happens during quiet hours is forgotten
2592
+ // rather than kept for later, so nothing about it
2593
+ // shows up when the quiet window ends.
2594
+ if (!pageIsWatched() && !quietNow()) unreadCompletion = true;
2595
+ notify("completion", undefined, sessionId);
2596
+ }
2509
2597
  }
2510
2598
  }
2511
2599
  }
@@ -2590,6 +2678,7 @@ window.__ModuleLoader__.load({
2590
2678
  unsubscribeForm();
2591
2679
  unsubscribeLocale();
2592
2680
  clearInterval(renotifyTimer);
2681
+ for (const stop of [...goalWatchers.values()]) stop();
2593
2682
  if (typeof document !== "undefined") document.removeEventListener("visibilitychange", onVisibility);
2594
2683
  applyTitleFlash(undefined, titleAlerts(t));
2595
2684
  };
@@ -2690,7 +2779,6 @@ window.__ModuleLoader__.load({
2690
2779
  exports.SOUND_IDS = SOUND_IDS;
2691
2780
  exports.FOCUS_PATH = FOCUS_PATH;
2692
2781
  exports.UPDATE_CHECK_PATH = UPDATE_CHECK_PATH;
2693
- exports.UPDATE_APPLY_PATH = UPDATE_APPLY_PATH;
2694
2782
  // Which update stages a retry can fix and which need a fresh install:
2695
2783
  // the Host names a stage in every failure it reports, so this map is the
2696
2784
  // one place the advice comes from, and the tests cross-check it against
package/lib/index.js CHANGED
@@ -683,6 +683,41 @@ async function readCappedBytes(response, cap) {
683
683
  * @returns `{ ok, current, latest, updateAvailable, checkedAt }`, or
684
684
  * `{ ok: false, current, error }` when no registry answered.
685
685
  */
686
+ /**
687
+ * How the running package relates to what the profile's package manager
688
+ * recorded for it.
689
+ *
690
+ * This plugin no longer installs its own releases (as of 1.8.0): a release
691
+ * reaches a profile through the package manager, which also owns the
692
+ * lockfile. A tree that arrived by any other route looks identical on disk
693
+ * while the lockfile still pins an older version — and the next
694
+ * `pnpm install` in that profile silently restores the old one. Reading the
695
+ * version the lockfile would restore lets the Settings row say so instead of
696
+ * leaving the user to discover it after the next plugin operation.
697
+ *
698
+ * Every part is optional: no profile directory, no lockfile or an unreadable
699
+ * one simply reports nothing, and the row keeps its normal wording.
700
+ *
701
+ * @param current - the version actually on disk.
702
+ * @returns the fields the check payload mirrors to the row.
703
+ */
704
+ function installationProvenance(current) {
705
+ try {
706
+ const profileDir = process.env.DSH_PROFILE_DIR;
707
+ if (profileDir === undefined) return {};
708
+ const lock = readFileSync(join(profileDir, "pnpm-lock.yaml"), "utf8");
709
+ const recorded = new RegExp(`${UPDATE_PACKAGE}@([0-9][^:\\s"']*)`).exec(lock)?.[1];
710
+ return {
711
+ recorded,
712
+ unregistered: current !== undefined && recorded !== undefined && recorded !== current,
713
+ profile: process.env.DSH_PROFILE,
714
+ };
715
+ } catch {
716
+ return {};
717
+ }
718
+ }
719
+ export { installationProvenance };
720
+
686
721
  export async function checkForUpdate(options = {}) {
687
722
  const now = Date.now();
688
723
  if (options.force !== true && updateCheck.result !== undefined && now - updateCheck.checkedAt < UPDATE_CHECK_TTL_MS) {
@@ -704,7 +739,7 @@ export async function checkForUpdate(options = {}) {
704
739
  const current = readOwnVersion(options.root);
705
740
  const answer = await fetchRegistryAnswer();
706
741
  if (answer === undefined) {
707
- const result = { ok: false, current, error: "no registry answered", applied: updateCheck.applied };
742
+ const result = { ok: false, current, error: "no registry answered", applied: updateCheck.applied, ...installationProvenance(current) };
708
743
  updateCheck.checkedAt = now;
709
744
  updateCheck.result = result;
710
745
  return result;
@@ -717,6 +752,7 @@ export async function checkForUpdate(options = {}) {
717
752
  updateAvailable: Number.isFinite(ordering) && ordering < 0,
718
753
  checkedAt: now,
719
754
  applied: updateCheck.applied,
755
+ ...installationProvenance(current),
720
756
  };
721
757
  updateCheck.checkedAt = now;
722
758
  updateCheck.result = result;
@@ -770,7 +806,11 @@ async function fetchRegistryAnswer() {
770
806
 
771
807
  //#endregion
772
808
 
773
- //#region update apply
809
+ //#region update apply — UNREACHABLE since 1.8.0: no route calls it any more.
810
+ // The Settings row sends the user to the plugin manager / package manager
811
+ // instead, so this plugin never writes its own files. The code below stays
812
+ // only until its tests retire with a later release; nothing in apply() can
813
+ // reach it.
774
814
 
775
815
  /** Route the browser half asks for an update to be applied through. */
776
816
  export const UPDATE_APPLY_PATH = "/notify-sounds/update/apply";
@@ -1334,6 +1374,8 @@ export const Config = z.object({
1334
1374
  quietStart: z.string().pattern(TIME_OF_DAY).default("22:00").volatile(),
1335
1375
  /** Quiet range end, "HH:MM" 24-hour. */
1336
1376
  quietEnd: z.string().pattern(TIME_OF_DAY).default("08:00").volatile(),
1377
+ /** In goal mode, stay silent on intermediate rounds and chime once when the goal ends. */
1378
+ goalFinalOnly: z.boolean().default(false).volatile(),
1337
1379
  });
1338
1380
 
1339
1381
  /**
@@ -1436,37 +1478,5 @@ export function apply(ctx) {
1436
1478
  },
1437
1479
  }), "notify-sounds: update check route");
1438
1480
 
1439
- // The update apply route: same fence, same fixed target. It accepts no
1440
- // version and no URL from the caller — the update it performs is always
1441
- // the one a registry described for this package, verified against that
1442
- // registry's own digest before anything is written.
1443
- child.effect(() => child.webServer.register({
1444
- kind: "exact",
1445
- path: UPDATE_APPLY_PATH,
1446
- handler: async (req, res) => {
1447
- const rejection = child.connection.requestRejection(req);
1448
- if (rejection !== undefined) {
1449
- res.statusCode = rejection;
1450
- res.end();
1451
- return;
1452
- }
1453
- if (req.method !== "POST") {
1454
- res.statusCode = 405;
1455
- res.setHeader("allow", "POST");
1456
- res.end();
1457
- return;
1458
- }
1459
- try {
1460
- const result = await applyUpdate();
1461
- res.statusCode = 200;
1462
- res.setHeader("content-type", "application/json");
1463
- res.end(JSON.stringify(result));
1464
- } catch (error) {
1465
- warn(`update apply failed: ${error?.message ?? error}`);
1466
- res.statusCode = 500;
1467
- res.end();
1468
- }
1469
- },
1470
- }), "notify-sounds: update apply route");
1471
1481
  });
1472
1482
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-notify-sounds",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Notification sounds for DeepSeek Harness — a soft chime when the agent needs your decision or finishes a task, with a Settings section styled like DSH's own · 需要决策或任务完成时播放提示音,点击系统通知可回到窗口,设置面板可调音量与音效",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -59,4 +59,4 @@
59
59
  "platform": "web"
60
60
  }
61
61
  }
62
- }
62
+ }