dsh-progress-union 0.1.9 → 0.3.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/client.js CHANGED
@@ -245,10 +245,28 @@ window.__ModuleLoader__.load({
245
245
  setAutoSyncCurrent: '自动同步 current',
246
246
  setAutoSyncThrottleMs: '自动同步节流(毫秒)',
247
247
  setMaxItems: '清单条目上限',
248
+ setTodoGroup: '官方 todo 同步',
249
+ setTodoHint: '板变更后自动镜像到宿主官方 todo 清单(会覆盖模型写的清单,谨慎开启);外部改动可由辅助 LLM 裁决。',
250
+ setTodoSync: '同步模式',
251
+ setTodoOff: '关闭(不写 todo)',
252
+ setTodoMirror: '只镜像(板 → todo)',
253
+ setTodoReconcile: '镜像 + 裁决',
254
+ setTodoReconcileMs: '裁决最小间隔(毫秒)',
255
+ setTodoThrottleMs: '镜像去抖(毫秒)',
256
+ setTodoWriteNote: '写入事件:agent.session.append(\'todo/write\', { todos })(只读说明)',
248
257
  setSaved: '已保存',
249
258
  setFailed: '保存失败',
250
259
  setReadOnly: '当前 config 不可写',
251
260
  setNoScope: '此宿主未提供设置写入面(configForms),只能从 profile 的 cordis.patch.yml 改配置。',
261
+ setLive: '运行时·可编辑',
262
+ setTopHint: '改完即时落盘,无需重启',
263
+ setLlmBadge: '监控审查',
264
+ setObserverBadge: '监控',
265
+ setApiBadge: '只读',
266
+ setSave: '保存',
267
+ setSaving: '保存中…',
268
+ setReset: '撤销',
269
+ setDirty: '有未保存的改动',
252
270
  setApiService: 'service',
253
271
  setApiAnchor: 'HTTP',
254
272
  setApiSnapshot: '快照',
@@ -393,11 +411,29 @@ window.__ModuleLoader__.load({
393
411
  setMaxIdleMs: 'Overdue time threshold (ms)',
394
412
  setAutoSyncCurrent: 'Auto-sync current',
395
413
  setAutoSyncThrottleMs: 'Auto-sync throttle (ms)',
396
- setMaxItems: 'Checklist item cap',
414
+ setMaxItems: 'Max checklist items',
415
+ setTodoGroup: 'Official todo sync',
416
+ setTodoHint: 'Mirror the board to the host official todo list after every board change (overwrites the model-written list — enable with care); external edits can be reconciled by the assistant LLM.',
417
+ setTodoSync: 'Sync mode',
418
+ setTodoOff: 'Off (no todo writes)',
419
+ setTodoMirror: 'Mirror only (board → todo)',
420
+ setTodoReconcile: 'Mirror + reconcile',
421
+ setTodoReconcileMs: 'Reconcile min interval (ms)',
422
+ setTodoThrottleMs: 'Mirror debounce (ms)',
423
+ setTodoWriteNote: 'Write event: agent.session.append(\'todo/write\', { todos }) (read-only)',
397
424
  setSaved: 'Saved',
398
425
  setFailed: 'Save failed',
399
426
  setReadOnly: 'Current config is not writable',
400
427
  setNoScope: 'This host exposes no settings write surface (configForms); edit the profile cordis.patch.yml instead.',
428
+ setLive: 'Runtime editable',
429
+ setTopHint: 'Changes persist immediately, no restart needed',
430
+ setLlmBadge: 'Audit',
431
+ setObserverBadge: 'Monitor',
432
+ setApiBadge: 'Read-only',
433
+ setSave: 'Save',
434
+ setSaving: 'Saving…',
435
+ setReset: 'Discard',
436
+ setDirty: 'Unsaved changes',
401
437
  setApiService: 'service',
402
438
  setApiAnchor: 'HTTP',
403
439
  setApiSnapshot: 'Snapshot',
@@ -1547,56 +1583,197 @@ window.__ModuleLoader__.load({
1547
1583
  )
1548
1584
  }
1549
1585
 
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
- }
1586
+ // ── 设置面:顶层 settings.section + 插件页 plugins.bundle.config 双座位 ──────
1587
+ // 宿主的既有规则(与 dsh-brief-sidebar / dsh-browser-cdp 一致):
1588
+ // · 顶层 `settings.section`:独立导航分节,id 自定义;
1589
+ // · `plugins.bundle.config`:bundle 详情页配置卡,key 必须是 **包名**;
1590
+ // · `configForms` 可能在客户端 apply 之后才就绪 → 句柄走 deferred inject,
1591
+ // 两个座位共用同一句柄,卡内自行降级为空态提示(不静默吞掉入口)。
1592
+ let unionConfigForms
1593
+ const unionFormsListeners = new Set()
1594
+
1595
+ function unionFormsScope() {
1596
+ const forms = unionConfigForms
1561
1597
  if (!forms || typeof forms.get !== 'function') return undefined
1562
1598
  // entry id 在 cordis.patch.yml 里是 `progress-union`,包名是 `dsh-progress-union`,两个都试。
1563
1599
  for (const id of ['progress-union', 'dsh-progress-union']) {
1564
- let scope
1565
1600
  try {
1566
- scope = forms.get(id)
1601
+ const scope = forms.get(id)
1602
+ if (scope && typeof scope.getSnapshot === 'function' && typeof scope.subscribe === 'function' && typeof scope.set === 'function') return scope
1567
1603
  } catch (_error) {
1568
- scope = undefined
1604
+ // entry 尚未注册时跳过
1569
1605
  }
1570
- if (scope && typeof scope.getSnapshot === 'function' && typeof scope.subscribe === 'function' && typeof scope.set === 'function') return scope
1571
1606
  }
1572
1607
  return undefined
1573
1608
  }
1574
1609
 
1575
- function SettingsRow(props) {
1610
+ function bindUnionConfigForms(ctx) {
1611
+ try {
1612
+ ctx.inject(['configForms'], (scope) => {
1613
+ unionConfigForms = scope && scope.configForms
1614
+ for (const fn of unionFormsListeners) {
1615
+ try {
1616
+ fn()
1617
+ } catch (_error) {
1618
+ // 监听者卸载期失败无关紧要
1619
+ }
1620
+ }
1621
+ })
1622
+ } catch (_error) {
1623
+ // 宿主无 ctx.inject:卡退化为只读提示
1624
+ }
1625
+ }
1626
+
1627
+ function useUnionScope() {
1628
+ const [scope, setScope] = useState(() => unionFormsScope())
1629
+ useEffect(() => {
1630
+ const sync = () => setScope(unionFormsScope())
1631
+ unionFormsListeners.add(sync)
1632
+ sync()
1633
+ return () => {
1634
+ unionFormsListeners.delete(sync)
1635
+ }
1636
+ }, [])
1637
+ return scope
1638
+ }
1639
+
1640
+ // 样式必须注入 document.head:设置页 / 插件详情页是另一个 React 根,
1641
+ // 数据面板里的 <style> 到不了那里(上一版设置卡「裸奔」的原因)。
1642
+ const SETTINGS_STYLE_ID = 'dsh-progress-union-settings-style'
1643
+ const SETTINGS_CSS = `
1644
+ .dsu-set { display: grid; gap: 14px; font-size: 12px; color: inherit; }
1645
+ .dsu-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
1646
+ .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; }
1647
+ .dsu-chip-warn { background: rgba(217,119,6,.14); color: #b45309; }
1648
+ .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; }
1649
+ .dsu-card-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; user-select: none; }
1650
+ .dsu-card-head:hover { background: rgba(128,128,128,.06); }
1651
+ .dsu-card-title { font-size: 13px; font-weight: 650; }
1652
+ .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; }
1653
+ .dsu-card-chev { margin-left: auto; opacity: .55; font-size: 11px; }
1654
+ .dsu-card-body { display: grid; gap: 10px; padding: 2px 14px 14px; }
1655
+ .dsu-hint { font-size: 11px; line-height: 1.6; opacity: .66; }
1656
+ .dsu-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 4px 12px; align-items: center; }
1657
+ .dsu-row-hint { grid-column: 2; }
1658
+ .dsu-label { opacity: .84; }
1659
+ .dsu-control { min-width: 0; display: flex; align-items: center; gap: 8px; }
1660
+ .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; }
1661
+ .dsu-input:focus, .dsu-select:focus { border-color: #2f6fed; box-shadow: 0 0 0 3px rgba(47,111,237,.14); }
1662
+ .dsu-input[disabled] { opacity: .6; }
1663
+ .dsu-unit { flex: none; font-size: 11px; opacity: .6; min-width: 18px; }
1664
+ .dsu-switch { position: relative; display: inline-flex; width: 38px; height: 21px; flex: none; }
1665
+ .dsu-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
1666
+ .dsu-switch > i { position: absolute; inset: 0; border-radius: 999px; background: rgba(128,128,128,.38); transition: background .16s; pointer-events: none; }
1667
+ .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; }
1668
+ .dsu-switch input:checked + i { background: #2f6fed; }
1669
+ .dsu-switch input:checked + i::after { transform: translateX(17px); }
1670
+ .dsu-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(128,128,128,.14); }
1671
+ .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; }
1672
+ .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; }
1673
+ .dsu-actions { display: flex; align-items: center; gap: 10px; padding-top: 2px; }
1674
+ .dsu-actions .dsu-spacer { flex: 1; }
1675
+ .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; }
1676
+ .dsu-btn:disabled { opacity: .45; cursor: default; }
1677
+ .dsu-btn-primary { background: #2f6fed; border-color: #2f6fed; color: #fff; font-weight: 600; }
1678
+ .dsu-api { display: grid; gap: 6px; font-size: 11px; }
1679
+ .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; }
1680
+ .dsu-api b { flex: none; font-family: inherit; font-weight: 600; opacity: .72; }
1681
+ .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; }
1682
+ `
1683
+
1684
+ function ensureUnionSettingsStyle() {
1685
+ try {
1686
+ if (typeof document === 'undefined') return
1687
+ if (document.getElementById(SETTINGS_STYLE_ID)) return
1688
+ const el = document.createElement('style')
1689
+ el.id = SETTINGS_STYLE_ID
1690
+ el.textContent = SETTINGS_CSS
1691
+ document.head.appendChild(el)
1692
+ } catch (_error) {
1693
+ // 无 DOM(SSR / 测试环境)时静默跳过
1694
+ }
1695
+ }
1696
+
1697
+ function SettingsSwitch(props) {
1576
1698
  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,
1699
+ 'span',
1700
+ { className: 'dsu-switch' },
1701
+ h('input', { type: 'checkbox', checked: props.checked === true, disabled: props.disabled === true, onChange: (e) => props.onChange(e.target.checked) }),
1702
+ h('i', null),
1582
1703
  )
1583
1704
  }
1584
1705
 
1585
- function SettingsGroup(props) {
1706
+ function SettingsSegment(props) {
1586
1707
  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,
1708
+ 'span',
1709
+ { className: 'dsu-seg' },
1710
+ props.options.map((opt) =>
1711
+ h(
1712
+ 'button',
1713
+ {
1714
+ key: opt[0],
1715
+ type: 'button',
1716
+ 'data-on': String(props.value === opt[0]),
1717
+ disabled: props.disabled === true,
1718
+ onClick: () => {
1719
+ if (props.value !== opt[0]) props.onChange(opt[0])
1720
+ },
1721
+ },
1722
+ opt[1],
1723
+ ),
1724
+ ),
1725
+ )
1726
+ }
1727
+
1728
+ function SettingsCard(props) {
1729
+ const [open, setOpen] = useState(props.defaultOpen !== false)
1730
+ return h(
1731
+ 'div',
1732
+ { className: 'dsu-card' },
1733
+ h(
1734
+ 'div',
1735
+ {
1736
+ className: 'dsu-card-head',
1737
+ role: 'button',
1738
+ tabIndex: 0,
1739
+ onClick: () => setOpen((v) => !v),
1740
+ onKeyDown: (e) => {
1741
+ if (e && (e.key === 'Enter' || e.key === ' ')) setOpen((v) => !v)
1742
+ },
1743
+ },
1744
+ h('span', { className: 'dsu-card-title' }, props.title),
1745
+ props.badge ? h('span', { className: 'dsu-card-badge' }, props.badge) : null,
1746
+ h('span', { className: 'dsu-card-chev' }, open ? '▾' : '▸'),
1747
+ ),
1748
+ open
1749
+ ? h(
1750
+ 'div',
1751
+ { className: 'dsu-card-body' },
1752
+ props.hint ? h('div', { className: 'dsu-hint' }, props.hint) : null,
1753
+ props.children,
1754
+ )
1755
+ : null,
1756
+ )
1757
+ }
1758
+
1759
+ function SettingsRow(props) {
1760
+ return h(
1761
+ 'div',
1762
+ { className: 'dsu-row' },
1763
+ h('span', { className: 'dsu-label' }, props.label),
1764
+ h('span', { className: 'dsu-control' }, props.children),
1765
+ props.hint ? h('span', { className: 'dsu-hint dsu-row-hint' }, props.hint) : null,
1592
1766
  )
1593
1767
  }
1594
1768
 
1595
1769
  function ProgressUnionSettings(props) {
1596
1770
  const t = makeT(props)
1597
- const scope = props.scope
1771
+ const scope = useUnionScope()
1598
1772
  const [snap, setSnap] = useState(null)
1773
+ const [draft, setDraft] = useState({})
1599
1774
  const [status, setStatus] = useState('')
1775
+ const [busy, setBusy] = useState(false)
1776
+
1600
1777
  useEffect(() => {
1601
1778
  if (!scope) return undefined
1602
1779
  let alive = true
@@ -1605,7 +1782,7 @@ window.__ModuleLoader__.load({
1605
1782
  try {
1606
1783
  setSnap(scope.getSnapshot())
1607
1784
  } catch (_error) {
1608
- // 句柄随时会随 entry 重载重建;读失败就保持上一帧
1785
+ // 句柄随 entry 重载重建;读失败保持上一帧
1609
1786
  }
1610
1787
  }
1611
1788
  read()
@@ -1629,94 +1806,186 @@ window.__ModuleLoader__.load({
1629
1806
 
1630
1807
  const value = (snap && snap.value) || {}
1631
1808
  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 : {}
1809
+ const asObject = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {})
1810
+ const assistant = asObject(value.assistant)
1811
+ const observer = asObject(value.observer)
1812
+ const todo = asObject(value.todo)
1813
+
1814
+ // 文本/数字走草稿(避免逐字符写盘),开关与分段直接落盘(即时生效)。
1815
+ const readField = (group, key, fallback) => {
1816
+ const bucket = draft[group]
1817
+ if (bucket && Object.prototype.hasOwnProperty.call(bucket, key)) return bucket[key]
1818
+ const stored = (group === 'assistant' ? assistant : group === 'todo' ? todo : observer)[key]
1819
+ return stored === undefined || stored === null ? fallback : stored
1820
+ }
1821
+ const setDraftField = (group, key, v) => setDraft((prev) => ({ ...prev, [group]: { ...(prev[group] || {}), [key]: v } }))
1822
+ const dirtyKeys = (group) => Object.keys(draft[group] || {})
1634
1823
 
1635
- const write = async (field, next) => {
1824
+ const commit = async (group, patch) => {
1636
1825
  if (!scope) {
1637
1826
  setStatus(t('setNoScope'))
1638
- return
1827
+ return false
1639
1828
  }
1640
1829
  if (!writable) {
1641
1830
  setStatus(t('setReadOnly'))
1642
- return
1831
+ return false
1643
1832
  }
1833
+ setBusy(true)
1644
1834
  try {
1645
- const ok = await scope.set(field, next)
1835
+ const ok = await scope.set(group, patch)
1646
1836
  setStatus(ok === false ? t('setFailed') : t('setSaved'))
1837
+ return ok !== false
1647
1838
  } catch (_error) {
1648
1839
  setStatus(t('setFailed'))
1840
+ return false
1841
+ } finally {
1842
+ setBusy(false)
1649
1843
  }
1650
1844
  }
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
- )
1845
+ const commitNow = (group, base, key, next) => void commit(group, { ...base, [key]: next })
1846
+ const flush = async () => {
1847
+ const aKeys = dirtyKeys('assistant')
1848
+ const oKeys = dirtyKeys('observer')
1849
+ const todoKeys = dirtyKeys('todo')
1850
+ if (aKeys.length) await commit('assistant', { ...assistant, ...draft.assistant })
1851
+ if (oKeys.length) await commit('observer', { ...observer, ...draft.observer })
1852
+ if (todoKeys.length) await commit('todo', { ...todo, ...draft.todo })
1853
+ setDraft({})
1854
+ }
1855
+
1856
+ const textInput = (group, key, fallback, placeholder) =>
1857
+ h('input', {
1858
+ className: 'dsu-input',
1859
+ type: 'text',
1860
+ value: String(readField(group, key, fallback) ?? ''),
1861
+ placeholder: placeholder || '',
1862
+ disabled: !writable,
1863
+ onChange: (e) => setDraftField(group, key, e.target.value),
1864
+ })
1865
+ const secretInput = (group, key, placeholder) =>
1866
+ h('input', {
1867
+ className: 'dsu-input',
1868
+ type: 'password',
1869
+ value: String(readField(group, key, '') ?? ''),
1870
+ placeholder: placeholder || '',
1871
+ disabled: !writable,
1872
+ onChange: (e) => setDraftField(group, key, e.target.value),
1873
+ })
1874
+ const numberInput = (group, key, fallback, step, unit) => [
1875
+ h('input', {
1876
+ key: 'input',
1877
+ className: 'dsu-input',
1878
+ type: 'number',
1879
+ step,
1880
+ value: String(readField(group, key, fallback)),
1881
+ disabled: !writable,
1882
+ onChange: (e) => setDraftField(group, key, Number(e.target.value)),
1883
+ }),
1884
+ unit ? h('span', { key: 'unit', className: 'dsu-unit' }, unit) : null,
1885
+ ]
1886
+ const switchInput = (group, base, key, fallback) =>
1887
+ h(SettingsSwitch, {
1888
+ checked: readField(group, key, fallback) !== false,
1889
+ disabled: !writable || busy,
1890
+ onChange: (v) => {
1891
+ setDraftField(group, key, v)
1892
+ commitNow(group, base, key, v)
1893
+ },
1894
+ })
1895
+ const segmentInput = (group, base, key, fallback, options) =>
1896
+ h(SettingsSegment, {
1897
+ value: readField(group, key, fallback),
1898
+ disabled: !writable || busy,
1899
+ options,
1900
+ onChange: (v) => {
1901
+ setDraftField(group, key, v)
1902
+ commitNow(group, base, key, v)
1903
+ },
1904
+ })
1905
+
1906
+ const hasDirty = dirtyKeys('assistant').length > 0 || dirtyKeys('observer').length > 0 || dirtyKeys('todo').length > 0 || Object.prototype.hasOwnProperty.call(draft, 'todoSync')
1907
+ const mode = readField('assistant', 'mode', '')
1908
+ const authority = readField('assistant', 'authority', 'both')
1665
1909
 
1666
1910
  return h(
1667
1911
  'div',
1668
- { className: 'pb-set' },
1669
- scope ? null : h('div', { className: 'pb-set-banner' }, t('setNoScope')),
1912
+ { className: 'dsu-set' },
1913
+ h(
1914
+ 'div',
1915
+ { className: 'dsu-topline' },
1916
+ h('span', { className: writable ? 'dsu-chip' : 'dsu-chip dsu-chip-warn' }, writable ? t('setLive') : t('setReadOnly')),
1917
+ h('span', { className: 'dsu-hint' }, writable ? t('setTopHint') : t('setNoScope')),
1918
+ ),
1670
1919
  h(
1671
- SettingsGroup,
1672
- { title: t('setLlmGroup'), hint: t('setLlmHint') },
1920
+ SettingsCard,
1921
+ { title: t('setLlmGroup'), badge: t('setLlmBadge'), hint: t('setLlmHint') },
1673
1922
  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))),
1923
+ segmentInput('assistant', assistant, 'mode', '', [['', t('setModeOff')], ['registered', t('setModeRegistered')], ['direct', t('setModeDirect')]])),
1924
+ mode === 'registered'
1925
+ ? h(SettingsRow, { label: t('setProvider'), hint: t('setProviderHint') }, textInput('assistant', 'provider', '', 'local-35b'))
1926
+ : null,
1927
+ h(SettingsRow, { label: t('setModel') }, textInput('assistant', 'model', '', mode === 'direct' ? 'qwen2.5-3b' : 'Qwen3.6-35B-A3B')),
1928
+ mode === 'direct' ? h(SettingsRow, { label: t('setBaseUrl') }, textInput('assistant', 'baseUrl', '', 'http://127.0.0.1:8000/v1')) : null,
1929
+ mode === 'direct' ? h(SettingsRow, { label: t('setApiKey'), hint: t('setApiKeyHint') }, secretInput('assistant', 'apiKey', assistant.hasApiKey ? '••••••' : '')) : null,
1930
+ mode === ''
1931
+ ? null
1932
+ : h(SettingsRow, { label: t('setAuthority') },
1933
+ segmentInput('assistant', assistant, 'authority', 'both', [['both', t('setAuthorityBoth')], ['slots', t('setAuthoritySlots')], ['rounds', t('setAuthorityRounds')]])),
1934
+ mode === '' ? null : h(SettingsRow, { label: t('setInterval'), hint: t('setIntervalHint') }, numberInput('assistant', 'minIntervalMs', 90000, 1000, 'ms')),
1935
+ mode === '' ? null : h(SettingsRow, { label: t('setAutoApply') }, switchInput('assistant', assistant, 'autoApply', true)),
1936
+ ),
1937
+ h(
1938
+ SettingsCard,
1939
+ { title: t('setObserverGroup'), badge: t('setObserverBadge'), hint: t('setObserverHint') },
1940
+ h(SettingsRow, { label: t('setObserverEnabled') }, switchInput('observer', observer, 'enabled', true)),
1941
+ h(SettingsRow, { label: t('setMaxIdleSteps') }, numberInput('observer', 'maxIdleSteps', 6, 1, '步')),
1942
+ h(SettingsRow, { label: t('setMaxIdleMs') }, numberInput('observer', 'maxIdleMs', 180000, 1000, 'ms')),
1943
+ h(SettingsRow, { label: t('setAutoSyncCurrent') }, switchInput('observer', observer, 'autoSyncCurrent', true)),
1944
+ h(SettingsRow, { label: t('setAutoSyncThrottleMs') }, numberInput('observer', 'autoSyncThrottleMs', 60000, 1000, 'ms')),
1945
+ h(SettingsRow, { label: t('setMaxItems') }, numberInput('observer', 'maxItems', 12, 1, '项')),
1689
1946
  ),
1690
1947
  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))),
1948
+ SettingsCard,
1949
+ { title: t('setTodoGroup'), badge: t('setTodoSync'), hint: t('setTodoHint'), defaultOpen: false },
1950
+ h(SettingsRow, { label: t('setTodoSync') },
1951
+ h(SettingsSegment, {
1952
+ value: Object.prototype.hasOwnProperty.call(draft, 'todoSync') ? draft.todoSync : (value.todoSync === undefined ? 'reconcile' : value.todoSync),
1953
+ disabled: !writable || busy,
1954
+ options: [['off', t('setTodoOff')], ['mirror', t('setTodoMirror')], ['reconcile', t('setTodoReconcile')]],
1955
+ onChange: (v) => { setDraft((prev) => ({ ...prev, todoSync: v })); void commit('todoSync', v) },
1956
+ })),
1957
+ h(SettingsRow, { label: t('setTodoReconcileMs') }, numberInput('todo', 'maxReconcileIntervalMs', 60000, 1000, 'ms')),
1958
+ h(SettingsRow, { label: t('setTodoThrottleMs') }, numberInput('todo', 'mirrorThrottleMs', 200, 1, 'ms')),
1959
+ h('div', { className: 'dsu-hint' }, t('setTodoWriteNote')),
1705
1960
  ),
1706
1961
  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()'),
1962
+ SettingsCard,
1963
+ { title: t('setApiGroup'), badge: t('setApiBadge'), hint: t('setApiHint'), defaultOpen: false },
1964
+ h('div', { className: 'dsu-api' },
1965
+ h('div', null, h('b', null, t('setApiService')), "ctx.get('progressAnchor').get(sessionId) / .list()"),
1711
1966
  h('div', null, h('b', null, t('setApiAnchor')), 'GET /progress-union/anchor?sessionId=<id>'),
1712
1967
  h('div', null, h('b', null, t('setApiSnapshot')), 'GET /progress-union/snapshot?sessionId=<id>'),
1713
1968
  h('div', null, h('b', null, t('setApiStatus')), 'GET /dsh-progress/status?sessionId=<id>'),
1714
1969
  ),
1715
1970
  ),
1716
- status ? h('div', { className: 'pb-set-status' }, status) : null,
1971
+ h(
1972
+ 'div',
1973
+ { className: 'dsu-actions' },
1974
+ h('button', { type: 'button', className: 'dsu-btn dsu-btn-primary', disabled: !hasDirty || busy || !writable, onClick: () => void flush() }, busy ? t('setSaving') : t('setSave')),
1975
+ h('button', {
1976
+ type: 'button',
1977
+ className: 'dsu-btn',
1978
+ disabled: !hasDirty || busy,
1979
+ onClick: () => {
1980
+ setDraft({})
1981
+ setStatus('')
1982
+ },
1983
+ }, t('setReset')),
1984
+ h('span', { className: 'dsu-hint dsu-spacer' }, hasDirty ? t('setDirty') : ''),
1985
+ status ? h('span', { className: 'dsu-hint' }, status) : null,
1986
+ ),
1717
1987
  )
1718
1988
  }
1719
-
1720
1989
  function ProgressSidePanel(props) {
1721
1990
  const t = makeT(props)
1722
1991
  const { sessionId } = props
@@ -2439,27 +2708,32 @@ window.__ModuleLoader__.load({
2439
2708
 
2440
2709
  const t = ctx.locale.bind(NS)
2441
2710
 
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
- ),
2711
+ // 双座位注册:顶层设置分节(settings.section)+ 插件详情页配置卡
2712
+ // (plugins.bundle.config,keyed by **包名**)。
2713
+ // configForms 可能在 apply 之后才就绪 → 走 deferred inject 捕获句柄,
2714
+ // 卡内自己订阅句柄并重取 scope,所以两个座位都可以先注空 prop。
2715
+ bindUnionConfigForms(ctx)
2716
+ ensureUnionSettingsStyle()
2717
+ const registerSettingsSeat = (seat, options) =>
2718
+ ctx.slots.inject(seat, () =>
2719
+ ctx.slots.register(
2720
+ {
2721
+ name: seat,
2722
+ ...options,
2723
+ locale: NS,
2724
+ inject: () => ({}),
2725
+ },
2726
+ ProgressUnionSettings,
2460
2727
  ),
2728
+ )
2729
+ ctx.effect(
2730
+ () => registerSettingsSeat('settings.section', { id: 'dsh-progress-union', order: 215, label: () => t('setTitle') }),
2461
2731
  'progress-union: settings section',
2462
2732
  )
2733
+ ctx.effect(
2734
+ () => registerSettingsSeat('plugins.bundle.config', { key: 'dsh-progress-union', order: 15 }),
2735
+ 'progress-union: bundle config card',
2736
+ )
2463
2737
 
2464
2738
  const wakeAgent = (sessionId, text) => {
2465
2739
  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.3.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": {