dsh-progress-union 0.7.4 → 0.7.5

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,21 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.7.5 (2026-12-04)
6
+
7
+ **feat(settings):`ops.enabled` 等 v0.7.0 四组开关第一次有了真正可达的表单入口;ops 操作块不再把开关位钉在首帧。**
8
+
9
+ 真机回灌(沙箱宿主 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`。
10
+
11
+ 顺着这条线查下去又抓到一个更基本的缺口:**设置卡只渲染 `assistant` / `observer` / `todo` 三组**(`readField` 里写死三元,其余组一律落到 observer 的桶),宿主也不会为外部插件另生成通用表单 —— 两个座位(`settings.section` 与 `plugins.bundle.config`)实测都只有那 4 组 10 个控件,全 DOM 搜不到 `ops` 字样。也就是说 0.7.2 上线的「整块开关」和 download/toolGloss/notifyMajorChanges 一样,**只有 schema、没有用户可达的入口**。
12
+
13
+ - **`ProgressUnionSettings` 补两张卡**:「下载感知与工序」(`download.enabled` / `showSubBar` / `markBackground` / `ttlMs` + `toolGloss.enabled` / `softNarrate` / `maxLen`)与「LLM 操作与队列提醒」(`ops.enabled` + 顶层标量 `notifyMajorChanges`)。开关走 `commitNow` 即时落盘,数字走草稿由「保存」提交,与既有三组同构。
14
+ - **`readField` 改为组查表**(`buckets = { assistant, observer, todo, download, toolGloss, ops }`),`flush()` 同步补上三个新组的整体回写;此前若只接线开关不接回写,会表现成「拨了开关但从未落盘」。
15
+ - **`LlmOpsBlock` 定期重探开关位**:新增 `OPS_POLL_MS = 15000`,`setOff(true)` 与 `setOff(false)` 成对出现,设置页拨完无需重挂载就跟上;默认 provider/model 只在首次探测回填(`primed` ref),不覆用户手选。卸载收定时器。
16
+ - **文案**:zh/en 各 +17 键(`setDl*` / `setGloss*` / `setOps*` / `setNotifyMajor*`)。本插件只注册 `zh`/`en` 两语,其余语种按既有设计回退英文。
17
+ - **测试**:`test/settings.test.mjs` +2 用例并扩写 volatile 叶子清单(补 `download.*`/`toolGloss.*`/`notifyMajorChanges`/`ops.enabled`,漏一个就红):一张断言「有 volatile 就必须有表单入口」,一张断言开关位定期重探不钉首帧。`npm test` **244 pass / 0 fail**(242 → +2),零回归。
18
+
19
+
5
20
  ## 0.7.4 (2026-12-04)
6
21
 
7
22
  **fix(download):工具名本身就是解释器(实测 `pwsh`)时不再被 `isShell` 门拦下。**
package/README.md CHANGED
@@ -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(244 用例,纯 mock ctx,无需宿主进程)
272
272
  ```
273
273
 
274
274
  ## 冷启动接续(v0.6.2)
@@ -312,7 +312,16 @@ 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)
318
+
319
+ 设置 → 插件 → dsh-progress-union(与右侧栏「进度板」分区是同一张卡)现在共 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
+ 开关类拨完即落盘(走宿主 `configForms` 句柄的 `scope.set(顶层键, 整组值)`),数字类进草稿、点「保存」提交。两个坑已经踩实:**一**是 `scope.set` 按顶层键**整体替换**、不深合并,所以代码里永远先 `{ ...旧组, ...改字段 }` 再写;**二**是从 profile 的 `cordis.patch.yml` 手工覆盖时,条目 `id` 必须是插件自身 `insert:` 里的 **entry id**(本插件 = `progress-union`),写成包名或 `dsh-external/<包名>` 会整段静默不下发(不报错,只是配置始终是默认值)。
316
325
 
317
326
  ## 重大变更落输入队列(v0.7.0)
318
327
 
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.5"; /* 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)。
@@ -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 不可写',
@@ -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
@@ -2521,12 +2574,19 @@ 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 } }))
@@ -2558,9 +2618,15 @@ window.__ModuleLoader__.load({
2558
2618
  const aKeys = dirtyKeys('assistant')
2559
2619
  const oKeys = dirtyKeys('observer')
2560
2620
  const todoKeys = dirtyKeys('todo')
2621
+ const dlKeys = dirtyKeys('download')
2622
+ const glossKeys = dirtyKeys('toolGloss')
2623
+ const opsKeys = dirtyKeys('ops')
2561
2624
  if (aKeys.length) await commit('assistant', { ...assistant, ...draft.assistant })
2562
2625
  if (oKeys.length) await commit('observer', { ...observer, ...draft.observer })
2563
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 })
2564
2630
  setDraft({})
2565
2631
  }
2566
2632
 
@@ -2614,7 +2680,7 @@ window.__ModuleLoader__.load({
2614
2680
  },
2615
2681
  })
2616
2682
 
2617
- const hasDirty = dirtyKeys('assistant').length > 0 || dirtyKeys('observer').length > 0 || dirtyKeys('todo').length > 0 || Object.prototype.hasOwnProperty.call(draft, 'todoSync')
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')
2618
2684
  const mode = readField('assistant', 'mode', '')
2619
2685
  const authority = readField('assistant', 'authority', 'both')
2620
2686
 
@@ -2655,6 +2721,28 @@ window.__ModuleLoader__.load({
2655
2721
  h(SettingsRow, { label: t('setAutoSyncThrottleMs') }, numberInput('observer', 'autoSyncThrottleMs', 60000, 1000, 'ms')),
2656
2722
  h(SettingsRow, { label: t('setMaxItems') }, numberInput('observer', 'maxItems', 12, 1, '项')),
2657
2723
  ),
2724
+ h(
2725
+ SettingsCard,
2726
+ { title: t('setDlGroup'), badge: t('setDlBadge'), hint: t('setDlHint'), defaultOpen: false },
2727
+ h(SettingsRow, { label: t('setDlEnabled') }, switchInput('download', download, 'enabled', true)),
2728
+ h(SettingsRow, { label: t('setDlSubBar'), hint: t('setDlSubBarHint') }, switchInput('download', download, 'showSubBar', true)),
2729
+ h(SettingsRow, { label: t('setDlBg') }, switchInput('download', download, 'markBackground', true)),
2730
+ h(SettingsRow, { label: t('setDlTtlMs') }, numberInput('download', 'ttlMs', 480000, 1000, 'ms')),
2731
+ h(SettingsRow, { label: t('setGlossEnabled') }, switchInput('toolGloss', toolGloss, 'enabled', true)),
2732
+ h(SettingsRow, { label: t('setGlossNarrate') }, switchInput('toolGloss', toolGloss, 'softNarrate', true)),
2733
+ h(SettingsRow, { label: t('setGlossMaxLen') }, numberInput('toolGloss', 'maxLen', 46, 1, '')),
2734
+ ),
2735
+ h(
2736
+ SettingsCard,
2737
+ { title: t('setOpsGroup'), badge: t('setOpsBadge'), hint: t('setOpsHint'), defaultOpen: false },
2738
+ h(SettingsRow, { label: t('setOpsEnabled') }, switchInput('ops', ops, 'enabled', true)),
2739
+ h(SettingsRow, { label: t('setNotifyMajor'), hint: t('setNotifyMajorHint') },
2740
+ h(SettingsSwitch, {
2741
+ checked: Object.prototype.hasOwnProperty.call(draft, 'notifyMajorChanges') ? draft.notifyMajorChanges : value.notifyMajorChanges !== false,
2742
+ disabled: !writable || busy,
2743
+ onChange: (v) => { setDraft((prev) => ({ ...prev, notifyMajorChanges: v })); void commit('notifyMajorChanges', v) },
2744
+ })),
2745
+ ),
2658
2746
  h(
2659
2747
  SettingsCard,
2660
2748
  { 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.5",
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.5",
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,52 @@ 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
+ "await commit('download', { ...download, ...draft.download })",
122
+ "await commit('toolGloss', { ...toolGloss, ...draft.toolGloss })",
123
+ "await commit('ops', { ...ops, ...draft.ops })",
124
+ ]) {
125
+ assert.ok(src.includes(line), `flush() 未提交新组:${line}`)
126
+ }
127
+ // 双语齐(本插件只注册 zh/en,其余语种按设计回退英文)
128
+ assert.equal((src.match(/setOpsEnabled:/g) || []).length, 2, 'setOpsEnabled 需 zh/en 两份')
129
+ assert.equal((src.match(/setDlEnabled:/g) || []).length, 2, 'setDlEnabled 需 zh/en 两份')
130
+ })
131
+
132
+ test('ops 块开关位定期重探,不钉在首帧(热生效无需重挂载)', () => {
133
+ const file = fileURLToPath(new URL('../client.js', import.meta.url))
134
+ const src = fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n')
135
+ assert.match(src, /const OPS_POLL_MS = \d+/, '需要有重探间隔常量')
136
+ assert.match(src, /setInterval\(probe, OPS_POLL_MS\)/, '必须真的定时重探 providers 面')
137
+ assert.match(src, /if \(data\.disabled\) \{[\s\S]{0,80}?setOff\(true\)[\s\S]{0,40}?return[\s\S]{0,120}?setOff\(false\)/, '关掉要隐块,改回开要自动复现(不能只置 true)')
138
+ assert.match(src, /if \(primed\.current\) return/, '默认 provider/model 只在首次回填,不覆用户手选')
139
+ assert.match(src, /clearInterval\(timer\)/, '卸载必须收定时器')
82
140
  })