dsh-notify-me 1.15.0 → 1.16.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,33 @@
2
2
 
3
3
  All notable changes to **dsh-notify-me** are documented here.
4
4
 
5
+ ## [1.16.1] — 2026-10-28
6
+
7
+ 文案修正,无行为变化。
8
+
9
+ ### 文档
10
+
11
+ - 设置页「会话静音」卡的说明原写「被静音的会话在标题前显示划掉的铃铛」,但那个槽位在会话有运行状态时被状态点占用——正在跑的后台任务看不到标记。说明里补上这一点,并指出此时看行尾铃铛的按下状态(中英同步)。`README.md` / `README.en.md` 的正文本来就写了这个限制,只有设置页漏了。
12
+ - 同一段里「列表上限 500 条」改成 200 条:上一版把 `MUTED_MAX` 降到 200(心跳 body 的 16 KiB 上限),README 两处漏改(`README.md:158`、`README.en.md:158`)。
13
+
14
+ ## [1.16.0] — 2026-10-28
15
+
16
+ 回应 [#23](https://github.com/chromoany/dsh-notify-me/issues/23):可以按对话静音,只影响那一行。
17
+
18
+ ### 新增
19
+
20
+ - **按对话静音**:会话行悬停时右侧多一个铃铛——点一下静音这条对话,再点恢复(`静音此会话` / `取消静音`)。闸门在 `fire()` 与列表判定同一处短路:本地通知、提示音、标签页标记、外部推送全部不发,别的对话不受影响;测试按钮不受影响(它直接走 `deliver()`,本来就是「我现在就要看一条」)。列表存在本地配置 `mutedSessions` 里,重载与重启后仍在,`readConfig` 会把手工改坏的内容(非字符串、空白、超长、重复)过滤掉而不是整页挂掉。
21
+ - **静音标记**:被静音的对话在标题前带一个划掉的铃铛(`role="img"` + `aria-label`,读屏能读出来)。它注在 `sidebar.session.row.leading` 槽位,而宿主在这一槽位被「会话有运行状态」的状态点占用时**不渲染**——正在跑的后台任务看不到标记,停下后回来。这是宿主槽位的既有语义,不是本插件能改的。
22
+ - **设置页「会话静音」卡片**:列出现有静音对话的数量,一键全部恢复(`恢复全部`);空列表时说明「没有静音的对话」。中英文案与读屏标签同时补齐。
23
+ - **宿主兜底跟着静音**(`lib/host-fallback.js`):心跳 body 从 `{alive, language}` 扩成 `{alive, language, muted}`,宿主记住这份列表并按会话 id 跳过——否则关掉标签页后,页面明明关掉了提醒,宿主兜底却照发一遍。心跳里只认数组,非数组、超长、重复项在 `createPresence` 侧归一(上限 200 条、单 id 200 字符),页面在发之前再按 8 KiB 字节预算截一段——心跳 body 的宿主上限是 16 KiB,压过线会回 `413`、租约断掉,兜底于是误以为页面关了;被截掉的会话仍在本页静音,只是不由兜底接管。标题仍然照记忆,取消静音后不会变成无名的会话。
24
+
25
+ ### 测试
26
+
27
+ - `smoke/smoke-test.cjs` 新增两组:`mutedSessionsHonoured`(未静音基线照发并外发一次 → 静音后既不弹也不外发 → 邻居对话不受影响 → 取消静音后恢复 → 存过的静音重载后仍生效 → 手改的垃圾列表被剪成 `["a","b"]`)、`mutedSessionsUi`(两槽位各自注册、未静音时铃铛为 `静音此会话` 且标记为 `null`、点击静音后状态翻转且阻止冒泡、设置卡片计数与一键恢复、空状态文案);心跳 body 的形状断言同步改成三个字段,并加「静音变化立刻补一次心跳」的用例。
28
+ - `smoke/page-bridge-test.mjs`:心跳带 `muted` 时仍 `200` 且租约正常;非数组被忽略、900 条的列表归一后仍 `200`,都不让心跳失败。
29
+ - `smoke/smoke-test.cjs` 另断言心跳本身不会超线:塞满 200 条 200 字符的静音列表后,仍按 8 KiB 预算截成前缀子集发出(防止「配了静音却因为 `413` 收到兜底提醒」)。
30
+ - `smoke/host-fallback-test.mjs`:页面报告静音后,`turn/end` 与 `approval/asked` 都不投递;未静音的邻居照发;心跳取消静音后下一条正常送达。
31
+
5
32
  ## [1.15.0] — 2026-10-28
6
33
 
7
34
  收编 [#25](https://github.com/chromoany/dsh-notify-me/pull/25)(回应 [#24](https://github.com/chromoany/dsh-notify-me/issues/24));两项宿主侧能力默认关,未配置时行为与上一版一致。
package/README.en.md CHANGED
@@ -139,6 +139,27 @@ Open **Settings → Notify me**. The page lays out three blocks — how you get
139
139
 
140
140
  </details>
141
141
 
142
+ ### Muting certain conversations
143
+
144
+ For the "this one runs automated work in the background — I do not need to hear about it tonight" case: silence one row and nothing else.
145
+
146
+ - **Mute**: hover a session in the sidebar, a bell appears on the right; click it to mute that conversation (the button reads "mute alerts for this session"), click again to resume.
147
+ - **Mark**: a muted conversation shows a crossed bell before its title (announced as "alerts muted for this session").
148
+ - **Scope**: "needs you", "reply finished", sound, the tab-title mark and external forwarding are all silenced for that conversation; every other conversation is untouched. The test buttons under "Try it" still fire — they exist to check the channel on the spot.
149
+ - **Persistence**: the list lives in local storage, so it survives reloads and restarts; a hand-edited list is pruned instead of breaking the page.
150
+ - **After the tab closes**: the list travels with the heartbeat, so the host-side fallback honours it too — otherwise closing the page would start the very alerts you turned off.
151
+
152
+ The settings page has a "Muted sessions" card under "When to alert" with the current count and an "Unmute all" button.
153
+
154
+ <details>
155
+ <summary>Edge cases</summary>
156
+
157
+ - The mark lives in the host's `sidebar.session.row.leading` slot, and the host puts its status dots there while a session is running, so the mark is not rendered then — a running background job shows no crossed bell until it stops. The mute itself is unaffected.
158
+ - Muting keys on the session id: renaming or moving the directory changes nothing, and a deleted session is harmless in the list (capped at 200 ids; "Unmute all" clears it).
159
+ - Muting does not change the "reply finished" policy or "current conversation stays quiet"; when both apply, the mute wins.
160
+
161
+ </details>
162
+
142
163
  ### Try it
143
164
 
144
165
  Three buttons send one "needs you", one "reply finished" and one "approval buttons" test alert with the current settings, right away, and deliberately **not** limited by the switches under "when to alert"; the line underneath states which channel can carry approval buttons right now.
@@ -223,7 +244,7 @@ Key by key (defaults in parentheses):
223
244
 
224
245
  **The credentials file** is a mode-0600 JSON file readable by the host user, holding `{"user": "...", "password": "..."}` (sent as HTTP Basic) or `{"authorization": "Bearer ..."}` (sent verbatim; a bare token gets `Bearer ` prepended). It must not go into the patch layer — that layer is world-readable and lands in the profile directory. Leaving the key empty sends the request without an authentication header: plenty of webhook endpoints never ask for one, and treating a missing credentials file as an error would make every alert fail; only a path that is configured and unreadable counts as credentials-unavailable. When the gateway answers 401 / 403 the host drops the cached credential, re-reads the file and retries exactly once, so a rotated password needs no host restart.
225
246
 
226
- **Deduplication rides on one page online lease**: on load the page probes `GET /__dsh-notify-me/host-bridge` once (and again every 60 s; no probe while the page is hidden, one catch-up probe when it becomes visible), and it only starts heartbeating when the reply says `hostFallback.enabled === true` — the body carries `{alive, language}` only, the interval is `leaseMs/3` clamped to 5–20 s, and `pagehide` releases immediately with one `{alive:false}` (sent with `keepalive`). A fresh host-side lease means no fallback push (the page is delivering), while an expired lease or an `alive:false` hands over, waiting at most `pageLeaseMs`. The heartbeat carries the language, not the page's push switches: the rule is simply that the host takes over while no page holds the lease, and the page's own visibility and idle heuristics are invisible to the host — honouring half of them would produce a rule nobody can predict. The language it brings is what keeps an English page from getting Chinese host alerts, and it applies whenever `language: 'auto'`. `pageLeaseMs: 0` turns coordination off so the host always pushes — the page then gets everything twice while it is open, so use it for debugging only.
247
+ **Deduplication rides on one page online lease**: on load the page probes `GET /__dsh-notify-me/host-bridge` once (and again every 60 s; no probe while the page is hidden, one catch-up probe when it becomes visible), and it only starts heartbeating when the reply says `hostFallback.enabled === true` — the body is `{alive, language, muted}` (`muted` being the ids of the sessions the user silenced), the interval is `leaseMs/3` clamped to 5–20 s, and `pagehide` releases immediately with one `{alive:false}` (sent with `keepalive`). A fresh host-side lease means no fallback push (the page is delivering), while an expired lease or an `alive:false` hands over, waiting at most `pageLeaseMs`. The heartbeat carries the language and the mute list, not the page's push switches: the rule is simply that the host takes over while no page holds the lease, and the page's own visibility and idle heuristics are invisible to the host — honouring half of them would produce a rule nobody can predict. The mute list is the exception: it is a settled state the user picked row by row and the page wrote to its config, so the host following it is the page speaking. The language it brings is what keeps an English page from getting Chinese host alerts, and it applies whenever `language: 'auto'`. The list is trimmed by bytes on the wire (an 8 KiB budget, at most 200 ids): a session past the cut is still silenced locally, it is just no longer covered by the fallback. `pageLeaseMs: 0` turns coordination off so the host always pushes — the page then gets everything twice while it is open, so use it for debugging only.
227
248
 
228
249
  **The two route contracts**: the probe the page calls, `GET /__dsh-notify-me/host-bridge`, answers `{ok, version, features, hostFallback:{enabled, leaseMs}, relay:{enabled, path, upstreamHost, upstreamPath}, language, page:{alive, ageMs}}` (`upstreamHost` / `upstreamPath` name the gateway the host forwards to, present only while the relay is enabled; the credential is never published); it is only registered while `hostFallback.enabled` or `relay.enabled` is true, so on a stock install it is a 404 and the page reads that as "off" rather than as a fault. The heartbeat `POST` requires the intent header `x-dsh-notify-me-page: bridge` (missing header → `403`), answers `400` to bad JSON and `413` to a body over 16 KiB, and `200 {ok, leaseUntil}` on success.
229
250
 
@@ -332,6 +353,7 @@ window.__dshNotifyMe.setConfig({
332
353
  idleMinutes: 3, // minutes without keyboard/mouse input before "away" counts (0 = turn the idle rule off)
333
354
  autoDismiss: "present", // toast auto-dismiss: 'present' keep while away | 'always' always close | 'never' never close
334
355
  ignoreSubagent: true, // true = no alerts for background subagent sessions (the open one still alerts)
356
+ mutedSessions: [], // session ids muted per conversation (written by the sidebar bell, survives reloads)
335
357
  sound: true, // sound switch (also governs the "system notification sound" mode)
336
358
  soundDone: "synth", // "reply finished" sound source: 'synth' built-in | 'custom' picked file | 'system' OS notification sound
337
359
  soundAttention: "synth", // "needs you" sound source, same values
@@ -439,6 +461,7 @@ The cases where it will not raise are the same ones listed under [Known limitati
439
461
  - On `>= 0.1.6` (including `0.2.0-rc.2`, `0.2.1-rc.2`) the "reply finished" alert body carries only the session name and no reply snippet any more — host snapshots no longer provide `nodes`; the alert itself still fires as usual.
440
462
  - The title marker is written into `document.title` alongside the host: when the host recomputes the title the marker can be overwritten until the next alert event writes it again.
441
463
  - "Stay quiet for the conversation on screen" is judged by whether the window is in front: covered by another app, switched to another app, or minimized all count as background; back in front or with fresh keyboard / mouse input it goes quiet again.
464
+ - The per-conversation mute mark lives in the host's `sidebar.session.row.leading` slot, and the host puts its status dots there while a session is running, so the mark is not rendered then — a running background job shows no crossed bell until it stops; the mute itself still applies.
442
465
 
443
466
  **External push**
444
467
 
package/README.md CHANGED
@@ -139,6 +139,27 @@ dsh-notify-me 把「监督」和「守在屏幕前」解耦:只在真的出现
139
139
 
140
140
  </details>
141
141
 
142
+ ### 静音某些对话
143
+
144
+ 适合「后台跑着周期任务、但这次不用管它」的对话:只关掉那一行的提醒,别的照旧。
145
+
146
+ - **静音**:鼠标移到侧边栏的会话行上,右侧出现铃铛,点一下即静音(按钮读作「静音此会话的提醒」);再点一次恢复;
147
+ - **标记**:被静音的对话在标题前显示一个划掉的铃铛(读屏读作「此会话已静音」);
148
+ - **范围**:「需要你」「回复完成」、提示音、标签页标记、外部推送一起关掉;别的对话完全不受影响;「试一试」里的测试按钮照发(它就是用来当场验证渠道的);
149
+ - **持久化**:列表存在本地,刷新、重启都在;手工改坏的配置会被剪掉而不是让整页失效;
150
+ - **关掉标签页之后**:静音列表会随心跳交给宿主,所以「页面关闭后的宿主侧兜底」也不会为它推送——否则关掉页面反而开始响。
151
+
152
+ 设置页「什么时候提醒」下面有一张「会话静音」卡片,显示当前静音了几个对话,可以一键「全部取消静音」。
153
+
154
+ <details>
155
+ <summary>边界条件</summary>
156
+
157
+ - 标记注在宿主的 `sidebar.session.row.leading` 槽位,宿主在「这条会话有运行状态」时用状态点占着这个位置,标记就不渲染——正在跑的后台任务看不到划掉的铃铛,停下后自动回来。静音本身不受影响,通知照旧不发。
158
+ - 静音只看会话 id:重命名、换目录都不影响,删掉的会话留在列表里也不会报错(列表上限 200 条,恢复按钮随时清空)。
159
+ - 静音不改变「回复完成」的 donePolicy 判定,也不改变「当前对话不弹通知」:两者叠加时以静音为准。
160
+
161
+ </details>
162
+
142
163
  ### 试一试
143
164
 
144
165
  三个按钮分别发一条「需要你」「回复完成」「审批按钮」测试提醒,用当前设置立即发,**不受**「什么时候提醒」里的开关限制;下方一行如实说明当前哪种渠道能给审批按钮。
@@ -223,7 +244,7 @@ profile 覆盖示例(`~/.dsh/profiles/<profile>/cordis.patch.yml`)。**`conf
223
244
 
224
245
  **凭据文件**:宿主用户可读的 0600 JSON,内容是 `{"user": "...", "password": "..."}`(按 HTTP Basic 发)或 `{"authorization": "Bearer ..."}`(原样发;裸 token 会自动补上 `Bearer `)。它不能写进 patch 层——那一层世界可读、还会进 profile 目录。不填这个键时请求不带认证头:很多 webhook 端点本来就不要认证,把「没配凭据」当成错误会让每个提醒都失败;只有「配了路径却读不出来」才算凭据不可用。网关回 401 / 403 时宿主丢掉缓存的凭据、重读文件、只重试一次,所以轮换密码不需要重启宿主。
225
246
 
226
- **去重靠一条页面在线租约**:页面加载后 `GET /__dsh-notify-me/host-bridge` 探测一次(之后每 60 秒复探,页面隐藏时不探、回到可见补探一次),只有回包 `hostFallback.enabled === true` 才开始心跳——body 只有 `{alive, language}`,间隔取 `leaseMs/3`、夹在 5–20 秒;`pagehide` 时发一条 `{alive:false}`(带 `keepalive`)立刻释放。宿主侧租约新鲜就不补推(页面自己在推),租约过期或收到 `alive:false` 才接手,最多等 `pageLeaseMs` 这么久。心跳只带语言,不带页面的推送开关:规则是「没有页面持有租约时宿主接手」,而页面的可见性与闲置判定宿主看不见,只照做一半会得到谁也算不清的规则。语言带过来是为了英文页面不收中文宿主提醒,`language: 'auto'` 时生效。`pageLeaseMs: 0` 关掉协调,宿主永远推——页面开着时会收到两份,只在调试时用。
247
+ **去重靠一条页面在线租约**:页面加载后 `GET /__dsh-notify-me/host-bridge` 探测一次(之后每 60 秒复探,页面隐藏时不探、回到可见补探一次),只有回包 `hostFallback.enabled === true` 才开始心跳——body 是 `{alive, language, muted}`(`muted` 是被静音会话的 id 列表),间隔取 `leaseMs/3`、夹在 5–20 秒;`pagehide` 时发一条 `{alive:false}`(带 `keepalive`)立刻释放。宿主侧租约新鲜就不补推(页面自己在推),租约过期或收到 `alive:false` 才接手,最多等 `pageLeaseMs` 这么久。心跳带语言与静音列表,不带页面的推送开关:规则是「没有页面持有租约时宿主接手」,而页面的可见性与闲置判定宿主看不见,只照做一半会得到谁也算不清的规则;静音列表是例外,它是用户逐条点出来、写在配置里的确定状态,宿主照它跳过就是页面自己的意思。语言带过来是为了英文页面不收中文宿主提醒,`language: 'auto'` 时生效。列表在心跳里按字节截断(预算 8 KiB、最多 200 条):被截掉的会话仍在本页静音,只是不由兜底接管。`pageLeaseMs: 0` 关掉协调,宿主永远推——页面开着时会收到两份,只在调试时用。
227
248
 
228
249
  **两个路由的契约**:页面探测的那条 `GET /__dsh-notify-me/host-bridge` 回 `{ok, version, features, hostFallback:{enabled, leaseMs}, relay:{enabled, path, upstreamHost, upstreamPath}, language, page:{alive, ageMs}}`(`upstreamHost` / `upstreamPath` 是宿主替你转发时的网关主机名与路径,只在中继启用时给出,凭据永不下发);它只在 `hostFallback.enabled` 或 `relay.enabled` 为真时注册,默认安装下是 404,页面按「未启用」处理而不是当故障。心跳 `POST` 要求意图头 `x-dsh-notify-me-page: bridge`(缺了回 `403`),坏 JSON 回 `400`,body 超 16 KiB 回 `413`,成功回 `200 {ok, leaseUntil}`。
229
250
 
@@ -332,6 +353,7 @@ window.__dshNotifyMe.setConfig({
332
353
  idleMinutes: 3, // 超过多少分钟没有键鼠输入算「离开」(0 = 关掉闲置判定)
333
354
  autoDismiss: "present", // 通知自动消失:'present' 离开时保留 | 'always' 总是关闭 | 'never' 从不关闭
334
355
  ignoreSubagent: true, // true = 后台子代理(subagent)会话不提醒(当前打开的照常)
356
+ mutedSessions: [], // 按对话静音的会话 id 列表(侧边栏铃铛写入,重载后仍在)
335
357
  sound: true, // 提示音开关(含「系统通知音」模式)
336
358
  soundDone: "synth", // 「完成」音效来源:'synth' 内置 | 'custom' 自定义文件 | 'system' 系统通知音
337
359
  soundAttention: "synth", // 「需要你」音效来源,取值同上
@@ -438,6 +460,7 @@ Windows 的激活顺序是实的:已经在前台就什么都不做(最常见
438
460
  - `≥ 0.1.6`(含 `0.2.0-rc.2`、`0.2.1-rc.2`)的「回复完成」提醒正文只有会话名,不再附带回复摘要——宿主快照已不再提供 `nodes`;提醒本身照常触发。
439
461
  - 标题标记由宿主与插件共同写 `document.title`:宿主重算标题时标记可能被覆盖,直到下一次提醒事件重新写成。
440
462
  - 「当前对话不弹通知」按「窗口是否在前台」判定:被别的应用盖住、切到别的应用、最小化都算后台;回到前台或重新有键鼠输入后恢复静默。
463
+ - 按对话静音的标记注在宿主的 `sidebar.session.row.leading` 槽位,而宿主在「这条会话有运行状态」时用状态点占着这个位置,标记就不渲染——正在跑的后台任务看不到划掉的铃铛,停下后自动回来;静音本身不受影响。
441
464
 
442
465
  **外部推送**
443
466
 
package/lib/client.js CHANGED
@@ -253,6 +253,11 @@
253
253
  // keys on, plus "not the session on screen" — an open subagent session is
254
254
  // just another conversation to alert for.
255
255
  ignoreSubagent: true,
256
+ // Session ids the user silenced from the sidebar row ("静音" on the row
257
+ // menu / hover button). Unlike ignoreSubagent this is a per-session hand
258
+ // choice, remembered across restarts; ids are opaque host strings and the
259
+ // list is pruned on read, so a hand-edited config cannot break matching.
260
+ mutedSessions: [],
256
261
  sound: true,
257
262
  // Where each alert's cue comes from (per kind, so "needs you" and "reply
258
263
  // finished" stay independent):
@@ -326,6 +331,7 @@
326
331
  // means anything still reading doneHiddenOnly (a script, the 1.x smoke
327
332
  // suite, a downgrade) sees what the policy actually does.
328
333
  cfg.doneHiddenOnly = cfg.donePolicy !== "always";
334
+ cfg.mutedSessions = cleanMutedSessions(cfg.mutedSessions);
329
335
  return cfg;
330
336
  }
331
337
  function writeConfig(patch) {
@@ -342,6 +348,7 @@
342
348
  }
343
349
  cfg.donePolicy = cfg.donePolicy === "smart" || cfg.donePolicy === "always" ? cfg.donePolicy : "background";
344
350
  cfg.doneHiddenOnly = cfg.donePolicy !== "always";
351
+ cfg.mutedSessions = cleanMutedSessions(cfg.mutedSessions);
345
352
  try {
346
353
  localStorage.setItem(LS_CONFIG, JSON.stringify(cfg));
347
354
  configWriteFailed = false;
@@ -359,9 +366,106 @@
359
366
  function setConfigLocal(patch) {
360
367
  config = writeConfig(patch);
361
368
  applyTitle();
369
+ // A mute-list change is the one setting the host half reads: tell the rows
370
+ // and beat right away so the host filters on the new list immediately.
371
+ if (patch && "mutedSessions" in patch) notifyMuteChange();
362
372
  return config;
363
373
  }
364
374
 
375
+ // ─────────────────── per-session mute (see #23) ──────────────────
376
+ // The list lives in the config JSON on purpose: the sidebar row button has
377
+ // to keep working after a reload, and the page already rewrites this object
378
+ // on every settings change.
379
+ var MUTED_MAX = 200;
380
+ var MUTED_ID_MAX = 200;
381
+ // The heartbeat body is capped at 16 KiB by the host, and the stored list
382
+ // can be longer than one beat may carry (200 ids of up to 200 chars is
383
+ // already ~40 KB worst case). Trim what goes on the wire by bytes, keeping
384
+ // the head of the list: a session past the cut still stops its own local
385
+ // alerts, it just is not covered by the host-side fallback.
386
+ var MUTED_BEAT_BUDGET = 8 * 1024;
387
+ function cleanMutedSessions(list) {
388
+ if (!Array.isArray(list)) return [];
389
+ var out = [];
390
+ var seen = {};
391
+ for (var i = 0; i < list.length && out.length < MUTED_MAX; i++) {
392
+ var raw = list[i];
393
+ if (typeof raw !== "string") continue;
394
+ var id = raw.trim();
395
+ if (id.length === 0 || id.length > MUTED_ID_MAX || seen[id] === true) continue;
396
+ seen[id] = true;
397
+ out.push(id);
398
+ }
399
+ return out;
400
+ }
401
+ function mutedSessions() {
402
+ return config && Array.isArray(config.mutedSessions) ? config.mutedSessions : [];
403
+ }
404
+ // Bytes, not code units: an id with non-ASCII characters costs more on the
405
+ // wire than its length suggests. Kept inline (no TextEncoder) so the smoke
406
+ // harness's plain `vm` sandbox can run it too.
407
+ function utf8Length(str) {
408
+ var n = 0;
409
+ for (var i = 0; i < str.length; i++) {
410
+ var c = str.charCodeAt(i);
411
+ if (c < 0x80) n += 1;
412
+ else if (c < 0x800) n += 2;
413
+ else if (c >= 0xd800 && c <= 0xdbff) { n += 4; i += 1; }
414
+ else n += 3;
415
+ }
416
+ return n;
417
+ }
418
+ // The subset of the list one heartbeat may carry, head first.
419
+ function mutedForBeat() {
420
+ var all = mutedSessions();
421
+ var out = [];
422
+ var used = 0;
423
+ for (var i = 0; i < all.length; i++) {
424
+ var cost = utf8Length(JSON.stringify(all[i])) + 1; // + the separating comma
425
+ if (used + cost > MUTED_BEAT_BUDGET) break;
426
+ used += cost;
427
+ out.push(all[i]);
428
+ }
429
+ return out;
430
+ }
431
+ function isSessionMuted(sid) {
432
+ if (typeof sid !== "string" || sid.length === 0) return false;
433
+ return mutedSessions().indexOf(sid) !== -1;
434
+ }
435
+ // One predicate for "this session alerts nothing": subagent children (a
436
+ // heuristic that follows the open session, see ignoreSubagent) plus the
437
+ // sessions the user muted by hand.
438
+ function alertMutedFor(sid, currentId) {
439
+ return isSubagentSession(sid, currentId) || isSessionMuted(sid);
440
+ }
441
+ function setSessionMuted(sid, muted) {
442
+ if (typeof sid !== "string" || sid.length === 0) return config;
443
+ var next = mutedSessions().filter(function (id) { return id !== sid; });
444
+ if (muted) next.push(sid);
445
+ setConfigLocal({ mutedSessions: next });
446
+ return config;
447
+ }
448
+ // Every row button and marker on screen subscribes: the host re-renders its
449
+ // list on its own schedule, so a component that only read the config at
450
+ // render time would keep showing a stale bell until something else moved.
451
+ var muteListeners = [];
452
+ function subscribeMuteChange(fn) {
453
+ muteListeners.push(fn);
454
+ return function () {
455
+ var i = muteListeners.indexOf(fn);
456
+ if (i !== -1) muteListeners.splice(i, 1);
457
+ };
458
+ }
459
+ function notifyMuteChange() {
460
+ for (var i = 0; i < muteListeners.length; i++) {
461
+ try { muteListeners[i](); } catch (e) { /* one broken row must not stop the rest */ }
462
+ }
463
+ // The host fallback filters on the list it last heard in a heartbeat, so
464
+ // beat right away instead of waiting for the next interval: muting and
465
+ // closing the tab must not leave a window where the host still alerts.
466
+ hostBridgeBeat();
467
+ }
468
+
365
469
  // Picked cue files live in their own localStorage keys, never inside the
366
470
  // config JSON: a data URL is ~1.37x the file size, and the config is parsed
367
471
  // on every readConfig() — which happens on every alert.
@@ -698,13 +802,15 @@
698
802
  return Promise.resolve(null);
699
803
  }
700
804
  }
701
- // Only the language travels. The host's fallback pushes exactly when this
702
- // page is not there, so the page's own forward switches never enter the
703
- // host's decision — and a field the host does not read is worse than no
704
- // field, because it reads like the toggles apply to the host too.
805
+ // Only the language and the muted-session list travel. The host's fallback
806
+ // pushes exactly when this page is not there, so the page's own forward
807
+ // switches never enter the host's decision — and a field the host does not
808
+ // read is worse than no field, because it reads like the toggles apply to
809
+ // the host too. The mute list is the exception because the host is the one
810
+ // that would otherwise speak for a silenced session.
705
811
  function hostBridgeBeat() {
706
812
  hostBridgeState.lastBeaconAt = Date.now();
707
- hostBridgePost({ alive: true, language: effectiveLang() }, false);
813
+ hostBridgePost({ alive: true, language: effectiveLang(), muted: mutedForBeat() }, false);
708
814
  }
709
815
  // One probe: ask the host whether it has a fallback, then start or stop the
710
816
  // lease to match. Every failure mode is silent — the reminder path must
@@ -2149,6 +2255,10 @@
2149
2255
  }
2150
2256
  function fire(kind, title, body, isCurrent, sessionId, quick) {
2151
2257
  if (!config.enabled) return false;
2258
+ // A session silenced from the sidebar row gets no toast, no sound and no
2259
+ // forwarded copy, whatever the other rules say. Queued wait copies are
2260
+ // filtered here too, because flushQuieted() calls back into this function.
2261
+ if (isSessionMuted(sessionId)) return false;
2152
2262
  if (kind === "attention" && config.attentionHiddenOnly && !away()) return false;
2153
2263
  // The wait belongs to the conversation the user is looking at right now:
2154
2264
  // the request is already on screen. The caller keeps the tab marker, and
@@ -2429,7 +2539,7 @@
2429
2539
  var pendingNow = row.pending || [];
2430
2540
  var prevPendingKeys = prev ? prev.pendingKeys : [];
2431
2541
  var wasRunning = prev ? prev.running : false;
2432
- var muted = isSubagentSession(row.id, row.currentId);
2542
+ var muted = alertMutedFor(row.id, row.currentId);
2433
2543
  var newKeys = [];
2434
2544
  // A muted row still feeds the baseline below, so lifting the mute
2435
2545
  // (turning the switch off, or opening that subagent session) resumes
@@ -2732,7 +2842,7 @@
2732
2842
  // announced before the mute was switched on (or before the user
2733
2843
  // switched away from that subagent session). Opening the session later
2734
2844
  // announces the outstanding wait then, like any first sighting.
2735
- if (isSubagentSession(sid, cur)) return;
2845
+ if (alertMutedFor(sid, cur)) return;
2736
2846
  seen[sid] = true;
2737
2847
  var key = it.key || (it.kind + ":" + sid);
2738
2848
  var prev = uiBaseline[sid];
@@ -2782,7 +2892,7 @@
2782
2892
  // as the edge path's !hasPendingNow guard. The on-screen session is
2783
2893
  // never "unread" (the host clears the flag for it; its completion is
2784
2894
  // the face edge's job), and a background subagent step is muted.
2785
- if (!value.completionUnread || value.pendingInteraction || isSubagentSession(sid, cur) || cur === sid) return;
2895
+ if (!value.completionUnread || value.pendingInteraction || alertMutedFor(sid, cur) || cur === sid) return;
2786
2896
  want[sid] = true;
2787
2897
  markDoneUnread(sid);
2788
2898
  if (uiDoneBaseline[sid]) return; // this unread instance already reported
@@ -2822,7 +2932,7 @@
2822
2932
  });
2823
2933
  } catch (e) {}
2824
2934
  // keep in sync with package.json "version" on every release
2825
- api.version = "1.15.0";
2935
+ api.version = "1.16.1";
2826
2936
  api.setConfig = function (patch) { return setConfigLocal(patch); };
2827
2937
  api.resetConfig = function () {
2828
2938
  try {
@@ -3148,6 +3258,14 @@
3148
3258
  permHint: "通知权限尚未授予:先在页面上点击一次并允许通知,系统通知才能弹出(提示音不受影响)。",
3149
3259
  offHint: "已关闭提醒:先打开「启用提醒」再测试。",
3150
3260
  storageFailed: "设置没能保存:浏览器拒绝了这次本地存储写入(空间不足或存储被禁用),改动只在当前页面有效,刷新即还原。",
3261
+ secMute: "会话静音",
3262
+ muteHint: "把鼠标移到侧边栏的会话上,点铃铛就只关掉这一条会话的提醒:被静音的会话在标题前显示划掉的铃铛,正在运行的会话那里被状态点占着,此时看行尾铃铛的按下状态;其它会话照旧提醒。",
3263
+ muteNone: "还没有静音的会话。",
3264
+ muteMuted: "已静音会话数:",
3265
+ muteClear: "全部取消静音",
3266
+ muteSession: "静音此会话的提醒",
3267
+ unmuteSession: "取消静音,恢复此会话的提醒",
3268
+ muteMark: "此会话已静音",
3151
3269
  versionLine: "插件版本:dsh-notify-me v"
3152
3270
  };
3153
3271
  var UI_en = {
@@ -3315,6 +3433,14 @@
3315
3433
  permHint: "Notification permission is not granted yet — click once on the page and allow notifications so toasts can appear (sound is unaffected).",
3316
3434
  offHint: "Reminders are off: enable them first, then test.",
3317
3435
  storageFailed: "Settings were not saved: the browser refused this local-storage write (quota or storage disabled), so the change lasts only for this page and is gone on reload.",
3436
+ secMute: "Muted sessions",
3437
+ muteHint: "Hover a session in the sidebar and click the bell to silence just that conversation: a muted session shows a crossed bell before its title — while a session is running that spot holds the status dots, so the hover bell (pressed, struck through) is where the state shows then; other sessions keep alerting.",
3438
+ muteNone: "No session is muted.",
3439
+ muteMuted: "Muted sessions: ",
3440
+ muteClear: "Unmute all",
3441
+ muteSession: "Mute alerts for this session",
3442
+ unmuteSession: "Unmute: resume alerts for this session",
3443
+ muteMark: "Alerts muted for this session",
3318
3444
  versionLine: "Plugin version: dsh-notify-me v"
3319
3445
  };
3320
3446
  // ─────────────────── sidebar row glyph ───────────────────────────
@@ -3475,7 +3601,15 @@
3475
3601
  ".dnm-srOnly{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}" +
3476
3602
  ".dnm-tip{position:fixed;left:-9999px;top:-9999px;z-index:2147483001;max-width:270px;box-sizing:border-box;padding:7px 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.35));background:var(--dsw-alias-bg-layer-3,#26282c);color:var(--dsw-alias-label-secondary,rgba(90,90,90,.9));font-size:12px;line-height:17px;box-shadow:0 6px 18px rgba(0,0,0,.35);pointer-events:none;opacity:0;transition:opacity .12s ease}" +
3477
3603
  ".dnm-tip.on{opacity:1}" +
3478
- ".dnm-advChev.open{transform:rotate(180deg)}";
3604
+ ".dnm-advChev.open{transform:rotate(180deg)}" +
3605
+ // Sidebar-row mute affordances (issue #23): a hover button in the row's
3606
+ // action slot and a marker in its leading slot. They live in the host's
3607
+ // own row layout, so everything is sized in em-free pixels and coloured
3608
+ // through the alias tokens to survive light and dark themes.
3609
+ ".dnm-rowIcon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:0;border-radius:4px;background:none;color:var(--dsw-alias-label-tertiary,rgba(120,120,120,.9));cursor:pointer;line-height:0}" +
3610
+ ".dnm-rowIcon:hover{color:var(--dsw-alias-label-primary,rgba(20,20,20,.9));background:var(--dsw-alias-bg-layer-2,rgba(128,128,128,.14))}" +
3611
+ ".dnm-rowIcon.on{color:var(--dsw-alias-label-secondary,rgba(90,90,90,.9))}" +
3612
+ ".dnm-rowMark{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none;line-height:0;color:var(--dsw-alias-label-tertiary,rgba(120,120,120,.9))}";
3479
3613
  (function injectStyle() {
3480
3614
  try {
3481
3615
  if (typeof document === "undefined" || typeof document.createElement !== "function") return;
@@ -3647,6 +3781,83 @@
3647
3781
  return h("div", { className: "dnm-card" }, children);
3648
3782
  }
3649
3783
 
3784
+ // ──────────────── per-session mute: sidebar row UI ─────────────────
3785
+ // The host ships no "silence this row" API, so the switch rides the row's
3786
+ // own action slot (visible on hover) and leaves a mark in its leading slot
3787
+ // while the session is muted — the two slots the schedule plugin already
3788
+ // injects into, i.e. the cheapest stable place to hang this off (issue #23).
3789
+ function sessionMuteIcon(kind) {
3790
+ var base = {
3791
+ viewBox: "0 0 16 16",
3792
+ width: "14",
3793
+ height: "14",
3794
+ fill: "none",
3795
+ stroke: "currentColor",
3796
+ strokeWidth: "1.4",
3797
+ strokeLinecap: "round",
3798
+ strokeLinejoin: "round",
3799
+ focusable: "false",
3800
+ "aria-hidden": "true"
3801
+ };
3802
+ if (kind === "off") {
3803
+ // A bell with a slash: "silenced".
3804
+ return h("svg", base, [
3805
+ h("path", { d: "M5.9 3.4a4.7 4.7 0 0 1 6.8 4.1v2.2l1.1 1.9H4.6" }),
3806
+ h("path", { d: "M6.7 13.3a1.5 1.5 0 0 0 2.6 0" }),
3807
+ h("path", { d: "M2.3 2.3l11.4 11.4" })
3808
+ ]);
3809
+ }
3810
+ return h("svg", base, [
3811
+ h("path", { d: "M3.3 11.2V6.9a4.7 4.7 0 0 1 9.4 0v4.3l1.1 1.9H2.2l1.1-1.9Z" }),
3812
+ h("path", { d: "M6.7 13.3a1.5 1.5 0 0 0 2.6 0" })
3813
+ ]);
3814
+ }
3815
+ // Both slots re-render themselves: the host repaints a row only when its own
3816
+ // state moves, so a bell that read the config once at mount would keep
3817
+ // showing the old state after the settings page or a sibling row changed it.
3818
+ function useSessionMuted(sessionId) {
3819
+ var bumpState = React.useState(0);
3820
+ var bump = bumpState[1];
3821
+ React.useEffect(function () {
3822
+ return subscribeMuteChange(function () { bump(function (n) { return n + 1; }); });
3823
+ }, []);
3824
+ return isSessionMuted(sessionId);
3825
+ }
3826
+ function SessionMuteButton(props) {
3827
+ var sid = typeof props.sessionId === "string" ? props.sessionId : "";
3828
+ var muted = useSessionMuted(sid);
3829
+ var labelText = muted ? props.t("unmuteSession") : props.t("muteSession");
3830
+ return h("button", {
3831
+ type: "button",
3832
+ className: "dnm-rowIcon" + (muted ? " on" : ""),
3833
+ title: labelText,
3834
+ "aria-label": labelText,
3835
+ "aria-pressed": muted ? "true" : "false",
3836
+ "data-dnm-mute": sid,
3837
+ onClick: function (e) {
3838
+ // The row opens the session on click and its action cell stops
3839
+ // propagation; stop here too so a host change cannot turn the bell
3840
+ // into "open this session".
3841
+ e.preventDefault();
3842
+ e.stopPropagation();
3843
+ if (!sid) return;
3844
+ setSessionMuted(sid, !isSessionMuted(sid));
3845
+ }
3846
+ }, sessionMuteIcon(muted ? "off" : "on"));
3847
+ }
3848
+ function SessionMuteMark(props) {
3849
+ var sid = typeof props.sessionId === "string" ? props.sessionId : "";
3850
+ var muted = useSessionMuted(sid);
3851
+ if (!muted) return null;
3852
+ return h("span", {
3853
+ className: "dnm-rowMark",
3854
+ role: "img",
3855
+ title: props.t("muteMark"),
3856
+ "aria-label": props.t("muteMark"),
3857
+ "data-dnm-mute-mark": sid
3858
+ }, sessionMuteIcon("off"));
3859
+ }
3860
+
3650
3861
  function NotifySettingsView(props) {
3651
3862
  var ctx = props.ctx;
3652
3863
  var t = props.t;
@@ -4091,6 +4302,11 @@
4091
4302
  var advState = React.useState(false);
4092
4303
  var advancedOpen = advState[0];
4093
4304
  var setAdvancedOpen = advState[1];
4305
+ // Rows mute sessions from the sidebar while this page is open; subscribe so
4306
+ // the muted-sessions card stays truthful without closing Settings.
4307
+ React.useEffect(function () {
4308
+ return subscribeMuteChange(function () { setCfg(readConfig()); });
4309
+ }, []);
4094
4310
  // Dependent controls (volume) stay folded away until the row they belong
4095
4311
  // to is clicked open.
4096
4312
  var subStateHook = React.useState({});
@@ -4205,6 +4421,29 @@
4205
4421
  rowSwitch("subagentQuiet", t("subagentQuiet"), t("subagentQuietHint"), cfg.ignoreSubagent, function (v) { patch({ ignoreSubagent: v }); }),
4206
4422
  rowSwitch("autoFocus", t("autoFocus"), t("autoFocusHint"), cfg.autoFocus, function (v) { patch({ autoFocus: v }); })
4207
4423
  ]),
4424
+ // 2b) Sessions silenced by hand from the sidebar row. The switch lives on
4425
+ // the row itself (hover bell) and as a mark before its title; this card
4426
+ // is where the list is visible and can be cleared in one click.
4427
+ secTitle(t("secMute")),
4428
+ card([
4429
+ cfg.mutedSessions.length === 0
4430
+ ? h("div", { className: "dnm-row" }, [
4431
+ h("div", { className: "dnm-rowText" }, [h("div", { className: "dnm-hint" }, t("muteNone"))])
4432
+ ])
4433
+ : h("div", { className: "dnm-row" }, [
4434
+ h("div", { className: "dnm-rowText" }, [
4435
+ h("div", { className: "dnm-rowLabel" }, t("muteMuted") + String(cfg.mutedSessions.length))
4436
+ ]),
4437
+ h("button", {
4438
+ type: "button",
4439
+ className: "dnm-btn",
4440
+ onClick: function () { patch({ mutedSessions: [] }); }
4441
+ }, t("muteClear"))
4442
+ ]),
4443
+ h("div", { className: "dnm-row" }, [
4444
+ h("div", { className: "dnm-rowText" }, [h("div", { className: "dnm-hint" }, t("muteHint"))])
4445
+ ])
4446
+ ]),
4208
4447
  // 3) Prove the setup works without leaving the page.
4209
4448
  secTitle(t("secTest")),
4210
4449
  card([
@@ -4406,6 +4645,41 @@
4406
4645
  ctx.effect(function () {
4407
4646
  return installNavBell(function () { return t("nav"); });
4408
4647
  }, "dsh-notify-me: sidebar glyph");
4648
+ // Per-session mute (issue #23): a bell in the row's hover actions and a
4649
+ // crossed bell before the title while the session is muted. Both are
4650
+ // host-declared list slots, so a host that does not have them simply
4651
+ // never calls these factories; each is attempted on its own so a host
4652
+ // with only one of the two still gets that one.
4653
+ try {
4654
+ ctx.slots.inject("sidebar.workspaces.session.row.action", function () {
4655
+ return ctx.slots.register({
4656
+ name: "sidebar.workspaces.session.row.action",
4657
+ id: "dsh-notify-me-mute",
4658
+ order: 20,
4659
+ locale: NS,
4660
+ inject: function () { return { t: t }; }
4661
+ }, function (ownerProps) {
4662
+ return React.createElement(SessionMuteButton, { sessionId: ownerProps.sessionId, t: t });
4663
+ });
4664
+ });
4665
+ } catch (e) {
4666
+ try { console.warn("[dsh-notify-me] row action slot unavailable", e); } catch (e2) {}
4667
+ }
4668
+ try {
4669
+ ctx.slots.inject("sidebar.session.row.leading", function () {
4670
+ return ctx.slots.register({
4671
+ name: "sidebar.session.row.leading",
4672
+ id: "dsh-notify-me-mute-mark",
4673
+ order: 20,
4674
+ locale: NS,
4675
+ inject: function () { return { t: t }; }
4676
+ }, function (ownerProps) {
4677
+ return React.createElement(SessionMuteMark, { sessionId: ownerProps.sessionId, t: t });
4678
+ });
4679
+ });
4680
+ } catch (e) {
4681
+ try { console.warn("[dsh-notify-me] row leading slot unavailable", e); } catch (e2) {}
4682
+ }
4409
4683
  }
4410
4684
  } catch (e) {
4411
4685
  try { console.error("[dsh-notify-me] settings page unavailable", e); } catch (e2) {}
@@ -167,12 +167,18 @@ export function mountHostFallback(ctx, config, shared) {
167
167
  if (session?.header?.origin === "subagent" && !includeSubagents) return;
168
168
  const key = keyOf(session);
169
169
  const type = event?.type;
170
+ // A session muted from the sidebar stays silent here too: the switch has to
171
+ // survive the tab closing, otherwise the fallback fires exactly the alert
172
+ // the user asked not to get. Titles are still remembered below, so lifting
173
+ // the mute does not leave the session nameless.
174
+ const quiet = presence.isMuted(key);
170
175
 
171
176
  if (type === "session/title") {
172
177
  const title = typeof event.data?.title === "string" ? event.data.title : "";
173
178
  if (title.length > 0) remember(titles, key, title);
174
179
  return;
175
180
  }
181
+ if (quiet) return;
176
182
  if (type === "approval/asked") {
177
183
  if (!events.has("approval/asked")) return;
178
184
  // An open page raised its own approval alert; pushing here would be the
@@ -69,6 +69,36 @@ const DEFAULT_PAGE_LEASE_MS = 60000;
69
69
  /** Languages the host alerts exist in; anything else falls back to `zh`. */
70
70
  const LANGUAGES = ["zh", "en"];
71
71
 
72
+ /**
73
+ * Upper bound on the muted-session list one heartbeat may carry. The page trims
74
+ * what it sends by bytes as well (its own budget), so this is only the sanity
75
+ * cap for a hand-edited config; keep it low enough that a full list still fits
76
+ * under the 16 KiB body limit with room to spare.
77
+ */
78
+ const MUTED_MAX = 200;
79
+ /** Longest session id kept from a heartbeat; host ids are short strings. */
80
+ const MUTED_ID_MAX = 200;
81
+
82
+ /**
83
+ * @param value - the untrusted `muted` field of a heartbeat.
84
+ * @returns a deduplicated list of plausible session ids; never throws, and
85
+ * silently drops anything that is not a short string, because the list only
86
+ * ever comes from our own page.
87
+ */
88
+ function normalizeMuted(value) {
89
+ const out = [];
90
+ const seen = new Set();
91
+ for (const raw of value) {
92
+ if (typeof raw !== "string") continue;
93
+ const id = raw.trim();
94
+ if (id.length === 0 || id.length > MUTED_ID_MAX || seen.has(id)) continue;
95
+ seen.add(id);
96
+ out.push(id);
97
+ if (out.length >= MUTED_MAX) break;
98
+ }
99
+ return out;
100
+ }
101
+
72
102
  /**
73
103
  * @param hostname - bare hostname.
74
104
  * @returns the comparable lowercase form, without IPv6 brackets.
@@ -532,7 +562,9 @@ export async function deliverNote(delivery, note) {
532
562
  * because the page said so on `pagehide`.
533
563
  *
534
564
  * The same heartbeat carries the page's language, so the host's wording follows
535
- * what the user is reading instead of a second, drifting config copy. It does
565
+ * what the user is reading instead of a second, drifting config copy, and the
566
+ * list of sessions the user muted, so the fallback stays quiet for them too
567
+ * (only the page ever writes that list; the host merely repeats it). It does
536
568
  * not carry the page's external-push switches: the rule is simply "the host
537
569
  * takes over while no page is open", and a page's visibility and idle
538
570
  * heuristics are invisible to the host, so honouring half of them would produce
@@ -551,21 +583,25 @@ export function createPresence(options = {}) {
551
583
  let released = true;
552
584
  /** Last language the page reported; `null` until it reports one. */
553
585
  let language = null;
586
+ /** Session ids the page muted; the fallback alerts skip them. */
587
+ let muted = [];
554
588
 
555
589
  const leaseUntil = () => (lastBeatAt === 0 || leaseMs <= 0 ? 0 : lastBeatAt + leaseMs);
556
590
 
557
591
  return {
558
592
  /**
559
593
  * Record one heartbeat.
560
- * @param beat - `{ alive, language }`, both optional; an omitted field keeps
561
- * its previous value so a short heartbeat cannot erase what a full one
562
- * reported, and any other key is ignored rather than trusted.
594
+ * @param beat - `{ alive, language, muted }`, all optional; an omitted field
595
+ * keeps its previous value so a short heartbeat cannot erase what a full
596
+ * one reported, and any other key is ignored rather than trusted. `muted`
597
+ * replaces the whole list when present: the page always sends it whole.
563
598
  * @returns the instant the lease now runs to (`0` when disabled).
564
599
  */
565
600
  touch(beat = {}) {
566
601
  lastBeatAt = Date.now();
567
602
  released = beat.alive === false;
568
603
  if (LANGUAGES.includes(beat.language)) language = beat.language;
604
+ if (Array.isArray(beat.muted)) muted = normalizeMuted(beat.muted);
569
605
  return leaseUntil();
570
606
  },
571
607
  /**
@@ -586,10 +622,18 @@ export function createPresence(options = {}) {
586
622
  if (lastBeatAt === 0 || released) return false;
587
623
  return now - lastBeatAt < leaseMs;
588
624
  },
625
+ /**
626
+ * @param id - session id.
627
+ * @returns whether the page reported this session as muted.
628
+ */
629
+ isMuted(id) {
630
+ return muted.includes(id);
631
+ },
589
632
  /**
590
633
  * @param now - clock to compare against, injectable for tests.
591
- * @returns `{ alive, ageMs, leaseUntil, language }`; `ageMs` is `null` when
592
- * no page ever checked in.
634
+ * @returns `{ alive, ageMs, leaseUntil, language, muted }`; `ageMs` is
635
+ * `null` when no page ever checked in, and `muted` is a copy so a caller
636
+ * cannot mutate the stored list.
593
637
  */
594
638
  snapshot(now = Date.now()) {
595
639
  return {
@@ -597,6 +641,7 @@ export function createPresence(options = {}) {
597
641
  ageMs: lastBeatAt === 0 ? null : Math.max(0, now - lastBeatAt),
598
642
  leaseUntil: leaseUntil(),
599
643
  language,
644
+ muted: [...muted],
600
645
  };
601
646
  },
602
647
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-notify-me",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
4
4
  "description": "离开 DSH 页面也能收到提醒:需要你操作 / 后台回复完成时发系统通知、标题标记与提示音,支持审批快捷裁决与外部推送,Web 版与桌面版均可用。",
5
5
  "license": "MIT",
6
6
  "type": "module",