dsh-memu-memory 1.3.6 → 1.3.8
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 +2 -1
- package/CHANGELOG.md +87 -0
- package/README.md +7 -7
- package/README.zh.md +7 -7
- package/docs/client-conventions.md +4 -0
- package/docs/contributing.md +2 -2
- package/docs/memory-semantics.md +10 -7
- package/docs/troubleshooting.md +132 -7
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +296 -122
- package/lib/consolidation-ledger.js +6 -2
- package/lib/consolidation-worker.js +7 -0
- package/lib/inbound.js +24 -9
- package/lib/inject.js +379 -215
- package/lib/lexicon.js +5 -0
- package/lib/local-embedding-manager.js +4 -0
- package/lib/local-vector-service.js +65 -1
- package/lib/memory.js +711 -175
- package/lib/paths.js +24 -0
- package/lib/private.js +284 -127
- package/lib/rpc.js +144 -45
- package/lib/snippet.js +49 -28
- package/lib/state.js +185 -26
- package/lib/tools.js +150 -31
- package/lib/webui/standalone.css +28 -1
- package/lib/webui.js +25 -1
- package/lib/worker-pool.js +260 -26
- package/package.json +1 -1
- package/scripts/check-i18n.mjs +19 -0
- package/scripts/recall-bench.mjs +4 -4
- package/scripts/simulate-injection.mjs +3 -0
- package/tests/activity-wiring.test.mjs +52 -0
- package/tests/client-render.test.mjs +207 -0
- package/tests/consolidation-feed.test.mjs +26 -0
- package/tests/consolidation-fork.test.mjs +618 -33
- package/tests/consolidation-snapshot.test.mjs +2 -1
- package/tests/cross-library-recall.test.mjs +156 -0
- package/tests/cue.test.mjs +15 -2
- package/tests/hybrid-recall.test.mjs +488 -0
- package/tests/inbound.test.mjs +49 -4
- package/tests/inject-conflict.test.mjs +70 -9
- package/tests/inject-guide.test.mjs +13 -1
- package/tests/inject.test.mjs +10 -0
- package/tests/injection-budget.test.mjs +101 -0
- package/tests/injection-chain.test.mjs +37 -0
- package/tests/injection-rollback.test.mjs +172 -9
- package/tests/issue2-chain.test.mjs +169 -0
- package/tests/lexicon-inject.test.mjs +33 -5
- package/tests/lexicon-ui.test.mjs +99 -2
- package/tests/managed-memory.test.mjs +625 -1
- package/tests/media.test.mjs +1 -1
- package/tests/new-session-gate.test.mjs +280 -25
- package/tests/open-loop-date.test.mjs +11 -1
- package/tests/recall-intent.test.mjs +52 -3
- package/tests/simulate-injection.test.mjs +4 -4
- package/tests/snippet.test.mjs +33 -1
- package/tests/state.test.mjs +8 -3
- package/tests/tool-schema.test.mjs +52 -0
- package/tests/tools.test.mjs +394 -0
- package/tests/webui.test.mjs +16 -2
- package/tests/worker-lifecycle.test.mjs +419 -36
package/lib/client.js
CHANGED
|
@@ -372,7 +372,7 @@ window.__ModuleLoader__.load({
|
|
|
372
372
|
settingsTuning: '保存与恢复',
|
|
373
373
|
settingsHeaderNote: '改动即时保存(约 0.25 秒后写盘);「恢复默认」需两次点击确认。',
|
|
374
374
|
settingsGroupRecall: '召回与注入',
|
|
375
|
-
settingsGroupRecallDesc: '
|
|
375
|
+
settingsGroupRecallDesc: '每轮注入什么、注入多少:注入模式、记忆组数、token 预算与已接纳内容去重。',
|
|
376
376
|
settingsGroupLifecycle: '记忆生命周期',
|
|
377
377
|
settingsGroupLifecycleDesc: '永久上限、短期保留、未了之事复提与归档清理节奏。',
|
|
378
378
|
settingsGroupCuration: '整理与唤醒',
|
|
@@ -384,8 +384,8 @@ window.__ModuleLoader__.load({
|
|
|
384
384
|
settingsGroupIntegration: '集成',
|
|
385
385
|
settingsGroupIntegrationDesc: '对外暴露的消息工具白名单与视觉描述服务。',
|
|
386
386
|
autoInject: '注入模式',
|
|
387
|
-
privateTopK: '
|
|
388
|
-
globalTopK: '
|
|
387
|
+
privateTopK: '私有记忆组数上限',
|
|
388
|
+
globalTopK: '全局记忆组数上限',
|
|
389
389
|
crossLibraryRecall: '跨库召回(仅同领域)',
|
|
390
390
|
crossLibraryRecallHint: '开启后,这些读取会合并其它「同领域」私有库:自动召回、memu_private_recall、memu_private_list、侧栏私有列表,以及词典的锚点摘要、本回合匹配与 memu_lexicon_search。\n显式浏览某个库时,仍只显示该库。\n写入不受影响,仍只写当前库;全局词典只有你能写。\n跨库读取改变隔离边界,默认关闭。',
|
|
391
391
|
crossLibraryRecallShort: '同领域私有库合并读取',
|
|
@@ -504,6 +504,8 @@ window.__ModuleLoader__.load({
|
|
|
504
504
|
accuracyTag: '细节未必准',
|
|
505
505
|
accept: '接受',
|
|
506
506
|
reject: '丢弃',
|
|
507
|
+
reviewAccepted: '复核已通过,记忆转为活跃。',
|
|
508
|
+
reviewRejected: '复核未通过,记忆已归档(可在已归档里恢复)。',
|
|
507
509
|
reviewReason: '原因',
|
|
508
510
|
noMemoriesView: '这个记忆库还是空的。可以先在对话里让 agent 记点什么,或用上面的表单手写一条。',
|
|
509
511
|
browseActiveTab: '活跃',
|
|
@@ -749,7 +751,7 @@ window.__ModuleLoader__.load({
|
|
|
749
751
|
noArchived: '没有归档的记忆库。',
|
|
750
752
|
archivedHint: '文件夹从 DSH 移除或在本机消失后,记忆库会自动归档;记忆不会被删除,需要你手动删除,或设置自动删除天数。',
|
|
751
753
|
restore: '恢复',
|
|
752
|
-
|
|
754
|
+
deleteLibrary: '彻底删除',
|
|
753
755
|
deleteLibraryConfirm: '彻底删除记忆库 {name}?这会删掉它的 MemU 数据库和索引,无法恢复。',
|
|
754
756
|
scopeMissing: '文件夹不存在',
|
|
755
757
|
purgeArchivedAfterDays: '归档清理候选阈值(天,0=不提示)',
|
|
@@ -789,7 +791,7 @@ window.__ModuleLoader__.load({
|
|
|
789
791
|
consolidateNow: '手动整理',
|
|
790
792
|
consolidateHint: '为本库绑定的对话发起整理(与侧边栏同一通道,每次最多 5 个,正在整理的会跳过)。整理会产生模型调用成本。',
|
|
791
793
|
consolidateNone: '该库没有可整理的绑定对话',
|
|
792
|
-
|
|
794
|
+
consolidateStarted: '已发起整理 {started} 个对话(正在整理 {running},失败 {failed}){rest}',
|
|
793
795
|
consolidateRest: ',还有 {n} 个可再点一次',
|
|
794
796
|
globalMemory: '全局记忆',
|
|
795
797
|
prompts: '提示词',
|
|
@@ -862,8 +864,11 @@ window.__ModuleLoader__.load({
|
|
|
862
864
|
lexiconScope: '词条管理',
|
|
863
865
|
lexiconNoLibrary: '还没有记忆库;词典随私有记忆库创建,全局词典现在就能用。',
|
|
864
866
|
lexiconGlobalScope: '全局词典',
|
|
867
|
+
lexiconAllScope: '全部词典',
|
|
868
|
+
lexiconAllHint: '这里把全局词典和所有私有库的词条合并展示,每张卡片标注它来自哪一本;编辑、归档、删除仍作用在词条所属的那本词典上。要新建词条请先切到具体的一本(全局词典或某个私有库)——聚合视图没有唯一的写入目标。注入与模型检索不受此视图影响,仍按召回作用域合并。',
|
|
869
|
+
lexiconAllPartial: '部分词典不可读,已跳过:{books}',
|
|
865
870
|
lexiconGlobalHint: '全局词典与全局记忆同构:每个会话都读得到它(锚点摘要、本回合匹配、memu_lexicon_search),但只有你能写——模型与整理链路只写各自的私有记忆库。没写领域的词条不分领域都可见。',
|
|
866
|
-
lexiconBrowseScopeHint: '
|
|
871
|
+
lexiconBrowseScopeHint: '这里选的是「正在看哪一本」:只列该库(或全局词典)自己的词条;选「全部词典」则合并所有书。注入与模型检索按召回作用域合并——当前库 + 全局词典,开了「跨库召回」再加上同领域的其它库(见记忆设置页)。',
|
|
867
872
|
lexiconTotal: '共 {total} 条',
|
|
868
873
|
lexiconTerm: '词条',
|
|
869
874
|
lexiconKind: '类型',
|
|
@@ -972,7 +977,7 @@ window.__ModuleLoader__.load({
|
|
|
972
977
|
helpScopesPitfall3: '条目带上下文(频道/角色/世界线/分支/knownBy)时,不匹配的会话看不到它;这是过滤,不是丢失。',
|
|
973
978
|
helpTitleCards: '标题卡与召回',
|
|
974
979
|
helpTitleCardsBody: '锚点与本回合召回只显示标题卡:标题、标签和 id,正文不注入;全文仍在记忆页抽屉与召回工具里。',
|
|
975
|
-
helpTitleCardsRecall: '
|
|
980
|
+
helpTitleCardsRecall: '标题是目录:关键词搜索返回短片段,方括号内的精确 id 默认读取正文页。长正文用 next 提示里的 offset 与 revision 继续;跨库读取保留 libraryId。',
|
|
976
981
|
helpTitleCardsRule: '标题写作:8–40 字,写具体的人/物/事件或结论(如「Yuike 名字来自小时候的白猫」),不要空标题或「关于XX的事」;细节放进 content。',
|
|
977
982
|
helpArchiveDelete: '归档、删除与撤回',
|
|
978
983
|
helpArchiveDeleteArchive: '归档 = 软删除:随时可恢复,关系与链接保留,不级联;条目移到「已归档」页签,不再注入。',
|
|
@@ -1029,7 +1034,7 @@ window.__ModuleLoader__.load({
|
|
|
1029
1034
|
helpFaq3: '为什么有些记忆不会被注入?',
|
|
1030
1035
|
helpFaq3A: '常见原因:pending_review(等内容复核)、archived/suppressed/expired/superseded、visibility=secret(自动注入会跳过)、上下文或 domain 不匹配。词典条目没有 pending 复核:写入即 active,归档的才不注入。',
|
|
1031
1036
|
helpFaq4: '为什么锚点只有标题?怎么拿到正文?',
|
|
1032
|
-
helpFaq4A: '锚点与本回合召回是目录:只给标题、标签和 id
|
|
1037
|
+
helpFaq4A: '锚点与本回合召回是目录:只给标题、标签和 id。用 memu_private_recall / memu_global_recall 按关键词取片段,按精确 id 读正文页;默认每页 2000 个码点,续页携带 offset 与 revision,正文更新会提示重新读取。也可在记忆页抽屉里直接读。',
|
|
1033
1038
|
helpFaq5: '整理合并(absorb)之后,原来的条目去哪了?怎么撤销?',
|
|
1034
1039
|
helpFaq5A: '合并不会删除任何东西:合并稿成为新的 active 条目,被吸收的来源归档、被取代的目标标记 superseded。在全局记忆页找到合并稿,点「撤销合并」即可整体恢复原状;全局链接也可以逐条移除。',
|
|
1035
1040
|
helpFaq6: '词典为什么自动生效?怎么归档?为什么某条不注入?',
|
|
@@ -1316,7 +1321,7 @@ window.__ModuleLoader__.load({
|
|
|
1316
1321
|
settingsTuning: 'Saving & reset',
|
|
1317
1322
|
settingsHeaderNote: 'Edits save themselves about 0.25s after each change; Reset defaults asks for a second click.',
|
|
1318
1323
|
settingsGroupRecall: 'Recall & injection',
|
|
1319
|
-
settingsGroupRecallDesc: 'What each turn injects and how much:
|
|
1324
|
+
settingsGroupRecallDesc: 'What each turn injects and how much: memory group limits, token budgets, and admitted-content dedupe.',
|
|
1320
1325
|
settingsGroupLifecycle: 'Memory lifecycle',
|
|
1321
1326
|
settingsGroupLifecycleDesc: 'Permanent cap, short-term retention, open-loop reminders and archive cleanup.',
|
|
1322
1327
|
settingsGroupCuration: 'Curation & wake',
|
|
@@ -1328,8 +1333,8 @@ window.__ModuleLoader__.load({
|
|
|
1328
1333
|
settingsGroupIntegration: 'Integration',
|
|
1329
1334
|
settingsGroupIntegrationDesc: 'External message tool allowlist and the vision caption service.',
|
|
1330
1335
|
autoInject: 'Injection mode',
|
|
1331
|
-
privateTopK: 'Private
|
|
1332
|
-
globalTopK: 'Global
|
|
1336
|
+
privateTopK: 'Private memory group limit',
|
|
1337
|
+
globalTopK: 'Global memory group limit',
|
|
1333
1338
|
crossLibraryRecall: 'Cross-library recall (same domain)',
|
|
1334
1339
|
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.',
|
|
1335
1340
|
crossLibraryRecallShort: 'Merge same-domain reads',
|
|
@@ -1448,6 +1453,8 @@ window.__ModuleLoader__.load({
|
|
|
1448
1453
|
accuracyTag: 'details may be off',
|
|
1449
1454
|
accept: 'Accept',
|
|
1450
1455
|
reject: 'Discard',
|
|
1456
|
+
reviewAccepted: 'Review accepted; the memory is now active.',
|
|
1457
|
+
reviewRejected: 'Review rejected; the memory was archived (restore it from Archived).',
|
|
1451
1458
|
reviewReason: 'Reason',
|
|
1452
1459
|
noMemoriesView: 'This library is empty. Let the agent note something in a conversation, or write one above.',
|
|
1453
1460
|
browseActiveTab: 'Active',
|
|
@@ -1692,7 +1699,7 @@ window.__ModuleLoader__.load({
|
|
|
1692
1699
|
noArchived: 'No archived libraries.',
|
|
1693
1700
|
archivedHint: 'A library is archived when its folder leaves DSH or disappears from this machine. Memory is never deleted automatically — delete it by hand, or set an auto-delete age.',
|
|
1694
1701
|
restore: 'Restore',
|
|
1695
|
-
|
|
1702
|
+
deleteLibrary: 'Delete forever',
|
|
1696
1703
|
deleteLibraryConfirm: 'Permanently delete {name}? This removes its MemU database and index and cannot be undone.',
|
|
1697
1704
|
scopeMissing: 'Folder missing',
|
|
1698
1705
|
purgeArchivedAfterDays: 'Archive cleanup review after days (0=off)',
|
|
@@ -1732,7 +1739,7 @@ window.__ModuleLoader__.load({
|
|
|
1732
1739
|
consolidateNow: 'Consolidate now',
|
|
1733
1740
|
consolidateHint: 'Start consolidation for conversations bound to this library (same channel as the sidebar; up to 5 per click, ones already running are skipped). Consolidation costs model calls.',
|
|
1734
1741
|
consolidateNone: 'No bound conversations to consolidate in this library',
|
|
1735
|
-
|
|
1742
|
+
consolidateStarted: 'Started {started} conversations ({running} already running, {failed} failed){rest}',
|
|
1736
1743
|
consolidateRest: ' — {n} more, click again',
|
|
1737
1744
|
globalMemory: 'Global memory',
|
|
1738
1745
|
prompts: 'Prompts',
|
|
@@ -1805,8 +1812,11 @@ window.__ModuleLoader__.load({
|
|
|
1805
1812
|
lexiconScope: 'Terms',
|
|
1806
1813
|
lexiconNoLibrary: 'No memory libraries yet; a lexicon comes with each private library. The global lexicon is already usable.',
|
|
1807
1814
|
lexiconGlobalScope: 'Global lexicon',
|
|
1815
|
+
lexiconAllScope: 'All dictionaries',
|
|
1816
|
+
lexiconAllHint: 'This merges the global lexicon and every private library into one list; each card tags the book it comes from. Edit, archive and delete still act on the term\'s own book. To add a term, switch to a specific book first (the global lexicon or a private library) — the aggregate view has no single write target. Injection and the model search are unaffected by this view and still merge by recall scope.',
|
|
1817
|
+
lexiconAllPartial: 'Some dictionaries are unreadable and were skipped: {books}',
|
|
1808
1818
|
lexiconGlobalHint: 'The global lexicon mirrors global memory: every conversation reads it (anchor summary, this-turn match, memu_lexicon_search), but only you write it — the model and consolidation only ever write their own private library. Terms without a domain are visible in every domain.',
|
|
1809
|
-
lexiconBrowseScopeHint: 'This picker answers "which book am I reading": it lists only that library (or the global lexicon). Injection and the model search merge by recall scope — bound library + global lexicon, plus same-domain libraries when cross-library recall is on (see Memory settings).',
|
|
1819
|
+
lexiconBrowseScopeHint: 'This picker answers "which book am I reading": it lists only that library (or the global lexicon); pick "All dictionaries" to merge every book. Injection and the model search merge by recall scope — bound library + global lexicon, plus same-domain libraries when cross-library recall is on (see Memory settings).',
|
|
1810
1820
|
lexiconTotal: '{total} terms',
|
|
1811
1821
|
lexiconTerm: 'Term',
|
|
1812
1822
|
lexiconKind: 'Kind',
|
|
@@ -1915,7 +1925,7 @@ window.__ModuleLoader__.load({
|
|
|
1915
1925
|
helpScopesPitfall3: 'Entries carrying context (channel / character / world / branch / knownBy) stay hidden from conversations that do not match; that is filtering, not loss.',
|
|
1916
1926
|
helpTitleCards: 'Title cards and recall',
|
|
1917
1927
|
helpTitleCardsBody: 'The anchor and per-turn recall show title cards only: title, tags and id; bodies are not injected. The full text still lives in the memory drawer and the recall tools.',
|
|
1918
|
-
helpTitleCardsRecall: '
|
|
1928
|
+
helpTitleCardsRecall: 'Titles are an index: keyword searches return snippets; exact bracketed ids read body pages by default. Continue with the next offset and revision; preserve libraryId for cross-library reads.',
|
|
1919
1929
|
helpTitleCardsRule: 'Title rule: 8–40 characters naming the concrete person/object/event or conclusion ("Yuike is named after a childhood white cat"); no empty titles or "about X" labels; details belong in content.',
|
|
1920
1930
|
helpArchiveDelete: 'Archive, delete and undo',
|
|
1921
1931
|
helpArchiveDeleteArchive: 'Archive = soft delete: restorable at any time, links and relationships kept, no cascade; the entry moves to the "Archived" tab and stops being injected.',
|
|
@@ -1972,7 +1982,7 @@ window.__ModuleLoader__.load({
|
|
|
1972
1982
|
helpFaq3: 'Why are some memories not injected?',
|
|
1973
1983
|
helpFaq3A: 'Common reasons: pending_review (waiting for approval), archived/suppressed/expired/superseded, visibility=secret (automatic injection skips it), or a context/domain mismatch. Lexicon terms have no pending review anymore: they are active on write and only archived terms stop being injected.',
|
|
1974
1984
|
helpFaq4: 'Why does the anchor show only titles, and how do I get the body?',
|
|
1975
|
-
helpFaq4A: '
|
|
1985
|
+
helpFaq4A: 'Anchor and per-turn recall are an index: title, tags and id only. Search keywords for snippets or read exact ids for body pages, 2000 Unicode code points per page by default. Continue with offset and revision; changed bodies require a restart. The memory-page drawer also shows the full text.',
|
|
1976
1986
|
helpFaq5: 'Where did the original entries go after an absorb, and how do I undo it?',
|
|
1977
1987
|
helpFaq5A: 'Absorbing deletes nothing: the merged entry becomes active, the target is marked superseded and the sources are archived. Find the merged entry on the global memory page and press "Undo merge" to restore everything; global links can be removed individually.',
|
|
1978
1988
|
helpFaq6: 'The lexicon writes automatically — how do I archive, and why is a term not injected?',
|
|
@@ -2083,16 +2093,27 @@ window.__ModuleLoader__.load({
|
|
|
2083
2093
|
.dshm-wall-views{margin:2px 0 4px}
|
|
2084
2094
|
.dshm-wall-graph{margin-top:4px}
|
|
2085
2095
|
.dshm-drawer-backdrop{position:fixed;inset:0;z-index:80;display:flex;justify-content:flex-end;background:rgba(10,14,22,.38);animation:dshm-fade-in .2s ease both}
|
|
2086
|
-
.dshm-drawer{width:min(480px,100%);height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:22px;background:var(--dsw-alias-bg-layer-1,#
|
|
2096
|
+
.dshm-drawer{width:min(480px,100%);height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:22px;background-color:#fff;background:linear-gradient(var(--dsw-alias-bg-layer-1,transparent),var(--dsw-alias-bg-layer-1,transparent)),light-dark(#ffffff,#1b1d23);color:var(--dsw-alias-label-primary,inherit);border-left:1px solid var(--dsw-alias-border-l1,#ddd);box-shadow:-24px 0 60px -34px rgba(0,0,0,.45);animation:dshm-drawer-in .3s cubic-bezier(.22,1,.36,1) backwards}
|
|
2087
2097
|
.dshm-drawer-head{display:flex;align-items:flex-start;gap:10px}
|
|
2088
2098
|
.dshm-drawer-title{margin:4px 0 6px;font-size:17px;font-weight:650;line-height:1.3;overflow-wrap:anywhere}
|
|
2089
2099
|
.dshm-drawer-meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
|
|
2090
2100
|
.dshm-drawer-form{display:flex;flex-direction:column;gap:8px;margin-top:4px}
|
|
2091
|
-
|
|
2101
|
+
/* 2026-11-16:纵向表单里的字段不再 flex-grow 拉伸——之前每个 field 被拉满剩余高度,抽屉下半全是空白 */
|
|
2102
|
+
.dshm-drawer-form .dshm-drawer-field{flex:0 0 auto}
|
|
2103
|
+
.dshm-drawer-form>.dshm-drawer-inline{flex:0 0 auto}
|
|
2104
|
+
.dshm-drawer-form>.dshm-drawer-note{flex:0 0 auto}
|
|
2105
|
+
/* 行内横排(说出口径/置信度/开关一行)保持横向伸展与窄列宽度 */
|
|
2106
|
+
.dshm-drawer-form .dshm-drawer-inline .dshm-drawer-field{flex:1 1 160px}
|
|
2107
|
+
.dshm-drawer-form .dshm-drawer-inline .dshm-drawer-field.is-narrow{flex:0 0 130px}
|
|
2108
|
+
.dshm-drawer-inline{display:flex;flex-wrap:wrap;gap:8px 14px;align-items:flex-end}
|
|
2092
2109
|
.dshm-drawer-switch{display:inline-flex;align-items:center;gap:7px;font-size:12px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
2093
2110
|
.dshm-drawer-copy{margin:4px 0;white-space:pre-wrap;line-height:1.7;font-size:13px}
|
|
2094
2111
|
.dshm-drawer-note{margin-top:4px;font-size:11.5px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
2095
2112
|
.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)}
|
|
2113
|
+
.dshm-drawer-field{display:flex;flex-direction:column;gap:5px;min-width:0;flex:1 1 160px}
|
|
2114
|
+
.dshm-drawer-field.is-narrow{flex:0 0 130px}
|
|
2115
|
+
.dshm-drawer-label{font-size:11.5px;font-weight:600;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
2116
|
+
.dshm-drawer-field input,.dshm-drawer-field select{width:100%;box-sizing:border-box}
|
|
2096
2117
|
@keyframes dshm-drawer-in{from{transform:translateX(28px);opacity:0}to{transform:none;opacity:1}}
|
|
2097
2118
|
.dshm-root .dshm-brand-tile{background:transparent;box-shadow:none}
|
|
2098
2119
|
.dshm-brand-tile img{display:block;object-fit:contain}
|
|
@@ -2487,6 +2508,22 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
|
|
|
2487
2508
|
.dshm-card-actions{margin-left:auto;display:flex;gap:8px;flex:none;align-items:center}
|
|
2488
2509
|
|
|
2489
2510
|
.dshm-root input:not([type=checkbox]):not([type=radio]):focus,.dshm-root textarea:focus,.dshm-root select:focus{border-color:var(--dsw-alias-brand-primary,#2563eb);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary,#2563eb) 18%,transparent)}
|
|
2511
|
+
.dshm-consolidation{min-width:0;border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.18));border-radius:16px;padding:10px 12px;margin-top:12px;background:var(--dsw-alias-bg-layer-1,rgba(127,127,127,.04))}
|
|
2512
|
+
.dshm-consolidation-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;width:100%;padding:0;border:0;background:transparent;cursor:pointer;text-align:left;color:inherit;font:inherit}
|
|
2513
|
+
.dshm-consolidation-title{min-width:0;font-size:12.5px;font-weight:600;overflow-wrap:anywhere}
|
|
2514
|
+
.dshm-consolidation-toggle{margin-left:auto;font-size:11px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
|
|
2515
|
+
.dshm-consolidation-columns{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:14px;margin-top:7px}
|
|
2516
|
+
.dshm-consolidation-column,.dshm-consolidation-row{min-width:0}
|
|
2517
|
+
.dshm-consolidation-column-head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
|
|
2518
|
+
.dshm-consolidation-failed{color:var(--dsw-alias-state-error-primary,#c0392b)}
|
|
2519
|
+
.dshm-consolidation-rows{display:flex;flex-direction:column;gap:8px}
|
|
2520
|
+
.dshm-consolidation-identity{display:flex;gap:6px;align-items:center;min-width:0}
|
|
2521
|
+
.dshm-consolidation-identity>span:first-child{flex-shrink:0}
|
|
2522
|
+
.dshm-consolidation-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
|
|
2523
|
+
.dshm-consolidation-meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:space-between;margin-top:3px}
|
|
2524
|
+
.dshm-consolidation-time{min-width:0;font-size:11px;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
|
|
2525
|
+
.dshm-consolidation-message{font-size:11px;margin-top:3px;overflow-wrap:anywhere;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
|
|
2526
|
+
.dshm-consolidation-latest{margin-top:7px}
|
|
2490
2527
|
.dshm-btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 5px 14px -6px rgba(0,0,0,.32)}
|
|
2491
2528
|
.dshm-btn:active:not(:disabled){transform:translateY(0) scale(.97);box-shadow:none}
|
|
2492
2529
|
.dshm-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:2px}
|
|
@@ -2933,9 +2970,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2933
2970
|
info: { color: V.accent, background: V.accentSoft },
|
|
2934
2971
|
}
|
|
2935
2972
|
|
|
2936
|
-
function Tag({ children, tone, title }) {
|
|
2937
|
-
const
|
|
2938
|
-
|
|
2973
|
+
function Tag({ children, tone, title, style }) {
|
|
2974
|
+
const base = tone && TAG_TONES[tone] ? { ...S.tag, ...TAG_TONES[tone] } : S.tag
|
|
2975
|
+
// style 由调用方收紧(如提醒行里允许药丸截断),只在基础样式之上叠加。
|
|
2976
|
+
return h('span', { style: style ? { ...base, ...style } : base, title }, children)
|
|
2939
2977
|
}
|
|
2940
2978
|
|
|
2941
2979
|
// 活动日志行的三档状态。失败 = ok=false 或 level=error;level=warn 而 ok 不为 false
|
|
@@ -4581,6 +4619,25 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4581
4619
|
setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
|
|
4582
4620
|
}
|
|
4583
4621
|
}
|
|
4622
|
+
// 待复核记忆在抽屉里直接拍板(私有与全局都支持):与墙内其它写操作同一
|
|
4623
|
+
// 管理面授权模型,不带 sessionId;全局条目不带 libraryId 走全局复核路由。
|
|
4624
|
+
const resolveDetailReview = async (action) => {
|
|
4625
|
+
const current = detail
|
|
4626
|
+
if (!current?.item || current.item.status !== 'pending_review') return
|
|
4627
|
+
setDetail({ ...current, busy: true, error: '' })
|
|
4628
|
+
try {
|
|
4629
|
+
await call('resolveReview', {
|
|
4630
|
+
id: current.item.id, action,
|
|
4631
|
+
...(current.item.libraryId ? { libraryId: current.item.libraryId } : {}),
|
|
4632
|
+
})
|
|
4633
|
+
setDetail(null)
|
|
4634
|
+
notifyMemoryWrite('review', current.item.libraryId || null)
|
|
4635
|
+
notice(action === 'accept' ? t('reviewAccepted') : t('reviewRejected'))
|
|
4636
|
+
reload()
|
|
4637
|
+
} catch (failure) {
|
|
4638
|
+
setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4584
4641
|
|
|
4585
4642
|
// —— 多选批量操作(只对私有块生效;全局只读)——
|
|
4586
4643
|
// 逐条走既有 RPC(updateMemory patch.status / deleteMemory),循环里失败的条目
|
|
@@ -4727,6 +4784,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4727
4784
|
detailForm,
|
|
4728
4785
|
detail.file && !detail.readonly ? h(MemoryAttachments, { items: detail.file.attachments, t, initialOpen: true }) : null,
|
|
4729
4786
|
h('div', { className: 'dshm-drawer-actions' },
|
|
4787
|
+
shown.status === 'pending_review'
|
|
4788
|
+
? h(Button, { primary: true, disabled: detail.busy, onClick: () => { void resolveDetailReview('accept') } }, t('accept'))
|
|
4789
|
+
: null,
|
|
4790
|
+
shown.status === 'pending_review'
|
|
4791
|
+
? h(Button, { style: S.ghost, disabled: detail.busy, onClick: () => { void resolveDetailReview('reject') } }, t('reject'))
|
|
4792
|
+
: null,
|
|
4730
4793
|
!detail.readonly
|
|
4731
4794
|
? h(Button, { primary: true, disabled: detail.busy, onClick: () => { void saveDetail() } }, t('save'))
|
|
4732
4795
|
: null,
|
|
@@ -4905,6 +4968,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4905
4968
|
// 全局词典的保留存储名,与服务端 lib/lexicon.js 的 GLOBAL_LEXICON_ID 同一个值:
|
|
4906
4969
|
// 私有库 id 恒为 `lib_<hex>`,所以它不可能撞上某本私有库。
|
|
4907
4970
|
const GLOBAL_LEXICON_ID = 'global'
|
|
4971
|
+
// 「全部词典」聚合浏览的保留作用域名,与服务端 lib/lexicon.js 的 ALL_LEXICON_ID 同值:
|
|
4972
|
+
// 合并全局词典 + 所有私有库,只读聚合;写操作按词条所属库路由。漂移由测试钉住。
|
|
4973
|
+
const ALL_LEXICON_ID = 'all'
|
|
4908
4974
|
const EMPTY_LEXICON_DRAFT = { term: '', kind: 'term', meaning: '', usage: '', aliases: '', examples: '' }
|
|
4909
4975
|
|
|
4910
4976
|
// 词典页(§2.4):公开生命周期只有 active / archived,卡片流对齐记忆墙的
|
|
@@ -4927,12 +4993,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4927
4993
|
const [notice, setNotice] = React.useState('')
|
|
4928
4994
|
const [editingId, setEditingId] = React.useState('')
|
|
4929
4995
|
const [editDraft, setEditDraft] = React.useState(null)
|
|
4996
|
+
// 编辑抽屉的头部要显示词条标题/类型/来源书:翻页后卡片可能不在当前页,
|
|
4997
|
+
// 所以打开时把整条存下来,不依赖 items 里还找得到它。
|
|
4998
|
+
const [editingTerm, setEditingTerm] = React.useState(null)
|
|
4930
4999
|
const [creating, setCreating] = React.useState(false)
|
|
4931
5000
|
const [newDraft, setNewDraft] = React.useState(EMPTY_LEXICON_DRAFT)
|
|
4932
5001
|
const [multi, setMulti] = React.useState(false)
|
|
4933
5002
|
const [selectedIds, setSelectedIds] = React.useState(() => new Set())
|
|
4934
5003
|
const [deleteArmed, setDeleteArmed] = React.useState('')
|
|
4935
5004
|
const [armedBulk, setArmedBulk] = React.useState('')
|
|
5005
|
+
// 宿主拒绝多库聚合读(403)时禁用「全部词典」选项,与记忆墙 multiBlocked 同一退路。
|
|
5006
|
+
const [allBlocked, setAllBlocked] = React.useState(false)
|
|
4936
5007
|
|
|
4937
5008
|
// 宿主可能把面板与别的块并排渲染;读取状态时保持类型收窄,坏形状按空值处理,
|
|
4938
5009
|
// 不在渲染期抛错(设置页任何一块抛错整页都会变空白)。
|
|
@@ -4942,8 +5013,24 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4942
5013
|
|
|
4943
5014
|
const activeLib = libraryId || libraries[0]?.id || GLOBAL_LEXICON_ID
|
|
4944
5015
|
const isGlobalLib = activeLib === GLOBAL_LEXICON_ID
|
|
5016
|
+
const isAllLib = activeLib === ALL_LEXICON_ID
|
|
5017
|
+
// 聚合视图里每张卡片来自不同的书:编辑/归档/删除必须路由回词条所属的那一本,
|
|
5018
|
+
// 不能拿 activeLib('all' 是保留作用域名,不是存储)去写。
|
|
5019
|
+
const bookOf = (e) => (isAllLib ? (e?.libraryId || GLOBAL_LEXICON_ID) : activeLib)
|
|
5020
|
+
// 聚合视图的写操作落在词条所属的具体库上,可能不是会话绑定的那本:省略 sessionId
|
|
5021
|
+
// 走管理面 capability(与聚合读同模型),否则跨库写会被单库授权 403。
|
|
5022
|
+
const writeSession = isAllLib ? undefined : (sessionId || undefined)
|
|
5023
|
+
// 词条来自哪一本:全局词典用保留名,私有库用库名(回退到服务端给的 name / id)。
|
|
5024
|
+
// 卡片标签与编辑抽屉头部共用。
|
|
5025
|
+
const bookLabelOf = (e) => (e?.libraryId === GLOBAL_LEXICON_ID
|
|
5026
|
+
? t('lexiconGlobalScope')
|
|
5027
|
+
: (libraries.find((lib) => lib.id === e?.libraryId)?.name || e?.libraryName || e?.libraryId || ''))
|
|
4945
5028
|
const emptyView = { items: [], total: 0, page: 1, pages: 1, counts: {}, statusCounts: { active: 0, archived: 0 } }
|
|
4946
5029
|
const loadSeq = React.useRef(0)
|
|
5030
|
+
// load 的依赖里不放 libraries/t:它们可能每次渲染都是新引用(`|| []`、bind),
|
|
5031
|
+
// 进了依赖会让 load 每渲染重建 → effect 重跑 → 再渲染,形成循环。用 ref 读最新值。
|
|
5032
|
+
const loadProps = React.useRef({ libraries, t })
|
|
5033
|
+
loadProps.current = { libraries, t }
|
|
4947
5034
|
const load = React.useCallback(async () => {
|
|
4948
5035
|
if (!activeLib) { setData(emptyView); return }
|
|
4949
5036
|
const seq = ++loadSeq.current
|
|
@@ -4951,16 +5038,29 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4951
5038
|
try {
|
|
4952
5039
|
// 只取当前页、当前页签:状态页签、kind、搜索、分页全在 RPC 侧收窄,
|
|
4953
5040
|
// 客户端不缓存任何全量词条列表。翻页/新建后并发的旧请求用代次抑制。
|
|
5041
|
+
// 「全部词典」是跨库聚合管理视图:与记忆墙 browseWall 同模型,不带 sessionId
|
|
5042
|
+
// (会话凭据表达不了多库授权),由宿主 capability 把关。
|
|
4954
5043
|
const res = await call('lexiconList', {
|
|
4955
|
-
libraryId: activeLib, sessionId: sessionId || undefined, page, pageSize: 50,
|
|
5044
|
+
libraryId: activeLib, ...(isAllLib ? {} : { sessionId: sessionId || undefined }), page, pageSize: 50,
|
|
4956
5045
|
status, kind: kind || undefined, q: query || undefined,
|
|
4957
5046
|
})
|
|
4958
5047
|
if (seq !== loadSeq.current) return
|
|
4959
5048
|
setData(res || emptyView)
|
|
4960
5049
|
setError('')
|
|
5050
|
+
if (isAllLib && Array.isArray(res?.errors) && res.errors.length > 0) {
|
|
5051
|
+
setNotice(loadProps.current.t('lexiconAllPartial').split('{books}').join(res.errors.map((x) => x.libraryId).join(', ')))
|
|
5052
|
+
}
|
|
4961
5053
|
} catch (e) {
|
|
4962
5054
|
if (seq !== loadSeq.current) return
|
|
4963
|
-
|
|
5055
|
+
const message = String(e?.message || e)
|
|
5056
|
+
if (isAllLib && /forbidden|403/i.test(message)) {
|
|
5057
|
+
const books = loadProps.current.libraries
|
|
5058
|
+
setAllBlocked(true)
|
|
5059
|
+
setLibraryId(books[0]?.id || GLOBAL_LEXICON_ID)
|
|
5060
|
+
setPage(1)
|
|
5061
|
+
return
|
|
5062
|
+
}
|
|
5063
|
+
setError(message)
|
|
4964
5064
|
} finally {
|
|
4965
5065
|
if (seq === loadSeq.current) setBusy(false)
|
|
4966
5066
|
}
|
|
@@ -4971,6 +5071,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4971
5071
|
const timer = setTimeout(() => { setError(''); setNotice('') }, 2600)
|
|
4972
5072
|
return () => clearTimeout(timer)
|
|
4973
5073
|
}, [error, notice])
|
|
5074
|
+
// 编辑抽屉与记忆详情抽屉同一交互:Escape 关闭(backdrop 点击也能关)。
|
|
5075
|
+
React.useEffect(() => {
|
|
5076
|
+
if (!editingId) return undefined
|
|
5077
|
+
const onKey = (event) => { if (event.key === 'Escape') { setEditingId(''); setEditDraft(null); setEditingTerm(null) } }
|
|
5078
|
+
window.addEventListener('keydown', onKey)
|
|
5079
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
5080
|
+
}, [editingId])
|
|
4974
5081
|
// 两段确认要能自行退场:armed 不会一直挂着;切页签/筛选/动作也会显式清掉。
|
|
4975
5082
|
React.useEffect(() => {
|
|
4976
5083
|
if (!deleteArmed && !armedBulk) return undefined
|
|
@@ -5003,10 +5110,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5003
5110
|
sensitivity: e.sensitivity || 'normal',
|
|
5004
5111
|
strength: typeof e.strength === 'number' ? String(e.strength) : '',
|
|
5005
5112
|
})
|
|
5113
|
+
const closeEdit = () => { setEditingId(''); setEditDraft(null); setEditingTerm(null) }
|
|
5006
5114
|
const toggleEdit = (e) => {
|
|
5007
|
-
if (editingId === e.id) {
|
|
5115
|
+
if (editingId === e.id) { closeEdit(); return }
|
|
5008
5116
|
setCreating(false)
|
|
5009
5117
|
setEditingId(e.id)
|
|
5118
|
+
setEditingTerm(e)
|
|
5010
5119
|
setEditDraft(draftOf(e))
|
|
5011
5120
|
}
|
|
5012
5121
|
const splitList = (value, limit) => String(value || '').split(',').map((item) => item.trim()).filter(Boolean).slice(0, limit)
|
|
@@ -5033,10 +5142,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5033
5142
|
}
|
|
5034
5143
|
const strength = strengthOf(draft.strength)
|
|
5035
5144
|
if (strength !== undefined) patch.strength = strength
|
|
5145
|
+
const row = (Array.isArray(data?.items) ? data.items : []).find((x) => x.id === current)
|
|
5146
|
+
const book = bookOf(row)
|
|
5036
5147
|
return act(async () => {
|
|
5037
|
-
await call('lexiconUpdate', { libraryId:
|
|
5038
|
-
setEditingId(''); setEditDraft(null); setDeleteArmed(''); setArmedBulk('')
|
|
5039
|
-
notifyMemoryWrite('lexicon',
|
|
5148
|
+
await call('lexiconUpdate', { libraryId: book, sessionId: writeSession, termId: current, patch })
|
|
5149
|
+
setEditingId(''); setEditDraft(null); setEditingTerm(null); setDeleteArmed(''); setArmedBulk('')
|
|
5150
|
+
notifyMemoryWrite('lexicon', book)
|
|
5040
5151
|
setNotice(t('lexiconSaveDone'))
|
|
5041
5152
|
setError('')
|
|
5042
5153
|
await load()
|
|
@@ -5045,9 +5156,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5045
5156
|
// 归档 / 恢复(§2.4):可逆的一击动作,不走审核、不产生 revision。
|
|
5046
5157
|
const setLifecycle = (e, action) => {
|
|
5047
5158
|
setDeleteArmed(''); setArmedBulk('')
|
|
5159
|
+
const book = bookOf(e)
|
|
5048
5160
|
return act(async () => {
|
|
5049
|
-
await call(action === 'archive' ? 'lexiconArchive' : 'lexiconRestore', { libraryId:
|
|
5050
|
-
notifyMemoryWrite('lexicon',
|
|
5161
|
+
await call(action === 'archive' ? 'lexiconArchive' : 'lexiconRestore', { libraryId: book, termId: e.id })
|
|
5162
|
+
notifyMemoryWrite('lexicon', book)
|
|
5051
5163
|
setNotice(action === 'archive' ? t('lexiconArchiveDone') : t('lexiconRestoreDone'))
|
|
5052
5164
|
setError('')
|
|
5053
5165
|
await load()
|
|
@@ -5056,9 +5168,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5056
5168
|
// 删除是永久动作,只走管理面:两段确认由卡片按钮负责,这里只发 RPC。
|
|
5057
5169
|
const deleteTerm = (e) => {
|
|
5058
5170
|
setDeleteArmed(''); setArmedBulk('')
|
|
5171
|
+
const book = bookOf(e)
|
|
5059
5172
|
return act(async () => {
|
|
5060
|
-
await call('lexiconDelete', { libraryId:
|
|
5061
|
-
notifyMemoryWrite('lexicon',
|
|
5173
|
+
await call('lexiconDelete', { libraryId: book, termId: e.id })
|
|
5174
|
+
notifyMemoryWrite('lexicon', book)
|
|
5062
5175
|
setNotice(t('lexiconDeleted').split('{n}').join('1'))
|
|
5063
5176
|
setError('')
|
|
5064
5177
|
await load()
|
|
@@ -5097,8 +5210,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5097
5210
|
const failures = []
|
|
5098
5211
|
for (const row of rows) {
|
|
5099
5212
|
try {
|
|
5100
|
-
|
|
5101
|
-
|
|
5213
|
+
const book = bookOf(row)
|
|
5214
|
+
if (action === 'delete') await call('lexiconDelete', { libraryId: book, termId: row.id })
|
|
5215
|
+
else await call(action === 'archive' ? 'lexiconArchive' : 'lexiconRestore', { libraryId: book, termId: row.id })
|
|
5102
5216
|
done += 1
|
|
5103
5217
|
} catch (failure) { failures.push(`${row.term || row.id}: ${String(failure?.message || failure)}`) }
|
|
5104
5218
|
}
|
|
@@ -5181,7 +5295,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5181
5295
|
onKeyDown: (e) => { if (e.key === 'Enter') applySearch() },
|
|
5182
5296
|
}),
|
|
5183
5297
|
h(Button, { style: S.ghost, onClick: applySearch, disabled: busy }, t('logRefresh')),
|
|
5184
|
-
|
|
5298
|
+
// 聚合视图没有唯一写入目标:新建按钮只在具体某一本(全局/私有库)时出现。
|
|
5299
|
+
isAllLib ? null : h(Button, { style: S.ghost, onClick: () => { setCreating((v) => !v); setEditingId(''); setEditDraft(null); setDeleteArmed(''); setArmedBulk('') } }, t('lexiconNew')),
|
|
5185
5300
|
activeLib ? h(Button, { style: S.ghost, onClick: () => (multi ? exitMulti() : setMulti(true)), disabled: busy }, t('multiSelect')) : null)
|
|
5186
5301
|
const newForm = creating
|
|
5187
5302
|
? h('div', { style: { ...S.item, display: 'block' } },
|
|
@@ -5197,26 +5312,57 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5197
5312
|
h(Button, { primary: true, disabled: busy || !String(safeNewDraft.term || '').trim() || !String(safeNewDraft.meaning || '').trim(), onClick: () => void submitNew() }, t('lexiconCreate')),
|
|
5198
5313
|
h(Button, { style: S.ghost, disabled: busy, onClick: () => setCreating(false) }, t('cancelDelete'))))
|
|
5199
5314
|
: null
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5315
|
+
// 编辑抽屉(2026-11-15):照记忆详情卡的做法在右侧栏展开,取代卡片内向下展开——
|
|
5316
|
+
// 内联表单只有卡片宽、释义/例句挤在一起看不全。抽屉给足纵向空间,字段逐行排布,
|
|
5317
|
+
// 头部显示词条标题/类型/来源书,底部保存/取消。背景与记忆抽屉同款(不透明)。
|
|
5318
|
+
const editDrawer = editingId && editingTerm && editDraft && typeof editDraft === 'object'
|
|
5319
|
+
? h('div', {
|
|
5320
|
+
className: 'dshm-drawer-backdrop',
|
|
5321
|
+
onClick: (event) => { if (event.target === event.currentTarget) closeEdit() },
|
|
5322
|
+
},
|
|
5323
|
+
h('aside', {
|
|
5324
|
+
className: 'dshm-drawer',
|
|
5325
|
+
role: 'dialog',
|
|
5326
|
+
'aria-modal': 'true',
|
|
5327
|
+
'aria-label': t('lexiconEdit'),
|
|
5328
|
+
},
|
|
5329
|
+
h('div', { className: 'dshm-drawer-head' },
|
|
5330
|
+
h('div', { style: { minWidth: 0, flex: 1 } },
|
|
5331
|
+
h('div', { className: 'dshm-overline' }, bookLabelOf(editingTerm) || t('lexiconScope')),
|
|
5332
|
+
h('h3', { className: 'dshm-drawer-title' }, editingTerm.term || editingTerm.id),
|
|
5333
|
+
h('div', { className: 'dshm-drawer-meta' },
|
|
5334
|
+
h(Tag, null, enumText(t, LEXICON_KIND_LABELS, editingTerm.kind)),
|
|
5335
|
+
editingTerm.sensitivity === 'sensitive' ? h(Tag, { tone: 'warn' }, t('lexiconSensitive')) : null)),
|
|
5336
|
+
h('button', { type: 'button', className: 'dshm-x', 'aria-label': t('close'), onClick: closeEdit }, '×')),
|
|
5337
|
+
h('div', { className: 'dshm-drawer-form' },
|
|
5338
|
+
h('label', { className: 'dshm-drawer-field' },
|
|
5339
|
+
h('span', { className: 'dshm-drawer-label' }, t('lexiconMeaning')),
|
|
5340
|
+
h('textarea', { style: { ...S.textarea, minHeight: 120 }, value: editDraft.meaning, 'aria-label': t('lexiconMeaning'), onChange: (event) => setEditDraft({ ...editDraft, meaning: event.target.value }) })),
|
|
5341
|
+
h('label', { className: 'dshm-drawer-field' },
|
|
5342
|
+
h('span', { className: 'dshm-drawer-label' }, t('lexiconUsage')),
|
|
5343
|
+
h('input', { style: S.input, value: editDraft.usage, 'aria-label': t('lexiconUsage'), onChange: (event) => setEditDraft({ ...editDraft, usage: event.target.value }) })),
|
|
5344
|
+
h('label', { className: 'dshm-drawer-field' },
|
|
5345
|
+
h('span', { className: 'dshm-drawer-label' }, t('lexiconAliases')),
|
|
5346
|
+
h('input', { style: S.input, value: editDraft.aliases, placeholder: 'alias1, alias2', 'aria-label': t('lexiconAliases'), onChange: (event) => setEditDraft({ ...editDraft, aliases: event.target.value }) })),
|
|
5347
|
+
h('label', { className: 'dshm-drawer-field' },
|
|
5348
|
+
h('span', { className: 'dshm-drawer-label' }, t('lexiconExamples')),
|
|
5349
|
+
h('textarea', { style: { ...S.textarea, minHeight: 96 }, value: editDraft.examples, 'aria-label': t('lexiconExamples'), onChange: (event) => setEditDraft({ ...editDraft, examples: event.target.value }) })),
|
|
5350
|
+
h('div', { className: 'dshm-drawer-inline' },
|
|
5351
|
+
h('label', { className: 'dshm-drawer-field' },
|
|
5352
|
+
h('span', { className: 'dshm-drawer-label' }, t('lexiconSensitivity')),
|
|
5353
|
+
h('select', { style: S.input, value: editDraft.sensitivity, 'aria-label': t('lexiconSensitivity'), onChange: (event) => setEditDraft({ ...editDraft, sensitivity: event.target.value }) },
|
|
5354
|
+
h('option', { value: 'normal' }, t('lexiconNormal')),
|
|
5355
|
+
h('option', { value: 'sensitive' }, t('lexiconSensitive')))),
|
|
5356
|
+
h('label', { className: 'dshm-drawer-field is-narrow' },
|
|
5357
|
+
h('span', { className: 'dshm-drawer-label' }, t('lexiconStrength')),
|
|
5358
|
+
h('input', { style: S.input, type: 'number', min: 0, max: 1, step: 0.05, value: editDraft.strength, 'aria-label': t('lexiconStrength'), onChange: (event) => setEditDraft({ ...editDraft, strength: event.target.value }) })))),
|
|
5359
|
+
h('div', { className: 'dshm-drawer-actions' },
|
|
5360
|
+
h(Button, { primary: true, disabled: busy, onClick: () => void saveEdit() }, t('save')),
|
|
5361
|
+
h(Button, { style: S.ghost, disabled: busy, onClick: closeEdit }, t('cancelDelete')))))
|
|
5362
|
+
: null
|
|
5216
5363
|
// 卡片流(§2.4):term 是标题,meaning 是正文(≤120 字),usage/aliases 是次要行;
|
|
5217
5364
|
// 命中三计数与 strength 同记忆墙一样不抢标题的位置。
|
|
5218
5365
|
const renderCard = (e) => {
|
|
5219
|
-
const editing = editingId === e.id
|
|
5220
5366
|
const aliases = Array.isArray(e.aliases) ? e.aliases : []
|
|
5221
5367
|
const armed = deleteArmed === e.id
|
|
5222
5368
|
const selection = chosenIds()
|
|
@@ -5225,6 +5371,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5225
5371
|
.split('{candidate}').join(String(Number(hits.candidate) || 0))
|
|
5226
5372
|
.split('{injection}').join(String(Number(hits.injection) || 0))
|
|
5227
5373
|
.split('{query}').join(String(Number(hits.query) || 0))
|
|
5374
|
+
// 聚合视图里标注词条来自哪一本(编辑抽屉头部也用同一个 helper)。
|
|
5375
|
+
const bookLabel = bookLabelOf(e)
|
|
5228
5376
|
return h('div', {
|
|
5229
5377
|
key: e.id,
|
|
5230
5378
|
style: { ...S.item, display: 'flex', flexDirection: 'column', gap: 7, minHeight: 150, ...(multi && selection.has(e.id) ? { outline: '2px solid ' + V.accent, outlineOffset: -2 } : {}) },
|
|
@@ -5233,6 +5381,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5233
5381
|
multi ? h('input', { type: 'checkbox', checked: selection.has(e.id), 'aria-label': e.term || e.id, onChange: () => toggleSelect(e.id), style: { margin: 0, accentColor: V.accent, flexShrink: 0 } }) : null,
|
|
5234
5382
|
h('strong', { style: { fontSize: 15, fontWeight: 650, lineHeight: 1.3, overflowWrap: 'anywhere', flex: '1 1 120px' } }, e.term || e.id),
|
|
5235
5383
|
h(Tag, null, enumText(t, LEXICON_KIND_LABELS, e.kind)),
|
|
5384
|
+
isAllLib && bookLabel ? h(Tag, null, bookLabel) : null,
|
|
5236
5385
|
e.sensitivity === 'sensitive' ? h(Tag, { tone: 'warn' }, t('lexiconSensitive')) : null),
|
|
5237
5386
|
h('p', { style: { margin: 0, fontSize: 12.5, lineHeight: 1.55, overflowWrap: 'anywhere', display: '-webkit-box', WebkitLineClamp: 3, WebkitBoxOrient: 'vertical', overflow: 'hidden' } },
|
|
5238
5387
|
clipText(e.meaning, 120) || '—'),
|
|
@@ -5245,10 +5394,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5245
5394
|
e.sourceMemoryId ? h(Button, {
|
|
5246
5395
|
style: { ...S.ghost, padding: '1px 7px', flexShrink: 0 },
|
|
5247
5396
|
title: t('lexiconSourceMemory'),
|
|
5248
|
-
onClick: () => onFocusMemory?.({ id: e.sourceMemoryId, libraryId: isGlobalLib ? null : activeLib, title: e.term || e.id, at: Date.now() }),
|
|
5397
|
+
onClick: () => onFocusMemory?.({ id: e.sourceMemoryId, libraryId: isAllLib ? (e.libraryId === GLOBAL_LEXICON_ID ? null : e.libraryId) : (isGlobalLib ? null : activeLib), title: e.term || e.id, at: Date.now() }),
|
|
5249
5398
|
}, t('lexiconSourceMemory')) : null),
|
|
5250
5399
|
h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' } },
|
|
5251
|
-
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => { setDeleteArmed(''); setArmedBulk(''); toggleEdit(e) } },
|
|
5400
|
+
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => { setDeleteArmed(''); setArmedBulk(''); toggleEdit(e) } }, t('lexiconEdit')),
|
|
5252
5401
|
// 归档 / 恢复是一击可逆动作;删除才要两段确认。
|
|
5253
5402
|
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => void setLifecycle(e, status === 'archived' ? 'restore' : 'archive') },
|
|
5254
5403
|
status === 'archived' ? t('lexiconRestore') : t('lexiconArchive')),
|
|
@@ -5256,8 +5405,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5256
5405
|
? h(React.Fragment, null,
|
|
5257
5406
|
h(Button, { style: { ...S.ghost, color: V.danger, borderColor: V.danger, padding: '2px 9px' }, disabled: busy, onClick: () => void deleteTerm(e) }, t('confirmDelete')),
|
|
5258
5407
|
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => setDeleteArmed('') }, t('cancelDelete')))
|
|
5259
|
-
: h(Button, { style: { ...S.ghost, color: V.danger, padding: '2px 9px' }, disabled: busy, title: t('lexiconDeleteHint'), onClick: () => { setArmedBulk(''); setDeleteArmed(e.id) } }, t('lexiconDelete')))
|
|
5260
|
-
editing ? editForm(e) : null)
|
|
5408
|
+
: h(Button, { style: { ...S.ghost, color: V.danger, padding: '2px 9px' }, disabled: busy, title: t('lexiconDeleteHint'), onClick: () => { setArmedBulk(''); setDeleteArmed(e.id) } }, t('lexiconDelete'))))
|
|
5261
5409
|
}
|
|
5262
5410
|
const selectedRows = items.filter((e) => chosenIds().has(e.id))
|
|
5263
5411
|
const multiBar = multi
|
|
@@ -5309,15 +5457,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5309
5457
|
// value 用 activeLib 而不是 libraryId:没选过也要显示真正在看的这一本
|
|
5310
5458
|
// (没有私有库时就是全局词典),否则选择器和数据会各说各话。
|
|
5311
5459
|
style: { ...S.input, flex: 1 }, value: activeLib,
|
|
5312
|
-
title: isGlobalLib ? t('lexiconGlobalScope') : (libraries.find((lib) => lib.id === activeLib)?.scopeKey || t('currentLibrary')),
|
|
5460
|
+
title: isAllLib ? t('lexiconAllScope') : isGlobalLib ? t('lexiconGlobalScope') : (libraries.find((lib) => lib.id === activeLib)?.scopeKey || t('currentLibrary')),
|
|
5313
5461
|
onChange: (e) => changeLibrary(e.target.value),
|
|
5314
5462
|
},
|
|
5463
|
+
// 「全部词典」是跨库聚合视图,与全局词典一样不是私有库;宿主拒绝多库读时禁用。
|
|
5464
|
+
h('option', { value: ALL_LEXICON_ID, disabled: allBlocked }, t('lexiconAllScope')),
|
|
5315
5465
|
h('option', { value: GLOBAL_LEXICON_ID }, t('lexiconGlobalScope')),
|
|
5316
5466
|
libraries.map((lib) => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))),
|
|
5317
5467
|
// 口径说明(样式与记忆设置页的开关说明同一款):浏览只看一本,注入与模型检索
|
|
5318
5468
|
// 按召回作用域合并——不解释清楚,用户会以为「跨库了却没看见别的库的词」。
|
|
5319
5469
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } },
|
|
5320
|
-
isGlobalLib ? t('lexiconGlobalHint') : t('lexiconBrowseScopeHint')),
|
|
5470
|
+
isAllLib ? t('lexiconAllHint') : isGlobalLib ? t('lexiconGlobalHint') : t('lexiconBrowseScopeHint')),
|
|
5321
5471
|
libraries.length === 0 ? h('div', { style: { ...S.muted, marginTop: 4 } }, t('lexiconNoLibrary')) : null,
|
|
5322
5472
|
h(React.Fragment, null, statusTabs, countsRow, filterRow, multiBar, newForm,
|
|
5323
5473
|
error && typeof error === 'string' ? h('div', { className: 'dshm-error', role: 'alert' }, error) : null,
|
|
@@ -5326,7 +5476,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5326
5476
|
? h(Empty, null, query || kind ? t('lexiconNoMatch')
|
|
5327
5477
|
: status === 'archived' ? t('lexiconArchivedEmpty') : t('lexiconEmpty'))
|
|
5328
5478
|
: h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(280px, 100%), 1fr))', gap: 10, marginTop: 10 } }, items.map(renderCard)),
|
|
5329
|
-
pager))
|
|
5479
|
+
pager)),
|
|
5480
|
+
editDrawer)
|
|
5330
5481
|
}
|
|
5331
5482
|
|
|
5332
5483
|
function SettingsPage({ ctx, t, embedded, standalone = false }) {
|
|
@@ -5734,8 +5885,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5734
5885
|
// another host process — land through the on-disk half of the marker.
|
|
5735
5886
|
const vectorWorking = !!vectorOperation || ['downloading', 'verifying', 'installing'].includes(state?.localVector?.runtime?.status || '') || Object.values(state?.localVector?.installations || {}).some(item => ['downloading', 'verifying'].includes(item.status)) || ['preparing', 'prepared', 'syncing', 'switching'].includes(state?.localVector?.vector?.pending?.status)
|
|
5736
5887
|
useMemoryBeat({ call, markerRef, onBeat: refresh, force: vectorWorking })
|
|
5737
|
-
//
|
|
5888
|
+
// 引擎体积与可安装版本只在总览页的引擎卡消费:首屏(记忆墙)不为它们
|
|
5889
|
+
// 多发两个 RPC——宿主桥接可能串行处理请求,慢一个就拖住整页首帧。
|
|
5890
|
+
// 体积要遍历 venv 目录,打开总览页后再问;安装完成后版本号变化会重问。
|
|
5738
5891
|
React.useEffect(() => {
|
|
5892
|
+
if (page !== PAGE.overview) return undefined
|
|
5739
5893
|
let alive = true
|
|
5740
5894
|
void (async () => {
|
|
5741
5895
|
try {
|
|
@@ -5744,10 +5898,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5744
5898
|
} catch {}
|
|
5745
5899
|
})()
|
|
5746
5900
|
return () => { alive = false }
|
|
5747
|
-
}, [call, state?.engine?.currentVersion])
|
|
5901
|
+
}, [call, page, state?.engine?.currentVersion])
|
|
5748
5902
|
// Ask once on open, in the background: the page paints from cached state and
|
|
5749
5903
|
// the version card fills in when PyPI answers.
|
|
5750
|
-
React.useEffect(() => { void loadVersions(false) }, [loadVersions])
|
|
5904
|
+
React.useEffect(() => { if (page === PAGE.overview) void loadVersions(false) }, [page, loadVersions])
|
|
5751
5905
|
React.useEffect(() => {
|
|
5752
5906
|
if (state?.engine?.status !== 'installing') return undefined
|
|
5753
5907
|
const id = setInterval(() => { void refreshEngine() }, 1200)
|
|
@@ -6079,7 +6233,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6079
6233
|
} catch { failed++ }
|
|
6080
6234
|
}
|
|
6081
6235
|
const rest = Math.max(0, targets.length - 5)
|
|
6082
|
-
setNotice(t('
|
|
6236
|
+
setNotice(t('consolidateStarted')
|
|
6083
6237
|
.replace('{started}', String(started))
|
|
6084
6238
|
.replace('{running}', String(running))
|
|
6085
6239
|
.replace('{failed}', String(failed))
|
|
@@ -7133,7 +7287,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7133
7287
|
h('div', { style: S.muted }, `${t('scope')}: ${lib.scopeKey || '—'}`)),
|
|
7134
7288
|
h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
|
|
7135
7289
|
h(Button, { onClick: () => restoreLibraryNow(lib.id), disabled: busy, style: S.ghost }, t('restore')),
|
|
7136
|
-
h(Button, { onClick: () => deleteLibraryNow(lib), disabled: busy, style: S.ghost }, actionLabel('library:' + lib.id, t('
|
|
7290
|
+
h(Button, { onClick: () => deleteLibraryNow(lib), disabled: busy, style: S.ghost }, actionLabel('library:' + lib.id, t('deleteLibrary'))))),
|
|
7137
7291
|
h('div', { style: S.row },
|
|
7138
7292
|
lib.scopeMissing ? h(Tag, null, t('scopeMissing')) : null,
|
|
7139
7293
|
h(Tag, null, `${t('privateCount')}: ${lib.privateCount ?? 0}`),
|
|
@@ -7434,6 +7588,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7434
7588
|
? h(Tag, { tone: 'warn' }, `${t('accuracyTag')} ${f.accuracy}`) : null,
|
|
7435
7589
|
h(Tag, null, enumText(t, STATUS_LABELS, f.status || 'active'))),
|
|
7436
7590
|
h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
|
|
7591
|
+
// 待复核条目在这里就能拍板,不必绕去全局页的复核队列;
|
|
7592
|
+
// resolution 沿用复核草稿(缺省 replace),与全局队列同一 RPC。
|
|
7593
|
+
f.status === 'pending_review'
|
|
7594
|
+
? h(Button, { onClick: () => resolveReview({ id: f.id, libraryId: browseLibId }, 'accept'), disabled: busy || browseBusy, primary: true }, t('accept'))
|
|
7595
|
+
: null,
|
|
7596
|
+
f.status === 'pending_review'
|
|
7597
|
+
? h(Button, { onClick: () => resolveReview({ id: f.id, libraryId: browseLibId }, 'reject'), disabled: busy || browseBusy, style: S.ghost }, t('reject'))
|
|
7598
|
+
: null,
|
|
7437
7599
|
h(Button, { onClick: () => saveMemory(f.id), disabled: busy || browseBusy }, t('save')),
|
|
7438
7600
|
h(Button, { onClick: () => archiveMemory(f.id), disabled: busy || browseBusy, style: S.ghost }, t('archive')))),
|
|
7439
7601
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, margin: '8px 0 4px' } },
|
|
@@ -8174,30 +8336,31 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8174
8336
|
const when = (row) => {
|
|
8175
8337
|
try { return new Date(row.at).toLocaleString([], { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) } catch { return row.at }
|
|
8176
8338
|
}
|
|
8177
|
-
const rowEl = (row, tone) => h('div', { key: row.id,
|
|
8178
|
-
h('div', {
|
|
8339
|
+
const rowEl = (row, tone) => h('div', { key: row.id, className: 'dshm-consolidation-row' },
|
|
8340
|
+
h('div', { className: 'dshm-consolidation-identity' },
|
|
8179
8341
|
h(Tag, { tone: tone === 'fail' ? 'warn' : undefined }, tone === 'fail' ? t('consolidateFailed') : t('consolidateDone')),
|
|
8180
|
-
h('span', {
|
|
8181
|
-
|
|
8342
|
+
h('span', { className: 'dshm-consolidation-label', title: label(row) }, label(row))),
|
|
8343
|
+
h('div', { className: 'dshm-consolidation-meta' },
|
|
8344
|
+
h('span', { className: 'dshm-consolidation-time' }, when(row)),
|
|
8182
8345
|
tone === 'fail' ? h(Button, {
|
|
8183
|
-
style:
|
|
8346
|
+
style: S.ghost,
|
|
8184
8347
|
title: t('consolidateJumpHint'),
|
|
8185
8348
|
onClick: () => onJump(row),
|
|
8186
8349
|
}, '↗') : null),
|
|
8187
8350
|
tone === 'fail' && row.message
|
|
8188
|
-
? h('div', {
|
|
8351
|
+
? h('div', { className: 'dshm-consolidation-message', title: row.message }, row.message)
|
|
8189
8352
|
: null)
|
|
8190
|
-
const column = (title, rows, tone) => h('div', {
|
|
8191
|
-
h('div', {
|
|
8192
|
-
h('span', {
|
|
8353
|
+
const column = (title, rows, tone) => h('div', { className: 'dshm-consolidation-column' },
|
|
8354
|
+
h('div', { className: 'dshm-consolidation-column-head' },
|
|
8355
|
+
h('span', { className: tone === 'fail' ? 'dshm-consolidation-failed' : undefined }, title),
|
|
8193
8356
|
tone === 'fail' && failures.length > 0 ? h(Button, {
|
|
8194
|
-
style:
|
|
8357
|
+
style: S.ghost,
|
|
8195
8358
|
title: t('consolidateClearHint'),
|
|
8196
8359
|
onClick: onClear,
|
|
8197
8360
|
}, t('consolidateClear')) : null),
|
|
8198
8361
|
rows.length === 0
|
|
8199
8362
|
? h('div', { style: S.muted }, '—')
|
|
8200
|
-
: h('div', {
|
|
8363
|
+
: h('div', { className: 'dshm-consolidation-rows' }, rows.map(row => rowEl(row, tone))))
|
|
8201
8364
|
const latest = failures.length > 0 ? failures[0] : successes[0]
|
|
8202
8365
|
const latestTone = failures.length > 0 ? 'fail' : 'ok'
|
|
8203
8366
|
const head = h('button', {
|
|
@@ -8205,18 +8368,18 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8205
8368
|
'aria-expanded': open,
|
|
8206
8369
|
title: open ? t('consolidateCollapse') : t('consolidateExpand'),
|
|
8207
8370
|
onClick: () => setOpen(v => !v),
|
|
8208
|
-
|
|
8371
|
+
className: 'dshm-consolidation-head',
|
|
8209
8372
|
},
|
|
8210
|
-
h('span', {
|
|
8373
|
+
h('span', { className: 'dshm-consolidation-title' }, t('consolidateFeedTitle')),
|
|
8211
8374
|
failures.length > 0 ? h(Tag, { tone: 'warn' }, t('consolidateFailedCount').replace('{n}', String(failures.length))) : null,
|
|
8212
|
-
h('span', {
|
|
8213
|
-
return h('div', {
|
|
8375
|
+
h('span', { className: 'dshm-consolidation-toggle' }, open ? t('consolidateCollapse') : t('consolidateExpand')))
|
|
8376
|
+
return h('div', { className: 'dshm-consolidation', role: 'status' },
|
|
8214
8377
|
head,
|
|
8215
8378
|
open
|
|
8216
|
-
? h('div', {
|
|
8379
|
+
? h('div', { className: 'dshm-consolidation-columns' },
|
|
8217
8380
|
column(t('consolidateFailedCol'), failures, 'fail'),
|
|
8218
8381
|
column(t('consolidateOkCol'), successes, 'ok'))
|
|
8219
|
-
: h('div', {
|
|
8382
|
+
: h('div', { className: 'dshm-consolidation-latest' }, rowEl(latest, latestTone)))
|
|
8220
8383
|
}
|
|
8221
8384
|
|
|
8222
8385
|
function MemoryTab({ ctx, t, sessionId }) {
|
|
@@ -8665,7 +8828,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8665
8828
|
const list = useSessionList(ctx)
|
|
8666
8829
|
const call = useRpc(ctx)
|
|
8667
8830
|
const decided = React.useRef(new Set())
|
|
8668
|
-
|
|
8831
|
+
// 已见过的空白会话即使抢先发了消息,也不能丢失尚未作答的询问。
|
|
8832
|
+
const pending = React.useRef(new Set())
|
|
8833
|
+
const visited = React.useRef(null)
|
|
8834
|
+
const deferred = React.useRef(null)
|
|
8835
|
+
const failures = React.useRef(new Map())
|
|
8669
8836
|
const [prompt, setPrompt] = React.useState(null)
|
|
8670
8837
|
const [choice, setChoice] = React.useState('auto')
|
|
8671
8838
|
// The card picks the layers; this only picks *which* library carries them.
|
|
@@ -8687,56 +8854,56 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8687
8854
|
const summaryBlank = summary?.blank
|
|
8688
8855
|
const summaryOrigin = summary?.origin
|
|
8689
8856
|
|
|
8857
|
+
const hasSummary = Boolean(summary)
|
|
8858
|
+
const promptSessionId = prompt?.sessionId
|
|
8859
|
+
|
|
8690
8860
|
React.useEffect(() => {
|
|
8691
|
-
if (
|
|
8692
|
-
|
|
8861
|
+
if (visited.current !== current) {
|
|
8862
|
+
visited.current = current
|
|
8863
|
+
deferred.current = null
|
|
8864
|
+
failures.current.delete(current)
|
|
8865
|
+
}
|
|
8866
|
+
if (!current || !hasSummary) return
|
|
8693
8867
|
if (summaryOrigin === 'subagent') { decided.current.add(current); return }
|
|
8694
|
-
if (summaryBlank ===
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8868
|
+
if (summaryBlank === true) pending.current.add(current)
|
|
8869
|
+
if (deferred.current === current || decided.current.has(current)) return
|
|
8870
|
+
if (summaryBlank === false && !pending.current.has(current)) {
|
|
8871
|
+
decided.current.add(current)
|
|
8872
|
+
return
|
|
8873
|
+
}
|
|
8874
|
+
if (!summaryCwd || promptSessionId === current) return
|
|
8700
8875
|
let cancelled = false
|
|
8701
|
-
|
|
8876
|
+
let retryTimer = null
|
|
8877
|
+
const check = async () => {
|
|
8878
|
+
if (cancelled) return
|
|
8702
8879
|
try {
|
|
8703
8880
|
const st = await call('getSessionPromptState', { sessionId: current, cwd: summaryCwd })
|
|
8704
8881
|
if (cancelled) return
|
|
8705
|
-
if (st.binding) {
|
|
8706
|
-
// A binding left over from the pre-folder build still says
|
|
8707
|
-
// Default/__default__. The conversation summary now carries the real
|
|
8708
|
-
// cwd, so repair the name in place instead of leaving the wrong label.
|
|
8709
|
-
if (st.binding.scopeKey === '__default__' && summaryCwd) {
|
|
8710
|
-
await call('initSession', { sessionId: current, cwd: summaryCwd, createLibrary: false })
|
|
8711
|
-
}
|
|
8712
|
-
decided.current.add(current)
|
|
8713
|
-
return
|
|
8714
|
-
}
|
|
8715
|
-
// The folder already said no to both layers, so there is nothing to
|
|
8716
|
-
// ask: bind silently with nothing enabled and no library created
|
|
8717
|
-
// (T5 — this is the bug where the prompt kept appearing for a folder
|
|
8718
|
-
// whose memory was switched off).
|
|
8719
|
-
if (st.shouldPrompt === false) {
|
|
8882
|
+
if (st.binding?.scopeKey === '__default__') {
|
|
8720
8883
|
await call('initSession', { sessionId: current, cwd: summaryCwd, createLibrary: false })
|
|
8721
|
-
|
|
8884
|
+
if (cancelled) return
|
|
8885
|
+
}
|
|
8886
|
+
if (st.binding?.domainSource === 'chosen') {
|
|
8887
|
+
failures.current.delete(current)
|
|
8722
8888
|
decided.current.add(current)
|
|
8723
8889
|
return
|
|
8724
8890
|
}
|
|
8725
|
-
if (st.settings?.newSessionPromptDismissed) {
|
|
8726
|
-
// "Don't ask again" must actually honor the remembered choice.
|
|
8727
|
-
// Writing only one of the two layers (or, as this branch used to,
|
|
8728
|
-
// only the library) let the folder policy fill the missing switch,
|
|
8729
|
-
// so the remembered answer was not the answer the sidebar showed.
|
|
8891
|
+
if (st.shouldPrompt === false || st.settings?.newSessionPromptDismissed) {
|
|
8730
8892
|
const card = CARD_OF[String(st.settings?.newSessionDefault || 'both')] || 'both'
|
|
8731
|
-
const layers = LAYERS_OF[card]
|
|
8893
|
+
const layers = st.shouldPrompt === false ? LAYERS_OF.none : LAYERS_OF[card]
|
|
8732
8894
|
await call('initSession', { sessionId: current, cwd: summaryCwd, createLibrary: layers.useLibrary })
|
|
8895
|
+
if (cancelled) return
|
|
8733
8896
|
await call('setSessionScope', { sessionId: current, ...layers })
|
|
8897
|
+
if (cancelled) return
|
|
8898
|
+
failures.current.delete(current)
|
|
8734
8899
|
decided.current.add(current)
|
|
8735
8900
|
return
|
|
8736
8901
|
}
|
|
8902
|
+
failures.current.delete(current)
|
|
8903
|
+
setError('')
|
|
8737
8904
|
setPrompt({
|
|
8738
8905
|
sessionId: current,
|
|
8739
|
-
cwd: summaryCwd
|
|
8906
|
+
cwd: summaryCwd,
|
|
8740
8907
|
libraries: (st.libraries || []).filter((l) => l.scopeKey !== '__default__'),
|
|
8741
8908
|
domains: Array.isArray(st.domains) && st.domains.length ? st.domains : ['rp', 'coding', 'general', 'mixed'],
|
|
8742
8909
|
folder: st.folder || null,
|
|
@@ -8747,14 +8914,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8747
8914
|
setDomain('rp')
|
|
8748
8915
|
setLibraryId((st.libraries || []).find((l) => l.scopeKey !== '__default__')?.id || '')
|
|
8749
8916
|
} catch (e) {
|
|
8750
|
-
if (
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8917
|
+
if (cancelled) return
|
|
8918
|
+
const count = (failures.current.get(current)?.count || 0) + 1
|
|
8919
|
+
const delay = Math.min(30_000, 1_000 * 2 ** Math.min(count - 1, 5))
|
|
8920
|
+
failures.current.set(current, { count, retryAt: Date.now() + delay })
|
|
8921
|
+
setError(String(e?.message || e))
|
|
8922
|
+
retryTimer = setTimeout(check, delay)
|
|
8923
|
+
void call('logClientEvent', { sessionId: current, kind: 'error', message: '新会话记忆询问检查失败,将自动重试', detail: String(e?.message || e) }).catch(() => {})
|
|
8754
8924
|
}
|
|
8755
|
-
}
|
|
8756
|
-
|
|
8757
|
-
|
|
8925
|
+
}
|
|
8926
|
+
const delay = Math.max(0, (failures.current.get(current)?.retryAt || 0) - Date.now())
|
|
8927
|
+
if (delay) retryTimer = setTimeout(check, delay)
|
|
8928
|
+
else void check()
|
|
8929
|
+
return () => { cancelled = true; clearTimeout(retryTimer) }
|
|
8930
|
+
}, [current, hasSummary, summaryCwd, summaryBlank, summaryOrigin, promptSessionId, call])
|
|
8758
8931
|
|
|
8759
8932
|
const confirm = async () => {
|
|
8760
8933
|
if (!prompt) return
|
|
@@ -8812,11 +8985,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8812
8985
|
} catch (e) {
|
|
8813
8986
|
setError(String(e?.message || e))
|
|
8814
8987
|
}
|
|
8815
|
-
|
|
8988
|
+
// 宿主复用空白会话;“稍后”只在本次停留期间抑制询问。
|
|
8989
|
+
deferred.current = prompt.sessionId
|
|
8816
8990
|
setPrompt(null)
|
|
8817
8991
|
}
|
|
8818
8992
|
|
|
8819
|
-
if (!prompt) return null
|
|
8993
|
+
if (!prompt || prompt.sessionId !== current) return null
|
|
8820
8994
|
const libraries = prompt.libraries || []
|
|
8821
8995
|
const folder = prompt.folder || null
|
|
8822
8996
|
const privateBlocked = folder ? folder.useLibrary === false : false
|