dsh-memu-memory 1.2.1 → 1.2.3
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 +3 -1
- package/README.md +23 -8
- package/README.zh.md +16 -6
- package/docs/client-conventions.md +1 -0
- package/docs/contributing.md +18 -4
- package/docs/emotion-model-spec.md +2 -2
- package/docs/env-and-commands.md +20 -0
- package/docs/host-api.md +22 -1
- package/docs/memory-semantics.md +30 -2
- package/docs/troubleshooting.md +76 -5
- package/lib/activity-log.js +1 -1
- package/lib/backup.js +24 -2
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +1511 -153
- package/lib/consolidation-worker.js +30 -8
- package/lib/curator-evidence.js +131 -0
- package/lib/curator-policy.js +81 -0
- package/lib/curator.js +1252 -91
- package/lib/cycle.js +12 -1
- package/lib/embedding-download.js +39 -4
- package/lib/engine.js +6 -3
- package/lib/freshness.js +97 -0
- package/lib/global-graph.js +282 -0
- package/lib/graph.js +295 -11
- package/lib/inbound.js +19 -0
- package/lib/inject.js +396 -25
- package/lib/lexicon.js +1115 -0
- package/lib/local-vector-service.js +8 -6
- package/lib/managed-runtime.js +33 -2
- package/lib/memory.js +365 -34
- package/lib/memu.js +2 -2
- package/lib/migrate.js +83 -2
- package/lib/private-links.js +587 -0
- package/lib/private.js +32 -3
- package/lib/prompts/global-curator.md +76 -19
- package/lib/prompts/private-consolidation.coding.md +4 -1
- package/lib/prompts/private-consolidation.md +3 -1
- package/lib/prompts/private-consolidation.mixed.md +3 -1
- package/lib/prompts/private-consolidation.rp.md +3 -1
- package/lib/prompts.js +1 -1
- package/lib/rpc.js +589 -10
- package/lib/salient-wake.js +402 -0
- package/lib/state.js +95 -1
- package/lib/text-retrieval.js +661 -0
- package/lib/text-similarity.js +36 -18
- package/lib/tools.js +168 -10
- package/lib/webui/standalone.css +17 -0
- package/lib/webui/standalone.js +2 -0
- package/package.json +1 -1
- package/scripts/acceptance-local.mjs +8 -5
- package/scripts/curator-pair-calibrate.mjs +259 -0
- package/scripts/drive-session.mjs +853 -0
- package/scripts/lexicon-calibrate.mjs +230 -0
- package/scripts/lexicon-dedupe.mjs +318 -0
- package/scripts/mock-llm.mjs +903 -0
- package/tests/absorb-review.test.mjs +353 -0
- package/tests/appendix-b2.test.mjs +2 -2
- package/tests/client-export.test.mjs +520 -0
- package/tests/client-render.test.mjs +32 -4
- package/tests/consolidation-fork.test.mjs +14 -12
- package/tests/consolidation-snapshot.test.mjs +39 -0
- package/tests/curator-absorb.test.mjs +443 -0
- package/tests/curator-calibrate.test.mjs +173 -0
- package/tests/curator-clusters.test.mjs +281 -0
- package/tests/curator-commit.test.mjs +52 -5
- package/tests/curator-evidence.test.mjs +102 -0
- package/tests/curator-link.test.mjs +316 -0
- package/tests/curator-pairing.test.mjs +252 -0
- package/tests/curator-probe.test.mjs +15 -6
- package/tests/curator-review-mode.test.mjs +314 -0
- package/tests/disclosure.test.mjs +2 -1
- package/tests/entity-merge.test.mjs +261 -0
- package/tests/fixtures/curator-pairs/labeled.v1.jsonl +90 -0
- package/tests/fixtures/lexicon-stub-hooks.mjs +15 -0
- package/tests/fixtures/lexicon-stub.mjs +284 -0
- package/tests/fixtures/mock-llm/reply.txt +1 -0
- package/tests/freshness.test.mjs +140 -0
- package/tests/graph-cascade.test.mjs +35 -2
- package/tests/graph.test.mjs +96 -0
- package/tests/help-page.test.mjs +415 -0
- package/tests/inbound.test.mjs +6 -3
- package/tests/inject-guide.test.mjs +28 -0
- package/tests/inject.test.mjs +157 -5
- package/tests/injection-chain.test.mjs +176 -0
- package/tests/lexicon-calibrate.test.mjs +48 -0
- package/tests/lexicon-dedupe.test.mjs +171 -0
- package/tests/lexicon-frequency.test.mjs +179 -0
- package/tests/lexicon-inject.test.mjs +410 -0
- package/tests/lexicon-perf.test.mjs +436 -0
- package/tests/lexicon-ui.test.mjs +547 -0
- package/tests/lexicon.test.mjs +922 -0
- package/tests/managed-runtime.test.mjs +32 -0
- package/tests/mock-llm.test.mjs +225 -0
- package/tests/open-loop-date.test.mjs +406 -0
- package/tests/private-links.test.mjs +445 -0
- package/tests/prompts.test.mjs +35 -0
- package/tests/recall-dedup.test.mjs +33 -4
- package/tests/salient-wake.test.mjs +362 -0
- package/tests/settings-plumbing.test.mjs +76 -0
- package/tests/sidebar.test.mjs +5 -1
- package/tests/stubs/dsh-schedule.js +105 -0
- package/tests/tool-schema.test.mjs +1 -1
- package/tests/tools.test.mjs +112 -3
- package/tests/webui-auth.test.mjs +352 -2
- package/tests/webui.test.mjs +188 -0
package/lib/client.js
CHANGED
|
@@ -8,7 +8,7 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
const exports = module.exports
|
|
9
9
|
|
|
10
10
|
const NS = 'dsh-memu-memory'
|
|
11
|
-
const SETTINGS_PAGES = ['engine', 'connection', 'settings', 'folders', 'libraries', 'browser', 'global', 'prompts', 'stats', 'memories', 'logs']
|
|
11
|
+
const SETTINGS_PAGES = ['engine', 'connection', 'settings', 'folders', 'libraries', 'browser', 'global', 'prompts', 'stats', 'memories', 'logs', 'lexicon', 'help']
|
|
12
12
|
const EMPTY_SESSIONS = Object.freeze({ byId: Object.freeze({}), ids: Object.freeze([]) })
|
|
13
13
|
const TAB_ID = `${NS}:memory`
|
|
14
14
|
const TAB_KIND = 'dsh-memu-memory'
|
|
@@ -132,9 +132,11 @@ window.__ModuleLoader__.load({
|
|
|
132
132
|
logKindError: '错误',
|
|
133
133
|
logKindSystem: '系统',
|
|
134
134
|
logKindCheck: '主动检查',
|
|
135
|
+
logKindWake: '日期唤醒',
|
|
135
136
|
logClear: '清空日志',
|
|
136
137
|
runLogTitle: '整理记录',
|
|
137
138
|
runLogEmpty: '还没有整理记录。',
|
|
139
|
+
runLogOpen: '全部日志',
|
|
138
140
|
dedupedNotice: '未写入:库里已有几乎相同的记忆 [{id}]。要补充内容请在原条目上编辑合并;确属两次独立观测时才需要 allow_duplicate 重写。',
|
|
139
141
|
consolidateFeedTitle: '整理提醒',
|
|
140
142
|
consolidateFailedCol: '失败',
|
|
@@ -149,6 +151,9 @@ window.__ModuleLoader__.load({
|
|
|
149
151
|
consolidateClearHint: '只删除失败的整理日志;成功记录与其它日志不动',
|
|
150
152
|
consolidateCleared: '已清除 {n} 条失败记录',
|
|
151
153
|
allLibraries: '全部记忆库',
|
|
154
|
+
wallAllBlocked: '当前宿主只允许单库读取,已显示第一个记忆库',
|
|
155
|
+
linkCountTag: '关联 {n}',
|
|
156
|
+
linkRemoved: '关联已移除',
|
|
152
157
|
searchMemories: '搜索标题、内容或标签',
|
|
153
158
|
poolReview: '待复核',
|
|
154
159
|
poolInactive: '已失效',
|
|
@@ -156,6 +161,10 @@ window.__ModuleLoader__.load({
|
|
|
156
161
|
wallLimit: '仅展示最近 300 条',
|
|
157
162
|
wallScopePrivate: '私有',
|
|
158
163
|
wallScopeGlobal: '全局',
|
|
164
|
+
wallFilterScope: '范围',
|
|
165
|
+
wallFilterStatus: '状态',
|
|
166
|
+
wallFilterLayer: '层级',
|
|
167
|
+
wallAllLayers: '全部层级',
|
|
159
168
|
multiSelect: '多选',
|
|
160
169
|
wallSelected: '已选 {n} 条',
|
|
161
170
|
wallSelectAll: '全选本页',
|
|
@@ -164,6 +173,15 @@ window.__ModuleLoader__.load({
|
|
|
164
173
|
viewMemory: '查看此记忆',
|
|
165
174
|
entityDelete: '删除实体',
|
|
166
175
|
entityDeleteForceHint: '仍被记忆或关系引用;再点一次将连同引用一起删除',
|
|
176
|
+
entityMergeTitle: '合并候选',
|
|
177
|
+
entityMergeHint: '写法相近的实体只是建议,不会自动合并。合并后来源实体的记忆链接改指主节点,别名并入,来源实体消失;记忆本身不删除。',
|
|
178
|
+
entityMergeAction: '合并',
|
|
179
|
+
entityMergeConfirm: '确认合并',
|
|
180
|
+
entityMergeDone: '已把「{from}」并入「{to}」:{links} 条记忆链接改指,别名共 {aliases} 个',
|
|
181
|
+
entityMergeDropped: '({n} 个别名超出上限,未并入)',
|
|
182
|
+
entityMergeConflict: '({n} 条关系快照与主节点侧冲突,保留主节点侧)',
|
|
183
|
+
mergeReasonContainment: '名称包含',
|
|
184
|
+
mergeReasonDistance: '写法相近',
|
|
167
185
|
openMemu: '打开 MemU WebUI',
|
|
168
186
|
saved: '已保存',
|
|
169
187
|
copied: '已复制',
|
|
@@ -185,7 +203,17 @@ window.__ModuleLoader__.load({
|
|
|
185
203
|
characterId: '当前角色 ID',
|
|
186
204
|
worldId: '世界线 ID',
|
|
187
205
|
branchId: '剧情分支 ID',
|
|
188
|
-
|
|
206
|
+
exportZip: '导出 ZIP(含图片)',
|
|
207
|
+
exportStarted: '已开始导出:{file}',
|
|
208
|
+
memorySaved: '记忆已保存',
|
|
209
|
+
memoryArchived: '记忆已归档',
|
|
210
|
+
memoryRestored: '记忆已恢复',
|
|
211
|
+
memoryDeleted: '记忆已删除',
|
|
212
|
+
bulkDone: '批量操作完成:{n} 条',
|
|
213
|
+
curatorReview: '全局记忆审核',
|
|
214
|
+
descCuratorReview: '控制全局提炼的写入方式:自动模式只暂扣冲突、缺证据与高风险改写;全部待审把每个内容改动都送进复核队列。',
|
|
215
|
+
curatorReviewAuto: '自动(默认)',
|
|
216
|
+
curatorReviewAll: '全部待审',
|
|
189
217
|
archiveTooLarge: '附件包超过单次导入上限(16 MB),请拆分',
|
|
190
218
|
openSettings: '打开设置页',
|
|
191
219
|
sidebarSettings: '在侧边栏保留完整设置',
|
|
@@ -196,7 +224,7 @@ window.__ModuleLoader__.load({
|
|
|
196
224
|
adjacency: '邻接列表',
|
|
197
225
|
graphView: '关系图',
|
|
198
226
|
viewMemories: '记忆',
|
|
199
|
-
viewRelations: '
|
|
227
|
+
viewRelations: '节点图',
|
|
200
228
|
close: '关闭',
|
|
201
229
|
openInBrowser: '在记忆浏览中打开',
|
|
202
230
|
globalReadOnly: '全局记忆在这里只读;需要修改请去全局记忆页。',
|
|
@@ -215,6 +243,7 @@ window.__ModuleLoader__.load({
|
|
|
215
243
|
entityAliases: '别名(逗号分隔)',
|
|
216
244
|
entityKind: '实体类型',
|
|
217
245
|
graphEmpty: '还没有关联',
|
|
246
|
+
graphAutoLink: '自动',
|
|
218
247
|
deletedNode: '[已删除]',
|
|
219
248
|
graphLimited: '仅显示最多 200 个节点',
|
|
220
249
|
graphFit: '适应全图',
|
|
@@ -251,6 +280,16 @@ window.__ModuleLoader__.load({
|
|
|
251
280
|
globalEveryNTurns: '全局每 N 轮',
|
|
252
281
|
minUserChars: '最短用户消息',
|
|
253
282
|
randomCueChance: '随机侧事件概率',
|
|
283
|
+
openLoopRemindDays: '未了之事复提间隔(天)',
|
|
284
|
+
freshnessHint: '时效提示',
|
|
285
|
+
freshnessDays: '写够多久算过时(天)',
|
|
286
|
+
freshnessHintHint: '召回里有条目带时间敏感信号时,在块尾提示模型先核实再回答「现在怎样」。',
|
|
287
|
+
salientWake: '日期到点唤醒',
|
|
288
|
+
salientWakeOff: '关闭(只被动注入)',
|
|
289
|
+
salientWakeSchedule: '到点唤醒会话',
|
|
290
|
+
salientWakeHour: '唤醒时间(HH:mm)',
|
|
291
|
+
salientWakeTimeZone: '唤醒时区(留空跟随系统)',
|
|
292
|
+
salientWakeHint: '实验特性,默认关闭。唤醒走宿主定时任务投递,会替会话开一整轮;只有宿主进程活着才会触发,任务在宿主的定时任务界面可见、可手动删除。还没做过真机验收,建议先在测试库里试开。',
|
|
254
293
|
autoInstall: '自动安装引擎',
|
|
255
294
|
sleepConsolidation: '空闲后整理记忆',
|
|
256
295
|
sleepAfterIdleMinutes: '空闲多久后整理(分钟)',
|
|
@@ -293,9 +332,23 @@ window.__ModuleLoader__.load({
|
|
|
293
332
|
salientDateLabel: '日期(MM-DD 每年复现,YYYY-MM-DD 一次性)',
|
|
294
333
|
salientDatePlaceholder: '例如 10-29 或 2026-10-29,留空则不设日期',
|
|
295
334
|
moodTag: '情绪',
|
|
335
|
+
arousalLabel: '激活',
|
|
336
|
+
dominanceLabel: '掌控',
|
|
337
|
+
emotionSourceLabel: '来源',
|
|
338
|
+
emotionSourceModel: '模型标注',
|
|
339
|
+
emotionSourceSession: '会话心情',
|
|
340
|
+
emotionSourceContent: '正文识别',
|
|
341
|
+
emotionSourceUnknown: '未知',
|
|
296
342
|
reviews: '待复核',
|
|
297
343
|
reviewsEmpty: '没有等待复核的记忆。',
|
|
298
344
|
reviewScopePrivate: '私有库',
|
|
345
|
+
// 包 F2:集合吸收(absorb)复核与撤销。
|
|
346
|
+
absorbTag: '集合吸收 · {n} 条',
|
|
347
|
+
absorbSourcesTag: '集合记忆 · {n} 条来源',
|
|
348
|
+
absorbUndo: '撤销合并',
|
|
349
|
+
absorbUndone: '已撤销合并,来源记忆已恢复',
|
|
350
|
+
absorbSourcesLabel: '吸收来源',
|
|
351
|
+
absorbLinksLabel: '关联记忆',
|
|
299
352
|
accuracyTag: '细节未必准',
|
|
300
353
|
accept: '接受',
|
|
301
354
|
reject: '丢弃',
|
|
@@ -633,7 +686,172 @@ window.__ModuleLoader__.load({
|
|
|
633
686
|
rememberChoice: '记住我的选择,下次新对话直接用',
|
|
634
687
|
confirm: '确定',
|
|
635
688
|
later: '稍后',
|
|
689
|
+
// —— 词典页 ——
|
|
690
|
+
pageLexicon: '词典',
|
|
691
|
+
descLexicon: '每个记忆库一本词典:黑话、梗、触发词与术语的释义、归档与命中统计。',
|
|
692
|
+
lexiconScope: '词条管理',
|
|
693
|
+
lexiconNoLibrary: '还没有记忆库;词典随私有记忆库创建。',
|
|
694
|
+
lexiconTotal: '共 {total} 条',
|
|
695
|
+
lexiconTerm: '词条',
|
|
696
|
+
lexiconKind: '类型',
|
|
697
|
+
lexiconAllKinds: '全部类型',
|
|
698
|
+
lexiconKindSlang: '黑话',
|
|
699
|
+
lexiconKindMeme: '梗',
|
|
700
|
+
lexiconKindTrigger: '触发词',
|
|
701
|
+
lexiconKindTerm: '术语',
|
|
702
|
+
lexiconMeaning: '释义',
|
|
703
|
+
lexiconUsage: '用法',
|
|
704
|
+
lexiconAliases: '别名(逗号分隔)',
|
|
705
|
+
lexiconExamples: '例句(每行一条)',
|
|
706
|
+
lexiconSensitivity: '敏感度',
|
|
707
|
+
lexiconSensitivityAll: '全部敏感度',
|
|
708
|
+
lexiconNormal: '普通',
|
|
709
|
+
lexiconSensitive: '敏感',
|
|
710
|
+
lexiconStatus: '状态',
|
|
711
|
+
lexiconAllStatus: '全部状态',
|
|
712
|
+
lexiconStPending: '待审',
|
|
713
|
+
lexiconStRejected: '已驳回',
|
|
714
|
+
lexiconPending: '待审',
|
|
715
|
+
lexiconApprove: '通过',
|
|
716
|
+
lexiconReject: '驳回',
|
|
717
|
+
lexiconHits: '命中次数',
|
|
718
|
+
lexiconStrength: '强度',
|
|
719
|
+
lexiconSourceMemory: '来源记忆 ↗',
|
|
720
|
+
lexiconSearch: '搜索词条 / 释义 / 别名',
|
|
721
|
+
lexiconNew: '新建词条',
|
|
722
|
+
lexiconCreate: '写入词典',
|
|
723
|
+
lexiconEdit: '编辑词条',
|
|
724
|
+
lexiconSaveDone: '词条已保存。',
|
|
725
|
+
lexiconReviewDone: '审核完成。',
|
|
726
|
+
lexiconAddDone: '词条已写入。',
|
|
727
|
+
lexiconDelete: '删除词条',
|
|
728
|
+
lexiconDeleteHint: '删除是永久的:先点一下「删除词条」,再点「确认删除」。',
|
|
729
|
+
lexiconDeleted: '已删除 {n} 条词条。',
|
|
730
|
+
lexiconPrev: '上一页',
|
|
731
|
+
lexiconNext: '下一页',
|
|
732
|
+
lexiconPageOf: '第 {page} / {pages} 页',
|
|
733
|
+
lexiconEmpty: '这个词库还没有词条。',
|
|
734
|
+
lexiconNoMatch: '没有匹配的词条。',
|
|
735
|
+
lexiconTabActive: '使用中 ({n})',
|
|
736
|
+
lexiconTabArchived: '已归档 ({n})',
|
|
737
|
+
lexiconArchivedEmpty: '没有已归档的词条。',
|
|
738
|
+
lexiconArchive: '归档',
|
|
739
|
+
lexiconRestore: '恢复',
|
|
740
|
+
lexiconArchiveDone: '词条已归档,可随时恢复。',
|
|
741
|
+
lexiconRestoreDone: '词条已恢复。',
|
|
742
|
+
lexiconArchivedCount: '已归档 {n} 条词条。',
|
|
743
|
+
lexiconRestoredCount: '已恢复 {n} 条词条。',
|
|
744
|
+
lexiconCardUsage: '用法',
|
|
745
|
+
lexiconCardAliases: '别名',
|
|
636
746
|
loading: '加载中…',
|
|
747
|
+
// ── 包 C/D/E 新增键(词典提案态 + 实体可见性 + 帮助页)──
|
|
748
|
+
lexiconProposal: '提案',
|
|
749
|
+
lexiconPendingEmpty: '没有待审的词条提案。',
|
|
750
|
+
lexiconHitsDetail: '命中明细:候选 {candidate} · 注入 {injection} · 查询 {query}',
|
|
751
|
+
orphanEntities: '未关联实体 ({n})',
|
|
752
|
+
orphanPruneHint: '这些实体没有被任何记忆或关系引用,插件下次启动时会自动清理。',
|
|
753
|
+
entityEmpty: '这个词库还没有实体。',
|
|
754
|
+
firstRunTitle: '先建一个记忆库',
|
|
755
|
+
firstRunDesc: '还没有任何记忆库。新建一个私有库后,会话里的记忆才有地方落。',
|
|
756
|
+
firstRunGoLibraries: '去新建库',
|
|
757
|
+
firstRunGuide: '查看快速上手',
|
|
758
|
+
pageHelp: '帮助',
|
|
759
|
+
descHelp: '快速上手、作用域/标注说明、常见问题与反馈入口',
|
|
760
|
+
helpQuickStart: '快速开始',
|
|
761
|
+
helpGoTo: '前往 →',
|
|
762
|
+
helpStep1: '新建一个私有库:在「记忆库」页新建。成功时列表里出现当前项目的库,文件夹页也能看到它。',
|
|
763
|
+
helpStep2: '在会话里绑定库:在对话中让助手调用 memu_bind(或发送 /memu 绑定),或在新会话卡里选定作用域。成功后侧栏会话卡显示已绑定这个库。',
|
|
764
|
+
helpStep3: '选择注入模式:在设置的「注入模式」里选 smart(按需)/ anchor-only(只锚点)/ per-turn(每轮)/ off(关闭)。成功时状态卡显示已选模式,下一轮按它注入。',
|
|
765
|
+
helpStep4: '在记忆页确认与修正:MemU 记忆页列出召回与写入的条目。点开抽屉看全文、改错字、归档不需要的内容;成功时改动立即生效。',
|
|
766
|
+
helpStep5: '在词典页维护黑话:AI 写入的词条会自动 active 并参与注入;你可以编辑、归档/恢复、彻底删除,sensitive trigger 只能由你添加或修改。成功时词条出现在「使用中」,归档的进入「已归档」可恢复。',
|
|
767
|
+
helpScopes: '私有与全局怎么判断',
|
|
768
|
+
helpScopesDesc: '先看文件夹上限,再看本会话开关,最后得到生效作用域。',
|
|
769
|
+
helpScopesChain: '判断顺序:工作区 → 文件夹策略(useLibrary / useGlobal 上限)→ 会话绑定(实际开关)→ effectiveScope。文件夹是天花板,会话只能在天花板以内生效。',
|
|
770
|
+
helpScopesPrivate: '私有 = 本文件夹内所有会话共享同一个库:换对话仍读同一份,写入对所有会话可见,可编辑、归档与恢复。',
|
|
771
|
+
helpScopesGlobal: '全局 = curator 在后台跨会话整理写入,按 domain 与 applies_to 过滤;界面上只读,只能复核、撤销合并或移除链接,不能手改正文。',
|
|
772
|
+
helpScopesWhere: '在哪里改:文件夹页设上限;侧栏会话卡设本对话开关;全局页只审阅。',
|
|
773
|
+
helpScopesPitfallsTitle: '常见误区',
|
|
774
|
+
helpScopesPitfall1: '文件夹关掉全局后,会话无法再打开它——上限优先,开关会显示为禁用。',
|
|
775
|
+
helpScopesPitfall2: '只开全局、不开私有的对话没有私有库,私有记忆工具会明确报错而不是凭空建库。',
|
|
776
|
+
helpScopesPitfall3: '条目带上下文(频道/角色/世界线/分支/knownBy)时,不匹配的会话看不到它;这是过滤,不是丢失。',
|
|
777
|
+
helpTitleCards: '标题卡与召回',
|
|
778
|
+
helpTitleCardsBody: '锚点与本回合召回只显示标题卡:标题、标签和 id,正文不注入;全文仍在记忆页抽屉与召回工具里。',
|
|
779
|
+
helpTitleCardsRecall: '标题是目录:用标题关键词,或标题卡里方括号内的 id 调 memu_private_recall / memu_global_recall,工具返回仍是全文。',
|
|
780
|
+
helpTitleCardsRule: '标题写作:8–40 字,写具体的人/物/事件或结论(如「Yuike 名字来自小时候的白猫」),不要空标题或「关于XX的事」;细节放进 content。',
|
|
781
|
+
helpArchiveDelete: '归档、删除与撤回',
|
|
782
|
+
helpArchiveDeleteArchive: '归档 = 软删除:随时可恢复,关系与链接保留,不级联;条目移到「已归档」页签,不再注入。',
|
|
783
|
+
helpArchiveDeleteDelete: '彻底删除:界面只对已归档条目开放,需两段确认,永久且不可撤销;会级联清掉指向它的入边,并清理因此孤立的实体。',
|
|
784
|
+
helpArchiveDeleteLexicon: '词典同口径:归档可恢复,删除永久;模型没有删除或复核路径,sensitive 词条只有用户能改。',
|
|
785
|
+
helpArchiveDeleteAbsorb: '合并(absorb):合并稿成为新 active,目标标记 superseded,来源归档;在全局页对合并稿点「撤销合并」可整体撤回,全局链接也可逐条移除。',
|
|
786
|
+
helpArchiveDeleteSessionGone: '删除的对话不会触发整理失败:扫描会标记 sessionGone 并跳过,不反复重试。',
|
|
787
|
+
helpVector: '向量库',
|
|
788
|
+
helpVectorSetup: 'memoryBackend=api + vectorSource=local 表示:MemU 负责存储与检索,本地受管 embedding 模型提供向量。到「连接与向量」选本地来源,并在同页的受管向量区下载运行时与模型,就绪后切换。',
|
|
789
|
+
helpVectorCount: '「当前已入向量库 N 条」统计的是当前 active 代际里已有向量的条数;条目上的「已入向量库 · gN」是该条写入时的代际标签。',
|
|
790
|
+
helpVectorFallback: '向量未激活(只有 requested 或重建失败)时,召回自动回退词法检索:仍然可用,只是语义匹配更弱。',
|
|
791
|
+
helpVectorRebuild: '切换模型或修复失败要重建:新代际建成前旧代际保持只读,成功后的新记忆写入新代际;失败不会改当前代际,可以再点一次续建。',
|
|
792
|
+
helpAutoLink: '私有自动关联与实体枢纽',
|
|
793
|
+
helpAutoLinkRule: "先跑算法,不额外花模型 token:同库、同上下文/轨道、可见且非 secret 的两条记忆,若共享稀有名称/别名、内容不冲突,就直接建立 memory↔memory 链接并标 source:'auto'。",
|
|
794
|
+
helpAutoLinkHub: '实体枢纽:「猫娘yuike」与「yuike名字的由来」共享 yuike,算法会复用或创建 yuike 实体,并把两条记忆连到它;人物/物品类型按保守信号推断。',
|
|
795
|
+
helpAutoLinkWorker: '拿不准的候选交给本次整理 worker(memu_private_link_suggest)带证据裁决;不会另起一次完整整理,也不重读转录;没有候选就不连。',
|
|
796
|
+
helpAutoLinkSafety: '自动关联只改图元数据:不改正文、不写向量、不删除。关系图显示「自动」标记和移除(×);实体删除仍按既有规则。',
|
|
797
|
+
helpLabels: '标注速查表',
|
|
798
|
+
helpLabelsDesc: '记忆与关系图上会出现的标记。',
|
|
799
|
+
helpLabelColLabel: '标注',
|
|
800
|
+
helpLabelColMeaning: '含义',
|
|
801
|
+
helpLabelSource: 'source',
|
|
802
|
+
helpLabelSourceMeaning: '来源:inferred 推断 / user_said 用户原话(可引用)/ told 转述 / imagined 想象。imagined 不能当事实。',
|
|
803
|
+
helpLabelLayer: 'layer',
|
|
804
|
+
helpLabelLayerMeaning: '层级:must_remember 必记 / long_term 长期 / short_term 短期指针(只给指针,不含正文)。',
|
|
805
|
+
helpLabelOpenLoop: 'open_loop',
|
|
806
|
+
helpLabelOpenLoopMeaning: '未闭环:还有承诺或悬念没交代。',
|
|
807
|
+
helpLabelMarginalized: 'marginalized',
|
|
808
|
+
helpLabelMarginalizedMeaning: '已边缘化:移出主记忆但未删除,仍可检索。',
|
|
809
|
+
helpLabelDate: 'date / anniversary',
|
|
810
|
+
helpLabelDateMeaning: '日期:date 是一次性某天;anniversary 每年重复(生日/纪念日)。',
|
|
811
|
+
helpLabelAttachment: '附件N',
|
|
812
|
+
helpLabelAttachmentMeaning: '标题卡上的附件计数,不展开 caption;正文与图片在抽屉或工具里。',
|
|
813
|
+
helpLabelVector: '已入向量库 · gN',
|
|
814
|
+
helpLabelVectorMeaning: '该条已写入第 N 代向量空间;「当前已入向量库 N 条」统计 active 代际。',
|
|
815
|
+
helpLabelReviewRisk: 'reviewRisk',
|
|
816
|
+
helpLabelReviewRiskMeaning: '全局条目的复核风险分(0–2);越高越可能进「待复核」,它不是置信度。',
|
|
817
|
+
helpLabelLexicon: 'lexicon kind / sensitive / hitCount · 自动',
|
|
818
|
+
helpLabelLexiconMeaning: '词典:kind 是词条类型;sensitive 仅用户可管;hitCount 是命中次数。关系图「自动」= 算法建立的链接。',
|
|
819
|
+
helpSidebar: '侧边栏地图',
|
|
820
|
+
helpSidebarDesc: '侧栏几个提醒与开关的位置。',
|
|
821
|
+
helpSidebarAlerts: '「整理提醒」跨会话汇总整理结果:失败行需要处理,点 ↗ 打开该条记忆所在的库;「清除失败记录」只删失败日志,成功记录与其他日志不动。',
|
|
822
|
+
helpSidebarReview: '「待复核」= pending_review:内容还没通过复核,所以不注入;侧栏统计只显示数量,审阅入口在「全局记忆」页的待复核队列(私有条目也在这里带「私有库」标签)。',
|
|
823
|
+
helpSidebarRunLog: '「整理记录」列最近几次整理的状态、时间与消息;「整理提醒」展开后分失败/成功两列。',
|
|
824
|
+
helpSidebarReviewMode: '审核模式开关在全局记忆页:「auto」只暂扣冲突、缺证据与高风险改写,「review-all」把所有内容操作送进复核。',
|
|
825
|
+
helpSidebarFirstRun: '首次安装卡只在没有任何记忆库时出现;建好第一个库后自动消失,没有关闭按钮,也不写本地存储。',
|
|
826
|
+
helpSidebarFallback: 'WebUI 若不允许「全部库」读取(宿主返回 403),记忆墙会退回第一个可访问的库并明确提示,不会整页空白;多库选项会禁用。',
|
|
827
|
+
helpSidebarScope: '本对话的作用域卡在侧栏「记忆」页:顶部两层显示文件夹与会话,控制卡里是私有/全局开关,下方折叠卡可设频道/角色/世界线/分支。',
|
|
828
|
+
helpFaq: '常见问题',
|
|
829
|
+
helpFaq1: '为什么没有召回?',
|
|
830
|
+
helpFaq1A: '按顺序检查:会话是否绑定库(memu_bind / /memu 绑定);注入模式是否 off;文件夹或会话的私有/全局开关是否关掉;条目是否还在 active 且未被上下文(频道/角色/世界线/分支/knownBy)或 domain 过滤。本地向量未激活不会让召回消失,只会回退到词法。',
|
|
831
|
+
helpFaq2: '私有库和全局记忆有什么区别?',
|
|
832
|
+
helpFaq2A: '私有库由本文件夹所有会话共享,写入即可编辑、归档、恢复;全局由 curator 在后台跨会话整理写入,按 domain/applies_to 过滤,界面里只读,只能复核、撤销合并或移除链接。',
|
|
833
|
+
helpFaq3: '为什么有些记忆不会被注入?',
|
|
834
|
+
helpFaq3A: '常见原因:pending_review(等内容复核)、archived/suppressed/expired/superseded、visibility=secret(自动注入会跳过)、上下文或 domain 不匹配。词典条目没有 pending 复核:写入即 active,归档的才不注入。',
|
|
835
|
+
helpFaq4: '为什么锚点只有标题?怎么拿到正文?',
|
|
836
|
+
helpFaq4A: '锚点与本回合召回是目录:只给标题、标签和 id,避免挤占预算,也避免模型引用没拿到的原文。正文用 memu_private_recall / memu_global_recall 按标题关键词或 id 取,工具仍返回全文;也可在记忆页抽屉里直接读。',
|
|
837
|
+
helpFaq5: '整理合并(absorb)之后,原来的条目去哪了?怎么撤销?',
|
|
838
|
+
helpFaq5A: '合并不会删除任何东西:合并稿成为新的 active 条目,被吸收的来源归档、被取代的目标标记 superseded。在全局记忆页找到合并稿,点「撤销合并」即可整体恢复原状;全局链接也可以逐条移除。',
|
|
839
|
+
helpFaq6: '词典为什么自动生效?怎么归档?为什么某条不注入?',
|
|
840
|
+
helpFaq6A: '词典写入即 active,没有待审队列;归档会立即停止注入且可恢复,彻底删除只在管理面提供、不可撤销。词条不注入时检查是否已归档、上下文/可见性是否匹配。sensitive trigger 只有用户能改。',
|
|
841
|
+
helpFaq7: '自动关联和实体枢纽怎么撤销?',
|
|
842
|
+
helpFaq7A: '关系图里带「自动」的边是算法建立的:点旁边的 × 两段确认后即可移除。移除只改图元数据,不改正文、不写向量、不删记忆。实体删除沿用既有规则:被引用时默认拒绝,确认后才连同入边一起移除。',
|
|
843
|
+
helpFaq8: '自动备份和导出 JSON/ZIP 有什么区别?',
|
|
844
|
+
helpFaq8A: '自动备份是整机快照:插件状态、全局/私有索引、词典、提示词、附件引用与 MemU 数据库,外加逐文件校验和的 manifest;切换引擎/恢复前会自动做一份。导出 JSON/ZIP 是单库导出,ZIP 额外带图片附件;两种导出都能再导入回来。',
|
|
845
|
+
helpFaq9: '删除的对话还会被整理吗?',
|
|
846
|
+
helpFaq9A: '不会。会话被删除后,空闲整理扫描会把它标记为 sessionGone 并跳过,只记一条 check 级日志,不反复重试,也不影响其他会话的整理。',
|
|
847
|
+
helpFaq10: '本地向量模型未激活怎么办?',
|
|
848
|
+
helpFaq10A: '没有 active 向量代际时会回退词法检索,仍可用但语义更弱。「当前已入向量库 N 条」指 active 代际里的条数;切换模型或修复失败后要重建,旧代际在重建期间只读,失败不会动当前代际,可再点一次续建。',
|
|
849
|
+
helpFaq11: '对话里为什么会主动提「那个日子已经过了」或「这条可能过时了」?',
|
|
850
|
+
helpFaq11A: '三种情况都来自记忆本身,不是模型即兴:① 带 `YYYY-MM-DD` 的未了之事过期后,会按「未了之事复提间隔」(默认 7 天)重新提一次,同一天不重复,也没日期的承诺仍是提过一次就安静;② 召回里有时效信号的条目(日期已过、标题带「最新/价格/版本」这类词、或写得够久)会让注入块尾多一行提示,让模型在会话有搜索工具时先核实——它不声称工具一定存在;③「日期到点唤醒」是**实验特性**且默认关闭,打开后宿主会在日子当天用定时任务让会话开一轮,那种回合不跑常规召回,所以只带着那条日期说话。三者都只是提示:不自动写记忆、不自动关闭约定,也不自动删除任何东西。',
|
|
851
|
+
helpFeedback: '反馈',
|
|
852
|
+
helpOpenIssue: '提交 Issue',
|
|
853
|
+
helpCopyDiagnostics: '复制诊断信息',
|
|
854
|
+
helpDocs: '打开文档',
|
|
637
855
|
}
|
|
638
856
|
|
|
639
857
|
const en = {
|
|
@@ -662,9 +880,11 @@ window.__ModuleLoader__.load({
|
|
|
662
880
|
logKindError: 'Error',
|
|
663
881
|
logKindSystem: 'System',
|
|
664
882
|
logKindCheck: 'Check',
|
|
883
|
+
logKindWake: 'Date wake',
|
|
665
884
|
logClear: 'Clear log',
|
|
666
885
|
runLogTitle: 'Runs',
|
|
667
886
|
runLogEmpty: 'No runs recorded yet.',
|
|
887
|
+
runLogOpen: 'All logs',
|
|
668
888
|
dedupedNotice: 'Not written: the library already holds a near-identical memory [{id}]. Edit and merge into that entry instead; pass allow_duplicate only for two genuinely independent observations.',
|
|
669
889
|
consolidateFeedTitle: 'Consolidation alerts',
|
|
670
890
|
consolidateFailedCol: 'Failed',
|
|
@@ -679,6 +899,9 @@ window.__ModuleLoader__.load({
|
|
|
679
899
|
consolidateClearHint: 'Deletes only failed consolidation logs; successes and other logs stay',
|
|
680
900
|
consolidateCleared: 'Cleared {n} failure logs',
|
|
681
901
|
allLibraries: 'All libraries',
|
|
902
|
+
wallAllBlocked: 'This host only allows one library per read; showing the first library',
|
|
903
|
+
linkCountTag: 'Links {n}',
|
|
904
|
+
linkRemoved: 'Link removed',
|
|
682
905
|
searchMemories: 'Search titles, content or tags',
|
|
683
906
|
poolReview: 'Review',
|
|
684
907
|
poolInactive: 'Inactive',
|
|
@@ -686,6 +909,10 @@ window.__ModuleLoader__.load({
|
|
|
686
909
|
wallLimit: 'Showing the latest 300 entries',
|
|
687
910
|
wallScopePrivate: 'Private',
|
|
688
911
|
wallScopeGlobal: 'Global',
|
|
912
|
+
wallFilterScope: 'Scope',
|
|
913
|
+
wallFilterStatus: 'Status',
|
|
914
|
+
wallFilterLayer: 'Layer',
|
|
915
|
+
wallAllLayers: 'All layers',
|
|
689
916
|
multiSelect: 'Multi-select',
|
|
690
917
|
wallSelected: '{n} selected',
|
|
691
918
|
wallSelectAll: 'Select page',
|
|
@@ -694,6 +921,15 @@ window.__ModuleLoader__.load({
|
|
|
694
921
|
viewMemory: 'View',
|
|
695
922
|
entityDelete: 'Delete entity',
|
|
696
923
|
entityDeleteForceHint: 'Still referenced by memories or relations; click again to delete with its links',
|
|
924
|
+
entityMergeTitle: 'Merge candidates',
|
|
925
|
+
entityMergeHint: 'Similar spellings are only suggestions and are never merged automatically. Merging redirects the source entity memory links to the main node, folds its aliases in, and drops the source entity; memories themselves are never deleted.',
|
|
926
|
+
entityMergeAction: 'Merge',
|
|
927
|
+
entityMergeConfirm: 'Confirm merge',
|
|
928
|
+
entityMergeDone: 'Merged "{from}" into "{to}": {links} memory links redirected, {aliases} aliases in total',
|
|
929
|
+
entityMergeDropped: '({n} aliases over the cap were not folded in)',
|
|
930
|
+
entityMergeConflict: '({n} relationship snapshots clashed with the target side and were dropped)',
|
|
931
|
+
mergeReasonContainment: 'Name contained',
|
|
932
|
+
mergeReasonDistance: 'Similar spelling',
|
|
697
933
|
openMemu: 'Open MemU WebUI',
|
|
698
934
|
saved: 'Saved',
|
|
699
935
|
copied: 'Copied',
|
|
@@ -715,7 +951,17 @@ window.__ModuleLoader__.load({
|
|
|
715
951
|
characterId: 'Current character ID',
|
|
716
952
|
worldId: 'World ID',
|
|
717
953
|
branchId: 'Story branch ID',
|
|
718
|
-
|
|
954
|
+
exportZip: 'Export ZIP (with images)',
|
|
955
|
+
exportStarted: 'Export started: {file}',
|
|
956
|
+
memorySaved: 'Memory saved',
|
|
957
|
+
memoryArchived: 'Memory archived',
|
|
958
|
+
memoryRestored: 'Memory restored',
|
|
959
|
+
memoryDeleted: 'Memory deleted',
|
|
960
|
+
bulkDone: 'Bulk action finished: {n}',
|
|
961
|
+
curatorReview: 'Curation review mode',
|
|
962
|
+
descCuratorReview: 'How global curation writes: auto holds conflicts, missing evidence and risky rewrites for review; review-everything sends each content change to the review queue.',
|
|
963
|
+
curatorReviewAuto: 'Auto (default)',
|
|
964
|
+
curatorReviewAll: 'Review everything',
|
|
719
965
|
archiveTooLarge: 'Attachment archive exceeds 16 MB; split it before importing',
|
|
720
966
|
openSettings: 'Open settings',
|
|
721
967
|
sidebarSettings: 'Keep full settings in the sidebar',
|
|
@@ -726,7 +972,7 @@ window.__ModuleLoader__.load({
|
|
|
726
972
|
adjacency: 'Adjacency',
|
|
727
973
|
graphView: 'Graph',
|
|
728
974
|
viewMemories: 'Memories',
|
|
729
|
-
viewRelations: '
|
|
975
|
+
viewRelations: 'Node graph',
|
|
730
976
|
close: 'Close',
|
|
731
977
|
openInBrowser: 'Open in the browser',
|
|
732
978
|
globalReadOnly: 'Global memories are read-only here; edit them on the global page.',
|
|
@@ -745,6 +991,7 @@ window.__ModuleLoader__.load({
|
|
|
745
991
|
entityAliases: 'Aliases (comma separated)',
|
|
746
992
|
entityKind: 'Entity kind',
|
|
747
993
|
graphEmpty: 'No connections yet',
|
|
994
|
+
graphAutoLink: 'Auto',
|
|
748
995
|
deletedNode: '[deleted]',
|
|
749
996
|
graphLimited: 'Showing at most 200 nodes',
|
|
750
997
|
graphFit: 'Fit graph',
|
|
@@ -781,6 +1028,16 @@ window.__ModuleLoader__.load({
|
|
|
781
1028
|
globalEveryNTurns: 'Global every N turns',
|
|
782
1029
|
minUserChars: 'Min user chars',
|
|
783
1030
|
randomCueChance: 'Random cue chance',
|
|
1031
|
+
openLoopRemindDays: 'Re-remind open loops every N days',
|
|
1032
|
+
freshnessHint: 'Freshness hint',
|
|
1033
|
+
freshnessDays: 'Age treated as stale (days)',
|
|
1034
|
+
freshnessHintHint: 'When recalled entries carry time-sensitive signals, add one line telling the model to verify before answering about the present.',
|
|
1035
|
+
salientWake: 'Wake on salient dates',
|
|
1036
|
+
salientWakeOff: 'Off (passive injection only)',
|
|
1037
|
+
salientWakeSchedule: 'Wake the conversation',
|
|
1038
|
+
salientWakeHour: 'Wake time (HH:mm)',
|
|
1039
|
+
salientWakeTimeZone: 'Wake time zone (empty = system)',
|
|
1040
|
+
salientWakeHint: 'Experimental and off by default. Delivery goes through the host scheduler and opens a full turn for the conversation. It only fires while the host process is alive, and the tasks are visible (and deletable) in the host schedule UI. Not yet verified on a real install — try it on a test library first.',
|
|
784
1041
|
autoInstall: 'Auto-install engine',
|
|
785
1042
|
sleepConsolidation: 'Consolidate after idle',
|
|
786
1043
|
sleepAfterIdleMinutes: 'Idle minutes before consolidating',
|
|
@@ -823,9 +1080,23 @@ window.__ModuleLoader__.load({
|
|
|
823
1080
|
salientDateLabel: 'Date (MM-DD recurs yearly, YYYY-MM-DD is one-off)',
|
|
824
1081
|
salientDatePlaceholder: 'e.g. 10-29 or 2026-10-29; empty for no date',
|
|
825
1082
|
moodTag: 'mood',
|
|
1083
|
+
arousalLabel: 'arousal',
|
|
1084
|
+
dominanceLabel: 'dominance',
|
|
1085
|
+
emotionSourceLabel: 'source',
|
|
1086
|
+
emotionSourceModel: 'model',
|
|
1087
|
+
emotionSourceSession: 'session',
|
|
1088
|
+
emotionSourceContent: 'content',
|
|
1089
|
+
emotionSourceUnknown: 'unknown',
|
|
826
1090
|
reviews: 'Awaiting review',
|
|
827
1091
|
reviewsEmpty: 'No memories are waiting for review.',
|
|
828
1092
|
reviewScopePrivate: 'private library',
|
|
1093
|
+
// Package F2: set-absorb (absorb) review and undo.
|
|
1094
|
+
absorbTag: 'Set absorb · {n} entries',
|
|
1095
|
+
absorbSourcesTag: 'Merged memory · {n} sources',
|
|
1096
|
+
absorbUndo: 'Undo merge',
|
|
1097
|
+
absorbUndone: 'Merge undone; source memories restored',
|
|
1098
|
+
absorbSourcesLabel: 'Absorbed sources',
|
|
1099
|
+
absorbLinksLabel: 'Linked memories',
|
|
829
1100
|
accuracyTag: 'details may be off',
|
|
830
1101
|
accept: 'Accept',
|
|
831
1102
|
reject: 'Discard',
|
|
@@ -1162,7 +1433,172 @@ window.__ModuleLoader__.load({
|
|
|
1162
1433
|
rememberChoice: 'Remember this choice for new conversations',
|
|
1163
1434
|
confirm: 'Confirm',
|
|
1164
1435
|
later: 'Later',
|
|
1436
|
+
// —— Lexicon page ——
|
|
1437
|
+
pageLexicon: 'Lexicon',
|
|
1438
|
+
descLexicon: 'One lexicon per memory library: slang, memes, triggers and terms with meanings, archive and hit counts.',
|
|
1439
|
+
lexiconScope: 'Terms',
|
|
1440
|
+
lexiconNoLibrary: 'No memory libraries yet; a lexicon comes with each private library.',
|
|
1441
|
+
lexiconTotal: '{total} terms',
|
|
1442
|
+
lexiconTerm: 'Term',
|
|
1443
|
+
lexiconKind: 'Kind',
|
|
1444
|
+
lexiconAllKinds: 'All kinds',
|
|
1445
|
+
lexiconKindSlang: 'Slang',
|
|
1446
|
+
lexiconKindMeme: 'Meme',
|
|
1447
|
+
lexiconKindTrigger: 'Trigger',
|
|
1448
|
+
lexiconKindTerm: 'Term',
|
|
1449
|
+
lexiconMeaning: 'Meaning',
|
|
1450
|
+
lexiconUsage: 'Usage',
|
|
1451
|
+
lexiconAliases: 'Aliases (comma separated)',
|
|
1452
|
+
lexiconExamples: 'Examples (one per line)',
|
|
1453
|
+
lexiconSensitivity: 'Sensitivity',
|
|
1454
|
+
lexiconSensitivityAll: 'All sensitivities',
|
|
1455
|
+
lexiconNormal: 'Normal',
|
|
1456
|
+
lexiconSensitive: 'Sensitive',
|
|
1457
|
+
lexiconStatus: 'Status',
|
|
1458
|
+
lexiconAllStatus: 'All statuses',
|
|
1459
|
+
lexiconStPending: 'Pending',
|
|
1460
|
+
lexiconStRejected: 'Rejected',
|
|
1461
|
+
lexiconPending: 'Pending',
|
|
1462
|
+
lexiconApprove: 'Approve',
|
|
1463
|
+
lexiconReject: 'Reject',
|
|
1464
|
+
lexiconHits: 'Hits',
|
|
1465
|
+
lexiconStrength: 'Strength',
|
|
1466
|
+
lexiconSourceMemory: 'Source memory ↗',
|
|
1467
|
+
lexiconSearch: 'Search terms / meanings / aliases',
|
|
1468
|
+
lexiconNew: 'New term',
|
|
1469
|
+
lexiconCreate: 'Add to lexicon',
|
|
1470
|
+
lexiconEdit: 'Edit term',
|
|
1471
|
+
lexiconSaveDone: 'Term saved.',
|
|
1472
|
+
lexiconReviewDone: 'Review recorded.',
|
|
1473
|
+
lexiconAddDone: 'Term added.',
|
|
1474
|
+
lexiconDelete: 'Delete terms',
|
|
1475
|
+
lexiconDeleteHint: 'Deletion is permanent: click "Delete terms" once, then confirm.',
|
|
1476
|
+
lexiconDeleted: 'Deleted {n} terms.',
|
|
1477
|
+
lexiconPrev: 'Previous',
|
|
1478
|
+
lexiconNext: 'Next',
|
|
1479
|
+
lexiconPageOf: 'Page {page} / {pages}',
|
|
1480
|
+
lexiconEmpty: 'This lexicon has no terms yet.',
|
|
1481
|
+
lexiconNoMatch: 'No matching terms.',
|
|
1482
|
+
lexiconTabActive: 'In use ({n})',
|
|
1483
|
+
lexiconTabArchived: 'Archived ({n})',
|
|
1484
|
+
lexiconArchivedEmpty: 'No archived terms.',
|
|
1485
|
+
lexiconArchive: 'Archive',
|
|
1486
|
+
lexiconRestore: 'Restore',
|
|
1487
|
+
lexiconArchiveDone: 'Term archived — you can restore it anytime.',
|
|
1488
|
+
lexiconRestoreDone: 'Term restored.',
|
|
1489
|
+
lexiconArchivedCount: 'Archived {n} term(s).',
|
|
1490
|
+
lexiconRestoredCount: 'Restored {n} term(s).',
|
|
1491
|
+
lexiconCardUsage: 'Usage',
|
|
1492
|
+
lexiconCardAliases: 'Aliases',
|
|
1165
1493
|
loading: 'Loading…',
|
|
1494
|
+
// ── Package C/D/E keys (lexicon proposals + entity visibility + help page) ──
|
|
1495
|
+
lexiconProposal: 'Proposal',
|
|
1496
|
+
lexiconPendingEmpty: 'No pending term proposals.',
|
|
1497
|
+
lexiconHitsDetail: 'Hit detail: {candidate} candidates · {injection} injections · {query} queries',
|
|
1498
|
+
orphanEntities: 'Unlinked entities ({n})',
|
|
1499
|
+
orphanPruneHint: 'No memory or relationship references these entities; the plugin cleans them up automatically at the next startup.',
|
|
1500
|
+
entityEmpty: 'No entities in this library yet.',
|
|
1501
|
+
firstRunTitle: 'Create a memory library first',
|
|
1502
|
+
firstRunDesc: 'There are no libraries yet. Memories from your conversations need one to land in.',
|
|
1503
|
+
firstRunGoLibraries: 'Create a library',
|
|
1504
|
+
firstRunGuide: 'Quick start guide',
|
|
1505
|
+
pageHelp: 'Help',
|
|
1506
|
+
descHelp: 'Quick start, scope and label reference, FAQ and feedback',
|
|
1507
|
+
helpQuickStart: 'Quick start',
|
|
1508
|
+
helpGoTo: 'Go →',
|
|
1509
|
+
helpStep1: 'Create a private library: create one on the Libraries page. Success looks like the project library in the list, and the folders page showing it too.',
|
|
1510
|
+
helpStep2: 'Bind the library in the conversation: ask the assistant to call memu_bind (or send the /memu bind command), or pick the scope in the new-session card. Success looks like the sidebar session card naming this library.',
|
|
1511
|
+
helpStep3: 'Pick an injection mode: in Settings → Injection mode choose smart (on demand), anchor-only (anchor only), per-turn (every turn) or off. Success looks like the status card showing the chosen mode and the next turn following it.',
|
|
1512
|
+
helpStep4: 'Confirm and correct on the memory page: the MemU memory page lists recalled and written entries. Open the drawer for the full text, fix mistakes, archive what you do not need; changes take effect immediately.',
|
|
1513
|
+
helpStep5: 'Maintain slang on the lexicon page: entries the AI writes become active automatically and join injection; you can edit, archive/restore and permanently delete, and sensitive triggers are user-only. Success looks like the term under "In use", with archived ones restorable under "Archived".',
|
|
1514
|
+
helpScopes: 'Private vs global',
|
|
1515
|
+
helpScopesDesc: 'The folder sets the ceiling, the conversation sets the switches.',
|
|
1516
|
+
helpScopesChain: 'Decision order: workspace → folder policy (useLibrary / useGlobal ceilings) → session binding (actual switches) → effectiveScope. The folder is a ceiling; a conversation can only work within it.',
|
|
1517
|
+
helpScopesPrivate: 'Private = every conversation in this folder shares one library: another chat in the same folder reads the same entries, writes are visible to all of them, and entries stay editable, archivable and restorable.',
|
|
1518
|
+
helpScopesGlobal: 'Global = the curator consolidates across conversations in the background and writes it, filtered by domain and applies_to; in the UI it is read-only — review, undo a merge or remove a link, never hand-edit the body.',
|
|
1519
|
+
helpScopesWhere: 'Where to change it: the folders page sets the ceilings; the sidebar session card sets this conversation; the global page only reviews.',
|
|
1520
|
+
helpScopesPitfallsTitle: 'Common pitfalls',
|
|
1521
|
+
helpScopesPitfall1: 'With global off in the folder, a conversation cannot turn it back on — the ceiling wins and the switch is shown disabled.',
|
|
1522
|
+
helpScopesPitfall2: 'A conversation with global only has no private library; private-memory tools say so instead of creating one silently.',
|
|
1523
|
+
helpScopesPitfall3: 'Entries carrying context (channel / character / world / branch / knownBy) stay hidden from conversations that do not match; that is filtering, not loss.',
|
|
1524
|
+
helpTitleCards: 'Title cards and recall',
|
|
1525
|
+
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.',
|
|
1526
|
+
helpTitleCardsRecall: 'The title is a directory: recall by title keyword, or by the id shown in brackets on the card, with memu_private_recall / memu_global_recall; the tools still return the full text.',
|
|
1527
|
+
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.',
|
|
1528
|
+
helpArchiveDelete: 'Archive, delete and undo',
|
|
1529
|
+
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.',
|
|
1530
|
+
helpArchiveDeleteDelete: 'Permanent delete: the UI offers it only for archived entries, with a two-step confirmation. It is final and also removes inbound links to the entry and prunes entities left orphaned by it.',
|
|
1531
|
+
helpArchiveDeleteLexicon: 'The lexicon follows the same rules: archive is restorable, delete is permanent; the model has no delete or review path, and sensitive terms stay user-managed.',
|
|
1532
|
+
helpArchiveDeleteAbsorb: 'Absorb: the merged entry becomes active, the target is marked superseded and the sources are archived. On the global page press "Undo merge" on the merged entry to roll it all back; global links can also be removed one by one.',
|
|
1533
|
+
helpArchiveDeleteSessionGone: 'A deleted conversation never fails consolidation: the sweep marks it sessionGone and skips it instead of retrying forever.',
|
|
1534
|
+
helpVector: 'Vector store',
|
|
1535
|
+
helpVectorSetup: 'memoryBackend=api with vectorSource=local means MemU keeps storing and retrieving locally while a managed embedding model supplies the vectors. Pick the local source on "Connection & vectors", then download the runtime and model in the managed-vector area on the same page and switch.',
|
|
1536
|
+
helpVectorCount: '"Currently indexed N items" counts entries that already have vectors in the active generation; "In vector store · gN" on an entry is the generation tag it was written into.',
|
|
1537
|
+
helpVectorFallback: 'With no active generation (only requested, or a failed rebuild) recall falls back to lexical search: still usable, weaker semantics.',
|
|
1538
|
+
helpVectorRebuild: 'Rebuild when switching models or repairing a failure: the old generation stays read-only until the new one commits, and new memories then go to the new generation. A failed rebuild leaves the active generation unchanged; press again to resume.',
|
|
1539
|
+
helpAutoLink: 'Private auto-links and entity hubs',
|
|
1540
|
+
helpAutoLinkRule: "Algorithm first, zero extra model tokens: two memories in the same library, same context/track, visible and not secret, sharing a rare name/alias and not conflicting are linked memory↔memory with source:'auto'.",
|
|
1541
|
+
helpAutoLinkHub: 'Entity hub: "猫娘yuike" and "yuike名字的由来" share yuike, so the algorithm reuses or creates a yuike entity and links both memories to it; person/thing kind is inferred conservatively.',
|
|
1542
|
+
helpAutoLinkWorker: 'Uncertain candidates go to the current consolidation worker (memu_private_link_suggest), which adjudicates with evidence; it never starts another full consolidation or rereads the transcript, and no candidates means no links.',
|
|
1543
|
+
helpAutoLinkSafety: 'Auto-links only add graph metadata: no body changes, no vectors, no deletion. The graph shows an "Auto" badge and a remove (×); entity deletion still follows the existing rules.',
|
|
1544
|
+
helpLabels: 'Label cheat sheet',
|
|
1545
|
+
helpLabelsDesc: 'Badges you will see on memories and in the relationship graph.',
|
|
1546
|
+
helpLabelColLabel: 'Label',
|
|
1547
|
+
helpLabelColMeaning: 'Meaning',
|
|
1548
|
+
helpLabelSource: 'source',
|
|
1549
|
+
helpLabelSourceMeaning: 'Provenance: inferred / user_said (quotable) / told / imagined. imagined must never be treated as fact.',
|
|
1550
|
+
helpLabelLayer: 'layer',
|
|
1551
|
+
helpLabelLayerMeaning: 'Layer: must_remember / long_term / short_term pointer (a pointer only, no body).',
|
|
1552
|
+
helpLabelOpenLoop: 'open_loop',
|
|
1553
|
+
helpLabelOpenLoopMeaning: 'Open loop: a promise or suspense line is still unresolved.',
|
|
1554
|
+
helpLabelMarginalized: 'marginalized',
|
|
1555
|
+
helpLabelMarginalizedMeaning: 'Marginalized: pulled out of primary memory but not deleted; still searchable.',
|
|
1556
|
+
helpLabelDate: 'date / anniversary',
|
|
1557
|
+
helpLabelDateMeaning: 'Date: date is one specific day; anniversary repeats every year (birthday / memorial).',
|
|
1558
|
+
helpLabelAttachment: '附件N',
|
|
1559
|
+
helpLabelAttachmentMeaning: 'Attachment count on a title card; captions are not expanded there — body and images live in the drawer or tools.',
|
|
1560
|
+
helpLabelVector: 'In vector store · gN',
|
|
1561
|
+
helpLabelVectorMeaning: 'The entry is in generation N of the vector space; "Currently indexed N items" counts the active generation.',
|
|
1562
|
+
helpLabelReviewRisk: 'reviewRisk',
|
|
1563
|
+
helpLabelReviewRiskMeaning: 'Review risk score (0–2) for global entries; higher means more likely held for review. It is not confidence.',
|
|
1564
|
+
helpLabelLexicon: 'lexicon kind / sensitive / hitCount · Auto',
|
|
1565
|
+
helpLabelLexiconMeaning: 'Lexicon: kind is the term type; sensitive is user-managed; hitCount is how often it hit. Graph "Auto" = an algorithm-created link.',
|
|
1566
|
+
helpSidebar: 'Sidebar map',
|
|
1567
|
+
helpSidebarDesc: 'Where the reminders and switches live in the sidebar.',
|
|
1568
|
+
helpSidebarAlerts: 'Consolidation alerts aggregate results across conversations: failed rows need attention, ↗ opens the library holding that memory, and "Clear failures" deletes only failed logs — successes and other logs stay.',
|
|
1569
|
+
helpSidebarReview: '"Needs review" = pending_review: nobody has approved the content yet, so it is not injected. The sidebar only shows the count; the review queue is on the global page (private items are tagged "private library" there).',
|
|
1570
|
+
helpSidebarRunLog: '"Runs" lists recent consolidation status, time and message; expanding the alerts card splits failures and successes into two columns.',
|
|
1571
|
+
helpSidebarReviewMode: 'The review-mode switch is on the global memory page: "auto" holds only conflicts, missing evidence and risky rewrites; "review-all" sends every content operation to review.',
|
|
1572
|
+
helpSidebarFirstRun: 'The first-install card appears only while there are no libraries; it disappears once the first one exists. There is no dismiss button and no local storage.',
|
|
1573
|
+
helpSidebarFallback: 'If the host forbids all-library browsing (403), the memory wall falls back to the first accessible library and says so instead of going blank; the multi-library option is disabled.',
|
|
1574
|
+
helpSidebarScope: 'The conversation scope card is on the sidebar Memory page: the top shows folder and conversation, the control card holds the private/global switches, and the collapsed card below sets channel / character / world / branch.',
|
|
1575
|
+
helpFaq: 'FAQ',
|
|
1576
|
+
helpFaq1: 'Why is nothing being recalled?',
|
|
1577
|
+
helpFaq1A: 'Check in order: is the conversation bound to a library (memu_bind / the /memu bind command); is the injection mode off; are the folder or conversation private/global switches off; is the entry still active and not filtered by context (channel/character/world/branch/knownBy) or domain. A missing local vector generation does not empty recall — it only falls back to lexical search.',
|
|
1578
|
+
helpFaq2: 'How do private libraries differ from global memory?',
|
|
1579
|
+
helpFaq2A: 'A private library is shared by every conversation in the folder: writes are editable, archivable and restorable. Global memory is written by the curator across conversations, filtered by domain/applies_to, and read-only in the UI — review, undo a merge or remove a link, never hand-edit.',
|
|
1580
|
+
helpFaq3: 'Why are some memories not injected?',
|
|
1581
|
+
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.',
|
|
1582
|
+
helpFaq4: 'Why does the anchor show only titles, and how do I get the body?',
|
|
1583
|
+
helpFaq4A: 'The anchor and per-turn recall are a directory: title, tags and id only, to save budget and avoid quoting text the model was not given. Fetch the body with memu_private_recall / memu_global_recall by title keyword or id; the tools still return full text, and the memory-page drawer shows it too.',
|
|
1584
|
+
helpFaq5: 'Where did the original entries go after an absorb, and how do I undo it?',
|
|
1585
|
+
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.',
|
|
1586
|
+
helpFaq6: 'The lexicon writes automatically — how do I archive, and why is a term not injected?',
|
|
1587
|
+
helpFaq6A: 'Lexicon terms go active immediately: there is no pending queue. Archiving stops injection at once and is restorable; permanent deletion exists only in the admin UI and cannot be undone. If a term is not injected, check whether it is archived or its context/visibility does not match. Sensitive triggers are user-only.',
|
|
1588
|
+
helpFaq7: 'How do I undo an auto-link or entity hub?',
|
|
1589
|
+
helpFaq7A: 'Edges with the "Auto" badge in the relationship graph were created by the algorithm: press × and confirm to remove one. Removal only touches graph metadata — no body, no vector, no deletion. Entity deletion follows the existing rules: refused while referenced, and force also removes the inbound links.',
|
|
1590
|
+
helpFaq8: 'Automatic backups vs JSON/ZIP export?',
|
|
1591
|
+
helpFaq8A: 'An automatic backup is a whole-install snapshot: plugin state, global/private indexes, lexicon, prompts, attachment references and the MemU databases, plus a manifest with per-file checksums; one is taken before engine switches/restores. JSON/ZIP export is per-library, and ZIP also carries image attachments; both exports can be imported back.',
|
|
1592
|
+
helpFaq9: 'Are deleted conversations still consolidated?',
|
|
1593
|
+
helpFaq9A: 'No. Once a conversation is deleted, the idle sweep marks it sessionGone and skips it, records a check-level log instead of an error, and does not retry forever or affect other conversations.',
|
|
1594
|
+
helpFaq10: 'The vector model is inactive — what happens?',
|
|
1595
|
+
helpFaq10A: 'Recall falls back to lexical search: still usable, weaker semantically. "Currently indexed N items" counts the active generation. Switching models or repairing a failure requires a rebuild; the old generation stays read-only during it, a failed rebuild leaves the active generation unchanged, and pressing again resumes.',
|
|
1596
|
+
helpFaq11: 'Why does the conversation bring up "that date already passed" or "this may be out of date"?',
|
|
1597
|
+
helpFaq11A: 'All three cases come from the memories themselves, not the model improvising: (1) an open loop whose `YYYY-MM-DD` has passed is raised again on the "re-remind every N days" cadence (default 7), never twice on one day, while undated promises stay quiet after their first mention; (2) recalled entries with time-sensitive signals (a past date, wording like "latest / price / version", or enough age) append one line to the recall block telling the model to verify first if the conversation has a search tool — it never claims the tool exists; (3) date wake-up is an experimental switch and off by default: with it enabled the host scheduler opens a turn on the day itself, and that turn runs no normal recall, so it only carries that date. All three are hints: nothing is written automatically, no commitment is closed automatically, nothing is deleted.',
|
|
1598
|
+
helpFeedback: 'Feedback',
|
|
1599
|
+
helpOpenIssue: 'Open an issue',
|
|
1600
|
+
helpCopyDiagnostics: 'Copy diagnostics',
|
|
1601
|
+
helpDocs: 'Documentation',
|
|
1166
1602
|
}
|
|
1167
1603
|
|
|
1168
1604
|
// One token table for both surfaces. Every colour goes through a DSH alias so
|
|
@@ -1272,6 +1708,8 @@ window.__ModuleLoader__.load({
|
|
|
1272
1708
|
.dshm-graph-tools{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:12px 0}
|
|
1273
1709
|
.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}
|
|
1274
1710
|
.dshm-graph-tools input{flex:1 1 160px}
|
|
1711
|
+
.dshm-root select{height:32px;max-width:100%;padding:0 30px 0 10px!important;border:1px solid var(--dsw-alias-border-l1,#dfe1e6);border-radius:9px;background-color:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.08));color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12.5px;line-height:1.2;text-overflow:ellipsis;cursor:pointer;appearance:none;-webkit-appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23808a99' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 9px center!important;background-size:10px 6px!important}
|
|
1712
|
+
.dshm-root select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:2px}
|
|
1275
1713
|
.dshm-graph-list{display:grid;gap:8px;margin:12px 0}
|
|
1276
1714
|
.dshm-graph-edge{display:flex;align-items:center;gap:8px;border-bottom:1px solid var(--dsw-alias-border-l1,#43444a);padding:10px 0;min-width:0}
|
|
1277
1715
|
.dshm-graph-edge>div{flex:1;min-width:0;overflow-wrap:anywhere}
|
|
@@ -1299,15 +1737,17 @@ window.__ModuleLoader__.load({
|
|
|
1299
1737
|
.dshm-graph-missing{opacity:.5}
|
|
1300
1738
|
/* The sidebar's context-scope form: a collapsed card instead of four bare
|
|
1301
1739
|
inputs and a browser-default button. */
|
|
1302
|
-
.dshm-scope{margin:0
|
|
1740
|
+
.dshm-scope{width:100%;margin:0 0 10px;border:1px solid var(--dsw-alias-border-l1,#ddd);border-radius:12px;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.05));overflow:hidden;flex-shrink:0}
|
|
1303
1741
|
.dshm-scope>summary{display:flex;align-items:center;gap:7px;padding:9px 12px;list-style:none;cursor:pointer;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8));transition:color .18s ease}
|
|
1304
1742
|
.dshm-scope>summary::-webkit-details-marker{display:none}
|
|
1305
1743
|
.dshm-scope>summary::before{content:"";width:6px;height:6px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);transition:transform .2s ease;margin-right:1px}
|
|
1306
1744
|
.dshm-scope[open]>summary::before{transform:rotate(45deg)}
|
|
1307
1745
|
.dshm-scope>summary:hover{color:var(--dsw-alias-label-primary,inherit)}
|
|
1308
1746
|
.dshm-scope>summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:-2px}
|
|
1309
|
-
.dshm-scope-form{display:grid;grid-template-columns:repeat(
|
|
1310
|
-
.dshm-scope-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:11px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
1747
|
+
.dshm-scope-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:0 12px 12px}
|
|
1748
|
+
.dshm-scope-field{display:flex;flex-direction:column;gap:4px;min-width:0;font-size:11px;line-height:1.35;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
1749
|
+
.dshm-scope-field>span{display:block;min-height:15px}
|
|
1750
|
+
.dshm-tab-body>*{flex-shrink:0}
|
|
1311
1751
|
.dshm-scope-field input{height:32px;min-width:0;padding:0 10px;border:1px solid var(--dsw-alias-border-l1,#ddd);border-radius:9px;background:var(--dsw-alias-bg-layer-1,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12.5px;outline:none;transition:border-color .18s ease,box-shadow .18s ease}
|
|
1312
1752
|
.dshm-scope-field input: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) 16%,transparent)}
|
|
1313
1753
|
.dshm-scope-actions{grid-column:1/-1;display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:2px}
|
|
@@ -1615,6 +2055,7 @@ window.__ModuleLoader__.load({
|
|
|
1615
2055
|
const GlyphText = glyph(['M5 6h14', 'M5 11h14', 'M5 16h9'])
|
|
1616
2056
|
const GlyphLayers = glyph(['M12 3l9 5-9 5-9-5 9-5z', 'M3 13l9 5 9-5'])
|
|
1617
2057
|
const GlyphChart = glyph(['M4 19V5', 'M4 19h16', 'M8 15v-4', 'M12 15V8', 'M16 15v-6'])
|
|
2058
|
+
const GlyphQuestion = glyph(['M9.1 9a3 3 0 0 1 5.8 1c0 2-3 2.4-3 4', 'M12 17.5h.01'])
|
|
1618
2059
|
|
|
1619
2060
|
// Thirty daily bars, written by hand: the bundle purity gate refuses absolute
|
|
1620
2061
|
// imports, and a chart this small does not need a library. Zero days still draw
|
|
@@ -1713,13 +2154,14 @@ window.__ModuleLoader__.load({
|
|
|
1713
2154
|
h('div', { style: { ...S.barFill, width: `${pct}%` } }))
|
|
1714
2155
|
}
|
|
1715
2156
|
|
|
1716
|
-
function Button({ children, onClick, disabled, primary, style, title, type = 'button' }) {
|
|
2157
|
+
function Button({ children, onClick, disabled, primary, style, title, type = 'button', 'aria-pressed': ariaPressed }) {
|
|
1717
2158
|
return h('button', {
|
|
1718
2159
|
type,
|
|
1719
2160
|
className: 'dshm-btn',
|
|
1720
2161
|
// Without this the prop never reaches the node, and every hover hint on
|
|
1721
2162
|
// the surface silently stops working.
|
|
1722
2163
|
title,
|
|
2164
|
+
'aria-pressed': ariaPressed,
|
|
1723
2165
|
style: { ...S.btn, ...(primary ? S.primary : {}), ...(style || {}), opacity: disabled ? 0.5 : 1 },
|
|
1724
2166
|
onClick,
|
|
1725
2167
|
disabled,
|
|
@@ -1830,6 +2272,27 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
1830
2272
|
.join('/')
|
|
1831
2273
|
}
|
|
1832
2274
|
|
|
2275
|
+
const EMOTION_SOURCE_LABELS = {
|
|
2276
|
+
model: 'emotionSourceModel',
|
|
2277
|
+
session: 'emotionSourceSession',
|
|
2278
|
+
content: 'emotionSourceContent',
|
|
2279
|
+
unknown: 'emotionSourceUnknown',
|
|
2280
|
+
}
|
|
2281
|
+
// Read-only affect metadata. Old entries have no arousal/dominance at all; do
|
|
2282
|
+
// not infer them from valence, and do not show a lone source line.
|
|
2283
|
+
function emotionMetaText(entry, t) {
|
|
2284
|
+
const arousal = typeof entry?.arousal === 'number' && Number.isFinite(entry.arousal) ? entry.arousal : null
|
|
2285
|
+
const dominance = typeof entry?.dominance === 'number' && Number.isFinite(entry.dominance) ? entry.dominance : null
|
|
2286
|
+
if (arousal === null && dominance === null) return ''
|
|
2287
|
+
const parts = []
|
|
2288
|
+
if (arousal !== null) parts.push(`${t('arousalLabel')} ${arousal.toFixed(1)}`)
|
|
2289
|
+
if (dominance !== null) parts.push(`${t('dominanceLabel')} ${dominance > 0 ? '+' : ''}${dominance.toFixed(1)}`)
|
|
2290
|
+
if (entry?.emotionSource) {
|
|
2291
|
+
parts.push(`${t('emotionSourceLabel')} ${t(EMOTION_SOURCE_LABELS[entry.emotionSource] || 'emotionSourceUnknown')}`)
|
|
2292
|
+
}
|
|
2293
|
+
return parts.join(' · ')
|
|
2294
|
+
}
|
|
2295
|
+
|
|
1833
2296
|
// Tags are labels, not decoration — except when the label is a warning. A memory
|
|
1834
2297
|
// marked "never say out loud" has to look different from one that can be said,
|
|
1835
2298
|
// otherwise the badge is just more grey text to skim past.
|
|
@@ -1838,9 +2301,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
1838
2301
|
info: { color: V.accent, background: V.accentSoft },
|
|
1839
2302
|
}
|
|
1840
2303
|
|
|
1841
|
-
function Tag({ children, tone }) {
|
|
2304
|
+
function Tag({ children, tone, title }) {
|
|
1842
2305
|
const style = tone && TAG_TONES[tone] ? { ...S.tag, ...TAG_TONES[tone] } : S.tag
|
|
1843
|
-
return h('span', { style }, children)
|
|
2306
|
+
return h('span', { style, title }, children)
|
|
1844
2307
|
}
|
|
1845
2308
|
|
|
1846
2309
|
// The host lists untitled sessions (renamed title events are async), so fall
|
|
@@ -1862,6 +2325,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
1862
2325
|
h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 16 } }, footer || null)))
|
|
1863
2326
|
}
|
|
1864
2327
|
|
|
2328
|
+
// Library selectors previously showed the whole absolute scope path, which made
|
|
2329
|
+
// every option a long, nearly identical line. Keep the folder leaf as context and
|
|
2330
|
+
// disambiguate same-looking names with a short id suffix only when needed.
|
|
2331
|
+
function libraryBaseLabel(lib) {
|
|
2332
|
+
const name = String(lib?.name || lib?.id || '')
|
|
2333
|
+
const leaf = String(lib?.scopeKey || '').split(/[\\/]/).filter(Boolean).pop() || ''
|
|
2334
|
+
return leaf && leaf.toLowerCase() !== name.toLowerCase() ? `${name} · ${leaf}` : name
|
|
2335
|
+
}
|
|
2336
|
+
function libraryOptionLabel(lib, libraries = []) {
|
|
2337
|
+
const base = libraryBaseLabel(lib)
|
|
2338
|
+
const duplicated = (Array.isArray(libraries) ? libraries : []).filter((item) => libraryBaseLabel(item) === base).length > 1
|
|
2339
|
+
return duplicated ? `${base} · ${String(lib?.id || '').slice(-4)}` : base
|
|
2340
|
+
}
|
|
2341
|
+
|
|
1865
2342
|
function useRpc(ctx) {
|
|
1866
2343
|
return React.useCallback((endpoint, payload) => rpc(ctx, endpoint, payload), [ctx])
|
|
1867
2344
|
}
|
|
@@ -1875,7 +2352,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
1875
2352
|
const ui = ctx.get?.('uiSession') || ctx.uiSession
|
|
1876
2353
|
const cur = ui?.adapter?.current
|
|
1877
2354
|
if (cur?.getSnapshot) {
|
|
1878
|
-
return { subscribe: cur.subscribe.bind(cur), get: ()
|
|
2355
|
+
return { subscribe: typeof cur.subscribe === 'function' ? cur.subscribe.bind(cur) : function () { return function () {} }, get: function () { return cur.getSnapshot()?.key } }
|
|
1879
2356
|
}
|
|
1880
2357
|
return null
|
|
1881
2358
|
}, [ctx])
|
|
@@ -2101,6 +2578,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2101
2578
|
const [armed, setArmed] = React.useState('')
|
|
2102
2579
|
// deleteEntity 被后端拒绝(仍被引用)的实体 id:此时再点确认升级为 force。
|
|
2103
2580
|
const [deleteRefused, setDeleteRefused] = React.useState('')
|
|
2581
|
+
// 工单 F:实体合并候选。后端只出建议,合并必须由用户逐条确认;候选读失败不影响
|
|
2582
|
+
// 图谱其余部分,所以单独 catch 成空列表。
|
|
2583
|
+
const [merges, setMerges] = React.useState([])
|
|
2584
|
+
const [mergeNotice, setMergeNotice] = React.useState('')
|
|
2104
2585
|
const [error, setError] = React.useState('')
|
|
2105
2586
|
const requestId = React.useRef(0)
|
|
2106
2587
|
const mounted = React.useRef(true)
|
|
@@ -2110,12 +2591,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2110
2591
|
}, [])
|
|
2111
2592
|
const refresh = React.useCallback(async () => {
|
|
2112
2593
|
const id = ++requestId.current
|
|
2113
|
-
const [next, list] = await Promise.all([
|
|
2594
|
+
const [next, list, suggested] = await Promise.all([
|
|
2114
2595
|
call('getGraph', { libraryId, focusId: focus || null, depth: 2, limit: 200 }),
|
|
2115
2596
|
call('listEntities', { libraryId }),
|
|
2597
|
+
call('suggestEntityMerges', { libraryId }).catch(() => null),
|
|
2116
2598
|
])
|
|
2117
2599
|
if (mounted.current && id === requestId.current) {
|
|
2118
|
-
setGraph(next); setEntities(list.items || []); setError('')
|
|
2600
|
+
setGraph(next); setEntities(list.items || []); setMerges(suggested?.items || []); setError('')
|
|
2119
2601
|
}
|
|
2120
2602
|
}, [call, libraryId, focus])
|
|
2121
2603
|
React.useEffect(() => {
|
|
@@ -2133,6 +2615,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2133
2615
|
const timer = setTimeout(() => setError(''), 2600)
|
|
2134
2616
|
return () => clearTimeout(timer)
|
|
2135
2617
|
}, [error])
|
|
2618
|
+
// 合并影响面要说清"多少条链接改了指向",比普通错误停留更久。
|
|
2619
|
+
React.useEffect(() => {
|
|
2620
|
+
if (!mergeNotice) return undefined
|
|
2621
|
+
const timer = setTimeout(() => setMergeNotice(''), 9000)
|
|
2622
|
+
return () => clearTimeout(timer)
|
|
2623
|
+
}, [mergeNotice])
|
|
2136
2624
|
const act = async (method, payload) => {
|
|
2137
2625
|
try {
|
|
2138
2626
|
await call(method, { libraryId, ...payload })
|
|
@@ -2140,8 +2628,62 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2140
2628
|
if (mounted.current) await refresh()
|
|
2141
2629
|
} catch (error) { if (mounted.current) setError(String(error.message || error)) }
|
|
2142
2630
|
}
|
|
2631
|
+
const entityLabel = (id) => {
|
|
2632
|
+
const found = entities.find(item => item.id === id)
|
|
2633
|
+
return found ? (found.name || found.id) : id
|
|
2634
|
+
}
|
|
2635
|
+
const doMerge = async (item) => {
|
|
2636
|
+
try {
|
|
2637
|
+
const result = await call('mergeEntities', { libraryId, targetId: item.targetId, sourceIds: [item.sourceId] })
|
|
2638
|
+
let message = t('entityMergeDone')
|
|
2639
|
+
.replace('{from}', entityLabel(item.sourceId))
|
|
2640
|
+
.replace('{to}', entityLabel(item.targetId))
|
|
2641
|
+
.replace('{links}', String(result?.remappedLinks ?? 0))
|
|
2642
|
+
.replace('{aliases}', String((result?.aliases || []).length))
|
|
2643
|
+
const dropped = (result?.droppedAliases || []).length
|
|
2644
|
+
if (dropped) message += ' ' + t('entityMergeDropped').replace('{n}', String(dropped))
|
|
2645
|
+
const conflicts = (result?.relationships?.conflicts || []).length
|
|
2646
|
+
if (conflicts) message += ' ' + t('entityMergeConflict').replace('{n}', String(conflicts))
|
|
2647
|
+
setArmed('')
|
|
2648
|
+
setMergeNotice(message)
|
|
2649
|
+
notifyMemoryWrite('relation', libraryId)
|
|
2650
|
+
if (mounted.current) await refresh()
|
|
2651
|
+
} catch (failure) { if (mounted.current) setError(String(failure.message || failure)) }
|
|
2652
|
+
}
|
|
2143
2653
|
const titles = new Map(graph.nodes.map(node => [node.id, node.missing ? t('deletedNode') : node.title]))
|
|
2144
2654
|
const edges = graph.edges.filter(edge => !focus || edge.from === focus || edge.to === focus).sort((a, b) => b.confidence - a.confidence)
|
|
2655
|
+
// 实体行:改名表单 + 删除按钮。删除是文字按钮(§6.4 包 D,原灰色 × 读不出
|
|
2656
|
+
// 语义):未 armed 显示「删除」,armed 显示「确认删除」,后端拒绝过(仍被
|
|
2657
|
+
// 引用)再点确认升级为 force——「确认删除!」,连同引用一起删,force 明示的
|
|
2658
|
+
// 代价。title 与两段确认保持不变,后端 force 语义零改动。
|
|
2659
|
+
const entityForm = entity => h('form', { key: entity.id, className: 'dshm-graph-tools', onSubmit: event => {
|
|
2660
|
+
event.preventDefault()
|
|
2661
|
+
const data = new FormData(event.currentTarget)
|
|
2662
|
+
void act('renameEntity', { entityId: entity.id, name: String(data.get('name')), aliases: String(data.get('aliases')).split(',').map(value => value.trim()).filter(Boolean) })
|
|
2663
|
+
} },
|
|
2664
|
+
h('input', { name: 'name', defaultValue: entity.name, 'aria-label': t('entityName') }),
|
|
2665
|
+
h('input', { name: 'aliases', defaultValue: (entity.aliases || []).join(', '), placeholder: t('entityAliases'), 'aria-label': t('entityAliases') }),
|
|
2666
|
+
h('button', { type: 'submit', className: 'dshm-btn', style: S.btn }, t('save')),
|
|
2667
|
+
h('button', {
|
|
2668
|
+
type: 'button',
|
|
2669
|
+
className: `dshm-graph-unlink${armed === 'entity:' + entity.id ? ' is-armed' : ''}`,
|
|
2670
|
+
title: deleteRefused === entity.id ? t('entityDeleteForceHint') : t('entityDelete'),
|
|
2671
|
+
'aria-label': deleteRefused === entity.id ? t('entityDeleteForceHint') : t('entityDelete'),
|
|
2672
|
+
onClick: async () => {
|
|
2673
|
+
const key = 'entity:' + entity.id
|
|
2674
|
+
if (armed !== key) { setArmed(key); return }
|
|
2675
|
+
try {
|
|
2676
|
+
await call('deleteEntity', { libraryId, entityId: entity.id, force: deleteRefused === entity.id })
|
|
2677
|
+
setArmed(''); setDeleteRefused('')
|
|
2678
|
+
notifyMemoryWrite('relation', libraryId)
|
|
2679
|
+
if (mounted.current) await refresh()
|
|
2680
|
+
} catch (failure) {
|
|
2681
|
+
const message = String(failure?.message || failure)
|
|
2682
|
+
if (/referenced|引用/.test(message)) setDeleteRefused(entity.id)
|
|
2683
|
+
if (mounted.current) setError(message)
|
|
2684
|
+
}
|
|
2685
|
+
},
|
|
2686
|
+
}, armed === 'entity:' + entity.id ? (deleteRefused === entity.id ? t('relationConfirm') + '!' : t('relationConfirm')) : t('entityDelete')))
|
|
2145
2687
|
return h('div', null,
|
|
2146
2688
|
error ? h('div', { className: 'dshm-toast', role: 'status' }, error) : null,
|
|
2147
2689
|
h('div', { className: 'dshm-graph-tools' },
|
|
@@ -2158,6 +2700,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2158
2700
|
h('div', { className: 'dshm-graph-list' }, edges.length ? edges.map(edge => h('div', { key: edge.from + edge.to + edge.kind, className: 'dshm-graph-edge' },
|
|
2159
2701
|
h('div', null, h('button', { type: 'button', className: 'dshm-graph-node', onClick: () => setFocus(edge.from) }, titles.get(edge.from) || edge.from),
|
|
2160
2702
|
' → ', h('button', { type: 'button', className: 'dshm-graph-node', onClick: () => setFocus(edge.to) }, titles.get(edge.to) || edge.to),
|
|
2703
|
+
// 私有自动关联(§5.7):source:'auto' 的边来自算法/实体枢纽,不是用户手连。
|
|
2704
|
+
// 只多一个可点读的小 Tag;kind/confidence/note 与移除按钮保持原样。
|
|
2705
|
+
edge.source === 'auto' ? h('span', { style: { margin: '0 5px', verticalAlign: 'middle' } }, h(Tag, { tone: 'info' }, t('graphAutoLink'))) : null,
|
|
2161
2706
|
h('small', null, edge.kind + ' · ' + Math.round(edge.confidence * 100) + '% · ' + edge.note)),
|
|
2162
2707
|
h('button', {
|
|
2163
2708
|
type: 'button',
|
|
@@ -2181,35 +2726,37 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2181
2726
|
h('select', { value: entityKind, title: t('entityKind'), onChange: event => setEntityKind(event.target.value) }, ['person', 'place', 'thing', 'org'].map(value => h('option', { key: value, value }, value))),
|
|
2182
2727
|
h(Button, { disabled: !entityName.trim(), onClick: () => act('createEntity', { name: entityName, kind: entityKind }) }, t('entityNew'))),
|
|
2183
2728
|
h(RelationshipPanel, { call, libraryId, entities, files, t }),
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
h('
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2729
|
+
// 工单 F:合并候选只列出来,永不自动合并。两次点击确认沿用删除的 armed 模式,
|
|
2730
|
+
// 合并后的影响面(改指多少条链接、并入多少别名)用一行回执说清。
|
|
2731
|
+
mergeNotice ? h('div', { style: { ...S.muted, marginTop: 6, color: V.accent }, role: 'status' }, mergeNotice) : null,
|
|
2732
|
+
merges.length ? h('div', { style: { margin: '10px 0' } },
|
|
2733
|
+
h('div', { style: { fontSize: 12, fontWeight: 600 } }, t('entityMergeTitle')),
|
|
2734
|
+
h('div', { style: { ...S.muted, margin: '4px 0 6px', lineHeight: 1.5 } }, t('entityMergeHint')),
|
|
2735
|
+
merges.map(item => {
|
|
2736
|
+
const key = 'merge:' + item.sourceId + '>' + item.targetId
|
|
2737
|
+
return h('div', { key, className: 'dshm-graph-tools' },
|
|
2738
|
+
h('span', { style: { minWidth: 0, overflowWrap: 'anywhere' } }, entityLabel(item.sourceId) + ' → ' + entityLabel(item.targetId)),
|
|
2739
|
+
h(Tag, { tone: 'info' }, item.reason === 'containment' ? t('mergeReasonContainment') : t('mergeReasonDistance')),
|
|
2740
|
+
h(Button, {
|
|
2741
|
+
style: armed === key ? { ...S.btn, color: V.danger, borderColor: V.danger } : S.btn,
|
|
2742
|
+
title: t('entityMergeHint'),
|
|
2743
|
+
onClick: () => { if (armed !== key) { setArmed(key); return } void doMerge(item) },
|
|
2744
|
+
}, armed === key ? t('entityMergeConfirm') : t('entityMergeAction')))
|
|
2745
|
+
})) : null,
|
|
2746
|
+
entities.length === 0 ? h(Empty, null, t('entityEmpty')) : null,
|
|
2747
|
+
// 孤立分组(§6.4 包 D):listEntities 给出 linked 派生标记。被引用的实体照常
|
|
2748
|
+
// 渲染;孤立实体(linked=false,没有任何记忆 link/关系快照指着)收进折叠区,
|
|
2749
|
+
// 默认收起——它们是启动 prune 还没跑到的残余,不该和正常实体平起平坐。
|
|
2750
|
+
entities.filter(entity => entity.linked !== false).map(entityForm),
|
|
2751
|
+
(() => {
|
|
2752
|
+
const orphans = entities.filter(entity => entity.linked === false)
|
|
2753
|
+
if (!orphans.length) return null
|
|
2754
|
+
return h('details', { key: 'dshm-orphans', className: 'dshm-graph-orphans', style: { margin: '8px 0' } },
|
|
2755
|
+
h('summary', { style: { cursor: 'pointer', fontSize: 12, color: V.textDim } },
|
|
2756
|
+
t('orphanEntities').replace('{n}', String(orphans.length))),
|
|
2757
|
+
h('div', { style: { ...S.muted, margin: '6px 0' } }, t('orphanPruneHint')),
|
|
2758
|
+
orphans.map(entityForm))
|
|
2759
|
+
})())
|
|
2213
2760
|
}
|
|
2214
2761
|
|
|
2215
2762
|
function InboundToolsInput({ names, onChange }) {
|
|
@@ -2238,9 +2785,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2238
2785
|
item.attachmentCount > 1 ? h('span', { className: 'dshm-wall-cover-count' }, '▧ ' + item.attachmentCount) : null)
|
|
2239
2786
|
}
|
|
2240
2787
|
|
|
2241
|
-
function MemoryWallPanel({ call, libraries, revision, stamp, onOpen, t, indexed = null, focus = null }) {
|
|
2788
|
+
function MemoryWallPanel({ call, libraries, revision, stamp, onOpen, t, indexed = null, focus = null, onNotice = null, initialLibraryId = '' }) {
|
|
2789
|
+
// 成功提示走宿主面板的 notice 通道(spec §6.2):失败仍走本面板的 error 通道,
|
|
2790
|
+
// 同一动作只走一条。onNotice 缺省时静默(面板也可能在无 notice 通道的宿主里用)。
|
|
2791
|
+
const notice = (message) => { if (typeof onNotice === 'function' && message) onNotice(message) }
|
|
2242
2792
|
const [data, setData] = React.useState({ items: [], total: 0, errors: [] })
|
|
2243
|
-
const [libraryId, setLibraryId] = React.useState('')
|
|
2793
|
+
const [libraryId, setLibraryId] = React.useState(initialLibraryId || '')
|
|
2794
|
+
const [multiBlocked, setMultiBlocked] = React.useState(false)
|
|
2244
2795
|
const [view, setView] = React.useState('memories')
|
|
2245
2796
|
const [graphLib, setGraphLib] = React.useState('')
|
|
2246
2797
|
const [pool, setPool] = React.useState('active')
|
|
@@ -2267,16 +2818,47 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2267
2818
|
setScope(focus.libraryId ? 'private' : 'global')
|
|
2268
2819
|
void openDetail({ id: focus.id, libraryId: focus.libraryId || null, title: focus.title || focus.id })
|
|
2269
2820
|
}, [focus])
|
|
2821
|
+
const firstLibraryId = libraries?.[0]?.id || ''
|
|
2270
2822
|
React.useEffect(() => {
|
|
2271
2823
|
let alive = true
|
|
2272
|
-
|
|
2273
|
-
|
|
2824
|
+
const load = async () => {
|
|
2825
|
+
try {
|
|
2826
|
+
const value = await call('browseWall', { libraryId: libraryId || null, limit: 300 })
|
|
2827
|
+
if (!alive) return
|
|
2828
|
+
setData(value)
|
|
2829
|
+
setError('')
|
|
2830
|
+
} catch (failure) {
|
|
2831
|
+
if (!alive) return
|
|
2832
|
+
const message = String(failure?.message || failure)
|
|
2833
|
+
// 宿主对“全部记忆库”多库读取返回 403(browseWall 无法表达为单库授权)时,
|
|
2834
|
+
// 退到第一个库并明确告知;单库 + 全局(browseWall 总会带全局)仍能出数据,
|
|
2835
|
+
// 不再整页空。用户可手动切换库;多库选项保留为禁用。
|
|
2836
|
+
if (!libraryId && firstLibraryId && /forbidden|403/i.test(message)) {
|
|
2837
|
+
try {
|
|
2838
|
+
const value = await call('browseWall', { libraryId: firstLibraryId, limit: 300 })
|
|
2839
|
+
if (!alive) return
|
|
2840
|
+
setData(value)
|
|
2841
|
+
setError('')
|
|
2842
|
+
setMultiBlocked(true)
|
|
2843
|
+
setLibraryId(firstLibraryId)
|
|
2844
|
+
return
|
|
2845
|
+
} catch (fallbackFailure) {
|
|
2846
|
+
if (alive) setError(String(fallbackFailure?.message || fallbackFailure))
|
|
2847
|
+
return
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
setError(message)
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
void load()
|
|
2274
2854
|
return () => { alive = false }
|
|
2275
|
-
}, [call, libraryId, revision, stamp, version])
|
|
2855
|
+
}, [call, libraryId, revision, stamp, version, firstLibraryId])
|
|
2276
2856
|
React.useEffect(() => {
|
|
2277
|
-
if (graphLib) return
|
|
2278
|
-
const
|
|
2857
|
+
if (graphLib && libraries.some((lib) => lib.id === graphLib)) return
|
|
2858
|
+
const selected = libraryId && libraries.some((lib) => lib.id === libraryId) ? libraryId : ''
|
|
2859
|
+
const first = selected || libraries[0]?.id || ''
|
|
2279
2860
|
if (first) setGraphLib(first)
|
|
2861
|
+
else if (graphLib) setGraphLib('')
|
|
2280
2862
|
}, [graphLib, libraryId, libraries])
|
|
2281
2863
|
React.useEffect(() => {
|
|
2282
2864
|
if (!detail) return undefined
|
|
@@ -2358,6 +2940,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2358
2940
|
if (Number.isFinite(confidence)) patch.confidence = Math.max(0, Math.min(1, confidence))
|
|
2359
2941
|
await call('updateMemory', { libraryId: current.item.libraryId, id: current.item.id, patch })
|
|
2360
2942
|
await refreshDetail(current)
|
|
2943
|
+
notice(t('memorySaved'))
|
|
2361
2944
|
} catch (failure) {
|
|
2362
2945
|
setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
|
|
2363
2946
|
}
|
|
@@ -2369,6 +2952,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2369
2952
|
try {
|
|
2370
2953
|
await call('updateMemory', { libraryId: current.item.libraryId, id: current.item.id, patch: { status } })
|
|
2371
2954
|
await refreshDetail(current)
|
|
2955
|
+
// 归档/恢复/保存是三个不同结果,同一条通知通道但各说各话。
|
|
2956
|
+
notice(status === 'archived' ? t('memoryArchived') : status === 'active' ? t('memoryRestored') : t('memorySaved'))
|
|
2372
2957
|
} catch (failure) {
|
|
2373
2958
|
setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
|
|
2374
2959
|
}
|
|
@@ -2382,6 +2967,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2382
2967
|
setDetail(null)
|
|
2383
2968
|
setDeleteArmed(false)
|
|
2384
2969
|
notifyMemoryWrite('memory', current.item.libraryId)
|
|
2970
|
+
notice(t('memoryDeleted'))
|
|
2385
2971
|
reload()
|
|
2386
2972
|
} catch (failure) {
|
|
2387
2973
|
setDetail(prev => prev ? { ...prev, busy: false, error: String(failure?.message || failure) } : prev)
|
|
@@ -2411,7 +2997,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2411
2997
|
setDeleteArmedMulti(false)
|
|
2412
2998
|
setSelectedIds(new Set())
|
|
2413
2999
|
if (done > 0) { notifyMemoryWrite('memory', libraryId || null); reload() }
|
|
3000
|
+
// 部分成功不说成全部成功:有失败只走 error(带 done/total 前缀),全成功才报 notice。
|
|
2414
3001
|
if (failures.length > 0) setError(`${done}/${targets.length} · ` + failures.slice(0, 3).join(';'))
|
|
3002
|
+
else if (done > 0) notice(t('bulkDone').replace('{n}', String(done)))
|
|
2415
3003
|
}
|
|
2416
3004
|
|
|
2417
3005
|
const shown = detail ? { ...detail.item, ...(detail.file || {}) } : null
|
|
@@ -2458,11 +3046,33 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2458
3046
|
t('openLoopTag'))),
|
|
2459
3047
|
h('div', { className: 'dshm-drawer-note' },
|
|
2460
3048
|
t('decay') + ' ' + Math.round((Number(shown.decay) || 0) * 100) + '% · ' +
|
|
2461
|
-
(shown.updatedAt ? String(shown.updatedAt).slice(0, 16).replace('T', ' ') : ''))
|
|
3049
|
+
(shown.updatedAt ? String(shown.updatedAt).slice(0, 16).replace('T', ' ') : '')),
|
|
3050
|
+
emotionMetaText(shown, t) ? h('div', { className: 'dshm-drawer-note' }, emotionMetaText(shown, t)) : null)
|
|
2462
3051
|
: detail && detail.file && detail.readonly
|
|
2463
|
-
?
|
|
2464
|
-
|
|
2465
|
-
|
|
3052
|
+
? (() => {
|
|
3053
|
+
// 全局条目只读(spec §6.7 UI):详情抽屉里只读展示 links / absorbedFrom,
|
|
3054
|
+
// 不提供编辑、不提供手动全局关联。links 移除按钮在全局页(F1 接入)。
|
|
3055
|
+
const absorbed = Array.isArray(detail.file.absorbedFrom) ? detail.file.absorbedFrom : []
|
|
3056
|
+
const links = Array.isArray(detail.file.links) ? detail.file.links : []
|
|
3057
|
+
return h(React.Fragment, null,
|
|
3058
|
+
h('p', { className: 'dshm-drawer-copy' }, detail.file.content || shown.preview),
|
|
3059
|
+
absorbed.length || links.length
|
|
3060
|
+
? h('div', { className: 'dshm-drawer-note', style: { lineHeight: 1.7 } },
|
|
3061
|
+
absorbed.length
|
|
3062
|
+
? h('div', null, h('strong', null, t('absorbSourcesTag').replace('{n}', String(absorbed.length))),
|
|
3063
|
+
h('div', { style: { marginTop: 2 } }, absorbed.slice(0, 8).join('、'),
|
|
3064
|
+
absorbed.length > 8 ? `… +${absorbed.length - 8}` : ''))
|
|
3065
|
+
: null,
|
|
3066
|
+
links.length
|
|
3067
|
+
? h('div', { style: absorbed.length ? { marginTop: 6 } : null },
|
|
3068
|
+
h('strong', null, `${t('absorbLinksLabel')} · ${links.length}`),
|
|
3069
|
+
h('div', { style: { marginTop: 2 } }, links.slice(0, 8).map((link, index) =>
|
|
3070
|
+
h('div', { key: `${link.id || index}` }, `· ${link.kind || 'related'} → ${link.to || '?'}`)),
|
|
3071
|
+
links.length > 8 ? h('div', null, `… +${links.length - 8}`) : null))
|
|
3072
|
+
: null)
|
|
3073
|
+
: null,
|
|
3074
|
+
h('p', { className: 'dshm-drawer-note' }, t('globalReadOnly')))
|
|
3075
|
+
})()
|
|
2466
3076
|
: detail && detail.busy
|
|
2467
3077
|
? h(Empty, null, t('loading'))
|
|
2468
3078
|
: null
|
|
@@ -2536,7 +3146,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2536
3146
|
h(Button, { style: S.ghost, onClick: () => setDetail(null) }, t('close')))))
|
|
2537
3147
|
: null
|
|
2538
3148
|
|
|
2539
|
-
const
|
|
3149
|
+
const validLib = (id) => id && libraries.some((lib) => lib.id === id) ? id : ''
|
|
3150
|
+
const graphLibrary = validLib(graphLib) || validLib(libraryId) || libraries[0]?.id || ''
|
|
2540
3151
|
const graphFiles = React.useMemo(() => items
|
|
2541
3152
|
.filter(item => item.libraryId === graphLibrary)
|
|
2542
3153
|
.map(item => ({ id: item.id, title: item.title })), [items, graphLibrary])
|
|
@@ -2547,65 +3158,126 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2547
3158
|
h('div', { className: 'dshm-graph-tools' },
|
|
2548
3159
|
h('select', {
|
|
2549
3160
|
value: graphLibrary,
|
|
2550
|
-
title: t('currentLibrary'),
|
|
3161
|
+
title: libraries.find((lib) => lib.id === graphLibrary)?.scopeKey || t('currentLibrary'),
|
|
2551
3162
|
// One library drives both views, otherwise the graph's focus list can
|
|
2552
3163
|
// be empty when the wall is filtered to a different library.
|
|
2553
3164
|
onChange: (event) => { setGraphLib(event.target.value); setLibraryId(event.target.value) },
|
|
2554
3165
|
},
|
|
2555
|
-
libraries.map(lib => h('option', { key: lib.id, value: lib.id }, lib
|
|
3166
|
+
libraries.map(lib => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))),
|
|
2556
3167
|
h(GraphPanel, { key: graphLibrary, call, libraryId: graphLibrary, files: graphFiles, t })))
|
|
2557
3168
|
|
|
3169
|
+
// Category filters used to reuse the compact nav pills (2px gap, 30px high) and
|
|
3170
|
+
// stacked directly on top of each other. Give every group its own segmented
|
|
3171
|
+
// control, a label and breathing room so the state/layer filters are distinct.
|
|
3172
|
+
const wallTabGroup = (items, current, onSelect, { label = '', className = '', marginTop = 0, extra = null } = {}) => h('div', {
|
|
3173
|
+
className,
|
|
3174
|
+
style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', margin: `${marginTop}px 0 0` },
|
|
3175
|
+
},
|
|
3176
|
+
label ? h('span', { style: { ...S.muted, fontSize: 11.5, minWidth: 30 } }, label) : null,
|
|
3177
|
+
h('div', {
|
|
3178
|
+
role: 'tablist',
|
|
3179
|
+
'aria-label': label || undefined,
|
|
3180
|
+
style: {
|
|
3181
|
+
display: 'inline-flex', flexWrap: 'wrap', alignItems: 'stretch', gap: 4,
|
|
3182
|
+
padding: 4, maxWidth: '100%', boxSizing: 'border-box',
|
|
3183
|
+
border: `1px solid ${V.borderSoft}`, borderRadius: V.radius, background: V.surface,
|
|
3184
|
+
},
|
|
3185
|
+
}, items.map(([value, text]) => {
|
|
3186
|
+
const selected = current === value
|
|
3187
|
+
return h('button', {
|
|
3188
|
+
key: value, type: 'button', role: 'tab', 'aria-selected': selected,
|
|
3189
|
+
className: 'dshm-nav-item',
|
|
3190
|
+
style: {
|
|
3191
|
+
height: 34, minHeight: 34, padding: '0 14px', border: 0, borderRadius: V.radiusSm,
|
|
3192
|
+
background: selected ? V.accentSoft : 'transparent',
|
|
3193
|
+
color: selected ? V.accent : V.textDim,
|
|
3194
|
+
fontWeight: selected ? 650 : 500, fontSize: 12.5, lineHeight: 1.2,
|
|
3195
|
+
cursor: 'pointer', whiteSpace: 'nowrap',
|
|
3196
|
+
transition: 'background .18s ease, color .18s ease',
|
|
3197
|
+
},
|
|
3198
|
+
onClick: () => onSelect(value),
|
|
3199
|
+
}, text)
|
|
3200
|
+
})),
|
|
3201
|
+
extra)
|
|
3202
|
+
|
|
3203
|
+
const scopeItems = [['private', 'wallScopePrivate'], ['global', 'wallScopeGlobal']]
|
|
3204
|
+
.map(([value, key]) => [value, t(key) + ' (' + items.filter(item => value === 'global' ? item.libraryId === null : item.libraryId !== null).length + ')'])
|
|
3205
|
+
const poolItems = [['active', 'browseActiveTab'], ['archived', 'browseArchivedTab'], ['review', 'poolReview'], ['inactive', 'poolInactive']]
|
|
3206
|
+
.map(([value, key]) => [value, t(key) + ' (' + scoped.filter(item => poolOf(item) === value).length + ')'])
|
|
3207
|
+
const layerItems = ['all', 'must_remember', 'long_term', 'short_term', 'anchor']
|
|
3208
|
+
.map(value => [value, (value === 'all' ? t('wallAllLayers') : enumText(t, LAYER_LABELS, value)) + ' (' + rows.filter(item => layerMatch(item, value)).length + ')'])
|
|
3209
|
+
const selectedLibrary = libraries.find((lib) => lib.id === libraryId) || null
|
|
3210
|
+
const librarySelect = scope === 'private' && libraries.length
|
|
3211
|
+
? h('select', {
|
|
3212
|
+
value: libraryId,
|
|
3213
|
+
title: selectedLibrary?.scopeKey || t('currentLibrary'),
|
|
3214
|
+
'aria-label': t('currentLibrary'),
|
|
3215
|
+
style: { ...S.input, flex: '0 1 220px', minWidth: 150, maxWidth: 260 },
|
|
3216
|
+
onChange: (event) => {
|
|
3217
|
+
const value = event.target.value
|
|
3218
|
+
setLibraryId(value)
|
|
3219
|
+
if (value) setMultiBlocked(false)
|
|
3220
|
+
},
|
|
3221
|
+
},
|
|
3222
|
+
h('option', { value: '', disabled: multiBlocked }, t('allLibraries')),
|
|
3223
|
+
libraries.map((lib) => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))
|
|
3224
|
+
: null
|
|
3225
|
+
const hasOptionControls = scope === 'private' || multiBlocked || data?.total > items.length
|
|
3226
|
+
const multiToggle = scope === 'private'
|
|
3227
|
+
? h(Button, {
|
|
3228
|
+
'aria-pressed': multi,
|
|
3229
|
+
style: multi ? { ...S.ghost, color: V.accent, borderColor: V.accent } : S.ghost,
|
|
3230
|
+
onClick: () => { if (multi) exitMulti(); else setMulti(true) },
|
|
3231
|
+
}, multi ? t('wallMultiExit') : t('multiSelect'))
|
|
3232
|
+
: null
|
|
3233
|
+
const multiActions = multi && scope === 'private' ? (() => {
|
|
3234
|
+
const chosen = selectedRows(visible)
|
|
3235
|
+
const archiveN = chosen.filter(item => ['active', 'inactive'].includes(poolOf(item))).length
|
|
3236
|
+
const restoreN = chosen.filter(item => item.status === 'archived').length
|
|
3237
|
+
const deleteN = restoreN
|
|
3238
|
+
return h(React.Fragment, null,
|
|
3239
|
+
h('span', { style: S.muted }, t('wallSelected').replace('{n}', String(chosen.length))),
|
|
3240
|
+
h(Button, { style: S.ghost, disabled: chosen.length === visible.length, onClick: () => setSelectedIds(new Set(visible.map(keyOf))) }, t('wallSelectAll')),
|
|
3241
|
+
h(Button, { style: S.ghost, disabled: chosen.length === 0, onClick: () => setSelectedIds(new Set()) }, t('wallClearSelection')),
|
|
3242
|
+
h(Button, { style: S.ghost, disabled: wallBusy || archiveN === 0, onClick: () => { void bulkApply('archive') } }, t('archive') + ` (${archiveN})`),
|
|
3243
|
+
h(Button, { style: S.ghost, disabled: wallBusy || restoreN === 0, onClick: () => { void bulkApply('restore') } }, t('restore') + ` (${restoreN})`),
|
|
3244
|
+
deleteArmedMulti
|
|
3245
|
+
? h(React.Fragment, null,
|
|
3246
|
+
h(Button, { style: { ...S.ghost, color: V.danger, borderColor: V.danger }, disabled: wallBusy || deleteN === 0, onClick: () => { void bulkApply('delete') } }, t('confirmDelete') + ` (${deleteN})`),
|
|
3247
|
+
h(Button, { style: S.ghost, disabled: wallBusy, onClick: () => setDeleteArmedMulti(false) }, t('cancelDelete')))
|
|
3248
|
+
: h(Button, { style: { ...S.ghost, color: V.danger }, disabled: wallBusy || deleteN === 0, title: t('browseArchivedHint'), onClick: () => setDeleteArmedMulti(true) }, t('deleteForever') + ` (${deleteN})`))
|
|
3249
|
+
})() : null
|
|
3250
|
+
|
|
2558
3251
|
return h('div', { className: 'dshm-wall' },
|
|
2559
|
-
|
|
2560
|
-
[['memories', 'viewMemories'], ['relations', 'viewRelations']].map(([value, key]) =>
|
|
2561
|
-
h('button', {
|
|
2562
|
-
key: value, type: 'button', role: 'tab', 'aria-selected': view === value,
|
|
2563
|
-
className: `dshm-nav-item${view === value ? ' on' : ''}`,
|
|
2564
|
-
onClick: () => setView(value),
|
|
2565
|
-
}, t(key)))),
|
|
3252
|
+
wallTabGroup([['memories', t('viewMemories')], ['relations', t('viewRelations')]], view, setView, { className: 'dshm-wall-views' }),
|
|
2566
3253
|
error || data.errors?.length ? h('p', { className: 'dshm-error', role: 'alert' }, error || t('wallReadError')) : null,
|
|
2567
3254
|
view === 'relations'
|
|
2568
3255
|
? graphView
|
|
2569
3256
|
: h(React.Fragment, null,
|
|
2570
3257
|
// 组分类:私有 / 全局(默认私有、私有靠前)。计数按各自的块算,切换即重置多选。
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
3258
|
+
// The library selector belongs to the scope row, not the search row: it
|
|
3259
|
+
// narrows the same private block the two tabs switch between.
|
|
3260
|
+
wallTabGroup(scopeItems, scope, (value) => { setScope(value); exitMulti() }, { label: t('wallFilterScope'), marginTop: 10, extra: librarySelect }),
|
|
3261
|
+
h('div', { className: 'dshm-graph-tools', style: { marginTop: 10, marginBottom: 0 } },
|
|
3262
|
+
h('input', {
|
|
3263
|
+
type: 'search',
|
|
3264
|
+
style: { ...S.input, width: '100%', flex: '1 1 100%' },
|
|
3265
|
+
value: query, placeholder: t('searchMemories'), 'aria-label': t('searchMemories'),
|
|
3266
|
+
onChange: event => setQuery(event.target.value),
|
|
3267
|
+
})),
|
|
3268
|
+
hasOptionControls ? h('div', {
|
|
3269
|
+
className: 'dshm-graph-tools',
|
|
3270
|
+
role: multi ? 'toolbar' : undefined,
|
|
3271
|
+
'aria-label': multi ? t('multiSelect') : undefined,
|
|
3272
|
+
style: { marginTop: 8, marginBottom: 0 },
|
|
3273
|
+
},
|
|
2583
3274
|
// 多选只对私有块:全局条目只读,批量操作没有意义。
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
return h('div', { className: 'dshm-graph-tools', role: 'toolbar', 'aria-label': t('multiSelect') },
|
|
2591
|
-
h('span', { style: S.muted }, t('wallSelected').replace('{n}', String(chosen.length))),
|
|
2592
|
-
h(Button, { style: S.ghost, disabled: chosen.length === visible.length, onClick: () => setSelectedIds(new Set(visible.map(keyOf))) }, t('wallSelectAll')),
|
|
2593
|
-
h(Button, { style: S.ghost, disabled: chosen.length === 0, onClick: () => setSelectedIds(new Set()) }, t('wallClearSelection')),
|
|
2594
|
-
h(Button, { style: S.ghost, disabled: wallBusy || archiveN === 0, onClick: () => { void bulkApply('archive') } }, t('archive') + ` (${archiveN})`),
|
|
2595
|
-
h(Button, { style: S.ghost, disabled: wallBusy || restoreN === 0, onClick: () => { void bulkApply('restore') } }, t('restore') + ` (${restoreN})`),
|
|
2596
|
-
deleteArmedMulti
|
|
2597
|
-
? h(React.Fragment, null,
|
|
2598
|
-
h(Button, { style: { ...S.ghost, color: V.danger, borderColor: V.danger }, disabled: wallBusy || deleteN === 0, onClick: () => { void bulkApply('delete') } }, t('confirmDelete') + ` (${deleteN})`),
|
|
2599
|
-
h(Button, { style: S.ghost, disabled: wallBusy, onClick: () => setDeleteArmedMulti(false) }, t('cancelDelete')))
|
|
2600
|
-
: h(Button, { style: { ...S.ghost, color: V.danger }, disabled: wallBusy || deleteN === 0, title: t('browseArchivedHint'), onClick: () => setDeleteArmedMulti(true) }, t('deleteForever') + ` (${deleteN})`),
|
|
2601
|
-
h(Button, { style: S.ghost, onClick: exitMulti }, t('wallMultiExit')))
|
|
2602
|
-
})() : null,
|
|
2603
|
-
h('div', { className: 'dshm-nav-list is-row', role: 'tablist' }, [['active', 'browseActiveTab'], ['archived', 'browseArchivedTab'], ['review', 'poolReview'], ['inactive', 'poolInactive']].map(([value, key]) =>
|
|
2604
|
-
h('button', { key: value, type: 'button', role: 'tab', 'aria-selected': pool === value, className: `dshm-nav-item${pool === value ? ' on' : ''}`, onClick: () => setPool(value) },
|
|
2605
|
-
t(key) + ' (' + scoped.filter(item => poolOf(item) === value).length + ')'))),
|
|
2606
|
-
h('div', { className: 'dshm-nav-list is-row', role: 'tablist' }, ['all', 'must_remember', 'long_term', 'short_term', 'anchor'].map(value =>
|
|
2607
|
-
h('button', { key: value, type: 'button', role: 'tab', 'aria-selected': layer === value, className: `dshm-nav-item${layer === value ? ' on' : ''}`, onClick: () => setLayer(value) },
|
|
2608
|
-
(value === 'all' ? t('allLibraries') : enumText(t, LAYER_LABELS, value)) + ' (' + rows.filter(item => layerMatch(item, value)).length + ')'))),
|
|
3275
|
+
multiToggle,
|
|
3276
|
+
multiActions,
|
|
3277
|
+
multiBlocked ? h('span', { style: S.muted, role: 'status' }, t('wallAllBlocked')) : null,
|
|
3278
|
+
data?.total > items.length ? h('span', { style: S.muted }, t('wallLimit') + ` (${items.length}/${data.total})`) : null) : null,
|
|
3279
|
+
wallTabGroup(poolItems, pool, setPool, { label: t('wallFilterStatus'), marginTop: 12 }),
|
|
3280
|
+
wallTabGroup(layerItems, layer, setLayer, { label: t('wallFilterLayer'), marginTop: 10 }),
|
|
2609
3281
|
visible.length ? h('div', { className: 'dshm-wall-grid' }, visible.map(item =>
|
|
2610
3282
|
h('button', {
|
|
2611
3283
|
key: keyOf(item), type: 'button', className: 'dshm-wall-item' + (multi && selectedIds.has(keyOf(item)) ? ' is-selected' : ''),
|
|
@@ -2634,6 +3306,419 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2634
3306
|
detailView)
|
|
2635
3307
|
}
|
|
2636
3308
|
|
|
3309
|
+
// The stored enums stay English (they are data); only the display flips with
|
|
3310
|
+
// the host language.
|
|
3311
|
+
const LEXICON_KIND_LABELS = { slang: 'lexiconKindSlang', meme: 'lexiconKindMeme', trigger: 'lexiconKindTrigger', term: 'lexiconKindTerm' }
|
|
3312
|
+
// 公开生命周期两档:页签文案带计数占位符,数字来自 RPC 的 statusCounts。
|
|
3313
|
+
const LEXICON_TAB_LABELS = { active: 'lexiconTabActive', archived: 'lexiconTabArchived' }
|
|
3314
|
+
const EMPTY_LEXICON_DRAFT = { term: '', kind: 'term', meaning: '', usage: '', aliases: '', examples: '' }
|
|
3315
|
+
|
|
3316
|
+
// 词典页(§2.4):公开生命周期只有 active / archived,卡片流对齐记忆墙的
|
|
3317
|
+
// 交互约定(筛选/分页都在 RPC 侧完成,每页 50 条,客户端不缓存全量),但没有审核
|
|
3318
|
+
// ——模型写入直接生效,用户只做编辑 / 归档 / 恢复 / 删除。归档与恢复可逆、一击
|
|
3319
|
+
// 生效;删除是管理面独有的永久动作,两段确认。带 sourceMemoryId 的词条可跳回
|
|
3320
|
+
// 记忆墙对应条目(wallFocus 接力棒,见 SettingsPage)。
|
|
3321
|
+
function LexiconPanel({ call, libraries, t, onFocusMemory, sessionId }) {
|
|
3322
|
+
const [libraryId, setLibraryId] = React.useState('')
|
|
3323
|
+
const [data, setData] = React.useState(null)
|
|
3324
|
+
const [status, setStatus] = React.useState('active')
|
|
3325
|
+
const [kind, setKind] = React.useState('')
|
|
3326
|
+
const [queryInput, setQueryInput] = React.useState('')
|
|
3327
|
+
const [query, setQuery] = React.useState('')
|
|
3328
|
+
const [page, setPage] = React.useState(1)
|
|
3329
|
+
const [busy, setBusy] = React.useState(false)
|
|
3330
|
+
const [error, setError] = React.useState('')
|
|
3331
|
+
const [notice, setNotice] = React.useState('')
|
|
3332
|
+
const [editingId, setEditingId] = React.useState('')
|
|
3333
|
+
const [editDraft, setEditDraft] = React.useState(null)
|
|
3334
|
+
const [creating, setCreating] = React.useState(false)
|
|
3335
|
+
const [newDraft, setNewDraft] = React.useState(EMPTY_LEXICON_DRAFT)
|
|
3336
|
+
const [multi, setMulti] = React.useState(false)
|
|
3337
|
+
const [selectedIds, setSelectedIds] = React.useState(() => new Set())
|
|
3338
|
+
const [deleteArmed, setDeleteArmed] = React.useState('')
|
|
3339
|
+
const [armedBulk, setArmedBulk] = React.useState('')
|
|
3340
|
+
|
|
3341
|
+
// 宿主可能把面板与别的块并排渲染;读取状态时保持类型收窄,坏形状按空值处理,
|
|
3342
|
+
// 不在渲染期抛错(设置页任何一块抛错整页都会变空白)。
|
|
3343
|
+
const safeNewDraft = newDraft && typeof newDraft === 'object' ? newDraft : EMPTY_LEXICON_DRAFT
|
|
3344
|
+
const safeQueryInput = typeof queryInput === 'string' ? queryInput : ''
|
|
3345
|
+
const chosenIds = () => selectedIds instanceof Set ? selectedIds : new Set()
|
|
3346
|
+
|
|
3347
|
+
const activeLib = libraryId || libraries[0]?.id || ''
|
|
3348
|
+
const emptyView = { items: [], total: 0, page: 1, pages: 1, counts: {}, statusCounts: { active: 0, archived: 0 } }
|
|
3349
|
+
const load = React.useCallback(async () => {
|
|
3350
|
+
if (!activeLib) { setData(emptyView); return }
|
|
3351
|
+
setBusy(true)
|
|
3352
|
+
try {
|
|
3353
|
+
// 只取当前页、当前页签:状态页签、kind、搜索、分页全在 RPC 侧收窄,
|
|
3354
|
+
// 客户端不缓存任何全量词条列表。
|
|
3355
|
+
const res = await call('lexiconList', {
|
|
3356
|
+
libraryId: activeLib, sessionId: sessionId || undefined, page, pageSize: 50,
|
|
3357
|
+
status, kind: kind || undefined, q: query || undefined,
|
|
3358
|
+
})
|
|
3359
|
+
setData(res || emptyView)
|
|
3360
|
+
setError('')
|
|
3361
|
+
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
3362
|
+
}, [call, activeLib, page, status, kind, query, sessionId])
|
|
3363
|
+
React.useEffect(() => { void load() }, [load])
|
|
3364
|
+
React.useEffect(() => {
|
|
3365
|
+
if (!error && !notice) return undefined
|
|
3366
|
+
const timer = setTimeout(() => { setError(''); setNotice('') }, 2600)
|
|
3367
|
+
return () => clearTimeout(timer)
|
|
3368
|
+
}, [error, notice])
|
|
3369
|
+
// 两段确认要能自行退场:armed 不会一直挂着;切页签/筛选/动作也会显式清掉。
|
|
3370
|
+
React.useEffect(() => {
|
|
3371
|
+
if (!deleteArmed && !armedBulk) return undefined
|
|
3372
|
+
const timer = setTimeout(() => { setDeleteArmed(''); setArmedBulk('') }, 2500)
|
|
3373
|
+
return () => clearTimeout(timer)
|
|
3374
|
+
}, [deleteArmed, armedBulk])
|
|
3375
|
+
|
|
3376
|
+
const resetSelection = () => { setSelectedIds(new Set()); setDeleteArmed(''); setArmedBulk('') }
|
|
3377
|
+
const resetTransient = () => { setEditingId(''); setEditDraft(null); setCreating(false); setMulti(false); resetSelection() }
|
|
3378
|
+
const changeLibrary = (value) => { setLibraryId(value); setPage(1); resetTransient() }
|
|
3379
|
+
const changeStatus = (value) => {
|
|
3380
|
+
if (value === status) return
|
|
3381
|
+
setStatus(value); setPage(1); setEditingId(''); setEditDraft(null); resetSelection()
|
|
3382
|
+
}
|
|
3383
|
+
const changeFilter = (setter) => (value) => { setter(value); setPage(1); setEditingId(''); setEditDraft(null); resetSelection() }
|
|
3384
|
+
const applySearch = () => { setQuery(safeQueryInput.trim()); setPage(1); setEditingId(''); setEditDraft(null); resetSelection() }
|
|
3385
|
+
const hitsTotal = (e) => {
|
|
3386
|
+
const counts = e.hitCounts && typeof e.hitCounts === 'object' ? e.hitCounts : {}
|
|
3387
|
+
return (Number(counts.candidate) || 0) + (Number(counts.injection) || 0) + (Number(counts.query) || 0)
|
|
3388
|
+
}
|
|
3389
|
+
const clipText = (value, max) => {
|
|
3390
|
+
const text = String(value ?? '')
|
|
3391
|
+
return text.length > max ? text.slice(0, max) + '…' : text
|
|
3392
|
+
}
|
|
3393
|
+
const draftOf = (e) => ({
|
|
3394
|
+
meaning: e.meaning || '',
|
|
3395
|
+
usage: e.usage || '',
|
|
3396
|
+
aliases: (Array.isArray(e.aliases) ? e.aliases : []).join(', '),
|
|
3397
|
+
examples: (Array.isArray(e.examples) ? e.examples : []).join('\n'),
|
|
3398
|
+
sensitivity: e.sensitivity || 'normal',
|
|
3399
|
+
strength: typeof e.strength === 'number' ? String(e.strength) : '',
|
|
3400
|
+
})
|
|
3401
|
+
const toggleEdit = (e) => {
|
|
3402
|
+
if (editingId === e.id) { setEditingId(''); setEditDraft(null); return }
|
|
3403
|
+
setCreating(false)
|
|
3404
|
+
setEditingId(e.id)
|
|
3405
|
+
setEditDraft(draftOf(e))
|
|
3406
|
+
}
|
|
3407
|
+
const splitList = (value, limit) => String(value || '').split(',').map((item) => item.trim()).filter(Boolean).slice(0, limit)
|
|
3408
|
+
const splitExamples = (value) => String(value || '').split('\n').map((item) => item.trim()).filter(Boolean).slice(0, 8)
|
|
3409
|
+
const strengthOf = (value) => {
|
|
3410
|
+
if (String(value ?? '').trim() === '') return undefined
|
|
3411
|
+
const n = Number(value)
|
|
3412
|
+
return Number.isFinite(n) ? Math.max(0, Math.min(1, n)) : undefined
|
|
3413
|
+
}
|
|
3414
|
+
const act = async (fn) => {
|
|
3415
|
+
setBusy(true)
|
|
3416
|
+
try { await fn() } catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
3417
|
+
}
|
|
3418
|
+
const saveEdit = () => {
|
|
3419
|
+
const current = editingId
|
|
3420
|
+
const draft = editDraft
|
|
3421
|
+
if (!current || !draft) return
|
|
3422
|
+
const patch = {
|
|
3423
|
+
meaning: draft.meaning,
|
|
3424
|
+
usage: draft.usage,
|
|
3425
|
+
aliases: splitList(draft.aliases, 20),
|
|
3426
|
+
examples: splitExamples(draft.examples),
|
|
3427
|
+
sensitivity: draft.sensitivity,
|
|
3428
|
+
}
|
|
3429
|
+
const strength = strengthOf(draft.strength)
|
|
3430
|
+
if (strength !== undefined) patch.strength = strength
|
|
3431
|
+
return act(async () => {
|
|
3432
|
+
await call('lexiconUpdate', { libraryId: activeLib, sessionId: sessionId || undefined, termId: current, patch })
|
|
3433
|
+
setEditingId(''); setEditDraft(null); setDeleteArmed(''); setArmedBulk('')
|
|
3434
|
+
notifyMemoryWrite('lexicon', activeLib)
|
|
3435
|
+
setNotice(t('lexiconSaveDone'))
|
|
3436
|
+
setError('')
|
|
3437
|
+
await load()
|
|
3438
|
+
})
|
|
3439
|
+
}
|
|
3440
|
+
// 归档 / 恢复(§2.4):可逆的一击动作,不走审核、不产生 revision。
|
|
3441
|
+
const setLifecycle = (e, action) => {
|
|
3442
|
+
setDeleteArmed(''); setArmedBulk('')
|
|
3443
|
+
return act(async () => {
|
|
3444
|
+
await call(action === 'archive' ? 'lexiconArchive' : 'lexiconRestore', { libraryId: activeLib, termId: e.id })
|
|
3445
|
+
notifyMemoryWrite('lexicon', activeLib)
|
|
3446
|
+
setNotice(action === 'archive' ? t('lexiconArchiveDone') : t('lexiconRestoreDone'))
|
|
3447
|
+
setError('')
|
|
3448
|
+
await load()
|
|
3449
|
+
})
|
|
3450
|
+
}
|
|
3451
|
+
// 删除是永久动作,只走管理面:两段确认由卡片按钮负责,这里只发 RPC。
|
|
3452
|
+
const deleteTerm = (e) => {
|
|
3453
|
+
setDeleteArmed(''); setArmedBulk('')
|
|
3454
|
+
return act(async () => {
|
|
3455
|
+
await call('lexiconDelete', { libraryId: activeLib, termId: e.id })
|
|
3456
|
+
notifyMemoryWrite('lexicon', activeLib)
|
|
3457
|
+
setNotice(t('lexiconDeleted').split('{n}').join('1'))
|
|
3458
|
+
setError('')
|
|
3459
|
+
await load()
|
|
3460
|
+
})
|
|
3461
|
+
}
|
|
3462
|
+
const submitNew = () => {
|
|
3463
|
+
const draft = safeNewDraft
|
|
3464
|
+
if (!String(draft.term || '').trim() || !String(draft.meaning || '').trim()) return
|
|
3465
|
+
return act(async () => {
|
|
3466
|
+
await call('lexiconAdd', {
|
|
3467
|
+
libraryId: activeLib,
|
|
3468
|
+
sessionId: sessionId || undefined,
|
|
3469
|
+
term: draft.term, kind: draft.kind, meaning: draft.meaning, usage: draft.usage,
|
|
3470
|
+
aliases: splitList(draft.aliases, 20), examples: splitExamples(draft.examples),
|
|
3471
|
+
})
|
|
3472
|
+
setCreating(false)
|
|
3473
|
+
setNewDraft({ ...EMPTY_LEXICON_DRAFT, kind: draft.kind })
|
|
3474
|
+
notifyMemoryWrite('lexicon', activeLib)
|
|
3475
|
+
setNotice(t('lexiconAddDone'))
|
|
3476
|
+
setError('')
|
|
3477
|
+
// 新词条总是 active:留在归档页签会看不见刚写入的词,切回使用中。
|
|
3478
|
+
setStatus('active')
|
|
3479
|
+
setPage(1)
|
|
3480
|
+
await load()
|
|
3481
|
+
})
|
|
3482
|
+
}
|
|
3483
|
+
const exitMulti = () => { setMulti(false); resetSelection() }
|
|
3484
|
+
const bulkApply = (action) => {
|
|
3485
|
+
const wanted = action === 'archive' ? 'active' : action === 'restore' ? 'archived' : null
|
|
3486
|
+
const rows = (Array.isArray(data?.items) ? data.items : []).filter((e) => chosenIds().has(e.id) && (!wanted || (e.status || 'active') === wanted))
|
|
3487
|
+
if (!rows.length) return
|
|
3488
|
+
// 与记忆墙的 bulkApply 同一约定:部分成功不能说成全部成功——成功数进 notice,
|
|
3489
|
+
// 失败明细进 error(带 done/total 前缀),两列分开读。
|
|
3490
|
+
return act(async () => {
|
|
3491
|
+
let done = 0
|
|
3492
|
+
const failures = []
|
|
3493
|
+
for (const row of rows) {
|
|
3494
|
+
try {
|
|
3495
|
+
if (action === 'delete') await call('lexiconDelete', { libraryId: activeLib, termId: row.id })
|
|
3496
|
+
else await call(action === 'archive' ? 'lexiconArchive' : 'lexiconRestore', { libraryId: activeLib, termId: row.id })
|
|
3497
|
+
done += 1
|
|
3498
|
+
} catch (failure) { failures.push(`${row.term || row.id}: ${String(failure?.message || failure)}`) }
|
|
3499
|
+
}
|
|
3500
|
+
setArmedBulk(''); setDeleteArmed(''); setSelectedIds(new Set())
|
|
3501
|
+
if (done > 0) {
|
|
3502
|
+
notifyMemoryWrite('lexicon', activeLib)
|
|
3503
|
+
await load()
|
|
3504
|
+
setNotice(action === 'delete'
|
|
3505
|
+
? t('lexiconDeleted').split('{n}').join(String(done))
|
|
3506
|
+
: action === 'archive'
|
|
3507
|
+
? t('lexiconArchivedCount').split('{n}').join(String(done))
|
|
3508
|
+
: t('lexiconRestoredCount').split('{n}').join(String(done)))
|
|
3509
|
+
}
|
|
3510
|
+
if (failures.length > 0) setError(`${done}/${rows.length} · ` + failures.slice(0, 3).join(';'))
|
|
3511
|
+
})
|
|
3512
|
+
}
|
|
3513
|
+
const toggleSelect = (id) => setSelectedIds((prev) => {
|
|
3514
|
+
const next = prev instanceof Set ? new Set(prev) : new Set()
|
|
3515
|
+
if (next.has(id)) next.delete(id); else next.add(id)
|
|
3516
|
+
return next
|
|
3517
|
+
})
|
|
3518
|
+
|
|
3519
|
+
const items = Array.isArray(data?.items) ? data.items : []
|
|
3520
|
+
const counts = data?.counts && typeof data.counts === 'object' ? data.counts : {}
|
|
3521
|
+
const statusCounts = data?.statusCounts && typeof data.statusCounts === 'object' ? data.statusCounts : { active: 0, archived: 0 }
|
|
3522
|
+
// The old row reused the generic nav pills (2px gap, 30px high) and sat directly
|
|
3523
|
+
// above the count tags, so the two rows read as one cramped button cluster. Keep
|
|
3524
|
+
// the state switch as its own segmented control and give the counts their own
|
|
3525
|
+
// line; the kind counts are real filter chips, not decoration.
|
|
3526
|
+
const statusTabs = h('div', {
|
|
3527
|
+
role: 'tablist',
|
|
3528
|
+
'aria-label': t('lexiconStatus'),
|
|
3529
|
+
style: {
|
|
3530
|
+
display: 'inline-flex', flexWrap: 'wrap', alignItems: 'stretch', gap: 4,
|
|
3531
|
+
padding: 4, margin: '2px 0 12px', maxWidth: '100%', boxSizing: 'border-box',
|
|
3532
|
+
border: `1px solid ${V.borderSoft}`, borderRadius: V.radius, background: V.surface,
|
|
3533
|
+
},
|
|
3534
|
+
}, Object.entries(LEXICON_TAB_LABELS).map(([value, key]) => {
|
|
3535
|
+
const selected = status === value
|
|
3536
|
+
return h('button', {
|
|
3537
|
+
key: value, type: 'button', role: 'tab', 'aria-selected': selected,
|
|
3538
|
+
className: 'dshm-nav-item',
|
|
3539
|
+
style: {
|
|
3540
|
+
height: 36, minHeight: 36, padding: '0 16px', border: 0, borderRadius: V.radiusSm,
|
|
3541
|
+
background: selected ? V.accentSoft : 'transparent',
|
|
3542
|
+
color: selected ? V.accent : V.textDim,
|
|
3543
|
+
fontWeight: selected ? 650 : 500, fontSize: 12.5, lineHeight: 1.2,
|
|
3544
|
+
cursor: 'pointer', whiteSpace: 'nowrap',
|
|
3545
|
+
transition: 'background .18s ease, color .18s ease, box-shadow .18s ease',
|
|
3546
|
+
},
|
|
3547
|
+
onClick: () => changeStatus(value),
|
|
3548
|
+
}, t(key).split('{n}').join(String(statusCounts[value] ?? 0)))
|
|
3549
|
+
}))
|
|
3550
|
+
const countsRow = h('div', { style: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 8, margin: '0 0 14px' } },
|
|
3551
|
+
h('span', { style: { ...S.muted, marginRight: 2 } }, t('lexiconTotal').split('{total}').join(String(data?.total ?? 0))),
|
|
3552
|
+
Object.entries(LEXICON_KIND_LABELS).map(([value, key]) => {
|
|
3553
|
+
const selected = kind === value
|
|
3554
|
+
const n = Number(counts[value]) || 0
|
|
3555
|
+
return h('button', {
|
|
3556
|
+
key: value, type: 'button',
|
|
3557
|
+
'aria-pressed': selected,
|
|
3558
|
+
title: `${t(key)} · ${n}`,
|
|
3559
|
+
style: {
|
|
3560
|
+
display: 'inline-flex', alignItems: 'center', gap: 6,
|
|
3561
|
+
minHeight: 30, padding: '0 11px', borderRadius: 999,
|
|
3562
|
+
border: `1px solid ${selected ? V.accent : V.borderSoft}`,
|
|
3563
|
+
background: selected ? V.accentSoft : V.surfaceRaised,
|
|
3564
|
+
color: selected ? V.accent : V.textDim,
|
|
3565
|
+
cursor: 'pointer', fontSize: 11.5, lineHeight: 1, whiteSpace: 'nowrap',
|
|
3566
|
+
transition: 'background .18s ease, border-color .18s ease, color .18s ease',
|
|
3567
|
+
},
|
|
3568
|
+
onClick: () => changeFilter(setKind)(selected ? '' : value),
|
|
3569
|
+
}, t(key), h('b', { style: { fontWeight: 650, color: selected ? V.accent : V.text } }, String(n)))
|
|
3570
|
+
}))
|
|
3571
|
+
const filterRow = h('div', { className: 'dshm-graph-tools', style: { flexWrap: 'wrap', marginTop: 0 } },
|
|
3572
|
+
h('input', {
|
|
3573
|
+
type: 'search', style: S.input, value: safeQueryInput, placeholder: t('lexiconSearch'),
|
|
3574
|
+
'aria-label': t('lexiconSearch'),
|
|
3575
|
+
onChange: (e) => setQueryInput(e.target.value),
|
|
3576
|
+
onKeyDown: (e) => { if (e.key === 'Enter') applySearch() },
|
|
3577
|
+
}),
|
|
3578
|
+
h(Button, { style: S.ghost, onClick: applySearch, disabled: busy }, t('logRefresh')),
|
|
3579
|
+
h(Button, { style: S.ghost, onClick: () => { setCreating((v) => !v); setEditingId(''); setEditDraft(null); setDeleteArmed(''); setArmedBulk('') } }, t('lexiconNew')),
|
|
3580
|
+
activeLib ? h(Button, { style: S.ghost, onClick: () => (multi ? exitMulti() : setMulti(true)), disabled: busy }, t('multiSelect')) : null)
|
|
3581
|
+
const newForm = creating
|
|
3582
|
+
? h('div', { style: { ...S.item, display: 'block' } },
|
|
3583
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
3584
|
+
h('input', { style: { ...S.input, flex: '1 1 160px' }, value: safeNewDraft.term, placeholder: t('lexiconTerm'), 'aria-label': t('lexiconTerm'), onChange: (e) => setNewDraft({ ...safeNewDraft, term: e.target.value }) }),
|
|
3585
|
+
h('select', { style: S.input, value: safeNewDraft.kind, 'aria-label': t('lexiconKind'), onChange: (e) => setNewDraft({ ...safeNewDraft, kind: e.target.value }) },
|
|
3586
|
+
Object.entries(LEXICON_KIND_LABELS).map(([value, key]) => h('option', { key: value, value }, t(key))))),
|
|
3587
|
+
h('textarea', { style: { ...S.textarea, minHeight: 54, marginTop: 8 }, value: safeNewDraft.meaning, placeholder: t('lexiconMeaning'), 'aria-label': t('lexiconMeaning'), onChange: (e) => setNewDraft({ ...safeNewDraft, meaning: e.target.value }) }),
|
|
3588
|
+
h('input', { style: { ...S.input, marginTop: 8 }, value: safeNewDraft.usage, placeholder: t('lexiconUsage'), 'aria-label': t('lexiconUsage'), onChange: (e) => setNewDraft({ ...safeNewDraft, usage: e.target.value }) }),
|
|
3589
|
+
h('input', { style: { ...S.input, marginTop: 8 }, value: safeNewDraft.aliases, placeholder: t('lexiconAliases'), 'aria-label': t('lexiconAliases'), onChange: (e) => setNewDraft({ ...safeNewDraft, aliases: e.target.value }) }),
|
|
3590
|
+
h('textarea', { style: { ...S.textarea, minHeight: 54, marginTop: 8 }, value: safeNewDraft.examples, placeholder: t('lexiconExamples'), 'aria-label': t('lexiconExamples'), onChange: (e) => setNewDraft({ ...safeNewDraft, examples: e.target.value }) }),
|
|
3591
|
+
h('div', { style: { display: 'flex', gap: 8, marginTop: 8 } },
|
|
3592
|
+
h(Button, { primary: true, disabled: busy || !String(safeNewDraft.term || '').trim() || !String(safeNewDraft.meaning || '').trim(), onClick: () => void submitNew() }, t('lexiconCreate')),
|
|
3593
|
+
h(Button, { style: S.ghost, disabled: busy, onClick: () => setCreating(false) }, t('cancelDelete'))))
|
|
3594
|
+
: null
|
|
3595
|
+
const editForm = (e) => {
|
|
3596
|
+
const draft = editingId === e.id && editDraft && typeof editDraft === 'object' ? editDraft : null
|
|
3597
|
+
if (!draft) return null
|
|
3598
|
+
return h('div', { style: { marginTop: 8, borderTop: `1px solid ${V.borderSoft}`, paddingTop: 8 } },
|
|
3599
|
+
h('textarea', { style: { ...S.textarea, minHeight: 54 }, value: draft.meaning, 'aria-label': t('lexiconMeaning'), onChange: (event) => setEditDraft({ ...draft, meaning: event.target.value }) }),
|
|
3600
|
+
h('input', { style: { ...S.input, marginTop: 8 }, value: draft.usage, 'aria-label': t('lexiconUsage'), onChange: (event) => setEditDraft({ ...draft, usage: event.target.value }) }),
|
|
3601
|
+
h('input', { style: { ...S.input, marginTop: 8 }, value: draft.aliases, 'aria-label': t('lexiconAliases'), onChange: (event) => setEditDraft({ ...draft, aliases: event.target.value }) }),
|
|
3602
|
+
h('textarea', { style: { ...S.textarea, minHeight: 54, marginTop: 8 }, value: draft.examples, 'aria-label': t('lexiconExamples'), onChange: (event) => setEditDraft({ ...draft, examples: event.target.value }) }),
|
|
3603
|
+
h('div', { style: { display: 'flex', gap: 8, marginTop: 8, flexWrap: 'wrap', alignItems: 'center' } },
|
|
3604
|
+
h('select', { style: S.input, value: draft.sensitivity, 'aria-label': t('lexiconSensitivity'), onChange: (event) => setEditDraft({ ...draft, sensitivity: event.target.value }) },
|
|
3605
|
+
h('option', { value: 'normal' }, t('lexiconNormal')),
|
|
3606
|
+
h('option', { value: 'sensitive' }, t('lexiconSensitive'))),
|
|
3607
|
+
h('input', { style: { ...S.input, maxWidth: 90 }, type: 'number', min: 0, max: 1, step: 0.05, value: draft.strength, 'aria-label': t('lexiconStrength'), onChange: (event) => setEditDraft({ ...draft, strength: event.target.value }) }),
|
|
3608
|
+
h(Button, { primary: true, disabled: busy, onClick: () => void saveEdit() }, t('save')),
|
|
3609
|
+
h(Button, { style: S.ghost, disabled: busy, onClick: () => { setEditingId(''); setEditDraft(null) } }, t('cancelDelete'))))
|
|
3610
|
+
}
|
|
3611
|
+
// 卡片流(§2.4):term 是标题,meaning 是正文(≤120 字),usage/aliases 是次要行;
|
|
3612
|
+
// 命中三计数与 strength 同记忆墙一样不抢标题的位置。
|
|
3613
|
+
const renderCard = (e) => {
|
|
3614
|
+
const editing = editingId === e.id
|
|
3615
|
+
const aliases = Array.isArray(e.aliases) ? e.aliases : []
|
|
3616
|
+
const armed = deleteArmed === e.id
|
|
3617
|
+
const selection = chosenIds()
|
|
3618
|
+
const hits = e.hitCounts && typeof e.hitCounts === 'object' ? e.hitCounts : {}
|
|
3619
|
+
const hitsTitle = t('lexiconHitsDetail')
|
|
3620
|
+
.split('{candidate}').join(String(Number(hits.candidate) || 0))
|
|
3621
|
+
.split('{injection}').join(String(Number(hits.injection) || 0))
|
|
3622
|
+
.split('{query}').join(String(Number(hits.query) || 0))
|
|
3623
|
+
return h('div', {
|
|
3624
|
+
key: e.id,
|
|
3625
|
+
style: { ...S.item, display: 'flex', flexDirection: 'column', gap: 7, minHeight: 150, ...(multi && selection.has(e.id) ? { outline: '2px solid ' + V.accent, outlineOffset: -2 } : {}) },
|
|
3626
|
+
},
|
|
3627
|
+
h('div', { style: { display: 'flex', gap: 7, alignItems: 'center', flexWrap: 'wrap' } },
|
|
3628
|
+
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,
|
|
3629
|
+
h('strong', { style: { fontSize: 15, fontWeight: 650, lineHeight: 1.3, overflowWrap: 'anywhere', flex: '1 1 120px' } }, e.term || e.id),
|
|
3630
|
+
h(Tag, null, enumText(t, LEXICON_KIND_LABELS, e.kind)),
|
|
3631
|
+
e.sensitivity === 'sensitive' ? h(Tag, { tone: 'warn' }, t('lexiconSensitive')) : null),
|
|
3632
|
+
h('p', { style: { margin: 0, fontSize: 12.5, lineHeight: 1.55, overflowWrap: 'anywhere', display: '-webkit-box', WebkitLineClamp: 3, WebkitBoxOrient: 'vertical', overflow: 'hidden' } },
|
|
3633
|
+
clipText(e.meaning, 120) || '—'),
|
|
3634
|
+
e.usage ? h('div', { style: { ...S.muted, overflowWrap: 'anywhere' } }, `${t('lexiconCardUsage')} · ${clipText(e.usage, 80)}`) : null,
|
|
3635
|
+
aliases.length ? h('div', { style: { ...S.muted, overflowWrap: 'anywhere' } }, `${t('lexiconCardAliases')} · ${aliases.slice(0, 4).join(', ')}`) : null,
|
|
3636
|
+
h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap', marginTop: 'auto' } },
|
|
3637
|
+
h('span', { style: S.muted, title: hitsTitle }, `⌁ ${hitsTotal(e)}`),
|
|
3638
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, flex: '1 1 90px', minWidth: 70 } },
|
|
3639
|
+
h(Bar, { value: e.strength ?? 0, title: `${t('lexiconStrength')} ${Math.round((Number(e.strength) || 0) * 100)}%` })),
|
|
3640
|
+
e.sourceMemoryId ? h(Button, {
|
|
3641
|
+
style: { ...S.ghost, padding: '1px 7px', flexShrink: 0 },
|
|
3642
|
+
title: t('lexiconSourceMemory'),
|
|
3643
|
+
onClick: () => onFocusMemory?.({ id: e.sourceMemoryId, libraryId: activeLib, title: e.term || e.id, at: Date.now() }),
|
|
3644
|
+
}, t('lexiconSourceMemory')) : null),
|
|
3645
|
+
h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' } },
|
|
3646
|
+
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => { setDeleteArmed(''); setArmedBulk(''); toggleEdit(e) } }, editing ? t('cancelDelete') : t('lexiconEdit')),
|
|
3647
|
+
// 归档 / 恢复是一击可逆动作;删除才要两段确认。
|
|
3648
|
+
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => void setLifecycle(e, status === 'archived' ? 'restore' : 'archive') },
|
|
3649
|
+
status === 'archived' ? t('lexiconRestore') : t('lexiconArchive')),
|
|
3650
|
+
armed
|
|
3651
|
+
? h(React.Fragment, null,
|
|
3652
|
+
h(Button, { style: { ...S.ghost, color: V.danger, borderColor: V.danger, padding: '2px 9px' }, disabled: busy, onClick: () => void deleteTerm(e) }, t('confirmDelete')),
|
|
3653
|
+
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => setDeleteArmed('') }, t('cancelDelete')))
|
|
3654
|
+
: h(Button, { style: { ...S.ghost, color: V.danger, padding: '2px 9px' }, disabled: busy, title: t('lexiconDeleteHint'), onClick: () => { setArmedBulk(''); setDeleteArmed(e.id) } }, t('lexiconDelete'))),
|
|
3655
|
+
editing ? editForm(e) : null)
|
|
3656
|
+
}
|
|
3657
|
+
const selectedRows = items.filter((e) => chosenIds().has(e.id))
|
|
3658
|
+
const multiBar = multi
|
|
3659
|
+
? (() => {
|
|
3660
|
+
const action = status === 'archived' ? 'restore' : 'archive'
|
|
3661
|
+
const actionLabel = action === 'archive' ? t('lexiconArchive') : t('lexiconRestore')
|
|
3662
|
+
const actionCount = selectedRows.filter((e) => (e.status || 'active') === (action === 'archive' ? 'active' : 'archived')).length
|
|
3663
|
+
const bulkButton = (value, label, count, danger) => {
|
|
3664
|
+
const armed = armedBulk === value
|
|
3665
|
+
return h(Button, {
|
|
3666
|
+
style: { ...S.ghost, ...(danger ? { color: V.danger } : {}), ...(armed ? { borderColor: danger ? V.danger : V.accent } : {}) },
|
|
3667
|
+
disabled: busy || count === 0,
|
|
3668
|
+
title: value === 'delete' ? t('lexiconDeleteHint') : undefined,
|
|
3669
|
+
onClick: () => {
|
|
3670
|
+
setDeleteArmed('')
|
|
3671
|
+
if (armedBulk !== value) { setArmedBulk(value); return }
|
|
3672
|
+
setArmedBulk('')
|
|
3673
|
+
void bulkApply(value)
|
|
3674
|
+
},
|
|
3675
|
+
}, (armed ? (value === 'delete' ? t('confirmDelete') : t('confirmAction')) : label) + ` (${count})`)
|
|
3676
|
+
}
|
|
3677
|
+
return h('div', { className: 'dshm-graph-tools', role: 'toolbar', 'aria-label': t('multiSelect') },
|
|
3678
|
+
h('span', { style: S.muted }, t('wallSelected').replace('{n}', String(selectedRows.length))),
|
|
3679
|
+
h(Button, { style: S.ghost, disabled: selectedRows.length === items.length, onClick: () => setSelectedIds(new Set(items.map((e) => e.id))) }, t('wallSelectAll')),
|
|
3680
|
+
h(Button, { style: S.ghost, disabled: selectedRows.length === 0, onClick: () => resetSelection() }, t('wallClearSelection')),
|
|
3681
|
+
// 批量归档/恢复/删除都是两段确认:第一次点只是 arm 当前动作。
|
|
3682
|
+
bulkButton(action, actionLabel, actionCount, false),
|
|
3683
|
+
bulkButton('delete', t('lexiconDelete'), selectedRows.length, true),
|
|
3684
|
+
armedBulk ? h(Button, { style: S.ghost, disabled: busy, onClick: () => setArmedBulk('') }, t('cancelDelete')) : null,
|
|
3685
|
+
h(Button, { style: S.ghost, onClick: exitMulti }, t('wallMultiExit')))
|
|
3686
|
+
})()
|
|
3687
|
+
: null
|
|
3688
|
+
const pager = h('div', { style: { display: 'flex', gap: 8, alignItems: 'center', marginTop: 10 } },
|
|
3689
|
+
h(Button, { style: S.ghost, disabled: busy || (data?.page || 1) <= 1, onClick: () => setPage(Math.max(1, (data?.page || 1) - 1)) }, t('lexiconPrev')),
|
|
3690
|
+
h('span', { style: S.muted }, t('lexiconPageOf').split('{page}').join(String(data?.page || 1)).split('{pages}').join(String(data?.pages || 1))),
|
|
3691
|
+
h(Button, { style: S.ghost, disabled: busy || (data?.page || 1) >= (data?.pages || 1), onClick: () => setPage((data?.page || 1) + 1) }, t('lexiconNext')),
|
|
3692
|
+
busy ? h('span', { style: S.muted }, t('loading')) : null)
|
|
3693
|
+
|
|
3694
|
+
return h(React.Fragment, null,
|
|
3695
|
+
h(Section, {
|
|
3696
|
+
title: t('lexiconScope'),
|
|
3697
|
+
desc: t('descLexicon'),
|
|
3698
|
+
icon: GlyphStack,
|
|
3699
|
+
right: h(Button, { style: S.ghost, onClick: () => { setPage(1); resetTransient(); return load() }, disabled: busy }, t('refresh')),
|
|
3700
|
+
},
|
|
3701
|
+
h('div', { style: S.row },
|
|
3702
|
+
h('span', { style: S.label }, t('currentLibrary')),
|
|
3703
|
+
h('select', {
|
|
3704
|
+
style: { ...S.input, flex: 1 }, value: libraryId,
|
|
3705
|
+
title: libraries.find((lib) => lib.id === activeLib)?.scopeKey || t('currentLibrary'),
|
|
3706
|
+
onChange: (e) => changeLibrary(e.target.value),
|
|
3707
|
+
},
|
|
3708
|
+
libraries.length === 0 ? h('option', { value: '' }, t('noLibraries')) : null,
|
|
3709
|
+
libraries.map((lib) => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))),
|
|
3710
|
+
libraries.length === 0
|
|
3711
|
+
? h(Empty, null, t('lexiconNoLibrary'))
|
|
3712
|
+
: h(React.Fragment, null, statusTabs, countsRow, filterRow, multiBar, newForm,
|
|
3713
|
+
error && typeof error === 'string' ? h('div', { className: 'dshm-error', role: 'alert' }, error) : null,
|
|
3714
|
+
notice && typeof notice === 'string' ? h('div', { style: { ...S.muted, marginTop: 6, color: V.accent } }, notice) : null,
|
|
3715
|
+
items.length === 0
|
|
3716
|
+
? h(Empty, null, query || kind ? t('lexiconNoMatch')
|
|
3717
|
+
: status === 'archived' ? t('lexiconArchivedEmpty') : t('lexiconEmpty'))
|
|
3718
|
+
: h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(280px, 100%), 1fr))', gap: 10, marginTop: 10 } }, items.map(renderCard)),
|
|
3719
|
+
pager)))
|
|
3720
|
+
}
|
|
3721
|
+
|
|
2637
3722
|
function SettingsPage({ ctx, t, embedded, standalone = false }) {
|
|
2638
3723
|
const PAGE = {
|
|
2639
3724
|
overview: 0,
|
|
@@ -2646,8 +3731,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2646
3731
|
prompts: 7,
|
|
2647
3732
|
stats: 8,
|
|
2648
3733
|
memories: 9,
|
|
3734
|
+
// logs:10 之前缺失:SETTINGS_PAGES 里有 'logs' 但 PAGE 没有对应索引,
|
|
3735
|
+
// 任何"跳到日志页"的入口都会错位到词典。补上,help 才能落在正确的 12。
|
|
3736
|
+
logs: 10,
|
|
3737
|
+
lexicon: 11,
|
|
3738
|
+
help: 12,
|
|
2649
3739
|
}
|
|
2650
3740
|
const call = useRpc(ctx)
|
|
3741
|
+
const sessionId = useCurrentSession(ctx)
|
|
2651
3742
|
const [state, setState] = React.useState(null)
|
|
2652
3743
|
const [prompts, setPrompts] = React.useState([])
|
|
2653
3744
|
const [promptsLoaded, setPromptsLoaded] = React.useState(false)
|
|
@@ -2897,9 +3988,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2897
3988
|
const loadReviews = React.useCallback(async () => {
|
|
2898
3989
|
try {
|
|
2899
3990
|
const [globalQueue, privateQueue] = await Promise.all([
|
|
2900
|
-
call('listReviews', {}),
|
|
3991
|
+
call('listReviews', sessionId ? { sessionId } : {}),
|
|
2901
3992
|
browseLibId
|
|
2902
|
-
? call('listReviews', { libraryId: browseLibId }).catch(() => ({ items: [] }))
|
|
3993
|
+
? call('listReviews', { libraryId: browseLibId, sessionId: sessionId || undefined }).catch(() => ({ items: [] }))
|
|
2903
3994
|
: Promise.resolve({ items: [] }),
|
|
2904
3995
|
])
|
|
2905
3996
|
setReviews([...(privateQueue?.items || []), ...(globalQueue?.items || [])])
|
|
@@ -3006,13 +4097,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3006
4097
|
React.useEffect(() => {
|
|
3007
4098
|
if (page !== PAGE.browser || !browseLibId) return undefined
|
|
3008
4099
|
let alive = true
|
|
3009
|
-
void call('browseLibrary', { libraryId: browseLibId }).then(result => {
|
|
4100
|
+
void call('browseLibrary', { libraryId: browseLibId, sessionId: sessionId || undefined }).then(result => {
|
|
3010
4101
|
if (!alive) return
|
|
3011
4102
|
setBrowseFiles(result.files || [])
|
|
3012
4103
|
setBrowseSource(result.source || '')
|
|
3013
4104
|
}).catch(error => { if (alive) setError(String(error.message || error)) })
|
|
3014
4105
|
return () => { alive = false }
|
|
3015
|
-
}, [call, page, browseLibId, state?.revision, state?.stamp])
|
|
4106
|
+
}, [call, page, browseLibId, sessionId, state?.revision, state?.stamp])
|
|
3016
4107
|
// Statistics are per library and read the whole index for the scatter, so they
|
|
3017
4108
|
// load only when that page is open. Every settings refresh (a heartbeat heard a
|
|
3018
4109
|
// write) re-reads them, which is what keeps the page honest.
|
|
@@ -3285,6 +4376,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3285
4376
|
return
|
|
3286
4377
|
}
|
|
3287
4378
|
notifyMemoryWrite('memory', browseLibId)
|
|
4379
|
+
setNotice(t('memorySaved'))
|
|
3288
4380
|
setNewMem({ title: '', content: '', layer: 'long_term', salientDate: '' })
|
|
3289
4381
|
await openBrowser(browseLibId)
|
|
3290
4382
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
@@ -3296,6 +4388,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3296
4388
|
try {
|
|
3297
4389
|
await call('updateMemory', { libraryId: browseLibId, id, patch })
|
|
3298
4390
|
notifyMemoryWrite('memory', browseLibId)
|
|
4391
|
+
setNotice(t('memorySaved'))
|
|
3299
4392
|
await openBrowser(browseLibId)
|
|
3300
4393
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
3301
4394
|
}
|
|
@@ -3304,6 +4397,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3304
4397
|
try {
|
|
3305
4398
|
await call('archiveMemory', { libraryId: browseLibId, id })
|
|
3306
4399
|
notifyMemoryWrite('memory', browseLibId)
|
|
4400
|
+
setNotice(t('memoryArchived'))
|
|
3307
4401
|
await openBrowser(browseLibId)
|
|
3308
4402
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
3309
4403
|
}
|
|
@@ -3312,6 +4406,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3312
4406
|
try {
|
|
3313
4407
|
await call('updateMemory', { libraryId: browseLibId, id, patch: { status: 'active' } })
|
|
3314
4408
|
notifyMemoryWrite('memory', browseLibId)
|
|
4409
|
+
setNotice(t('memoryRestored'))
|
|
3315
4410
|
await openBrowser(browseLibId)
|
|
3316
4411
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
3317
4412
|
}
|
|
@@ -3321,6 +4416,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3321
4416
|
try {
|
|
3322
4417
|
await call('deleteMemory', { libraryId: browseLibId, id })
|
|
3323
4418
|
notifyMemoryWrite('memory', browseLibId)
|
|
4419
|
+
setNotice(t('memoryDeleted'))
|
|
3324
4420
|
setDeleteArmed('')
|
|
3325
4421
|
await openBrowser(browseLibId)
|
|
3326
4422
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
@@ -3333,6 +4429,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3333
4429
|
action,
|
|
3334
4430
|
resolution: reviewDrafts[item.id]?.resolution || 'replace',
|
|
3335
4431
|
reason: reviewDrafts[item.id]?.reason || '',
|
|
4432
|
+
sessionId: sessionId || undefined,
|
|
3336
4433
|
...(item.libraryId ? { libraryId: item.libraryId } : {}),
|
|
3337
4434
|
})
|
|
3338
4435
|
notifyMemoryWrite('review', item.libraryId || null)
|
|
@@ -3342,32 +4439,63 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3342
4439
|
if (item.libraryId && browseLibId === item.libraryId) await openBrowser(item.libraryId)
|
|
3343
4440
|
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
3344
4441
|
}
|
|
3345
|
-
|
|
3346
|
-
|
|
4442
|
+
// 撤销集合合并(spec §4.11 undo-absorb / §6.7 UI):全局元数据动作,不带
|
|
4443
|
+
// libraryId;两段确认由 actionLabel/confirmAction 承担。成功后刷新全局列表。
|
|
4444
|
+
const undoAbsorb = async (id) => {
|
|
4445
|
+
if (!confirmAction('undo-absorb:' + id)) return
|
|
4446
|
+
setBusy(true)
|
|
4447
|
+
try {
|
|
4448
|
+
await call('resolveReview', { id, action: 'undo-absorb', sessionId: sessionId || undefined })
|
|
4449
|
+
setNotice(t('absorbUndone'))
|
|
4450
|
+
const res = await call('listGlobal', {})
|
|
4451
|
+
setGlobalFiles((res.files || []))
|
|
4452
|
+
setGlobalLoaded(true)
|
|
4453
|
+
await loadReviews()
|
|
4454
|
+
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
4455
|
+
}
|
|
4456
|
+
const removeGlobalLink = async (link) => {
|
|
4457
|
+
const linkId = String(link?.id || '')
|
|
4458
|
+
if (!linkId || !confirmAction('unlink:' + linkId)) return
|
|
4459
|
+
setBusy(true)
|
|
4460
|
+
try {
|
|
4461
|
+
await call('resolveReview', { linkId, action: 'unlink', sessionId: sessionId || undefined })
|
|
4462
|
+
setNotice(t('linkRemoved'))
|
|
4463
|
+
const res = await call('listGlobal', {})
|
|
4464
|
+
setGlobalFiles(res.files || [])
|
|
4465
|
+
setGlobalLoaded(true)
|
|
4466
|
+
await loadReviews()
|
|
4467
|
+
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
4468
|
+
}
|
|
4469
|
+
// 导出契约(spec §6.2):显式对象参数——libraryId 缺省取当前浏览库,但调用点可以
|
|
4470
|
+
// 传入别的 id(契约保证 payload、回退文件名、成功提示都用**传入**的 id)。
|
|
4471
|
+
const exportLibraryNow = async ({ libraryId = browseLibId, includeAttachments = false } = {}) => {
|
|
4472
|
+
if (!libraryId) return
|
|
3347
4473
|
setBrowseBusy(true)
|
|
3348
4474
|
try {
|
|
3349
|
-
const data = await call('exportLibrary', { libraryId:
|
|
4475
|
+
const data = await call('exportLibrary', { libraryId, sessionId: sessionId || undefined, includeAttachments, delivery: includeAttachments ? 'download' : undefined })
|
|
3350
4476
|
if (data.downloadUrl) {
|
|
3351
4477
|
const link = document.createElement('a')
|
|
3352
4478
|
link.href = data.downloadUrl; link.download = data.filename; link.click()
|
|
3353
|
-
|
|
4479
|
+
} else {
|
|
4480
|
+
const blob = data.base64
|
|
4481
|
+
? new Blob([Uint8Array.from(atob(data.base64), char => char.charCodeAt(0))], { type: 'application/zip' })
|
|
4482
|
+
: new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
|
|
4483
|
+
const url = URL.createObjectURL(blob)
|
|
4484
|
+
const a = document.createElement('a')
|
|
4485
|
+
a.href = url
|
|
4486
|
+
a.download = data.filename || `dsh-memu-memory-${libraryId}.json`
|
|
4487
|
+
a.click()
|
|
4488
|
+
URL.revokeObjectURL(url)
|
|
3354
4489
|
}
|
|
3355
|
-
|
|
3356
|
-
? new Blob([Uint8Array.from(atob(data.base64), char => char.charCodeAt(0))], { type: 'application/zip' })
|
|
3357
|
-
: new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
|
|
3358
|
-
const url = URL.createObjectURL(blob)
|
|
3359
|
-
const a = document.createElement('a')
|
|
3360
|
-
a.href = url
|
|
3361
|
-
a.download = data.filename || `dsh-memu-memory-${browseLibId}.json`
|
|
3362
|
-
a.click()
|
|
3363
|
-
URL.revokeObjectURL(url)
|
|
4490
|
+
setNotice(t('exportStarted').replace('{file}', data.filename || ''))
|
|
3364
4491
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
3365
4492
|
}
|
|
3366
4493
|
|
|
3367
4494
|
// Import reads the file in the browser and hands the text to the server: the
|
|
3368
4495
|
// host already owns the state directory, so no path guessing is needed.
|
|
3369
|
-
|
|
3370
|
-
|
|
4496
|
+
// 同一契约:payload 与 ZIP 上传 URL 都用**传入**的 libraryId,成功后回到该库。
|
|
4497
|
+
const importLibraryNow = ({ libraryId = browseLibId } = {}) => {
|
|
4498
|
+
if (!libraryId) return
|
|
3371
4499
|
const input = document.createElement('input')
|
|
3372
4500
|
input.type = 'file'
|
|
3373
4501
|
input.accept = 'application/json,.json,application/zip,.zip'
|
|
@@ -3378,10 +4506,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3378
4506
|
setNotice('')
|
|
3379
4507
|
setError('')
|
|
3380
4508
|
try {
|
|
3381
|
-
const payload = { libraryId:
|
|
4509
|
+
const payload = { libraryId, sessionId: sessionId || undefined }
|
|
3382
4510
|
let res
|
|
3383
4511
|
if (file.name.toLowerCase().endsWith('.zip')) {
|
|
3384
|
-
const
|
|
4512
|
+
const sessionQuery = sessionId ? '?sessionId=' + encodeURIComponent(sessionId) : ''
|
|
4513
|
+
const response = await fetch('/dsh-memu-memory/import/' + encodeURIComponent(libraryId) + '.zip' + sessionQuery, {
|
|
3385
4514
|
method: 'POST', credentials: 'same-origin', body: file, headers: { 'content-type': 'application/zip' },
|
|
3386
4515
|
})
|
|
3387
4516
|
const result = await response.json()
|
|
@@ -3398,8 +4527,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3398
4527
|
const adjusted = c.downgraded || 0
|
|
3399
4528
|
setNotice(`${t('importDone')}: +${res.imported || 0} / −${skipped}${adjusted ? ` · ${t('importAdjusted')}: ${adjusted}` : ''}`)
|
|
3400
4529
|
if (res.engineWarning) setError(`${t('importEngineWarning')}: ${res.engineWarning}`)
|
|
3401
|
-
notifyMemoryWrite('import',
|
|
3402
|
-
await openBrowser(
|
|
4530
|
+
notifyMemoryWrite('import', libraryId)
|
|
4531
|
+
await openBrowser(libraryId)
|
|
3403
4532
|
await refresh()
|
|
3404
4533
|
} catch (e) { setError(String(e?.message || e)) } finally { setBrowseBusy(false) }
|
|
3405
4534
|
}
|
|
@@ -3970,6 +5099,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3970
5099
|
h(Field, { label: t('minUserChars') }, h('input', { type: 'number', style: S.input, value: settings.minUserChars ?? 6, onChange: (e) => setSetting('minUserChars', Number(e.target.value)) })),
|
|
3971
5100
|
h(Field, { label: t('relevanceThreshold') }, h('input', { type: 'number', step: '0.05', min: 0, max: 1, style: S.input, value: settings.relevanceThreshold ?? 0.4, onChange: (e) => setSetting('relevanceThreshold', Number(e.target.value)) })),
|
|
3972
5101
|
h(Field, { label: t('randomCueChance') }, h('input', { type: 'number', step: '0.01', min: 0, max: 1, style: S.input, value: settings.randomCueChance ?? 0.02, onChange: (e) => setSetting('randomCueChance', Number(e.target.value)) })),
|
|
5102
|
+
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)) })),
|
|
5103
|
+
h(Field, { label: t('freshnessHint') }, h(Toggle, { checked: settings.freshnessHint !== false, label: t('freshnessHint'), onChange: value => setSetting('freshnessHint', value) })),
|
|
5104
|
+
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)) })),
|
|
5105
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('freshnessHintHint')),
|
|
5106
|
+
h(Field, { label: t('salientWake') },
|
|
5107
|
+
h('select', { style: S.input, value: settings.salientWake || 'off', onChange: (e) => setSetting('salientWake', e.target.value) },
|
|
5108
|
+
h('option', { value: 'off' }, t('salientWakeOff')),
|
|
5109
|
+
h('option', { value: 'schedule' }, t('salientWakeSchedule')))),
|
|
5110
|
+
h(Field, { label: t('salientWakeHour') }, h('input', { type: 'time', style: S.input, value: settings.salientWakeHour || '09:00', onChange: (e) => setSetting('salientWakeHour', e.target.value) })),
|
|
5111
|
+
h(Field, { label: t('salientWakeTimeZone') }, h('input', { type: 'text', style: S.input, placeholder: 'Asia/Shanghai', value: settings.salientWakeTimeZone || '', onChange: (e) => setSetting('salientWakeTimeZone', e.target.value) })),
|
|
5112
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('salientWakeHint')),
|
|
3973
5113
|
h(Field, { label: t('autoInstall') }, h('input', { type: 'checkbox', checked: settings.autoInstallEngine !== false, onChange: (e) => setSetting('autoInstallEngine', e.target.checked) })),
|
|
3974
5114
|
h(Field, { label: t('newSessionPrompt') }, h('input', { type: 'checkbox', checked: settings.newSessionPromptDismissed !== true, onChange: (e) => setSetting('newSessionPromptDismissed', !e.target.checked) })),
|
|
3975
5115
|
h(Field, { label: t('habitsInjection') }, h('input', { type: 'checkbox', checked: settings.habitsInjection !== false, onChange: (e) => setSetting('habitsInjection', e.target.checked) })),
|
|
@@ -4033,12 +5173,30 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4033
5173
|
? h(Empty, null, t('noArchived'))
|
|
4034
5174
|
: h('div', { style: S.list }, (state.archivedLibraries || []).map(renderArchivedItem))))
|
|
4035
5175
|
|
|
4036
|
-
const renderGlobalItem = (f) =>
|
|
5176
|
+
const renderGlobalItem = (f) => {
|
|
5177
|
+
// 集合记忆(spec §6.7 UI):absorbedFrom → 「集合记忆 · N 条来源」Tag +
|
|
5178
|
+
// 「撤销合并」两段确认按钮(resolveReview action:'undo-absorb')。links
|
|
5179
|
+
// 只读展示 + 「移除」(resolveReview action:'unlink'),不提供手动全局关联。
|
|
5180
|
+
const absorbed = Array.isArray(f.absorbedFrom) ? f.absorbedFrom : []
|
|
5181
|
+
const links = Array.isArray(f.links) ? f.links : []
|
|
5182
|
+
const titleOf = (id) => (globalFiles.find((item) => item.id === id)?.title) || id
|
|
5183
|
+
return h('div', { key: f.id, style: S.item },
|
|
4037
5184
|
h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8 } },
|
|
4038
5185
|
h('strong', null, f.title || f.id),
|
|
4039
5186
|
h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
|
|
4040
5187
|
h(Tag, null, domainText(t, f.domain)),
|
|
4041
5188
|
h(Tag, null, `conf ${f.confidence ?? '?'}`),
|
|
5189
|
+
links.length ? h(Tag, { tone: 'info' }, t('linkCountTag').replace('{n}', String(links.length))) : null,
|
|
5190
|
+
absorbed.length ? h(Tag, { tone: 'info' }, t('absorbSourcesTag').replace('{n}', String(absorbed.length))) : null,
|
|
5191
|
+
// 撤销合并:两段确认(点一次变为「确认此操作?」,再点才发请求)。
|
|
5192
|
+
absorbed.length
|
|
5193
|
+
? h(Button, {
|
|
5194
|
+
style: S.ghost,
|
|
5195
|
+
title: t('absorbUndo'),
|
|
5196
|
+
disabled: busy,
|
|
5197
|
+
onClick: () => { void undoAbsorb(f.id) },
|
|
5198
|
+
}, actionLabel('undo-absorb:' + f.id, t('absorbUndo')))
|
|
5199
|
+
: null,
|
|
4042
5200
|
// 查看此记忆:切到 MemU 记忆页的全局块并直接打开对应条目的抽屉。
|
|
4043
5201
|
h(Button, {
|
|
4044
5202
|
style: S.ghost,
|
|
@@ -4046,8 +5204,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4046
5204
|
onClick: () => { setWallFocus({ id: f.id, libraryId: null, title: f.title || f.id, at: Date.now() }); setPage(PAGE.memories) },
|
|
4047
5205
|
}, t('viewMemory')))),
|
|
4048
5206
|
h('div', { style: { ...S.muted, marginTop: 4, whiteSpace: 'pre-wrap' } },
|
|
4049
|
-
String(f.content || '').slice(0, 400))
|
|
5207
|
+
String(f.content || '').slice(0, 400)),
|
|
5208
|
+
links.length
|
|
5209
|
+
? h('div', { style: { ...S.muted, marginTop: 4 } },
|
|
5210
|
+
links.slice(0, 8).map((link) => h('div', { key: link.id || (link.to + ':' + link.kind), style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap' } },
|
|
5211
|
+
h('span', null, `${link.kind || 'related'} · ${titleOf(link.to)}`),
|
|
5212
|
+
h(Button, {
|
|
5213
|
+
style: { ...S.ghost, padding: '1px 6px' },
|
|
5214
|
+
disabled: busy,
|
|
5215
|
+
onClick: () => { void removeGlobalLink(link) },
|
|
5216
|
+
}, actionLabel('unlink:' + (link.id || ''), t('relationRemove'))))),
|
|
5217
|
+
links.length > 8 ? h('div', null, `… +${links.length - 8}`) : null)
|
|
5218
|
+
: null
|
|
4050
5219
|
)
|
|
5220
|
+
}
|
|
4051
5221
|
|
|
4052
5222
|
const renderSessionChoice = (s) => h('label', {
|
|
4053
5223
|
key: s.id,
|
|
@@ -4063,28 +5233,48 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4063
5233
|
h('div', { style: S.muted }, `${s.cwd || '—'} · ${s.agentPreset || 'general'}`))
|
|
4064
5234
|
)
|
|
4065
5235
|
|
|
4066
|
-
const renderReviewItem = (r) =>
|
|
5236
|
+
const renderReviewItem = (r) => {
|
|
5237
|
+
// 集合吸收提案(spec §6.7 UI):pendingAbsorb → 「集合吸收 · N 条」Tag +
|
|
5238
|
+
// 来源标题列表(≤6,从 globalFiles 的 id→标题映射);accept 恒为 replace
|
|
5239
|
+
// (合并稿不能与自己的来源并存,服务端对 coexist 直接抛错),所以隐藏
|
|
5240
|
+
// 复核方式选择器;保留 accept/reject,不做批量接受。
|
|
5241
|
+
const absorbSources = r.pendingAbsorb && Array.isArray(r.pendingAbsorb.sourceIds) ? r.pendingAbsorb.sourceIds : []
|
|
5242
|
+
const titleOf = (id) => {
|
|
5243
|
+
const file = (globalFiles || []).find((item) => item.id === id)
|
|
5244
|
+
return (file && (file.title || file.id)) || id
|
|
5245
|
+
}
|
|
5246
|
+
return h('div', { key: r.id, style: S.item },
|
|
4067
5247
|
h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8, alignItems: 'center' } },
|
|
4068
5248
|
h('div', { style: { minWidth: 0 } },
|
|
4069
5249
|
h('strong', null, r.title || r.id),
|
|
4070
5250
|
h('div', { style: S.row },
|
|
4071
5251
|
h(Tag, { tone: r.libraryId ? 'info' : undefined }, r.libraryId ? t('reviewScopePrivate') : (r.domain || 'unknown')),
|
|
5252
|
+
r.pendingAbsorb ? h(Tag, { tone: 'info' }, t('absorbTag').replace('{n}', String(absorbSources.length + 1))) : null,
|
|
4072
5253
|
r.reviewReason ? h(Tag, null, `${t('reviewReason')}: ${r.reviewReason}`) : null,
|
|
4073
5254
|
typeof r.confidence === 'number' ? h(Tag, null, `conf ${r.confidence}`) : null)),
|
|
4074
5255
|
h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
|
|
4075
5256
|
h(Button, { onClick: () => resolveReview(r, 'accept'), disabled: busy, primary: true }, t('accept')),
|
|
4076
5257
|
h(Button, { onClick: () => resolveReview(r, 'reject'), disabled: busy, style: S.ghost }, t('reject')))),
|
|
5258
|
+
absorbSources.length
|
|
5259
|
+
? h('div', { style: { ...S.muted, marginTop: 4, lineHeight: 1.6 } },
|
|
5260
|
+
absorbSources.slice(0, 6).map((id) => h('div', { key: id }, `· ${titleOf(id)}`)),
|
|
5261
|
+
absorbSources.length > 6 ? h('div', null, `… +${absorbSources.length - 6}`) : null)
|
|
5262
|
+
: null,
|
|
4077
5263
|
h('div', { style: { ...S.muted, marginTop: 6, whiteSpace: 'pre-wrap' } }, String(r.content || '').slice(0, 800)),
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
h('
|
|
4082
|
-
|
|
4083
|
-
|
|
5264
|
+
// 集合吸收的 accept 固定 replace:不渲染 coexist 选择器。
|
|
5265
|
+
!r.pendingAbsorb
|
|
5266
|
+
? h('div', { className: 'dshm-graph-tools' },
|
|
5267
|
+
h('select', { title: t('reviewResolution'), value: reviewDrafts[r.id]?.resolution || 'replace',
|
|
5268
|
+
onChange: event => setReviewDrafts(previous => ({ ...previous, [r.id]: { ...previous[r.id], resolution: event.target.value } })) },
|
|
5269
|
+
h('option', { value: 'replace' }, t('reviewReplace')), h('option', { value: 'coexist' }, t('reviewCoexist'))),
|
|
5270
|
+
reviewDrafts[r.id]?.resolution === 'coexist' ? h('input', { placeholder: t('reviewConditions'), value: reviewDrafts[r.id]?.reason || '',
|
|
5271
|
+
onChange: event => setReviewDrafts(previous => ({ ...previous, [r.id]: { ...previous[r.id], reason: event.target.value } })) }) : null)
|
|
5272
|
+
: null,
|
|
4084
5273
|
(r.evidence || []).length > 0
|
|
4085
5274
|
? h('div', { style: { ...S.muted, marginTop: 6, lineHeight: 1.6 } },
|
|
4086
5275
|
r.evidence.map((e, i) => h('div', { key: `${r.id}-ev-${i}` }, `· ${e.sessionId}:${String(e.quote || '').slice(0, 160)}`)))
|
|
4087
5276
|
: null)
|
|
5277
|
+
}
|
|
4088
5278
|
|
|
4089
5279
|
const globalBlock = h(React.Fragment, null,
|
|
4090
5280
|
h(Section, {
|
|
@@ -4114,7 +5304,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4114
5304
|
job ? h('div', { style: { ...S.muted, marginTop: 8 } },
|
|
4115
5305
|
`${job.status}${job.step ? ` · ${job.step}` : ''}`,
|
|
4116
5306
|
job.error ? h('div', { style: { color: V.danger } }, job.error) : null) : null
|
|
4117
|
-
)
|
|
5307
|
+
),
|
|
5308
|
+
// 审核模式(spec §6.1 包 A):这是设置页的 globalBlock,不是侧栏那个只读块。
|
|
5309
|
+
h(Section, { title: t('curatorReview'), desc: t('descCuratorReview') },
|
|
5310
|
+
h(Field, { label: t('curatorReview') },
|
|
5311
|
+
h('select', {
|
|
5312
|
+
style: S.input,
|
|
5313
|
+
value: settings.curatorReviewMode || 'auto',
|
|
5314
|
+
onChange: (e) => setSetting('curatorReviewMode', e.target.value),
|
|
5315
|
+
},
|
|
5316
|
+
h('option', { value: 'auto' }, t('curatorReviewAuto')),
|
|
5317
|
+
h('option', { value: 'review-all' }, t('curatorReviewAll')))))
|
|
4118
5318
|
)
|
|
4119
5319
|
|
|
4120
5320
|
const renderPromptItem = (p) => h('div', { key: p.key, style: S.item },
|
|
@@ -4244,7 +5444,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4244
5444
|
f.salientDate
|
|
4245
5445
|
? h(Tag, null, `${/^\d{4}-\d{2}-\d{2}$/.test(f.salientDate) ? t('dueDateTag') : t('anniversaryTag')} ${f.salientDate}`)
|
|
4246
5446
|
: null,
|
|
4247
|
-
moodText ? h(Tag,
|
|
5447
|
+
moodText ? h(Tag, { title: emotionMetaText(f, t) || undefined }, `${t('moodTag')} ${moodText}`) : null,
|
|
4248
5448
|
typeof f.accuracy === 'number' && typeof f.confidence === 'number' && f.accuracy <= 0.6 && f.accuracy < f.confidence - 0.1
|
|
4249
5449
|
? h(Tag, { tone: 'warn' }, `${t('accuracyTag')} ${f.accuracy}`) : null,
|
|
4250
5450
|
h(Tag, null, enumText(t, STATUS_LABELS, f.status || 'active'))),
|
|
@@ -4359,15 +5559,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4359
5559
|
right: h('div', { style: { display: 'flex', gap: 8, flexShrink: 0 } },
|
|
4360
5560
|
h(Button, { onClick: () => importLibraryNow(), disabled: !browseLibId || browseBusy, style: S.ghost, title: t('importHint') }, t('importJson')),
|
|
4361
5561
|
h(Button, { onClick: () => exportLibraryNow(), disabled: !browseLibId, style: S.ghost }, t('export')),
|
|
4362
|
-
h(Button, { onClick: () => exportLibraryNow(true), disabled: !browseLibId, title: t('
|
|
5562
|
+
h(Button, { onClick: () => exportLibraryNow({ includeAttachments: true }), disabled: !browseLibId, title: t('exportZip') }, t('exportZip')),
|
|
4363
5563
|
h(Button, { onClick: () => openBrowser(browseLibId), disabled: busy || !browseLibId, primary: true }, t('reload'))),
|
|
4364
5564
|
},
|
|
4365
5565
|
h('div', { style: S.row },
|
|
4366
5566
|
h('span', { style: S.label }, t('currentLibrary')),
|
|
4367
5567
|
h('select', {
|
|
4368
5568
|
style: { ...S.input, flex: 1 }, value: browseLibId,
|
|
5569
|
+
title: (state.libraries || []).find((lib) => lib.id === browseLibId)?.scopeKey || t('currentLibrary'),
|
|
4369
5570
|
onChange: (e) => setBrowseLibId(e.target.value),
|
|
4370
|
-
}, (state.libraries || []).map((l) => h('option', { key: l.id, value: l.id },
|
|
5571
|
+
}, (state.libraries || []).map((l) => h('option', { key: l.id, value: l.id }, libraryOptionLabel(l, state.libraries || []))))),
|
|
4371
5572
|
browseSource === 'index'
|
|
4372
5573
|
? h('div', { style: { ...S.muted, marginTop: 6 } }, t('browserIndexOnly'))
|
|
4373
5574
|
: null,
|
|
@@ -4512,8 +5713,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4512
5713
|
h('select', {
|
|
4513
5714
|
style: { ...S.input, flex: 1 },
|
|
4514
5715
|
value: statsLibId,
|
|
5716
|
+
title: (state.libraries || []).find((lib) => lib.id === statsLibId)?.scopeKey || t('currentLibrary'),
|
|
4515
5717
|
onChange: (e) => setStatsLibId(e.target.value),
|
|
4516
|
-
}, (state.libraries || []).map((l) => h('option', { key: l.id, value: l.id },
|
|
5718
|
+
}, (state.libraries || []).map((l) => h('option', { key: l.id, value: l.id }, libraryOptionLabel(l, state.libraries || []))))),
|
|
4517
5719
|
!statsLibId
|
|
4518
5720
|
? h(Empty, null, t('statsNoLibrary'))
|
|
4519
5721
|
: !statsData
|
|
@@ -4625,17 +5827,154 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4625
5827
|
]
|
|
4626
5828
|
pageDefs.push({ label: t('pageMemories'), overline: 'MEMU', desc: t('descMemories'), icon: GlyphLayers })
|
|
4627
5829
|
pageDefs.push({ label: t('pageLogs'), overline: 'ACTIVITY', desc: t('descLogs'), icon: GlyphText })
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
5830
|
+
pageDefs.push({ label: t('pageLexicon'), overline: 'LEXICON', desc: t('descLexicon'), icon: GlyphStack })
|
|
5831
|
+
pageDefs.push({ label: t('pageHelp'), overline: 'GUIDE', desc: t('descHelp'), icon: GlyphQuestion })
|
|
5832
|
+
// 首次安装引导(§6.5 包 E):只在还没有任何库时出现——有了库,用户已经过了
|
|
5833
|
+
// 这一步,卡片只会碍事。不落 localStorage:关不掉是刻意的,等第一个库建好
|
|
5834
|
+
// 它自然消失;以后要记关闭状态必须走 settings,不许加本地存储。
|
|
5835
|
+
const firstRunCard = (state.libraries || []).length === 0
|
|
5836
|
+
? h(Section, { title: t('firstRunTitle'), desc: t('firstRunDesc'), icon: GlyphLayers },
|
|
5837
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
5838
|
+
h(Button, { primary: true, onClick: () => setPage(PAGE.libraries) }, t('firstRunGoLibraries')),
|
|
5839
|
+
h(Button, { style: S.ghost, onClick: () => setPage(PAGE.help) }, t('firstRunGuide'))))
|
|
5840
|
+
: null
|
|
5841
|
+
const memoriesBlock = h(React.Fragment, null, firstRunCard,
|
|
5842
|
+
h(MemoryWallPanel, { call, libraries: state.libraries || [], revision: state.revision, stamp: state.stamp, t,
|
|
5843
|
+
indexed: localVector.vector?.indexed || null,
|
|
5844
|
+
focus: wallFocus,
|
|
5845
|
+
initialLibraryId: browseLibId,
|
|
5846
|
+
onNotice: setNotice,
|
|
5847
|
+
onOpen: item => {
|
|
5848
|
+
if (item.libraryId) { setBrowseLibId(item.libraryId); setPage(PAGE.browser); void openBrowser(item.libraryId) }
|
|
5849
|
+
else setPage(PAGE.global)
|
|
5850
|
+
} }))
|
|
5851
|
+
// 词典页:sourceMemoryId →「来源记忆 ↗」复用全局记忆页的 wallFocus 接力棒,
|
|
5852
|
+
// 跳到 MemU 记忆页并直接打开对应条目的抽屉。
|
|
5853
|
+
const lexiconBlock = h(LexiconPanel, {
|
|
5854
|
+
call,
|
|
5855
|
+
libraries: state.libraries || [],
|
|
5856
|
+
t,
|
|
5857
|
+
sessionId,
|
|
5858
|
+
onFocusMemory: (term) => {
|
|
5859
|
+
setWallFocus({ id: term.id, libraryId: term.libraryId || null, title: term.title || term.id, at: Date.now() })
|
|
5860
|
+
setPage(PAGE.memories)
|
|
5861
|
+
},
|
|
5862
|
+
})
|
|
5863
|
+
|
|
5864
|
+
// 帮助页 v2(包 G4):快速开始 5 步 + 七个详解区 + FAQ 11 条 + 反馈入口。
|
|
5865
|
+
// 所有跳转都走既有 setPage(不新增路由/RPC/localStorage),诊断复制只序列化
|
|
5866
|
+
// getSettingsState 已有快照(复用上方 copyText);正文全部走 i18n,段落/列表/
|
|
5867
|
+
// 表格只由本地小助手拼装,样式复用 Section/Tag/Button 与 S 里的既有 token。
|
|
5868
|
+
const helpStepTargets = [
|
|
5869
|
+
{ key: 'helpStep1', to: PAGE.libraries },
|
|
5870
|
+
{ key: 'helpStep2', to: null }, // 绑定发生在会话侧,页面里只能给文案指引
|
|
5871
|
+
{ key: 'helpStep3', to: PAGE.settings },
|
|
5872
|
+
{ key: 'helpStep4', to: PAGE.memories },
|
|
5873
|
+
{ key: 'helpStep5', to: PAGE.lexicon },
|
|
5874
|
+
]
|
|
5875
|
+
const copyDiagnostics = async () => {
|
|
5876
|
+
try {
|
|
5877
|
+
const snapshot = state || await call('getSettingsState', {})
|
|
5878
|
+
const engine = snapshot.engine || {}
|
|
5879
|
+
const summary = JSON.stringify({
|
|
5880
|
+
version: engine.currentVersion || engine.recommendedVersion || '',
|
|
5881
|
+
engine: { status: engine.status, installed: engine.installed, versions: engine.versions || [] },
|
|
5882
|
+
settings: snapshot.settings || {},
|
|
5883
|
+
libraries: (snapshot.libraries || []).map(lib => ({ id: lib.id, name: lib.name, scopeKey: lib.scopeKey, privateCount: lib.privateCount })),
|
|
5884
|
+
}, null, 2)
|
|
5885
|
+
const ok = await copyText(summary)
|
|
5886
|
+
setNotice(ok ? t('copied') : t('copyFailed'))
|
|
5887
|
+
} catch (failure) { setError(String(failure?.message || failure)) }
|
|
5888
|
+
}
|
|
5889
|
+
// 帮助页的三种小节积木:段落、列表、两列表格。它们只读 i18n 文本,
|
|
5890
|
+
// 不持有状态,也不做交互——帮助页是说明书,不是教程。
|
|
5891
|
+
const helpPara = key => h('p', { style: { ...S.muted, margin: '0 0 6px', fontSize: 12.5, lineHeight: 1.7 } }, t(key))
|
|
5892
|
+
const helpBullets = keys => h('ul', {
|
|
5893
|
+
style: { margin: '0 0 6px', padding: '0 0 0 18px', fontSize: 12.5, lineHeight: 1.7 },
|
|
5894
|
+
}, keys.map(key => h('li', { key, style: { marginBottom: 3 } }, t(key))))
|
|
5895
|
+
const helpCell = { borderBottom: `1px solid ${V.borderSoft}`, padding: '6px 8px', textAlign: 'left', verticalAlign: 'top' }
|
|
5896
|
+
const helpTable = rows => h('table', {
|
|
5897
|
+
'data-help-table': 'labels',
|
|
5898
|
+
style: { width: '100%', borderCollapse: 'collapse', fontSize: 12, lineHeight: 1.6 },
|
|
5899
|
+
},
|
|
5900
|
+
h('thead', null, h('tr', null,
|
|
5901
|
+
h('th', { style: { ...helpCell, fontWeight: 600, whiteSpace: 'nowrap' } }, t('helpLabelColLabel')),
|
|
5902
|
+
h('th', { style: { ...helpCell, fontWeight: 600 } }, t('helpLabelColMeaning')))),
|
|
5903
|
+
h('tbody', null, rows.map(([label, meaning, rowKey]) => h('tr', { key: rowKey, 'data-help-row': rowKey },
|
|
5904
|
+
h('td', { style: { ...helpCell, overflowWrap: 'anywhere', fontFamily: 'var(--dshm-mono)' } }, label),
|
|
5905
|
+
h('td', { style: { ...helpCell, overflowWrap: 'anywhere' } }, meaning)))))
|
|
5906
|
+
const helpLabelRows = [
|
|
5907
|
+
[t('helpLabelSource'), t('helpLabelSourceMeaning'), 'helpLabelSource'],
|
|
5908
|
+
[t('helpLabelLayer'), t('helpLabelLayerMeaning'), 'helpLabelLayer'],
|
|
5909
|
+
[t('helpLabelOpenLoop'), t('helpLabelOpenLoopMeaning'), 'helpLabelOpenLoop'],
|
|
5910
|
+
[t('helpLabelMarginalized'), t('helpLabelMarginalizedMeaning'), 'helpLabelMarginalized'],
|
|
5911
|
+
[t('helpLabelDate'), t('helpLabelDateMeaning'), 'helpLabelDate'],
|
|
5912
|
+
[t('helpLabelAttachment'), t('helpLabelAttachmentMeaning'), 'helpLabelAttachment'],
|
|
5913
|
+
[t('helpLabelVector'), t('helpLabelVectorMeaning'), 'helpLabelVector'],
|
|
5914
|
+
[t('helpLabelReviewRisk'), t('helpLabelReviewRiskMeaning'), 'helpLabelReviewRisk'],
|
|
5915
|
+
[t('helpLabelLexicon'), t('helpLabelLexiconMeaning'), 'helpLabelLexicon'],
|
|
5916
|
+
]
|
|
5917
|
+
const helpBlock = h(React.Fragment, null,
|
|
5918
|
+
h(Section, { title: t('helpQuickStart'), desc: t('descHelp'), icon: GlyphLayers },
|
|
5919
|
+
helpStepTargets.map((step, index) => h('div', { key: step.key, style: { ...S.row, alignItems: 'flex-start' } },
|
|
5920
|
+
h(Tag, { tone: 'info' }, String(index + 1)),
|
|
5921
|
+
h('span', { style: { flex: '1 1 320px', fontSize: 12.5, lineHeight: 1.6 } }, t(step.key)),
|
|
5922
|
+
step.to !== null
|
|
5923
|
+
? h(Button, { style: { ...S.ghost, flexShrink: 0 }, onClick: () => setPage(step.to) }, t('helpGoTo'))
|
|
5924
|
+
: null))),
|
|
5925
|
+
h(Section, { title: t('helpScopes'), desc: t('helpScopesDesc'), icon: GlyphFolder },
|
|
5926
|
+
helpPara('helpScopesChain'),
|
|
5927
|
+
h('div', { style: S.row }, ['useLibrary', 'useGlobal', 'effectiveScope'].map(key => h(Tag, { key, tone: 'info' }, key))),
|
|
5928
|
+
helpPara('helpScopesPrivate'),
|
|
5929
|
+
helpPara('helpScopesGlobal'),
|
|
5930
|
+
helpPara('helpScopesWhere'),
|
|
5931
|
+
h('div', { style: { ...S.muted, margin: '8px 0 4px', fontWeight: 600 } }, t('helpScopesPitfallsTitle')),
|
|
5932
|
+
helpBullets(['helpScopesPitfall1', 'helpScopesPitfall2', 'helpScopesPitfall3'])),
|
|
5933
|
+
h(Section, { title: t('helpTitleCards'), icon: GlyphLayers },
|
|
5934
|
+
helpPara('helpTitleCardsBody'),
|
|
5935
|
+
helpPara('helpTitleCardsRecall'),
|
|
5936
|
+
helpPara('helpTitleCardsRule')),
|
|
5937
|
+
h(Section, { title: t('helpArchiveDelete'), icon: GlyphStack },
|
|
5938
|
+
helpBullets(['helpArchiveDeleteArchive', 'helpArchiveDeleteDelete', 'helpArchiveDeleteLexicon',
|
|
5939
|
+
'helpArchiveDeleteAbsorb', 'helpArchiveDeleteSessionGone'])),
|
|
5940
|
+
h(Section, { title: t('helpVector'), icon: GlyphGauge },
|
|
5941
|
+
helpPara('helpVectorSetup'),
|
|
5942
|
+
helpPara('helpVectorCount'),
|
|
5943
|
+
helpPara('helpVectorFallback'),
|
|
5944
|
+
helpPara('helpVectorRebuild')),
|
|
5945
|
+
h(Section, { title: t('helpAutoLink'), icon: GlyphGlobe },
|
|
5946
|
+
helpPara('helpAutoLinkRule'),
|
|
5947
|
+
h('div', { style: S.row }, h(Tag, { tone: 'info' }, 'source=auto'), h(Tag, null, 'memu_private_link_suggest')),
|
|
5948
|
+
helpPara('helpAutoLinkHub'),
|
|
5949
|
+
helpPara('helpAutoLinkWorker'),
|
|
5950
|
+
helpPara('helpAutoLinkSafety')),
|
|
5951
|
+
h(Section, { title: t('helpLabels'), desc: t('helpLabelsDesc'), icon: GlyphText },
|
|
5952
|
+
helpTable(helpLabelRows)),
|
|
5953
|
+
h(Section, { title: t('helpSidebar'), desc: t('helpSidebarDesc'), icon: GlyphSliders },
|
|
5954
|
+
helpBullets(['helpSidebarAlerts', 'helpSidebarReview', 'helpSidebarRunLog',
|
|
5955
|
+
'helpSidebarReviewMode', 'helpSidebarFirstRun', 'helpSidebarFallback', 'helpSidebarScope'])),
|
|
5956
|
+
h(Section, { title: t('helpFaq'), icon: GlyphQuestion },
|
|
5957
|
+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(n => h('details', { key: 'helpFaq' + n, style: { margin: '0 0 8px' } },
|
|
5958
|
+
h('summary', { style: { cursor: 'pointer', fontSize: 12.5, fontWeight: 600, lineHeight: 1.5 } }, t('helpFaq' + n)),
|
|
5959
|
+
h('div', { style: { ...S.muted, marginTop: 5, fontSize: 12, lineHeight: 1.7 } }, t('helpFaq' + n + 'A'))))),
|
|
5960
|
+
h(Section, { title: t('helpFeedback'), icon: GlyphGlobe },
|
|
5961
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
5962
|
+
h(Button, {
|
|
5963
|
+
primary: true,
|
|
5964
|
+
title: t('helpOpenIssue'),
|
|
5965
|
+
onClick: () => { try { window.open('https://github.com/Tkingxiao/dsh-memu-memory/issues/new', '_blank') } catch {} },
|
|
5966
|
+
}, t('helpOpenIssue')),
|
|
5967
|
+
h(Button, { style: S.ghost, onClick: () => { void copyDiagnostics() } }, t('helpCopyDiagnostics')),
|
|
5968
|
+
h(Button, {
|
|
5969
|
+
style: S.ghost,
|
|
5970
|
+
title: t('helpDocs'),
|
|
5971
|
+
onClick: () => { try { window.open('https://github.com/Tkingxiao/dsh-memu-memory#readme', '_blank') } catch {} },
|
|
5972
|
+
}, t('helpDocs')))))
|
|
4635
5973
|
|
|
4636
5974
|
const LOG_KIND_LABELS = {
|
|
4637
5975
|
recall: t('logKindRecall'), write: t('logKindWrite'), consolidate: t('logKindConsolidate'),
|
|
4638
5976
|
curate: t('logKindCurate'), vector: t('logKindVector'), error: t('logKindError'), system: t('logKindSystem'), check: t('logKindCheck'),
|
|
5977
|
+
wake: t('logKindWake'),
|
|
4639
5978
|
}
|
|
4640
5979
|
const logsBlock = h(React.Fragment, null,
|
|
4641
5980
|
h(Section, {
|
|
@@ -4670,7 +6009,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4670
6009
|
onChange: (event) => setLogKind(event.target.value),
|
|
4671
6010
|
},
|
|
4672
6011
|
h('option', { value: '' }, t('logAllKinds')),
|
|
4673
|
-
['recall', 'write', 'consolidate', 'curate', 'vector', 'error', 'check'].map(kind => h('option', { key: kind, value: kind }, LOG_KIND_LABELS[kind]))),
|
|
6012
|
+
['recall', 'write', 'consolidate', 'curate', 'vector', 'error', 'check', 'wake'].map(kind => h('option', { key: kind, value: kind }, LOG_KIND_LABELS[kind]))),
|
|
4674
6013
|
h('input', {
|
|
4675
6014
|
style: S.input,
|
|
4676
6015
|
value: logQueryInput,
|
|
@@ -4719,7 +6058,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4719
6058
|
row.detail
|
|
4720
6059
|
? h('pre', { style: { ...S.muted, margin: '6px 0 0', fontSize: 11, whiteSpace: 'pre-wrap', wordBreak: 'break-all' } }, JSON.stringify(row.detail).slice(0, 600))
|
|
4721
6060
|
: null)))))
|
|
4722
|
-
const pageBlocks = [engineBlock, connectionBlock, settingsBlock, foldersBlock, librariesBlock, browserBlock, globalBlock, promptsBlock, statsBlock, memoriesBlock, logsBlock]
|
|
6061
|
+
const pageBlocks = [engineBlock, connectionBlock, settingsBlock, foldersBlock, librariesBlock, browserBlock, globalBlock, promptsBlock, statsBlock, memoriesBlock, logsBlock, lexiconBlock, helpBlock]
|
|
4723
6062
|
|
|
4724
6063
|
// Settings uses a left nav with a sliding indicator (the sidebar keeps its
|
|
4725
6064
|
// top segments). The indicator is one absolutely-positioned element moved by
|
|
@@ -5068,6 +6407,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5068
6407
|
const RUN_KIND_LABELS = {
|
|
5069
6408
|
recall: t('logKindRecall'), write: t('logKindWrite'), consolidate: t('logKindConsolidate'),
|
|
5070
6409
|
curate: t('logKindCurate'), vector: t('logKindVector'), error: t('logKindError'), system: t('logKindSystem'),
|
|
6410
|
+
check: t('logKindCheck'), wake: t('logKindWake'),
|
|
5071
6411
|
}
|
|
5072
6412
|
const renderRunRow = (row) => h('div', { key: row.id, style: S.item },
|
|
5073
6413
|
h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap' } },
|
|
@@ -5118,10 +6458,21 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5118
6458
|
// 但不再压住页头。数据不按当前对话过滤,展开后失败/成功两列各看最新 6 条。
|
|
5119
6459
|
alertBlock,
|
|
5120
6460
|
h('div', { style: { marginTop: 12 } },
|
|
5121
|
-
h('
|
|
6461
|
+
h('button', {
|
|
6462
|
+
type: 'button',
|
|
6463
|
+
title: t('runLogOpen'),
|
|
6464
|
+
onClick: () => { openWebUiPage('logs') },
|
|
6465
|
+
style: {
|
|
6466
|
+
display: 'flex', alignItems: 'center', gap: 6, width: '100%',
|
|
6467
|
+
marginBottom: 4, padding: 0, border: 0, background: 'transparent',
|
|
6468
|
+
color: 'inherit', font: 'inherit', textAlign: 'left', cursor: 'pointer',
|
|
6469
|
+
},
|
|
6470
|
+
},
|
|
6471
|
+
h('span', { style: { ...S.muted, fontWeight: 600 } }, t('runLogTitle')),
|
|
6472
|
+
h('span', { style: { marginLeft: 'auto', fontSize: 11, fontWeight: 600, color: V.accent } }, t('runLogOpen') + ' ↗')),
|
|
5122
6473
|
runLog.length === 0
|
|
5123
6474
|
? h('div', { style: S.muted }, t('runLogEmpty'))
|
|
5124
|
-
: h('div', { style: S.list }, runLog.slice(0,
|
|
6475
|
+
: h('div', { style: S.list }, runLog.slice(0, 5).map(renderRunRow)))),
|
|
5125
6476
|
// 作用域放在控制卡之后:它是一组低频字段,先让用户看到记忆开关和整理入口。
|
|
5126
6477
|
h(ContextScope, { binding, sessionId, call, t })
|
|
5127
6478
|
)
|
|
@@ -5230,7 +6581,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5230
6581
|
}, p.label)))),
|
|
5231
6582
|
error ? h('div', { style: { ...S.muted, padding: '8px 12px 0', color: V.danger } }, error) : null,
|
|
5232
6583
|
notice ? h('div', { style: { ...S.muted, padding: '8px 12px 0' } }, notice) : null,
|
|
5233
|
-
h('div', { style: S.tabBody }, pages[tabPage]?.node || null))
|
|
6584
|
+
h('div', { className: 'dshm-tab-body', style: S.tabBody }, pages[tabPage]?.node || null))
|
|
5234
6585
|
}
|
|
5235
6586
|
|
|
5236
6587
|
// One card = one pair of switches. The card the user clicks, the binding
|
|
@@ -5497,8 +6848,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5497
6848
|
// scope was written and the folder policy checked both switches.
|
|
5498
6849
|
h('label', { style: S.row }, h('input', { type: 'radio', name: 'memu-library', checked: pick === 'folder', onChange: () => setPick('folder') }), t('folderLibrary')),
|
|
5499
6850
|
h('label', { style: S.row }, h('input', { type: 'radio', name: 'memu-library', checked: pick === 'existing', onChange: () => setPick('existing') }), t('chooseLibrary')),
|
|
5500
|
-
pick === 'existing' ? h('select', {
|
|
5501
|
-
|
|
6851
|
+
pick === 'existing' ? h('select', {
|
|
6852
|
+
style: { ...S.input, marginLeft: 24 }, value: libraryId,
|
|
6853
|
+
title: libraries.find((lib) => lib.id === libraryId)?.scopeKey || t('currentLibrary'),
|
|
6854
|
+
onChange: (e) => setLibraryId(e.target.value),
|
|
6855
|
+
}, libraries.map((l) => h('option', { key: l.id, value: l.id }, libraryOptionLabel(l, libraries)))) : null,
|
|
5502
6856
|
h('label', { style: S.row }, h('input', { type: 'radio', name: 'memu-library', checked: pick === 'new', onChange: () => setPick('new') }), t('createLibrary')),
|
|
5503
6857
|
pick === 'new' ? h('input', { style: { ...S.input, marginLeft: 24 }, placeholder: t('name'), value: newName, onChange: (e) => setNewName(e.target.value) }) : null)),
|
|
5504
6858
|
h('label', { style: { ...S.row, marginTop: 12 } }, h('input', { type: 'checkbox', checked: dontShow, onChange: (e) => setDontShow(e.target.checked) }), t('rememberChoice')))
|
|
@@ -5516,7 +6870,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5516
6870
|
body: JSON.stringify({ type: 'client-request', rpcId: 'standalone-' + (++sequence), method: endpoint, payload: payload || {} }),
|
|
5517
6871
|
})
|
|
5518
6872
|
const envelope = await response.json()
|
|
5519
|
-
if (!envelope.result)
|
|
6873
|
+
if (!envelope.result) {
|
|
6874
|
+
// 服务端错误信封(如 403 forbidden)带可读 message:透传它而不是
|
|
6875
|
+
// 只报 HTTP 状态码,用户才能看到「为什么」。
|
|
6876
|
+
throw new Error(envelope.error?.message || ('Invalid RPC response: ' + response.status))
|
|
6877
|
+
}
|
|
5520
6878
|
return envelope.result
|
|
5521
6879
|
} } },
|
|
5522
6880
|
}
|