dsh-progress-union 0.7.5 → 0.7.7

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,40 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.7.7 (2026-12-04)
6
+
7
+ **fix(settings):脏位改按「草稿值 ≠ 存值」算 —— 拨完即落盘的开关不再永久挂着「有未保存的改动」。**
8
+
9
+ 真机回灌(沙箱宿主 0.2.2-rc.5 + 0.7.6):写面已修好(`settings/mutate` 的 `path` 实测为两段 `["ops","enabled"]` / `["download","enabled"]`,四次全部 `ok:true`,`expectedRevision` 0→1→2→3→4 逐次推远,刷新后值仍在),但页脚出现两个提示并存:
10
+
11
+ ```
12
+ <span class="dsu-hint dsu-spacer">有未保存的改动</span><span class="dsu-hint">已保存</span>
13
+ ```
14
+
15
+ 因为 `switchInput` / `segmentInput` 为了避免受控控件闪回, onChange 会先写一份**乐观草稿**再即时提交;而 `dirtyKeys` 当时只看「草稿里有没有这个键」,快照追平后那份草稿已与存储值相同,却仍被计为脏 —— 结果「保存」按钮永远可点,点下去还会把同样的值再写一轮。
16
+
17
+ - **`dirtyKeys(group)` 改为值比对**:拿 `buckets[group]` 做基准,`draft[group][key] !== bucket[key]` 才算脏;顶层标量走同式的 `scalarDirty(key)`(`todoSync` / `notifyMajorChanges`)。`hasDirty` 与 `flush()` 共用这一个口径,落盘完成后自动变清。仍保留乐观草稿(不改回纯受控),避免写入往返期间开关闪回。
18
+ - **不动写面**:0.7.6 定下来的叶路径提交(`scope.mutate` + `[group, key]`)逐字保留,本次只改脏位判定。
19
+ - **测试**:`test/settings.test.mjs` +1 用例「拨完即落盘的开关不再留脏」(钉住值比对、`scalarDirty` 接线,并反向断言旧的 `Object.keys(draft[group] || {})` 一行式必须消失)。`npm test` **246 pass / 0 fail**(245 → +1),零回归。
20
+
21
+ ## 0.7.6 (2026-12-04)
22
+
23
+ **fix(settings):设置卡的嵌套组改走 `scope.mutate` 叶路径 —— 此前每一次组写都被宿主拒收。**
24
+
25
+ 真机回灌(沙箱宿主 0.2.2-rc.5 + dsh-progress-union 0.7.5):拿新上的「LLM 操作与队列提醒」卡拨 `ops.enabled` 关,UI 直接报「**有未保存的改动**」+「**保存失败**」;抓同源请求:
26
+
27
+ ```
28
+ POST api/settings/mutate {"ns":"progress-union","ops":[{"op":"set","path":["ops"],"value":{"enabled":false}}],"expectedRevision":0}
29
+ → {"result":{"ok":false,"error":{"code":"settings/rejected","message":"Config field \"ops\" is not volatile"}}}
30
+ ```
31
+
32
+ 查宿主 `@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`,所以从未暴露。
33
+
34
+ - **新增 `writeOps(ops)`**:走 `scope.mutate` 的多段 path,`commitNow` 只写 `[…, key]` 这一条叶子,`flush()` 把草稿里的脏键一次原子提交;老宿主没有 `mutate` 句柄时才退回原来的整组 `set`(`canMutate()` 判定)。
35
+ - **顺带堵住一个静默数据丢失**:原来的整组铺回会把 `assistant` 整对象写回去,而 `apiKey` 是 `role('secret')`、前端快照里只有脱敏值 —— 一旦写入成功就会用脱敏串覆盖真密钥。叶路径只写用户真正动过的字段,`mutate` 的注释也正是为这种“视图不完整”的调用方设计的。
36
+ - **文案纠错**:侧边栏 `llmHint` 与实际座位不符(写的是「设置 → 插件 → dsh-progress-union」,实测在「设置 → 进度板」独立分节;bundle 详情页那个座位在本宿主里并不渲染本插件的卡),zh/en 均改为「设置 → 进度板」/ “Settings → Progress board”。
37
+ - **测试**:`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),零回归。
38
+
5
39
  ## 0.7.5 (2026-12-04)
6
40
 
7
41
  **feat(settings):`ops.enabled` 等 v0.7.0 四组开关第一次有了真正可达的表单入口;ops 操作块不再把开关位钉在首帧。**
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(244 用例,纯 mock ctx,无需宿主进程)
271
+ npm test # node --test test/*.test.mjs(246 用例,纯 mock ctx,无需宿主进程)
272
272
  ```
273
273
 
274
274
  ## 冷启动接续(v0.6.2)
@@ -314,14 +314,16 @@ npm test # node --test test/*.test.mjs(244 用例,纯 mock ctx,无需宿
314
314
 
315
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
316
 
317
- ## 设置页开关(v0.7.5)
317
+ ## 设置页开关(v0.7.5 表单入口,v0.7.6 写面修正,v0.7.7 脏位修正)
318
318
 
319
- 设置 → 插件 → dsh-progress-union(与右侧栏「进度板」分区是同一张卡)现在共 6 组:除原有的辅助 LLM / 观察者 / 官方 todo 同步外,新增两张:
319
+ 设置页里的「进度板」分节(宿主把本插件的 composition entry 直接当成一个独立设置节,导航文案 = `setTitle`)现在共 6 组:除原有的辅助 LLM / 观察者 / 官方 todo 同步外,新增两张:
320
320
 
321
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
322
  - **LLM 操作与队列提醒**:`ops.enabled`(整块开关)与 `notifyMajorChanges`(结构性变更是否落输入队列)。
323
323
 
324
- 开关类拨完即落盘(走宿主 `configForms` 句柄的 `scope.set(顶层键, 整组值)`),数字类进草稿、点「保存」提交。两个坑已经踩实:**一**是 `scope.set` 按顶层键**整体替换**、不深合并,所以代码里永远先 `{ ...旧组, ...改字段 }` 再写;**二**是从 profile 的 `cordis.patch.yml` 手工覆盖时,条目 `id` 必须是插件自身 `insert:` 里的 **entry id**(本插件 = `progress-union`),写成包名或 `dsh-external/<包名>` 会整段静默不下发(不报错,只是配置始终是默认值)。
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 叶子」钉成回归闸。**v0.7.7** 再把脏位改成「草稿值 ≠ 存值」——开关拨完即落盘,快照追平后不该再算未保存(否则「已保存」与「有未保存的改动」会并存,「保存」永远可点、还会重写同值)。
325
+
326
+ 两个已经踩实的坑:**一** 叶路径只写用户真正动过的字段,顺便避免了旧写法的隐患——`assistant.apiKey` 是 `role('secret')`,快照里只有脱敏值,整对象铺回一旦成功就是用脱敏串盖掉真密钥;**二** 从 profile 的 `cordis.patch.yml` 手工覆盖时,条目 `id` 必须是插件自身 `insert:` 里的 **entry id**(本插件 = `progress-union`),写成包名或 `dsh-external/<包名>` 会整段静默不下发(不报错,只是配置始终是默认值);且同层覆盖**按顶层键整体替换、不深合并**。
325
327
 
326
328
  ## 重大变更落输入队列(v0.7.0)
327
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.5"; /* ladder:ver */
27
+ var STAR_VERSION = "0.7.7"; /* 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 操作',
@@ -637,7 +637,7 @@ window.__ModuleLoader__.load({
637
637
  llmOn: 'Enabled',
638
638
  llmOff: 'Disabled: the observer is rule-based (zero LLM cost). When enabled, the assistant manages task slots and produces round suggestions.',
639
639
  llmAuto: ', auto-applied',
640
- 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.',
641
641
  llmSettingsHint: 'Change in Settings',
642
642
  // v0.7.0 R3: in-panel "LLM actions" block (writes back here, no new top-level tab)
643
643
  opsTitle: 'LLM actions',
@@ -2300,7 +2300,7 @@ window.__ModuleLoader__.load({
2300
2300
  )
2301
2301
  }
2302
2302
 
2303
- // 只读状态行:配置面归宿主设置页(设置 → 插件 → dsh-progress-union),
2303
+ // 只读状态行:配置面归宿主设置页(设置 → 进度板),
2304
2304
  // 侧边栏不再放编辑表单(避免两处写同一命名空间)。
2305
2305
  function LlmAssistNotice(props) {
2306
2306
  const t = makeT(props)
@@ -2590,9 +2590,47 @@ window.__ModuleLoader__.load({
2590
2590
  return stored === undefined || stored === null ? fallback : stored
2591
2591
  }
2592
2592
  const setDraftField = (group, key, v) => setDraft((prev) => ({ ...prev, [group]: { ...(prev[group] || {}), [key]: v } }))
2593
- const dirtyKeys = (group) => Object.keys(draft[group] || {})
2594
-
2593
+ // 脏键按「草稿值 ≠ 存值」算,不是「草稿里有这个键」:开关与分段拨完
2594
+ // 即落盘(也会先写一份乐观草稿),快照追平后那份草稿已经和存储一致,
2595
+ // 若仍计为脏,页脚会永久挂着「有未保存的改动」、点「保存」还会把同样的值
2596
+ // 再写一轮(真机 0.7.6 实测并存)。
2597
+ const dirtyKeys = (group) => {
2598
+ const bucket = buckets[group] || {}
2599
+ return Object.keys(draft[group] || {}).filter((key) => draft[group][key] !== bucket[key])
2600
+ }
2601
+ const scalarDirty = (key) => Object.prototype.hasOwnProperty.call(draft, key) && draft[key] !== value[key]
2602
+
2603
+ // 宿主 ConfigForm 的写面(0.2.2 实证):`set(field, value)` 只支持**顶层标量**
2604
+ // —— 它把 path 拼成单段 [field],而 Config 的 volatile 是逐叶子标的(组对象
2605
+ // 本身没标),于是整对象写嵌套组一律被 settings/rejected 挡掉:
2606
+ // Config field "ops" is not volatile
2607
+ // 症状就是“拨了开关→保存失败→值不落盘”(0.7.5 真机实测)。嵌套组必须走
2608
+ // scope.mutate 的多段 path;顺带也避免把整组铺回去——assistant 里有
2609
+ // role('secret') 的 apiKey,前端只拿到脱敏后的值,整对象写回会抹掉真密钥。
2610
+ const canMutate = () => Boolean(scope) && typeof scope.mutate === 'function'
2611
+ const writeOps = async (ops) => {
2612
+ if (!scope) {
2613
+ setStatus(t('setNoScope'))
2614
+ return false
2615
+ }
2616
+ if (!writable) {
2617
+ setStatus(t('setReadOnly'))
2618
+ return false
2619
+ }
2620
+ setBusy(true)
2621
+ try {
2622
+ const ok = await scope.mutate(ops)
2623
+ setStatus(ok === false ? t('setFailed') : t('setSaved'))
2624
+ return ok !== false
2625
+ } catch (_error) {
2626
+ setStatus(t('setFailed'))
2627
+ return false
2628
+ } finally {
2629
+ setBusy(false)
2630
+ }
2631
+ }
2595
2632
  const commit = async (group, patch) => {
2633
+ if (canMutate()) return writeOps([{ op: 'set', path: [group], value: patch }])
2596
2634
  if (!scope) {
2597
2635
  setStatus(t('setNoScope'))
2598
2636
  return false
@@ -2613,20 +2651,21 @@ window.__ModuleLoader__.load({
2613
2651
  setBusy(false)
2614
2652
  }
2615
2653
  }
2616
- const commitNow = (group, base, key, next) => void commit(group, { ...base, [key]: next })
2654
+ // 单字段落盘:有 mutate 就只写这一条 path,老宿主才退回整组铺回。
2655
+ const commitNow = (group, base, key, next) => {
2656
+ if (canMutate()) return void writeOps([{ op: 'set', path: [group, key], value: next }])
2657
+ return void commit(group, { ...(base || {}), [key]: next })
2658
+ }
2617
2659
  const flush = async () => {
2618
- const aKeys = dirtyKeys('assistant')
2619
- const oKeys = dirtyKeys('observer')
2620
- const todoKeys = dirtyKeys('todo')
2621
- const dlKeys = dirtyKeys('download')
2622
- const glossKeys = dirtyKeys('toolGloss')
2623
- const opsKeys = dirtyKeys('ops')
2624
- if (aKeys.length) await commit('assistant', { ...assistant, ...draft.assistant })
2625
- if (oKeys.length) await commit('observer', { ...observer, ...draft.observer })
2626
- if (todoKeys.length) await commit('todo', { ...todo, ...draft.todo })
2627
- if (dlKeys.length) await commit('download', { ...download, ...draft.download })
2628
- if (glossKeys.length) await commit('toolGloss', { ...toolGloss, ...draft.toolGloss })
2629
- if (opsKeys.length) await commit('ops', { ...ops, ...draft.ops })
2660
+ for (const group of ['assistant', 'observer', 'todo', 'download', 'toolGloss', 'ops']) {
2661
+ const keys = dirtyKeys(group)
2662
+ if (!keys.length) continue
2663
+ if (canMutate()) {
2664
+ await writeOps(keys.map((key) => ({ op: 'set', path: [group, key], value: draft[group][key] })))
2665
+ } else {
2666
+ await commit(group, { ...(buckets[group] || {}), ...draft[group] })
2667
+ }
2668
+ }
2630
2669
  setDraft({})
2631
2670
  }
2632
2671
 
@@ -2680,7 +2719,7 @@ window.__ModuleLoader__.load({
2680
2719
  },
2681
2720
  })
2682
2721
 
2683
- 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')
2722
+ const hasDirty = ['assistant', 'observer', 'todo', 'download', 'toolGloss', 'ops'].some((g) => dirtyKeys(g).length > 0) || scalarDirty('todoSync') || scalarDirty('notifyMajorChanges')
2684
2723
  const mode = readField('assistant', 'mode', '')
2685
2724
  const authority = readField('assistant', 'authority', 'both')
2686
2725
 
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
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.5",
3
+ "version": "0.7.7",
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",
@@ -118,17 +118,60 @@ test('设置卡:v0.7.0 四组开关真的有表单入口(不能只存 schema
118
118
  assert.match(src, /\(buckets\[group\] \|\| observer\)\[key\]/, 'readField 必须走组查表取值')
119
119
  // 保存通道也得把新组写回去(不写 = 拨了开关但从未落盘,看着像“配置不下发”)。
120
120
  for (const line of [
121
- "await commit('download', { ...download, ...draft.download })",
122
- "await commit('toolGloss', { ...toolGloss, ...draft.toolGloss })",
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 [
123
129
  "await commit('ops', { ...ops, ...draft.ops })",
130
+ "await commit('download', { ...download, ...draft.download })",
131
+ "await commit('assistant', { ...assistant, ...draft.assistant })",
124
132
  ]) {
125
- assert.ok(src.includes(line), `flush() 未提交新组:${line}`)
133
+ assert.ok(!src.includes(dead), `嵌套组不得再整对象铺回(会被 settings/rejected 拒):${dead}`)
126
134
  }
127
135
  // 双语齐(本插件只注册 zh/en,其余语种按设计回退英文)
128
136
  assert.equal((src.match(/setOpsEnabled:/g) || []).length, 2, 'setOpsEnabled 需 zh/en 两份')
129
137
  assert.equal((src.match(/setDlEnabled:/g) || []).length, 2, 'setDlEnabled 需 zh/en 两份')
130
138
  })
131
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
+ /**
162
+ * v0.7.7 真机回灌:0.7.6 修好写面后,页脚出现「已保存」与「有未保存的改动」并存
163
+ * —— 开关拨完即落盘,但乐观草稿仍按「键存在」计脏。脏位必须按值比对。
164
+ */
165
+ test('设置卡:拨完即落盘的开关不再留脏(脏位按值比对)', () => {
166
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
167
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
168
+ assert.match(src, /const dirtyKeys = \(group\) => \{\s*const bucket = buckets\[group\] \|\| \{\}/, 'dirtyKeys 需要拿存储桶做值比对')
169
+ assert.match(src, /\.filter\(\(key\) => draft\[group\]\[key\] !== bucket\[key\]\)/, '脏键必须按「草稿值 ≠ 存值」过滤')
170
+ assert.match(src, /const scalarDirty = \(key\) => Object\.prototype\.hasOwnProperty\.call\(draft, key\) && draft\[key\] !== value\[key\]/, '顶层标量同样按值判脏')
171
+ assert.match(src, /scalarDirty\('todoSync'\) \|\| scalarDirty\('notifyMajorChanges'\)/, 'hasDirty 不得再用「键存在即脏」')
172
+ assert.ok(!src.includes('const dirtyKeys = (group) => Object.keys(draft[group] || {})'), '旧的按键存在判脏必须移除')
173
+ })
174
+
132
175
  test('ops 块开关位定期重探,不钉在首帧(热生效无需重挂载)', () => {
133
176
  const file = fileURLToPath(new URL('../client.js', import.meta.url))
134
177
  const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')