dsh-notify-me 1.4.0 → 1.5.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/CHANGELOG.md +16 -0
- package/README.en.md +4 -4
- package/README.md +4 -4
- package/lib/client.js +140 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **dsh-notify-me** are documented here.
|
|
4
4
|
|
|
5
|
+
## [1.5.0] — 2026-10-03
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
- **「完成未读」标题标记**:后台会话的回复跑完、你还没打开看的期间,标签页标题前出现 `✅ 回复完成 · …` / `✅ Reply finished · …`,打开该会话(宿主此时清掉未读)或它再次开跑即消失——离开屏幕再回来,一眼看到哪些跑完了。与「需要你」标记可同时出现(「需要你」在前),宿主改写标题后标记基于新标题重建。未读事实取自宿主:`≥ 0.1.6` 用 `sessionStatus` 行的 `completionUnread`(后台会话完成即点亮,打开 / 再次开跑 / 会话消失即清零),旧宿主用列表行的 `completed` 提醒位(选中会话即清零)。静音中的后台子代理会话照旧不标记;「页面打开时也提醒『回复完成』」开关只管通知,不影响标记。
|
|
9
|
+
- **「回复完成」通道接上宿主的完成未读标志**:此前只靠 `running` 快照边沿,页面没看见的完成(插件热重载中途、快照把 true→false 合并成一跳、完成发生在绑定之前)就永远漏掉。现在 `sessionStatus` 的 `completionUnread` 级别标志(0.1.6+)负责补漏——每条未读实例只报一次,绑定时已存在的未读也补报一声;边沿与级别标志是同一次完成的两个视角、同刻到达时按短时间窗合并成一声。边沿路径保持不变:当前会话的正文仍带回复摘要,旧宿主照旧。
|
|
10
|
+
- 「等你操作」不算完成:一轮带着 plan-review / 提问结束时只走「需要你」提醒,答完也不补「回复完成」马后炮;宿主仍标未读时,标题标记照常挂到你打开会话为止。后台子代理会话的未读照旧静音,解除静音后补报一次。
|
|
11
|
+
- `window.__dshNotifyMe.debug()` 新增 `doneUnreadMarked`(当前挂着「完成未读」标记的会话列表)。
|
|
12
|
+
|
|
13
|
+
### 变更
|
|
14
|
+
- 版本号 1.4.0 → 1.5.0;`window.__dshNotifyMe.version` 同步。
|
|
15
|
+
- README(中英)同步:「提醒时机」表、「提醒方式」的标题标记说明、「工作原理」的完成未读级别标志两代取源与合并口径。
|
|
16
|
+
|
|
17
|
+
### 测试
|
|
18
|
+
- `smoke/smoke-test.cjs` 新增 completionUnread 用例段:漏报补发、同刻双视角只响一声、绑定前已有的未读只报一次、等输入的停顿不算完成(答完不补马后炮、标记照旧)、当前会话不走未读通道、后台子代理静音与解除静音、页面可见时只留标记不弹通知、双标记叠加与宿主改标题后的重建;legacy 用例补 `completed` 提醒位的标记出现与「选中会话即撤」。
|
|
19
|
+
- `smoke/cordis-host-test.mjs` 在真 cordis `sessionStatus` 宿主上补一条走真 store 的完成未读用例:报告一次、标记、不重复、打开即撤。
|
|
20
|
+
|
|
5
21
|
## [1.4.0] — 2026-10-03
|
|
6
22
|
|
|
7
23
|
### 新增
|
package/README.en.md
CHANGED
|
@@ -43,7 +43,7 @@ dsh-notify-me decouples **supervision** from **sitting in front of the screen**:
|
|
|
43
43
|
| When | What you get | Default |
|
|
44
44
|
| --- | --- | --- |
|
|
45
45
|
| 🔔 **The agent needs your input** — sandbox approval / plan review / a question (`ask_user_question`) | Toast + sound + `🔔 Action needed ·` title marker; approval toasts also carry Approve / Reject buttons | Alerts even while the page is visible (the conversation on screen is the exception: tab marker only by default) |
|
|
46
|
-
| ✅ **A reply finishes** — a turn completes; background sessions finishing are also reported | Toast + sound | Alerts only while the page is hidden / backgrounded |
|
|
46
|
+
| ✅ **A reply finishes** — a turn completes; background sessions finishing are also reported | Toast + sound; while a background session is **finished but unread** the tab title carries a `✅ Reply finished ·` marker, gone once you open that session | Alerts only while the page is hidden / backgrounded (the title marker is not gated by this) |
|
|
47
47
|
|
|
48
48
|
> **Background** subagent child sessions are **not** alerted about by default: DSH lists each of them as its own session, but they are steps inside the parent conversation's turn, so an alert for them is only noise. The subagent session you have open is not part of this and alerts as usual. Settings → "Ignore subagent sessions" turns the mute off.
|
|
49
49
|
|
|
@@ -67,7 +67,7 @@ Open **Settings → Notify me** (refresh the page once after installing):
|
|
|
67
67
|
|
|
68
68
|
- **System notification** — a toast through the browser into the Windows action center / macOS Notification Center (clicking it opens the conversation it came from; approval toasts can be decided straight from the buttons)
|
|
69
69
|
- **Sound** — WebAudio beeps (distinct patterns for "needs you" vs "done")
|
|
70
|
-
- **Tab title marker** — while something is waiting on you, the tab title is prefixed with `🔔 Action needed · …` / `🔔 需要你 · …`
|
|
70
|
+
- **Tab title marker** — while something is waiting on you, the tab title is prefixed with `🔔 Action needed · …` / `🔔 需要你 · …`; while a background session is **finished but unread**, with `✅ Reply finished · …` / `✅ 回复完成 · …`, gone once you open that session (or it starts running again). Both kinds can be up together, "needs you" first; a host title change is rebased under the markers
|
|
71
71
|
|
|
72
72
|
This is a **browser-layer** plugin: the DSH page must stay open (minimized or backgrounded is fine — that's exactly the "away" state it watches for).
|
|
73
73
|
|
|
@@ -88,7 +88,7 @@ Restart `dsh web`, then hard-refresh the page (Ctrl+Shift+R).
|
|
|
88
88
|
| `0.1.2-alpha.2 .. 0.1.6-alpha.1` | `uiSession.pendingInteractions` | snapshot `current` | `sessions.open()` |
|
|
89
89
|
| `>= 0.1.6-alpha.2` (incl. `0.2.0-rc.2`) | `uiSession.sessionStatus` | `retainedBy.mainView` | `uiWorkspace.openSession()` |
|
|
90
90
|
|
|
91
|
-
The ranges are illustrative: the plugin picks its source by store shape (whenever `sessionStatus` exists it takes the new path); the version numbers only mark where each shape appeared.
|
|
91
|
+
The ranges are illustrative: the plugin picks its source by store shape (whenever `sessionStatus` exists it takes the new path); the version numbers only mark where each shape appeared. The `peerDependencies` range in `package.json` likewise only shapes npm's install warning — compatibility is declared per release in `dshReleases` after real testing, and untested new versions fall back to shape-driven behaviour.
|
|
92
92
|
|
|
93
93
|
Verified to actually activate on `0.1.2-rc.1`, `0.1.5-rc.2` and `0.2.0-rc.2` (each booted in its own profile: the Settings → Notifications section registers, i.e. the plugin's `apply` really runs), and previously on `0.1.1-rc.2`. Two traps are worth remembering: a package listed in `dsh.client.inject` that a newer runtime no longer ships parks the client entry at `pending (waiting for services: …)` forever — which is what broke 1.1.3 on `0.1.2-rc.1` and later; and when the host renames a store or a field nothing throws, alerts just go **silent** — `0.2.0-rc.2` moved `pendingInteractions`→`sessionStatus`, `list.current`→`retainedBy.mainView` and `sessions.open()`→`uiWorkspace.openSession()`. So every adaptation must confirm `window.__dshNotifyMe.debug()` reports `bound` and which source answered.
|
|
94
94
|
|
|
@@ -136,7 +136,7 @@ The reminder core picks its interaction source per host generation (see the tabl
|
|
|
136
136
|
|
|
137
137
|
- the **selected session's** `SessionSnapshot`: a `running: true → false` edge means a reply finished;
|
|
138
138
|
- **pending interactions**: a new key in `uiSession.sessionStatus` (`>= 0.1.6`, per-session `pendingInteraction`) or in `pendingInteractions` (`0.1.2 .. 0.1.5`) means the agent is waiting on you — approval requests carry the tool name and reason, questions their text; older hosts fall back to the controller snapshot's `pending[]`;
|
|
139
|
-
- **every other listed session's** summary: a `running: true → false` edge (or the legacy `completed` flag) alerts you about background work
|
|
139
|
+
- **every other listed session's** summary: a `running: true → false` edge (or the legacy `completed` flag) alerts you about background work. The host's completion-unread level flag backs that edge up and owns the title marker: `sessionStatus` rows' `completionUnread` on `>= 0.1.6` (lit when a background session finishes, cleared when it is opened / re-runs / disappears), the list row's `completed` reminder bit on older hosts (cleared on select). It re-reports a completion whose edge this page never saw (a plugin remount mid-turn, coalesced snapshots) exactly once, and when both views of one completion arrive together a short window collapses them into a single alert.
|
|
140
140
|
- **subagent sessions**: **background** rows carrying `origin: 'subagent'` (and a `parentId`) stay muted by default. The subagent session you have open is exempt — its alerts follow the normal current-conversation rules (tab marker only while the page is visible, delivered on background), its outstanding waits are picked up when you switch into it, and switching away mutes them again. A fork has a `parentId` but no `origin`, is your own conversation, and keeps alerting throughout.
|
|
141
141
|
|
|
142
142
|
The reminder core stays dependency-free and self-contained: notification copy resolves at alert time from the chosen language (follow-interface / Simplified Chinese / English). The Settings page is an **optional** React surface — it only registers into Settings when the web profile provides the `slots` / `locale` services and `react`; without them the plugin degrades gracefully to alerts-only (no Settings page).
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ dsh-notify-me 把「监督」和「守在屏幕前」解耦:只在真的出现
|
|
|
43
43
|
| 时机 | 提醒内容 | 默认 |
|
|
44
44
|
| --- | --- | --- |
|
|
45
45
|
| 🔔 **模型需要你操作** — 审批请求 / 方案待确认(plan review)/ 提问(`ask_user_question`) | 通知 + 提示音 + `🔔 需要你 ·` 标题标记;审批的通知上直接带「同意 / 拒绝」按钮 | 页面可见也提醒(当前对话除外:默认只留标题标记) |
|
|
46
|
-
| ✅ **回复完成** — 一轮回复跑完;后台会话完成也会报 | 通知 +
|
|
46
|
+
| ✅ **回复完成** — 一轮回复跑完;后台会话完成也会报 | 通知 + 提示音;后台会话**完成但还没看**的期间标题带 `✅ 回复完成 ·` 标记,打开该会话即撤 | 仅页面隐藏/后台时提醒(标题标记不受此限) |
|
|
47
47
|
|
|
48
48
|
> **后台**子代理(subagent)子会话的等待与完成默认**不提醒**:DSH 把每个子代理子会话列成独立会话,但它们是所属主对话那一轮里的步骤,提醒只会是噪音。你当前打开的那个子代理会话不算在内,照常提醒。设置页「子代理会话不提醒」可关掉这个静音。
|
|
49
49
|
|
|
@@ -67,7 +67,7 @@ dsh-notify-me 把「监督」和「守在屏幕前」解耦:只在真的出现
|
|
|
67
67
|
|
|
68
68
|
- **系统通知**:经浏览器弹出的系统通知,进 Windows 通知中心或 macOS 通知中心(点击回到提醒所属的对话;审批的通知点按钮直接裁决)
|
|
69
69
|
- **提示音**:WebAudio 合成音(「需要你」与「完成」使用不同音型)
|
|
70
|
-
- **标签页标题标记**:有待处理事项时,标题前出现 `🔔 需要你 · …` / `🔔 Action needed · …`
|
|
70
|
+
- **标签页标题标记**:有待处理事项时,标题前出现 `🔔 需要你 · …` / `🔔 Action needed · …`;后台会话**完成但还没看**时出现 `✅ 回复完成 · …` / `✅ Reply finished · …`,打开对应会话(或它再次开跑)即消失。两种标记可同时出现,「需要你」在前;宿主改写标题后标记基于新标题重建
|
|
71
71
|
|
|
72
72
|
本插件是**浏览器层**实现:DSH 页面需保持打开(最小化/后台即可——那正是它监听的「离开」状态)。
|
|
73
73
|
|
|
@@ -88,7 +88,7 @@ dsh plugin --profile web add dsh-notify-me
|
|
|
88
88
|
| `0.1.2-alpha.2 .. 0.1.6-alpha.1` | `uiSession.pendingInteractions` | 快照 `current` | `sessions.open()` |
|
|
89
89
|
| `≥ 0.1.6-alpha.2`(含 `0.2.0-rc.2`) | `uiSession.sessionStatus` | `retainedBy.mainView` | `uiWorkspace.openSession()` |
|
|
90
90
|
|
|
91
|
-
区间仅作示意:插件按 store 形状自动选源(`sessionStatus`
|
|
91
|
+
区间仅作示意:插件按 store 形状自动选源(`sessionStatus` 存在即走新路),版本号只是各形状的出现边界。`package.json` 的 `peerDependencies` 范围同理只影响 npm install 的提示文案——兼容与否以 `dshReleases` 的逐版实测声明为准,未实测的新版本由形状驱动兜底。
|
|
92
92
|
|
|
93
93
|
实测**真正激活**(各自独立 profile 启动:设置里出现「通知提醒」分区,即插件的 `apply` 确实执行)于 `0.1.2-rc.1`、`0.1.5-rc.2` 与 `0.2.0-rc.2`;更早的 `0.1.1-rc.2` 亦验证过。两个坑值得记住:一是 `dsh.client.inject` 里列了新版运行时已不再提供的包,客户端条目会停在 `pending (waiting for services: …)` 而永不执行——1.1.3 在 `0.1.2-rc.1` 及以后正是这样失效的;二是宿主换存储/字段名时**不会报错**,提醒只会静默失效——`0.2.0-rc.2` 上 `pendingInteractions`→`sessionStatus`、`list.current`→`retainedBy.mainView`、`sessions.open()`→`uiWorkspace.openSession()` 都是这一类,所以每次适配都要用 `window.__dshNotifyMe.debug()` 确认真的是 `bound`、以及用的是哪个来源。
|
|
94
94
|
|
|
@@ -132,7 +132,7 @@ window.__dshNotifyMe.decide("approval:3", "allowed-once") // 程序化裁决:
|
|
|
132
132
|
|
|
133
133
|
- **当前会话** `SessionSnapshot`:`running` true→false = 回复完成;
|
|
134
134
|
- **待办交互**:`uiSession` 的 `sessionStatus`(`≥ 0.1.6`,逐会话 `pendingInteraction`)或 `pendingInteractions`(`0.1.2 .. 0.1.5`)出现新 key = 模型在等你,容器里带上审批工具名 / 理由、提问文本;旧宿主回落到控制器快照的 `pending[]`;
|
|
135
|
-
- **其它已列会话**摘要:`running` true→false(或旧宿主的 `completed` 边沿)=
|
|
135
|
+
- **其它已列会话**摘要:`running` true→false(或旧宿主的 `completed` 边沿)= 后台工作提醒。宿主的「完成未读」级别标志负责补漏与标题标记:`≥ 0.1.6` 用 `sessionStatus` 行的 `completionUnread`(后台会话完成即点亮、打开该会话/再次开跑/会话消失即清零),旧宿主用列表行的 `completed` 提醒位(选中会话即清零);页面没看见的完成边沿(插件热重载中途、快照合并跳变)由此补报一次,边沿与级别标志同来时按短时间窗合并,只响一声。
|
|
136
136
|
- **子代理会话**:列表行带 `origin: 'subagent'`(并有 `parentId`)的**后台**会话默认静音;你正打开着的那个子代理会话不算静音对象,它的提醒走当前对话的常规规则(页面可见时默认只留标题标记、转后台补发),切进来时积压的等待同样补上,切走后重新静音。只有 `parentId`、没有 `origin` 的分支(fork)会话属于你自己的对话,始终照常提醒。
|
|
137
137
|
|
|
138
138
|
提醒核心仍然零第三方运行时依赖、完全自包含:通知文字按所选语言(跟随界面 / 中文 / English)即时解析。设置页是**可选**的 React 呈现层——当 DSH web profile 提供 `slots` / `locale` / `react` 时才注册进「设置 → 通知提醒」,缺任一能力时插件自动降级为纯提醒(无设置页),不影响功能。
|
package/lib/client.js
CHANGED
|
@@ -28,6 +28,13 @@
|
|
|
28
28
|
// * "sessions" -> the selected session's ConversationSnapshot (running)
|
|
29
29
|
// and the session-list summaries of every other session (running /
|
|
30
30
|
// completed), which carry the "reply finished" edge on every version.
|
|
31
|
+
// The host's completion-unread level flag backs that edge up and owns
|
|
32
|
+
// the "完成未读" title marker: `sessionStatus.completionUnread` on
|
|
33
|
+
// 0.1.6+ (armed when a background session finishes, cleared when it is
|
|
34
|
+
// opened / re-runs / disappears), the list row's `completed` reminder
|
|
35
|
+
// bit on older hosts. The edge path stays the reporter for the on-screen
|
|
36
|
+
// session (its snippet comes from the face snapshot); the two views of
|
|
37
|
+
// one completion are collapsed by reportDone's short dedupe window.
|
|
31
38
|
// The selected ("current") session is read from the list snapshot's
|
|
32
39
|
// `current` field where it exists (<= 0.1.5-rc.3) and otherwise derived
|
|
33
40
|
// from the mainView retention count (0.1.6+, the way the shipped
|
|
@@ -203,6 +210,7 @@
|
|
|
203
210
|
doneBody: "回复已完成",
|
|
204
211
|
background: "后台会话",
|
|
205
212
|
marker: "🔔 需要你 · ",
|
|
213
|
+
doneMarker: "✅ 回复完成 · ",
|
|
206
214
|
sep: ":",
|
|
207
215
|
approve: "同意",
|
|
208
216
|
reject: "拒绝",
|
|
@@ -226,6 +234,7 @@
|
|
|
226
234
|
doneBody: "Reply finished",
|
|
227
235
|
background: "Background session",
|
|
228
236
|
marker: "🔔 Action needed · ",
|
|
237
|
+
doneMarker: "✅ Reply finished · ",
|
|
229
238
|
sep: ": ",
|
|
230
239
|
approve: "Approve",
|
|
231
240
|
reject: "Reject",
|
|
@@ -599,16 +608,25 @@
|
|
|
599
608
|
// title over (or an earlier load leaving a marker behind) can never make us
|
|
600
609
|
// mistake our own marker for the base title.
|
|
601
610
|
var attentionActive = 0;
|
|
611
|
+
var doneActive = 0; // "完成未读" marks, one per finished-but-unread session
|
|
602
612
|
var hostBase = null; // document.title as the host last left it
|
|
603
613
|
var writtenTitle = null; // exact string this plugin last put into document.title
|
|
604
|
-
// Our own marker
|
|
605
|
-
//
|
|
606
|
-
//
|
|
614
|
+
// Our own marker prefixes never belong to the base title — strip leftovers
|
|
615
|
+
// (an earlier load that was closed while a mark was up, or a title the host
|
|
616
|
+
// tracked while a marker was up) before storing the base. Both marker kinds
|
|
617
|
+
// can be up at once and either may lead, so strip repeatedly.
|
|
607
618
|
function cleanBase(t) {
|
|
608
619
|
var d = texts();
|
|
609
|
-
var prefixes = [d.marker, TXT.zh.marker, TXT.en.marker];
|
|
610
|
-
|
|
611
|
-
|
|
620
|
+
var prefixes = [d.marker, TXT.zh.marker, TXT.en.marker, d.doneMarker, TXT.zh.doneMarker, TXT.en.doneMarker];
|
|
621
|
+
var stripped = true;
|
|
622
|
+
while (stripped) {
|
|
623
|
+
stripped = false;
|
|
624
|
+
for (var i = 0; i < prefixes.length; i++) {
|
|
625
|
+
if (prefixes[i] && t.indexOf(prefixes[i]) === 0) {
|
|
626
|
+
t = t.slice(prefixes[i].length);
|
|
627
|
+
stripped = true;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
612
630
|
}
|
|
613
631
|
return t;
|
|
614
632
|
}
|
|
@@ -616,7 +634,15 @@
|
|
|
616
634
|
try {
|
|
617
635
|
var current = String(document.title || "");
|
|
618
636
|
if (current !== writtenTitle) hostBase = cleanBase(current);
|
|
619
|
-
var
|
|
637
|
+
var d = texts();
|
|
638
|
+
var prefix = "";
|
|
639
|
+
if (config.enabled) {
|
|
640
|
+
// "needs you" leads when both kinds are up: it is the one that wants
|
|
641
|
+
// action, the unread mark only says something finished.
|
|
642
|
+
if (attentionActive > 0) prefix += d.marker;
|
|
643
|
+
if (doneActive > 0) prefix += d.doneMarker;
|
|
644
|
+
}
|
|
645
|
+
var next = prefix + hostBase;
|
|
620
646
|
writtenTitle = next;
|
|
621
647
|
if (current !== next) document.title = next;
|
|
622
648
|
} catch (e) {}
|
|
@@ -629,6 +655,24 @@
|
|
|
629
655
|
if (attentionActive > 0) attentionActive -= 1;
|
|
630
656
|
applyTitle();
|
|
631
657
|
}
|
|
658
|
+
// Unread-reply marker: one per session id, held exactly while the host
|
|
659
|
+
// still calls the completion unread (sessionStatus.completionUnread on
|
|
660
|
+
// 0.1.6+, the list row's `completed` reminder bit on older hosts) and
|
|
661
|
+
// dropped the moment the session is opened — the tab then reads "something
|
|
662
|
+
// finished, waiting for you" until it is read.
|
|
663
|
+
var doneUnreadMarks = Object.create(null); // sid -> true
|
|
664
|
+
function markDoneUnread(sid) {
|
|
665
|
+
if (!sid || doneUnreadMarks[sid]) return;
|
|
666
|
+
doneUnreadMarks[sid] = true;
|
|
667
|
+
doneActive += 1;
|
|
668
|
+
applyTitle();
|
|
669
|
+
}
|
|
670
|
+
function unmarkDoneUnread(sid) {
|
|
671
|
+
if (!sid || !doneUnreadMarks[sid]) return;
|
|
672
|
+
delete doneUnreadMarks[sid];
|
|
673
|
+
if (doneActive > 0) doneActive -= 1;
|
|
674
|
+
applyTitle();
|
|
675
|
+
}
|
|
632
676
|
// Title marker ownership: on hosts that publish pending interactions
|
|
633
677
|
// (uiSession) that source owns the marker, but whichever source saw the wait
|
|
634
678
|
// first must still mark it (the other one may never report that key at all),
|
|
@@ -664,6 +708,14 @@
|
|
|
664
708
|
// release path deletes it) and is re-delivered once the page is backgrounded.
|
|
665
709
|
var quietedAttention = Object.create(null);
|
|
666
710
|
var lastAttentionAt = 0;
|
|
711
|
+
// One completion can reach this plugin twice: the running edge from the
|
|
712
|
+
// controller snapshots and the completionUnread level flag from
|
|
713
|
+
// sessionStatus are two views of the same host event and land in the same
|
|
714
|
+
// tick (the host publishes both stores from one manager update). A short
|
|
715
|
+
// per-session window collapses them; two genuine completions of one session
|
|
716
|
+
// are never that close — each needs a whole turn in between.
|
|
717
|
+
var doneFiredAt = Object.create(null); // sid -> last done report timestamp
|
|
718
|
+
var DONE_DEDUPE_MS = 250;
|
|
667
719
|
|
|
668
720
|
function hidden() { return document.hidden || document.visibilityState === "hidden"; }
|
|
669
721
|
|
|
@@ -804,6 +856,18 @@
|
|
|
804
856
|
if (snippet) body = body + "\n" + snippet;
|
|
805
857
|
fire("done", d.doneTitle, body, false, sessionId);
|
|
806
858
|
}
|
|
859
|
+
// Every "reply finished" report funnels through here, so the edge path and
|
|
860
|
+
// the completionUnread level flag cannot double-alert one completion. The
|
|
861
|
+
// timestamp is recorded even when the visibility rules suppress the toast:
|
|
862
|
+
// the report was handled (the unread marker is what persists), not queued.
|
|
863
|
+
function reportDone(sessionLabel, snippet, sessionId) {
|
|
864
|
+
if (sessionId) {
|
|
865
|
+
var now = Date.now();
|
|
866
|
+
if (doneFiredAt[sessionId] && now - doneFiredAt[sessionId] < DONE_DEDUPE_MS) return;
|
|
867
|
+
doneFiredAt[sessionId] = now;
|
|
868
|
+
}
|
|
869
|
+
fireDone(sessionLabel, snippet, sessionId);
|
|
870
|
+
}
|
|
807
871
|
// Test alerts deliberately ignore the visibility rules (attentionHiddenOnly
|
|
808
872
|
// / doneHiddenOnly): the whole point of a test button is to prove the
|
|
809
873
|
// channel works while you are looking at the page. Only the master switch
|
|
@@ -960,7 +1024,7 @@
|
|
|
960
1024
|
// 2) a non-selected session finished while we were away (sidebar "done")
|
|
961
1025
|
var notified = false;
|
|
962
1026
|
if (!muted && !row.face && row.completed && prev && !prev.completed && prev.seeded) {
|
|
963
|
-
|
|
1027
|
+
reportDone(sessionLabelText(row), "", row.id);
|
|
964
1028
|
notified = true;
|
|
965
1029
|
}
|
|
966
1030
|
|
|
@@ -970,7 +1034,7 @@
|
|
|
970
1034
|
if (Date.now() - lastAttentionAt < 300) {
|
|
971
1035
|
/* answered by an attention alert above */
|
|
972
1036
|
} else {
|
|
973
|
-
|
|
1037
|
+
reportDone(sessionLabelText(row), row.face ? snippetOfLastAssistant(row.faceSnap) : "", row.id);
|
|
974
1038
|
}
|
|
975
1039
|
}
|
|
976
1040
|
|
|
@@ -986,6 +1050,16 @@
|
|
|
986
1050
|
if (!uiPending && prev && prevPendingKeys.length > 0 && pendingNow.length === 0) {
|
|
987
1051
|
for (var r = 0; r < prevPendingKeys.length; r++) unmarkAttention(prevPendingKeys[r]);
|
|
988
1052
|
}
|
|
1053
|
+
|
|
1054
|
+
// Unread-reply marker on hosts whose reminder bit lives in the list row
|
|
1055
|
+
// (`completed`: armed when a non-selected session finishes, cleared on
|
|
1056
|
+
// select — the manager's completedNotifications). Hosts exposing
|
|
1057
|
+
// sessionStatus get their marker from syncDoneFromStatus instead; the
|
|
1058
|
+
// two never share a row, so the mark counter stays balanced.
|
|
1059
|
+
if (!statusDoneSource()) {
|
|
1060
|
+
if (row.completed && !muted) markDoneUnread(row.id);
|
|
1061
|
+
else unmarkDoneUnread(row.id);
|
|
1062
|
+
}
|
|
989
1063
|
}
|
|
990
1064
|
|
|
991
1065
|
// face -> row adapter (selected session, rich data)
|
|
@@ -1054,12 +1128,18 @@
|
|
|
1054
1128
|
bindCurrentFace();
|
|
1055
1129
|
bindUiSession();
|
|
1056
1130
|
// The subagent mute keys on "not the session on screen", and switching
|
|
1057
|
-
// sessions only emits on the list store — re-run the
|
|
1131
|
+
// sessions only emits on the list store — re-run the status pass so
|
|
1058
1132
|
// the decision tracks the switch: opening a muted subagent session
|
|
1059
1133
|
// announces its outstanding wait (under the current-conversation rules),
|
|
1060
1134
|
// leaving it puts the next edge back in the muted bucket.
|
|
1061
|
-
|
|
1135
|
+
evalUiStatus();
|
|
1062
1136
|
var byId = (st && st.byId) || {};
|
|
1137
|
+
// A vanished row drops its unread-reply mark with it: the host forgets
|
|
1138
|
+
// the reminder bit together with the row, and a gone row reports
|
|
1139
|
+
// nothing. (Hosts with sessionStatus sweep this in syncDoneFromStatus.)
|
|
1140
|
+
if (!statusDoneSource()) {
|
|
1141
|
+
for (var mk in doneUnreadMarks) if (!byId[mk]) unmarkDoneUnread(mk);
|
|
1142
|
+
}
|
|
1063
1143
|
for (var sid in byId) {
|
|
1064
1144
|
if (sid === cur) continue; // current handled by the face watcher
|
|
1065
1145
|
var sum = byId[sid];
|
|
@@ -1162,16 +1242,22 @@
|
|
|
1162
1242
|
uiStore = store;
|
|
1163
1243
|
uiSource = found.source;
|
|
1164
1244
|
uiPending = true; // this watcher now owns the title marker
|
|
1165
|
-
uiSub = store.subscribe(function () { try {
|
|
1245
|
+
uiSub = store.subscribe(function () { try { evalUiStatus(); } catch (e) {} });
|
|
1166
1246
|
noteUiBind("bound");
|
|
1167
|
-
|
|
1247
|
+
evalUiStatus(); // seed: a wait that predates this plugin still alerts once
|
|
1248
|
+
}
|
|
1249
|
+
// True once the sessionStatus store is the live uiSession source (0.1.6+):
|
|
1250
|
+
// its rows then also own the completion-unread level flag and its marker.
|
|
1251
|
+
function statusDoneSource() {
|
|
1252
|
+
return !!(uiPending && uiSource === "sessionStatus");
|
|
1168
1253
|
}
|
|
1169
|
-
function
|
|
1254
|
+
function evalUiStatus() {
|
|
1170
1255
|
var svc = lookupService("uiSession");
|
|
1171
1256
|
var found = interactionStore(svc);
|
|
1172
1257
|
if (!found || typeof found.store.getSnapshot !== "function") return;
|
|
1173
1258
|
var snap = found.store.getSnapshot(); // Map<sessionId, interaction|status>
|
|
1174
1259
|
if (!snap || typeof snap.forEach !== "function") return;
|
|
1260
|
+
if (found.source === "sessionStatus") syncDoneFromStatus(snap);
|
|
1175
1261
|
var seen = Object.create(null);
|
|
1176
1262
|
snap.forEach(function (value, sid) {
|
|
1177
1263
|
var it = pendingOf(value, found.source);
|
|
@@ -1210,6 +1296,42 @@
|
|
|
1210
1296
|
delete uiBaseline[sid2];
|
|
1211
1297
|
}
|
|
1212
1298
|
}
|
|
1299
|
+
// The sessionStatus rows also carry the reply-finished channel's level
|
|
1300
|
+
// flag (0.1.6-alpha.2+): `completionUnread` lights when a session that is
|
|
1301
|
+
// not on screen finishes and clears when the session is opened, starts
|
|
1302
|
+
// running again, or disappears. Two jobs live here:
|
|
1303
|
+
// * the "完成未读" title marker, held exactly while a background session
|
|
1304
|
+
// is finished-but-unread — open the session and the tab goes quiet;
|
|
1305
|
+
// * one done alert for completions whose running edge this page never saw
|
|
1306
|
+
// (coalesced list snapshots, a plugin remount mid-turn, a completion
|
|
1307
|
+
// that predates this bind). The latch reports each unread instance once;
|
|
1308
|
+
// reportDone's window collapses the double view when the edge did fire.
|
|
1309
|
+
// The edge path stays the reporter for the on-screen session (its snippet
|
|
1310
|
+
// comes from the face snapshot) and for hosts without this store.
|
|
1311
|
+
var uiDoneBaseline = Object.create(null); // sid -> true once this unread reported
|
|
1312
|
+
function syncDoneFromStatus(snap) {
|
|
1313
|
+
var want = Object.create(null);
|
|
1314
|
+
try {
|
|
1315
|
+
snap.forEach(function (value, sid) {
|
|
1316
|
+
if (!value) return;
|
|
1317
|
+
// A stop that awaits input (plan-review / question end the turn with
|
|
1318
|
+
// a pending interaction) is a wait, not a completion — the same rule
|
|
1319
|
+
// as the edge path's !hasPendingNow guard. The on-screen session is
|
|
1320
|
+
// never "unread" (the host clears the flag for it; its completion is
|
|
1321
|
+
// the face edge's job), and a background subagent step is muted.
|
|
1322
|
+
if (!value.completionUnread || value.pendingInteraction || isSubagentSession(sid) || currentSessionId() === sid) return;
|
|
1323
|
+
want[sid] = true;
|
|
1324
|
+
markDoneUnread(sid);
|
|
1325
|
+
if (uiDoneBaseline[sid]) return; // this unread instance already reported
|
|
1326
|
+
uiDoneBaseline[sid] = true;
|
|
1327
|
+
if (Date.now() - lastAttentionAt < 300) return; // same-tick attention owns the moment
|
|
1328
|
+
reportDone(labelForSessionId(sid), "", sid);
|
|
1329
|
+
});
|
|
1330
|
+
} catch (e) {}
|
|
1331
|
+
// answered / re-run / gone / muted: latch and mark go with the flag
|
|
1332
|
+
for (var s in uiDoneBaseline) if (!want[s]) delete uiDoneBaseline[s];
|
|
1333
|
+
for (var m in doneUnreadMarks) if (!want[m]) unmarkDoneUnread(m);
|
|
1334
|
+
}
|
|
1213
1335
|
function detachUiSession() {
|
|
1214
1336
|
if (uiSub) { try { uiSub(); } catch (e) {} uiSub = null; }
|
|
1215
1337
|
uiStore = null;
|
|
@@ -1218,6 +1340,8 @@
|
|
|
1218
1340
|
// go back to the controller marker path
|
|
1219
1341
|
for (var s in uiBaseline) unmarkAttention(uiBaseline[s].key);
|
|
1220
1342
|
uiBaseline = Object.create(null);
|
|
1343
|
+
for (var dm in doneUnreadMarks) unmarkDoneUnread(dm);
|
|
1344
|
+
uiDoneBaseline = Object.create(null);
|
|
1221
1345
|
uiPending = false;
|
|
1222
1346
|
}
|
|
1223
1347
|
|
|
@@ -1235,7 +1359,7 @@
|
|
|
1235
1359
|
});
|
|
1236
1360
|
} catch (e) {}
|
|
1237
1361
|
// keep in sync with package.json "version" on every release
|
|
1238
|
-
api.version = "1.
|
|
1362
|
+
api.version = "1.5.0";
|
|
1239
1363
|
api.setConfig = function (patch) { return setConfigLocal(patch); };
|
|
1240
1364
|
api.resetConfig = function () {
|
|
1241
1365
|
try { localStorage.removeItem(LS_CONFIG); } catch (e) {}
|
|
@@ -1286,6 +1410,7 @@
|
|
|
1286
1410
|
pendingBaselines: Object.keys(uiBaseline).length,
|
|
1287
1411
|
firedKeys: Object.keys(attentionKeysFired),
|
|
1288
1412
|
markedKeys: Object.keys(attentionKeysMarked),
|
|
1413
|
+
doneUnreadMarked: Object.keys(doneUnreadMarks),
|
|
1289
1414
|
quietedKeys: Object.keys(quietedAttention),
|
|
1290
1415
|
lastAttentionAt: lastAttentionAt ? new Date(lastAttentionAt).toISOString() : null
|
|
1291
1416
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-notify-me",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "DSH 桌面消息提醒插件:模型需要你操作(审批/方案确认/提问的可操作提醒)或回复在后台完成时,系统通知+提示音+标签页标题提醒你;权限审批的通知上可直接点「同意/拒绝」完成裁决;可在设置页开关并切换通知语言。Desktop notification & message alerts for DeepSeek Harness web — toasts, sounds and a tab-title marker when the agent needs your input (approval / plan review / question) or a reply finishes in the background, Approve/Reject buttons on approval toasts to decide right from the notification; toggleable from Settings with zh/en notification language.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|