dsh-progress-union 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.7.6 (2026-12-04)
6
+
7
+ **fix(settings):设置卡的嵌套组改走 `scope.mutate` 叶路径 —— 此前每一次组写都被宿主拒收。**
8
+
9
+ 真机回灌(沙箱宿主 0.2.2-rc.5 + dsh-progress-union 0.7.5):拿新上的「LLM 操作与队列提醒」卡拨 `ops.enabled` 关,UI 直接报「**有未保存的改动**」+「**保存失败**」;抓同源请求:
10
+
11
+ ```
12
+ POST api/settings/mutate {"ns":"progress-union","ops":[{"op":"set","path":["ops"],"value":{"enabled":false}}],"expectedRevision":0}
13
+ → {"result":{"ok":false,"error":{"code":"settings/rejected","message":"Config field \"ops\" is not volatile"}}}
14
+ ```
15
+
16
+ 查宿主 `@deepseek-ai/dsh-settings`:`isVolatilePath(schema, path)` 从根节点逐段下钻,`path:["ops"]` 要的是 **`ops` 这个对象自己**带 volatile,而本插件(按宿主表单生成的规则)只在**叶子上**标 `.volatile()`;再看客户端 `config-form.ts` —— `set(field, value)` 写死 `path: [field]` 单段,注释也明说 field 是 “scalar field inside the namespace section”。两条合起来:**嵌套组永远写不进去**。也就是说这个缺陷从设置卡上线那天起就存在,`assistant` / `observer` / `todo` 三组的开关和分段控件同样是“拨得动、落不了盘”(`notifyMajorChanges` / `todoSync` 这类顶层标量不受影响)。用户能真正把配置写进去一直是靠 profile 的 `cordis.patch.yml`,所以从未暴露。
17
+
18
+ - **新增 `writeOps(ops)`**:走 `scope.mutate` 的多段 path,`commitNow` 只写 `[…, key]` 这一条叶子,`flush()` 把草稿里的脏键一次原子提交;老宿主没有 `mutate` 句柄时才退回原来的整组 `set`(`canMutate()` 判定)。
19
+ - **顺带堵住一个静默数据丢失**:原来的整组铺回会把 `assistant` 整对象写回去,而 `apiKey` 是 `role('secret')`、前端快照里只有脱敏值 —— 一旦写入成功就会用脱敏串覆盖真密钥。叶路径只写用户真正动过的字段,`mutate` 的注释也正是为这种“视图不完整”的调用方设计的。
20
+ - **文案纠错**:侧边栏 `llmHint` 与实际座位不符(写的是「设置 → 插件 → dsh-progress-union」,实测在「设置 → 进度板」独立分节;bundle 详情页那个座位在本宿主里并不渲染本插件的卡),zh/en 均改为「设置 → 进度板」/ “Settings → Progress board”。
21
+ - **测试**:`test/settings.test.mjs` +1 用例「设置卡:每条写路径必须是 Config 里的 volatile 叶子」——从 client.js 扫出全部 `switchInput/segmentInput/numberInput/textInput/secretInput/commit` 接线(26 条)逐条对照 schema,漏标 volatile 或缺键即红;并把“嵌套组不得再整对象铺回”钉成反向断言。`npm test` **245 pass / 0 fail**(244 → +1),零回归。
22
+
23
+ ## 0.7.5 (2026-12-04)
24
+
25
+ **feat(settings):`ops.enabled` 等 v0.7.0 四组开关第一次有了真正可达的表单入口;ops 操作块不再把开关位钉在首帧。**
26
+
27
+ 真机回灌(沙箱宿主 0.2.2-rc.5 + 0.7.4):为了验「关掉 ops 后整块收起」,先往 profile 的 `cordis.patch.yml` 写 `ops: {enabled: false}`,重启后 `/progress-union/ops/providers` 照旧 `disabled:false`。同一条 patch 里 `assistant.mode: registered` 也已写了几个月,而 `configured` 回执一直是 `{mode:""}` —— 两个探针合起来指向同一个根因:**那条目的 `id` 写成了 `dsh-external/dsh-progress-union`,宿主里根本查无此串**。外部 bundle 的 patch 目标 id 是插件自身 `cordis.patch.yml` 里 `insert:` 的 **entry id**(本插件 = `progress-union`),既不是包名也不是 `dsh-external/<包名>`;且同层覆盖是**按键整体替换、不深合并**。改成 `id: progress-union` 后 `configured.mode` 立刻变 `registered`、`disabled` 立刻变 `true`。
28
+
29
+ 顺着这条线查下去又抓到一个更基本的缺口:**设置卡只渲染 `assistant` / `observer` / `todo` 三组**(`readField` 里写死三元,其余组一律落到 observer 的桶),宿主也不会为外部插件另生成通用表单 —— 两个座位(`settings.section` 与 `plugins.bundle.config`)实测都只有那 4 组 10 个控件,全 DOM 搜不到 `ops` 字样。也就是说 0.7.2 上线的「整块开关」和 download/toolGloss/notifyMajorChanges 一样,**只有 schema、没有用户可达的入口**。
30
+
31
+ - **`ProgressUnionSettings` 补两张卡**:「下载感知与工序」(`download.enabled` / `showSubBar` / `markBackground` / `ttlMs` + `toolGloss.enabled` / `softNarrate` / `maxLen`)与「LLM 操作与队列提醒」(`ops.enabled` + 顶层标量 `notifyMajorChanges`)。开关走 `commitNow` 即时落盘,数字走草稿由「保存」提交,与既有三组同构。
32
+ - **`readField` 改为组查表**(`buckets = { assistant, observer, todo, download, toolGloss, ops }`),`flush()` 同步补上三个新组的整体回写;此前若只接线开关不接回写,会表现成「拨了开关但从未落盘」。
33
+ - **`LlmOpsBlock` 定期重探开关位**:新增 `OPS_POLL_MS = 15000`,`setOff(true)` 与 `setOff(false)` 成对出现,设置页拨完无需重挂载就跟上;默认 provider/model 只在首次探测回填(`primed` ref),不覆用户手选。卸载收定时器。
34
+ - **文案**:zh/en 各 +17 键(`setDl*` / `setGloss*` / `setOps*` / `setNotifyMajor*`)。本插件只注册 `zh`/`en` 两语,其余语种按既有设计回退英文。
35
+ - **测试**:`test/settings.test.mjs` +2 用例并扩写 volatile 叶子清单(补 `download.*`/`toolGloss.*`/`notifyMajorChanges`/`ops.enabled`,漏一个就红):一张断言「有 volatile 就必须有表单入口」,一张断言开关位定期重探不钉首帧。`npm test` **244 pass / 0 fail**(242 → +2),零回归。
36
+
37
+
5
38
  ## 0.7.4 (2026-12-04)
6
39
 
7
40
  **fix(download):工具名本身就是解释器(实测 `pwsh`)时不再被 `isShell` 门拦下。**
package/README.md CHANGED
@@ -114,7 +114,7 @@ curl "http://127.0.0.1:<web-port>/progress-union/archive/version?sessionId=<sid>
114
114
 
115
115
  `progressAnchor` 锚点只**追加** `archive: { seq, revision, at, reason, handoff, degraded }`;`ANCHOR_VERSION` 仍为 1,老 consumer 可选链读取即可。失败只写 `archiveError`(快照 `archive.error` 回显),绝不阻断板写入。
116
116
 
117
- ### 配置(设置 → 插件,全部有默认值、老 profile 零迁移)
117
+ ### 配置(设置页「进度板」分节,全部有默认值、老 profile 零迁移)
118
118
 
119
119
  | key | 默认 | 说明 |
120
120
  | --- | --- | --- |
@@ -268,7 +268,7 @@ assistant:
268
268
  ## 开发与测试
269
269
 
270
270
  ```bash
271
- npm test # node --test test/*.test.mjs(242 用例,纯 mock ctx,无需宿主进程)
271
+ npm test # node --test test/*.test.mjs(245 用例,纯 mock ctx,无需宿主进程)
272
272
  ```
273
273
 
274
274
  ## 冷启动接续(v0.6.2)
@@ -312,7 +312,18 @@ npm test # node --test test/*.test.mjs(242 用例,纯 mock ctx,无需宿
312
312
 
313
313
  选模型口径同 prime-memory:`GET /ops/providers` 读宿主 `llm.listProviders()` 与默认模型选择,宿主没给服务时退回设置页里的 `assistant.provider/model`(下拉显示「沿用设置页」),不报错。落盘走同一条 `callAssistant → parseProposal → applyChanges(origin:'ops')` 通道:改动截 8 条、未知 id 与空 title 丢弃、模型答非 JSON 返 502 且**板 revision 不动**、未配置模型返 400。`origin:'ops'` 不算「主模型刚刚同过步」,催办计时不被侧边栏操作抹平。
314
314
 
315
- **整块开关 `ops.enabled`(v0.7.2,默认开)**:关掉后 `GET /ops/providers` 直接报 `disabled:true` 且**不再打宿主 `listProviders`**,客户端据此把「LLM 操作」块整块收起(不是一堆禁用按钮,也不是报错);`POST /ops` 的 refine / mutate / ask 一律 **403**,唯独 `validate` 照常 200 —— 它是零 token 的本地板面体检,与花不花钱无关。该键与 `download.*` / `toolGloss.*` 同级:逐叶子 `.volatile()`、`DEFAULT_CONFIG.ops`、`flatSection('ops', …)` 三处齐全,设置页改完即生效,老 profile 零迁移。默认模型仍只走 `assistant.*` 与宿主当前选择,本开关不提供 `defaultProvider/defaultModel` 覆盖(计划里的那两个字段由宿主选择器承担,避免第二套模型配置面)。
315
+ **整块开关 `ops.enabled`(v0.7.2,默认开)**:关掉后 `GET /ops/providers` 直接报 `disabled:true` 且**不再打宿主 `listProviders`**,客户端据此把「LLM 操作」块整块收起(不是一堆禁用按钮,也不是报错);`POST /ops` 的 refine / mutate / ask 一律 **403**,唯独 `validate` 照常 200 —— 它是零 token 的本地板面体检,与花不花钱无关。该键与 `download.*` / `toolGloss.*` / `notifyMajorChanges` 同级:逐叶子 `.volatile()`、`DEFAULT_CONFIG.ops`、`flatSection('ops', …)` 三处齐全。表单入口从 **v0.7.5** 起真的存在(见下一节);开关关掉时服务端的 403 / `disabled` 判定是即时的,客户端块的隐去靠一次轮询重探(最多 15s),无需重加载页面。默认模型仍只走 `assistant.*` 与宿主当前选择,本开关不提供 `defaultProvider/defaultModel` 覆盖(计划里的那两个字段由宿主选择器承担,避免第二套模型配置面)。
316
+
317
+ ## 设置页开关(v0.7.5 表单入口,v0.7.6 写面修正)
318
+
319
+ 设置页里的「进度板」分节(宿主把本插件的 composition entry 直接当成一个独立设置节,导航文案 = `setTitle`)现在共 6 组:除原有的辅助 LLM / 观察者 / 官方 todo 同步外,新增两张:
320
+
321
+ - **下载感知与工序**:`download.enabled`(关掉即观察块不出 `⬇` 行、快照 `download.active` 恒为 false)、`download.showSubBar`(不再下发 download 字段)、`download.markBackground`(后台徽标)、`download.ttlMs`(一次下载算「还在跑」的窗口),以及 `toolGloss.enabled` / `toolGloss.softNarrate` / `toolGloss.maxLen`(关掉后「最近动作」逐字退回 0.6.x 的 `name×count`)。
322
+ - **LLM 操作与队列提醒**:`ops.enabled`(整块开关)与 `notifyMajorChanges`(结构性变更是否落输入队列)。
323
+
324
+ 开关类拨完即落盘,数字类进草稿、点「保存」提交。**v0.7.6 前这里全是坏的**:宿主 `ConfigForm.set(field, value)` 只支持**顶层标量**(它把 path 拼成单段 `[field]`),而 `isVolatilePath` 对 `path:["ops"]` 要的是组对象自己带 volatile——本插件按表单生成规则只在**叶子**上标,所以嵌套组的整对象写回一律 `settings/rejected: Config field "ops" is not volatile`(UI 表现为「保存失败」+「有未保存的改动」)。现在嵌套组走 `scope.mutate([{ op:'set', path:[group, key], value }])` 的**叶路径**(老宿主无 `mutate` 时才退回整组 `set`);`test/settings.test.mjs` 把「设置卡实写的每条路径 ∈ volatile 叶子」钉成回归闸。
325
+
326
+ 两个已经踩实的坑:**一** 叶路径只写用户真正动过的字段,顺便避免了旧写法的隐患——`assistant.apiKey` 是 `role('secret')`,快照里只有脱敏值,整对象铺回一旦成功就是用脱敏串盖掉真密钥;**二** 从 profile 的 `cordis.patch.yml` 手工覆盖时,条目 `id` 必须是插件自身 `insert:` 里的 **entry id**(本插件 = `progress-union`),写成包名或 `dsh-external/<包名>` 会整段静默不下发(不报错,只是配置始终是默认值);且同层覆盖**按顶层键整体替换、不深合并**。
316
327
 
317
328
  ## 重大变更落输入队列(v0.7.0)
318
329
 
package/client.js CHANGED
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
24
24
  var REPO_URL = "https://github.com/drscrewdriver/dsh-progress-union";
25
25
  var STAR_NS = "progress-union";
26
26
  var STAR_GEN = "v4"; /* ladder:gen */
27
- var STAR_VERSION = "0.7.4"; /* ladder:ver */
27
+ var STAR_VERSION = "0.7.6"; /* ladder:ver */
28
28
  var LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
29
29
 
30
30
  // 三代共享:GitHub 单色 mark(octicon 轮廓,fill 随 currentColor)。
@@ -204,7 +204,7 @@ window.__ModuleLoader__.load({
204
204
  window.dispatchEvent(new CustomEvent(PROGRESS_EVENT, { detail: { sessionId, snapshot } }))
205
205
  }
206
206
 
207
- // 辅助 LLM 的配置面不在客户端:宿主设置页(设置 → 插件 → dsh-progress-union)
207
+ // 辅助 LLM 的配置面不在客户端:宿主设置页(设置 → 进度板)
208
208
  // 按插件导出的 Config 逐叶子 .volatile() 自动生成表单,本面板只做只读状态展示。
209
209
 
210
210
  /*
@@ -420,7 +420,7 @@ window.__ModuleLoader__.load({
420
420
  llmOn: '已启用',
421
421
  llmOff: '未启用:观察者为规则版(零 LLM 费用)。启用后由辅助模型管理任务槽位、产出续轮建议。',
422
422
  llmAuto: ',自动落地',
423
- llmHint: '配置在「设置 → 插件 → dsh-progress-union」:mode 选 registered 复用 Settings→模型 里的 provider/model(走宿主,免密钥),或 direct 直连自建 OpenAI 兼容端点。仅滞后时触发,每回合至多一次。助手可增删改槽位并产出轮次草案(仅供参考),判断权归主模型。',
423
+ llmHint: '配置在「设置 → 进度板」:mode 选 registered 复用 Settings→模型 里的 provider/model(走宿主,免密钥),或 direct 直连自建 OpenAI 兼容端点。仅滞后时触发,每回合至多一次。助手可增删改槽位并产出轮次草案(仅供参考),判断权归主模型。',
424
424
  llmSettingsHint: '在设置页修改',
425
425
  // v0.7.0 R3:侧边栏「LLM 操作」小块(就地写回本板,不新开顶级标签)
426
426
  opsTitle: 'LLM 操作',
@@ -477,6 +477,23 @@ window.__ModuleLoader__.load({
477
477
  setTodoReconcileMs: '裁决最小间隔(毫秒)',
478
478
  setTodoThrottleMs: '镜像去抖(毫秒)',
479
479
  setTodoWriteNote: '写入事件:agent.session.append(\'todo/write\', { todos })(只读说明)',
480
+ setDlGroup: '下载感知与工序',
481
+ setDlBadge: '感知',
482
+ setDlHint: '下载只做软感知(识别 + 催办),绝不拦截工具;关掉后观察块逐字退回 0.6.x 文案。',
483
+ setDlEnabled: '启用下载感知',
484
+ setDlSubBar: '迷你条下方画下载子进度条',
485
+ setDlSubBarHint: '关掉即快照不再下发 download 字段;无真值时只走条纹时长态,绝不显示假百分比。',
486
+ setDlBg: '后台下载加徽标',
487
+ setDlTtlMs: '下载存活窗口(毫秒)',
488
+ setGlossEnabled: '工序说人话(最近动作改写成一句)',
489
+ setGlossNarrate: '追加一行叙述纪律(▸ 动作 → 本步目的)',
490
+ setGlossMaxLen: '工序句上限(字)',
491
+ setOpsGroup: 'LLM 操作与队列提醒',
492
+ setOpsBadge: '操作',
493
+ setOpsHint: '关掉即侧边栏「LLM 操作」整块收起:提供方不再枚举,细化/改板/问询返回 403;「校验」是零 token 的本地板面体检,照常可用。',
494
+ setOpsEnabled: '开放 LLM 任务操作',
495
+ setNotifyMajor: '结构性变更落输入队列(黄档)',
496
+ setNotifyMajorHint: '增删/重排任务时往队列插一条提醒,让模型先对齐板面;纯状态刷新不触发。',
480
497
  setSaved: '已保存',
481
498
  setFailed: '保存失败',
482
499
  setReadOnly: '当前 config 不可写',
@@ -620,7 +637,7 @@ window.__ModuleLoader__.load({
620
637
  llmOn: 'Enabled',
621
638
  llmOff: 'Disabled: the observer is rule-based (zero LLM cost). When enabled, the assistant manages task slots and produces round suggestions.',
622
639
  llmAuto: ', auto-applied',
623
- llmHint: 'Configure in Settings → Plugins → dsh-progress-union: set mode=registered to reuse a provider/model from Settings → Models (via host, no API key), or mode=direct for a self-hosted OpenAI-compatible endpoint. Triggered only while overdue, at most once per turn. The assistant may add/edit/remove slots and emit round suggestions (advice only); the main model decides.',
640
+ llmHint: 'Configure in Settings → Progress board: set mode=registered to reuse a provider/model from Settings → Models (via host, no API key), or mode=direct for a self-hosted OpenAI-compatible endpoint. Triggered only while overdue, at most once per turn. The assistant may add/edit/remove slots and emit round suggestions (advice only); the main model decides.',
624
641
  llmSettingsHint: 'Change in Settings',
625
642
  // v0.7.0 R3: in-panel "LLM actions" block (writes back here, no new top-level tab)
626
643
  opsTitle: 'LLM actions',
@@ -677,6 +694,23 @@ window.__ModuleLoader__.load({
677
694
  setTodoReconcileMs: 'Reconcile min interval (ms)',
678
695
  setTodoThrottleMs: 'Mirror debounce (ms)',
679
696
  setTodoWriteNote: 'Write event: agent.session.append(\'todo/write\', { todos }) (read-only)',
697
+ setDlGroup: 'Downloads & step gloss',
698
+ setDlBadge: 'Awareness',
699
+ setDlHint: 'Download awareness stays soft (detect + nudge) and never blocks a tool; switching it off restores the pre-0.7 observer text verbatim.',
700
+ setDlEnabled: 'Enable download awareness',
701
+ setDlSubBar: 'Draw the download sub-bar under the mini bar',
702
+ setDlSubBarHint: 'Off stops emitting the download field in the snapshot. Without a real figure only the striped elapsed state shows — never a fake percentage.',
703
+ setDlBg: 'Badge background downloads',
704
+ setDlTtlMs: 'Download liveness window (ms)',
705
+ setGlossEnabled: 'Plain-language step gloss',
706
+ setGlossNarrate: 'Append one narration-discipline line (▸ action → purpose)',
707
+ setGlossMaxLen: 'Max gloss length (chars)',
708
+ setOpsGroup: 'LLM actions & queue notices',
709
+ setOpsBadge: 'Actions',
710
+ setOpsHint: 'Off collapses the sidebar “LLM actions” block: providers stop enumerating and refine/mutate/ask return 403. Validate is a zero-token local check and stays available.',
711
+ setOpsEnabled: 'Allow LLM board actions',
712
+ setNotifyMajor: 'Route structural changes into the input queue (yellow tier)',
713
+ setNotifyMajorHint: 'Inserts one queue message on add/remove/reorder so the model re-aligns the board; pure status refreshes never trigger it.',
680
714
  setSaved: 'Saved',
681
715
  setFailed: 'Save failed',
682
716
  setReadOnly: 'Current config is not writable',
@@ -1593,6 +1627,10 @@ window.__ModuleLoader__.load({
1593
1627
  return { response, body }
1594
1628
  }
1595
1629
 
1630
+ // ops 开关位的重探间隔:比快照轮询慢一档(省一次宿主 listProviders),
1631
+ // 但足够让设置页拨完开关后无需重挂载就跟上。
1632
+ const OPS_POLL_MS = 15000
1633
+
1596
1634
  async function fetchOpsProviders() {
1597
1635
  const response = await fetch(`${API}/ops/providers`, { method: 'GET', credentials: 'same-origin' })
1598
1636
  const body = await response.json().catch(() => null)
@@ -1635,23 +1673,38 @@ window.__ModuleLoader__.load({
1635
1673
  const [busy, setBusy] = useState('')
1636
1674
  const [out, setOut] = useState(null)
1637
1675
  const [off, setOff] = useState(false)
1676
+ const primed = useRef(false)
1638
1677
 
1678
+ // 开关位不能只信首帧:ops.enabled 是 volatile,设置页改完服务端立刻 403/放行,
1679
+ // 但客户端若在挂载前就拿到旧值,块会一直缺席(或一直留着)。因此按 OPS_POLL_MS
1680
+ // 重探一次,并只在首次探测时回填默认 provider/model,避免覆掉用户手选。
1639
1681
  useEffect(() => {
1640
1682
  let alive = true
1641
- fetchOpsProviders()
1642
- .then((data) => {
1643
- if (!alive) return
1644
- if (data.disabled) {
1645
- setOff(true)
1646
- return
1647
- }
1648
- setProviders(data.providers)
1649
- const d = data.default || {}
1650
- if (d.provider) setProvider(String(d.provider))
1651
- if (d.model) setModel(String(d.model))
1652
- })
1653
- .catch(() => {})
1654
- return () => { alive = false }
1683
+ const probe = () => {
1684
+ fetchOpsProviders()
1685
+ .then((data) => {
1686
+ if (!alive) return
1687
+ if (data.disabled) {
1688
+ setOff(true)
1689
+ return
1690
+ }
1691
+ // 改回开:块得自己回来,不能等重挂载。
1692
+ setOff(false)
1693
+ setProviders(data.providers)
1694
+ if (primed.current) return
1695
+ primed.current = true
1696
+ const d = data.default || {}
1697
+ if (d.provider) setProvider(String(d.provider))
1698
+ if (d.model) setModel(String(d.model))
1699
+ })
1700
+ .catch(() => {})
1701
+ }
1702
+ probe()
1703
+ const timer = setInterval(probe, OPS_POLL_MS)
1704
+ return () => {
1705
+ alive = false
1706
+ clearInterval(timer)
1707
+ }
1655
1708
  }, [sessionId])
1656
1709
 
1657
1710
  const active = providers.find((p) => p && p.id === provider) || null
@@ -2247,7 +2300,7 @@ window.__ModuleLoader__.load({
2247
2300
  )
2248
2301
  }
2249
2302
 
2250
- // 只读状态行:配置面归宿主设置页(设置 → 插件 → dsh-progress-union),
2303
+ // 只读状态行:配置面归宿主设置页(设置 → 进度板),
2251
2304
  // 侧边栏不再放编辑表单(避免两处写同一命名空间)。
2252
2305
  function LlmAssistNotice(props) {
2253
2306
  const t = makeT(props)
@@ -2521,18 +2574,55 @@ window.__ModuleLoader__.load({
2521
2574
  const assistant = asObject(value.assistant)
2522
2575
  const observer = asObject(value.observer)
2523
2576
  const todo = asObject(value.todo)
2577
+ // v0.7.5:download/toolGloss/ops 三组也要能在设置卡里拨——此前只有
2578
+ // assistant/observer/todo 进了表单,导致 ops.enabled=false 这个整块开关
2579
+ // 没有用户可达的入口(宿主不会为外部插件另生成通用表单)。
2580
+ const download = asObject(value.download)
2581
+ const toolGloss = asObject(value.toolGloss)
2582
+ const ops = asObject(value.ops)
2583
+ const buckets = { assistant, observer, todo, download, toolGloss, ops }
2524
2584
 
2525
2585
  // 文本/数字走草稿(避免逐字符写盘),开关与分段直接落盘(即时生效)。
2526
2586
  const readField = (group, key, fallback) => {
2527
2587
  const bucket = draft[group]
2528
2588
  if (bucket && Object.prototype.hasOwnProperty.call(bucket, key)) return bucket[key]
2529
- const stored = (group === 'assistant' ? assistant : group === 'todo' ? todo : observer)[key]
2589
+ const stored = (buckets[group] || observer)[key]
2530
2590
  return stored === undefined || stored === null ? fallback : stored
2531
2591
  }
2532
2592
  const setDraftField = (group, key, v) => setDraft((prev) => ({ ...prev, [group]: { ...(prev[group] || {}), [key]: v } }))
2533
2593
  const dirtyKeys = (group) => Object.keys(draft[group] || {})
2534
2594
 
2595
+ // 宿主 ConfigForm 的写面(0.2.2 实证):`set(field, value)` 只支持**顶层标量**
2596
+ // —— 它把 path 拼成单段 [field],而 Config 的 volatile 是逐叶子标的(组对象
2597
+ // 本身没标),于是整对象写嵌套组一律被 settings/rejected 挡掉:
2598
+ // Config field "ops" is not volatile
2599
+ // 症状就是“拨了开关→保存失败→值不落盘”(0.7.5 真机实测)。嵌套组必须走
2600
+ // scope.mutate 的多段 path;顺带也避免把整组铺回去——assistant 里有
2601
+ // role('secret') 的 apiKey,前端只拿到脱敏后的值,整对象写回会抹掉真密钥。
2602
+ const canMutate = () => Boolean(scope) && typeof scope.mutate === 'function'
2603
+ const writeOps = async (ops) => {
2604
+ if (!scope) {
2605
+ setStatus(t('setNoScope'))
2606
+ return false
2607
+ }
2608
+ if (!writable) {
2609
+ setStatus(t('setReadOnly'))
2610
+ return false
2611
+ }
2612
+ setBusy(true)
2613
+ try {
2614
+ const ok = await scope.mutate(ops)
2615
+ setStatus(ok === false ? t('setFailed') : t('setSaved'))
2616
+ return ok !== false
2617
+ } catch (_error) {
2618
+ setStatus(t('setFailed'))
2619
+ return false
2620
+ } finally {
2621
+ setBusy(false)
2622
+ }
2623
+ }
2535
2624
  const commit = async (group, patch) => {
2625
+ if (canMutate()) return writeOps([{ op: 'set', path: [group], value: patch }])
2536
2626
  if (!scope) {
2537
2627
  setStatus(t('setNoScope'))
2538
2628
  return false
@@ -2553,14 +2643,21 @@ window.__ModuleLoader__.load({
2553
2643
  setBusy(false)
2554
2644
  }
2555
2645
  }
2556
- const commitNow = (group, base, key, next) => void commit(group, { ...base, [key]: next })
2646
+ // 单字段落盘:有 mutate 就只写这一条 path,老宿主才退回整组铺回。
2647
+ const commitNow = (group, base, key, next) => {
2648
+ if (canMutate()) return void writeOps([{ op: 'set', path: [group, key], value: next }])
2649
+ return void commit(group, { ...(base || {}), [key]: next })
2650
+ }
2557
2651
  const flush = async () => {
2558
- const aKeys = dirtyKeys('assistant')
2559
- const oKeys = dirtyKeys('observer')
2560
- const todoKeys = dirtyKeys('todo')
2561
- if (aKeys.length) await commit('assistant', { ...assistant, ...draft.assistant })
2562
- if (oKeys.length) await commit('observer', { ...observer, ...draft.observer })
2563
- if (todoKeys.length) await commit('todo', { ...todo, ...draft.todo })
2652
+ for (const group of ['assistant', 'observer', 'todo', 'download', 'toolGloss', 'ops']) {
2653
+ const keys = dirtyKeys(group)
2654
+ if (!keys.length) continue
2655
+ if (canMutate()) {
2656
+ await writeOps(keys.map((key) => ({ op: 'set', path: [group, key], value: draft[group][key] })))
2657
+ } else {
2658
+ await commit(group, { ...(buckets[group] || {}), ...draft[group] })
2659
+ }
2660
+ }
2564
2661
  setDraft({})
2565
2662
  }
2566
2663
 
@@ -2614,7 +2711,7 @@ window.__ModuleLoader__.load({
2614
2711
  },
2615
2712
  })
2616
2713
 
2617
- const hasDirty = dirtyKeys('assistant').length > 0 || dirtyKeys('observer').length > 0 || dirtyKeys('todo').length > 0 || Object.prototype.hasOwnProperty.call(draft, 'todoSync')
2714
+ const hasDirty = ['assistant', 'observer', 'todo', 'download', 'toolGloss', 'ops'].some((g) => dirtyKeys(g).length > 0) || Object.prototype.hasOwnProperty.call(draft, 'todoSync') || Object.prototype.hasOwnProperty.call(draft, 'notifyMajorChanges')
2618
2715
  const mode = readField('assistant', 'mode', '')
2619
2716
  const authority = readField('assistant', 'authority', 'both')
2620
2717
 
@@ -2655,6 +2752,28 @@ window.__ModuleLoader__.load({
2655
2752
  h(SettingsRow, { label: t('setAutoSyncThrottleMs') }, numberInput('observer', 'autoSyncThrottleMs', 60000, 1000, 'ms')),
2656
2753
  h(SettingsRow, { label: t('setMaxItems') }, numberInput('observer', 'maxItems', 12, 1, '项')),
2657
2754
  ),
2755
+ h(
2756
+ SettingsCard,
2757
+ { title: t('setDlGroup'), badge: t('setDlBadge'), hint: t('setDlHint'), defaultOpen: false },
2758
+ h(SettingsRow, { label: t('setDlEnabled') }, switchInput('download', download, 'enabled', true)),
2759
+ h(SettingsRow, { label: t('setDlSubBar'), hint: t('setDlSubBarHint') }, switchInput('download', download, 'showSubBar', true)),
2760
+ h(SettingsRow, { label: t('setDlBg') }, switchInput('download', download, 'markBackground', true)),
2761
+ h(SettingsRow, { label: t('setDlTtlMs') }, numberInput('download', 'ttlMs', 480000, 1000, 'ms')),
2762
+ h(SettingsRow, { label: t('setGlossEnabled') }, switchInput('toolGloss', toolGloss, 'enabled', true)),
2763
+ h(SettingsRow, { label: t('setGlossNarrate') }, switchInput('toolGloss', toolGloss, 'softNarrate', true)),
2764
+ h(SettingsRow, { label: t('setGlossMaxLen') }, numberInput('toolGloss', 'maxLen', 46, 1, '')),
2765
+ ),
2766
+ h(
2767
+ SettingsCard,
2768
+ { title: t('setOpsGroup'), badge: t('setOpsBadge'), hint: t('setOpsHint'), defaultOpen: false },
2769
+ h(SettingsRow, { label: t('setOpsEnabled') }, switchInput('ops', ops, 'enabled', true)),
2770
+ h(SettingsRow, { label: t('setNotifyMajor'), hint: t('setNotifyMajorHint') },
2771
+ h(SettingsSwitch, {
2772
+ checked: Object.prototype.hasOwnProperty.call(draft, 'notifyMajorChanges') ? draft.notifyMajorChanges : value.notifyMajorChanges !== false,
2773
+ disabled: !writable || busy,
2774
+ onChange: (v) => { setDraft((prev) => ({ ...prev, notifyMajorChanges: v })); void commit('notifyMajorChanges', v) },
2775
+ })),
2776
+ ),
2658
2777
  h(
2659
2778
  SettingsCard,
2660
2779
  { title: t('setTodoGroup'), badge: t('setTodoSync'), hint: t('setTodoHint'), defaultOpen: false },
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "main": "./index.js",
5
5
  "description": "进度结合原型:board 槽位真相源(用户可编辑、diff+ack 增量同步、staleness nudge)× 鲸程时间引擎(step 计数、ETA 三档 board>todo>local>prior、悬浮迷你条),向压缩插件暴露只读三层进度锚点 progressAnchor(board 语义锚 + time 时间锚 + userEdits 未确认改动,service 与 HTTP 双平面),并在 0.6.0 起每回合落一版会话归档(handoff 规则摘要 + 重启注入一次)。",
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-progress-union",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "type": "module",
5
5
  "description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎;向压缩插件暴露只读三层进度锚点(service + HTTP 双平面);0.6.0 起每回合落一版会话归档(handoff + 重启注入一次)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
6
6
  "license": "MIT",
@@ -51,6 +51,16 @@ test('Config:assistant / observer 的每个叶子都带 volatile(否则设
51
51
  'todoSync',
52
52
  'todo.maxReconcileIntervalMs',
53
53
  'todo.mirrorThrottleMs',
54
+ // v0.7.0 新增面:漏一个叶子就不会出现在宿主表单里,也不会热生效。
55
+ 'download.enabled',
56
+ 'download.ttlMs',
57
+ 'download.showSubBar',
58
+ 'download.markBackground',
59
+ 'toolGloss.enabled',
60
+ 'toolGloss.softNarrate',
61
+ 'toolGloss.maxLen',
62
+ 'notifyMajorChanges',
63
+ 'ops.enabled',
54
64
  ]
55
65
  for (const key of expected) {
56
66
  assert.ok(key in leaves, `缺少配置键 ${key}`)
@@ -79,4 +89,81 @@ test('客户端:设置卡双座位(settings.section + plugins.bundle.config
79
89
  assert.match(src, /function ProgressUnionSettings\(/, '设置卡组件必须在')
80
90
  assert.match(src, /scope\.subscribe/, '设置卡要订阅句柄快照')
81
91
  assert.match(src, /function ensureUnionSettingsStyle\(/, '样式要注入 document.head,否则设置页里裸奔')
92
+ })
93
+
94
+ /**
95
+ * v0.7.5 真机回灌:0.7.2 就把 ops.enabled 做成了「整块开关」,但设置卡只渲染
96
+ * assistant/observer/todo 三组——宿主不会为外部插件另生成通用表单,于是这个开关
97
+ * 根本没有用户可达的入口(实测:两个座位都是那 4 组 10 个控件,搜不到 ops)。
98
+ * download 组、toolGloss 组、notifyMajorChanges 同病。这里钉住「有 volatile 就必须有表单」。
99
+ */
100
+ test('设置卡:v0.7.0 四组开关真的有表单入口(不能只存 schema)', () => {
101
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
102
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
103
+ for (const call of [
104
+ "switchInput('download', download, 'enabled'",
105
+ "switchInput('download', download, 'showSubBar'",
106
+ "switchInput('download', download, 'markBackground'",
107
+ "numberInput('download', 'ttlMs'",
108
+ "switchInput('toolGloss', toolGloss, 'enabled'",
109
+ "switchInput('toolGloss', toolGloss, 'softNarrate'",
110
+ "numberInput('toolGloss', 'maxLen'",
111
+ "switchInput('ops', ops, 'enabled'",
112
+ "commit('notifyMajorChanges', v)",
113
+ ]) {
114
+ assert.ok(src.includes(call), `设置卡缺少表单接线:${call}`)
115
+ }
116
+ // 读值必须按组路由(旧实现写死三元,新组会全读到 observer 的桶里去)。
117
+ assert.match(src, /const buckets = \{ assistant, observer, todo, download, toolGloss, ops \}/, 'readField 需要组查表')
118
+ assert.match(src, /\(buckets\[group\] \|\| observer\)\[key\]/, 'readField 必须走组查表取值')
119
+ // 保存通道也得把新组写回去(不写 = 拨了开关但从未落盘,看着像“配置不下发”)。
120
+ for (const line of [
121
+ "const canMutate = () => Boolean(scope) && typeof scope.mutate === 'function'",
122
+ 'const writeOps = async (ops) => {',
123
+ "if (canMutate()) return void writeOps([{ op: 'set', path: [group, key], value: next }])",
124
+ "await writeOps(keys.map((key) => ({ op: 'set', path: [group, key], value: draft[group][key] })))",
125
+ ]) {
126
+ assert.ok(src.includes(line), `写面缺少叶路径接线:${line}`)
127
+ }
128
+ for (const dead of [
129
+ "await commit('ops', { ...ops, ...draft.ops })",
130
+ "await commit('download', { ...download, ...draft.download })",
131
+ "await commit('assistant', { ...assistant, ...draft.assistant })",
132
+ ]) {
133
+ assert.ok(!src.includes(dead), `嵌套组不得再整对象铺回(会被 settings/rejected 拒):${dead}`)
134
+ }
135
+ // 双语齐(本插件只注册 zh/en,其余语种按设计回退英文)
136
+ assert.equal((src.match(/setOpsEnabled:/g) || []).length, 2, 'setOpsEnabled 需 zh/en 两份')
137
+ assert.equal((src.match(/setDlEnabled:/g) || []).length, 2, 'setDlEnabled 需 zh/en 两份')
138
+ })
139
+
140
+ /**
141
+ * v0.7.6 真机回灌:设置卡此前把嵌套组整对象铺回(scope.set('ops', {...})),
142
+ * 而宿主 ConfigForm.set 只接受顶层标量、Config 的 volatile 又是逐叶子标的,
143
+ * 于是每一次组写都被 settings/rejected 拒(Config field "ops" is not volatile)。
144
+ * 这条把“设置卡实际写的每条路径 ∈ volatile 叶子”钉成回归闸。
145
+ */
146
+ test('设置卡:每条写路径必须是 Config 里的 volatile 叶子', () => {
147
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
148
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
149
+ const leaves = volatileLeaves(Config)
150
+ const paths = new Set()
151
+ for (const m of src.matchAll(/(?:switchInput|segmentInput)\('(\w+)',\s*\w+,\s*'(\w+)'/g)) paths.add(`${m[1]}.${m[2]}`)
152
+ for (const m of src.matchAll(/(?:numberInput|textInput|secretInput)\('(\w+)',\s*'(\w+)'/g)) paths.add(`${m[1]}.${m[2]}`)
153
+ for (const m of src.matchAll(/void commit\('(\w+)'/g)) paths.add(m[1])
154
+ assert.ok(paths.size >= 24, `扫到的写路径只有 ${paths.size} 条,正则可能失效`)
155
+ for (const p of [...paths].sort()) {
156
+ assert.ok(p in leaves, `设置卡要写 ${p},但 Config 里没这个键`)
157
+ assert.equal(leaves[p], true, `设置卡要写 ${p},但它不是 volatile 叶子 → 宿主 settings/rejected`)
158
+ }
159
+ })
160
+
161
+ test('ops 块开关位定期重探,不钉在首帧(热生效无需重挂载)', () => {
162
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
163
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
164
+ assert.match(src, /const OPS_POLL_MS = \d+/, '需要有重探间隔常量')
165
+ assert.match(src, /setInterval\(probe, OPS_POLL_MS\)/, '必须真的定时重探 providers 面')
166
+ assert.match(src, /if \(data\.disabled\) \{[\s\S]{0,80}?setOff\(true\)[\s\S]{0,40}?return[\s\S]{0,120}?setOff\(false\)/, '关掉要隐块,改回开要自动复现(不能只置 true)')
167
+ assert.match(src, /if \(primed\.current\) return/, '默认 provider/model 只在首次回填,不覆用户手选')
168
+ assert.match(src, /clearInterval\(timer\)/, '卸载必须收定时器')
82
169
  })