dsh-memu-memory 1.2.7 → 1.2.9
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/AGENTS.md +1 -1
- package/CHANGELOG.md +472 -0
- package/README.md +10 -15
- package/README.zh.md +10 -15
- package/docs/memory-semantics.md +23 -3
- package/lib/backup.js +155 -26
- package/lib/binding-diagnostics.js +1 -2
- package/lib/budget.js +31 -9
- package/lib/client.js +221 -128
- package/lib/commitment.js +138 -0
- package/lib/consolidation-ledger.js +5 -2
- package/lib/consolidation-receipt.js +2 -0
- package/lib/consolidation-worker.js +3 -0
- package/lib/curator-policy.js +23 -0
- package/lib/cycle.js +8 -4
- package/lib/embedding-download.js +168 -28
- package/lib/embedding-runtime.js +76 -17
- package/lib/engine.js +0 -6
- package/lib/freshness.js +24 -0
- package/lib/graph.js +139 -11
- package/lib/index.js +71 -20
- package/lib/inject.js +167 -17
- package/lib/lexicon.js +62 -17
- package/lib/local-vector-service.js +25 -2
- package/lib/media.js +49 -12
- package/lib/memory.js +1202 -123
- package/lib/memu.js +4 -0
- package/lib/paths.js +0 -7
- package/lib/preset-scope.js +6 -1
- package/lib/private.js +50 -10
- package/lib/prompts/private-consolidation.mixed.md +2 -2
- package/lib/prompts/private-consolidation.rp.md +6 -1
- package/lib/prompts/private-policy.rp.md +4 -0
- package/lib/prompts/system-guide.rp.md +3 -0
- package/lib/prompts.js +0 -7
- package/lib/recall-cache.js +10 -2
- package/lib/rpc.js +104 -19
- package/lib/snippet.js +41 -0
- package/lib/state.js +109 -30
- package/lib/stats.js +2 -2
- package/lib/temporal.js +348 -0
- package/lib/text-retrieval.js +191 -44
- package/lib/text-similarity.js +205 -24
- package/lib/tokenizer-v2.js +0 -24
- package/lib/tools.js +81 -4
- package/lib/vector-migration.js +15 -0
- package/lib/vector-profile.js +81 -8
- package/lib/visibility.js +0 -4
- package/lib/webui/standalone.css +17 -22
- package/lib/webui/standalone.js +27 -9
- package/lib/webui.js +4 -4
- package/package.json +3 -2
- package/scripts/acceptance-local.mjs +2 -2
- package/scripts/bench-recall.mjs +2 -2
- package/scripts/check-all.mjs +3 -1
- package/scripts/check-i18n.mjs +35 -1
- package/scripts/check-seed-compat.mjs +1 -1
- package/scripts/migrate-visibility.mjs +3 -3
- package/scripts/prune-sessions.mjs +34 -0
- package/scripts/prune-vectors.mjs +24 -0
- package/tests/appendix-b.test.mjs +5 -4
- package/tests/audit-batch3.test.mjs +247 -0
- package/tests/audit-regression.test.mjs +2 -2
- package/tests/backup.test.mjs +85 -85
- package/tests/browser.test.mjs +6 -1
- package/tests/client-render.test.mjs +2 -2
- package/tests/commitment.test.mjs +144 -0
- package/tests/consolidation-fork.test.mjs +3 -3
- package/tests/curator-clusters.test.mjs +18 -0
- package/tests/curator-pairing.test.mjs +59 -16
- package/tests/disclosure.test.mjs +34 -17
- package/tests/dynamic-rrf.test.mjs +22 -19
- package/tests/dynamic-threshold.test.mjs +52 -0
- package/tests/fact-version.test.mjs +146 -0
- package/tests/fixtures/tokenizer-cases.mjs +27 -0
- package/tests/graph-cascade.test.mjs +29 -0
- package/tests/graph.test.mjs +45 -0
- package/tests/help-page.test.mjs +1 -1
- package/tests/inject-conflict.test.mjs +112 -0
- package/tests/inject-guide.test.mjs +5 -3
- package/tests/inject.test.mjs +2 -2
- package/tests/injection-intent-budget.test.mjs +92 -0
- package/tests/lexical-bm25.test.mjs +171 -0
- package/tests/lexicon-frequency.test.mjs +17 -1
- package/tests/lexicon-inject.test.mjs +21 -0
- package/tests/lexicon-perf.test.mjs +37 -9
- package/tests/lexicon-scope.test.mjs +2 -2
- package/tests/lexicon-ui.test.mjs +1 -1
- package/tests/managed-memory.test.mjs +19 -0
- package/tests/memory-chain.test.mjs +140 -0
- package/tests/memory-fields.test.mjs +134 -0
- package/tests/memu-resident.test.mjs +33 -0
- package/tests/ops-hardening.test.mjs +209 -0
- package/tests/package-shipping.test.mjs +4 -0
- package/tests/prompt-semantics.test.mjs +51 -0
- package/tests/query-decompose.test.mjs +62 -0
- package/tests/recall-cache.test.mjs +4 -2
- package/tests/recall-intent.test.mjs +123 -0
- package/tests/slot-similarity.test.mjs +153 -0
- package/tests/speaker-provenance.test.mjs +120 -0
- package/tests/state-gc.test.mjs +34 -0
- package/tests/state.test.mjs +2 -2
- package/tests/temporal.test.mjs +124 -0
- package/tests/tokenizer-v2.test.mjs +1 -1
- package/tests/vector-gc.test.mjs +37 -0
- package/tests/webui.test.mjs +27 -0
package/lib/client.js
CHANGED
|
@@ -107,6 +107,9 @@ window.__ModuleLoader__.load({
|
|
|
107
107
|
} catch {}
|
|
108
108
|
|
|
109
109
|
const zh = {
|
|
110
|
+
settingsUnsaved: '有未保存的设置更改',
|
|
111
|
+
settingsRetry: '重试保存',
|
|
112
|
+
settingsDiscard: '丢弃更改',
|
|
110
113
|
inboundToolNames: '外部消息工具白名单',
|
|
111
114
|
reviewResolution: '复核方式',
|
|
112
115
|
reviewReplace: '替代旧事实',
|
|
@@ -223,6 +226,8 @@ window.__ModuleLoader__.load({
|
|
|
223
226
|
sidebarSettings: '在侧边栏保留完整设置',
|
|
224
227
|
visionCaptionEnabled: '允许发送图片到视觉描述服务',
|
|
225
228
|
visionService: '图片描述服务(可选)',
|
|
229
|
+
visionServiceHint: '独立于主记忆服务的可选图片描述接入,只有开启「允许发送图片到视觉描述服务」时才会调用;下面三项一起保存。',
|
|
230
|
+
captionModel: '视觉模型',
|
|
226
231
|
attachmentMissing: '附件缺失',
|
|
227
232
|
relations: '关系',
|
|
228
233
|
adjacency: '邻接列表',
|
|
@@ -273,7 +278,7 @@ window.__ModuleLoader__.load({
|
|
|
273
278
|
refresh: '刷新',
|
|
274
279
|
warning: '更新到未经验证的最新版可能导致 CLI 变化或记忆功能损坏。只安装插件声明的推荐版本。',
|
|
275
280
|
memorySettings: '记忆设置',
|
|
276
|
-
settingsTuning: '
|
|
281
|
+
settingsTuning: '保存与恢复',
|
|
277
282
|
settingsHeaderNote: '改动即时保存(约 0.25 秒后写盘);「恢复默认」需两次点击确认。',
|
|
278
283
|
settingsGroupRecall: '召回与注入',
|
|
279
284
|
settingsGroupRecallDesc: '每轮注入什么、注入多少:注入模式、召回条数、token 预算与去重。',
|
|
@@ -292,6 +297,7 @@ window.__ModuleLoader__.load({
|
|
|
292
297
|
globalTopK: '全局 topK',
|
|
293
298
|
crossLibraryRecall: '跨库召回(仅同领域)',
|
|
294
299
|
crossLibraryRecallHint: '开启后,这些读取会合并其它「同领域」私有库:自动召回、memu_private_recall、memu_private_list、侧栏私有列表,以及词典的锚点摘要、本回合匹配与 memu_lexicon_search。\n显式浏览某个库时,仍只显示该库。\n写入不受影响,仍只写当前库;全局词典只有你能写。\n跨库读取改变隔离边界,默认关闭。',
|
|
300
|
+
crossLibraryRecallShort: '同领域私有库合并读取',
|
|
295
301
|
mustRememberCap: '永久记忆软上限',
|
|
296
302
|
shortTermTtlHours: '短期记忆保留(小时,0=关闭)',
|
|
297
303
|
anchorTokens: '锚点 token',
|
|
@@ -911,6 +917,9 @@ window.__ModuleLoader__.load({
|
|
|
911
917
|
}
|
|
912
918
|
|
|
913
919
|
const en = {
|
|
920
|
+
settingsUnsaved: 'Unsaved settings changes',
|
|
921
|
+
settingsRetry: 'Retry save',
|
|
922
|
+
settingsDiscard: 'Discard changes',
|
|
914
923
|
inboundToolNames: 'External message tool allowlist',
|
|
915
924
|
reviewResolution: 'Resolution',
|
|
916
925
|
reviewReplace: 'Replace the old fact',
|
|
@@ -1027,6 +1036,8 @@ window.__ModuleLoader__.load({
|
|
|
1027
1036
|
sidebarSettings: 'Keep full settings in the sidebar',
|
|
1028
1037
|
visionCaptionEnabled: 'Allow sending images to the vision description service',
|
|
1029
1038
|
visionService: 'Image description service (optional)',
|
|
1039
|
+
visionServiceHint: 'Optional caption endpoint, independent of the memory service. It is only called when "Allow sending images to the vision description service" is on; the three fields save together.',
|
|
1040
|
+
captionModel: 'Vision model',
|
|
1030
1041
|
attachmentMissing: 'Attachment missing',
|
|
1031
1042
|
relations: 'Relations',
|
|
1032
1043
|
adjacency: 'Adjacency',
|
|
@@ -1077,7 +1088,7 @@ window.__ModuleLoader__.load({
|
|
|
1077
1088
|
refresh: 'Refresh',
|
|
1078
1089
|
warning: 'Unverified latest releases can change the CLI or break memory. Only the recommended version declared by the plugin is installed.',
|
|
1079
1090
|
memorySettings: 'Memory settings',
|
|
1080
|
-
settingsTuning: '
|
|
1091
|
+
settingsTuning: 'Saving & reset',
|
|
1081
1092
|
settingsHeaderNote: 'Edits save themselves about 0.25s after each change; Reset defaults asks for a second click.',
|
|
1082
1093
|
settingsGroupRecall: 'Recall & injection',
|
|
1083
1094
|
settingsGroupRecallDesc: 'What each turn injects and how much: injection mode, topK, token budgets, dedupe.',
|
|
@@ -1096,6 +1107,7 @@ window.__ModuleLoader__.load({
|
|
|
1096
1107
|
globalTopK: 'Global topK',
|
|
1097
1108
|
crossLibraryRecall: 'Cross-library recall (same domain)',
|
|
1098
1109
|
crossLibraryRecallHint: 'When on, these reads merge other same-domain private libraries: automatic recall, memu_private_recall, memu_private_list, the sidebar private list, plus the lexicon anchor summaries, this-turn matching and memu_lexicon_search.\nExplicitly browsing a library still shows that library only.\nWrites are unaffected and still go to the current library; the global lexicon stays yours alone to write.\nReading across libraries changes the isolation boundary, so this is off by default.',
|
|
1110
|
+
crossLibraryRecallShort: 'Merge same-domain reads',
|
|
1099
1111
|
mustRememberCap: 'Permanent memory cap',
|
|
1100
1112
|
shortTermTtlHours: 'Short-term TTL in hours (0=off)',
|
|
1101
1113
|
anchorTokens: 'Anchor tokens',
|
|
@@ -1725,8 +1737,8 @@ window.__ModuleLoader__.load({
|
|
|
1725
1737
|
accentSoft: 'color-mix(in srgb, var(--dsw-alias-brand-primary, #2563eb) 10%, transparent)',
|
|
1726
1738
|
text: 'var(--dsw-alias-label-primary, inherit)',
|
|
1727
1739
|
textDim: 'var(--dsw-alias-label-secondary, rgba(127,127,127,.72))',
|
|
1728
|
-
danger: 'var(--dsw-alias-
|
|
1729
|
-
warn: 'var(--dsw-alias-label
|
|
1740
|
+
danger: 'var(--dsw-alias-state-error-primary, #c0392b)',
|
|
1741
|
+
warn: 'var(--dsw-alias-state-warn-label, #b7791f)',
|
|
1730
1742
|
radius: 12,
|
|
1731
1743
|
radiusSm: 8,
|
|
1732
1744
|
}
|
|
@@ -1777,14 +1789,13 @@ window.__ModuleLoader__.load({
|
|
|
1777
1789
|
const UI_CSS = `
|
|
1778
1790
|
.dshm-root{letter-spacing:0!important}
|
|
1779
1791
|
.dshm-root *{letter-spacing:0!important;min-width:0}
|
|
1780
|
-
.dshm-root
|
|
1792
|
+
.dshm-root .dshm-page .dshm-card{border-radius:16px}
|
|
1781
1793
|
.dshm-card-head,.dshm-card-actions{flex-wrap:wrap}
|
|
1782
1794
|
.dshm-card-head>div:not([class]){flex:1 1 180px!important;min-width:120px}
|
|
1783
1795
|
.dshm-card-actions{max-width:100%}
|
|
1784
1796
|
.dshm-card-actions>div{flex-wrap:wrap;max-width:100%}
|
|
1785
1797
|
.dshm-card-head{display:flex;flex-wrap:wrap}
|
|
1786
1798
|
.dshm-root .dshm-btn{white-space:normal;overflow-wrap:anywhere;border-radius:4px!important}
|
|
1787
|
-
.dshm-card:hover{transform:none!important;box-shadow:none!important}
|
|
1788
1799
|
.dshm-wall-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr));gap:12px;margin-top:18px}
|
|
1789
1800
|
.dshm-wall-item{display:flex;flex-direction:column;gap:10px;min-height:220px;width:100%;padding:16px;border:1px solid var(--dsw-alias-border-l1,#ccc);border-radius:6px;background:var(--dsw-alias-bg-layer-1,transparent);color:inherit;text-align:left;cursor:pointer;font:inherit}
|
|
1790
1801
|
.dshm-wall-item:hover{border-color:var(--dsw-alias-brand-primary,#167b69)}
|
|
@@ -1815,7 +1826,7 @@ window.__ModuleLoader__.load({
|
|
|
1815
1826
|
.dshm-drawer-note{margin-top:4px;font-size:11.5px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
1816
1827
|
.dshm-drawer-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto;padding-top:14px;border-top:1px solid var(--dsw-alias-border-l1,#ddd)}
|
|
1817
1828
|
@keyframes dshm-drawer-in{from{transform:translateX(28px);opacity:0}to{transform:none;opacity:1}}
|
|
1818
|
-
.dshm-brand-tile{background:transparent
|
|
1829
|
+
.dshm-root .dshm-brand-tile{background:transparent;box-shadow:none}
|
|
1819
1830
|
.dshm-brand-tile img{display:block;object-fit:contain}
|
|
1820
1831
|
.dshm-graph-tools{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:12px 0}
|
|
1821
1832
|
.dshm-graph-tools input,.dshm-graph-tools select{min-width:0;max-width:100%;padding:7px;border:1px solid var(--dsw-alias-border-l2,#505158);border-radius:4px;background:var(--dsw-alias-bg-layer-1,#242529);color:inherit;font:inherit}
|
|
@@ -1843,8 +1854,8 @@ window.__ModuleLoader__.load({
|
|
|
1843
1854
|
.dshm-graph-node{max-width:100%;padding:3px 9px;border:1px solid var(--dsw-alias-border-l1,#ccc);border-radius:999px;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.08));color:inherit;font:inherit;font-size:12.5px;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:border-color .18s ease,color .18s ease,background .18s ease}
|
|
1844
1855
|
.dshm-graph-node:hover{border-color:var(--dsw-alias-brand-primary,#2563eb);color:var(--dsw-alias-brand-primary,#2563eb)}
|
|
1845
1856
|
.dshm-graph-unlink{flex:none;min-width:24px;height:24px;padding:0 6px;border:0;border-radius:7px;background:none;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8));font:inherit;font-size:14px;line-height:1;cursor:pointer;transition:background .18s ease,color .18s ease}
|
|
1846
|
-
.dshm-graph-unlink:hover{background:color-mix(in srgb,var(--dsw-alias-
|
|
1847
|
-
.dshm-graph-unlink.is-armed{width:auto;padding:0 8px;font-size:11.5px;color:var(--dsw-alias-
|
|
1857
|
+
.dshm-graph-unlink:hover{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#b43e45) 10%,transparent);color:var(--dsw-alias-state-error-primary,#b43e45)}
|
|
1858
|
+
.dshm-graph-unlink.is-armed{width:auto;padding:0 8px;font-size:11.5px;color:var(--dsw-alias-state-error-primary,#b43e45);background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#b43e45) 12%,transparent)}
|
|
1848
1859
|
@media (max-width:1100px){.dshm-graph-stage{grid-template-columns:minmax(0,1fr)}}
|
|
1849
1860
|
.dshm-graph-missing{opacity:.5}
|
|
1850
1861
|
/* The sidebar's context-scope form: a collapsed card instead of four bare
|
|
@@ -1907,7 +1918,7 @@ window.__ModuleLoader__.load({
|
|
|
1907
1918
|
.dshm-nav-item:disabled{opacity:.45;cursor:default}
|
|
1908
1919
|
.dshm-nav-item:disabled:hover{color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
1909
1920
|
.dshm-x{flex:none;width:22px;height:22px;padding:0;border:0;border-radius:6px;background:none;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8));font:inherit;font-size:14px;line-height:1;opacity:.6;cursor:pointer;transition:opacity .18s ease,background .18s ease,color .18s ease}
|
|
1910
|
-
.dshm-x:hover{opacity:1;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.1));color:var(--dsw-alias-
|
|
1921
|
+
.dshm-x:hover{opacity:1;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.1));color:var(--dsw-alias-state-error-primary,#e5484d)}
|
|
1911
1922
|
.dshm-x:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:1px}
|
|
1912
1923
|
|
|
1913
1924
|
.dshm-page{min-width:0;display:flex;flex-direction:column;gap:13px;animation:dshm-page-in .26s cubic-bezier(.22,1,.36,1) both}
|
|
@@ -1922,9 +1933,9 @@ window.__ModuleLoader__.load({
|
|
|
1922
1933
|
.dshm-card:hover{transform:translateY(-2px);box-shadow:0 10px 28px -12px rgba(0,0,0,.28)}
|
|
1923
1934
|
.dshm-rise{animation:dshm-rise-in .34s cubic-bezier(.22,1,.36,1) both;animation-delay:calc(var(--d,0) * 38ms)}
|
|
1924
1935
|
.dshm-card-head{display:flex;align-items:flex-start;gap:11px}
|
|
1925
|
-
.dshm-logrow.is-failed{border-left:2px solid var(--dsw-alias-
|
|
1926
|
-
.dshm-logrow.is-failed .dshm-logmsg{color:var(--dsw-alias-
|
|
1927
|
-
.dshm-logrow.is-degraded{border-left:2px solid var(--dsw-alias-label
|
|
1936
|
+
.dshm-logrow.is-failed{border-left:2px solid var(--dsw-alias-state-error-primary,#c0392b);background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#c0392b) 7%,transparent)}
|
|
1937
|
+
.dshm-logrow.is-failed .dshm-logmsg{color:var(--dsw-alias-state-error-primary,#c0392b)}
|
|
1938
|
+
.dshm-logrow.is-degraded{border-left:2px solid var(--dsw-alias-state-warn-label,#b7791f)}
|
|
1928
1939
|
.dshm-card-ico{width:32px;height:32px;flex:none;border-radius:10px;display:grid;place-items:center;color:var(--dsw-alias-brand-primary,#2563eb);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#2563eb) 12%,transparent)}
|
|
1929
1940
|
.dshm-card-title{font-size:13.5px;font-weight:600;line-height:1.3}
|
|
1930
1941
|
.dshm-card-sub{margin-top:3px;font-size:11.5px;line-height:1.5;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8));max-width:60ch}
|
|
@@ -1965,7 +1976,7 @@ window.__ModuleLoader__.load({
|
|
|
1965
1976
|
.dshm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:2px}
|
|
1966
1977
|
.dshm-toggle{transition:background .28s ease,border-color .28s ease}
|
|
1967
1978
|
.dshm-toggle-knob{transition:transform .28s cubic-bezier(.22,1,.36,1)}
|
|
1968
|
-
.dshm-error{color:var(--dsw-alias-
|
|
1979
|
+
.dshm-error{color:var(--dsw-alias-state-error-primary,#c0392b);font-size:12px;line-height:1.6}
|
|
1969
1980
|
.dshm-muted{font-size:12px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
1970
1981
|
.dshm-subhead{margin:14px 0 6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8));letter-spacing:.02em}
|
|
1971
1982
|
.dshm-chart{display:block;width:100%;height:auto;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
@@ -1983,26 +1994,15 @@ window.__ModuleLoader__.load({
|
|
|
1983
1994
|
.dshm-prompt-head{display:flex;justify-content:space-between;gap:8px;align-items:flex-start;flex-wrap:wrap}
|
|
1984
1995
|
.dshm-prompt-meta{flex:1 1 240px;min-width:0;overflow-wrap:anywhere}
|
|
1985
1996
|
.dshm-prompt-actions{display:flex;gap:6px;flex-shrink:0;margin-left:auto}
|
|
1997
|
+
/* 单一响应式通道:@container 同时覆盖宿主侧栏与独立页,不再与 @media 双轨重复。
|
|
1998
|
+
窄屏规则只作用于容器后代——容器自身不可自查询(原 .dshm-root 规则已删除)。 */
|
|
1986
1999
|
@container (max-width:900px){
|
|
1987
2000
|
.dshm-prompt-layout{grid-template-columns:minmax(0,1fr)}
|
|
1988
2001
|
.dshm-prompt-pages{flex-direction:row;flex-wrap:wrap;gap:2px}
|
|
1989
2002
|
.dshm-prompt-pages>div{flex:none}
|
|
1990
2003
|
.dshm-prompt-new{max-width:240px}
|
|
2004
|
+
.dshm-graph-stage{grid-template-columns:minmax(0,1fr)}
|
|
1991
2005
|
}
|
|
1992
|
-
@container (max-width:480px){
|
|
1993
|
-
.dshm-prompt-meta{flex-basis:100%}
|
|
1994
|
-
.dshm-prompt-actions{width:100%;justify-content:flex-end;margin-left:0}
|
|
1995
|
-
}
|
|
1996
|
-
@media (max-width:760px){
|
|
1997
|
-
.dshm-prompt-layout{grid-template-columns:minmax(0,1fr)}
|
|
1998
|
-
.dshm-prompt-pages{flex-direction:row;flex-wrap:wrap;gap:2px}
|
|
1999
|
-
.dshm-prompt-pages>div{flex:none}
|
|
2000
|
-
}
|
|
2001
|
-
@media (max-width:520px){
|
|
2002
|
-
.dshm-prompt-meta{flex-basis:100%}
|
|
2003
|
-
.dshm-prompt-actions{width:100%;justify-content:flex-end;margin-left:0}
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
2006
|
@container (max-width:620px){
|
|
2007
2007
|
.dshm-shell{grid-template-columns:minmax(0,1fr);gap:14px} .dshm-nav{position:static;gap:10px}
|
|
2008
2008
|
.dshm-brand{padding:0 2px}
|
|
@@ -2013,17 +2013,13 @@ window.__ModuleLoader__.load({
|
|
|
2013
2013
|
.dshm-h1{font-size:18px}
|
|
2014
2014
|
}
|
|
2015
2015
|
@container (max-width:480px){
|
|
2016
|
-
.dshm-
|
|
2016
|
+
.dshm-prompt-meta{flex-basis:100%}
|
|
2017
|
+
.dshm-prompt-actions{width:100%;justify-content:flex-end;margin-left:0}
|
|
2017
2018
|
.dshm-page{gap:10px}
|
|
2018
2019
|
.dshm-overline{font-size:10px}
|
|
2019
2020
|
.dshm-h1{font-size:17px}
|
|
2020
2021
|
.dshm-desc{font-size:12px}
|
|
2021
2022
|
}
|
|
2022
|
-
/* The host renders the wall inside a pane, not a viewport: the merged graph needs
|
|
2023
|
-
to stack by its own width, not the browser's. */
|
|
2024
|
-
@container (max-width:900px){
|
|
2025
|
-
.dshm-graph-stage{grid-template-columns:minmax(0,1fr)}
|
|
2026
|
-
}
|
|
2027
2023
|
|
|
2028
2024
|
/* Sidebar surface: the panel is narrow and scrolls. The rail carries is-row in its
|
|
2029
2025
|
own markup here, so only the page scroll and the type scale differ. */
|
|
@@ -2066,7 +2062,13 @@ window.__ModuleLoader__.load({
|
|
|
2066
2062
|
function openWebUiPage(page = null, { libraryId = null } = {}) {
|
|
2067
2063
|
// libraryId 走 query:SettingsPage 的 standalone 分支从 search 里取 browseLibId,
|
|
2068
2064
|
// 跳进去就停在出错记忆所在的库;hash 只决定落到哪个页面。
|
|
2069
|
-
|
|
2065
|
+
// 宿主主题随 URL 带过去,独立壳首帧就按当前深浅色绘制,避免 dark 下闪白。
|
|
2066
|
+
const params = new URLSearchParams()
|
|
2067
|
+
if (libraryId) params.set('libraryId', libraryId)
|
|
2068
|
+
let dark = false
|
|
2069
|
+
try { dark = document.body?.hasAttribute('data-ds-dark-theme') || document.documentElement?.dataset?.theme === 'dark' } catch {}
|
|
2070
|
+
params.set('theme', dark ? 'dark' : 'light')
|
|
2071
|
+
const query = '?' + params.toString()
|
|
2070
2072
|
let url = '/dsh-memu-memory/ui' + query + '#/settings/' + (page || 'memories')
|
|
2071
2073
|
try { url = new URL(url, window.location.href).toString() } catch {}
|
|
2072
2074
|
let win = null
|
|
@@ -2111,7 +2113,11 @@ window.__ModuleLoader__.load({
|
|
|
2111
2113
|
wrap.style.cssText = [
|
|
2112
2114
|
'position:fixed', 'inset:0', 'z-index:2147483000', 'display:flex',
|
|
2113
2115
|
'align-items:center', 'justify-content:center', 'padding:24px',
|
|
2114
|
-
|
|
2116
|
+
// No backdrop-filter on this full-viewport wrapper. Behind it sits the
|
|
2117
|
+
// whole host app; with a maximized window every repaint inside the
|
|
2118
|
+
// iframe made WebView2 re-blur that backdrop and the panel flickered or
|
|
2119
|
+
// lost tiles. A plain dim is cheap and looks the same at 55% black.
|
|
2120
|
+
'background:rgba(6,8,12,.6)',
|
|
2115
2121
|
].join(';')
|
|
2116
2122
|
|
|
2117
2123
|
const frame = document.createElement('iframe')
|
|
@@ -2121,7 +2127,9 @@ window.__ModuleLoader__.load({
|
|
|
2121
2127
|
// 1600px cap left a dark band on wide windows.
|
|
2122
2128
|
frame.style.cssText = [
|
|
2123
2129
|
'width:100%', 'height:100%', 'border:0',
|
|
2124
|
-
|
|
2130
|
+
// Opaque, theme-aware: a transparent frame let the host show through
|
|
2131
|
+
// while the embedded page painted, which read as flashing at fullscreen.
|
|
2132
|
+
'border-radius:16px', 'background:var(--dsw-alias-bg-base, #f4f5f9)',
|
|
2125
2133
|
'box-shadow:0 30px 80px -30px rgba(0,0,0,.85)',
|
|
2126
2134
|
].join(';')
|
|
2127
2135
|
|
|
@@ -2291,40 +2299,33 @@ window.__ModuleLoader__.load({
|
|
|
2291
2299
|
}
|
|
2292
2300
|
|
|
2293
2301
|
// A session-level switch sitting in a tight row. Field is wrong here: its
|
|
2294
|
-
// label reserves a 132px column, so side-by-side Fields push each
|
|
2302
|
+
// label reserves a 132px column, so side-by-side Fields push each control
|
|
2295
2303
|
// away from its own text and it reads as the neighbour's switch. Keep the
|
|
2296
|
-
//
|
|
2304
|
+
// switch and the words in one pill so the pairing cannot be misread.
|
|
2297
2305
|
function CheckRow({ label, checked, disabled, title, onChange }) {
|
|
2298
|
-
return h('
|
|
2306
|
+
return h('span', {
|
|
2299
2307
|
title: title || '',
|
|
2300
2308
|
style: {
|
|
2301
|
-
display: 'inline-flex', alignItems: 'center', gap:
|
|
2302
|
-
padding: '
|
|
2309
|
+
display: 'inline-flex', alignItems: 'center', gap: 7,
|
|
2310
|
+
padding: '3px 10px 3px 6px', borderRadius: 999,
|
|
2303
2311
|
border: `1px solid ${V.borderSoft}`,
|
|
2304
2312
|
fontSize: 12, color: V.textDim, whiteSpace: 'nowrap',
|
|
2305
|
-
cursor: disabled ? 'default' : 'pointer',
|
|
2306
2313
|
opacity: disabled ? 0.55 : 1,
|
|
2307
2314
|
},
|
|
2308
2315
|
},
|
|
2309
|
-
h(
|
|
2310
|
-
type: 'checkbox',
|
|
2311
|
-
checked: checked === true,
|
|
2312
|
-
disabled: disabled === true,
|
|
2313
|
-
style: { margin: 0, flexShrink: 0, accentColor: V.accent, cursor: 'inherit' },
|
|
2314
|
-
onChange: (e) => onChange(e.target.checked),
|
|
2315
|
-
}),
|
|
2316
|
+
h(Toggle, { checked: checked === true, disabled: disabled === true, label, title, onChange }),
|
|
2316
2317
|
h('span', null, label))
|
|
2317
2318
|
}
|
|
2318
2319
|
|
|
2319
2320
|
// Accessible switch used by the folder list. Native checkbox input is avoided
|
|
2320
2321
|
// because the settings pane's dark theme makes an unstyled checkbox vanish.
|
|
2321
|
-
function Toggle({ checked, onChange, disabled, label }) {
|
|
2322
|
+
function Toggle({ checked, onChange, disabled, label, title }) {
|
|
2322
2323
|
return h('button', {
|
|
2323
2324
|
type: 'button',
|
|
2324
2325
|
role: 'switch',
|
|
2325
2326
|
'aria-checked': checked === true,
|
|
2326
2327
|
'aria-label': label,
|
|
2327
|
-
title: label,
|
|
2328
|
+
title: title || label,
|
|
2328
2329
|
className: 'dshm-toggle',
|
|
2329
2330
|
disabled,
|
|
2330
2331
|
onClick: () => onChange(!checked),
|
|
@@ -2340,7 +2341,7 @@ window.__ModuleLoader__.load({
|
|
|
2340
2341
|
style: {
|
|
2341
2342
|
position: 'absolute', top: 2, left: checked ? 20 : 2,
|
|
2342
2343
|
width: 18, height: 18, borderRadius: '50%',
|
|
2343
|
-
background: checked ? '#fff' : V.textDim,
|
|
2344
|
+
background: checked ? 'var(--dsw-alias-brand-text, #fff)' : V.textDim,
|
|
2344
2345
|
transition: 'left .15s ease',
|
|
2345
2346
|
},
|
|
2346
2347
|
}))
|
|
@@ -2504,6 +2505,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2504
2505
|
|
|
2505
2506
|
function ContextScope({ binding, sessionId, call, t }) {
|
|
2506
2507
|
const [notice, setNotice] = React.useState('')
|
|
2508
|
+
React.useEffect(() => {
|
|
2509
|
+
if (!notice) return undefined
|
|
2510
|
+
const timer = setTimeout(() => setNotice(''), 2600)
|
|
2511
|
+
return () => clearTimeout(timer)
|
|
2512
|
+
}, [notice])
|
|
2507
2513
|
if (!binding) return null
|
|
2508
2514
|
return h('details', { className: 'dshm-scope' },
|
|
2509
2515
|
h('summary', null, t('contextScope')),
|
|
@@ -2519,7 +2525,6 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2519
2525
|
notifyMemoryWrite('context', binding.libraryId)
|
|
2520
2526
|
setNotice(t('saved'))
|
|
2521
2527
|
} catch (error) { setNotice(String(error.message || error)) }
|
|
2522
|
-
setTimeout(() => setNotice(''), 2600)
|
|
2523
2528
|
},
|
|
2524
2529
|
},
|
|
2525
2530
|
['channelId', 'characterId', 'worldId', 'branchId'].map(key => h('label', { key, className: 'dshm-scope-field' },
|
|
@@ -2552,7 +2557,15 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2552
2557
|
function VisionConfigPanel({ call, config, t }) {
|
|
2553
2558
|
const [message, setMessage] = React.useState('')
|
|
2554
2559
|
const [busy, setBusy] = React.useState(false)
|
|
2555
|
-
|
|
2560
|
+
React.useEffect(() => {
|
|
2561
|
+
if (!message) return undefined
|
|
2562
|
+
const timer = setTimeout(() => setMessage(''), 2600)
|
|
2563
|
+
return () => clearTimeout(timer)
|
|
2564
|
+
}, [message])
|
|
2565
|
+
// Same Field/row rhythm as every other settings card: labels above inputs,
|
|
2566
|
+
// one action row at the bottom. The previous bare row of three inputs made
|
|
2567
|
+
// this card read like a different product.
|
|
2568
|
+
return h('form', { style: { display: 'flex', flexDirection: 'column', gap: 10 }, onSubmit: async event => {
|
|
2556
2569
|
event.preventDefault()
|
|
2557
2570
|
const data = new FormData(event.currentTarget)
|
|
2558
2571
|
setBusy(true)
|
|
@@ -2561,13 +2574,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2561
2574
|
setMessage(t('saved'))
|
|
2562
2575
|
notifyMemoryWrite('settings')
|
|
2563
2576
|
} catch (error) { setMessage(String(error.message || error)) } finally { setBusy(false) }
|
|
2564
|
-
setTimeout(() => setMessage(''), 2600)
|
|
2565
2577
|
} },
|
|
2566
|
-
h('
|
|
2567
|
-
h(
|
|
2568
|
-
|
|
2569
|
-
h(
|
|
2570
|
-
|
|
2578
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, lineHeight: 1.55 } }, t('visionServiceHint')),
|
|
2579
|
+
h(Field, { label: t('baseUrl') },
|
|
2580
|
+
h('input', { name: 'url', type: 'url', style: S.input, defaultValue: config?.baseUrl || '', placeholder: 'https://host/v1', 'aria-label': t('baseUrl') })),
|
|
2581
|
+
h(Field, { label: t('captionModel') },
|
|
2582
|
+
h('input', { name: 'model', style: S.input, defaultValue: config?.model || '', placeholder: t('captionModel'), 'aria-label': t('captionModel') })),
|
|
2583
|
+
h(Field, { label: t('apiKey') },
|
|
2584
|
+
h('input', { name: 'key', type: 'password', style: S.input, autoComplete: 'new-password', placeholder: config?.hasKey ? '********' : 'API key', 'aria-label': t('apiKey') })),
|
|
2585
|
+
h('div', { style: S.row },
|
|
2586
|
+
h('button', { className: 'dshm-btn', type: 'submit', disabled: busy }, t('save')),
|
|
2587
|
+
message ? h('span', { role: 'status', style: S.muted }, message) : null))
|
|
2571
2588
|
}
|
|
2572
2589
|
|
|
2573
2590
|
let graphModulePromise = null
|
|
@@ -2646,8 +2663,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2646
2663
|
h('label', { key }, t(label), h('input', { type: 'range', min, max, step: 5, value: options[key],
|
|
2647
2664
|
onChange: event => setOptions(value => ({ ...value, [key]: Number(event.target.value) })) }))),
|
|
2648
2665
|
[['labels', 'graphLabels'], ['motion', 'graphMotion']].map(([key, label]) =>
|
|
2649
|
-
h('
|
|
2650
|
-
|
|
2666
|
+
h('div', { key, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10 } },
|
|
2667
|
+
h('span', null, t(label)),
|
|
2668
|
+
h(Toggle, { checked: options[key] === true, label: t(label),
|
|
2669
|
+
onChange: value => setOptions(current => ({ ...current, [key]: value })) })))) : null,
|
|
2651
2670
|
h('canvas', { ref, className: 'dshm-graph-canvas', role: 'img', tabIndex: 0, 'aria-label': t('graphView') }),
|
|
2652
2671
|
h('div', { ref: tooltipRef, className: 'dshm-graph-tooltip', hidden: true, 'aria-hidden': true }),
|
|
2653
2672
|
loadError ? h('div', { className: 'dshm-graph-error', role: 'alert' },
|
|
@@ -2659,6 +2678,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2659
2678
|
const [to, setTo] = React.useState('')
|
|
2660
2679
|
const [snapshot, setSnapshot] = React.useState(null)
|
|
2661
2680
|
const [message, setMessage] = React.useState('')
|
|
2681
|
+
React.useEffect(() => {
|
|
2682
|
+
if (!message) return undefined
|
|
2683
|
+
const timer = setTimeout(() => setMessage(''), 2600)
|
|
2684
|
+
return () => clearTimeout(timer)
|
|
2685
|
+
}, [message])
|
|
2662
2686
|
React.useEffect(() => {
|
|
2663
2687
|
let alive = true
|
|
2664
2688
|
setSnapshot(null)
|
|
@@ -2682,7 +2706,6 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2682
2706
|
const value = await call('updateRelationship', { libraryId, fromId: from, toId: to, state, evidenceIds: [values.get('evidence')], reason: values.get('reason') })
|
|
2683
2707
|
setSnapshot(value.relationship); setMessage(t('saved')); notifyMemoryWrite('relation', libraryId)
|
|
2684
2708
|
} catch (error) { setMessage(String(error.message || error)) }
|
|
2685
|
-
setTimeout(() => setMessage(''), 2600)
|
|
2686
2709
|
} },
|
|
2687
2710
|
h('div', { className: 'dshm-graph-tools' }, ['familiarity', 'trust', 'warmth'].map(key => h('label', { key }, t(key),
|
|
2688
2711
|
h('input', { type: 'number', name: key, min: 0, max: 1, step: .05, defaultValue: snapshot.state?.[key] ?? '' })))),
|
|
@@ -2972,6 +2995,18 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2972
2995
|
const [selectedIds, setSelectedIds] = React.useState(() => new Set())
|
|
2973
2996
|
const [wallBusy, setWallBusy] = React.useState(false)
|
|
2974
2997
|
const [deleteArmedMulti, setDeleteArmedMulti] = React.useState(false)
|
|
2998
|
+
// Library switches can overlap: the host does not order RPC replies, so a
|
|
2999
|
+
// slow answer for the previous library must not repaint the wall after the
|
|
3000
|
+
// reader already picked another one.
|
|
3001
|
+
const browseRequest = React.useRef(0)
|
|
3002
|
+
// 二次确认不能无限期挂着:照 LexiconPanel / SettingsPage 的口径 2.5s 自动复原,
|
|
3003
|
+
// 切池/层级/查询时立即失效,避免回来一次点击就批量删除。
|
|
3004
|
+
React.useEffect(() => {
|
|
3005
|
+
if (!deleteArmedMulti) return undefined
|
|
3006
|
+
const timer = setTimeout(() => setDeleteArmedMulti(false), 2500)
|
|
3007
|
+
return () => clearTimeout(timer)
|
|
3008
|
+
}, [deleteArmedMulti])
|
|
3009
|
+
React.useEffect(() => { setDeleteArmedMulti(false) }, [pool, layer, query])
|
|
2975
3010
|
// Opens in place instead of jumping to the browser: one card, one request, and
|
|
2976
3011
|
// the wall stays where the reader left it. `null` means the drawer is closed.
|
|
2977
3012
|
const [detail, setDetail] = React.useState(null)
|
|
@@ -2988,14 +3023,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2988
3023
|
const firstLibraryId = libraries?.[0]?.id || ''
|
|
2989
3024
|
React.useEffect(() => {
|
|
2990
3025
|
let alive = true
|
|
3026
|
+
const requestId = ++browseRequest.current
|
|
3027
|
+
const current = () => alive && requestId === browseRequest.current
|
|
2991
3028
|
const load = async () => {
|
|
2992
3029
|
try {
|
|
2993
3030
|
const value = await call('browseWall', { libraryId: libraryId || null, limit: 300 })
|
|
2994
|
-
if (!
|
|
3031
|
+
if (!current()) return
|
|
2995
3032
|
setData(value)
|
|
2996
3033
|
setError('')
|
|
2997
3034
|
} catch (failure) {
|
|
2998
|
-
if (!
|
|
3035
|
+
if (!current()) return
|
|
2999
3036
|
const message = String(failure?.message || failure)
|
|
3000
3037
|
// 宿主对“全部记忆库”多库读取返回 403(browseWall 无法表达为单库授权)时,
|
|
3001
3038
|
// 退到第一个库并明确告知;单库 + 全局(browseWall 总会带全局)仍能出数据,
|
|
@@ -3003,14 +3040,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3003
3040
|
if (!libraryId && firstLibraryId && /forbidden|403/i.test(message)) {
|
|
3004
3041
|
try {
|
|
3005
3042
|
const value = await call('browseWall', { libraryId: firstLibraryId, limit: 300 })
|
|
3006
|
-
|
|
3043
|
+
// A newer selection owns the wall now; do not force the reader
|
|
3044
|
+
// back to the first library from a fallback they did not ask for.
|
|
3045
|
+
if (!current()) return
|
|
3007
3046
|
setData(value)
|
|
3008
3047
|
setError('')
|
|
3009
3048
|
setMultiBlocked(true)
|
|
3010
3049
|
setLibraryId(firstLibraryId)
|
|
3011
3050
|
return
|
|
3012
3051
|
} catch (fallbackFailure) {
|
|
3013
|
-
if (
|
|
3052
|
+
if (current()) setError(String(fallbackFailure?.message || fallbackFailure))
|
|
3014
3053
|
return
|
|
3015
3054
|
}
|
|
3016
3055
|
}
|
|
@@ -3045,7 +3084,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3045
3084
|
const inScope = item => scope === 'global' ? item.libraryId === null : item.libraryId !== null
|
|
3046
3085
|
const scoped = items.filter(inScope)
|
|
3047
3086
|
const rows = scoped.filter(item => poolOf(item) === pool)
|
|
3048
|
-
const keyOf = item => (item.libraryId || 'global') + item.id
|
|
3087
|
+
const keyOf = item => (item.libraryId || 'global') + ':' + item.id
|
|
3049
3088
|
const selectedRows = visible => visible.filter(item => selectedIds.has(keyOf(item)))
|
|
3050
3089
|
const layerMatch = (item, value) => value === 'all' || (value === 'anchor' ? item.layer === 'must_remember' && poolOf(item) === 'active' : item.layer === value)
|
|
3051
3090
|
const text = String(query || '').toLowerCase()
|
|
@@ -3130,7 +3169,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3130
3169
|
if (!current?.file || current.readonly || current.file.status !== 'archived') return
|
|
3131
3170
|
setDetail({ ...current, busy: true, error: '' })
|
|
3132
3171
|
try {
|
|
3133
|
-
await call('deleteMemory', { libraryId: current.item.libraryId, id: current.item.id })
|
|
3172
|
+
await call('deleteMemory', { libraryId: current.item.libraryId, id: current.item.id, confirmed: true })
|
|
3134
3173
|
setDetail(null)
|
|
3135
3174
|
setDeleteArmed(false)
|
|
3136
3175
|
notifyMemoryWrite('memory', current.item.libraryId)
|
|
@@ -3155,7 +3194,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3155
3194
|
const failures = []
|
|
3156
3195
|
for (const item of targets) {
|
|
3157
3196
|
try {
|
|
3158
|
-
if (action === 'delete') await call('deleteMemory', { libraryId: item.libraryId, id: item.id })
|
|
3197
|
+
if (action === 'delete') await call('deleteMemory', { libraryId: item.libraryId, id: item.id, confirmed: true })
|
|
3159
3198
|
else await call('updateMemory', { libraryId: item.libraryId, id: item.id, patch: { status: action === 'archive' ? 'archived' : 'active' } })
|
|
3160
3199
|
done += 1
|
|
3161
3200
|
} catch (failure) { failures.push(`${item.title || item.id}: ${String(failure?.message || failure)}`) }
|
|
@@ -3210,12 +3249,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3210
3249
|
value: detail.draft.confidence,
|
|
3211
3250
|
onChange: (event) => patchDraft({ confidence: event.target.value }),
|
|
3212
3251
|
})),
|
|
3213
|
-
h('
|
|
3214
|
-
h(
|
|
3215
|
-
|
|
3216
|
-
|
|
3252
|
+
h('div', { className: 'dshm-drawer-switch' },
|
|
3253
|
+
h(Toggle, {
|
|
3254
|
+
checked: detail.draft.openLoop === true,
|
|
3255
|
+
label: t('openLoopTag'),
|
|
3256
|
+
onChange: (value) => patchDraft({ openLoop: value }),
|
|
3217
3257
|
}),
|
|
3218
|
-
t('openLoopTag'))),
|
|
3258
|
+
h('span', null, t('openLoopTag')))),
|
|
3219
3259
|
h('div', { className: 'dshm-drawer-note' },
|
|
3220
3260
|
t('decay') + ' ' + Math.round((Number(shown.decay) || 0) * 100) + '% · ' +
|
|
3221
3261
|
(shown.updatedAt ? String(shown.updatedAt).slice(0, 16).replace('T', ' ') : '')),
|
|
@@ -3533,19 +3573,27 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3533
3573
|
const activeLib = libraryId || libraries[0]?.id || GLOBAL_LEXICON_ID
|
|
3534
3574
|
const isGlobalLib = activeLib === GLOBAL_LEXICON_ID
|
|
3535
3575
|
const emptyView = { items: [], total: 0, page: 1, pages: 1, counts: {}, statusCounts: { active: 0, archived: 0 } }
|
|
3576
|
+
const loadSeq = React.useRef(0)
|
|
3536
3577
|
const load = React.useCallback(async () => {
|
|
3537
3578
|
if (!activeLib) { setData(emptyView); return }
|
|
3579
|
+
const seq = ++loadSeq.current
|
|
3538
3580
|
setBusy(true)
|
|
3539
3581
|
try {
|
|
3540
3582
|
// 只取当前页、当前页签:状态页签、kind、搜索、分页全在 RPC 侧收窄,
|
|
3541
|
-
//
|
|
3583
|
+
// 客户端不缓存任何全量词条列表。翻页/新建后并发的旧请求用代次抑制。
|
|
3542
3584
|
const res = await call('lexiconList', {
|
|
3543
3585
|
libraryId: activeLib, sessionId: sessionId || undefined, page, pageSize: 50,
|
|
3544
3586
|
status, kind: kind || undefined, q: query || undefined,
|
|
3545
3587
|
})
|
|
3588
|
+
if (seq !== loadSeq.current) return
|
|
3546
3589
|
setData(res || emptyView)
|
|
3547
3590
|
setError('')
|
|
3548
|
-
} catch (e) {
|
|
3591
|
+
} catch (e) {
|
|
3592
|
+
if (seq !== loadSeq.current) return
|
|
3593
|
+
setError(String(e?.message || e))
|
|
3594
|
+
} finally {
|
|
3595
|
+
if (seq === loadSeq.current) setBusy(false)
|
|
3596
|
+
}
|
|
3549
3597
|
}, [call, activeLib, page, status, kind, query, sessionId])
|
|
3550
3598
|
React.useEffect(() => { void load() }, [load])
|
|
3551
3599
|
React.useEffect(() => {
|
|
@@ -3963,6 +4011,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3963
4011
|
? SETTINGS_PAGES.indexOf(String(window.location.hash || '').replace(/^#\/settings\//, '')) : PAGE.memories)
|
|
3964
4012
|
: 0)
|
|
3965
4013
|
const pendingSettings = React.useRef({})
|
|
4014
|
+
// 保存失败的 patch 单独存放:绝不放回 pending(否则 adoptState 每次心跳把
|
|
4015
|
+
// 失败值盖到服务端返回值上,永远回滚不了),并驱动一个不自动消失的标记。
|
|
4016
|
+
const [failedPatch, setFailedPatch] = React.useState(null)
|
|
3966
4017
|
// Hook order is a contract: every hook below must run on every render,
|
|
3967
4018
|
// including the loading branch (`if (!state) return ...` further down).
|
|
3968
4019
|
// Putting these next to the other state declarations is what keeps the
|
|
@@ -4008,6 +4059,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4008
4059
|
const [browseLibId, setBrowseLibId] = React.useState(() => standalone ? new URLSearchParams(window.location.search).get('libraryId') || '' : '')
|
|
4009
4060
|
const [browseFiles, setBrowseFiles] = React.useState([])
|
|
4010
4061
|
const [browseSource, setBrowseSource] = React.useState('')
|
|
4062
|
+
// Same stale-reply guard as the wall: the browser page can be pointed at a
|
|
4063
|
+
// different library while its previous request is still in flight.
|
|
4064
|
+
const browseLibraryRequest = React.useRef(0)
|
|
4065
|
+
const reviewsRequest = React.useRef(0)
|
|
4066
|
+
const statsRequest = React.useRef(0)
|
|
4011
4067
|
const [browseDraft, setBrowseDraft] = React.useState({})
|
|
4012
4068
|
const [browseBusy, setBrowseBusy] = React.useState(false)
|
|
4013
4069
|
// 'active' | 'archived'. Archiving used to be a one-way door in the UI: the entry
|
|
@@ -4052,6 +4108,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4052
4108
|
const [forkKeyDraft, setForkKeyDraft] = React.useState('')
|
|
4053
4109
|
const [forkDiscoverBusy, setForkDiscoverBusy] = React.useState(false)
|
|
4054
4110
|
const [forkDiscoverNote, setForkDiscoverNote] = React.useState('')
|
|
4111
|
+
React.useEffect(() => {
|
|
4112
|
+
if (!forkDiscoverNote) return undefined
|
|
4113
|
+
const timer = setTimeout(() => setForkDiscoverNote(''), 2600)
|
|
4114
|
+
return () => clearTimeout(timer)
|
|
4115
|
+
}, [forkDiscoverNote])
|
|
4055
4116
|
const [forkDiscoverModels, setForkDiscoverModels] = React.useState(null)
|
|
4056
4117
|
const forkCatalogLoadingRef = React.useRef(false)
|
|
4057
4118
|
|
|
@@ -4098,12 +4159,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4098
4159
|
return
|
|
4099
4160
|
} catch (failure) { error = failure }
|
|
4100
4161
|
}
|
|
4101
|
-
|
|
4162
|
+
setFailedPatch(prev => ({ ...(prev || {}), ...patch }))
|
|
4102
4163
|
console.warn('dsh-memu-memory: settings save failed after retry')
|
|
4103
4164
|
setError(String(error?.message || error))
|
|
4165
|
+
void refresh()
|
|
4104
4166
|
})
|
|
4105
4167
|
return saveChain.current
|
|
4106
|
-
}, [call])
|
|
4168
|
+
}, [call, refresh])
|
|
4107
4169
|
React.useEffect(() => {
|
|
4108
4170
|
const flush = () => { void flushSettings() }
|
|
4109
4171
|
window.addEventListener?.('pagehide', flush)
|
|
@@ -4211,6 +4273,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4211
4273
|
// are shown in one list because "something needs a human decision" is one job,
|
|
4212
4274
|
// and each row says which library it came from.
|
|
4213
4275
|
const loadReviews = React.useCallback(async () => {
|
|
4276
|
+
const requestId = ++reviewsRequest.current
|
|
4214
4277
|
try {
|
|
4215
4278
|
const [globalQueue, privateQueue] = await Promise.all([
|
|
4216
4279
|
call('listReviews', sessionId ? { sessionId } : {}),
|
|
@@ -4218,8 +4281,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4218
4281
|
? call('listReviews', { libraryId: browseLibId, sessionId: sessionId || undefined }).catch(() => ({ items: [] }))
|
|
4219
4282
|
: Promise.resolve({ items: [] }),
|
|
4220
4283
|
])
|
|
4284
|
+
if (requestId !== reviewsRequest.current) return
|
|
4221
4285
|
setReviews([...(privateQueue?.items || []), ...(globalQueue?.items || [])])
|
|
4222
|
-
} catch (e) { setError(String(e?.message || e)) }
|
|
4286
|
+
} catch (e) { if (requestId === reviewsRequest.current) setError(String(e?.message || e)) }
|
|
4223
4287
|
}, [call, browseLibId])
|
|
4224
4288
|
|
|
4225
4289
|
const loadFolders = React.useCallback(async () => {
|
|
@@ -4231,14 +4295,18 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4231
4295
|
}, [call])
|
|
4232
4296
|
|
|
4233
4297
|
const loadStatsFor = React.useCallback(async (libraryId) => {
|
|
4298
|
+
const requestId = ++statsRequest.current
|
|
4234
4299
|
if (!libraryId) { setStatsData(null); return }
|
|
4235
4300
|
setStatsBusy(true)
|
|
4236
4301
|
try {
|
|
4237
|
-
|
|
4302
|
+
const next = await call('getStats', { libraryId, days: 30 })
|
|
4303
|
+
if (requestId === statsRequest.current) setStatsData(next)
|
|
4238
4304
|
} catch (e) {
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4305
|
+
if (requestId === statsRequest.current) {
|
|
4306
|
+
setError(String(e?.message || e))
|
|
4307
|
+
setStatsData(null)
|
|
4308
|
+
}
|
|
4309
|
+
} finally { if (requestId === statsRequest.current) setStatsBusy(false) }
|
|
4242
4310
|
}, [call])
|
|
4243
4311
|
|
|
4244
4312
|
const loadFolderSessions = React.useCallback(async (scopeKey) => {
|
|
@@ -4329,11 +4397,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4329
4397
|
React.useEffect(() => {
|
|
4330
4398
|
if (page !== PAGE.browser || !browseLibId) return undefined
|
|
4331
4399
|
let alive = true
|
|
4400
|
+
const requestId = ++browseLibraryRequest.current
|
|
4401
|
+
const current = () => alive && requestId === browseLibraryRequest.current
|
|
4332
4402
|
void call('browseLibrary', { libraryId: browseLibId, sessionId: sessionId || undefined }).then(result => {
|
|
4333
|
-
if (!
|
|
4403
|
+
if (!current()) return
|
|
4334
4404
|
setBrowseFiles(result.files || [])
|
|
4335
4405
|
setBrowseSource(result.source || '')
|
|
4336
|
-
}).catch(error => { if (
|
|
4406
|
+
}).catch(error => { if (current()) setError(String(error.message || error)) })
|
|
4337
4407
|
return () => { alive = false }
|
|
4338
4408
|
}, [call, page, browseLibId, sessionId, state?.revision, state?.stamp])
|
|
4339
4409
|
// Statistics are per library and read the whole index for the scatter, so they
|
|
@@ -4542,16 +4612,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4542
4612
|
} finally {
|
|
4543
4613
|
setForkDiscoverBusy(false)
|
|
4544
4614
|
}
|
|
4545
|
-
setTimeout(() => setForkDiscoverNote(''), 2600)
|
|
4546
4615
|
}
|
|
4547
|
-
|
|
4616
|
+
// 只经 setSetting 一条写入口:它已排定 250ms flushSettings(内含 setSettings
|
|
4617
|
+
// 与 broadcastMemoryWrite),再直接 call 会造成双写双广播。
|
|
4618
|
+
const setBackend = (backend) => {
|
|
4548
4619
|
setSetting('memoryBackend', backend)
|
|
4549
4620
|
setConfigNotice('')
|
|
4550
|
-
try {
|
|
4551
|
-
await call('setSettings', { patch: { memoryBackend: backend } })
|
|
4552
|
-
broadcastMemoryWrite('settings')
|
|
4553
|
-
await refresh()
|
|
4554
|
-
} catch (e) { setError(String(e?.message || e)) }
|
|
4555
4621
|
}
|
|
4556
4622
|
const createLibrary = async () => {
|
|
4557
4623
|
const name = newLibName.trim()
|
|
@@ -4601,13 +4667,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4601
4667
|
if (!id) return
|
|
4602
4668
|
if (!libraryId) setBrowseLibId(id)
|
|
4603
4669
|
setBrowseBusy(true)
|
|
4670
|
+
// Counts as the newest browse request, so the page effect (which bumps the
|
|
4671
|
+
// same counter when browseLibId changes) cannot be overwritten by this one.
|
|
4672
|
+
const requestId = ++browseLibraryRequest.current
|
|
4604
4673
|
try {
|
|
4605
4674
|
const res = await call('browseLibrary', { libraryId: id })
|
|
4675
|
+
if (requestId !== browseLibraryRequest.current) return
|
|
4606
4676
|
setBrowseFiles(res?.files || [])
|
|
4607
4677
|
setBrowseSource(res?.source || 'engine')
|
|
4608
4678
|
setBrowseDraft({})
|
|
4609
4679
|
setDeleteArmed('')
|
|
4610
|
-
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
4680
|
+
} catch (e) { if (requestId === browseLibraryRequest.current) setError(String(e?.message || e)) } finally { if (requestId === browseLibraryRequest.current) setBrowseBusy(false) }
|
|
4611
4681
|
}
|
|
4612
4682
|
const openBrowserFromLibrary = (libraryId) => {
|
|
4613
4683
|
setPage(PAGE.browser)
|
|
@@ -4670,7 +4740,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4670
4740
|
setBrowseBusy(true)
|
|
4671
4741
|
setError('')
|
|
4672
4742
|
try {
|
|
4673
|
-
await call('deleteMemory', { libraryId: browseLibId, id })
|
|
4743
|
+
await call('deleteMemory', { libraryId: browseLibId, id, confirmed: true })
|
|
4674
4744
|
notifyMemoryWrite('memory', browseLibId)
|
|
4675
4745
|
setNotice(t('memoryDeleted'))
|
|
4676
4746
|
setDeleteArmed('')
|
|
@@ -5552,8 +5622,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5552
5622
|
// 一致性由 tests/ui-defaults.test.mjs 守着。
|
|
5553
5623
|
h(Field, { label: t('privateTopK') }, h('input', { type: 'number', style: S.input, value: settings.privateTopK ?? 5, onChange: (e) => setSetting('privateTopK', Number(e.target.value)) })),
|
|
5554
5624
|
h(Field, { label: t('globalTopK') }, h('input', { type: 'number', style: S.input, value: settings.globalTopK ?? 5, onChange: (e) => setSetting('globalTopK', Number(e.target.value)) })),
|
|
5555
|
-
|
|
5556
|
-
|
|
5625
|
+
// Keep the explanation beside the switch, not on its own grid row: the
|
|
5626
|
+
// short text stays visible and the full four-line detail lives in the
|
|
5627
|
+
// tooltip, so the numeric fields start immediately after this row.
|
|
5628
|
+
h(Field, { label: t('crossLibraryRecall') },
|
|
5629
|
+
h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 8, minWidth: 0, flexWrap: 'wrap' } },
|
|
5630
|
+
h(Toggle, { checked: settings.crossLibraryRecall === true, label: t('crossLibraryRecall'), onChange: value => setSetting('crossLibraryRecall', value) }),
|
|
5631
|
+
h('span', {
|
|
5632
|
+
title: t('crossLibraryRecallHint'),
|
|
5633
|
+
style: { ...S.muted, fontSize: 11, lineHeight: 1.35, whiteSpace: 'nowrap' },
|
|
5634
|
+
}, t('crossLibraryRecallShort')))),
|
|
5557
5635
|
h(Field, { label: t('anchorTokens') }, h('input', { type: 'number', style: S.input, value: settings.anchorTokens ?? 800, onChange: (e) => setSetting('anchorTokens', Number(e.target.value)) })),
|
|
5558
5636
|
h(Field, { label: t('turnTokens') }, h('input', { type: 'number', style: S.input, value: settings.turnTokens ?? 800, onChange: (e) => setSetting('turnTokens', Number(e.target.value)) })),
|
|
5559
5637
|
h(Field, { label: t('injectionTotalTokens') }, h('input', { type: 'number', style: S.input, value: settings.injectionTotalTokens ?? 2000, onChange: (e) => setSetting('injectionTotalTokens', Number(e.target.value)) })),
|
|
@@ -5565,14 +5643,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5565
5643
|
h(Field, { label: t('freshnessHint') }, h(Toggle, { checked: settings.freshnessHint !== false, label: t('freshnessHint'), onChange: value => setSetting('freshnessHint', value) })),
|
|
5566
5644
|
h(Field, { label: t('freshnessDays') }, h('input', { type: 'number', min: 1, max: 3650, style: S.input, value: settings.freshnessDays ?? 30, onChange: (e) => setSetting('freshnessDays', Number(e.target.value)) })),
|
|
5567
5645
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('freshnessHintHint')),
|
|
5568
|
-
h(Field, { label: t('habitsInjection') }, h(
|
|
5646
|
+
h(Field, { label: t('habitsInjection') }, h(Toggle, { checked: settings.habitsInjection !== false, label: t('habitsInjection'), onChange: value => setSetting('habitsInjection', value) }))),
|
|
5569
5647
|
settingsGroup(t('settingsGroupLifecycle'), t('settingsGroupLifecycleDesc'),
|
|
5570
5648
|
h(Field, { label: t('mustRememberCap') }, h('input', { type: 'number', style: S.input, value: settings.mustRememberCap ?? 12, onChange: (e) => setSetting('mustRememberCap', Number(e.target.value)) })),
|
|
5571
5649
|
h(Field, { label: t('shortTermTtlHours') }, h('input', { type: 'number', min: 0, style: S.input, value: settings.shortTermTtlHours ?? 72, onChange: (e) => setSetting('shortTermTtlHours', Number(e.target.value)) })),
|
|
5572
5650
|
h(Field, { label: t('openLoopRemindDays') }, h('input', { type: 'number', min: 1, max: 365, style: S.input, value: settings.openLoopRemindDays ?? 7, onChange: (e) => setSetting('openLoopRemindDays', Number(e.target.value)) })),
|
|
5573
5651
|
h(Field, { label: t('purgeArchivedAfterDays') }, h('input', { type: 'number', min: 0, style: S.input, value: settings.purgeArchivedAfterDays ?? 0, onChange: (e) => setSetting('purgeArchivedAfterDays', Number(e.target.value)) }))),
|
|
5574
5652
|
settingsGroup(t('settingsGroupCuration'), t('settingsGroupCurationDesc'),
|
|
5575
|
-
h(Field, { label: t('sleepConsolidation') }, h(
|
|
5653
|
+
h(Field, { label: t('sleepConsolidation') }, h(Toggle, { checked: settings.sleepConsolidation === true, label: t('sleepConsolidation'), onChange: value => setSetting('sleepConsolidation', value) })),
|
|
5576
5654
|
h(Field, { label: t('sleepAfterIdleMinutes') }, h('input', { type: 'number', min: 1, style: S.input, value: settings.sleepAfterIdleMinutes ?? 2, onChange: (e) => setSetting('sleepAfterIdleMinutes', Number(e.target.value)) })),
|
|
5577
5655
|
h(Field, { label: t('autoCurateEveryHours') }, h('input', { type: 'number', min: 0, style: S.input, value: settings.autoCurateEveryHours ?? 0, onChange: (e) => setSetting('autoCurateEveryHours', Number(e.target.value)) })),
|
|
5578
5656
|
h(Field, { label: t('autoCurateSessionLimit') }, h('input', { type: 'number', min: 1, max: 30, style: S.input, value: settings.autoCurateSessionLimit ?? 8, onChange: (e) => setSetting('autoCurateSessionLimit', Number(e.target.value)) })),
|
|
@@ -5596,9 +5674,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5596
5674
|
h('select', { style: S.input, value: settings.memoryMode || 'local', onChange: (e) => setSetting('memoryMode', e.target.value) },
|
|
5597
5675
|
['local', 'cloud'].map((v) => h('option', { key: v, value: v }, v)))),
|
|
5598
5676
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('memoryModeHint')),
|
|
5599
|
-
h(Field, { label: t('autoInstall') }, h(
|
|
5677
|
+
h(Field, { label: t('autoInstall') }, h(Toggle, { checked: settings.autoInstallEngine !== false, label: t('autoInstall'), onChange: value => setSetting('autoInstallEngine', value) }))),
|
|
5600
5678
|
settingsGroup(t('settingsGroupSession'), t('settingsGroupSessionDesc'),
|
|
5601
|
-
h(Field, { label: t('newSessionPrompt') }, h(
|
|
5679
|
+
h(Field, { label: t('newSessionPrompt') }, h(Toggle, { checked: settings.newSessionPromptDismissed !== true, label: t('newSessionPrompt'), onChange: value => setSetting('newSessionPromptDismissed', !value) })),
|
|
5602
5680
|
h(Field, { label: t('sidebarSettings') }, h(Toggle, { checked: settings.sidebarSettings === true, label: t('sidebarSettings'), onChange: value => setSetting('sidebarSettings', value) })),
|
|
5603
5681
|
h(Field, { label: t('visionCaptionEnabled') }, h(Toggle, { checked: settings.visionCaptionEnabled === true, label: t('visionCaptionEnabled'), onChange: value => setSetting('visionCaptionEnabled', value) }))),
|
|
5604
5682
|
settingsGroup(t('settingsGroupIntegration'), t('settingsGroupIntegrationDesc'),
|
|
@@ -6473,7 +6551,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6473
6551
|
style: S.ghost,
|
|
6474
6552
|
onClick: async () => {
|
|
6475
6553
|
try {
|
|
6476
|
-
await call('clearActivityLog')
|
|
6554
|
+
await call('clearActivityLog', { confirmed: true })
|
|
6477
6555
|
// 跨面板即时生效:侧边栏的整理提醒不用等下一个 20s 轮询。
|
|
6478
6556
|
broadcastMemoryWrite('logs-cleared')
|
|
6479
6557
|
await loadLogs()
|
|
@@ -6565,7 +6643,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6565
6643
|
'aria-hidden': true,
|
|
6566
6644
|
}),
|
|
6567
6645
|
pageDefs.map((p, i) => h('button', {
|
|
6568
|
-
key: p.
|
|
6646
|
+
key: p.overline,
|
|
6569
6647
|
type: 'button',
|
|
6570
6648
|
role: 'tab',
|
|
6571
6649
|
'aria-selected': page === i,
|
|
@@ -6591,6 +6669,15 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6591
6669
|
}, t('openMemu')))),
|
|
6592
6670
|
notice ? h('div', { style: { padding: '8px 12px 0', fontSize: 12, color: V.accent } }, notice) : null,
|
|
6593
6671
|
error ? h('div', { className: 'dshm-error' }, error) : null,
|
|
6672
|
+
failedPatch ? h('div', { className: 'dshm-error', style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
|
|
6673
|
+
h('span', null, t('settingsUnsaved')),
|
|
6674
|
+
h(Button, { style: S.ghost, onClick: () => {
|
|
6675
|
+
if (!failedPatch) return
|
|
6676
|
+
pendingSettings.current = { ...failedPatch, ...pendingSettings.current }
|
|
6677
|
+
setFailedPatch(null)
|
|
6678
|
+
void flushSettings()
|
|
6679
|
+
} }, t('settingsRetry')),
|
|
6680
|
+
h(Button, { style: S.ghost, onClick: () => setFailedPatch(null) }, t('settingsDiscard'))) : null,
|
|
6594
6681
|
pageBlocks[page] || null)))
|
|
6595
6682
|
}
|
|
6596
6683
|
|
|
@@ -6673,6 +6760,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6673
6760
|
const [busy, setBusy] = React.useState(false)
|
|
6674
6761
|
const [notice, setNotice] = React.useState('')
|
|
6675
6762
|
const [tabPage, setTabPage] = React.useState(0)
|
|
6763
|
+
const hasConfigPage = !!state?.sidebarSettings
|
|
6764
|
+
// pages 从 4 变 3 时把 tabPage 钳回有效范围,避免停留空内容且无高亮。
|
|
6765
|
+
React.useEffect(() => { setTabPage(p => Math.min(p, hasConfigPage ? 3 : 2)) }, [hasConfigPage])
|
|
6676
6766
|
// Distinguishes "not fetched yet" from "fetched, genuinely empty": showing
|
|
6677
6767
|
// an empty state while the first request is in flight is what made a
|
|
6678
6768
|
// full library look like it had nothing for a few seconds.
|
|
@@ -6684,9 +6774,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6684
6774
|
// Which snapshot the painted data belongs to, so the shared beat can tell
|
|
6685
6775
|
// "nothing changed" from "refetch".
|
|
6686
6776
|
const markerRef = React.useRef(null)
|
|
6777
|
+
// 宿主 call 不保序、会话切换不卸载面板:用单调代次只让最后一次 refresh 落地,
|
|
6778
|
+
// finally 也不再把旧 sessionId 写回 loadedFor。
|
|
6779
|
+
const refreshRequest = React.useRef(0)
|
|
6687
6780
|
|
|
6688
6781
|
const refresh = React.useCallback(async () => {
|
|
6689
6782
|
if (!sessionId) return
|
|
6783
|
+
const requestId = ++refreshRequest.current
|
|
6690
6784
|
// One round trip for the whole first screen (T4). Previews are capped
|
|
6691
6785
|
// server-side, so opening a 500-entry library no longer ships every body.
|
|
6692
6786
|
try {
|
|
@@ -6699,6 +6793,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6699
6793
|
const privateList = await call('listPrivate', { sessionId, limit: 120, previewChars: 160 }).catch(() => null)
|
|
6700
6794
|
if (privateList?.files) files = privateList.files
|
|
6701
6795
|
}
|
|
6796
|
+
if (requestId !== refreshRequest.current) return
|
|
6702
6797
|
setState({
|
|
6703
6798
|
...st,
|
|
6704
6799
|
pinnedCount: st.private?.pinned ?? 0,
|
|
@@ -6710,10 +6805,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6710
6805
|
markerRef.current = sidebarMarker(st)
|
|
6711
6806
|
setError('')
|
|
6712
6807
|
} catch (e) {
|
|
6808
|
+
if (requestId !== refreshRequest.current) return
|
|
6713
6809
|
setError(String(e?.message || e))
|
|
6714
6810
|
return false
|
|
6715
6811
|
} finally {
|
|
6716
|
-
setLoadedFor(sessionId)
|
|
6812
|
+
if (requestId === refreshRequest.current) setLoadedFor(sessionId)
|
|
6717
6813
|
}
|
|
6718
6814
|
}, [call, sessionId])
|
|
6719
6815
|
|
|
@@ -6789,8 +6885,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6789
6885
|
return () => clearInterval(timer)
|
|
6790
6886
|
}, [busy, sessionId, loadRunLog])
|
|
6791
6887
|
|
|
6792
|
-
//
|
|
6793
|
-
//
|
|
6888
|
+
// 整理提醒(跨会话):挂载即拉一次,之后单一慢轮询;busy 时提高频率但
|
|
6889
|
+
// 绝不叠加第二个定时器(约定 §7.4)。不依赖 sessionId —— 没选中对话也要显示。
|
|
6794
6890
|
const [feed, setFeed] = React.useState(null)
|
|
6795
6891
|
const loadFeed = React.useCallback(async () => {
|
|
6796
6892
|
try { setFeed(await call('getConsolidationFeed', { limit: 6 })) } catch {}
|
|
@@ -6798,13 +6894,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6798
6894
|
React.useEffect(() => {
|
|
6799
6895
|
void loadFeed()
|
|
6800
6896
|
// unref:浏览器里没有这个方法(可选调用跳过),Node 测试环境里别让轮询拖住进程退出。
|
|
6801
|
-
const timer = setInterval(() => { void loadFeed() }, 20000)
|
|
6802
|
-
try { timer.unref?.() } catch {}
|
|
6803
|
-
return () => clearInterval(timer)
|
|
6804
|
-
}, [loadFeed])
|
|
6805
|
-
React.useEffect(() => {
|
|
6806
|
-
if (!busy) return undefined
|
|
6807
|
-
const timer = setInterval(() => { void loadFeed() }, 4000)
|
|
6897
|
+
const timer = setInterval(() => { void loadFeed() }, busy ? 4000 : 20000)
|
|
6808
6898
|
try { timer.unref?.() } catch {}
|
|
6809
6899
|
return () => clearInterval(timer)
|
|
6810
6900
|
}, [busy, loadFeed])
|
|
@@ -6926,22 +7016,22 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6926
7016
|
h(Tag, null, domainText(t, state?.domain || 'general')),
|
|
6927
7017
|
h(Tag, null, `pinned ${state?.pinnedCount ?? 0}`)),
|
|
6928
7018
|
h(Field, { label: t('usePrivate') },
|
|
6929
|
-
h(
|
|
6930
|
-
type: 'checkbox',
|
|
7019
|
+
h(Toggle, {
|
|
6931
7020
|
checked: effective ? effective.useLibrary : binding.useLibrary !== false,
|
|
6932
7021
|
// The folder is the ceiling: a blocked switch is shown disabled with
|
|
6933
7022
|
// the reason, not silently switched off.
|
|
6934
7023
|
disabled: busy || (folderPolicy && folderPolicy.useLibrary === false),
|
|
6935
|
-
|
|
6936
|
-
|
|
7024
|
+
label: t('usePrivate'),
|
|
7025
|
+
title: folderPolicy && folderPolicy.useLibrary === false ? t('folderSwitchOff') : t('usePrivate'),
|
|
7026
|
+
onChange: (value) => setScope('useLibrary', value),
|
|
6937
7027
|
})),
|
|
6938
7028
|
h(Field, { label: t('useGlobal') },
|
|
6939
|
-
h(
|
|
6940
|
-
type: 'checkbox',
|
|
7029
|
+
h(Toggle, {
|
|
6941
7030
|
checked: effective ? effective.useGlobal : binding.useGlobal !== false,
|
|
6942
7031
|
disabled: busy || (folderPolicy && folderPolicy.useGlobal === false),
|
|
6943
|
-
|
|
6944
|
-
|
|
7032
|
+
label: t('useGlobal'),
|
|
7033
|
+
title: folderPolicy && folderPolicy.useGlobal === false ? t('folderSwitchOff') : t('useGlobal'),
|
|
7034
|
+
onChange: (value) => setScope('useGlobal', value),
|
|
6945
7035
|
})),
|
|
6946
7036
|
h(Field, { label: t('domain') }, h('select', { style: S.input, value: state?.domain || 'general', onChange: (e) => setDomain(e.target.value) },
|
|
6947
7037
|
['general', ...(state?.domains || [])].filter((d, i, list) => list.indexOf(d) === i)
|
|
@@ -7047,8 +7137,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7047
7137
|
{ key: 'global', label: t('pageGlobal'), node: globalBlock },
|
|
7048
7138
|
// The whole settings surface, embedded: the same component, so there is no
|
|
7049
7139
|
// second set of rules to drift.
|
|
7050
|
-
...(
|
|
7140
|
+
...(hasConfigPage ? [{ key: 'config', label: t('pageConfig'), node: h(SettingsPage, { ctx, t, embedded: true }) }] : []),
|
|
7051
7141
|
]
|
|
7142
|
+
const tabIndex = Math.min(tabPage, pages.length - 1)
|
|
7052
7143
|
|
|
7053
7144
|
return h('div', { style: S.tab },
|
|
7054
7145
|
h('div', { style: S.topBar },
|
|
@@ -7071,16 +7162,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7071
7162
|
h(Button, { onClick: refresh, style: S.ghost }, t('refresh')))),
|
|
7072
7163
|
h('div', { className: 'dshm-nav-list is-row', role: 'tablist' },
|
|
7073
7164
|
pages.map((p, i) => h('button', {
|
|
7074
|
-
key: p.
|
|
7165
|
+
key: p.key,
|
|
7075
7166
|
type: 'button',
|
|
7076
7167
|
role: 'tab',
|
|
7077
|
-
'aria-selected':
|
|
7078
|
-
className: `dshm-nav-item${
|
|
7168
|
+
'aria-selected': tabIndex === i,
|
|
7169
|
+
className: `dshm-nav-item${tabIndex === i ? ' on' : ''}`,
|
|
7079
7170
|
onClick: () => setTabPage(i),
|
|
7080
7171
|
}, p.label)))),
|
|
7081
7172
|
error ? h('div', { style: { ...S.muted, padding: '8px 12px 0', color: V.danger } }, error) : null,
|
|
7082
7173
|
notice ? h('div', { style: { ...S.muted, padding: '8px 12px 0' } }, notice) : null,
|
|
7083
|
-
h('div', { className: 'dshm-tab-body', style: S.tabBody }, pages[
|
|
7174
|
+
h('div', { className: 'dshm-tab-body', style: S.tabBody }, pages[tabIndex]?.node || null))
|
|
7084
7175
|
}
|
|
7085
7176
|
|
|
7086
7177
|
// One card = one pair of switches. The card the user clicks, the binding
|
|
@@ -7354,7 +7445,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7354
7445
|
}, libraries.map((l) => h('option', { key: l.id, value: l.id }, libraryOptionLabel(l, libraries)))) : null,
|
|
7355
7446
|
h('label', { style: S.row }, h('input', { type: 'radio', name: 'memu-library', checked: pick === 'new', onChange: () => setPick('new') }), t('createLibrary')),
|
|
7356
7447
|
pick === 'new' ? h('input', { style: { ...S.input, marginLeft: 24 }, placeholder: t('name'), value: newName, onChange: (e) => setNewName(e.target.value) }) : null)),
|
|
7357
|
-
h('
|
|
7448
|
+
h('div', { style: { ...S.row, marginTop: 12 } },
|
|
7449
|
+
h(Toggle, { checked: dontShow === true, label: t('rememberChoice'), onChange: setDontShow }),
|
|
7450
|
+
h('span', null, t('rememberChoice'))))
|
|
7358
7451
|
}
|
|
7359
7452
|
|
|
7360
7453
|
exports.name = NS
|