@restregular/dsh-memory 0.6.1 → 0.6.2

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/lib/client.js +30 -27
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -309,6 +309,7 @@ tools/build-single-package.mjs 构建(产物契约检查 + 可选加载验证)
309
309
 
310
310
  ## 版本
311
311
 
312
+ - **0.6.2** —— 设置页**去掉「保存设置」按钮**:开关拨动、数值改动即保存(连续调数值会合并成一次请求),页内只留一行“已保存”提示;顶部说明改成与行为一致的一句话(“设置保存在记忆数据目录的 settings.json”),不再写“保存后生效/无需重启”这类与实际操作不符的描述。
312
313
  - **0.6.1** —— 面板与工具打磨:
313
314
  - **标签页**改成分段式按钮(选中项浅底 + 品牌色),记录页各区块之间补上间距。
314
315
  - **设置项**统一成开关按钮(不再用复选框 + “启用”文字),每条提示压到一行。
package/lib/client.js CHANGED
@@ -584,9 +584,11 @@ window.__ModuleLoader__.load({
584
584
  }, h('span', { className: 'knob' }))
585
585
  }
586
586
 
587
+ /** 设置自动保存的合并定时器:连续调数值只发一次请求。 */
588
+ let autoSaveTimer = null
589
+
587
590
  /**
588
- * 设置标签页:这些开关直接改注入行为,保存后下一步生效(不进 cordis 配置,
589
- * 落盘在记忆数据目录的 settings.json)。分组顺序与「注入链路」一致:
591
+ * 设置标签页:这些开关直接改注入行为,改完立即保存(没有"保存"按钮)。
590
592
  * 每轮召回 → 印象 → 会话摘要 → 系统提示(策略/规则) → 轮末提醒 → 界面。
591
593
  */
592
594
  const SETTINGS_GROUPS = [
@@ -645,7 +647,6 @@ window.__ModuleLoader__.load({
645
647
 
646
648
  function SettingsTab() {
647
649
  const [settings, setSettings] = React.useState(null)
648
- const [busy, setBusy] = React.useState(false)
649
650
  const [error, setError] = React.useState('')
650
651
  const [notice, setNotice] = React.useState('')
651
652
  const [rulesCount, setRulesCount] = React.useState(null)
@@ -696,30 +697,37 @@ window.__ModuleLoader__.load({
696
697
  event.target.value = ''
697
698
  }
698
699
 
699
- const patch = (group, key, value) => setSettings((current) => {
700
- if (!current) return current
701
- return { ...current, [group]: { ...current[group], [key]: value } }
702
- })
700
+ // 改动即保存:开关/数值一变就提交(数值连续输入时合并成一次请求),
701
+ // 不再有"保存设置"按钮 —— 界面上也就不该再写"保存后生效"这类话。
702
+ const patch = (group, key, value) => {
703
+ if (!settings) return
704
+ const next = { ...settings, [group]: { ...settings[group], [key]: value } }
705
+ setSettings(next)
706
+ autoSave(next)
707
+ }
703
708
 
704
- const save = async () => {
705
- setBusy(true); setError(''); setNotice('')
706
- try {
707
- const next = await api('settings', settings)
708
- setSettings(next)
709
- setNotice('已保存,下一步生效')
710
- if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function') {
711
- try { window.dispatchEvent(new CustomEvent('dsh-memory:settings')) } catch { /* 没有 CustomEvent 就等下次启动 */ }
709
+ const autoSave = (next) => {
710
+ if (autoSaveTimer !== null) clearTimeout(autoSaveTimer)
711
+ setError('')
712
+ autoSaveTimer = setTimeout(async () => {
713
+ autoSaveTimer = null
714
+ try {
715
+ await api('settings', next)
716
+ setNotice('已保存')
717
+ setTimeout(() => setNotice(''), 1500)
718
+ if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function') {
719
+ try { window.dispatchEvent(new CustomEvent('dsh-memory:settings')) } catch { /* 没有 CustomEvent 就等下次启动 */ }
720
+ }
721
+ } catch (e) {
722
+ setError(String(e.message || e))
712
723
  }
713
- } catch (e) {
714
- setError(String(e.message || e))
715
- }
716
- setBusy(false)
724
+ }, 250)
717
725
  }
718
726
 
719
727
  if (!settings) return h('div', { className: 'empty' }, error || '加载设置…')
720
728
 
721
729
  return h('div', { className: 'setp' },
722
- h('div', { className: 'hint' }, '开关立即生效,无需重启;设置保存在记忆数据目录的 settings.json。'),
730
+ h('div', { className: 'hint' }, '设置保存在记忆数据目录的 settings.json。'),
723
731
  SETTINGS_GROUPS.map((group) => {
724
732
  const value = settings[group.key] || {}
725
733
  return h('div', { className: 'setrow', key: group.key },
@@ -728,14 +736,12 @@ window.__ModuleLoader__.load({
728
736
  ? h(Switch, {
729
737
  key: field.k,
730
738
  checked: Boolean(value[field.k]),
731
- disabled: busy,
732
739
  title: group.hint || field.label,
733
740
  onChange: (next) => patch(group.key, field.k, next),
734
741
  })
735
742
  : h('label', { className: 'set-field', key: field.k }, field.label, ' ',
736
743
  h('input', {
737
744
  type: 'number', min: field.min, max: field.max, step: field.step, value: value[field.k],
738
- disabled: busy,
739
745
  onChange: (e) => patch(group.key, field.k, Number(e.target.value)),
740
746
  }))),
741
747
  h('span', { className: 'set-desc' }, group.desc),
@@ -754,11 +760,8 @@ window.__ModuleLoader__.load({
754
760
  dataNotice ? h('span', { className: 'muted' }, dataNotice) : null,
755
761
  ),
756
762
  ),
757
- h('div', { className: 'setfoot' },
758
- h('button', { onClick: save, disabled: busy }, busy ? '保存中…' : '保存设置'),
759
- notice ? h('span', { className: 'muted' }, notice) : null,
760
- error ? h('span', { className: 'err' }, error) : null,
761
- ),
763
+ error ? h('div', { className: 'err' }, error) : null,
764
+ notice ? h('div', { className: 'muted' }, notice) : null,
762
765
  )
763
766
  }
764
767
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "DeepSeek Harness 本地长期记忆(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 四个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",