dsh-progress-union 0.1.9 → 0.2.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/CHANGELOG.md CHANGED
@@ -25,6 +25,18 @@
25
25
  - 侧边栏保持只读状态行(编辑统一留在设置页,避免两处写同一命名空间)。
26
26
  - 测试:新增 3 条设置面契约守卫(逐叶子 volatile、外层不标、客户端注册 settings.section + configForms),共 51 用例全绿。
27
27
 
28
+ ## 0.2.0 (2026-11-26)
29
+
30
+ **设置面双座位 + 卡片重做(向 browser-cdp / prime-memory 的密度看齐)。**
31
+
32
+ - 为什么 0.1.9 只"勉强看到":样式写在数据面板的 `<style>` 里,而设置页是另一个 React 根,样式到不了 → 卡片裸奔、标签与输入框挤成一行。现在改为把样式表注入 `document.head`(id `dsh-progress-union-settings-style`),全命名空间 `.dsu-*` 前缀。
33
+ - 双座位:顶层 `settings.section`(独立分节「进度板」)+ `plugins.bundle.config`(插件详情页卡片,keyed by **包名**)。bundle 页此前是空的,现在与分节共用同一张卡。
34
+ - `configForms` 句柄改为 deferred `ctx.inject(['configForms'])` 捕获:该服务可能晚于客户端 apply 就绪,旧写法在那种时序下会永远拿不到写面;现在句柄到位后两个座位自动刷新。
35
+ - 卡片结构:可折叠分组卡(标题 + 徽标 + 折叠箭头)/行式 label+control、开关为药丸开关、枚举为分段控件(模式:关闭·已注册·直连;权限:槽位+轮次·仅槽位·仅轮次)、数值带单位后缀(ms / 步 / 项)、底部动作条(保存 / 撤销 / 未保存提示 / 状态)。
36
+ - 写入策略:文本与数字走草稿,点「保存」按组一次落盘(避免逐字符写盘);开关与分段即时落盘(乐观刷新 + 状态回执)。
37
+ - 模式为「关闭」时只显示模式行,选中 registered 才出现 provider,选中 direct 才出现 baseUrl/apiKey——不再把互斥字段一起摊开。
38
+ - 测试:设置面守卫扩到 8 条断言(双座位、包名 key、configForms、样式注入),共 51 用例全绿。
39
+
28
40
  > 说明:0.1.0 是真实构建产物;0.1.1–0.1.6 由 0.1.0 → 最终态的可核验 diff 按功能块「逻辑分化重建」,每一版都只包含该版本描述的能力,源码逐版可执行;0.1.7 是发布工程面。
29
41
 
30
42
  ## 0.1.7 (2026-11-26)
package/README.md CHANGED
@@ -14,7 +14,7 @@ npm i dsh-progress-union # 走 npm 版本号
14
14
  # 或本地开发:pnpm --dir <profile> add file:<repo>/dsh-progress-union-<ver>.tgz
15
15
  ```
16
16
 
17
- 装好后在 profile 的 `dsh.profile.bundles` 里挂上 `dsh-progress-union`,重启宿主加载;**所有配置面在设置页的独立分节「进度板」**(与记忆 / 模型 / 插件并列,由客户端注册 `settings.section` 槽、经宿主 `configForms` 读写,改完即生效、无需重启);也可在 profile 的 `cordis.patch.yml` 里写 `config:` 作部署面默认值。
17
+ 装好后在 profile 的 `dsh.profile.bundles` 里挂上 `dsh-progress-union`,重启宿主加载;**配置面有两个入口**:设置页左侧的独立分节「进度板」(与记忆 / 模型 / 插件并列),以及插件详情页(bundle 设置页)里的同名配置卡。两处是同一张卡,经宿主 `configForms` 句柄读写;文本/数字改完点「保存」,开关与分段即时落盘,均无需重启。也可在 profile 的 `cordis.patch.yml` 里写 `config:` 作部署面默认值。
18
18
 
19
19
  ## 它解决什么
20
20
 
@@ -120,7 +120,7 @@ observer:
120
120
 
121
121
  观察者默认是**规则版(零 LLM 费用)**。可选的辅助模型会把"清单 + 最近输出 + 最近动作 + 最近改动"交给一个小模型做审查:
122
122
 
123
- **配置位置:设置 → 进度板**(分节内三组:辅助 LLM / 观察者 / 只读 API;观察者的滞后阈值也在这张卡里)。
123
+ **配置位置:设置 → 进度板**(或插件详情页的同名卡片)。卡内三组可折叠:辅助 LLM / 观察者 / 只读 API;观察者的滞后阈值也在这张卡里。
124
124
 
125
125
  ```yaml
126
126
  assistant:
package/client.js CHANGED
@@ -249,6 +249,15 @@ window.__ModuleLoader__.load({
249
249
  setFailed: '保存失败',
250
250
  setReadOnly: '当前 config 不可写',
251
251
  setNoScope: '此宿主未提供设置写入面(configForms),只能从 profile 的 cordis.patch.yml 改配置。',
252
+ setLive: '运行时·可编辑',
253
+ setTopHint: '改完即时落盘,无需重启',
254
+ setLlmBadge: '监控审查',
255
+ setObserverBadge: '监控',
256
+ setApiBadge: '只读',
257
+ setSave: '保存',
258
+ setSaving: '保存中…',
259
+ setReset: '撤销',
260
+ setDirty: '有未保存的改动',
252
261
  setApiService: 'service',
253
262
  setApiAnchor: 'HTTP',
254
263
  setApiSnapshot: '快照',
@@ -398,6 +407,15 @@ window.__ModuleLoader__.load({
398
407
  setFailed: 'Save failed',
399
408
  setReadOnly: 'Current config is not writable',
400
409
  setNoScope: 'This host exposes no settings write surface (configForms); edit the profile cordis.patch.yml instead.',
410
+ setLive: 'Runtime editable',
411
+ setTopHint: 'Changes persist immediately, no restart needed',
412
+ setLlmBadge: 'Audit',
413
+ setObserverBadge: 'Monitor',
414
+ setApiBadge: 'Read-only',
415
+ setSave: 'Save',
416
+ setSaving: 'Saving…',
417
+ setReset: 'Discard',
418
+ setDirty: 'Unsaved changes',
401
419
  setApiService: 'service',
402
420
  setApiAnchor: 'HTTP',
403
421
  setApiSnapshot: 'Snapshot',
@@ -1547,56 +1565,197 @@ window.__ModuleLoader__.load({
1547
1565
  )
1548
1566
  }
1549
1567
 
1550
- // ── 设置分节(顶层 settings.section,与 dsh-browser-cdp 同式)─────────────
1551
- // 宿主不会凭导出的 Config 自动生成表单:设置面必须由客户端注册到
1552
- // `settings.section` 槽,数据臂走宿主原生 `configForms` 句柄
1553
- // (get(entryId) → subscribe/getSnapshot/set),写值带 revision、改完即生效。
1554
- function unionFormsScope(ctx) {
1555
- let forms
1556
- try {
1557
- forms = typeof ctx.get === 'function' ? ctx.get('configForms') : undefined
1558
- } catch (_error) {
1559
- forms = undefined
1560
- }
1568
+ // ── 设置面:顶层 settings.section + 插件页 plugins.bundle.config 双座位 ──────
1569
+ // 宿主的既有规则(与 dsh-brief-sidebar / dsh-browser-cdp 一致):
1570
+ // · 顶层 `settings.section`:独立导航分节,id 自定义;
1571
+ // · `plugins.bundle.config`:bundle 详情页配置卡,key 必须是 **包名**;
1572
+ // · `configForms` 可能在客户端 apply 之后才就绪 → 句柄走 deferred inject,
1573
+ // 两个座位共用同一句柄,卡内自行降级为空态提示(不静默吞掉入口)。
1574
+ let unionConfigForms
1575
+ const unionFormsListeners = new Set()
1576
+
1577
+ function unionFormsScope() {
1578
+ const forms = unionConfigForms
1561
1579
  if (!forms || typeof forms.get !== 'function') return undefined
1562
1580
  // entry id 在 cordis.patch.yml 里是 `progress-union`,包名是 `dsh-progress-union`,两个都试。
1563
1581
  for (const id of ['progress-union', 'dsh-progress-union']) {
1564
- let scope
1565
1582
  try {
1566
- scope = forms.get(id)
1583
+ const scope = forms.get(id)
1584
+ if (scope && typeof scope.getSnapshot === 'function' && typeof scope.subscribe === 'function' && typeof scope.set === 'function') return scope
1567
1585
  } catch (_error) {
1568
- scope = undefined
1586
+ // entry 尚未注册时跳过
1569
1587
  }
1570
- if (scope && typeof scope.getSnapshot === 'function' && typeof scope.subscribe === 'function' && typeof scope.set === 'function') return scope
1571
1588
  }
1572
1589
  return undefined
1573
1590
  }
1574
1591
 
1575
- function SettingsRow(props) {
1592
+ function bindUnionConfigForms(ctx) {
1593
+ try {
1594
+ ctx.inject(['configForms'], (scope) => {
1595
+ unionConfigForms = scope && scope.configForms
1596
+ for (const fn of unionFormsListeners) {
1597
+ try {
1598
+ fn()
1599
+ } catch (_error) {
1600
+ // 监听者卸载期失败无关紧要
1601
+ }
1602
+ }
1603
+ })
1604
+ } catch (_error) {
1605
+ // 宿主无 ctx.inject:卡退化为只读提示
1606
+ }
1607
+ }
1608
+
1609
+ function useUnionScope() {
1610
+ const [scope, setScope] = useState(() => unionFormsScope())
1611
+ useEffect(() => {
1612
+ const sync = () => setScope(unionFormsScope())
1613
+ unionFormsListeners.add(sync)
1614
+ sync()
1615
+ return () => {
1616
+ unionFormsListeners.delete(sync)
1617
+ }
1618
+ }, [])
1619
+ return scope
1620
+ }
1621
+
1622
+ // 样式必须注入 document.head:设置页 / 插件详情页是另一个 React 根,
1623
+ // 数据面板里的 <style> 到不了那里(上一版设置卡「裸奔」的原因)。
1624
+ const SETTINGS_STYLE_ID = 'dsh-progress-union-settings-style'
1625
+ const SETTINGS_CSS = `
1626
+ .dsu-set { display: grid; gap: 14px; font-size: 12px; color: inherit; }
1627
+ .dsu-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
1628
+ .dsu-chip { font-size: 11px; line-height: 1.6; padding: 1px 9px; border-radius: 999px; background: rgba(47,111,237,.12); color: #2f6fed; white-space: nowrap; }
1629
+ .dsu-chip-warn { background: rgba(217,119,6,.14); color: #b45309; }
1630
+ .dsu-card { border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.22)); border-radius: 12px; background: var(--dsw-alias-bg-layer-1, rgba(128,128,128,.04)); overflow: hidden; }
1631
+ .dsu-card-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; user-select: none; }
1632
+ .dsu-card-head:hover { background: rgba(128,128,128,.06); }
1633
+ .dsu-card-title { font-size: 13px; font-weight: 650; }
1634
+ .dsu-card-badge { font-size: 10px; line-height: 1.7; padding: 0 7px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.25)); opacity: .72; white-space: nowrap; }
1635
+ .dsu-card-chev { margin-left: auto; opacity: .55; font-size: 11px; }
1636
+ .dsu-card-body { display: grid; gap: 10px; padding: 2px 14px 14px; }
1637
+ .dsu-hint { font-size: 11px; line-height: 1.6; opacity: .66; }
1638
+ .dsu-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
1639
+ .dsu-row-hint { grid-column: 2; }
1640
+ .dsu-label { opacity: .84; }
1641
+ .dsu-control { min-width: 0; display: flex; align-items: center; gap: 8px; }
1642
+ .dsu-input, .dsu-select { flex: 1; min-width: 0; padding: 7px 10px; font: inherit; font-size: 12px; color: inherit; background: var(--dsw-alias-bg-base, rgba(255,255,255,.04)); border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.3)); border-radius: 8px; outline: none; transition: border-color .15s, box-shadow .15s; }
1643
+ .dsu-input:focus, .dsu-select:focus { border-color: #2f6fed; box-shadow: 0 0 0 3px rgba(47,111,237,.14); }
1644
+ .dsu-input[disabled] { opacity: .6; }
1645
+ .dsu-unit { flex: none; font-size: 11px; opacity: .6; min-width: 18px; }
1646
+ .dsu-switch { position: relative; display: inline-flex; width: 38px; height: 21px; flex: none; }
1647
+ .dsu-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
1648
+ .dsu-switch > i { position: absolute; inset: 0; border-radius: 999px; background: rgba(128,128,128,.38); transition: background .16s; pointer-events: none; }
1649
+ .dsu-switch > i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.24); transition: transform .16s; }
1650
+ .dsu-switch input:checked + i { background: #2f6fed; }
1651
+ .dsu-switch input:checked + i::after { transform: translateX(17px); }
1652
+ .dsu-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(128,128,128,.14); }
1653
+ .dsu-seg > button { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 7px; cursor: pointer; opacity: .72; white-space: nowrap; }
1654
+ .dsu-seg > button[data-on="true"] { background: var(--dsw-alias-bg-base, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.14); opacity: 1; font-weight: 600; }
1655
+ .dsu-actions { display: flex; align-items: center; gap: 10px; padding-top: 2px; }
1656
+ .dsu-actions .dsu-spacer { flex: 1; }
1657
+ .dsu-btn { appearance: none; font: inherit; font-size: 12px; padding: 6px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.3)); background: transparent; color: inherit; }
1658
+ .dsu-btn:disabled { opacity: .45; cursor: default; }
1659
+ .dsu-btn-primary { background: #2f6fed; border-color: #2f6fed; color: #fff; font-weight: 600; }
1660
+ .dsu-api { display: grid; gap: 6px; font-size: 11px; }
1661
+ .dsu-api > div { display: flex; gap: 8px; padding: 6px 9px; border-radius: 7px; background: rgba(128,128,128,.09); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
1662
+ .dsu-api b { flex: none; font-family: inherit; font-weight: 600; opacity: .72; }
1663
+ .dsu-empty { padding: 12px 14px; border-radius: 10px; border: 1px dashed var(--dsw-alias-border-l1, rgba(128,128,128,.35)); font-size: 12px; line-height: 1.6; opacity: .8; }
1664
+ `
1665
+
1666
+ function ensureUnionSettingsStyle() {
1667
+ try {
1668
+ if (typeof document === 'undefined') return
1669
+ if (document.getElementById(SETTINGS_STYLE_ID)) return
1670
+ const el = document.createElement('style')
1671
+ el.id = SETTINGS_STYLE_ID
1672
+ el.textContent = SETTINGS_CSS
1673
+ document.head.appendChild(el)
1674
+ } catch (_error) {
1675
+ // 无 DOM(SSR / 测试环境)时静默跳过
1676
+ }
1677
+ }
1678
+
1679
+ function SettingsSwitch(props) {
1576
1680
  return h(
1577
- 'label',
1578
- { className: 'pb-set-row' },
1579
- h('span', { className: 'pb-set-label' }, props.label),
1580
- h('span', { className: 'pb-set-control' }, props.children),
1581
- props.hint ? h('span', { className: 'pb-set-hint' }, props.hint) : null,
1681
+ 'span',
1682
+ { className: 'dsu-switch' },
1683
+ h('input', { type: 'checkbox', checked: props.checked === true, disabled: props.disabled === true, onChange: (e) => props.onChange(e.target.checked) }),
1684
+ h('i', null),
1582
1685
  )
1583
1686
  }
1584
1687
 
1585
- function SettingsGroup(props) {
1688
+ function SettingsSegment(props) {
1586
1689
  return h(
1587
- 'section',
1588
- { className: 'pb-set-group' },
1589
- h('div', { className: 'pb-set-group-title' }, props.title),
1590
- props.hint ? h('div', { className: 'pb-set-group-hint' }, props.hint) : null,
1591
- props.children,
1690
+ 'span',
1691
+ { className: 'dsu-seg' },
1692
+ props.options.map((opt) =>
1693
+ h(
1694
+ 'button',
1695
+ {
1696
+ key: opt[0],
1697
+ type: 'button',
1698
+ 'data-on': String(props.value === opt[0]),
1699
+ disabled: props.disabled === true,
1700
+ onClick: () => {
1701
+ if (props.value !== opt[0]) props.onChange(opt[0])
1702
+ },
1703
+ },
1704
+ opt[1],
1705
+ ),
1706
+ ),
1707
+ )
1708
+ }
1709
+
1710
+ function SettingsCard(props) {
1711
+ const [open, setOpen] = useState(props.defaultOpen !== false)
1712
+ return h(
1713
+ 'div',
1714
+ { className: 'dsu-card' },
1715
+ h(
1716
+ 'div',
1717
+ {
1718
+ className: 'dsu-card-head',
1719
+ role: 'button',
1720
+ tabIndex: 0,
1721
+ onClick: () => setOpen((v) => !v),
1722
+ onKeyDown: (e) => {
1723
+ if (e && (e.key === 'Enter' || e.key === ' ')) setOpen((v) => !v)
1724
+ },
1725
+ },
1726
+ h('span', { className: 'dsu-card-title' }, props.title),
1727
+ props.badge ? h('span', { className: 'dsu-card-badge' }, props.badge) : null,
1728
+ h('span', { className: 'dsu-card-chev' }, open ? '▾' : '▸'),
1729
+ ),
1730
+ open
1731
+ ? h(
1732
+ 'div',
1733
+ { className: 'dsu-card-body' },
1734
+ props.hint ? h('div', { className: 'dsu-hint' }, props.hint) : null,
1735
+ props.children,
1736
+ )
1737
+ : null,
1738
+ )
1739
+ }
1740
+
1741
+ function SettingsRow(props) {
1742
+ return h(
1743
+ 'div',
1744
+ { className: 'dsu-row' },
1745
+ h('span', { className: 'dsu-label' }, props.label),
1746
+ h('span', { className: 'dsu-control' }, props.children),
1747
+ props.hint ? h('span', { className: 'dsu-hint dsu-row-hint' }, props.hint) : null,
1592
1748
  )
1593
1749
  }
1594
1750
 
1595
1751
  function ProgressUnionSettings(props) {
1596
1752
  const t = makeT(props)
1597
- const scope = props.scope
1753
+ const scope = useUnionScope()
1598
1754
  const [snap, setSnap] = useState(null)
1755
+ const [draft, setDraft] = useState({})
1599
1756
  const [status, setStatus] = useState('')
1757
+ const [busy, setBusy] = useState(false)
1758
+
1600
1759
  useEffect(() => {
1601
1760
  if (!scope) return undefined
1602
1761
  let alive = true
@@ -1605,7 +1764,7 @@ window.__ModuleLoader__.load({
1605
1764
  try {
1606
1765
  setSnap(scope.getSnapshot())
1607
1766
  } catch (_error) {
1608
- // 句柄随时会随 entry 重载重建;读失败就保持上一帧
1767
+ // 句柄随 entry 重载重建;读失败保持上一帧
1609
1768
  }
1610
1769
  }
1611
1770
  read()
@@ -1629,94 +1788,169 @@ window.__ModuleLoader__.load({
1629
1788
 
1630
1789
  const value = (snap && snap.value) || {}
1631
1790
  const writable = Boolean(scope) && (!snap || snap.writable !== false)
1632
- const assistant = value.assistant && typeof value.assistant === 'object' ? value.assistant : {}
1633
- const observer = value.observer && typeof value.observer === 'object' ? value.observer : {}
1791
+ const asObject = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {})
1792
+ const assistant = asObject(value.assistant)
1793
+ const observer = asObject(value.observer)
1794
+
1795
+ // 文本/数字走草稿(避免逐字符写盘),开关与分段直接落盘(即时生效)。
1796
+ const readField = (group, key, fallback) => {
1797
+ const bucket = draft[group]
1798
+ if (bucket && Object.prototype.hasOwnProperty.call(bucket, key)) return bucket[key]
1799
+ const stored = (group === 'assistant' ? assistant : observer)[key]
1800
+ return stored === undefined || stored === null ? fallback : stored
1801
+ }
1802
+ const setDraftField = (group, key, v) => setDraft((prev) => ({ ...prev, [group]: { ...(prev[group] || {}), [key]: v } }))
1803
+ const dirtyKeys = (group) => Object.keys(draft[group] || {})
1634
1804
 
1635
- const write = async (field, next) => {
1805
+ const commit = async (group, patch) => {
1636
1806
  if (!scope) {
1637
1807
  setStatus(t('setNoScope'))
1638
- return
1808
+ return false
1639
1809
  }
1640
1810
  if (!writable) {
1641
1811
  setStatus(t('setReadOnly'))
1642
- return
1812
+ return false
1643
1813
  }
1814
+ setBusy(true)
1644
1815
  try {
1645
- const ok = await scope.set(field, next)
1816
+ const ok = await scope.set(group, patch)
1646
1817
  setStatus(ok === false ? t('setFailed') : t('setSaved'))
1818
+ return ok !== false
1647
1819
  } catch (_error) {
1648
1820
  setStatus(t('setFailed'))
1821
+ return false
1822
+ } finally {
1823
+ setBusy(false)
1649
1824
  }
1650
1825
  }
1651
- const putAssistant = (key, v) => void write('assistant', { ...assistant, [key]: v })
1652
- const putObserver = (key, v) => void write('observer', { ...observer, [key]: v })
1653
-
1654
- const textOf = (v) => (v === undefined || v === null ? '' : String(v))
1655
- const inputText = (v, onChange) => h('input', { type: 'text', value: textOf(v), onChange: (e) => onChange(e.target.value) })
1656
- const inputSecret = (v, placeholder, onChange) => h('input', { type: 'password', value: textOf(v), placeholder, onChange: (e) => onChange(e.target.value) })
1657
- const inputNum = (v, step, onChange) => h('input', { type: 'number', step, value: Number.isFinite(Number(v)) ? Number(v) : 0, onChange: (e) => onChange(Number(e.target.value)) })
1658
- const inputBool = (v, fallback, onChange) => h('input', { type: 'checkbox', checked: v === undefined ? fallback : v !== false, onChange: (e) => onChange(e.target.checked) })
1659
- const inputSelect = (v, options, onChange) =>
1660
- h(
1661
- 'select',
1662
- { value: textOf(v), onChange: (e) => onChange(e.target.value) },
1663
- options.map((opt) => h('option', { key: opt[0], value: opt[0] }, opt[1])),
1664
- )
1826
+ const commitNow = (group, base, key, next) => void commit(group, { ...base, [key]: next })
1827
+ const flush = async () => {
1828
+ const aKeys = dirtyKeys('assistant')
1829
+ const oKeys = dirtyKeys('observer')
1830
+ if (aKeys.length) await commit('assistant', { ...assistant, ...draft.assistant })
1831
+ if (oKeys.length) await commit('observer', { ...observer, ...draft.observer })
1832
+ setDraft({})
1833
+ }
1834
+
1835
+ const textInput = (group, key, fallback, placeholder) =>
1836
+ h('input', {
1837
+ className: 'dsu-input',
1838
+ type: 'text',
1839
+ value: String(readField(group, key, fallback) ?? ''),
1840
+ placeholder: placeholder || '',
1841
+ disabled: !writable,
1842
+ onChange: (e) => setDraftField(group, key, e.target.value),
1843
+ })
1844
+ const secretInput = (group, key, placeholder) =>
1845
+ h('input', {
1846
+ className: 'dsu-input',
1847
+ type: 'password',
1848
+ value: String(readField(group, key, '') ?? ''),
1849
+ placeholder: placeholder || '',
1850
+ disabled: !writable,
1851
+ onChange: (e) => setDraftField(group, key, e.target.value),
1852
+ })
1853
+ const numberInput = (group, key, fallback, step, unit) => [
1854
+ h('input', {
1855
+ key: 'input',
1856
+ className: 'dsu-input',
1857
+ type: 'number',
1858
+ step,
1859
+ value: String(readField(group, key, fallback)),
1860
+ disabled: !writable,
1861
+ onChange: (e) => setDraftField(group, key, Number(e.target.value)),
1862
+ }),
1863
+ unit ? h('span', { key: 'unit', className: 'dsu-unit' }, unit) : null,
1864
+ ]
1865
+ const switchInput = (group, base, key, fallback) =>
1866
+ h(SettingsSwitch, {
1867
+ checked: readField(group, key, fallback) !== false,
1868
+ disabled: !writable || busy,
1869
+ onChange: (v) => {
1870
+ setDraftField(group, key, v)
1871
+ commitNow(group, base, key, v)
1872
+ },
1873
+ })
1874
+ const segmentInput = (group, base, key, fallback, options) =>
1875
+ h(SettingsSegment, {
1876
+ value: readField(group, key, fallback),
1877
+ disabled: !writable || busy,
1878
+ options,
1879
+ onChange: (v) => {
1880
+ setDraftField(group, key, v)
1881
+ commitNow(group, base, key, v)
1882
+ },
1883
+ })
1884
+
1885
+ const hasDirty = dirtyKeys('assistant').length > 0 || dirtyKeys('observer').length > 0
1886
+ const mode = readField('assistant', 'mode', '')
1887
+ const authority = readField('assistant', 'authority', 'both')
1665
1888
 
1666
1889
  return h(
1667
1890
  'div',
1668
- { className: 'pb-set' },
1669
- scope ? null : h('div', { className: 'pb-set-banner' }, t('setNoScope')),
1891
+ { className: 'dsu-set' },
1892
+ h(
1893
+ 'div',
1894
+ { className: 'dsu-topline' },
1895
+ h('span', { className: writable ? 'dsu-chip' : 'dsu-chip dsu-chip-warn' }, writable ? t('setLive') : t('setReadOnly')),
1896
+ h('span', { className: 'dsu-hint' }, writable ? t('setTopHint') : t('setNoScope')),
1897
+ ),
1670
1898
  h(
1671
- SettingsGroup,
1672
- { title: t('setLlmGroup'), hint: t('setLlmHint') },
1899
+ SettingsCard,
1900
+ { title: t('setLlmGroup'), badge: t('setLlmBadge'), hint: t('setLlmHint') },
1673
1901
  h(SettingsRow, { label: t('setMode') },
1674
- inputSelect(assistant.mode || '', [['', t('setModeOff')], ['registered', t('setModeRegistered')], ['direct', t('setModeDirect')]], (v) => putAssistant('mode', v))),
1675
- h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') },
1676
- inputText(assistant.provider || '', (v) => putAssistant('provider', v))),
1677
- h(SettingsRow, { label: t('setModel') },
1678
- inputText(assistant.model || '', (v) => putAssistant('model', v))),
1679
- h(SettingsRow, { label: t('setBaseUrl') },
1680
- inputText(assistant.baseUrl || '', (v) => putAssistant('baseUrl', v))),
1681
- h(SettingsRow, { label: t('setApiKey'), hint: t('setApiKeyHint') },
1682
- inputSecret('', assistant.hasApiKey ? '••••••' : '', (v) => putAssistant('apiKey', v))),
1683
- h(SettingsRow, { label: t('setAuthority') },
1684
- inputSelect(assistant.authority || 'both', [['both', t('setAuthorityBoth')], ['slots', t('setAuthoritySlots')], ['rounds', t('setAuthorityRounds')]], (v) => putAssistant('authority', v))),
1685
- h(SettingsRow, { label: t('setInterval'), hint: t('setIntervalHint') },
1686
- inputNum(assistant.minIntervalMs === undefined ? 90000 : assistant.minIntervalMs, 1000, (v) => putAssistant('minIntervalMs', v))),
1687
- h(SettingsRow, { label: t('setAutoApply') },
1688
- inputBool(assistant.autoApply, true, (v) => putAssistant('autoApply', v))),
1902
+ segmentInput('assistant', assistant, 'mode', '', [['', t('setModeOff')], ['registered', t('setModeRegistered')], ['direct', t('setModeDirect')]])),
1903
+ mode === 'registered'
1904
+ ? h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') }, textInput('assistant', 'provider', '', 'local-35b'))
1905
+ : null,
1906
+ h(SettingsRow, { label: t('setModel') }, textInput('assistant', 'model', '', mode === 'direct' ? 'qwen2.5-3b' : 'Qwen3.6-35B-A3B')),
1907
+ mode === 'direct' ? h(SettingsRow, { label: t('setBaseUrl') }, textInput('assistant', 'baseUrl', '', 'http://127.0.0.1:8000/v1')) : null,
1908
+ mode === 'direct' ? h(SettingsRow, { label: t('setApiKey'), hint: t('setApiKeyHint') }, secretInput('assistant', 'apiKey', assistant.hasApiKey ? '••••••' : '')) : null,
1909
+ mode === ''
1910
+ ? null
1911
+ : h(SettingsRow, { label: t('setAuthority') },
1912
+ segmentInput('assistant', assistant, 'authority', 'both', [['both', t('setAuthorityBoth')], ['slots', t('setAuthoritySlots')], ['rounds', t('setAuthorityRounds')]])),
1913
+ mode === '' ? null : h(SettingsRow, { label: t('setInterval'), hint: t('setIntervalHint') }, numberInput('assistant', 'minIntervalMs', 90000, 1000, 'ms')),
1914
+ mode === '' ? null : h(SettingsRow, { label: t('setAutoApply') }, switchInput('assistant', assistant, 'autoApply', true)),
1689
1915
  ),
1690
1916
  h(
1691
- SettingsGroup,
1692
- { title: t('setObserverGroup'), hint: t('setObserverHint') },
1693
- h(SettingsRow, { label: t('setObserverEnabled') },
1694
- inputBool(observer.enabled, true, (v) => putObserver('enabled', v))),
1695
- h(SettingsRow, { label: t('setMaxIdleSteps') },
1696
- inputNum(observer.maxIdleSteps === undefined ? 6 : observer.maxIdleSteps, 1, (v) => putObserver('maxIdleSteps', v))),
1697
- h(SettingsRow, { label: t('setMaxIdleMs') },
1698
- inputNum(observer.maxIdleMs === undefined ? 180000 : observer.maxIdleMs, 1000, (v) => putObserver('maxIdleMs', v))),
1699
- h(SettingsRow, { label: t('setAutoSyncCurrent') },
1700
- inputBool(observer.autoSyncCurrent, true, (v) => putObserver('autoSyncCurrent', v))),
1701
- h(SettingsRow, { label: t('setAutoSyncThrottleMs') },
1702
- inputNum(observer.autoSyncThrottleMs === undefined ? 60000 : observer.autoSyncThrottleMs, 1000, (v) => putObserver('autoSyncThrottleMs', v))),
1703
- h(SettingsRow, { label: t('setMaxItems') },
1704
- inputNum(observer.maxItems === undefined ? 12 : observer.maxItems, 1, (v) => putObserver('maxItems', v))),
1917
+ SettingsCard,
1918
+ { title: t('setObserverGroup'), badge: t('setObserverBadge'), hint: t('setObserverHint') },
1919
+ h(SettingsRow, { label: t('setObserverEnabled') }, switchInput('observer', observer, 'enabled', true)),
1920
+ h(SettingsRow, { label: t('setMaxIdleSteps') }, numberInput('observer', 'maxIdleSteps', 6, 1, '步')),
1921
+ h(SettingsRow, { label: t('setMaxIdleMs') }, numberInput('observer', 'maxIdleMs', 180000, 1000, 'ms')),
1922
+ h(SettingsRow, { label: t('setAutoSyncCurrent') }, switchInput('observer', observer, 'autoSyncCurrent', true)),
1923
+ h(SettingsRow, { label: t('setAutoSyncThrottleMs') }, numberInput('observer', 'autoSyncThrottleMs', 60000, 1000, 'ms')),
1924
+ h(SettingsRow, { label: t('setMaxItems') }, numberInput('observer', 'maxItems', 12, 1, '项')),
1705
1925
  ),
1706
1926
  h(
1707
- SettingsGroup,
1708
- { title: t('setApiGroup'), hint: t('setApiHint') },
1709
- h('div', { className: 'pb-set-api' },
1710
- h('div', null, h('b', null, t('setApiService')), 'ctx.get(\'progressAnchor\').get(sessionId) / .list()'),
1927
+ SettingsCard,
1928
+ { title: t('setApiGroup'), badge: t('setApiBadge'), hint: t('setApiHint'), defaultOpen: false },
1929
+ h('div', { className: 'dsu-api' },
1930
+ h('div', null, h('b', null, t('setApiService')), "ctx.get('progressAnchor').get(sessionId) / .list()"),
1711
1931
  h('div', null, h('b', null, t('setApiAnchor')), 'GET /progress-union/anchor?sessionId=<id>'),
1712
1932
  h('div', null, h('b', null, t('setApiSnapshot')), 'GET /progress-union/snapshot?sessionId=<id>'),
1713
1933
  h('div', null, h('b', null, t('setApiStatus')), 'GET /dsh-progress/status?sessionId=<id>'),
1714
1934
  ),
1715
1935
  ),
1716
- status ? h('div', { className: 'pb-set-status' }, status) : null,
1936
+ h(
1937
+ 'div',
1938
+ { className: 'dsu-actions' },
1939
+ h('button', { type: 'button', className: 'dsu-btn dsu-btn-primary', disabled: !hasDirty || busy || !writable, onClick: () => void flush() }, busy ? t('setSaving') : t('setSave')),
1940
+ h('button', {
1941
+ type: 'button',
1942
+ className: 'dsu-btn',
1943
+ disabled: !hasDirty || busy,
1944
+ onClick: () => {
1945
+ setDraft({})
1946
+ setStatus('')
1947
+ },
1948
+ }, t('setReset')),
1949
+ h('span', { className: 'dsu-hint dsu-spacer' }, hasDirty ? t('setDirty') : ''),
1950
+ status ? h('span', { className: 'dsu-hint' }, status) : null,
1951
+ ),
1717
1952
  )
1718
1953
  }
1719
-
1720
1954
  function ProgressSidePanel(props) {
1721
1955
  const t = makeT(props)
1722
1956
  const { sessionId } = props
@@ -2439,27 +2673,32 @@ window.__ModuleLoader__.load({
2439
2673
 
2440
2674
  const t = ctx.locale.bind(NS)
2441
2675
 
2442
- // 独立设置分节:顶层 `settings.section`(与记忆/模型/插件并列)。
2443
- // order 215 接在宿主内置分节之后;旧宿主没声明该槽时 inject 空转,
2444
- // 面板与迷你条不受影响(不靠版本号判断,只靠槽位存在性)。
2445
- const settingsScope = unionFormsScope(ctx)
2446
- ctx.effect(
2447
- () =>
2448
- ctx.slots.inject('settings.section', () =>
2449
- ctx.slots.register(
2450
- {
2451
- name: 'settings.section',
2452
- id: 'dsh-progress-union',
2453
- order: 215,
2454
- locale: NS,
2455
- label: () => t('setTitle'),
2456
- inject: () => ({ scope: settingsScope }),
2457
- },
2458
- ProgressUnionSettings,
2459
- ),
2676
+ // 双座位注册:顶层设置分节(settings.section)+ 插件详情页配置卡
2677
+ // (plugins.bundle.config,keyed by **包名**)。
2678
+ // configForms 可能在 apply 之后才就绪 → 走 deferred inject 捕获句柄,
2679
+ // 卡内自己订阅句柄并重取 scope,所以两个座位都可以先注空 prop。
2680
+ bindUnionConfigForms(ctx)
2681
+ ensureUnionSettingsStyle()
2682
+ const registerSettingsSeat = (seat, options) =>
2683
+ ctx.slots.inject(seat, () =>
2684
+ ctx.slots.register(
2685
+ {
2686
+ name: seat,
2687
+ ...options,
2688
+ locale: NS,
2689
+ inject: () => ({}),
2690
+ },
2691
+ ProgressUnionSettings,
2460
2692
  ),
2693
+ )
2694
+ ctx.effect(
2695
+ () => registerSettingsSeat('settings.section', { id: 'dsh-progress-union', order: 215, label: () => t('setTitle') }),
2461
2696
  'progress-union: settings section',
2462
2697
  )
2698
+ ctx.effect(
2699
+ () => registerSettingsSeat('plugins.bundle.config', { key: 'dsh-progress-union', order: 15 }),
2700
+ 'progress-union: bundle config card',
2701
+ )
2463
2702
 
2464
2703
  const wakeAgent = (sessionId, text) => {
2465
2704
  try {
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
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 双平面)。",
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-progress-union",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎,另向压缩插件暴露只读三层进度锚点(service + HTTP 双平面)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
6
6
  "license": "MIT",
@@ -62,12 +62,15 @@ test('Config:外层对象不得自己标 volatile(嵌套 volatile 会被宿
62
62
  }
63
63
  })
64
64
 
65
- test('客户端:设置卡注册到 settings.section 且走 configForms 句柄', () => {
65
+ test('客户端:设置卡双座位(settings.section + plugins.bundle.config)且走 configForms 句柄', () => {
66
66
  const file = new URL('../client.js', import.meta.url).pathname.replace(/^\//, '')
67
67
  const src = fs.readFileSync(file, 'utf8')
68
- assert.match(src, /name: 'settings\.section'/, '必须注册 settings.section 槽')
68
+ assert.match(src, /registerSettingsSeat\('settings\.section'/, '必须注册 settings.section 槽')
69
69
  assert.match(src, /id: 'dsh-progress-union'/, '分节 id 必须固定')
70
+ assert.match(src, /registerSettingsSeat\('plugins\.bundle\.config'/, 'bundle 详情页也要有配置卡(keyed by 包名)')
71
+ assert.match(src, /key: 'dsh-progress-union'/, 'bundle 座位 key 必须是包名')
70
72
  assert.match(src, /configForms/, '必须经宿主 configForms 读写配置')
71
73
  assert.match(src, /function ProgressUnionSettings\(/, '设置卡组件必须在')
72
74
  assert.match(src, /scope\.subscribe/, '设置卡要订阅句柄快照')
75
+ assert.match(src, /function ensureUnionSettingsStyle\(/, '样式要注入 document.head,否则设置页里裸奔')
73
76
  })