Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac6963279c | ||
|
|
302e0a8bf5 | ||
|
|
ec8661b317 | ||
|
|
074cdccdb9 |
@@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
版本说明按倒序排列。提交信息遵循 [CONTRIBUTING.md](CONTRIBUTING.md) 的单行规范,因此每次改动"为什么这样改、影响面是什么"记在这里,而不是提交信息里。
|
版本说明按倒序排列。提交信息遵循 [CONTRIBUTING.md](CONTRIBUTING.md) 的单行规范,因此每次改动"为什么这样改、影响面是什么"记在这里,而不是提交信息里。
|
||||||
|
|
||||||
|
## v1.0.8
|
||||||
|
|
||||||
|
- 修复:**授权与提问两类提醒从来不会弹**(只有「会话已完成」会弹)。原因不是判据写错了,而是投递前的「是否还值得提醒」那道闸门用错了事实:
|
||||||
|
- `stillWorth` 原本对所有提醒都要求「会话已经不在运行」,可待处理请求恰恰出现在会话仍在运行的时候——客户端的 `running` 只镜像宿主的 `api-session/status`,和有没有待处理请求是两件独立的事(`dsh-client-ui-session` 的 `observeRunning` 就是这么写的),于是每条授权 / 提问提醒都在 400ms 确认窗口结束时被静默丢掉;
|
||||||
|
- 更糟的是丢之前 `pendingNotice` 已经记下了这个请求,所以它再也不会被重新排进队列——同一请求只报一次的规则反而变成了"一次都不报"。
|
||||||
|
- 现在两类提醒用各自该问的问题:**待处理请求问「它还在等吗」**(请求被你自己答掉就不提醒,还在就提醒,不看运行状态),**完成提醒仍问「这一轮真的停下来了吗」**(在确认窗口里又跑起来就不提醒)。
|
||||||
|
- 修复:**计划确认(`plan-review`)的文案从 v1.0.1 起就是死代码**——`copyFor` 先判断 `kind === 'question'`,而计划确认正是以 `kind: 'question'` 入队的,于是「计划正在等待你确认」永远走不到,实际显示的是提问那段文案。现在先看判别符,计划确认用自己的文案,与 README 的说明一致。
|
||||||
|
- 投递节流不再丢待处理提醒:1.5 秒的洪泛保护原本会直接吃掉被拦下的提醒,现在**待处理请求**被拦下时会回到队列、下一个 tick 重试(只有你能清掉它,所以它一直是欠你的);完成提醒保持原有的丢弃语义,多个会话同时结束仍然不会刷屏。
|
||||||
|
- 重新设计插件页(**插件 → 会话通知**):原来是一段孤立说明 + 四段标题与行标题同字号的段落,状态区把四句话和按钮挤在一行里。现在:
|
||||||
|
- 顶部一句「提醒是怎么送出去的」,下面三组:**提醒内容 / 系统通知权限 / 运行状态**,组标题加粗,组内是「左侧对象 + 右侧唯一控件」的列表,行之间用细线分隔;
|
||||||
|
- 权限状态带一个小圆点(绿=已开启,黄=未授权,红=被系统关掉,灰=当前环境不支持),下面一行按情况给出该去哪授权或该按钮验什么;
|
||||||
|
- 运行状态改成**键值对照表**(窗口状态 / 会话监听 / 最近一次投递 / 待补发提醒),最近一次投递拆成「时间 · 通道」加下一行提醒类型,不再是四个句子堆在一个格子里;
|
||||||
|
- 「测试提醒」独立成行右对齐,按钮区分主次(未授权时的「允许通知」是主按钮),行高与圆角统一。
|
||||||
|
- 字典随之增删:新增 `config.diag.watch`、`config.diag.replayValue`,`config.diag.replay` 改成短标签「待补发提醒」、`config.diag.replayNone` 改成「没有」,两个字典键集合仍然完全一致,没有死键。
|
||||||
|
- 测试从 36 条增加到 39 条:新增「待处理请求放着 `running: true` 也照样该提醒」的回归用例(这条如果早就有,v1.0.7 之前就能发现上面那个 bug)、计划确认文案用例,并把页面渲染测试改到新的结构与文案上。
|
||||||
|
|
||||||
## v1.0.7
|
## v1.0.7
|
||||||
|
|
||||||
- 重构:**客户端源码拆成模块,`client.js` 从「手写文件」变成「构建产物」**。原来的 `client.js` 是 1452 行单文件,通知引擎、轻弹窗、插件页、观察器、字典、样式、图标全塞在一个 `apply` 里,改任何一处都要在同一个文件里上下翻。现在:
|
- 重构:**客户端源码拆成模块,`client.js` 从「手写文件」变成「构建产物」**。原来的 `client.js` 是 1452 行单文件,通知引擎、轻弹窗、插件页、观察器、字典、样式、图标全塞在一个 `apply` 里,改任何一处都要在同一个文件里上下翻。现在:
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ DeepSeek Harness(DSH)插件:会话**需要你注意**时提醒你——窗
|
|||||||
| 分组 | 内容 |
|
| 分组 | 内容 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 提醒内容 | **完成 / 授权 / 提问** 三个开关,分别控制三类提醒,默认全开;开关保存在浏览器本地,重开页面、重装插件都保留 |
|
| 提醒内容 | **完成 / 授权 / 提问** 三个开关,分别控制三类提醒,默认全开;开关保存在浏览器本地,重开页面、重装插件都保留 |
|
||||||
| 系统通知权限 | 当前权限状态;尚未授权时点「允许通知」请求授权(浏览器要求必须由你手动点击),授权成功后会自动发一条测试提醒。权限被系统层关闭时,会按当前平台告诉你去哪里打开 |
|
| 系统通知权限 | 一行状态(前面的小圆点表示健康程度)+ 一个按钮;尚未授权时按钮是「允许通知」(浏览器要求必须由你手动点击),授权成功后自动发一条测试提醒,按钮随之变成「测试系统通知」;权限被系统层关闭或当前环境不支持时,状态下面按当前平台告诉你去哪里打开 |
|
||||||
| 运行状态 | 窗口现在是前台还是后台(即会走哪条通道)、插件是否真的在读会话状态、**最近一次提醒走的通道、系统是否确认弹出、时间**(本机时间),以及还有几条提醒在等你回到窗口时补发;旁边「测试提醒」按钮发一条测试提醒 |
|
| 运行状态 | 四项读数:**窗口状态**(前台还是后台,即会走哪条通道)、**会话监听**(插件是否真的在读会话状态)、**最近一次投递**(时间、走的通道、系统是否确认弹出,下一行是提醒类型)、**待补发提醒**(还有几条在等你回到窗口);下面「测试提醒」按钮发一条测试提醒 |
|
||||||
|
|
||||||
- 已经授权时,权限行的按钮变成「测试系统通知」:它直接走系统通知通道(窗口在前台也照发),专门用来验证系统通知本身是否可用。
|
- 已经授权时,权限行的按钮变成「测试系统通知」:它直接走系统通知通道(窗口在前台也照发),专门用来验证系统通知本身是否可用。
|
||||||
- 开关只影响提醒,不改 DSH 本身的任何设置。
|
- 开关只影响提醒,不改 DSH 本身的任何设置。
|
||||||
@@ -59,10 +59,10 @@ DeepSeek Harness(DSH)插件:会话**需要你注意**时提醒你——窗
|
|||||||
在 DSH 的 **插件 → 添加插件** 的上方输入框里填:
|
在 DSH 的 **插件 → 添加插件** 的上方输入框里填:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
https://gitea.iwake.top/dsh-plugin/session-notify.git#v1.0.7
|
https://gitea.iwake.top/dsh-plugin/session-notify.git#v1.0.8
|
||||||
```
|
```
|
||||||
|
|
||||||
`#` 后面跟标签或提交,用来锁定版本;不写则取默认分支。跟随 1.x 最新版可以写 `#semver:^1.0.7`。仓库是公开的,不需要凭据,也不用改「安装源」。
|
`#` 后面跟标签或提交,用来锁定版本;不写则取默认分支。跟随 1.x 最新版可以写 `#semver:^1.0.8`。仓库是公开的,不需要凭据,也不用改「安装源」。
|
||||||
|
|
||||||
### 本地路径安装
|
### 本地路径安装
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ D:\DeepSeek Harness Plugins\dsh-session-notify
|
|||||||
- **正在看的那个会话完成后不打扰**。
|
- **正在看的那个会话完成后不打扰**。
|
||||||
- **子智能体的会话不单独提醒**,等它归属的主会话结束时才提醒。
|
- **子智能体的会话不单独提醒**,等它归属的主会话结束时才提醒。
|
||||||
- **空白会话完成不提醒**。
|
- **空白会话完成不提醒**。
|
||||||
- **授权 / 提问如果出现的当下会话仍在运行,会先记下、等这一轮真正停下来再提醒**,不在模型还在跑的时候打扰你。
|
- **授权 / 提问会立刻提醒,不押后**:待处理请求只有你能清掉,而会话「正在等它」本来就是会话的状态(`running` 是宿主自己的另一条事实,和有没有待处理请求无关),所以不会因为「会话还在跑」而压后提醒;请求在 400ms 确认窗口内被你自己答掉,就不再提醒。
|
||||||
- **节流**:1.5 秒内只投递一条,多个会话同时完成不会刷屏。
|
- **节流**:1.5 秒内只投递一条,多个会话同时完成不会刷屏。
|
||||||
- **完成提醒有 400ms 的确认窗口**:如果那一轮马上又跑起来,就不报了。
|
- **完成提醒有 400ms 的确认窗口**:如果那一轮马上又跑起来,就不报了。
|
||||||
- **同一会话的完成提醒会覆盖上一条**(通知带 `tag`),不叠加堆积。
|
- **同一会话的完成提醒会覆盖上一条**(通知带 `tag`),不叠加堆积。
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ var zh = {
|
|||||||
"config.testAny": "测试提醒",
|
"config.testAny": "测试提醒",
|
||||||
"config.testSystem": "测试系统通知",
|
"config.testSystem": "测试系统通知",
|
||||||
"config.diag.window": "窗口状态",
|
"config.diag.window": "窗口状态",
|
||||||
|
"config.diag.watch": "会话监听",
|
||||||
"config.diag.inFront": "在前台(会走轻弹窗)",
|
"config.diag.inFront": "在前台(会走轻弹窗)",
|
||||||
"config.diag.away": "不在前台(会走系统通知)",
|
"config.diag.away": "不在前台(会走系统通知)",
|
||||||
"config.diag.last": "最近一次投递",
|
"config.diag.last": "最近一次投递",
|
||||||
@@ -114,8 +115,9 @@ var zh = {
|
|||||||
"config.diag.replayDelivery": "应用内轻弹窗(回到窗口时补发)",
|
"config.diag.replayDelivery": "应用内轻弹窗(回到窗口时补发)",
|
||||||
"config.diag.popup": "应用内轻弹窗",
|
"config.diag.popup": "应用内轻弹窗",
|
||||||
"config.diag.refused": "系统通知被拒绝,改用了轻弹窗",
|
"config.diag.refused": "系统通知被拒绝,改用了轻弹窗",
|
||||||
"config.diag.replay": "等你回到窗口时补发:{count} 条",
|
"config.diag.replay": "待补发提醒",
|
||||||
"config.diag.replayNone": "没有待补发的提醒"
|
"config.diag.replayValue": "{count} 条",
|
||||||
|
"config.diag.replayNone": "没有"
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/client/i18n/en.js
|
// src/client/i18n/en.js
|
||||||
@@ -163,6 +165,7 @@ var en = {
|
|||||||
"config.testAny": "Test alert",
|
"config.testAny": "Test alert",
|
||||||
"config.testSystem": "Test system notification",
|
"config.testSystem": "Test system notification",
|
||||||
"config.diag.window": "Window",
|
"config.diag.window": "Window",
|
||||||
|
"config.diag.watch": "Session watch",
|
||||||
"config.diag.inFront": "in front (popup is used)",
|
"config.diag.inFront": "in front (popup is used)",
|
||||||
"config.diag.away": "not in front (system notification is used)",
|
"config.diag.away": "not in front (system notification is used)",
|
||||||
"config.diag.last": "Last delivery",
|
"config.diag.last": "Last delivery",
|
||||||
@@ -173,8 +176,9 @@ var en = {
|
|||||||
"config.diag.replayDelivery": "in-app popup (replayed when you came back)",
|
"config.diag.replayDelivery": "in-app popup (replayed when you came back)",
|
||||||
"config.diag.popup": "in-app popup",
|
"config.diag.popup": "in-app popup",
|
||||||
"config.diag.refused": "system channel refused, popup was used instead",
|
"config.diag.refused": "system channel refused, popup was used instead",
|
||||||
"config.diag.replay": "waiting for you to come back: {count}",
|
"config.diag.replay": "Replay",
|
||||||
"config.diag.replayNone": "nothing waiting to be replayed"
|
"config.diag.replayValue": "{count} waiting",
|
||||||
|
"config.diag.replayNone": "None"
|
||||||
};
|
};
|
||||||
|
|
||||||
// src/client/i18n/index.js
|
// src/client/i18n/index.js
|
||||||
@@ -331,6 +335,9 @@ function createCopy(t) {
|
|||||||
if (candidate.kind === "completion") {
|
if (candidate.kind === "completion") {
|
||||||
return { kind: "completion", title: t("notification.completion"), body: t("body.completion", { title }) };
|
return { kind: "completion", title: t("notification.completion"), body: t("body.completion", { title }) };
|
||||||
}
|
}
|
||||||
|
if (candidate.pendingKind === "plan-review") {
|
||||||
|
return { kind: "question", title: t("notification.question"), body: t("body.planReview", { title }) };
|
||||||
|
}
|
||||||
if (candidate.kind === "question") {
|
if (candidate.kind === "question") {
|
||||||
const question = candidate.detail;
|
const question = candidate.detail;
|
||||||
return {
|
return {
|
||||||
@@ -339,9 +346,6 @@ function createCopy(t) {
|
|||||||
body: question === "" ? t("body.question", { title }) : `${title} · ${question}`
|
body: question === "" ? t("body.question", { title }) : `${title} · ${question}`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (candidate.pendingKind === "plan-review") {
|
|
||||||
return { kind: "question", title: t("notification.question"), body: t("body.planReview", { title }) };
|
|
||||||
}
|
|
||||||
const tool = candidate.detail;
|
const tool = candidate.detail;
|
||||||
return {
|
return {
|
||||||
kind: "approval",
|
kind: "approval",
|
||||||
@@ -349,13 +353,13 @@ function createCopy(t) {
|
|||||||
body: tool === "" ? t("body.approvalPlain", { title }) : t("body.approval", { title, tool })
|
body: tool === "" ? t("body.approvalPlain", { title }) : t("body.approval", { title, tool })
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const describeDelivery = (last, tr) => {
|
const deliveryFacts = (last, tr) => {
|
||||||
if (last === null || last === void 0) return tr("config.diag.none");
|
if (last === null || last === void 0) return null;
|
||||||
const outcome = last.outcome.startsWith("system-refused") ? tr("config.diag.refused") : last.outcome === "system" ? last.shown === true ? tr("config.diag.systemShown") : last.shown === false ? tr("config.diag.systemFailed") : tr("config.diag.systemUnconfirmed") : last.outcome === "replay" ? tr("config.diag.replayDelivery") : tr("config.diag.popup");
|
const outcome = last.outcome.startsWith("system-refused") ? tr("config.diag.refused") : last.outcome === "system" ? last.shown === true ? tr("config.diag.systemShown") : last.shown === false ? tr("config.diag.systemFailed") : tr("config.diag.systemUnconfirmed") : last.outcome === "replay" ? tr("config.diag.replayDelivery") : tr("config.diag.popup");
|
||||||
return `${tr("config.diag.last")}: ${last.at} · ${outcome} · ${last.title}`;
|
return { at: last.at, outcome, title: last.title ?? "" };
|
||||||
};
|
};
|
||||||
const describeReplay = (count, tr) => count === 0 ? tr("config.diag.replayNone") : tr("config.diag.replay", { count });
|
const replayValue = (count, tr) => count === 0 ? tr("config.diag.replayNone") : tr("config.diag.replayValue", { count });
|
||||||
return { copyFor, describeDelivery, describeReplay };
|
return { copyFor, deliveryFacts, replayValue };
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/client/core/toasts.js
|
// src/client/core/toasts.js
|
||||||
@@ -548,13 +552,18 @@ function isOnScreen(sessionId, list) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function stillWorth(candidate, live) {
|
function stillOwed(candidate, live) {
|
||||||
|
if (candidate.test === true) return true;
|
||||||
|
if (candidate.pendingKind !== "") {
|
||||||
|
const sessionStatus = live.status?.get?.(candidate.sessionId);
|
||||||
|
if (sessionStatus === void 0) return true;
|
||||||
|
return servedPendingKind(sessionStatus.pendingInteraction) === candidate.pendingKind;
|
||||||
|
}
|
||||||
const list = live.list;
|
const list = live.list;
|
||||||
if (candidate.test === true || list === void 0) return true;
|
if (list === void 0) return true;
|
||||||
const summary = list.byId?.[candidate.sessionId];
|
const summary = list.byId?.[candidate.sessionId];
|
||||||
if (summary === void 0) return true;
|
if (summary === void 0) return true;
|
||||||
const status = live.status;
|
const running = live.status?.get?.(candidate.sessionId)?.running ?? summary.running;
|
||||||
const running = status?.get?.(candidate.sessionId)?.running ?? summary.running;
|
|
||||||
return running !== true;
|
return running !== true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,28 +591,32 @@ function createDelivery({ store, copy, live, toasts, system, replay }) {
|
|||||||
const deliver = (candidate, ignoreThrottle) => {
|
const deliver = (candidate, ignoreThrottle) => {
|
||||||
if (ignoreThrottle !== true) {
|
if (ignoreThrottle !== true) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (now - lastDelivery < THROTTLE_MS) return;
|
if (now - lastDelivery < THROTTLE_MS) return false;
|
||||||
lastDelivery = now;
|
lastDelivery = now;
|
||||||
}
|
}
|
||||||
if (!windowIsAway()) {
|
if (!windowIsAway()) {
|
||||||
if (isOnScreen(candidate.sessionId, live.list)) return;
|
if (isOnScreen(candidate.sessionId, live.list)) return true;
|
||||||
toasts.showToast(candidate);
|
toasts.showToast(candidate);
|
||||||
recordDelivery("popup", candidate);
|
recordDelivery("popup", candidate);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
const result = system.notifySystem(candidate, candidate.test === true);
|
const result = system.notifySystem(candidate, candidate.test === true);
|
||||||
if (result.outcome === "raised") {
|
if (result.outcome === "raised") {
|
||||||
recordDelivery("system", candidate, result);
|
recordDelivery("system", candidate, result);
|
||||||
if (candidate.test !== true) replay.holdForReplay(candidate, result);
|
if (candidate.test !== true) replay.holdForReplay(candidate, result);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
toasts.showToast(candidate);
|
toasts.showToast(candidate);
|
||||||
recordDelivery(`system-refused-${result.outcome}`, candidate);
|
recordDelivery(`system-refused-${result.outcome}`, candidate);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
const flushSettle = () => {
|
const flushSettle = () => {
|
||||||
settleTimer = 0;
|
settleTimer = 0;
|
||||||
const candidate = pending.shift();
|
const candidate = pending.shift();
|
||||||
if (candidate !== void 0 && stillWorth(candidate, live)) deliver(candidate, false);
|
if (candidate !== void 0 && stillOwed(candidate, live)) {
|
||||||
|
const delivered = deliver(candidate, false);
|
||||||
|
if (delivered === false && candidate.pendingKind !== "") pending.push(candidate);
|
||||||
|
}
|
||||||
if (pending.length > 0) settleTimer = setTimeout(() => flushSettle(), SETTLE_MS);
|
if (pending.length > 0) settleTimer = setTimeout(() => flushSettle(), SETTLE_MS);
|
||||||
};
|
};
|
||||||
const queue = (candidate) => {
|
const queue = (candidate) => {
|
||||||
@@ -894,17 +907,29 @@ var CSS = `
|
|||||||
.dsn-toast-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-toast-label);opacity:.8;cursor:pointer}
|
.dsn-toast-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-toast-label);opacity:.8;cursor:pointer}
|
||||||
.dsn-toast-close:hover{background:var(--dsw-alias-interactive-bg-hover);opacity:1}
|
.dsn-toast-close:hover{background:var(--dsw-alias-interactive-bg-hover);opacity:1}
|
||||||
.dsn-toast-close:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
.dsn-toast-close:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
||||||
.dsn-sections{display:flex;flex-direction:column;gap:24px}
|
.dsn-page{display:flex;flex-direction:column;gap:28px;max-width:560px}
|
||||||
.dsn-section{display:flex;flex-direction:column;gap:10px}
|
.dsn-lede{margin:0;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px}
|
||||||
.dsn-section-title{margin:0;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}
|
.dsn-group{display:flex;flex-direction:column;gap:2px}
|
||||||
.dsn-section-desc{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
.dsn-group-title{margin:0 0 8px;color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:20px}
|
||||||
.dsn-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 0;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
.dsn-group-note{margin:8px 0 0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
||||||
.dsn-row:last-child{border-bottom:0}
|
.dsn-list{display:flex;flex-direction:column}
|
||||||
|
.dsn-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 0}
|
||||||
|
.dsn-row+.dsn-row{border-top:.5px solid var(--dsw-alias-border-l2)}
|
||||||
|
.dsn-row.is-action{justify-content:flex-end;padding:12px 0 0}
|
||||||
.dsn-row-text{display:flex;flex-direction:column;gap:2px;min-width:0}
|
.dsn-row-text{display:flex;flex-direction:column;gap:2px;min-width:0}
|
||||||
.dsn-row-title{color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
|
.dsn-row-title{color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
|
||||||
.dsn-row-desc{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
.dsn-row-sub{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
||||||
.dsn-status{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
.dsn-state{display:inline-flex;align-items:center;gap:8px;color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
|
||||||
.dsn-status-error{color:var(--dsw-alias-state-error-primary)}
|
.dsn-dot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary)}
|
||||||
|
.dsn-dot.is-warn{background:var(--dsw-alias-state-warn-label)}
|
||||||
|
.dsn-dot.is-error{background:var(--dsw-alias-state-error-primary)}
|
||||||
|
.dsn-dot.is-muted{background:var(--dsw-alias-border-l3)}
|
||||||
|
.dsn-facts{display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px 14px;margin:0;min-width:0}
|
||||||
|
.dsn-fact-key{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;white-space:nowrap}
|
||||||
|
.dsn-fact{display:flex;flex-direction:column;gap:2px;margin:0;min-width:0}
|
||||||
|
.dsn-fact-value{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
||||||
|
.dsn-fact-value.is-error{color:var(--dsw-alias-state-error-primary)}
|
||||||
|
.dsn-fact-title{margin:0;color:var(--dsw-alias-label-primary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
||||||
.dsn-switch{box-sizing:border-box;position:relative;flex:0 0 auto;width:36px;height:20px;padding:2px;border:0;border-radius:999px;background:var(--dsw-alias-border-l3);cursor:pointer}
|
.dsn-switch{box-sizing:border-box;position:relative;flex:0 0 auto;width:36px;height:20px;padding:2px;border:0;border-radius:999px;background:var(--dsw-alias-border-l3);cursor:pointer}
|
||||||
.dsn-switch[aria-checked='true']{background:var(--dsw-alias-brand-primary)}
|
.dsn-switch[aria-checked='true']{background:var(--dsw-alias-brand-primary)}
|
||||||
.dsn-switch:disabled{cursor:default;opacity:.5}
|
.dsn-switch:disabled{cursor:default;opacity:.5}
|
||||||
@@ -912,10 +937,12 @@ var CSS = `
|
|||||||
.dsn-thumb{display:block;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary-foreground);transition:transform 120ms ease}
|
.dsn-thumb{display:block;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary-foreground);transition:transform 120ms ease}
|
||||||
.dsn-switch[aria-checked='false'] .dsn-thumb{background:var(--dsw-alias-switch-thumb)}
|
.dsn-switch[aria-checked='false'] .dsn-thumb{background:var(--dsw-alias-switch-thumb)}
|
||||||
.dsn-switch[aria-checked='true'] .dsn-thumb{transform:translateX(16px)}
|
.dsn-switch[aria-checked='true'] .dsn-thumb{transform:translateX(16px)}
|
||||||
.dsn-button{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);background:transparent;flex:none}
|
.dsn-button{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:32px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);background:transparent;flex:none}
|
||||||
.dsn-button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
.dsn-button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
||||||
.dsn-button:disabled{cursor:not-allowed;opacity:.4}
|
.dsn-button:disabled{cursor:not-allowed;opacity:.4}
|
||||||
.dsn-button:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
.dsn-button:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
||||||
|
.dsn-button.is-primary{border-color:transparent;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground)}
|
||||||
|
.dsn-button.is-primary:hover:not(:disabled){background:var(--dsw-alias-brand-primary);opacity:.88}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// src/client/ui/ToastLayer.js
|
// src/client/ui/ToastLayer.js
|
||||||
@@ -1022,85 +1049,125 @@ function ConfigSection(props) {
|
|||||||
const supported = permission !== "unsupported";
|
const supported = permission !== "unsupported";
|
||||||
const failed = permission === "denied" || snapshot.promptError !== "";
|
const failed = permission === "denied" || snapshot.promptError !== "";
|
||||||
const statusKey = permission === "granted" ? "settings.permission.granted" : permission === "denied" ? "settings.permission.denied" : supported ? "settings.permission.default" : "settings.permission.unsupported";
|
const statusKey = permission === "granted" ? "settings.permission.granted" : permission === "denied" ? "settings.permission.denied" : supported ? "settings.permission.default" : "settings.permission.unsupported";
|
||||||
const permissionText = snapshot.promptError === "" ? `${tr(statusKey)}${permission === "denied" || !supported ? ` · ${tr(`settings.permission.hint.${props.platform}`)}` : ""}` : snapshot.promptError;
|
const promptFailed = snapshot.promptError !== "";
|
||||||
|
const permissionText = promptFailed ? snapshot.promptError : tr(statusKey);
|
||||||
|
const dotClass = permission === "granted" ? "" : failed ? " is-error" : supported ? " is-warn" : " is-muted";
|
||||||
|
const permissionNote = promptFailed ? "" : permission === "denied" || !supported ? tr(`settings.permission.hint.${props.platform}`) : permission === "granted" ? tr("config.testHint") : tr("settings.permission.hint.plain");
|
||||||
const health = snapshot.health;
|
const health = snapshot.health;
|
||||||
const healthText = health.state === "watching" ? tr("settings.health.watching") : health.state === "noHooks" ? tr("settings.health.noHooks") : health.state === "error" ? tr("settings.health.error", { message: health.message }) : tr("settings.health.starting");
|
const healthText = health.state === "watching" ? tr("settings.health.watching") : health.state === "noHooks" ? tr("settings.health.noHooks") : health.state === "error" ? tr("settings.health.error", { message: health.message }) : tr("settings.health.starting");
|
||||||
const healthFailed = health.state !== "watching" && health.state !== "starting";
|
const healthFailed = health.state !== "watching" && health.state !== "starting";
|
||||||
|
const delivery = props.copy.deliveryFacts(snapshot.lastDelivery, tr);
|
||||||
return h4(
|
return h4(
|
||||||
React5.Fragment,
|
React5.Fragment,
|
||||||
null,
|
null,
|
||||||
h4("style", null, CSS),
|
h4("style", null, CSS),
|
||||||
h4(
|
h4(
|
||||||
"div",
|
"div",
|
||||||
{ className: "dsn-sections" },
|
{ className: "dsn-page" },
|
||||||
// The page header already shows this bundle's title and description, so
|
// The page header already shows this bundle's title and description, so this
|
||||||
// this section opens with what the header cannot say: how alerts are
|
// lede says what the header cannot: how an alert travels, and that the
|
||||||
// carried, and what this form changes.
|
// channel is chosen at delivery time.
|
||||||
|
h4("p", { className: "dsn-lede" }, tr("config.intro")),
|
||||||
h4(
|
h4(
|
||||||
"section",
|
"section",
|
||||||
{ className: "dsn-section" },
|
{ className: "dsn-group" },
|
||||||
h4("p", { className: "dsn-section-desc" }, tr("config.intro"))
|
h4("h3", { className: "dsn-group-title" }, tr("config.section.kinds")),
|
||||||
),
|
|
||||||
h4(
|
|
||||||
"section",
|
|
||||||
{ className: "dsn-section" },
|
|
||||||
h4("h3", { className: "dsn-section-title" }, tr("config.section.kinds")),
|
|
||||||
KINDS.map((kind) => h4(KindRow, {
|
|
||||||
key: kind,
|
|
||||||
label: tr(`settings.kind.${kind}`),
|
|
||||||
checked: snapshot.kinds[kind] === true,
|
|
||||||
disabled: false,
|
|
||||||
onToggle: () => props.setKind(kind, snapshot.kinds[kind] !== true)
|
|
||||||
})),
|
|
||||||
h4("p", { className: "dsn-section-desc" }, tr("config.saveNote"))
|
|
||||||
),
|
|
||||||
h4(
|
|
||||||
"section",
|
|
||||||
{ className: "dsn-section" },
|
|
||||||
h4("h3", { className: "dsn-section-title" }, tr("config.section.permission")),
|
|
||||||
h4(
|
h4(
|
||||||
"div",
|
"div",
|
||||||
{ className: "dsn-row" },
|
{ className: "dsn-list" },
|
||||||
h4(
|
KINDS.map((kind) => h4(KindRow, {
|
||||||
"div",
|
key: kind,
|
||||||
{ className: "dsn-row-text" },
|
label: tr(`settings.kind.${kind}`),
|
||||||
h4("p", {
|
checked: snapshot.kinds[kind] === true,
|
||||||
className: `dsn-status${failed ? " dsn-status-error" : ""}`,
|
disabled: false,
|
||||||
role: failed ? "alert" : "status"
|
onToggle: () => props.setKind(kind, snapshot.kinds[kind] !== true)
|
||||||
}, permissionText)
|
}))
|
||||||
),
|
|
||||||
h4("button", {
|
|
||||||
type: "button",
|
|
||||||
className: "dsn-button",
|
|
||||||
disabled: !supported,
|
|
||||||
onClick: permission === "granted" ? props.testSystem : props.ask
|
|
||||||
}, tr(!supported ? "settings.action.unsupported" : permission === "granted" ? "settings.action.testSystem" : "settings.action.allow"))
|
|
||||||
),
|
),
|
||||||
h4("p", { className: "dsn-section-desc" }, tr("config.testHint"))
|
h4("p", { className: "dsn-group-note" }, tr("config.saveNote"))
|
||||||
),
|
),
|
||||||
h4(
|
h4(
|
||||||
"section",
|
"section",
|
||||||
{ className: "dsn-section" },
|
{ className: "dsn-group" },
|
||||||
h4("h3", { className: "dsn-section-title" }, tr("config.section.status")),
|
h4("h3", { className: "dsn-group-title" }, tr("config.section.permission")),
|
||||||
h4(
|
h4(
|
||||||
"div",
|
"div",
|
||||||
{ className: "dsn-row" },
|
{ className: "dsn-list" },
|
||||||
h4(
|
h4(
|
||||||
"div",
|
"div",
|
||||||
{ className: "dsn-row-text" },
|
{ className: "dsn-row" },
|
||||||
h4("p", { className: "dsn-status" }, `${tr("config.diag.window")}: ${tr(windowIsAway() ? "config.diag.away" : "config.diag.inFront")}`),
|
h4(
|
||||||
h4("p", {
|
"div",
|
||||||
className: `dsn-status${healthFailed ? " dsn-status-error" : ""}`,
|
{ className: "dsn-row-text" },
|
||||||
role: healthFailed ? "alert" : "status"
|
h4(
|
||||||
}, healthText),
|
"span",
|
||||||
h4("p", { className: "dsn-status" }, props.copy.describeDelivery(snapshot.lastDelivery, tr)),
|
{
|
||||||
h4("p", { className: "dsn-status" }, props.copy.describeReplay(props.replayCount(), tr))
|
className: "dsn-state",
|
||||||
|
role: failed ? "alert" : "status"
|
||||||
|
},
|
||||||
|
h4("span", { className: `dsn-dot${dotClass}` }),
|
||||||
|
permissionText
|
||||||
|
),
|
||||||
|
h4("p", { className: "dsn-row-sub" }, permissionNote)
|
||||||
|
),
|
||||||
|
h4("button", {
|
||||||
|
type: "button",
|
||||||
|
className: `dsn-button${supported && permission !== "granted" ? " is-primary" : ""}`,
|
||||||
|
disabled: !supported,
|
||||||
|
onClick: permission === "granted" ? props.testSystem : props.ask
|
||||||
|
}, tr(!supported ? "settings.action.unsupported" : permission === "granted" ? "settings.action.testSystem" : "settings.action.allow"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
h4(
|
||||||
|
"section",
|
||||||
|
{ className: "dsn-group" },
|
||||||
|
h4("h3", { className: "dsn-group-title" }, tr("config.section.status")),
|
||||||
|
h4(
|
||||||
|
"dl",
|
||||||
|
{ className: "dsn-facts" },
|
||||||
|
h4("dt", { className: "dsn-fact-key" }, tr("config.diag.window")),
|
||||||
|
h4(
|
||||||
|
"dd",
|
||||||
|
{ className: "dsn-fact" },
|
||||||
|
h4("p", { className: "dsn-fact-value" }, tr(windowIsAway() ? "config.diag.away" : "config.diag.inFront"))
|
||||||
),
|
),
|
||||||
h4("button", {
|
h4("dt", { className: "dsn-fact-key" }, tr("config.diag.watch")),
|
||||||
type: "button",
|
h4(
|
||||||
className: "dsn-button",
|
"dd",
|
||||||
onClick: props.testAny
|
{ className: "dsn-fact" },
|
||||||
}, tr("settings.action.testAny"))
|
h4("p", {
|
||||||
|
className: `dsn-fact-value${healthFailed ? " is-error" : ""}`,
|
||||||
|
role: healthFailed ? "alert" : "status"
|
||||||
|
}, healthText)
|
||||||
|
),
|
||||||
|
h4("dt", { className: "dsn-fact-key" }, tr("config.diag.last")),
|
||||||
|
h4(
|
||||||
|
"dd",
|
||||||
|
{ className: "dsn-fact" },
|
||||||
|
delivery === null ? h4("p", { className: "dsn-fact-value" }, tr("config.diag.none")) : [
|
||||||
|
h4("p", { key: "line", className: "dsn-fact-value" }, `${delivery.at} · ${delivery.outcome}`),
|
||||||
|
delivery.title === "" ? null : h4("p", { key: "title", className: "dsn-fact-title" }, delivery.title)
|
||||||
|
]
|
||||||
|
),
|
||||||
|
h4("dt", { className: "dsn-fact-key" }, tr("config.diag.replay")),
|
||||||
|
h4(
|
||||||
|
"dd",
|
||||||
|
{ className: "dsn-fact" },
|
||||||
|
h4("p", { className: "dsn-fact-value" }, props.copy.replayValue(props.replayCount(), tr))
|
||||||
|
)
|
||||||
|
),
|
||||||
|
h4(
|
||||||
|
"div",
|
||||||
|
{ className: "dsn-list" },
|
||||||
|
h4(
|
||||||
|
"div",
|
||||||
|
{ className: "dsn-row is-action" },
|
||||||
|
h4("button", {
|
||||||
|
type: "button",
|
||||||
|
className: "dsn-button",
|
||||||
|
onClick: props.testAny
|
||||||
|
}, tr("settings.action.testAny"))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dsh-plugin/session-notify",
|
"name": "@dsh-plugin/session-notify",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "会话完成、需要授权、需要回答时提醒你:窗口不在前台用系统通知,窗口在前台用应用内轻弹窗。",
|
"description": "会话完成、需要授权、需要回答时提醒你:窗口不在前台用系统通知,窗口在前台用应用内轻弹窗。",
|
||||||
|
|||||||
+21
-18
@@ -8,7 +8,8 @@
|
|||||||
/**
|
/**
|
||||||
* Build the copy table for one translate function.
|
* Build the copy table for one translate function.
|
||||||
* @param t - the translate function every string here goes through.
|
* @param t - the translate function every string here goes through.
|
||||||
* @returns `copyFor` (candidate → notice) and the two diagnosis renderers.
|
* @returns `copyFor` (candidate → notice), `deliveryFacts` and `replayValue`
|
||||||
|
* (the two status values the settings page shows).
|
||||||
*/
|
*/
|
||||||
export function createCopy(t) {
|
export function createCopy(t) {
|
||||||
/** Build the delivered copy for one candidate. */
|
/** Build the delivered copy for one candidate. */
|
||||||
@@ -17,6 +18,12 @@ export function createCopy(t) {
|
|||||||
if (candidate.kind === 'completion') {
|
if (candidate.kind === 'completion') {
|
||||||
return { kind: 'completion', title: t('notification.completion'), body: t('body.completion', { title }) }
|
return { kind: 'completion', title: t('notification.completion'), body: t('body.completion', { title }) }
|
||||||
}
|
}
|
||||||
|
// A plan review arrives as a question with its own discriminator, so it is
|
||||||
|
// answered before the question branch below — a plan review says what it is,
|
||||||
|
// rather than repeating the plan text the user has not read yet.
|
||||||
|
if (candidate.pendingKind === 'plan-review') {
|
||||||
|
return { kind: 'question', title: t('notification.question'), body: t('body.planReview', { title }) }
|
||||||
|
}
|
||||||
if (candidate.kind === 'question') {
|
if (candidate.kind === 'question') {
|
||||||
const question = candidate.detail
|
const question = candidate.detail
|
||||||
return {
|
return {
|
||||||
@@ -25,15 +32,6 @@ export function createCopy(t) {
|
|||||||
body: question === '' ? t('body.question', { title }) : `${title} · ${question}`,
|
body: question === '' ? t('body.question', { title }) : `${title} · ${question}`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Kept in v1.0.6's order, which makes this branch unreachable today: the
|
|
||||||
// observer queues a plan review as `kind: 'question'`, so the branch above
|
|
||||||
// already answered with the plan's own text. Restoring the documented copy
|
|
||||||
// (`body.planReview`, "计划正在等待你确认") means testing `pendingKind`
|
|
||||||
// before `kind` — a user-visible behavior change, so it is deliberately NOT
|
|
||||||
// part of this refactor. `tests/unit/copy.test.js` pins today's output.
|
|
||||||
if (candidate.pendingKind === 'plan-review') {
|
|
||||||
return { kind: 'question', title: t('notification.question'), body: t('body.planReview', { title }) }
|
|
||||||
}
|
|
||||||
const tool = candidate.detail
|
const tool = candidate.detail
|
||||||
return {
|
return {
|
||||||
kind: 'approval',
|
kind: 'approval',
|
||||||
@@ -42,9 +40,14 @@ export function createCopy(t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Describe the newest alert's fate in one line. */
|
/**
|
||||||
const describeDelivery = (last, tr) => {
|
* Split the newest delivery into the three facts the status list shows.
|
||||||
if (last === null || last === undefined) return tr('config.diag.none')
|
* @param last - `store.lastDelivery`.
|
||||||
|
* @param tr - the translate function the outcome label is rendered with.
|
||||||
|
* @returns `{ at, outcome, title }`, or null when nothing was ever delivered.
|
||||||
|
*/
|
||||||
|
const deliveryFacts = (last, tr) => {
|
||||||
|
if (last === null || last === undefined) return null
|
||||||
const outcome = last.outcome.startsWith('system-refused')
|
const outcome = last.outcome.startsWith('system-refused')
|
||||||
? tr('config.diag.refused')
|
? tr('config.diag.refused')
|
||||||
: last.outcome === 'system'
|
: last.outcome === 'system'
|
||||||
@@ -56,13 +59,13 @@ export function createCopy(t) {
|
|||||||
: last.outcome === 'replay'
|
: last.outcome === 'replay'
|
||||||
? tr('config.diag.replayDelivery')
|
? tr('config.diag.replayDelivery')
|
||||||
: tr('config.diag.popup')
|
: tr('config.diag.popup')
|
||||||
return `${tr('config.diag.last')}: ${last.at} · ${outcome} · ${last.title}`
|
return { at: last.at, outcome, title: last.title ?? '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Say how many away-channel alerts are still waiting to be replayed in-app. */
|
/** How many away-channel alerts are still waiting for the user to come back. */
|
||||||
const describeReplay = (count, tr) => (
|
const replayValue = (count, tr) => (
|
||||||
count === 0 ? tr('config.diag.replayNone') : tr('config.diag.replay', { count })
|
count === 0 ? tr('config.diag.replayNone') : tr('config.diag.replayValue', { count })
|
||||||
)
|
)
|
||||||
|
|
||||||
return { copyFor, describeDelivery, describeReplay }
|
return { copyFor, deliveryFacts, replayValue }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
import { SETTLE_MS, THROTTLE_MS } from '../constants.js'
|
import { SETTLE_MS, THROTTLE_MS } from '../constants.js'
|
||||||
import { windowIsAway } from '../platform.js'
|
import { windowIsAway } from '../platform.js'
|
||||||
import { isOnScreen, stillWorth } from './session.js'
|
import { isOnScreen, stillOwed } from './session.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the delivery path.
|
* Build the delivery path.
|
||||||
@@ -67,29 +67,33 @@ export function createDelivery({ store, copy, live, toasts, system, replay }) {
|
|||||||
* never actually receives.
|
* never actually receives.
|
||||||
* @param candidate - the alert to deliver.
|
* @param candidate - the alert to deliver.
|
||||||
* @param ignoreThrottle - deliver immediately, bypassing the flood guard.
|
* @param ignoreThrottle - deliver immediately, bypassing the flood guard.
|
||||||
|
* @returns `false` when the flood guard suppressed this alert, `true` when the
|
||||||
|
* delivery path itself ran (including a deliberate skip for the conversation
|
||||||
|
* on screen).
|
||||||
*/
|
*/
|
||||||
const deliver = (candidate, ignoreThrottle) => {
|
const deliver = (candidate, ignoreThrottle) => {
|
||||||
if (ignoreThrottle !== true) {
|
if (ignoreThrottle !== true) {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
if (now - lastDelivery < THROTTLE_MS) return
|
if (now - lastDelivery < THROTTLE_MS) return false
|
||||||
lastDelivery = now
|
lastDelivery = now
|
||||||
}
|
}
|
||||||
if (!windowIsAway()) {
|
if (!windowIsAway()) {
|
||||||
if (isOnScreen(candidate.sessionId, live.list)) return
|
if (isOnScreen(candidate.sessionId, live.list)) return true
|
||||||
toasts.showToast(candidate)
|
toasts.showToast(candidate)
|
||||||
recordDelivery('popup', candidate)
|
recordDelivery('popup', candidate)
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
const result = system.notifySystem(candidate, candidate.test === true)
|
const result = system.notifySystem(candidate, candidate.test === true)
|
||||||
if (result.outcome === 'raised') {
|
if (result.outcome === 'raised') {
|
||||||
recordDelivery('system', candidate, result)
|
recordDelivery('system', candidate, result)
|
||||||
if (candidate.test !== true) replay.holdForReplay(candidate, result)
|
if (candidate.test !== true) replay.holdForReplay(candidate, result)
|
||||||
return
|
return true
|
||||||
}
|
}
|
||||||
// A test alert still has to reach the user, and so does a real one when
|
// A test alert still has to reach the user, and so does a real one when
|
||||||
// the system channel refuses: the popup is the channel that remains.
|
// the system channel refuses: the popup is the channel that remains.
|
||||||
toasts.showToast(candidate)
|
toasts.showToast(candidate)
|
||||||
recordDelivery(`system-refused-${result.outcome}`, candidate)
|
recordDelivery(`system-refused-${result.outcome}`, candidate)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,11 +102,19 @@ export function createDelivery({ store, copy, live, toasts, system, replay }) {
|
|||||||
* One candidate per tick keeps the throttle meaningful, and anything still
|
* One candidate per tick keeps the throttle meaningful, and anything still
|
||||||
* queued arms its own follow-up tick — a burst used to leave every candidate
|
* queued arms its own follow-up tick — a burst used to leave every candidate
|
||||||
* after the first stranded in the queue with no timer to flush it.
|
* after the first stranded in the queue with no timer to flush it.
|
||||||
|
*
|
||||||
|
* A pending interaction the flood guard holds back is put back in the queue
|
||||||
|
* instead of being dropped: only the user can clear it, so it stays owed, and
|
||||||
|
* the next tick retries it. Flood control still drops the completions it was
|
||||||
|
* written for.
|
||||||
*/
|
*/
|
||||||
const flushSettle = () => {
|
const flushSettle = () => {
|
||||||
settleTimer = 0
|
settleTimer = 0
|
||||||
const candidate = pending.shift()
|
const candidate = pending.shift()
|
||||||
if (candidate !== undefined && stillWorth(candidate, live)) deliver(candidate, false)
|
if (candidate !== undefined && stillOwed(candidate, live)) {
|
||||||
|
const delivered = deliver(candidate, false)
|
||||||
|
if (delivered === false && candidate.pendingKind !== '') pending.push(candidate)
|
||||||
|
}
|
||||||
if (pending.length > 0) settleTimer = setTimeout(() => flushSettle(), SETTLE_MS)
|
if (pending.length > 0) settleTimer = setTimeout(() => flushSettle(), SETTLE_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+34
-12
@@ -8,9 +8,13 @@
|
|||||||
import { PENDING_KINDS } from '../constants.js'
|
import { PENDING_KINDS } from '../constants.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discriminate a pending interaction the client published. Only the three
|
* Discriminate a pending interaction the client published.
|
||||||
* domains the Harness itself renders are served; anything else is ignored
|
*
|
||||||
* rather than guessed at.
|
* The domains that can ask the user something are `@deepseek-ai/dsh-client-ui-approval`
|
||||||
|
* (a tool authorisation) and `@deepseek-ai/dsh-client-ui-user-questions` (a
|
||||||
|
* question batch, or the plan review its `planReviewOf` marks); each publishes a
|
||||||
|
* literal `kind` on its pending value. Anything else is ignored rather than
|
||||||
|
* guessed at.
|
||||||
* @param value - `status.pendingInteraction`.
|
* @param value - `status.pendingInteraction`.
|
||||||
* @returns a served kind, or undefined.
|
* @returns a served kind, or undefined.
|
||||||
*/
|
*/
|
||||||
@@ -55,21 +59,39 @@ export function isOnScreen(sessionId, list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether a queued candidate is still worth delivering. Read from the LIVE
|
* Whether a queued candidate is still owed, read from the LIVE snapshot rather
|
||||||
* snapshot rather than the one captured when the transition was seen: a
|
* than the one captured when the transition was seen.
|
||||||
* conversation that resumed in the settle window owes no alert, and the
|
*
|
||||||
* snapshot the transition was derived from still carries the pre-transition
|
* The two triggers are owed for different reasons, so they are checked for
|
||||||
* `running` flag of the session record.
|
* different things:
|
||||||
|
*
|
||||||
|
* - A **pending interaction** (approval, question, plan review) is owed until
|
||||||
|
* the user answers it. It is deliberately NOT gated on the run state: the
|
||||||
|
* session is `running` while it waits — the client's own `observeRunning`
|
||||||
|
* only mirrors `api-session/status` and says nothing about a pending request —
|
||||||
|
* so a running gate would silently drop every approval and question alert.
|
||||||
|
* - A **completion** is owed only while the conversation stayed idle. A
|
||||||
|
* conversation that resumed inside the settle window owes no alert, and the
|
||||||
|
* snapshot the transition was derived from still carries the pre-transition
|
||||||
|
* `running` flag of the session record.
|
||||||
* @param candidate - the alert waiting for its settle tick.
|
* @param candidate - the alert waiting for its settle tick.
|
||||||
* @param live - the freshest `{ list, status }` the observer has seen.
|
* @param live - the freshest `{ list, status }` the observer has seen.
|
||||||
* @returns whether the alert is still owed.
|
* @returns whether the alert is still owed.
|
||||||
*/
|
*/
|
||||||
export function stillWorth(candidate, live) {
|
export function stillOwed(candidate, live) {
|
||||||
|
if (candidate.test === true) return true
|
||||||
|
|
||||||
|
if (candidate.pendingKind !== '') {
|
||||||
|
const sessionStatus = live.status?.get?.(candidate.sessionId)
|
||||||
|
// No status entry contradicts the request, so it is still the user's move.
|
||||||
|
if (sessionStatus === undefined) return true
|
||||||
|
return servedPendingKind(sessionStatus.pendingInteraction) === candidate.pendingKind
|
||||||
|
}
|
||||||
|
|
||||||
const list = live.list
|
const list = live.list
|
||||||
if (candidate.test === true || list === undefined) return true
|
if (list === undefined) return true
|
||||||
const summary = list.byId?.[candidate.sessionId]
|
const summary = list.byId?.[candidate.sessionId]
|
||||||
if (summary === undefined) return true
|
if (summary === undefined) return true
|
||||||
const status = live.status
|
const running = live.status?.get?.(candidate.sessionId)?.running ?? summary.running
|
||||||
const running = status?.get?.(candidate.sessionId)?.running ?? summary.running
|
|
||||||
return running !== true
|
return running !== true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export const en = {
|
|||||||
'config.testAny': 'Test alert',
|
'config.testAny': 'Test alert',
|
||||||
'config.testSystem': 'Test system notification',
|
'config.testSystem': 'Test system notification',
|
||||||
'config.diag.window': 'Window',
|
'config.diag.window': 'Window',
|
||||||
|
'config.diag.watch': 'Session watch',
|
||||||
'config.diag.inFront': 'in front (popup is used)',
|
'config.diag.inFront': 'in front (popup is used)',
|
||||||
'config.diag.away': 'not in front (system notification is used)',
|
'config.diag.away': 'not in front (system notification is used)',
|
||||||
'config.diag.last': 'Last delivery',
|
'config.diag.last': 'Last delivery',
|
||||||
@@ -62,6 +63,7 @@ export const en = {
|
|||||||
'config.diag.replayDelivery': 'in-app popup (replayed when you came back)',
|
'config.diag.replayDelivery': 'in-app popup (replayed when you came back)',
|
||||||
'config.diag.popup': 'in-app popup',
|
'config.diag.popup': 'in-app popup',
|
||||||
'config.diag.refused': 'system channel refused, popup was used instead',
|
'config.diag.refused': 'system channel refused, popup was used instead',
|
||||||
'config.diag.replay': 'waiting for you to come back: {count}',
|
'config.diag.replay': 'Replay',
|
||||||
'config.diag.replayNone': 'nothing waiting to be replayed',
|
'config.diag.replayValue': '{count} waiting',
|
||||||
|
'config.diag.replayNone': 'None',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export const zh = {
|
|||||||
'config.testAny': '测试提醒',
|
'config.testAny': '测试提醒',
|
||||||
'config.testSystem': '测试系统通知',
|
'config.testSystem': '测试系统通知',
|
||||||
'config.diag.window': '窗口状态',
|
'config.diag.window': '窗口状态',
|
||||||
|
'config.diag.watch': '会话监听',
|
||||||
'config.diag.inFront': '在前台(会走轻弹窗)',
|
'config.diag.inFront': '在前台(会走轻弹窗)',
|
||||||
'config.diag.away': '不在前台(会走系统通知)',
|
'config.diag.away': '不在前台(会走系统通知)',
|
||||||
'config.diag.last': '最近一次投递',
|
'config.diag.last': '最近一次投递',
|
||||||
@@ -62,6 +63,7 @@ export const zh = {
|
|||||||
'config.diag.replayDelivery': '应用内轻弹窗(回到窗口时补发)',
|
'config.diag.replayDelivery': '应用内轻弹窗(回到窗口时补发)',
|
||||||
'config.diag.popup': '应用内轻弹窗',
|
'config.diag.popup': '应用内轻弹窗',
|
||||||
'config.diag.refused': '系统通知被拒绝,改用了轻弹窗',
|
'config.diag.refused': '系统通知被拒绝,改用了轻弹窗',
|
||||||
'config.diag.replay': '等你回到窗口时补发:{count} 条',
|
'config.diag.replay': '待补发提醒',
|
||||||
'config.diag.replayNone': '没有待补发的提醒',
|
'config.diag.replayValue': '{count} 条',
|
||||||
|
'config.diag.replayNone': '没有',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,12 @@
|
|||||||
* row's description) and `page` (the whole form). Everything visible here
|
* row's description) and `page` (the whole form). Everything visible here
|
||||||
* belongs to this package, including the platform-specific permission hint.
|
* belongs to this package, including the platform-specific permission hint.
|
||||||
*
|
*
|
||||||
|
* The page is laid out as three groups — what to notify about, the system
|
||||||
|
* channel's own state, and what the plugin is doing right now. Each group keeps
|
||||||
|
* its controls in one place: a list whose rows carry the subject on the left and
|
||||||
|
* the control on the right, and a fact list for the readings, so the status
|
||||||
|
* block is scannable instead of being four sentences in one cell.
|
||||||
|
*
|
||||||
* @module @dsh-plugin/session-notify/client/ui/ConfigSection
|
* @module @dsh-plugin/session-notify/client/ui/ConfigSection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -22,6 +28,7 @@ export function ConfigSection(props) {
|
|||||||
const snapshot = useOwnStore(props.store)
|
const snapshot = useOwnStore(props.store)
|
||||||
const tr = seatTranslator(props, props.fallbackT)
|
const tr = seatTranslator(props, props.fallbackT)
|
||||||
if (props.view === 'summary') return h(React.Fragment, null, tr('settings.description'))
|
if (props.view === 'summary') return h(React.Fragment, null, tr('settings.description'))
|
||||||
|
|
||||||
const permission = snapshot.permission
|
const permission = snapshot.permission
|
||||||
const supported = permission !== 'unsupported'
|
const supported = permission !== 'unsupported'
|
||||||
const failed = permission === 'denied' || snapshot.promptError !== ''
|
const failed = permission === 'denied' || snapshot.promptError !== ''
|
||||||
@@ -32,9 +39,19 @@ export function ConfigSection(props) {
|
|||||||
: supported
|
: supported
|
||||||
? 'settings.permission.default'
|
? 'settings.permission.default'
|
||||||
: 'settings.permission.unsupported'
|
: 'settings.permission.unsupported'
|
||||||
const permissionText = snapshot.promptError === ''
|
const promptFailed = snapshot.promptError !== ''
|
||||||
? `${tr(statusKey)}${permission === 'denied' || !supported ? ` · ${tr(`settings.permission.hint.${props.platform}`)}` : ''}`
|
const permissionText = promptFailed ? snapshot.promptError : tr(statusKey)
|
||||||
: snapshot.promptError
|
const dotClass = permission === 'granted'
|
||||||
|
? ''
|
||||||
|
: failed ? ' is-error' : supported ? ' is-warn' : ' is-muted'
|
||||||
|
const permissionNote = promptFailed
|
||||||
|
? ''
|
||||||
|
: permission === 'denied' || !supported
|
||||||
|
? tr(`settings.permission.hint.${props.platform}`)
|
||||||
|
: permission === 'granted'
|
||||||
|
? tr('config.testHint')
|
||||||
|
: tr('settings.permission.hint.plain')
|
||||||
|
|
||||||
const health = snapshot.health
|
const health = snapshot.health
|
||||||
const healthText = health.state === 'watching'
|
const healthText = health.state === 'watching'
|
||||||
? tr('settings.health.watching')
|
? tr('settings.health.watching')
|
||||||
@@ -44,55 +61,80 @@ export function ConfigSection(props) {
|
|||||||
? tr('settings.health.error', { message: health.message })
|
? tr('settings.health.error', { message: health.message })
|
||||||
: tr('settings.health.starting')
|
: tr('settings.health.starting')
|
||||||
const healthFailed = health.state !== 'watching' && health.state !== 'starting'
|
const healthFailed = health.state !== 'watching' && health.state !== 'starting'
|
||||||
|
|
||||||
|
const delivery = props.copy.deliveryFacts(snapshot.lastDelivery, tr)
|
||||||
|
|
||||||
return h(React.Fragment, null,
|
return h(React.Fragment, null,
|
||||||
h('style', null, CSS),
|
h('style', null, CSS),
|
||||||
h('div', { className: 'dsn-sections' },
|
h('div', { className: 'dsn-page' },
|
||||||
// The page header already shows this bundle's title and description, so
|
// The page header already shows this bundle's title and description, so this
|
||||||
// this section opens with what the header cannot say: how alerts are
|
// lede says what the header cannot: how an alert travels, and that the
|
||||||
// carried, and what this form changes.
|
// channel is chosen at delivery time.
|
||||||
h('section', { className: 'dsn-section' },
|
h('p', { className: 'dsn-lede' }, tr('config.intro')),
|
||||||
h('p', { className: 'dsn-section-desc' }, tr('config.intro'))),
|
|
||||||
h('section', { className: 'dsn-section' },
|
h('section', { className: 'dsn-group' },
|
||||||
h('h3', { className: 'dsn-section-title' }, tr('config.section.kinds')),
|
h('h3', { className: 'dsn-group-title' }, tr('config.section.kinds')),
|
||||||
KINDS.map((kind) => h(KindRow, {
|
h('div', { className: 'dsn-list' },
|
||||||
key: kind,
|
KINDS.map((kind) => h(KindRow, {
|
||||||
label: tr(`settings.kind.${kind}`),
|
key: kind,
|
||||||
checked: snapshot.kinds[kind] === true,
|
label: tr(`settings.kind.${kind}`),
|
||||||
disabled: false,
|
checked: snapshot.kinds[kind] === true,
|
||||||
onToggle: () => props.setKind(kind, snapshot.kinds[kind] !== true),
|
disabled: false,
|
||||||
})),
|
onToggle: () => props.setKind(kind, snapshot.kinds[kind] !== true),
|
||||||
h('p', { className: 'dsn-section-desc' }, tr('config.saveNote'))),
|
}))),
|
||||||
h('section', { className: 'dsn-section' },
|
h('p', { className: 'dsn-group-note' }, tr('config.saveNote'))),
|
||||||
h('h3', { className: 'dsn-section-title' }, tr('config.section.permission')),
|
|
||||||
h('div', { className: 'dsn-row' },
|
h('section', { className: 'dsn-group' },
|
||||||
h('div', { className: 'dsn-row-text' },
|
h('h3', { className: 'dsn-group-title' }, tr('config.section.permission')),
|
||||||
|
h('div', { className: 'dsn-list' },
|
||||||
|
h('div', { className: 'dsn-row' },
|
||||||
|
h('div', { className: 'dsn-row-text' },
|
||||||
|
h('span', {
|
||||||
|
className: 'dsn-state',
|
||||||
|
role: failed ? 'alert' : 'status',
|
||||||
|
},
|
||||||
|
h('span', { className: `dsn-dot${dotClass}` }),
|
||||||
|
permissionText),
|
||||||
|
h('p', { className: 'dsn-row-sub' }, permissionNote)),
|
||||||
|
h('button', {
|
||||||
|
type: 'button',
|
||||||
|
className: `dsn-button${supported && permission !== 'granted' ? ' is-primary' : ''}`,
|
||||||
|
disabled: !supported,
|
||||||
|
onClick: permission === 'granted' ? props.testSystem : props.ask,
|
||||||
|
}, tr(!supported
|
||||||
|
? 'settings.action.unsupported'
|
||||||
|
: permission === 'granted' ? 'settings.action.testSystem' : 'settings.action.allow'))))),
|
||||||
|
|
||||||
|
h('section', { className: 'dsn-group' },
|
||||||
|
h('h3', { className: 'dsn-group-title' }, tr('config.section.status')),
|
||||||
|
h('dl', { className: 'dsn-facts' },
|
||||||
|
h('dt', { className: 'dsn-fact-key' }, tr('config.diag.window')),
|
||||||
|
h('dd', { className: 'dsn-fact' },
|
||||||
|
h('p', { className: 'dsn-fact-value' }, tr(windowIsAway() ? 'config.diag.away' : 'config.diag.inFront'))),
|
||||||
|
h('dt', { className: 'dsn-fact-key' }, tr('config.diag.watch')),
|
||||||
|
h('dd', { className: 'dsn-fact' },
|
||||||
h('p', {
|
h('p', {
|
||||||
className: `dsn-status${failed ? ' dsn-status-error' : ''}`,
|
className: `dsn-fact-value${healthFailed ? ' is-error' : ''}`,
|
||||||
role: failed ? 'alert' : 'status',
|
|
||||||
}, permissionText)),
|
|
||||||
h('button', {
|
|
||||||
type: 'button',
|
|
||||||
className: 'dsn-button',
|
|
||||||
disabled: !supported,
|
|
||||||
onClick: permission === 'granted' ? props.testSystem : props.ask,
|
|
||||||
}, tr(!supported
|
|
||||||
? 'settings.action.unsupported'
|
|
||||||
: permission === 'granted' ? 'settings.action.testSystem' : 'settings.action.allow'))),
|
|
||||||
h('p', { className: 'dsn-section-desc' }, tr('config.testHint'))),
|
|
||||||
h('section', { className: 'dsn-section' },
|
|
||||||
h('h3', { className: 'dsn-section-title' }, tr('config.section.status')),
|
|
||||||
h('div', { className: 'dsn-row' },
|
|
||||||
h('div', { className: 'dsn-row-text' },
|
|
||||||
h('p', { className: 'dsn-status' }, `${tr('config.diag.window')}: ${tr(windowIsAway() ? 'config.diag.away' : 'config.diag.inFront')}`),
|
|
||||||
h('p', {
|
|
||||||
className: `dsn-status${healthFailed ? ' dsn-status-error' : ''}`,
|
|
||||||
role: healthFailed ? 'alert' : 'status',
|
role: healthFailed ? 'alert' : 'status',
|
||||||
}, healthText),
|
}, healthText)),
|
||||||
h('p', { className: 'dsn-status' }, props.copy.describeDelivery(snapshot.lastDelivery, tr)),
|
h('dt', { className: 'dsn-fact-key' }, tr('config.diag.last')),
|
||||||
h('p', { className: 'dsn-status' }, props.copy.describeReplay(props.replayCount(), tr))),
|
h('dd', { className: 'dsn-fact' },
|
||||||
h('button', {
|
delivery === null
|
||||||
type: 'button',
|
? h('p', { className: 'dsn-fact-value' }, tr('config.diag.none'))
|
||||||
className: 'dsn-button',
|
: [
|
||||||
onClick: props.testAny,
|
h('p', { key: 'line', className: 'dsn-fact-value' }, `${delivery.at} · ${delivery.outcome}`),
|
||||||
}, tr('settings.action.testAny'))))))
|
delivery.title === ''
|
||||||
|
? null
|
||||||
|
: h('p', { key: 'title', className: 'dsn-fact-title' }, delivery.title),
|
||||||
|
]),
|
||||||
|
h('dt', { className: 'dsn-fact-key' }, tr('config.diag.replay')),
|
||||||
|
h('dd', { className: 'dsn-fact' },
|
||||||
|
h('p', { className: 'dsn-fact-value' }, props.copy.replayValue(props.replayCount(), tr)))),
|
||||||
|
h('div', { className: 'dsn-list' },
|
||||||
|
h('div', { className: 'dsn-row is-action' },
|
||||||
|
h('button', {
|
||||||
|
type: 'button',
|
||||||
|
className: 'dsn-button',
|
||||||
|
onClick: props.testAny,
|
||||||
|
}, tr('settings.action.testAny')))))))
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-15
@@ -3,11 +3,15 @@
|
|||||||
*
|
*
|
||||||
* The popup copies the shipped toast surface (a fixed entry in the frame-wide
|
* The popup copies the shipped toast surface (a fixed entry in the frame-wide
|
||||||
* overlay, the `--dsw-alias-toast-bg` / `--dsw-alias-toast-label` pair,
|
* overlay, the `--dsw-alias-toast-bg` / `--dsw-alias-toast-label` pair,
|
||||||
* `--dsw-radius-lg`, `--dsw-shadow-lv3`) and adds a title line above the text;
|
* `--dsw-radius-lg`, `--dsw-shadow-lv3`) and adds a title line above the text.
|
||||||
* the switch copies `Switch.module.css` behavior and proportion; the
|
*
|
||||||
* configuration sections follow the Plugin Manager page's own section rhythm
|
* The settings page is a reading order, not a form dump: a lede that says how
|
||||||
* (a column, 32px apart). Class names are renamed under `dsn-`; only the popup
|
* alerts travel, then one group per concern. Inside a group a title introduces a
|
||||||
* glyphs carry their own artwork colors.
|
* list whose rows put the subject on the left and the single control on the
|
||||||
|
* right, with hairlines only between rows; the status group is a two-column fact
|
||||||
|
* list, because four sentences stacked in one cell are not scannable. Class
|
||||||
|
* names are renamed under `dsn-`; only the popup glyphs carry their own artwork
|
||||||
|
* colors.
|
||||||
*
|
*
|
||||||
* A plugin must not import a Harness Client package, so the declarations are
|
* A plugin must not import a Harness Client package, so the declarations are
|
||||||
* this package's own text and reference theme tokens only.
|
* this package's own text and reference theme tokens only.
|
||||||
@@ -34,17 +38,29 @@ export const CSS = `
|
|||||||
.dsn-toast-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-toast-label);opacity:.8;cursor:pointer}
|
.dsn-toast-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-toast-label);opacity:.8;cursor:pointer}
|
||||||
.dsn-toast-close:hover{background:var(--dsw-alias-interactive-bg-hover);opacity:1}
|
.dsn-toast-close:hover{background:var(--dsw-alias-interactive-bg-hover);opacity:1}
|
||||||
.dsn-toast-close:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
.dsn-toast-close:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
||||||
.dsn-sections{display:flex;flex-direction:column;gap:24px}
|
.dsn-page{display:flex;flex-direction:column;gap:28px;max-width:560px}
|
||||||
.dsn-section{display:flex;flex-direction:column;gap:10px}
|
.dsn-lede{margin:0;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px}
|
||||||
.dsn-section-title{margin:0;color:var(--dsw-alias-label-primary);font-size:14px;font-weight:500;line-height:22px}
|
.dsn-group{display:flex;flex-direction:column;gap:2px}
|
||||||
.dsn-section-desc{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
.dsn-group-title{margin:0 0 8px;color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:20px}
|
||||||
.dsn-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 0;border-bottom:.5px solid var(--dsw-alias-border-l2)}
|
.dsn-group-note{margin:8px 0 0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
||||||
.dsn-row:last-child{border-bottom:0}
|
.dsn-list{display:flex;flex-direction:column}
|
||||||
|
.dsn-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 0}
|
||||||
|
.dsn-row+.dsn-row{border-top:.5px solid var(--dsw-alias-border-l2)}
|
||||||
|
.dsn-row.is-action{justify-content:flex-end;padding:12px 0 0}
|
||||||
.dsn-row-text{display:flex;flex-direction:column;gap:2px;min-width:0}
|
.dsn-row-text{display:flex;flex-direction:column;gap:2px;min-width:0}
|
||||||
.dsn-row-title{color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
|
.dsn-row-title{color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
|
||||||
.dsn-row-desc{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
.dsn-row-sub{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}
|
||||||
.dsn-status{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}
|
.dsn-state{display:inline-flex;align-items:center;gap:8px;color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
|
||||||
.dsn-status-error{color:var(--dsw-alias-state-error-primary)}
|
.dsn-dot{flex:none;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-state-success-primary)}
|
||||||
|
.dsn-dot.is-warn{background:var(--dsw-alias-state-warn-label)}
|
||||||
|
.dsn-dot.is-error{background:var(--dsw-alias-state-error-primary)}
|
||||||
|
.dsn-dot.is-muted{background:var(--dsw-alias-border-l3)}
|
||||||
|
.dsn-facts{display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px 14px;margin:0;min-width:0}
|
||||||
|
.dsn-fact-key{margin:0;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;white-space:nowrap}
|
||||||
|
.dsn-fact{display:flex;flex-direction:column;gap:2px;margin:0;min-width:0}
|
||||||
|
.dsn-fact-value{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
||||||
|
.dsn-fact-value.is-error{color:var(--dsw-alias-state-error-primary)}
|
||||||
|
.dsn-fact-title{margin:0;color:var(--dsw-alias-label-primary);font-size:12px;line-height:18px;overflow-wrap:anywhere}
|
||||||
.dsn-switch{box-sizing:border-box;position:relative;flex:0 0 auto;width:36px;height:20px;padding:2px;border:0;border-radius:999px;background:var(--dsw-alias-border-l3);cursor:pointer}
|
.dsn-switch{box-sizing:border-box;position:relative;flex:0 0 auto;width:36px;height:20px;padding:2px;border:0;border-radius:999px;background:var(--dsw-alias-border-l3);cursor:pointer}
|
||||||
.dsn-switch[aria-checked='true']{background:var(--dsw-alias-brand-primary)}
|
.dsn-switch[aria-checked='true']{background:var(--dsw-alias-brand-primary)}
|
||||||
.dsn-switch:disabled{cursor:default;opacity:.5}
|
.dsn-switch:disabled{cursor:default;opacity:.5}
|
||||||
@@ -52,8 +68,10 @@ export const CSS = `
|
|||||||
.dsn-thumb{display:block;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary-foreground);transition:transform 120ms ease}
|
.dsn-thumb{display:block;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary-foreground);transition:transform 120ms ease}
|
||||||
.dsn-switch[aria-checked='false'] .dsn-thumb{background:var(--dsw-alias-switch-thumb)}
|
.dsn-switch[aria-checked='false'] .dsn-thumb{background:var(--dsw-alias-switch-thumb)}
|
||||||
.dsn-switch[aria-checked='true'] .dsn-thumb{transform:translateX(16px)}
|
.dsn-switch[aria-checked='true'] .dsn-thumb{transform:translateX(16px)}
|
||||||
.dsn-button{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:36px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);background:transparent;flex:none}
|
.dsn-button{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:32px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);cursor:pointer;font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary);background:transparent;flex:none}
|
||||||
.dsn-button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
.dsn-button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
||||||
.dsn-button:disabled{cursor:not-allowed;opacity:.4}
|
.dsn-button:disabled{cursor:not-allowed;opacity:.4}
|
||||||
.dsn-button:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
.dsn-button:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
||||||
|
.dsn-button.is-primary{border-color:transparent;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground)}
|
||||||
|
.dsn-button.is-primary:hover:not(:disabled){background:var(--dsw-alias-brand-primary);opacity:.88}
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ test('applying the plugin registers its three seats without touching the DOM', (
|
|||||||
assert.equal(configProps.replayCount(), 0)
|
assert.equal(configProps.replayCount(), 0)
|
||||||
// No locale service in this fake context, so the plugin's own translator falls
|
// No locale service in this fake context, so the plugin's own translator falls
|
||||||
// back to its English dictionary.
|
// back to its English dictionary.
|
||||||
assert.equal(configProps.copy.describeDelivery(null, configProps.fallbackT), 'nothing delivered yet')
|
assert.equal(configProps.copy.deliveryFacts(null, configProps.fallbackT), null)
|
||||||
|
assert.equal(configProps.copy.replayValue(0, configProps.fallbackT), 'None')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the committed artifact is exactly what src/client builds', async (t) => {
|
test('the committed artifact is exactly what src/client builds', async (t) => {
|
||||||
|
|||||||
+82
-22
@@ -1,10 +1,10 @@
|
|||||||
// The components, rendered through a tiny React double.
|
// The components, rendered through a tiny React double.
|
||||||
//
|
//
|
||||||
// Why a double instead of React: this repository ships no runtime dependency at
|
// Why a double instead of React: this repository ships no runtime dependency at
|
||||||
// all, and the whole point of these tests is the wiring the refactor introduced —
|
// all, and the whole point of these tests is the wiring — which component reads
|
||||||
// which component reads which prop through which seat. The double implements the
|
// which prop through which seat. The double implements the four React entry
|
||||||
// four React entry points this package uses, so a component render is exercised
|
// points this package uses, so a component render is exercised end to end (hooks
|
||||||
// end to end (hooks included) without a DOM or a real React.
|
// included) without a DOM or a real React.
|
||||||
//
|
//
|
||||||
// It runs against the BUILT artifact, because that is what the page loads.
|
// It runs against the BUILT artifact, because that is what the page loads.
|
||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
@@ -98,11 +98,23 @@ function walk(node, collected = { text: [], types: [], elements: [] }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const flatten = (node) => walk(node).text.join(' ')
|
const flatten = (node) => walk(node).text.join(' ')
|
||||||
|
const classesOf = (rendered) => rendered.elements.map((element) => element.props.className ?? '')
|
||||||
|
|
||||||
test('the plugin page renders every section with copy, not raw keys', () => {
|
/**
|
||||||
|
* The permission hint the plugin shows on this machine. Node exposes a
|
||||||
|
* `navigator` too, so the platform branch is exercised here rather than falling
|
||||||
|
* through to the neutral copy.
|
||||||
|
*/
|
||||||
|
const HINT_BY_PLATFORM = {
|
||||||
|
win32: 'Windows Settings → System → Notifications → DeepSeek Harness',
|
||||||
|
darwin: 'System Settings → Notifications → DeepSeek Harness',
|
||||||
|
linux: 'Allow DeepSeek Harness in your desktop notification settings (GNOME / KDE)',
|
||||||
|
}
|
||||||
|
const platformHint = HINT_BY_PLATFORM[process.platform] ?? 'Allow DeepSeek Harness in your system notification settings'
|
||||||
|
|
||||||
|
test('the plugin page reads as three groups with copy, not raw keys', () => {
|
||||||
const { config } = mount()
|
const { config } = mount()
|
||||||
const props = { ...config.definition.inject(), view: 'page' }
|
const rendered = walk(config.component({ ...config.definition.inject(), view: 'page' }))
|
||||||
const rendered = walk(config.component(props))
|
|
||||||
const text = rendered.text.join(' ')
|
const text = rendered.text.join(' ')
|
||||||
|
|
||||||
// No locale service in this context, so the seat falls back to English.
|
// No locale service in this context, so the seat falls back to English.
|
||||||
@@ -111,10 +123,14 @@ test('the plugin page renders every section with copy, not raw keys', () => {
|
|||||||
'What to notify about',
|
'What to notify about',
|
||||||
'The switches are stored in this browser',
|
'The switches are stored in this browser',
|
||||||
'System notification permission',
|
'System notification permission',
|
||||||
'The buttons here go straight to the system channel',
|
'This environment cannot show system notifications',
|
||||||
|
platformHint,
|
||||||
'Status',
|
'Status',
|
||||||
|
'Window',
|
||||||
|
'Session watch',
|
||||||
|
'Last delivery',
|
||||||
'nothing delivered yet',
|
'nothing delivered yet',
|
||||||
'nothing waiting to be replayed',
|
'Replay',
|
||||||
'Test alert',
|
'Test alert',
|
||||||
]) {
|
]) {
|
||||||
assert.ok(text.includes(copy), `the page is missing: ${copy}`)
|
assert.ok(text.includes(copy), `the page is missing: ${copy}`)
|
||||||
@@ -122,30 +138,74 @@ test('the plugin page renders every section with copy, not raw keys', () => {
|
|||||||
assert.ok(!text.includes('config.'), 'a raw translation key reached the page')
|
assert.ok(!text.includes('config.'), 'a raw translation key reached the page')
|
||||||
assert.ok(!text.includes('settings.'), 'a raw translation key reached the page')
|
assert.ok(!text.includes('settings.'), 'a raw translation key reached the page')
|
||||||
|
|
||||||
const classes = rendered.elements.map((element) => element.props.className ?? '')
|
const classes = classesOf(rendered)
|
||||||
for (const className of ['dsn-sections', 'dsn-section', 'dsn-section-title', 'dsn-row', 'dsn-button', 'dsn-status']) {
|
for (const className of [
|
||||||
|
'dsn-page',
|
||||||
|
'dsn-lede',
|
||||||
|
'dsn-group',
|
||||||
|
'dsn-group-title',
|
||||||
|
'dsn-group-note',
|
||||||
|
'dsn-list',
|
||||||
|
'dsn-row',
|
||||||
|
'dsn-row-title',
|
||||||
|
'dsn-state',
|
||||||
|
'dsn-facts',
|
||||||
|
'dsn-fact-key',
|
||||||
|
'dsn-fact-value',
|
||||||
|
'dsn-button',
|
||||||
|
]) {
|
||||||
assert.ok(classes.includes(className), `the page is missing .${className}`)
|
assert.ok(classes.includes(className), `the page is missing .${className}`)
|
||||||
}
|
}
|
||||||
|
// Three switches, one status dot, and the readings as key/value pairs.
|
||||||
assert.equal(classes.filter((className) => className === 'dsn-switch').length, 3)
|
assert.equal(classes.filter((className) => className === 'dsn-switch').length, 3)
|
||||||
|
assert.equal(classes.filter((className) => className === 'dsn-dot is-muted').length, 1)
|
||||||
// The live window fact is rendered, not remembered.
|
assert.equal(classes.filter((className) => className === 'dsn-fact-key').length, 4)
|
||||||
assert.match(text, /Window: (in front \(popup is used\)|not in front \(system notification is used\))/)
|
assert.equal(classes.filter((className) => className === 'dsn-fact-value').length, 4)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the page reads the store: switches, permission and diagnostics follow it', () => {
|
test('the page follows the store: switches, permission state and delivery facts', () => {
|
||||||
const { config } = mount()
|
const { config } = mount()
|
||||||
const props = config.definition.inject()
|
const props = config.definition.inject()
|
||||||
|
|
||||||
props.store.set({
|
props.store.set({
|
||||||
...props.store.getSnapshot(),
|
...props.store.getSnapshot(),
|
||||||
kinds: { completion: false, approval: true, question: true },
|
kinds: { completion: false, approval: true, question: true },
|
||||||
|
})
|
||||||
|
const switched = walk(config.component({ ...props, view: 'page' }))
|
||||||
|
assert.deepEqual(
|
||||||
|
switched.elements
|
||||||
|
.filter((element) => element.props.className === 'dsn-switch')
|
||||||
|
.map((element) => element.props['aria-checked']),
|
||||||
|
[false, true, true],
|
||||||
|
)
|
||||||
|
|
||||||
|
props.store.set({
|
||||||
|
...props.store.getSnapshot(),
|
||||||
|
permission: 'granted',
|
||||||
lastDelivery: { outcome: 'system', shown: true, at: '17:52:30', title: 'Conversation finished' },
|
lastDelivery: { outcome: 'system', shown: true, at: '17:52:30', title: 'Conversation finished' },
|
||||||
})
|
})
|
||||||
const rendered = walk(config.component({ ...props, view: 'page' }))
|
const granted = walk(config.component({ ...props, view: 'page' }))
|
||||||
const switches = rendered.elements
|
const grantedClasses = classesOf(granted)
|
||||||
.filter((element) => element.props.className === 'dsn-switch')
|
// A healthy permission has no warning colour and the button becomes the
|
||||||
.map((element) => element.props['aria-checked'])
|
// channel-specific test.
|
||||||
assert.deepEqual(switches, [false, true, true])
|
assert.equal(grantedClasses.includes('dsn-dot is-muted'), false)
|
||||||
assert.match(rendered.text.join(' '), /Last delivery: 17:52:30 · system notification \(confirmed on screen\) · Conversation finished/)
|
assert.equal(grantedClasses.includes('dsn-dot is-error'), false)
|
||||||
|
assert.ok(grantedClasses.includes('dsn-dot'))
|
||||||
|
assert.ok(granted.text.join(' ').includes('Test system notification'))
|
||||||
|
assert.ok(granted.text.join(' ').includes('17:52:30 · system notification (confirmed on screen)'))
|
||||||
|
assert.ok(grantedClasses.includes('dsn-fact-title'))
|
||||||
|
|
||||||
|
props.store.set({
|
||||||
|
...props.store.getSnapshot(),
|
||||||
|
permission: 'denied',
|
||||||
|
lastDelivery: null,
|
||||||
|
})
|
||||||
|
const denied = walk(config.component({ ...props, view: 'page' }))
|
||||||
|
const deniedText = denied.text.join(' ')
|
||||||
|
assert.ok(classesOf(denied).includes('dsn-dot is-error'))
|
||||||
|
assert.ok(deniedText.includes('switched off in system settings'))
|
||||||
|
assert.ok(deniedText.includes(platformHint))
|
||||||
|
assert.ok(deniedText.includes('nothing delivered yet'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the summary view is the one-line description the plugin row shows', () => {
|
test('the summary view is the one-line description the plugin row shows', () => {
|
||||||
@@ -169,7 +229,7 @@ test('the popup stack renders nothing while empty, and one card per alert', () =
|
|||||||
assert.ok(text.includes('Bash is waiting for your approval'))
|
assert.ok(text.includes('Bash is waiting for your approval'))
|
||||||
assert.ok(text.includes('View'))
|
assert.ok(text.includes('View'))
|
||||||
|
|
||||||
const classes = rendered.elements.map((element) => element.props.className ?? '')
|
const classes = classesOf(rendered)
|
||||||
for (const className of ['dsn-stack', 'dsn-toast', 'dsn-toast-icon is-approval', 'dsn-toast-title', 'dsn-toast-desc', 'dsn-toast-action', 'dsn-toast-close']) {
|
for (const className of ['dsn-stack', 'dsn-toast', 'dsn-toast-icon is-approval', 'dsn-toast-title', 'dsn-toast-desc', 'dsn-toast-action', 'dsn-toast-close']) {
|
||||||
assert.ok(classes.includes(className), `the popup is missing .${className}`)
|
assert.ok(classes.includes(className), `the popup is missing .${className}`)
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-35
@@ -8,7 +8,7 @@ import { createCopy } from '../../src/client/core/copy.js'
|
|||||||
import { createTranslator } from '../../src/client/i18n/index.js'
|
import { createTranslator } from '../../src/client/i18n/index.js'
|
||||||
|
|
||||||
const t = createTranslator({ getSnapshot: () => ({ active: 'zh' }) })
|
const t = createTranslator({ getSnapshot: () => ({ active: 'zh' }) })
|
||||||
const { copyFor, describeDelivery, describeReplay } = createCopy(t)
|
const { copyFor, deliveryFacts, replayValue } = createCopy(t)
|
||||||
|
|
||||||
/** One trigger candidate with every field a caller may leave empty. */
|
/** One trigger candidate with every field a caller may leave empty. */
|
||||||
function candidate(overrides) {
|
function candidate(overrides) {
|
||||||
@@ -41,47 +41,42 @@ test('an approval without a tool name still says what is happening', () => {
|
|||||||
assert.equal(notice.body, '标题:有工具正在等待你的授权')
|
assert.equal(notice.body, '标题:有工具正在等待你的授权')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('a question carries the question text, and a plan review the plan\'s own text', () => {
|
test('a question carries the question text', () => {
|
||||||
const question = copyFor(candidate({ kind: 'question', pendingKind: 'question', detail: '要继续吗?' }))
|
assert.deepEqual(
|
||||||
assert.deepEqual(question, { kind: 'question', title: '需要回答', body: '标题 · 要继续吗?' })
|
copyFor(candidate({ kind: 'question', pendingKind: 'question', detail: '要继续吗?' })),
|
||||||
|
{ kind: 'question', title: '需要回答', body: '标题 · 要继续吗?' },
|
||||||
|
)
|
||||||
assert.equal(copyFor(candidate({ kind: 'question', pendingKind: 'question', detail: '' })).body, '标题:正在等待你的回答')
|
assert.equal(copyFor(candidate({ kind: 'question', pendingKind: 'question', detail: '' })).body, '标题:正在等待你的回答')
|
||||||
|
})
|
||||||
|
|
||||||
// v1.0.6 behavior, pinned on purpose: a plan review is queued with
|
test('a plan review says what it is instead of repeating the plan text', () => {
|
||||||
// `kind: 'question'`, so the question branch above answers it and the
|
// A plan review arrives as `kind: 'question'` with its own discriminator, so the
|
||||||
// `body.planReview` copy is unreachable. See the note in core/copy.js — fixing
|
// discriminator has to be read first — otherwise the plan-review copy is unreachable.
|
||||||
// it changes what a plan review says, so it is not part of this refactor.
|
const review = copyFor(candidate({ kind: 'question', pendingKind: 'plan-review', detail: '计划正文…' }))
|
||||||
const review = copyFor(candidate({ kind: 'question', pendingKind: 'plan-review', detail: '' }))
|
|
||||||
assert.equal(review.kind, 'question')
|
assert.equal(review.kind, 'question')
|
||||||
assert.equal(review.body, '标题:正在等待你的回答')
|
assert.equal(review.body, '标题:计划正在等待你确认')
|
||||||
assert.notEqual(review.body, t('body.planReview', { title: '标题' }))
|
assert.equal(review.title, '需要回答')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('a delivery that never happened is described as such', () => {
|
test('a delivery that never happened has no facts to show', () => {
|
||||||
assert.equal(describeDelivery(null, t), '还没有投递过')
|
assert.equal(deliveryFacts(null, t), null)
|
||||||
assert.equal(describeDelivery(undefined, t), '还没有投递过')
|
assert.equal(deliveryFacts(undefined, t), null)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the newest delivery is described by channel, confirmation and local time', () => {
|
test('the newest delivery is split into time, channel and what it was', () => {
|
||||||
const system = describeDelivery({ outcome: 'system', shown: true, at: '17:52:30', title: '会话已完成' }, t)
|
assert.deepEqual(
|
||||||
assert.equal(system, '最近一次投递: 17:52:30 · 系统通知(系统已确认弹出) · 会话已完成')
|
deliveryFacts({ outcome: 'system', shown: true, at: '17:52:30', title: '会话已完成' }, t),
|
||||||
|
{ at: '17:52:30', outcome: '系统通知(系统已确认弹出)', title: '会话已完成' },
|
||||||
const unconfirmed = describeDelivery({ outcome: 'system', shown: undefined, at: '17:52:30', title: 'X' }, t)
|
)
|
||||||
assert.match(unconfirmed, /系统没有回报/)
|
assert.equal(deliveryFacts({ outcome: 'system', shown: undefined, at: '1:00:00', title: 'X' }, t).outcome, '系统通知(系统没有回报,回到窗口时补发轻弹窗)')
|
||||||
|
assert.equal(deliveryFacts({ outcome: 'system', shown: false, at: '1:00:00', title: 'X' }, t).outcome, '系统通知没弹出来,回到窗口时补发轻弹窗')
|
||||||
const refused = describeDelivery({ outcome: 'system', shown: false, at: '17:52:30', title: 'X' }, t)
|
assert.equal(deliveryFacts({ outcome: 'system-refused-threw', at: '1:00:00', title: 'X' }, t).outcome, '系统通知被拒绝,改用了轻弹窗')
|
||||||
assert.match(refused, /没弹出来/)
|
assert.equal(deliveryFacts({ outcome: 'replay', at: '1:00:00', title: 'X' }, t).outcome, '应用内轻弹窗(回到窗口时补发)')
|
||||||
|
assert.equal(deliveryFacts({ outcome: 'popup', at: '1:00:00', title: 'X' }, t).outcome, '应用内轻弹窗')
|
||||||
const fellBack = describeDelivery({ outcome: 'system-refused-threw', shown: undefined, at: '17:52:30', title: 'X' }, t)
|
assert.equal(deliveryFacts({ outcome: 'popup', at: '1:00:00', title: undefined }, t).title, '')
|
||||||
assert.match(fellBack, /系统通知被拒绝,改用了轻弹窗/)
|
|
||||||
|
|
||||||
const replayed = describeDelivery({ outcome: 'replay', at: '17:52:30', title: 'X' }, t)
|
|
||||||
assert.match(replayed, /应用内轻弹窗(回到窗口时补发)/)
|
|
||||||
|
|
||||||
const popup = describeDelivery({ outcome: 'popup', at: '17:52:30', title: 'X' }, t)
|
|
||||||
assert.match(popup, /· 应用内轻弹窗 ·/)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('the replay line counts what is still waiting', () => {
|
test('the replay value is short enough for one status line', () => {
|
||||||
assert.equal(describeReplay(0, t), '没有待补发的提醒')
|
assert.equal(replayValue(0, t), '没有')
|
||||||
assert.equal(describeReplay(3, t), '等你回到窗口时补发:3 条')
|
assert.equal(replayValue(3, t), '3 条')
|
||||||
})
|
})
|
||||||
|
|||||||
+39
-11
@@ -9,11 +9,14 @@ import {
|
|||||||
preview,
|
preview,
|
||||||
questionText,
|
questionText,
|
||||||
servedPendingKind,
|
servedPendingKind,
|
||||||
stillWorth,
|
stillOwed,
|
||||||
titleOf,
|
titleOf,
|
||||||
} from '../../src/client/core/session.js'
|
} from '../../src/client/core/session.js'
|
||||||
|
|
||||||
test('only the three interaction kinds the Harness renders are served', () => {
|
test('only the three interaction kinds the domains publish are served', () => {
|
||||||
|
// The literals the shipped domains publish: dsh-client-ui-approval sets
|
||||||
|
// `kind = "approval"`, dsh-client-ui-user-questions picks between `"question"`
|
||||||
|
// and `"plan-review"` for one batch.
|
||||||
assert.equal(servedPendingKind({ kind: 'approval' }), 'approval')
|
assert.equal(servedPendingKind({ kind: 'approval' }), 'approval')
|
||||||
assert.equal(servedPendingKind({ kind: 'question' }), 'question')
|
assert.equal(servedPendingKind({ kind: 'question' }), 'question')
|
||||||
assert.equal(servedPendingKind({ kind: 'plan-review' }), 'plan-review')
|
assert.equal(servedPendingKind({ kind: 'plan-review' }), 'plan-review')
|
||||||
@@ -58,17 +61,42 @@ test('the conversation on screen is the one the main view retains', () => {
|
|||||||
assert.equal(isOnScreen('a', undefined), false)
|
assert.equal(isOnScreen('a', undefined), false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('a queued alert is dropped when its conversation resumed inside the settle window', () => {
|
test('a pending interaction stays owed while it waits, even though the run is still running', () => {
|
||||||
const candidate = { kind: 'completion', sessionId: 'a', test: false }
|
// The session is `running` whenever the agent loop is active, and a pending
|
||||||
|
// approval or question is exactly that: the loop is waiting for the human. The
|
||||||
|
// run state must therefore not gate these alerts — it used to drop every one
|
||||||
|
// of them, which is why only completions ever reached the user.
|
||||||
|
const candidate = { kind: 'approval', sessionId: 'a', pendingKind: 'approval', test: false }
|
||||||
|
const status = (pendingInteraction, running) => new Map([['a', { pendingInteraction, running }]])
|
||||||
|
|
||||||
|
assert.equal(stillOwed(candidate, { list: { byId: { a: { running: true } } }, status: status({ kind: 'approval' }, true) }), true)
|
||||||
|
assert.equal(stillOwed(candidate, { list: { byId: { a: { running: false } } }, status: status({ kind: 'approval' }, false) }), true)
|
||||||
|
// Answered inside the settle window: the request is gone, so nothing is owed.
|
||||||
|
assert.equal(stillOwed(candidate, { list: { byId: { a: { running: true } } }, status: status(undefined, true) }), false)
|
||||||
|
// Replaced by a different request of the same kind: a new request is a new alert.
|
||||||
|
assert.equal(stillOwed({ ...candidate, kind: 'question', pendingKind: 'question' }, { list: { byId: {} }, status: status({ kind: 'approval' }, true) }), false)
|
||||||
|
// A plan review is owed on its own discriminator.
|
||||||
|
assert.equal(stillOwed({ ...candidate, kind: 'question', pendingKind: 'plan-review' }, { list: { byId: {} }, status: status({ kind: 'plan-review' }, true) }), true)
|
||||||
|
// Nothing contradicts the request, so it is still the user's move.
|
||||||
|
assert.equal(stillOwed(candidate, { list: { byId: {} }, status: new Map() }), true)
|
||||||
|
assert.equal(stillOwed(candidate, { list: undefined, status: undefined }), true)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('a completion is owed only while the conversation stayed idle', () => {
|
||||||
|
const candidate = { kind: 'completion', sessionId: 'a', pendingKind: '', test: false }
|
||||||
const live = (byId, status) => ({ list: { byId }, status })
|
const live = (byId, status) => ({ list: { byId }, status })
|
||||||
|
|
||||||
assert.equal(stillWorth(candidate, { list: undefined, status: undefined }), true)
|
assert.equal(stillOwed(candidate, { list: undefined, status: undefined }), true)
|
||||||
assert.equal(stillWorth(candidate, live({ a: { running: false } })), true)
|
assert.equal(stillOwed(candidate, live({ a: { running: false } })), true)
|
||||||
assert.equal(stillWorth(candidate, live({})), true)
|
assert.equal(stillOwed(candidate, live({})), true)
|
||||||
assert.equal(stillWorth(candidate, live({ a: { running: true } })), false)
|
assert.equal(stillOwed(candidate, live({ a: { running: true } })), false)
|
||||||
// The per-session selector wins over the list summary, which still carries the
|
// The per-session selector wins over the list summary, which still carries the
|
||||||
// pre-transition flag.
|
// pre-transition flag.
|
||||||
assert.equal(stillWorth(candidate, { list: { byId: { a: { running: true } } }, status: new Map([['a', { running: false }]]) }), true)
|
assert.equal(stillOwed(candidate, { list: { byId: { a: { running: true } } }, status: new Map([['a', { running: false }]]) }), true)
|
||||||
// A test alert is owed no matter what the live state says.
|
})
|
||||||
assert.equal(stillWorth({ ...candidate, test: true }, live({ a: { running: true } })), true)
|
|
||||||
|
test('a test alert is always owed', () => {
|
||||||
|
const live = { list: { byId: { a: { running: true } } }, status: new Map([['a', { running: true }]]) }
|
||||||
|
assert.equal(stillOwed({ kind: 'completion', sessionId: 'a', pendingKind: '', test: true }, live), true)
|
||||||
|
assert.equal(stillOwed({ kind: 'approval', sessionId: 'a', pendingKind: 'approval', test: true }, live), true)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user