@lynn123411/dsh-notify-user 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/cordis.patch.yml +0 -8
- package/lib/client.js +280 -103
- package/lib/client.js.map +3 -3
- package/lib/index.js +1 -2
- package/lib/index.js.map +2 -2
- package/package.json +28 -28
package/README.md
CHANGED
|
@@ -24,13 +24,13 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
24
24
|
|
|
25
25
|
一个会话开不开由 `enabledFor(sessionOverrides, defaultEnabled, sessionId)` 回答:会话有自己的记录就用它,否则用默认值。判定是纯函数,宿主与浏览器两半边共用 `src/shared/config.ts` 里那一份。
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
会话选择保存在插件配置的 `sessionOverrides` 字典里。会话继承配置中已有的该会话值,缺省时使用 `defaultEnabled`。切回继承值会移除这次设置的覆盖。
|
|
28
28
|
|
|
29
29
|
关掉之后两处一起变:催办状态机不催,计数一并清零,重新打开从零开始;`notify_user` 用 `ctx.tools.register(def, { when })` 按会话收放,关掉的会话在这一步的声明与派发里都没有它。
|
|
30
30
|
|
|
31
31
|
子代理会话没有汇报工具和催办,也不显示这个开关。判定同时看当前会话快照的 `subagent` 与会话列表里的 `origin`。
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
点开关会立即显示所选值,当前会话的开关在保存期间暂时禁用。每次保存只改当前会话。另一处先改了其他会话时,插件用新的配置修订号再尝试一次。保存失败时,开关恢复为宿主上的值并提示重试。
|
|
34
34
|
|
|
35
35
|
## 配置
|
|
36
36
|
|
|
@@ -39,8 +39,8 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
39
39
|
| 字段 | 默认 | 范围 | 说明 |
|
|
40
40
|
| --- | --- | --- | --- |
|
|
41
41
|
| `defaultEnabled` | true | 布尔 | 会话没有自己的选择时,主动汇报开不开。 |
|
|
42
|
-
| `sessionOverrides` | `{}` | 会话 id → 布尔 |
|
|
43
|
-
| `nudgeAfter` | 10 | 0–100 |
|
|
42
|
+
| `sessionOverrides` | `{}` | 会话 id → 布尔 | 按会话覆盖继承值。 |
|
|
43
|
+
| `nudgeAfter` | 10 | 0–100 | 配置页的催办阈值接受 1–100 次根工具调用。关闭「催办提醒」写入 0,仍可主动汇报。重新打开后从默认的 10 次开始。 |
|
|
44
44
|
| `resetOnProse` | true | 布尔 | 助手消息里写了正文就清零计数。 |
|
|
45
45
|
| `collapsible` | true | 布尔 | 卡片带不带折叠键;关掉后正文始终展开。 |
|
|
46
46
|
| `summaryOnly` | false | 布尔 | 模型只写一行标题,卡片只显示标题行。 |
|
|
@@ -51,6 +51,8 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
|
|
|
51
51
|
|
|
52
52
|
配置卡把 `summaryOnly` 画成「结构化正文 / 只报摘要」两选一,把 `collapsible` 与 `bodyExpandedByDefault` 合成「始终展开 / 默认收起 / 默认展开」三选一,把 `showTime` 画成一个开关;只报摘要时「正文显示」整行不出现,改出现「摘要呈现」,摘要按散文渲染时根本不画卡片,「显示时间」整行随之不出现。
|
|
53
53
|
|
|
54
|
+
催办阈值在按 Enter 或离开输入框时保存。如果保存失败,输入会保留。再次进入输入框后按 Enter 或离开,即可重试同一个值。
|
|
55
|
+
|
|
54
56
|
字段都标了 `.volatile()`:改它们不重挂这条 loader entry。催办状态机每次 `pre-step` 现读 `nudgeAfter`、`summaryOnly` 与 `defaultEnabled`/`sessionOverrides`;浏览器用宿主下发的同步配置引用决定进度卡的位置、汇报形态、展开方式和时间显示。配置页与会话开关通过配置表单读写。
|
|
55
57
|
|
|
56
58
|
宿主没服务这份配置时卡片整块不出现。插件同时用 `ctx.settings.configure({ auto: false })` 关掉内核按 schema 自动生成的那份设置页。
|
|
@@ -149,9 +151,9 @@ cd plugins/dsh-notify-user && pnpm check
|
|
|
149
151
|
- `smoke-host.mjs`:真 cordis + 真 `ToolRuntime`,断言配置形状、工具注册与执行、装配行,以及催办接线在真 `ctx.waterfall` 下的行为(满阈值注入、汇报/散文/新回合/用户插话/阈值 0 清零、只有思考块不清零、失败尝试不清零、散文开关关掉不清零、上下文注入不清零、PTC 子调用不计数、嵌套汇报清零、子代理不注入、下游拒绝时不追加),以及按会话开关、零阈值仍可汇报,以及直接和 PTC 调用失败后保留计数、重试成功后清零。
|
|
150
152
|
- `smoke-client.mjs`:按 Web shell 方式装载浏览器 bundle,断言对话节点定义、位置切换会重挂定义、四处座位注册(进度卡、跟随工具行、菜单开关、配置卡)、同步展示配置、字典键集与「未声明服务读取会抛」的守卫。
|
|
151
153
|
- `test-nudge.mjs`:催办状态机的纯逻辑(阈值、四条清零路径、阈值与散文开关现读、按会话隔离、散文判定、开关关掉时不催且计数清零)。
|
|
152
|
-
- `test-config.mjs
|
|
153
|
-
- `test-render.mjs
|
|
154
|
-
- `test-card.mjs
|
|
154
|
+
- `test-config.mjs` 验证按会话开关的纯逻辑,包括默认值、会话选择优先,以及忽略无效值与原型属性。
|
|
155
|
+
- `test-render.mjs` 用 React 和 jsdom 验证会话开关的继承规则、不同会话并发保存、修订号冲突、失败回退、保存期间禁用和可见条件。
|
|
156
|
+
- `test-card.mjs` 用 React 和 jsdom 验证进度卡与配置卡,包括阈值保存失败后的草稿与重试、并发编辑、摘要与正文呈现、默认展开和宿主错误提示。
|
|
155
157
|
- `test-row-model.mjs`:进度卡数据视图的三条来路(`meta` / PTC 参数 / start 参数)与标题回退。
|
|
156
158
|
- `test-notify-node.mjs`:对话节点定义的认领范围、节点位置与卡片数据(原生调用、结果落定、流式增量与块结束、PTC 子调用、直接调用失败、PTC 失败交给原生行、结果先到、没有正文时的兜底)。
|
|
157
159
|
- `assert-lib-untracked.mjs`:`lib/` 是构建镜像,不入 git。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
# @lynn123411/dsh-notify-user bundle patch
|
|
2
|
-
# 声明在 package.json 的 dsh.bundle.patch,`dsh plugin --profile web add` 后自动并入 profile 层栈。
|
|
3
|
-
#
|
|
4
|
-
# 这一条 insert 行同时承载两个半边(见 docs/rules/client-wiring.md):
|
|
5
|
-
# - 宿主半边:在那条行下注册插件本体(上面 src/index.ts 的 apply)。行在 root 层,
|
|
6
|
-
# 所以它落进全局层;要收窄到某个 preset,就在 preset 的 config.plugins 里另注册一行。
|
|
7
|
-
# - 浏览器半边:这条行是 root loader entry,dsh-client-modules 只对 root loader 的
|
|
8
|
-
# enabled entry 依据 dsh.client 声明服务浏览器半边(lib/client.js)。
|
|
9
1
|
- insert:
|
|
10
2
|
- id: dsh-notify-user
|
|
11
3
|
name: '@lynn123411/dsh-notify-user'
|
package/lib/client.js
CHANGED
|
@@ -44,21 +44,9 @@ var CARD_PLACEMENTS = ["boundary", "inline"];
|
|
|
44
44
|
var DEFAULT_CARD_PLACEMENT = "boundary";
|
|
45
45
|
var DEFAULT_ENABLED = true;
|
|
46
46
|
function enabledFor(overrides, fallback, sessionId) {
|
|
47
|
-
const explicit = overrides
|
|
47
|
+
const explicit = overrides !== void 0 && Object.hasOwn(overrides, sessionId) ? overrides[sessionId] : void 0;
|
|
48
48
|
return typeof explicit === "boolean" ? explicit : fallback;
|
|
49
49
|
}
|
|
50
|
-
function overridesAfterWrite(overrides, sessionId, enabled, fallback) {
|
|
51
|
-
const current = overrides ?? {};
|
|
52
|
-
const hasEntry = Object.hasOwn(current, sessionId);
|
|
53
|
-
if (enabled === fallback) {
|
|
54
|
-
if (!hasEntry) return current;
|
|
55
|
-
const next = { ...current };
|
|
56
|
-
delete next[sessionId];
|
|
57
|
-
return next;
|
|
58
|
-
}
|
|
59
|
-
if (hasEntry && current[sessionId] === enabled) return current;
|
|
60
|
-
return { ...current, [sessionId]: enabled };
|
|
61
|
-
}
|
|
62
50
|
|
|
63
51
|
// src/client/ConfigCard.tsx
|
|
64
52
|
var import_react = require("react");
|
|
@@ -71,6 +59,37 @@ var MODEL_OPTIONS_SLOT = "conversation.input.model.options";
|
|
|
71
59
|
function isRecord(value) {
|
|
72
60
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73
61
|
}
|
|
62
|
+
var writeQueues = /* @__PURE__ */ new WeakMap();
|
|
63
|
+
function enqueueConfigWrite(form, operation) {
|
|
64
|
+
const task = (writeQueues.get(form) ?? Promise.resolve()).then(operation);
|
|
65
|
+
writeQueues.set(form, task.catch(() => false));
|
|
66
|
+
return task;
|
|
67
|
+
}
|
|
68
|
+
function sessionOverride(section, sessionId) {
|
|
69
|
+
const overrides = isRecord(section) ? section["sessionOverrides"] : void 0;
|
|
70
|
+
return isRecord(overrides) && Object.hasOwn(overrides, sessionId) ? overrides[sessionId] : void 0;
|
|
71
|
+
}
|
|
72
|
+
function mutateSessionEnabled(form, snapshot, sessionId, enabled) {
|
|
73
|
+
const config = decodeConfig(snapshot.value);
|
|
74
|
+
const inherited = sessionOverride(snapshot.base, sessionId);
|
|
75
|
+
const path = ["sessionOverrides", sessionId];
|
|
76
|
+
const op = enabled === (typeof inherited === "boolean" ? inherited : config.defaultEnabled) ? { op: "unset", path } : { op: "set", path, value: enabled };
|
|
77
|
+
return form.mutate([op], snapshot.revision);
|
|
78
|
+
}
|
|
79
|
+
function writeSessionEnabled(form, sessionId, enabled) {
|
|
80
|
+
return enqueueConfigWrite(form, async () => {
|
|
81
|
+
const snapshot = form.getSnapshot();
|
|
82
|
+
if (snapshot.status !== "ready") return false;
|
|
83
|
+
if (await mutateSessionEnabled(form, snapshot, sessionId, enabled)) return true;
|
|
84
|
+
const latest = form.getSnapshot();
|
|
85
|
+
if (latest.status !== "ready" || latest.revision === snapshot.revision) return false;
|
|
86
|
+
const config = decodeConfig(latest.value);
|
|
87
|
+
const currentOverride = sessionOverride(latest.value, sessionId);
|
|
88
|
+
if ((typeof currentOverride === "boolean" ? currentOverride : config.defaultEnabled) === enabled) return true;
|
|
89
|
+
if (sessionOverride(latest.user, sessionId) !== sessionOverride(snapshot.user, sessionId)) return false;
|
|
90
|
+
return mutateSessionEnabled(form, latest, sessionId, enabled);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
74
93
|
var DEFAULT_CLIENT_CONFIG = {
|
|
75
94
|
nudgeAfter: DEFAULT_NUDGE_AFTER,
|
|
76
95
|
resetOnProse: DEFAULT_RESET_ON_PROSE,
|
|
@@ -91,10 +110,12 @@ function readOverrides(value) {
|
|
|
91
110
|
}
|
|
92
111
|
return overrides;
|
|
93
112
|
}
|
|
94
|
-
function readConfig(
|
|
95
|
-
const snapshot = form.getSnapshot();
|
|
113
|
+
function readConfig(snapshot) {
|
|
96
114
|
if (snapshot.status === "unavailable") return void 0;
|
|
97
|
-
|
|
115
|
+
return decodeConfig(snapshot.value);
|
|
116
|
+
}
|
|
117
|
+
function decodeConfig(section) {
|
|
118
|
+
const value = isRecord(section) ? section : {};
|
|
98
119
|
const rawThreshold = value["nudgeAfter"];
|
|
99
120
|
const nudgeAfter = typeof rawThreshold === "number" && Number.isFinite(rawThreshold) ? Math.min(MAX_NUDGE_AFTER, Math.max(0, Math.floor(rawThreshold))) : DEFAULT_CLIENT_CONFIG.nudgeAfter;
|
|
100
121
|
const rawResetOnProse = value["resetOnProse"];
|
|
@@ -138,6 +159,21 @@ function bodyModeOf(config) {
|
|
|
138
159
|
if (!config.collapsible) return "always";
|
|
139
160
|
return config.bodyExpandedByDefault ? "expanded" : "collapsed";
|
|
140
161
|
}
|
|
162
|
+
function parseThreshold(text) {
|
|
163
|
+
const value = Number(text);
|
|
164
|
+
return Number.isInteger(value) && value >= 1 && value <= MAX_NUDGE_AFTER ? value : void 0;
|
|
165
|
+
}
|
|
166
|
+
function writeThreshold(form, next) {
|
|
167
|
+
return enqueueConfigWrite(form, async () => {
|
|
168
|
+
const snapshot = form.getSnapshot();
|
|
169
|
+
if (snapshot.status !== "ready") return false;
|
|
170
|
+
const current = readConfig(snapshot)?.nudgeAfter;
|
|
171
|
+
if (current === void 0 || current === 0) return false;
|
|
172
|
+
return current === next || await form.mutate([
|
|
173
|
+
{ op: "set", path: ["nudgeAfter"], value: next }
|
|
174
|
+
], snapshot.revision);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
141
177
|
function ChoiceGroup({ label, options, value, onSelect }) {
|
|
142
178
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-field", role: "group", "aria-label": label, children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
143
179
|
import_dsh_client_ui_primitives.Pill,
|
|
@@ -154,74 +190,70 @@ function ChoiceGroup({ label, options, value, onSelect }) {
|
|
|
154
190
|
}
|
|
155
191
|
function ConfigCard(props) {
|
|
156
192
|
const { form, t } = props;
|
|
157
|
-
const [config, setConfig] = (0, import_react.useState)(() => readConfig(form));
|
|
158
|
-
const [
|
|
193
|
+
const [config, setConfig] = (0, import_react.useState)(() => readConfig(form.getSnapshot()));
|
|
194
|
+
const [draft, setDraft] = (0, import_react.useState)();
|
|
159
195
|
const [error, setError] = (0, import_react.useState)(null);
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
setError(null);
|
|
173
|
-
} catch {
|
|
174
|
-
setError(t("config.write.failed"));
|
|
175
|
-
}
|
|
176
|
-
});
|
|
196
|
+
const [bodyModeDraft, setBodyModeDraft] = (0, import_react.useState)();
|
|
197
|
+
const draftRef = (0, import_react.useRef)(void 0);
|
|
198
|
+
const updateDraft = (next) => {
|
|
199
|
+
draftRef.current = next;
|
|
200
|
+
setDraft(next);
|
|
201
|
+
};
|
|
202
|
+
const enqueue = async (operation) => {
|
|
203
|
+
const accepted = await enqueueConfigWrite(form, operation).catch(() => false);
|
|
204
|
+
setError(accepted ? null : t("config.write.failed"));
|
|
177
205
|
};
|
|
178
206
|
(0, import_react.useEffect)(() => {
|
|
179
207
|
const sync = () => {
|
|
180
|
-
const next = readConfig(form);
|
|
208
|
+
const next = readConfig(form.getSnapshot());
|
|
181
209
|
setConfig(next);
|
|
182
|
-
if (next !== void 0)
|
|
210
|
+
if (next?.nudgeAfter === 0 && draftRef.current !== void 0) {
|
|
211
|
+
draftRef.current = void 0;
|
|
212
|
+
setDraft(void 0);
|
|
213
|
+
}
|
|
183
214
|
};
|
|
184
215
|
sync();
|
|
185
216
|
return form.subscribe(sync);
|
|
186
217
|
}, [form]);
|
|
187
|
-
(0, import_react.useEffect)(() => {
|
|
188
|
-
draftRef.current = text;
|
|
189
|
-
}, [text]);
|
|
190
|
-
(0, import_react.useEffect)(() => {
|
|
191
|
-
committedRef.current = config?.nudgeAfter;
|
|
192
|
-
}, [config?.nudgeAfter]);
|
|
193
218
|
(0, import_react.useEffect)(() => () => {
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const next =
|
|
197
|
-
if (next !==
|
|
219
|
+
const draft2 = draftRef.current;
|
|
220
|
+
if (draft2?.status !== "editing") return;
|
|
221
|
+
const next = parseThreshold(draft2.text);
|
|
222
|
+
if (next !== void 0) void writeThreshold(form, next).catch(() => false);
|
|
198
223
|
}, [form]);
|
|
199
224
|
if (config === void 0) {
|
|
200
225
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-note", children: t("config.unavailable") }) });
|
|
201
226
|
}
|
|
202
|
-
const bodyMode = bodyModeOf(config);
|
|
227
|
+
const bodyMode = bodyModeDraft?.mode ?? bodyModeOf(config);
|
|
203
228
|
const drawsCard = !(config.summaryOnly && config.summaryRender === "prose");
|
|
229
|
+
const displayedError = draft?.status === "rejected" ? t("config.write.failed") : error;
|
|
204
230
|
const write = (field, value) => {
|
|
205
|
-
enqueue(
|
|
231
|
+
void enqueue(() => form.set(field, value));
|
|
206
232
|
};
|
|
207
233
|
const chooseBodyMode = (mode) => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
234
|
+
const draft2 = { mode };
|
|
235
|
+
setBodyModeDraft(draft2);
|
|
236
|
+
void enqueue(() => form.mutate([
|
|
237
|
+
{ op: "set", path: ["collapsible"], value: mode !== "always" },
|
|
238
|
+
{ op: "set", path: ["bodyExpandedByDefault"], value: mode === "expanded" }
|
|
239
|
+
])).then(() => {
|
|
240
|
+
setBodyModeDraft((current) => current === draft2 ? void 0 : current);
|
|
241
|
+
});
|
|
213
242
|
};
|
|
214
243
|
const commitThreshold = () => {
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
|
|
244
|
+
const current = draftRef.current;
|
|
245
|
+
if (current === void 0 || current.status === "pending") return;
|
|
246
|
+
const next = parseThreshold(current.text);
|
|
247
|
+
if (next === void 0 || config.nudgeAfter === 0) {
|
|
248
|
+
updateDraft();
|
|
218
249
|
return;
|
|
219
250
|
}
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
const pending = { ...current, status: "pending" };
|
|
252
|
+
updateDraft(pending);
|
|
253
|
+
void writeThreshold(form, next).catch(() => false).then((accepted) => {
|
|
254
|
+
if (draftRef.current !== pending) return;
|
|
255
|
+
updateDraft(accepted ? void 0 : { ...pending, status: "rejected" });
|
|
256
|
+
});
|
|
225
257
|
};
|
|
226
258
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config", children: [
|
|
227
259
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
|
|
@@ -242,6 +274,22 @@ function ConfigCard(props) {
|
|
|
242
274
|
) })
|
|
243
275
|
] }),
|
|
244
276
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.nudgeEnabled.label") }),
|
|
279
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-hint", children: t("config.nudgeEnabled.hint") })
|
|
280
|
+
] }),
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-field", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
282
|
+
import_dsh_client_ui_primitives.Switch,
|
|
283
|
+
{
|
|
284
|
+
checked: config.nudgeAfter > 0,
|
|
285
|
+
label: t("config.nudgeEnabled.label"),
|
|
286
|
+
onChange: (next) => {
|
|
287
|
+
write("nudgeAfter", next ? DEFAULT_NUDGE_AFTER : 0);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
) })
|
|
291
|
+
] }),
|
|
292
|
+
config.nudgeAfter > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
|
|
245
293
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
|
|
246
294
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.threshold.label") }),
|
|
247
295
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-hint", children: t("config.threshold.hint") })
|
|
@@ -253,13 +301,13 @@ function ConfigCard(props) {
|
|
|
253
301
|
className: "dsh-notify-config-input",
|
|
254
302
|
type: "number",
|
|
255
303
|
inputMode: "numeric",
|
|
256
|
-
min:
|
|
304
|
+
min: 1,
|
|
257
305
|
max: MAX_NUDGE_AFTER,
|
|
258
306
|
step: 1,
|
|
259
|
-
value: text,
|
|
307
|
+
value: draft?.text ?? String(config.nudgeAfter),
|
|
260
308
|
"aria-label": t("config.threshold.label"),
|
|
261
309
|
onChange: (event) => {
|
|
262
|
-
|
|
310
|
+
updateDraft({ text: event.target.value, status: "editing" });
|
|
263
311
|
},
|
|
264
312
|
onBlur: commitThreshold,
|
|
265
313
|
onKeyDown: (event) => {
|
|
@@ -269,7 +317,7 @@ function ConfigCard(props) {
|
|
|
269
317
|
),
|
|
270
318
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-notify-config-unit", children: t("config.threshold.unit") })
|
|
271
319
|
] })
|
|
272
|
-
] }),
|
|
320
|
+
] }) : null,
|
|
273
321
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
|
|
274
322
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
|
|
275
323
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.resetOnProse.label") }),
|
|
@@ -379,7 +427,7 @@ function ConfigCard(props) {
|
|
|
379
427
|
}
|
|
380
428
|
) })
|
|
381
429
|
] }) : null,
|
|
382
|
-
|
|
430
|
+
displayedError === null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-error", role: "status", children: displayedError })
|
|
383
431
|
] });
|
|
384
432
|
}
|
|
385
433
|
|
|
@@ -392,14 +440,14 @@ function EnabledToggle(props) {
|
|
|
392
440
|
const addressedChild = useSession((snapshot) => snapshot.subagent !== null);
|
|
393
441
|
const listedChild = useSessions((state) => state.byId[sessionId]?.origin === "subagent");
|
|
394
442
|
if (addressedChild || listedChild) return null;
|
|
395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RootEnabledToggle, { ...props });
|
|
443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RootEnabledToggle, { ...props }, sessionId);
|
|
396
444
|
}
|
|
397
445
|
function RootEnabledToggle({ sessionId, form, locked, reportFailure, t }) {
|
|
398
|
-
const [config, setConfig] = (0, import_react2.useState)(() => readConfig(form));
|
|
399
|
-
const [pending, setPending] = (0, import_react2.useState)(
|
|
446
|
+
const [config, setConfig] = (0, import_react2.useState)(() => readConfig(form.getSnapshot()));
|
|
447
|
+
const [pending, setPending] = (0, import_react2.useState)();
|
|
400
448
|
(0, import_react2.useEffect)(() => {
|
|
401
449
|
const sync = () => {
|
|
402
|
-
setConfig(readConfig(form));
|
|
450
|
+
setConfig(readConfig(form.getSnapshot()));
|
|
403
451
|
};
|
|
404
452
|
sync();
|
|
405
453
|
return form.subscribe(sync);
|
|
@@ -407,23 +455,12 @@ function RootEnabledToggle({ sessionId, form, locked, reportFailure, t }) {
|
|
|
407
455
|
if (config === void 0) return null;
|
|
408
456
|
const enabled = enabledFor(config.sessionOverrides, config.defaultEnabled, sessionId);
|
|
409
457
|
const select = (next) => {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
(
|
|
416
|
-
if (!accepted) {
|
|
417
|
-
setConfig(readConfig(form));
|
|
418
|
-
reportFailure(t("toggle.failed"));
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
() => {
|
|
422
|
-
setConfig(readConfig(form));
|
|
423
|
-
reportFailure(t("toggle.failed"));
|
|
424
|
-
}
|
|
425
|
-
).finally(() => {
|
|
426
|
-
setPending(false);
|
|
458
|
+
setPending(next);
|
|
459
|
+
void writeSessionEnabled(form, sessionId, next).catch(() => false).then((accepted) => {
|
|
460
|
+
setConfig(readConfig(form.getSnapshot()));
|
|
461
|
+
if (!accepted) reportFailure(t("toggle.failed"));
|
|
462
|
+
}).finally(() => {
|
|
463
|
+
setPending(void 0);
|
|
427
464
|
});
|
|
428
465
|
};
|
|
429
466
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-notify-toggle-row", children: [
|
|
@@ -435,8 +472,8 @@ function RootEnabledToggle({ sessionId, form, locked, reportFailure, t }) {
|
|
|
435
472
|
import_dsh_client_ui_primitives2.Switch,
|
|
436
473
|
{
|
|
437
474
|
className: "dsh-notify-toggle-switch",
|
|
438
|
-
checked: enabled,
|
|
439
|
-
disabled: locked || pending,
|
|
475
|
+
checked: pending ?? enabled,
|
|
476
|
+
disabled: locked || pending !== void 0,
|
|
440
477
|
label: t("toggle.label"),
|
|
441
478
|
onChange: select
|
|
442
479
|
}
|
|
@@ -460,7 +497,9 @@ var en = {
|
|
|
460
497
|
"config.defaultEnabled.label": "On by default",
|
|
461
498
|
"config.defaultEnabled.hint": "New sessions start with proactive updates on; change a single session in the model and reasoning menu.",
|
|
462
499
|
"config.threshold.label": "Nudge after",
|
|
463
|
-
"config.threshold.hint": "Tool calls without an update before the model is nudged
|
|
500
|
+
"config.threshold.hint": "Tool calls without an update before the model is nudged.",
|
|
501
|
+
"config.nudgeEnabled.label": "Nudge for updates",
|
|
502
|
+
"config.nudgeEnabled.hint": "The model can still send updates when nudging is off.",
|
|
464
503
|
"config.threshold.unit": "calls",
|
|
465
504
|
"config.resetOnProse.label": "Reset on prose",
|
|
466
505
|
"config.resetOnProse.hint": "Any assistant reply with text counts as an update and resets the count; turn it off to reset only on a successful update, a new turn, or a user message.",
|
|
@@ -500,7 +539,9 @@ var zh = {
|
|
|
500
539
|
"config.defaultEnabled.label": "\u9ED8\u8BA4\u5F00\u542F",
|
|
501
540
|
"config.defaultEnabled.hint": "\u65B0\u4F1A\u8BDD\u9ED8\u8BA4\u6253\u5F00\u4E3B\u52A8\u6C47\u62A5\uFF1B\u5355\u4E2A\u4F1A\u8BDD\u7684\u5F00\u5173\u5728\u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7\u83DC\u5355\u91CC\u3002",
|
|
502
541
|
"config.threshold.label": "\u50AC\u529E\u9608\u503C",
|
|
503
|
-
"config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\
|
|
542
|
+
"config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\u3002",
|
|
543
|
+
"config.nudgeEnabled.label": "\u50AC\u529E\u63D0\u9192",
|
|
544
|
+
"config.nudgeEnabled.hint": "\u5173\u95ED\u50AC\u529E\u540E\uFF0C\u6A21\u578B\u4ECD\u53EF\u4E3B\u52A8\u6C47\u62A5\u3002",
|
|
504
545
|
"config.threshold.unit": "\u6B21",
|
|
505
546
|
"config.resetOnProse.label": "\u6563\u6587\u56DE\u590D\u6E05\u96F6",
|
|
506
547
|
"config.resetOnProse.hint": "\u6A21\u578B\u5728\u52A9\u624B\u6D88\u606F\u91CC\u5199\u4E86\u6B63\u6587\u5C31\u7B97\u6C47\u62A5\u8FC7\uFF0C\u8BA1\u6570\u6E05\u96F6\uFF1B\u5173\u6389\u540E\u53EA\u5728\u6C47\u62A5\u6210\u529F\u3001\u65B0\u56DE\u5408\u6216\u7528\u6237\u63D2\u8BDD\u65F6\u6E05\u96F6\u3002",
|
|
@@ -576,7 +617,7 @@ function formatClock(ms) {
|
|
|
576
617
|
|
|
577
618
|
// src/client/notify-node.ts
|
|
578
619
|
var NOTIFY_NODE_KIND = "notify-user";
|
|
579
|
-
var
|
|
620
|
+
var MAX_COMPLETED_CALLS = 4096;
|
|
580
621
|
function stateOf(update, time, settled, anchorSeq) {
|
|
581
622
|
return {
|
|
582
623
|
...update === null ? { message: "" } : update,
|
|
@@ -620,7 +661,8 @@ function fallbackState(context) {
|
|
|
620
661
|
return void 0;
|
|
621
662
|
}
|
|
622
663
|
function createNotifyDefinition() {
|
|
623
|
-
const
|
|
664
|
+
const pendingCalls = /* @__PURE__ */ new Set();
|
|
665
|
+
const completedCalls = /* @__PURE__ */ new Set();
|
|
624
666
|
return {
|
|
625
667
|
kind: NOTIFY_NODE_KIND,
|
|
626
668
|
target: "chat",
|
|
@@ -629,17 +671,22 @@ function createNotifyDefinition() {
|
|
|
629
671
|
case "tool/call": {
|
|
630
672
|
if (event.data.name !== NOTIFY_TOOL_NAME) return null;
|
|
631
673
|
const callId = String(event.data.callId);
|
|
632
|
-
if (
|
|
633
|
-
const oldest = calls.values().next().value;
|
|
634
|
-
if (oldest !== void 0) calls.delete(oldest);
|
|
635
|
-
}
|
|
636
|
-
calls.add(callId);
|
|
674
|
+
if (!completedCalls.has(callId)) pendingCalls.add(callId);
|
|
637
675
|
return { id: callId, role: "start", exclusive: true };
|
|
638
676
|
}
|
|
639
677
|
case "tool/result": {
|
|
640
678
|
if (event.surfaceOp !== "append") return null;
|
|
641
679
|
const callId = String(event.data.message.source.callId);
|
|
642
|
-
|
|
680
|
+
if (pendingCalls.delete(callId)) {
|
|
681
|
+
completedCalls.add(callId);
|
|
682
|
+
if (completedCalls.size > MAX_COMPLETED_CALLS) {
|
|
683
|
+
const oldest = completedCalls.values().next().value;
|
|
684
|
+
if (oldest !== void 0) completedCalls.delete(oldest);
|
|
685
|
+
}
|
|
686
|
+
} else if (!completedCalls.has(callId)) {
|
|
687
|
+
return null;
|
|
688
|
+
}
|
|
689
|
+
return { id: callId, role: "update", exclusive: true };
|
|
643
690
|
}
|
|
644
691
|
case "assistant/live-chunk": {
|
|
645
692
|
const chunk = event.data.chunk;
|
|
@@ -815,13 +862,143 @@ function NotifyRow(props) {
|
|
|
815
862
|
}
|
|
816
863
|
|
|
817
864
|
// src/client/ConfigCard.css
|
|
818
|
-
var ConfigCard_default = "
|
|
865
|
+
var ConfigCard_default = "\n.dsh-notify-config {\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.dsh-notify-config-row {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 16px;\n}\n\n.dsh-notify-config-info {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dsh-notify-config-label {\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n}\n\n.dsh-notify-config-hint {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-config-field {\n display: flex;\n flex: none;\n align-items: center;\n gap: 6px;\n}\n\n.dsh-notify-config-input {\n width: 88px;\n}\n\n.dsh-notify-config-unit {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n\n.dsh-notify-config-error {\n color: var(--dsw-alias-state-error-primary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-config-note {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n";
|
|
819
866
|
|
|
820
867
|
// src/client/NotifyCard.css
|
|
821
|
-
var NotifyCard_default =
|
|
868
|
+
var NotifyCard_default = `
|
|
869
|
+
.dsh-notify-card {
|
|
870
|
+
padding: 2px 0 8px;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.dsh-notify-card[data-seat="node"] {
|
|
874
|
+
padding: 0;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
.dsh-notify-head {
|
|
878
|
+
display: flex;
|
|
879
|
+
align-items: center;
|
|
880
|
+
gap: 6px;
|
|
881
|
+
min-height: 24px;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.dsh-notify-dot {
|
|
885
|
+
position: relative;
|
|
886
|
+
display: inline-flex;
|
|
887
|
+
align-items: center;
|
|
888
|
+
justify-content: center;
|
|
889
|
+
flex: none;
|
|
890
|
+
width: calc(16px + var(--dsh-content-font-delta, 0px));
|
|
891
|
+
height: calc(16px + var(--dsh-content-font-delta, 0px));
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
.dsh-notify-dot-idle {
|
|
895
|
+
display: inline-flex;
|
|
896
|
+
align-items: center;
|
|
897
|
+
justify-content: center;
|
|
898
|
+
opacity: 1;
|
|
899
|
+
transition: opacity 100ms ease;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
.dsh-notify-dot-idle::before {
|
|
903
|
+
content: '';
|
|
904
|
+
width: 7px;
|
|
905
|
+
height: 7px;
|
|
906
|
+
border-radius: 50%;
|
|
907
|
+
corner-shape: round;
|
|
908
|
+
background: var(--dsw-alias-state-business-primary);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
.dsh-notify-toggle {
|
|
912
|
+
display: inline-flex;
|
|
913
|
+
align-items: center;
|
|
914
|
+
gap: 6px;
|
|
915
|
+
min-width: 0;
|
|
916
|
+
padding: 0;
|
|
917
|
+
border: 0;
|
|
918
|
+
background: none;
|
|
919
|
+
color: inherit;
|
|
920
|
+
font: inherit;
|
|
921
|
+
text-align: left;
|
|
922
|
+
cursor: pointer;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
.dsh-notify-title {
|
|
926
|
+
color: var(--dsw-alias-state-business-primary);
|
|
927
|
+
font-size: 14px;
|
|
928
|
+
font-weight: 600;
|
|
929
|
+
line-height: 22px;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.dsh-notify-chevron {
|
|
933
|
+
position: absolute;
|
|
934
|
+
inset: 0;
|
|
935
|
+
margin: auto;
|
|
936
|
+
color: var(--dsw-alias-state-business-primary);
|
|
937
|
+
opacity: 0;
|
|
938
|
+
transition: transform 0.15s ease, opacity 100ms ease;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
.dsh-notify-dot[data-open] .dsh-notify-chevron {
|
|
942
|
+
transform: rotate(180deg);
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
@media (hover: hover) {
|
|
946
|
+
.dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-dot-idle {
|
|
947
|
+
opacity: 0;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
.dsh-notify-card[data-collapsible] .dsh-notify-head:hover .dsh-notify-chevron {
|
|
951
|
+
opacity: 1;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
@media (prefers-reduced-motion: reduce) {
|
|
956
|
+
.dsh-notify-dot-idle,
|
|
957
|
+
.dsh-notify-chevron {
|
|
958
|
+
transition: none;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.dsh-notify-time {
|
|
963
|
+
flex: none;
|
|
964
|
+
margin-left: auto;
|
|
965
|
+
color: var(--dsw-alias-label-tertiary);
|
|
966
|
+
font-size: 12px;
|
|
967
|
+
line-height: 18px;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
.dsh-notify-prose {
|
|
971
|
+
padding: 0;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
.dsh-notify-body {
|
|
975
|
+
margin: 2px 0 0 calc(8px + var(--dsh-content-font-delta, 0px) * 0.5);
|
|
976
|
+
padding-left: calc(13px + var(--dsh-content-font-delta, 0px) * 0.5);
|
|
977
|
+
border-left: 1px solid var(--dsw-alias-border-l1);
|
|
978
|
+
color: var(--dsw-alias-label-primary);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
.dsh-notify-body > div {
|
|
982
|
+
color: var(--dsw-alias-label-primary);
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
[data-chat-flow-kind="notify-user"] {
|
|
986
|
+
--dsh-chat-flow-gap: 12px;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
[data-chat-flow-kind="notify-user"] + * {
|
|
990
|
+
--dsh-chat-flow-gap: 12px;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
.dsh-notify-failure {
|
|
994
|
+
color: var(--dsw-alias-state-error-primary);
|
|
995
|
+
overflow-wrap: anywhere;
|
|
996
|
+
white-space: pre-wrap;
|
|
997
|
+
}
|
|
998
|
+
`;
|
|
822
999
|
|
|
823
1000
|
// src/client/EnabledToggle.css
|
|
824
|
-
var EnabledToggle_default = "
|
|
1001
|
+
var EnabledToggle_default = "\n.dsh-notify-toggle-row {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 34px;\n padding: 0 8px;\n border-radius: var(--dsw-radius-md);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n}\n\n.dsh-notify-toggle-label {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-width: 0;\n}\n\n.dsh-notify-toggle-info {\n position: relative;\n z-index: 1;\n flex: none;\n width: 20px;\n height: 20px;\n padding: 0;\n color: var(--dsw-alias-label-caption);\n}\n\n.dsh-notify-toggle-row .dsh-notify-toggle-switch {\n position: static;\n}\n\n.dsh-notify-toggle-switch::after {\n content: '';\n position: absolute;\n inset: 0;\n border-radius: var(--dsw-radius-md);\n}\n\n.dsh-notify-toggle-row:has(.dsh-notify-toggle-switch:focus-visible) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n@media (hover: hover) {\n .dsh-notify-toggle-row:has(.dsh-notify-toggle-switch:not(:disabled)):hover {\n background: var(--dsw-alias-interactive-bg-hover);\n }\n}\n";
|
|
825
1002
|
|
|
826
1003
|
// src/client/index.ts
|
|
827
1004
|
var name = BUNDLE_NAME;
|