@lynn123411/dsh-notify-user 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/DETAILS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lynn123411/dsh-notify-user 详情
2
2
 
3
- > 本文档是 [README.md](./README.md) 的补充:装配形态、节点投影、配置项、计数口径、设计参照与验证。
3
+ > 本文档是 [README.md](./README.md) 的补充:装配形态、节点投影、配置项、按会话开关、计数口径、设计参照与验证。
4
4
 
5
5
  ## 装配形态
6
6
 
@@ -10,8 +10,8 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
10
10
 
11
11
  这条命令把包名写进 profile 的 `dependencies` 与 `dsh.profile.bundles`,包内 `cordis.patch.yml` 随之插入一条 root loader entry(`id: dsh-notify-user`)。这一行同时承载两个半边:
12
12
 
13
- - 宿主半边注册 `notify_user` 工具,并把催办状态机接到 `tools/result`(纯观察)与 `agent/pre-step` 两条事件上;
14
- - 浏览器半边注册对话节点定义、进度卡渲染器(`conversation.chat.node`,key 是 `notify-user`)、工具行兜底渲染(`tool.call.toolview`,key 是 `notify_user`)与插件页配置卡(`plugins.bundle.config`,key 是包名)。
13
+ - 宿主半边注册 `notify_user` 工具,并把催办状态机接到 `tools/result`(纯观察)、`session/event`(助手消息落定)与 `agent/pre-step` 三条事件上;
14
+ - 浏览器半边注册对话节点定义、进度卡渲染器(`conversation.chat.node`,key 是 `notify-user`)、工具行兜底渲染(`tool.call.toolview`,key 是 `notify_user`)、菜单开关(`conversation.input.model.options`,id 是 `notify-user-enabled`)与插件页配置卡(`plugins.bundle.config`,key 是包名)。
15
15
 
16
16
  行 id 同时是配置命名空间:宿主 `Config` 与浏览器 `ctx.configForms.get('dsh-notify-user')` 读写的是同一份值。
17
17
 
@@ -38,24 +38,47 @@ dsh plugin --profile web add @lynn123411/dsh-notify-user
38
38
 
39
39
  | 字段 | 默认 | 范围 | 说明 |
40
40
  | --- | --- | --- | --- |
41
+ | `defaultEnabled` | true | 布尔 | 会话没有自己的选择时,主动汇报开不开。 |
42
+ | `sessionOverrides` | `{}` | 会话 id → 布尔 | 按会话的选择;只留与默认值不同的会话,切回默认值就删掉那条。 |
41
43
  | `nudgeAfter` | 10 | 0–100 | 连续多少次根工具调用没有汇报时催一次;0 关闭催办。 |
44
+ | `resetOnProse` | true | 布尔 | 助手消息里写了正文(非空白 `text` 块)就清零计数;关掉后只在 `notify_user`、新回合或用户插话时清零。 |
42
45
  | `collapsible` | true | 布尔 | 进度卡标题旁带不带折叠键;带折叠键时正文仍默认展开,关掉后正文始终展开、不显示折叠键。 |
43
46
  | `cardPlacement` | `boundary` | `boundary` / `inline` | 进度卡位置:`boundary` 站在步骤组边界,`inline` 跟随工具行、随组折叠。 |
44
47
 
45
- 字段都标了 `.volatile()`:改它们不重挂这条 loader entry。催办状态机每次 `pre-step` 现读 `nudgeAfter`;进度卡通过注册项的 `inject` 拿到同一张配置表单并订阅,所以 `collapsible` 改完当前页面的卡片立刻跟着变。配置界面在宿主「插件」页本插件的详情页上;宿主没服务这份配置时卡片整块不出现。插件同时用 `ctx.settings.configure({ auto: false })` 关掉内核按 schema 自动生成的那份设置页。
48
+ 字段都标了 `.volatile()`:改它们不重挂这条 loader entry。催办状态机每次 `pre-step` 现读 `nudgeAfter` 与 `defaultEnabled`/`sessionOverrides`;进度卡与菜单开关通过注册项的 `inject` 拿到同一张配置表单并订阅,所以改完当前页面的卡片与开关立刻跟着变。配置界面在宿主「插件」页本插件的详情页上;宿主没服务这份配置时卡片整块不出现。插件同时用 `ctx.settings.configure({ auto: false })` 关掉内核按 schema 自动生成的那份设置页。
49
+
50
+ ## 按会话开关
51
+
52
+ 菜单里的「主动汇报」开关挂在 `conversation.input.model.options`(list,`id: notify-user-enabled`),与官方智能体团队开关同处一个菜单:排在模型与推理等级两格之后,整行悬停高亮,标签旁的信息按钮解释这个开关做什么。
53
+
54
+ **一个会话开不开**由 `enabledFor(sessionOverrides, defaultEnabled, sessionId)` 回答:会话有自己的记录就用它,否则用默认值。判定是纯函数,宿主与浏览器两半边共用 `src/shared/config.ts` 里那一份。
55
+
56
+ **选择存在插件配置里**,不存会话日志:`sessionOverrides` 是一个「会话 id → 布尔」的字典,只留与默认值不同的会话。切回默认值时客户端把那条删掉(`overridesAfterWrite`),所以字典不会随会话数一直长。
57
+
58
+ > 为什么不是官方团队插件那样「写进会话日志 + 读会话投影」:那条路要一个 typert Remote(宿主 `./typert` 产物 + 客户端描述符)。生成物归内核的构建流水线,第三方插件手写会跟着内核版本漂移。本插件只有一个布尔值要按会话存,改用已有的配置表单:客户端用 `form.set('sessionOverrides', …)` 写,宿主现读,两半边都不加新管线。
59
+
60
+ **关掉之后**两处一起变:催办状态机不催(`readEnabled` 为假时连计数也清零,重新打开从零开始,不会一开就催);`notify_user` 工具用 `ctx.tools.register(def, { when })` 按会话收放,关掉的会话在这一步的声明与派发里都没有它。
61
+
62
+ **子代理会话里不画这一行**:催办本来就不进子代理,开关在那里没有作用。判定同时看当前会话快照的 `subagent` 与会话列表里的 `origin`。
63
+
64
+ **写入先重画、失败再退回**:点开关先按新值重画,写入交给设置表单排队;宿主拒收就退回宿主上的值,并通过菜单宿主的 `reportFailure` 报一次。写入在途时开关禁用,避免连点叠出两条互相覆盖的写入。
46
65
 
47
66
  ## 计数口径
48
67
 
49
68
  - 只数**根调用**:原生模式下是模型每次直接发起的调用(同一轮里的并行调用各算一次);PTC 模式下是每次 `run_code`,程序内部的子调用不算。
50
69
  - `notify_user` 无论根调用还是 PTC 子调用都清零。
70
+ - 助手消息(`assistant/message`)里带非空白正文时清零,`resetOnProse` 关掉则不算;`reasoning` 块不算正文,失败、重试、取消的尝试(`assistant/attempt`)也不清零。
51
71
  - 新回合(`agent/pre-step` 的 `step === 1`,不论由用户、定时提醒、队友消息还是 webhook 触发)或用户插话(收件箱里有 `source.kind === 'user'` 的消息)清零。回合边界取宿主给的 `step`,不按消息来源枚举。
52
72
  - 子代理会话不计数、不注入。
73
+ - 会话关掉主动汇报时不计数、不注入,计数一并清零;重新打开从零开始算。
53
74
  - 催办注入的是**指令**,不是替模型写正文;注入消息的来源是 `notify-user-nudge`、`form: 'notice'`,只进模型上下文,不占对话流正文。
54
75
 
55
76
  ## 设计参照
56
77
 
57
78
  机制照 Kimi Code 的 `NotifyUser`([`packages/agent-core-v2/src/features/notify`](https://github.com/MoonshotAI/kimi-code/tree/6974ac880d405d5565a2189925f3bef6daea6892/packages/agent-core-v2/src/features/notify)):普通工具调用负责产出更新,独立的一层 reminder 在模型久不汇报时注入一条指令。阈值与计数口径按 DSH 的两种工具呈现方式调整。
58
79
 
80
+ 菜单开关的形态照官方智能体团队开关(内核 `packages/client/ui-agent-team` 的 `TeamModeToggle`):同一行结构、同一套悬停高亮与整行点击区。
81
+
59
82
  ## 已知现状
60
83
 
61
84
  节点数据优先读 `tool/result` 的 `meta`(原生调用);PTC 子调用读 `tool/ptc-dispatch` 的 `meta`;没有 `meta` 的旧日志退回调用参数。三条来路都来自会话日志,直播与重放画出来一样。
@@ -77,13 +100,17 @@ cd plugins/dsh-notify-user && pnpm check
77
100
  `check` 链上每一步:
78
101
 
79
102
  - `typecheck`:`src` 的类型闸门。
80
- - `smoke-host.mjs`:真 cordis + 真 `ToolRuntime`,断言配置形状、工具注册与执行、装配行,以及催办接线在真 `ctx.waterfall` 下的行为(满阈值注入、汇报/新回合/用户插话/阈值 0 清零、上下文注入不清零、PTC 子调用不计数、嵌套汇报清零、子代理不注入、下游拒绝时不追加)。
81
- - `smoke-client.mjs`:按 Web shell 方式装载浏览器 bundle,断言对话节点定义、位置切换会重挂定义、三处座位注册、字典键集与「未声明服务读取会抛」的守卫。
82
- - `test-nudge.mjs`:催办状态机的纯逻辑(阈值、清零、现读、按 agent 隔离)。
103
+ - `smoke-host.mjs`:真 cordis + 真 `ToolRuntime`,断言配置形状、工具注册与执行、装配行,以及催办接线在真 `ctx.waterfall` 下的行为(满阈值注入、汇报/散文/新回合/用户插话/阈值 0 清零、只有思考块不清零、失败尝试不清零、散文开关关掉不清零、上下文注入不清零、PTC 子调用不计数、嵌套汇报清零、子代理不注入、下游拒绝时不追加),以及按会话开关(关掉的会话不催、默认关掉时新会话不催、显式打开的会话照常催、开关现读、关掉的会话里没有 `notify_user` 工具)。
104
+ - `smoke-client.mjs`:按 Web shell 方式装载浏览器 bundle,断言对话节点定义、位置切换会重挂定义、四处座位注册(进度卡、兜底行、菜单开关、配置卡)、字典键集与「未声明服务读取会抛」的守卫。
105
+ - `test-nudge.mjs`:催办状态机的纯逻辑(阈值、四条清零路径、阈值与散文开关现读、按会话隔离、散文判定、开关关掉时不催且计数清零、开关按会话现读)。
106
+ - `test-config.mjs`:按会话开关的纯逻辑(默认值、会话自己的选择优先、脏数据与原型键不算记录、写入时只留与默认值不同的会话、没有变化时返回同一个对象)。
107
+ - `test-render.mjs`:用真 react 把菜单开关画进 jsdom(默认值、写入规则、宿主拒收回退并报失败、写入在途禁用、子代理会话不画、配置不可用不画、锁住不可点)。
83
108
  - `test-row-model.mjs`:进度卡数据视图的三条来路(`meta` / PTC 参数 / start 参数)与标题回退。
84
109
  - `test-notify-node.mjs`:对话节点定义的认领范围、节点位置与卡片数据(原生调用、结果落定、流式增量与块结束、PTC 子调用、结果先到、没有正文时的兜底)。
85
110
  - `assert-lib-untracked.mjs`:`lib/` 是构建镜像,不入 git。
86
111
 
87
112
  浏览器里验收:打开跑过 `notify_user` 的会话,展开回合后进度卡应站在步骤组外、前后各有一条折叠组。DOM 判据是 `[data-chat-flow-kind="notify-user"]` 的节点不在 `[data-step-process-body]` 里,`[data-step-process]` 的组头成对出现在卡片之间。
88
113
 
114
+ 按会话开关:打开模型与推理等级菜单,模型与推理等级两格之后应有「主动汇报」一行;关掉它之后当前会话不再出现催办提示,`notify_user` 也从下一步的工具清单里消失;切回插件页把「默认开启」关掉,新会话的菜单开关应当默认是关的。
115
+
89
116
  实测(2026-11-06,运行中的 0.2.2-rc.1 实例):本会话加载窗口内 6 张进度卡全部站在步骤组外(0 张落在 `[data-step-process-body]` 里),卡片之间成对出现 `[data-step-process]` 组头;展开回合后看到「进度卡 → 折叠组 → 进度卡」的形态。
package/README.md CHANGED
@@ -5,8 +5,11 @@
5
5
  ## 功能
6
6
 
7
7
  - **主动汇报**:模型在干活途中调 `notify_user`,对话流里立刻出现一张进度卡——圆点、标题、时间,正文默认展开。本轮不结束、不阻塞,也不等你回答。
8
+ - **按会话开关**:模型与推理等级菜单里有「主动汇报」开关,与官方智能体团队开关同处一行。关掉后这个会话不再催模型汇报,也不再向它提供汇报工具。子代理会话里没有这个开关——催办本来就不进子代理。
8
9
  - **久不汇报会被催**:连续多次根工具调用没有汇报时,插件在下一步之前注入一条提醒,让模型把当前结论与下一步发出来;汇报过、或开了新回合就重新计数。子代理不催。
9
- - **阈值可改**:插件页的配置卡里改催办阈值,默认 10 次工具调用,0 关闭催办;改完当前会话下一步就生效。
10
+ - **散文回复也算汇报**:模型在助手消息里写了正文就清零计数,催办只在它连续只有工具调用、一句话都没说时出现;插件页的配置卡里可以关掉。
11
+ - **默认值可改**:插件页的配置卡里定新会话默认开不开主动汇报,默认开启;单个会话在菜单里改,改完当前会话下一步就生效。
12
+ - **阈值可改**:同一张配置卡里改催办阈值,默认 10 次工具调用,0 关闭催办。
10
13
  - **折叠可关**:同一张配置卡里决定进度卡带不带折叠键;带折叠键时正文仍默认展开,关掉后正文始终展开、不显示折叠键。
11
14
  - **位置可切**:同一张配置卡里切换进度卡位置——放在步骤组边界(默认),或跟随工具行、随组一起折叠。
12
15
 
package/lib/client.js CHANGED
@@ -33,9 +33,27 @@ var SETTINGS_NAMESPACE = "dsh-notify-user";
33
33
  var NOTIFY_TOOL_NAME = "notify_user";
34
34
  var DEFAULT_NUDGE_AFTER = 10;
35
35
  var MAX_NUDGE_AFTER = 100;
36
+ var DEFAULT_RESET_ON_PROSE = true;
36
37
  var DEFAULT_COLLAPSIBLE = true;
37
38
  var CARD_PLACEMENTS = ["boundary", "inline"];
38
39
  var DEFAULT_CARD_PLACEMENT = "boundary";
40
+ var DEFAULT_ENABLED = true;
41
+ function enabledFor(overrides, fallback, sessionId) {
42
+ const explicit = overrides?.[sessionId];
43
+ return typeof explicit === "boolean" ? explicit : fallback;
44
+ }
45
+ function overridesAfterWrite(overrides, sessionId, enabled, fallback) {
46
+ const current = overrides ?? {};
47
+ const hasEntry = Object.hasOwn(current, sessionId);
48
+ if (enabled === fallback) {
49
+ if (!hasEntry) return current;
50
+ const next = { ...current };
51
+ delete next[sessionId];
52
+ return next;
53
+ }
54
+ if (hasEntry && current[sessionId] === enabled) return current;
55
+ return { ...current, [sessionId]: enabled };
56
+ }
39
57
 
40
58
  // src/client/ConfigCard.tsx
41
59
  var import_react = require("react");
@@ -44,20 +62,42 @@ var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primit
44
62
  // src/client/config.ts
45
63
  var BUNDLE_NAME = "@lynn123411/dsh-notify-user";
46
64
  var BUNDLE_CONFIG_SLOT = "plugins.bundle.config";
65
+ var MODEL_OPTIONS_SLOT = "conversation.input.model.options";
47
66
  function isRecord(value) {
48
67
  return typeof value === "object" && value !== null && !Array.isArray(value);
49
68
  }
69
+ var DEFAULT_CLIENT_CONFIG = {
70
+ nudgeAfter: DEFAULT_NUDGE_AFTER,
71
+ resetOnProse: DEFAULT_RESET_ON_PROSE,
72
+ collapsible: DEFAULT_COLLAPSIBLE,
73
+ cardPlacement: DEFAULT_CARD_PLACEMENT,
74
+ defaultEnabled: DEFAULT_ENABLED,
75
+ sessionOverrides: {}
76
+ };
77
+ function readOverrides(value) {
78
+ if (!isRecord(value)) return {};
79
+ const overrides = {};
80
+ for (const [sessionId, enabled] of Object.entries(value)) {
81
+ if (typeof enabled === "boolean") overrides[sessionId] = enabled;
82
+ }
83
+ return overrides;
84
+ }
50
85
  function readConfig(form) {
51
86
  const snapshot = form.getSnapshot();
52
87
  if (snapshot.status === "unavailable") return void 0;
53
88
  const value = isRecord(snapshot.value) ? snapshot.value : {};
54
89
  const rawThreshold = value["nudgeAfter"];
55
- const nudgeAfter = typeof rawThreshold === "number" && Number.isFinite(rawThreshold) ? Math.min(MAX_NUDGE_AFTER, Math.max(0, Math.floor(rawThreshold))) : DEFAULT_NUDGE_AFTER;
90
+ const nudgeAfter = typeof rawThreshold === "number" && Number.isFinite(rawThreshold) ? Math.min(MAX_NUDGE_AFTER, Math.max(0, Math.floor(rawThreshold))) : DEFAULT_CLIENT_CONFIG.nudgeAfter;
91
+ const rawResetOnProse = value["resetOnProse"];
92
+ const resetOnProse = typeof rawResetOnProse === "boolean" ? rawResetOnProse : DEFAULT_CLIENT_CONFIG.resetOnProse;
56
93
  const rawCollapsible = value["collapsible"];
57
- const collapsible = typeof rawCollapsible === "boolean" ? rawCollapsible : DEFAULT_COLLAPSIBLE;
94
+ const collapsible = typeof rawCollapsible === "boolean" ? rawCollapsible : DEFAULT_CLIENT_CONFIG.collapsible;
58
95
  const rawPlacement = value["cardPlacement"];
59
- const cardPlacement = CARD_PLACEMENTS.find((placement) => placement === rawPlacement) ?? DEFAULT_CARD_PLACEMENT;
60
- return { nudgeAfter, collapsible, cardPlacement };
96
+ const cardPlacement = CARD_PLACEMENTS.find((placement) => placement === rawPlacement) ?? DEFAULT_CLIENT_CONFIG.cardPlacement;
97
+ const rawDefaultEnabled = value["defaultEnabled"];
98
+ const defaultEnabled = typeof rawDefaultEnabled === "boolean" ? rawDefaultEnabled : DEFAULT_CLIENT_CONFIG.defaultEnabled;
99
+ const sessionOverrides = readOverrides(value["sessionOverrides"]);
100
+ return { nudgeAfter, resetOnProse, collapsible, cardPlacement, defaultEnabled, sessionOverrides };
61
101
  }
62
102
 
63
103
  // src/client/ConfigCard.tsx
@@ -116,6 +156,23 @@ function ConfigCard(props) {
116
156
  write("nudgeAfter", next);
117
157
  };
118
158
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config", children: [
159
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
161
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.defaultEnabled.label") }),
162
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-hint", children: t("config.defaultEnabled.hint") })
163
+ ] }),
164
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-field", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
165
+ import_dsh_client_ui_primitives.Switch,
166
+ {
167
+ checked: config.defaultEnabled,
168
+ label: t("config.defaultEnabled.label"),
169
+ onChange: (next) => {
170
+ setConfig({ ...config, defaultEnabled: next });
171
+ write("defaultEnabled", next);
172
+ }
173
+ }
174
+ ) })
175
+ ] }),
119
176
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
120
177
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
121
178
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.threshold.label") }),
@@ -145,6 +202,23 @@ function ConfigCard(props) {
145
202
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-notify-config-unit", children: t("config.threshold.unit") })
146
203
  ] })
147
204
  ] }),
205
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
206
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
207
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.resetOnProse.label") }),
208
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-hint", children: t("config.resetOnProse.hint") })
209
+ ] }),
210
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-field", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
+ import_dsh_client_ui_primitives.Switch,
212
+ {
213
+ checked: config.resetOnProse,
214
+ label: t("config.resetOnProse.label"),
215
+ onChange: (next) => {
216
+ setConfig({ ...config, resetOnProse: next });
217
+ write("resetOnProse", next);
218
+ }
219
+ }
220
+ ) })
221
+ ] }),
148
222
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-row", children: [
149
223
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-notify-config-info", children: [
150
224
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-notify-config-label", children: t("config.placement.label") }),
@@ -186,6 +260,67 @@ function ConfigCard(props) {
186
260
  ] });
187
261
  }
188
262
 
263
+ // src/client/EnabledToggle.tsx
264
+ var import_react2 = require("react");
265
+ var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
266
+ var import_jsx_runtime2 = require("react/jsx-runtime");
267
+ function EnabledToggle(props) {
268
+ const { sessionId, useSession, useSessions } = props;
269
+ const addressedChild = useSession((snapshot) => snapshot.subagent !== null);
270
+ const listedChild = useSessions((state) => state.byId[sessionId]?.origin === "subagent");
271
+ if (addressedChild || listedChild) return null;
272
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RootEnabledToggle, { ...props });
273
+ }
274
+ function RootEnabledToggle({ sessionId, form, locked, reportFailure, t }) {
275
+ const [config, setConfig] = (0, import_react2.useState)(() => readConfig(form));
276
+ const [pending, setPending] = (0, import_react2.useState)(false);
277
+ (0, import_react2.useEffect)(() => {
278
+ const sync = () => {
279
+ setConfig(readConfig(form));
280
+ };
281
+ sync();
282
+ return form.subscribe(sync);
283
+ }, [form]);
284
+ if (config === void 0) return null;
285
+ const enabled = enabledFor(config.sessionOverrides, config.defaultEnabled, sessionId);
286
+ const select = (next) => {
287
+ const overrides = overridesAfterWrite(config.sessionOverrides, sessionId, next, config.defaultEnabled);
288
+ if (overrides === config.sessionOverrides) return;
289
+ setConfig({ ...config, sessionOverrides: overrides });
290
+ setPending(true);
291
+ void form.set("sessionOverrides", overrides).then(
292
+ (accepted) => {
293
+ if (!accepted) {
294
+ setConfig(readConfig(form));
295
+ reportFailure(t("toggle.failed"));
296
+ }
297
+ },
298
+ () => {
299
+ setConfig(readConfig(form));
300
+ reportFailure(t("toggle.failed"));
301
+ }
302
+ ).finally(() => {
303
+ setPending(false);
304
+ });
305
+ };
306
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-notify-toggle-row", children: [
307
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "dsh-notify-toggle-label", children: [
308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("toggle.label") }),
309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Tooltip, { label: t("toggle.description"), side: "top", delayMs: 300, maxWidth: 300, portal: true, openOnClick: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "ghost", size: "sm", className: "dsh-notify-toggle-info", "aria-label": t("toggle.infoLabel"), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.IconInfoOutlineRegular, { size: 11, "aria-hidden": "true" }) }) })
310
+ ] }),
311
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
312
+ import_dsh_client_ui_primitives2.Switch,
313
+ {
314
+ className: "dsh-notify-toggle-switch",
315
+ checked: enabled,
316
+ disabled: locked || pending,
317
+ label: t("toggle.label"),
318
+ onChange: select
319
+ }
320
+ )
321
+ ] });
322
+ }
323
+
189
324
  // src/client/locales.ts
190
325
  var NS = "notifyUser";
191
326
  var en = {
@@ -194,9 +329,17 @@ var en = {
194
329
  "markdown.copy": "Copy",
195
330
  "markdown.copied": "Copied",
196
331
  "markdown.footnotes": "Footnotes",
332
+ "toggle.label": "Proactive updates",
333
+ "toggle.description": "The model reports progress while it works. Turn it off and this session stops nudging it to report and no longer offers it the reporting tool.",
334
+ "toggle.infoLabel": "About proactive updates",
335
+ "toggle.failed": "Couldn't save the setting; try again.",
336
+ "config.defaultEnabled.label": "On by default",
337
+ "config.defaultEnabled.hint": "New sessions start with proactive updates on; change a single session in the model and reasoning menu.",
197
338
  "config.threshold.label": "Nudge after",
198
339
  "config.threshold.hint": "Tool calls without an update before the model is nudged; 0 turns nudging off.",
199
340
  "config.threshold.unit": "calls",
341
+ "config.resetOnProse.label": "Reset on prose",
342
+ "config.resetOnProse.hint": "Any assistant reply with text counts as an update and resets the count; turn it off to reset only on notify_user, a new turn, or a user message.",
200
343
  "config.collapsible.label": "Collapsible",
201
344
  "config.collapsible.hint": "The update body starts expanded with a collapse button beside the title; turn it off to keep the body always expanded with no button.",
202
345
  "config.placement.label": "Card placement",
@@ -212,9 +355,17 @@ var zh = {
212
355
  "markdown.copy": "\u590D\u5236",
213
356
  "markdown.copied": "\u5DF2\u590D\u5236",
214
357
  "markdown.footnotes": "\u811A\u6CE8",
358
+ "toggle.label": "\u4E3B\u52A8\u6C47\u62A5",
359
+ "toggle.description": "\u6A21\u578B\u5728\u5E72\u6D3B\u9014\u4E2D\u5411\u4F60\u6C47\u62A5\u8FDB\u5EA6\u3002\u5173\u6389\u540E\u8FD9\u4E2A\u4F1A\u8BDD\u4E0D\u518D\u50AC\u5B83\u6C47\u62A5\uFF0C\u4E5F\u4E0D\u518D\u5411\u5B83\u63D0\u4F9B\u6C47\u62A5\u5DE5\u5177\u3002",
360
+ "toggle.infoLabel": "\u5173\u4E8E\u4E3B\u52A8\u6C47\u62A5",
361
+ "toggle.failed": "\u6CA1\u4FDD\u5B58\u4E0A\uFF0C\u8BF7\u91CD\u8BD5\u3002",
362
+ "config.defaultEnabled.label": "\u9ED8\u8BA4\u5F00\u542F",
363
+ "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",
215
364
  "config.threshold.label": "\u50AC\u529E\u9608\u503C",
216
365
  "config.threshold.hint": "\u8FDE\u7EED\u591A\u5C11\u6B21\u5DE5\u5177\u8C03\u7528\u6CA1\u6709\u6C47\u62A5\u65F6\u50AC\u4E00\u6B21\uFF1B0 \u5173\u95ED\u50AC\u529E\u3002",
217
366
  "config.threshold.unit": "\u6B21",
367
+ "config.resetOnProse.label": "\u6563\u6587\u56DE\u590D\u6E05\u96F6",
368
+ "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 notify_user\u3001\u65B0\u56DE\u5408\u6216\u7528\u6237\u63D2\u8BDD\u65F6\u6E05\u96F6\u3002",
218
369
  "config.collapsible.label": "\u53EF\u6298\u53E0",
219
370
  "config.collapsible.hint": "\u8FDB\u5EA6\u5361\u6B63\u6587\u9ED8\u8BA4\u5C55\u5F00\uFF0C\u6807\u9898\u65C1\u5E26\u4E00\u4E2A\u6298\u53E0\u952E\uFF1B\u5173\u6389\u540E\u6B63\u6587\u59CB\u7EC8\u5C55\u5F00\u3001\u4E0D\u663E\u793A\u6298\u53E0\u952E\u3002",
220
371
  "config.placement.label": "\u8FDB\u5EA6\u5361\u4F4D\u7F6E",
@@ -393,19 +544,14 @@ function createNotifyDefinition() {
393
544
  }
394
545
 
395
546
  // src/client/NotifyCard.tsx
396
- var import_react2 = require("react");
397
- var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
398
- var import_jsx_runtime2 = require("react/jsx-runtime");
399
- var FALLBACK_CONFIG = {
400
- nudgeAfter: DEFAULT_NUDGE_AFTER,
401
- collapsible: DEFAULT_COLLAPSIBLE,
402
- cardPlacement: DEFAULT_CARD_PLACEMENT
403
- };
547
+ var import_react3 = require("react");
548
+ var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
549
+ var import_jsx_runtime3 = require("react/jsx-runtime");
404
550
  function useClientConfig(form) {
405
- const [config, setConfig] = (0, import_react2.useState)(() => readConfig(form) ?? FALLBACK_CONFIG);
406
- (0, import_react2.useEffect)(() => {
551
+ const [config, setConfig] = (0, import_react3.useState)(() => readConfig(form) ?? DEFAULT_CLIENT_CONFIG);
552
+ (0, import_react3.useEffect)(() => {
407
553
  const sync = () => {
408
- setConfig(readConfig(form) ?? FALLBACK_CONFIG);
554
+ setConfig(readConfig(form) ?? DEFAULT_CLIENT_CONFIG);
409
555
  };
410
556
  sync();
411
557
  return form.subscribe(sync);
@@ -420,14 +566,14 @@ function markdownLabels(t) {
420
566
  }
421
567
  function NotifyCard({ data, form, openFile, t }) {
422
568
  const config = useClientConfig(form);
423
- const [open, setOpen] = (0, import_react2.useState)(true);
569
+ const [open, setOpen] = (0, import_react3.useState)(true);
424
570
  const title = titleOf({ title: data.title, message: data.message }, t("row.fallbackTitle"));
425
571
  const hasBody = data.message.trim().length > 0;
426
572
  const collapsible = config.collapsible && hasBody;
427
573
  const expanded = collapsible ? open : true;
428
574
  const time = formatClock(data.time);
429
- const titleNode = data.settled ? title : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.TextShimmer, { active: true, children: title });
430
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
575
+ const titleNode = data.settled ? title : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.TextShimmer, { active: true, children: title });
576
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
431
577
  "div",
432
578
  {
433
579
  className: "dsh-notify-card",
@@ -435,9 +581,9 @@ function NotifyCard({ data, form, openFile, t }) {
435
581
  "data-state": data.settled ? "settled" : "running",
436
582
  "data-collapsible": collapsible || void 0,
437
583
  children: [
438
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsh-notify-head", children: [
439
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-notify-dot", "aria-hidden": "true" }),
440
- collapsible ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
584
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-notify-head", children: [
585
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-notify-dot", "aria-hidden": "true" }),
586
+ collapsible ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
441
587
  "button",
442
588
  {
443
589
  type: "button",
@@ -447,9 +593,9 @@ function NotifyCard({ data, form, openFile, t }) {
447
593
  setOpen((value) => !value);
448
594
  },
449
595
  children: [
450
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-notify-title", children: titleNode }),
451
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
452
- import_dsh_client_ui_primitives2.IconChevronDownOutlineRegular,
596
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-notify-title", children: titleNode }),
597
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
598
+ import_dsh_client_ui_primitives3.IconChevronDownOutlineRegular,
453
599
  {
454
600
  className: "dsh-notify-chevron",
455
601
  "data-open": expanded || void 0,
@@ -458,23 +604,23 @@ function NotifyCard({ data, form, openFile, t }) {
458
604
  )
459
605
  ]
460
606
  }
461
- ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-notify-title", children: titleNode }),
462
- time === null ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dsh-notify-time", children: time })
607
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-notify-title", children: titleNode }),
608
+ time === null ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-notify-time", children: time })
463
609
  ] }),
464
- expanded && hasBody ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsh-notify-body", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.MarkdownDelegateProvider, { openFile, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.MarkdownText, { text: data.message, labels: markdownLabels(t), variant: "compact" }) }) }) : null
610
+ expanded && hasBody ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-notify-body", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.MarkdownDelegateProvider, { openFile, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives3.MarkdownText, { text: data.message, labels: markdownLabels(t), variant: "compact" }) }) }) : null
465
611
  ]
466
612
  }
467
613
  );
468
614
  }
469
615
 
470
616
  // src/client/NotifyNodeView.tsx
471
- var import_jsx_runtime3 = require("react/jsx-runtime");
617
+ var import_jsx_runtime4 = require("react/jsx-runtime");
472
618
  function NotifyNodeView({ node, openFile, t, form }) {
473
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NotifyCard, { data: node.data, form, openFile, t });
619
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NotifyCard, { data: node.data, form, openFile, t });
474
620
  }
475
621
 
476
622
  // src/client/NotifyRow.tsx
477
- var import_jsx_runtime4 = require("react/jsx-runtime");
623
+ var import_jsx_runtime5 = require("react/jsx-runtime");
478
624
  function NotifyRow(props) {
479
625
  const { t, form } = props;
480
626
  const preparing = props.phase === "preparing";
@@ -485,21 +631,25 @@ function NotifyRow(props) {
485
631
  time: props.block.time,
486
632
  settled: props.phase === "result"
487
633
  };
488
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NotifyCard, { data, form, openFile: props.openFile, t });
634
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NotifyCard, { data, form, openFile: props.openFile, t });
489
635
  }
490
636
 
491
637
  // src/client/ConfigCard.css
492
- var ConfigCard_default = "/* \u63D2\u4EF6\u9875\u4E0A\u7684\u50AC\u529E\u9608\u503C\u914D\u7F6E\u5361\u3002 */\n\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";
638
+ var ConfigCard_default = "/* \u63D2\u4EF6\u9875\u4E0A\u7684\u50AC\u529E\u914D\u7F6E\u5361\u3002 */\n\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";
493
639
 
494
640
  // src/client/NotifyCard.css
495
641
  var NotifyCard_default = "/* `notify_user` \u7684\u8FDB\u5EA6\u5361\uFF1A\u5706\u70B9 + \u6807\u9898 + \u6298\u53E0\u952E + \u65F6\u95F4\uFF0C\u6B63\u6587\u9ED8\u8BA4\u5C55\u5F00\u3002 */\n\n.dsh-notify-card {\n padding: 2px 0 8px;\n}\n\n.dsh-notify-head {\n display: flex;\n align-items: center;\n gap: 8px;\n min-height: 24px;\n}\n\n.dsh-notify-dot {\n width: 7px;\n height: 7px;\n flex: none;\n border-radius: 50%;\n corner-shape: round;\n background: var(--dsw-alias-state-business-primary);\n}\n\n.dsh-notify-toggle {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-notify-title {\n color: var(--dsw-alias-state-business-primary);\n font-size: 14px;\n font-weight: 600;\n line-height: 22px;\n}\n\n.dsh-notify-chevron {\n flex: none;\n color: var(--dsw-alias-state-business-primary);\n transition: transform 0.15s ease;\n}\n\n.dsh-notify-chevron[data-open] {\n transform: rotate(180deg);\n}\n\n.dsh-notify-time {\n flex: none;\n margin-left: auto;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-notify-body {\n margin: 2px 0 0 3px;\n padding-left: 14px;\n border-left: 1px solid var(--dsw-alias-border-l1);\n color: var(--dsw-alias-label-primary);\n}\n\n/* \u5BBF\u4E3B\u7684 compact markdown \u81EA\u5E26\u7070\u5B57\uFF0C\u8FD9\u91CC\u6309\u6563\u6587\u9ED1\u8986\u76D6\u5230\u5B83\u7684\u6839\u8282\u70B9\u3002 */\n.dsh-notify-body > div {\n color: var(--dsw-alias-label-primary);\n}\n";
496
642
 
643
+ // src/client/EnabledToggle.css
644
+ var EnabledToggle_default = "/* \u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7\u83DC\u5355\u91CC\u7684\u300C\u4E3B\u52A8\u6C47\u62A5\u300D\u5F00\u5173\u3002 */\n\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/* \u5F00\u5173\u7684\u70B9\u51FB\u533A\u94FA\u6EE1\u6574\u884C\uFF0C\u4F46\u4E0D\u5305\u4F4F\u4FE1\u606F\u6309\u94AE\u3002 */\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";
645
+
497
646
  // src/client/index.ts
498
647
  var name = BUNDLE_NAME;
499
648
  var inject = ["configForms", "slots", "locale", "uiConversation"];
500
649
  var SHEETS = [
501
650
  ["NotifyCard.css", NotifyCard_default],
502
- ["ConfigCard.css", ConfigCard_default]
651
+ ["ConfigCard.css", ConfigCard_default],
652
+ ["EnabledToggle.css", EnabledToggle_default]
503
653
  ];
504
654
  function injectStyles() {
505
655
  if (typeof document === "undefined") return;
@@ -556,6 +706,12 @@ function apply(ctx) {
556
706
  locale: NS,
557
707
  inject: () => ({ form: ctx.configForms.get(SETTINGS_NAMESPACE) })
558
708
  }, NotifyRow));
709
+ ctx.slots.inject(MODEL_OPTIONS_SLOT, () => ctx.slots.register({
710
+ name: MODEL_OPTIONS_SLOT,
711
+ id: "notify-user-enabled",
712
+ locale: NS,
713
+ inject: () => ({ form: ctx.configForms.get(SETTINGS_NAMESPACE) })
714
+ }, EnabledToggle));
559
715
  ctx.effect(() => ctx.configForms.whileServed([SETTINGS_NAMESPACE], () => ctx.slots.inject(
560
716
  BUNDLE_CONFIG_SLOT,
561
717
  () => ctx.slots.register({