dsh-memu-memory 1.4.3 → 1.4.5
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/CHANGELOG.md +15 -0
- package/README.md +34 -15
- package/README.zh.md +35 -13
- package/assets/screenshots/drawer.jpg +0 -0
- package/assets/screenshots/libraries.jpg +0 -0
- package/assets/screenshots/mobile.jpg +0 -0
- package/assets/screenshots/relations.jpg +0 -0
- package/assets/screenshots/settings.jpg +0 -0
- package/assets/screenshots/webui-dark.jpg +0 -0
- package/assets/screenshots/webui-memory.jpg +0 -0
- package/docs/client-conventions.md +19 -3
- package/docs/contributing.md +4 -2
- package/docs/env-and-commands.md +9 -1
- package/docs/graph-scale.md +214 -0
- package/docs/lexicon-recall.md +100 -0
- package/docs/mcp-porting.md +8 -6
- package/docs/memory-semantics.md +35 -3
- package/docs/pending-work.md +3 -1
- package/docs/retention.md +83 -0
- package/docs/rt-index.md +452 -0
- package/docs/scale-performance.md +101 -0
- package/docs/token-budget.md +92 -0
- package/docs/troubleshooting.md +50 -11
- package/lib/auto-link/apply.js +7 -2
- package/lib/auto-link/candidates.js +32 -10
- package/lib/backup.js +67 -32
- package/lib/binding-diagnostics.js +1 -1
- package/lib/bounded-cache.js +80 -0
- package/lib/client.js +2096 -409
- package/lib/consolidation-ledger.js +21 -4
- package/lib/consolidation-worker.js +14 -1
- package/lib/cycle.js +16 -11
- package/lib/diagnostic-context.js +372 -0
- package/lib/diagnostics.js +147 -61
- package/lib/embedding-download.js +7 -8
- package/lib/engine-sources.js +286 -0
- package/lib/engine.js +23 -10
- package/lib/entity-repair.js +43 -13
- package/lib/entity-review.js +64 -0
- package/lib/environment-check.js +348 -36
- package/lib/feedback.js +25 -0
- package/lib/global-graph.js +46 -2
- package/lib/graph-adjacency-index.js +525 -0
- package/lib/graph-overview.js +293 -0
- package/lib/graph.js +658 -105
- package/lib/inbound.js +44 -15
- package/lib/index-pages.js +57 -0
- package/lib/index.js +44 -6
- package/lib/inject.js +119 -50
- package/lib/lexicon-rt-source.js +25 -0
- package/lib/lexicon-rt-worker.js +26 -0
- package/lib/lexicon-rt.js +224 -0
- package/lib/lexicon-scope.js +56 -5
- package/lib/lexicon.js +143 -54
- package/lib/local-vector-service.js +3 -0
- package/lib/maintenance-ledger.js +542 -12
- package/lib/managed-runtime.js +260 -80
- package/lib/media.js +1 -1
- package/lib/memory.js +564 -131
- package/lib/port-surface.js +96 -11
- package/lib/preset-mount.js +13 -7
- package/lib/private.js +47 -21
- package/lib/recall-cache.js +20 -34
- package/lib/retention.js +173 -0
- package/lib/rpc.js +135 -52
- package/lib/rt-index/builder.js +209 -0
- package/lib/rt-index/format.js +231 -0
- package/lib/rt-index/manifest.js +105 -0
- package/lib/rt-index/reader.js +673 -0
- package/lib/rt-index-retention.js +151 -0
- package/lib/rt-index-service.js +283 -0
- package/lib/rt-index-worker.js +21 -0
- package/lib/salient-wake.js +55 -4
- package/lib/state.js +195 -24
- package/lib/temporal.js +39 -13
- package/lib/token-measurement.js +126 -0
- package/lib/tools.js +101 -6
- package/lib/turn-log.js +108 -3
- package/lib/webui/graph-layout-worker.js +68 -0
- package/lib/webui/graph-local-physics.js +390 -0
- package/lib/webui/graph-spatial-grid.js +64 -0
- package/lib/webui/graph-view.bundle.js +6 -1
- package/lib/webui/graph-view.js +478 -135
- package/lib/webui/graph-webgl-renderer.js +74 -0
- package/lib/webui/standalone.js +1 -1
- package/lib/worker-pool.js +38 -7
- package/package.json +3 -2
- package/scripts/acceptance-local.mjs +4 -10
- package/scripts/bench-all-libraries.mjs +47 -0
- package/scripts/check-classic-graph-browser.mjs +189 -0
- package/scripts/check-client-browser.mjs +929 -0
- package/scripts/check-graph-browser.mjs +6 -0
- package/scripts/check-graph-elastic-browser.mjs +139 -0
- package/scripts/check-memory-review-browser.mjs +124 -0
- package/scripts/entity-dedupe.mjs +19 -3
- package/scripts/graph-artifact-provenance.mjs +30 -0
- package/scripts/graph-freeze-manifest.mjs +129 -0
- package/scripts/graph-geometry-fixture.mjs +40 -0
- package/scripts/graph-physics-bench.mjs +218 -0
- package/scripts/graph-scale-bench.mjs +213 -0
- package/scripts/graph-scale-memory.mjs +48 -0
- package/scripts/graph-service-bench.mjs +72 -0
- package/scripts/make-readme-shots.mjs +17 -5
- package/scripts/preview.mjs +1 -0
- package/scripts/rebuild-rt.mjs +18 -0
- package/scripts/scale-bench.mjs +183 -0
- package/scripts/simulate-injection.mjs +47 -8
- package/scripts/verify-host-fixtures.mjs +108 -0
- package/scripts/verify-host-recovery.mjs +565 -0
- package/scripts/verify-vector-recovery.mjs +740 -0
- package/tests/auto-link-candidates.test.mjs +20 -0
- package/tests/browser.test.mjs +16 -2
- package/tests/client-export.test.mjs +16 -1
- package/tests/client-pagination.test.mjs +1495 -0
- package/tests/client-render.test.mjs +223 -28
- package/tests/consolidation-fork.test.mjs +97 -13
- package/tests/consolidation-ledger.test.mjs +17 -1
- package/tests/diagnostic-entity-candidates.test.mjs +54 -0
- package/tests/diagnostic-report.test.mjs +429 -0
- package/tests/diagnostic-wiring.test.mjs +88 -0
- package/tests/diagnostics.test.mjs +27 -0
- package/tests/embedding-download.test.mjs +44 -0
- package/tests/engine-source-settings.test.mjs +69 -0
- package/tests/engine-sources.test.mjs +145 -0
- package/tests/entity-dedupe.test.mjs +143 -0
- package/tests/entity-merge-review.test.mjs +363 -0
- package/tests/entity-merge.test.mjs +12 -4
- package/tests/entity-review.test.mjs +87 -0
- package/tests/environment-check.test.mjs +51 -1
- package/tests/feedback.test.mjs +95 -0
- package/tests/graph-adjacency-index.test.mjs +536 -0
- package/tests/graph-cascade.test.mjs +229 -0
- package/tests/graph-import-diagnostic.test.mjs +25 -0
- package/tests/graph-overview.test.mjs +709 -0
- package/tests/graph-session-authorization.test.mjs +419 -0
- package/tests/graph-view-geometry.test.mjs +426 -0
- package/tests/graph-view-scale.test.mjs +88 -0
- package/tests/graph-view.test.mjs +444 -5
- package/tests/graph.test.mjs +43 -0
- package/tests/help-page.test.mjs +128 -54
- package/tests/inbound.test.mjs +19 -0
- package/tests/index-pagination.test.mjs +113 -0
- package/tests/index-read-view.test.mjs +212 -0
- package/tests/inject-guide.test.mjs +9 -0
- package/tests/injection-dedupe.test.mjs +213 -0
- package/tests/lexicon-recall.test.mjs +641 -0
- package/tests/lexicon-rt-lifecycle.test.mjs +196 -0
- package/tests/lexicon-rt.test.mjs +468 -0
- package/tests/local-embedding-worker.test.mjs +38 -0
- package/tests/local-vector-service.test.mjs +32 -3
- package/tests/maintenance-compat.test.mjs +128 -0
- package/tests/maintenance-settlement.test.mjs +1003 -0
- package/tests/managed-memory.test.mjs +39 -11
- package/tests/managed-runtime.test.mjs +109 -0
- package/tests/memory-fields.test.mjs +24 -12
- package/tests/observed-evidence.test.mjs +52 -0
- package/tests/port-surface.test.mjs +93 -1
- package/tests/preset-mount.test.mjs +12 -4
- package/tests/recall-cache.test.mjs +56 -3
- package/tests/recall-dedup.test.mjs +63 -2
- package/tests/retention.test.mjs +260 -0
- package/tests/rt-index-cross-library.test.mjs +230 -0
- package/tests/rt-index-integration.test.mjs +194 -0
- package/tests/rt-index-retention.test.mjs +552 -0
- package/tests/rt-index-scale.test.mjs +204 -0
- package/tests/rt-index.test.mjs +705 -0
- package/tests/salient-date-boundaries.test.mjs +121 -0
- package/tests/salient-wake.test.mjs +29 -0
- package/tests/scale-bench.test.mjs +53 -0
- package/tests/settings-plumbing.test.mjs +25 -0
- package/tests/simulate-injection.test.mjs +15 -1
- package/tests/standalone-navigation.test.mjs +44 -0
- package/tests/state.test.mjs +51 -0
- package/tests/temporal-precision.test.mjs +102 -0
- package/tests/temporal.test.mjs +10 -6
- package/tests/token-measurement.test.mjs +98 -0
- package/tests/tool-schema.test.mjs +41 -5
- package/tests/tools.test.mjs +6 -3
- package/tests/turn-token-budget.test.mjs +149 -0
- package/tests/webui-auth.test.mjs +57 -1
- package/tests/webui.test.mjs +40 -15
- package/tests/worker-lifecycle.test.mjs +2 -1
package/lib/client.js
CHANGED
|
@@ -118,7 +118,7 @@ window.__ModuleLoader__.load({
|
|
|
118
118
|
pageMemories: 'MemU 记忆',
|
|
119
119
|
descMemories: '跨库记忆、来源与状态',
|
|
120
120
|
pageGraph: '关系图谱',
|
|
121
|
-
descGraph: '
|
|
121
|
+
descGraph: '力导向节点图:拖动落位、右键固定、弹簧链跟随',
|
|
122
122
|
graphCenter: '向心力',
|
|
123
123
|
graphPinned: '已固定',
|
|
124
124
|
graphUnpinAll: '解除全部固定',
|
|
@@ -184,6 +184,16 @@ window.__ModuleLoader__.load({
|
|
|
184
184
|
gsAllStatus: '全部状态',
|
|
185
185
|
gsSort: '排序方式',
|
|
186
186
|
gsNoMatch: '没有匹配的节点',
|
|
187
|
+
gsIncludeOrphans: '包含未关联实体',
|
|
188
|
+
gsManagerScope: '管理目标库',
|
|
189
|
+
gsManagerChoose: '请选择管理目标库',
|
|
190
|
+
gsManagerPage: '本页筛选与排序 · 已加载 {n} / 查询共 {total}',
|
|
191
|
+
gsManagerPrevious: '上一页',
|
|
192
|
+
gsManagerNext: '下一页',
|
|
193
|
+
gsManagerBack: '返回管理列表',
|
|
194
|
+
gsManagerFocus: '定点管理 · 库 {library} · ID {id}',
|
|
195
|
+
gsManagerChanged: '管理数据持续变化,请刷新后重试',
|
|
196
|
+
gsManagerUnavailable: '此 ID 在当前会话或域范围内不可见;权限允许时请切换管理范围',
|
|
187
197
|
gsShortcuts: '+/− 缩放 · F 适应 · / 搜索 · 左键拖动 · 右键锁定/解除 · Shift 整簇 · 双击聚焦',
|
|
188
198
|
gsLegendMemory: '长期记忆',
|
|
189
199
|
gsLegendMust: '永久记忆',
|
|
@@ -206,6 +216,42 @@ window.__ModuleLoader__.load({
|
|
|
206
216
|
pageDiagnostics: '诊断',
|
|
207
217
|
descDiagnostics: '插件内部的故障与修复记录(含 stderr、目录、修复动作),与活动日志分开存放',
|
|
208
218
|
diagEnvTitle: '环境自检',
|
|
219
|
+
diagReportTitle: '运行环境与故障定位',
|
|
220
|
+
diagReportDesc: '只读技术快照:区分宿主、插件、引擎、向量、存储与后台任务;未知状态不会当成正常。',
|
|
221
|
+
diagReportUnavailable: '尚未取得完整脱敏诊断报告,请重新检查后重试。',
|
|
222
|
+
diagReportPrivacy: '报告只导出脱敏技术元数据、计数和错误调用位置,不复制设置、API key、记忆正文或原始对话。',
|
|
223
|
+
diagReportTime: '采集时间',
|
|
224
|
+
diagReportHost: 'DSH 版本',
|
|
225
|
+
diagReportPlugin: '插件版本',
|
|
226
|
+
diagReportNode: 'Node.js / ABI',
|
|
227
|
+
diagReportOs: '操作系统',
|
|
228
|
+
diagReportSource: '证据来源',
|
|
229
|
+
diagReportDetails: '展开完整技术细节',
|
|
230
|
+
diagReportDownload: '下载脱敏报告',
|
|
231
|
+
diagReportLayer: '故障层',
|
|
232
|
+
diagReportOperation: '操作',
|
|
233
|
+
diagReportCorrelation: '请求关联号',
|
|
234
|
+
diagReportRetry: '重试策略',
|
|
235
|
+
diagReportRetryAllowed: '可在退避后重试',
|
|
236
|
+
diagReportRetryManual: '先核对原因再重试',
|
|
237
|
+
diagReportRetryAfter: '建议等待(毫秒)',
|
|
238
|
+
diagReportCause: '原因与调用位置',
|
|
239
|
+
diagReportContext: '技术上下文',
|
|
240
|
+
diagReportLimitations: '此快照能证明什么',
|
|
241
|
+
diagLayerHost: 'DSH 宿主',
|
|
242
|
+
diagLayerPlugin: '插件程序',
|
|
243
|
+
diagLayerEngine: 'MemU 引擎',
|
|
244
|
+
diagLayerVector: '向量模型与索引',
|
|
245
|
+
diagLayerState: '状态与持久化',
|
|
246
|
+
diagLayerRpc: 'RPC 与入口守卫',
|
|
247
|
+
diagLayerWorkers: '后台任务与运行时',
|
|
248
|
+
diagStatusObserved: '已观测',
|
|
249
|
+
diagStatusUnknown: '未知 / 未实测',
|
|
250
|
+
diagStatusSkipped: '未启用 / 已跳过',
|
|
251
|
+
diagStatusNotBuilt: '尚未建库',
|
|
252
|
+
diagStatusAbsent: '文件不存在',
|
|
253
|
+
diagStatusError: '故障',
|
|
254
|
+
diagStatusDegraded: '已降级',
|
|
209
255
|
diagHostSurface: '宿主形状:',
|
|
210
256
|
diagHostSurfaceHint: '这些值来自本插件的宿主能力探测,用于核对 docs/host-versions.md 的台账行;插件不据此分支,也不读宿主版本号。',
|
|
211
257
|
diagEnvDesc: '启动时与打开本页时各检查一次:数据目录、遗留锁、引擎、向量档案、运行时、模型文件',
|
|
@@ -279,7 +325,52 @@ window.__ModuleLoader__.load({
|
|
|
279
325
|
poolReview: '待复核',
|
|
280
326
|
poolInactive: '已失效',
|
|
281
327
|
wallReadError: '部分记忆库读取失败',
|
|
282
|
-
wallLimit: '
|
|
328
|
+
wallLimit: '已加载,触底继续读取',
|
|
329
|
+
memoryLoaded: '已加载',
|
|
330
|
+
memoryPageChanged: 'MEMORY_CHANGED:记忆持续变化,已停止翻页,请刷新重试',
|
|
331
|
+
gsOverview: '总览',
|
|
332
|
+
gsReview: '图谱处理',
|
|
333
|
+
gsReviewLibrary: '处理记忆库',
|
|
334
|
+
gsReviewScope: '以下候选和操作属于所选记忆库,不随画布的域或节点筛选缩小范围。',
|
|
335
|
+
gsReviewLimit: '相似实体每批最多显示 {limit} 对;未检查完时只显示已发现数量。每对需单独确认,名字相近不会自动融合。',
|
|
336
|
+
gsReviewUnavailable: '部分候选读取失败,待处理数不完整',
|
|
337
|
+
gsReviewUnchecked: '待检查',
|
|
338
|
+
gsReviewPartialCount: '≥{n} · 数量不完整',
|
|
339
|
+
gsReviewDiscovered: '本批显示 {shown} 对;累计发现至少 {total} 对,非全库精确总数',
|
|
340
|
+
gsReviewScanProgress: '已检查 {scanned} / {space} 对实体组合',
|
|
341
|
+
gsReviewScanIncomplete: '尚未检查完,可继续扫描下一批候选',
|
|
342
|
+
gsReviewScanComplete: '本轮已检查至末尾。前批未处理候选可从头检查。',
|
|
343
|
+
gsReviewContinue: '继续扫描',
|
|
344
|
+
gsReviewRestart: '从头检查',
|
|
345
|
+
gsReviewScanReset: '候选扫描已失效,已从头重新检查',
|
|
346
|
+
gsReviewGroups: '相似实体组',
|
|
347
|
+
gsReviewShowing: '已显示 {shown} / {total} 对',
|
|
348
|
+
gsRejectMerge: '不是同一实体',
|
|
349
|
+
gsRestoreMerge: '恢复候选',
|
|
350
|
+
gsRejectedMerges: '已排除的相似候选',
|
|
351
|
+
gsRejectedMergeHint: '排除只记住本库对这两个实体的判断,保留两个实体与记忆;改名、删除或合并后判断失效,可在此恢复候选。',
|
|
352
|
+
gsMergeRejected: '已排除此实体对;两个实体与记忆均已保留',
|
|
353
|
+
gsMergeRestored: '已恢复候选,尚未合并',
|
|
354
|
+
gsReviewPending: '待处理',
|
|
355
|
+
gsConfirmAction: '确认执行?',
|
|
356
|
+
gsLinkSource: '来源记忆 ID',
|
|
357
|
+
gsLinkTarget: '目标记忆或实体 ID',
|
|
358
|
+
gsLinkConfidence: '关联置信度',
|
|
359
|
+
gsLinkHint: '先展开簇选择节点,或填写同库 ID。依据需为 8–500 字,person 关联的目标必须是人物实体。',
|
|
360
|
+
gsLinkDone: '关联已保存',
|
|
361
|
+
gsUnlinkHint: '移除自动关联还会记录抑制标记,阻止整理时重新生成;手工关联只移除连线。',
|
|
362
|
+
gsUnlinkDone: '已移除 {n} 条关联',
|
|
363
|
+
gsSuppressionHint: '“删除全部自动边”作用于整库并保留手工边。“解除删除标记”会清除整库抑制记录,确定性模式下可能重新生成自动边。',
|
|
364
|
+
gsSuppressMemory: '排除自动召回',
|
|
365
|
+
gsSuppressMemoryHint: '将此记忆标为已压制,保留正文;可在记忆墙“已失效”池找到并恢复。',
|
|
366
|
+
gsMergeSource: '并入的实体 ID',
|
|
367
|
+
gsMergeTarget: '保留的实体 ID',
|
|
368
|
+
gsReviewRefresh: '重新读取候选',
|
|
369
|
+
gsReviewEmpty: '当前没有待处理候选',
|
|
370
|
+
gsReviewMore: '显示更多候选',
|
|
371
|
+
gsSuppressedDone: '已排除自动召回,正文已保留',
|
|
372
|
+
gsClusters: '簇',
|
|
373
|
+
gsExpandCluster: '展开簇',
|
|
283
374
|
wallScopePrivate: '私有',
|
|
284
375
|
wallScopeGlobal: '全局',
|
|
285
376
|
wallFilterScope: '范围',
|
|
@@ -301,6 +392,35 @@ window.__ModuleLoader__.load({
|
|
|
301
392
|
entityMergeHint: '写法相近的实体只是建议,不会自动合并。合并后来源实体的记忆链接改指主节点,别名并入,来源实体消失;记忆本身不删除。',
|
|
302
393
|
entityMergeAction: '合并',
|
|
303
394
|
entityMergeConfirm: '确认合并',
|
|
395
|
+
entityReviewTitle: '实体待处理',
|
|
396
|
+
entityReviewDesc: '未审候选会自动交给所属会话的模型处理;这里只需核对模型无法安全裁决的身份问题。',
|
|
397
|
+
entityReviewModel: '等待 AI 自动处理',
|
|
398
|
+
entityReviewHuman: '需要人工复核',
|
|
399
|
+
entityReviewAutoHint: '后台按所属会话的模型与可见范围分批处理;失败自动退避重试,无需逐条提交。关闭空闲整理时暂停自动处理。',
|
|
400
|
+
entityReviewAllEmpty: '所选记忆库没有待处理的实体候选。',
|
|
401
|
+
entityReviewLibrary: '候选所属记忆库',
|
|
402
|
+
entityReviewLoading: '正在读取待处理候选…',
|
|
403
|
+
entityReviewError: '无法读取实体候选',
|
|
404
|
+
entityReviewEmpty: '当前记忆库没有待处理的实体候选。',
|
|
405
|
+
entityReviewCountExact: '显示 {shown} / 共 {total} 个待处理候选',
|
|
406
|
+
entityReviewCountApprox: '当前显示 {shown} 个;候选总数不精确(扫描可能未完成)',
|
|
407
|
+
entityReviewPair: '候选实体',
|
|
408
|
+
entityReviewSource: '实体 A',
|
|
409
|
+
entityReviewTarget: '实体 B',
|
|
410
|
+
entityReviewType: '类型',
|
|
411
|
+
entityReviewReason: '匹配原因',
|
|
412
|
+
entityReviewEvidence: '可见记忆证据',
|
|
413
|
+
entityReviewNoEvidence: '服务端未返回可见的记忆摘要。',
|
|
414
|
+
entityReviewExclude: '不是同一实体 / 排除',
|
|
415
|
+
entityReviewExcludeConfirm: '确认排除?',
|
|
416
|
+
entityReviewMergeDone: '实体已合并。',
|
|
417
|
+
entityReviewExcludeDone: '已排除此候选,两个实体及其记忆均保留。',
|
|
418
|
+
entityReviewMissingToken: '候选缺少有效复核凭据,请刷新后重试。',
|
|
419
|
+
entityReviewMore: '继续加载候选',
|
|
420
|
+
entityReviewSidebarTitle: '有实体候选待你裁决',
|
|
421
|
+
entityReviewSidebarDesc: 'AI 已先处理证据充分的候选;仍未能安全确定的项目需要你核对。',
|
|
422
|
+
entityReviewSidebarOpen: '查看候选',
|
|
423
|
+
entityReviewSidebarLater: '稍后',
|
|
304
424
|
entityMergeDone: '已把「{from}」并入「{to}」:{links} 条记忆链接改指,别名共 {aliases} 个',
|
|
305
425
|
entityMergeDropped: '({n} 个别名超出上限,未并入)',
|
|
306
426
|
entityMergeConflict: '({n} 条关系快照与主节点侧冲突,保留主节点侧)',
|
|
@@ -415,6 +535,8 @@ window.__ModuleLoader__.load({
|
|
|
415
535
|
settingsGroupLifecycleDesc: '永久上限、短期保留、未了之事复提与归档清理节奏。',
|
|
416
536
|
settingsGroupCuration: '整理与唤醒',
|
|
417
537
|
settingsGroupCurationDesc: '空闲整理与全局自动提炼的节奏,以及日期到点唤醒。',
|
|
538
|
+
settingsGroupRetention: '保留与清理',
|
|
539
|
+
settingsGroupRetentionDesc: '安全清理缓存与维护元数据;默认只预览。',
|
|
418
540
|
settingsGroupEngine: '引擎与后端',
|
|
419
541
|
settingsGroupEngineDesc: 'MemU 存储模式与引擎自动安装。',
|
|
420
542
|
settingsGroupSession: '会话与界面',
|
|
@@ -435,6 +557,58 @@ window.__ModuleLoader__.load({
|
|
|
435
557
|
dedupeTurns: '去重轮数',
|
|
436
558
|
globalEveryNTurns: '全局每 N 轮',
|
|
437
559
|
minUserChars: '最短用户消息',
|
|
560
|
+
midTurnRecall: '长工具回合中途补充召回',
|
|
561
|
+
midTurnHint: '中途召回仍服从同回合总 token 预算;下列阈值仅控制补充时机,不会每一步注入。',
|
|
562
|
+
midTurnMinSteps: '中途召回最少工具步数',
|
|
563
|
+
midTurnMinUnits: '中途召回最少上下文单元',
|
|
564
|
+
midTurnMinChars: '中途召回最少字符数',
|
|
565
|
+
midTurnMaxPerTurn: '每回合最多中途召回次数',
|
|
566
|
+
midTurnCooldownMs: '中途召回冷却(毫秒)',
|
|
567
|
+
midTurnTokens: '中途召回 token 上限',
|
|
568
|
+
midTurnFullUnits: '完整补充召回单元阈值',
|
|
569
|
+
midTurnFullChars: '完整补充召回字符阈值',
|
|
570
|
+
consolidationTurnLog: '增量回合日志',
|
|
571
|
+
consolidationTurnLogTools: '回合日志工具明细',
|
|
572
|
+
turnLogOff: '关闭',
|
|
573
|
+
turnLogOn: '开启',
|
|
574
|
+
turnLogNone: '不记录工具行',
|
|
575
|
+
turnLogErrors: '只记录工具错误',
|
|
576
|
+
turnLogSummary: '记录工具摘要',
|
|
577
|
+
newSessionDefault: '不再询问时的新会话默认范围',
|
|
578
|
+
sessionDefaultOff: '关闭记忆',
|
|
579
|
+
sessionDefaultAuto: '仅文件夹记忆',
|
|
580
|
+
sessionDefaultGlobal: '仅全局记忆',
|
|
581
|
+
sessionDefaultBoth: '文件夹与全局记忆',
|
|
582
|
+
sessionActions: '指定会话的记忆设置',
|
|
583
|
+
sessionActionsHint: '独立 WebUI 没有当前会话。先选择目标会话,再修改绑定、域、上下文或发起整理;文件夹权限仍是上限。',
|
|
584
|
+
sessionActionsPick: '选择目标会话',
|
|
585
|
+
sessionActionsLibrary: '绑定到记忆库',
|
|
586
|
+
sessionActionsBind: '确认绑定目标库',
|
|
587
|
+
sessionActionsBound: '会话绑定已更新',
|
|
588
|
+
sessionActionsOrganizing: '整理请求已提交;进度与结果请查看日志',
|
|
589
|
+
pipIndexes: 'Python 包索引(按优先顺序)',
|
|
590
|
+
pipIndexesHint: '用逗号分隔 HTTP(S) 索引地址,留空使用内置镜像。仅影响后续引擎安装;不接受含凭据的地址。',
|
|
591
|
+
pipIndexesInvalid: '地址无效,尚未保存:请使用不含账号、密码或查询凭据的 HTTP(S) 地址。',
|
|
592
|
+
engineSource: '引擎下载源',
|
|
593
|
+
engineSourceHint: '自动:先试国内镜像再回退 GitHub;官方:优先 GitHub;自定义:使用下面的镜像地址。只影响引擎安装,不改变已声明的引擎版本。',
|
|
594
|
+
engineSourceAuto: '自动(国内镜像优先)',
|
|
595
|
+
engineSourceMirror: '国内镜像优先',
|
|
596
|
+
engineSourceOfficial: 'GitHub 官方优先',
|
|
597
|
+
engineSourceCustom: '只走自定义镜像',
|
|
598
|
+
engineUvMirror: '自定义 uv 镜像基地址',
|
|
599
|
+
engineUvMirrorHint: '可选。形如 https://mirror.example/astral-sh/uv,最终请求 <基地址>/<版本>/<文件>;文件需与 GitHub release 同名同内容。',
|
|
600
|
+
enginePythonMirror: '自定义 CPython 镜像基地址',
|
|
601
|
+
enginePythonMirrorHint: '可选。形如 https://mirror.example/astral-sh/python-build-standalone,会作为 uv 的 UV_PYTHON_INSTALL_MIRROR 使用。',
|
|
602
|
+
engineAllowUnpinned: '允许镜像提供最新版本',
|
|
603
|
+
engineAllowUnpinnedHint: '默认关闭:只装固定的 uv 0.13.6 / Python 3.12.14,镜像没有就回退官方。开启后滚动镜像可提供它自己的最新版本,用镜像的 sha256.sum 校验;可复现性让位于可安装性。',
|
|
604
|
+
policyReadonly: '内部策略(只读)',
|
|
605
|
+
policyReadonlyHint: '以下当前值由服务端返回;当前设置 RPC 尚未开放修改,界面仅供核对。',
|
|
606
|
+
activeMemoryMinScore: '主动记忆最低分',
|
|
607
|
+
activeMemoryStarvationMinutes: '主动记忆饥饿阈值(分钟)',
|
|
608
|
+
activeMemoryCooldownMinutes: '主动记忆整理冷却(分钟)',
|
|
609
|
+
activeMemoryRecallCooldownMinutes: '主动记忆召回冷却(分钟)',
|
|
610
|
+
unpinBudgetPerSession: '每会话解除永久记忆额度',
|
|
611
|
+
unpinCooldownMinutes: '解除永久记忆冷却(分钟)',
|
|
438
612
|
randomCueChance: '随机侧事件概率',
|
|
439
613
|
openLoopRemindDays: '未了之事复提间隔(天)',
|
|
440
614
|
freshnessHint: '时效提示',
|
|
@@ -446,6 +620,19 @@ window.__ModuleLoader__.load({
|
|
|
446
620
|
salientWakeHour: '唤醒时间(HH:mm)',
|
|
447
621
|
salientWakeTimeZone: '唤醒时区(留空跟随系统)',
|
|
448
622
|
salientWakeHint: '实验特性,默认关闭:唤醒会替会话开一整轮,由宿主定时任务投递。\n只有宿主进程活着才会触发;任务在宿主的定时任务界面可见、可手动删除。\n还没做过真机验收,建议先在测试库里试开。',
|
|
623
|
+
retentionDryRun: '保留清理仅预览(dry-run)',
|
|
624
|
+
retentionBoundTurnLogsEnabled: '检查已绑定会话的旧回合日志',
|
|
625
|
+
retentionBoundTurnLogDays: '已绑定回合日志保留期(天)',
|
|
626
|
+
retentionOrphanTurnLogsEnabled: '允许清理孤儿回合日志(额外显式启用)',
|
|
627
|
+
retentionOrphanTurnLogDays: '孤儿回合日志保留期(天)',
|
|
628
|
+
retentionMaintenanceLedgerEnabled: '清理已结案维护台账元数据',
|
|
629
|
+
retentionMaintenanceLedgerDays: '维护台账保留期(天)',
|
|
630
|
+
retentionSessionBindingsEnabled: '允许清理过期会话绑定(额外启用)',
|
|
631
|
+
retentionSessionBindingDays: '会话绑定保留期(天)',
|
|
632
|
+
retentionVectorPruneEnabled: '清理旧向量代际文件',
|
|
633
|
+
retentionVectorKeepGenerations: '保留最近向量代际数',
|
|
634
|
+
retentionVectorDays: '旧向量文件最短保留期(天)',
|
|
635
|
+
retentionHint: '记忆不会被此功能删除。默认只预览;关闭预览后仍需分别启用孤儿日志和会话绑定清理。向量清理也默认只预览。',
|
|
449
636
|
autoInstall: '自动安装引擎',
|
|
450
637
|
sleepConsolidation: '空闲后整理记忆',
|
|
451
638
|
sleepAfterIdleMinutes: '空闲多久后整理(分钟)',
|
|
@@ -856,6 +1043,10 @@ window.__ModuleLoader__.load({
|
|
|
856
1043
|
variables: '变量',
|
|
857
1044
|
curation: '提炼全局记忆',
|
|
858
1045
|
startCuration: '开始提炼',
|
|
1046
|
+
curationExecutor: '执行者会话',
|
|
1047
|
+
curationExecutorPick: '请选择执行者会话',
|
|
1048
|
+
curationExecutorHint: '执行者仅提供 curator 的运行上下文;下方勾选的来源会话才是提炼材料。',
|
|
1049
|
+
curationSources: '来源会话(可多选)',
|
|
859
1050
|
noLiveSession: '没有活跃对话可作为 curator 的父会话。',
|
|
860
1051
|
privateMemory: '私有记忆',
|
|
861
1052
|
currentLibrary: '当前记忆库',
|
|
@@ -968,7 +1159,7 @@ window.__ModuleLoader__.load({
|
|
|
968
1159
|
lexiconPendingEmpty: '没有待审的词条提案。',
|
|
969
1160
|
lexiconHitsDetail: '命中明细:候选 {candidate} · 注入 {injection} · 查询 {query}',
|
|
970
1161
|
orphanEntities: '未关联实体 ({n})',
|
|
971
|
-
orphanPruneHint: '
|
|
1162
|
+
orphanPruneHint: '这些实体当前没有记忆或关系引用。启动时的孤立节点清理可能移除它们;需要保留时,请先建立连接。',
|
|
972
1163
|
entityEmpty: '这个词库还没有实体。',
|
|
973
1164
|
// —— 自动关联:待确认实体 ——
|
|
974
1165
|
anchorReviewTitle: '待确认实体',
|
|
@@ -994,14 +1185,47 @@ window.__ModuleLoader__.load({
|
|
|
994
1185
|
autoLinkOff: '关闭',
|
|
995
1186
|
autoLinkHint: '“只出候选”不会写任何边;“确定性写边”只写两类边:已确认实体的提及,以及 conflicts_with / supersedes / 同 fact_key 的字段证据。词面相似度与向量永远不建边。',
|
|
996
1187
|
autoRepairEntityFragments: '升级后自动合并名字碎片',
|
|
997
|
-
autoRepairEntityFragmentsHint: '
|
|
1188
|
+
autoRepairEntityFragmentsHint: '旧版本把中文名的滑窗片段当成了独立人物(两个节点其实是同一个人)。本版本首次启动会扫一遍并在**写入前备份**,但只合并可证明的那一类:片段能首尾重叠重建成一个在正文里出现过的完整名,或短名在正文里从未独立于长名出现。只是名字相近(编辑距离、共同字)的候选一律不自动合并;在「MemU 记忆」页的「实体待处理」查看未能由 AI 安全裁决的候选,结合记忆证据逐对核对;关系图谱仍保留原有管理入口。关闭此项 = 连可证明的也不动。',
|
|
998
1189
|
firstRunTitle: '先建一个记忆库',
|
|
999
1190
|
firstRunDesc: '还没有任何记忆库。新建一个私有库后,会话里的记忆才有地方落。',
|
|
1000
1191
|
firstRunGoLibraries: '去新建库',
|
|
1001
1192
|
firstRunGuide: '查看快速上手',
|
|
1002
1193
|
pageHelp: '帮助',
|
|
1003
|
-
descHelp: '
|
|
1194
|
+
descHelp: '按步骤完成第一次记忆验证,再学习向量、关系管理与排错',
|
|
1004
1195
|
helpQuickStart: '快速开始',
|
|
1196
|
+
helpTutorialDesc: '每一步都有操作、成功标志和排错入口;切换步骤不会修改记忆或设置。',
|
|
1197
|
+
helpTutorialSteps: '上手步骤',
|
|
1198
|
+
helpTutorialProgress: '步骤',
|
|
1199
|
+
helpTutorialExpected: '怎样确认成功',
|
|
1200
|
+
helpTutorialTrouble: '没有看到预期结果',
|
|
1201
|
+
helpTutorialPrevious: '上一步',
|
|
1202
|
+
helpTutorialNext: '下一步',
|
|
1203
|
+
helpTutorialDiagnose: '检查诊断',
|
|
1204
|
+
helpTutorialReference: '按主题查阅',
|
|
1205
|
+
helpTutorialReferenceHint: '从当前问题进入;完整说明和标注表在下方。',
|
|
1206
|
+
helpStep1Title: '创建记忆库',
|
|
1207
|
+
helpStep1Expected: '「记忆库」列表出现新库。已有库可以直接复用,不必为每段对话新建。',
|
|
1208
|
+
helpStep1Trouble: '创建失败先检查目录写权限与诊断。先确认目标库,不要用删除再新建来处理读取错误。',
|
|
1209
|
+
helpStep2Title: '绑定当前会话',
|
|
1210
|
+
helpStep2Expected: '会话侧栏显示目标库,私有记忆开关开启;频道、角色、世界线、分支与这段对话一致。',
|
|
1211
|
+
helpStep2Trouble: '独立 WebUI 不一定代表当前对话。回到 DSH 会话的记忆侧栏完成绑定;文件夹策略关闭的作用域无法由会话重新开启。',
|
|
1212
|
+
helpStep3Title: '开启并验证注入',
|
|
1213
|
+
helpStep3Expected: '设置显示选中的模式。下一条真实人类消息之后,出现可折叠的记忆规则或标题卡;空库没有召回卡是正常的。',
|
|
1214
|
+
helpStep3Trouble: '检查是否选了 off、文件夹/会话开关、domain 与上下文是否匹配;工具回执或心跳不会触发新一轮注入。',
|
|
1215
|
+
helpStep4Title: '写入、搜索与纠正',
|
|
1216
|
+
helpStep4Expected: '用一条不含隐私的测试事实写入已绑定私有库。在记忆页搜索到它,打开全文;纠正后重搜能看到新内容。',
|
|
1217
|
+
helpStep4Trouble: '写入和召回是两条链路。先确认库、域与状态,再看日志中的写入/召回;待复核、secret 或其他上下文内容不会自动注入。',
|
|
1218
|
+
helpStep5Title: '维护词典与黑话',
|
|
1219
|
+
helpStep5Expected: '词条在正确的库和 domain 中显示为使用中。用自然语句提及它后,检查是否召回;归档后应停止自动注入。',
|
|
1220
|
+
helpStep5Trouble: '关键词与语义召回都服从来源、域、上下文与敏感含义限制;sensitive 只能由用户修改,不要用扩大权限来绕过过滤。',
|
|
1221
|
+
helpStep6Title: '启用真实向量',
|
|
1222
|
+
helpStep6: '在「连接与向量」下载并校验运行时、模型,激活向量档案,再重建索引。用不同措辞询问已保存的事实,检查召回路线与实际命中。',
|
|
1223
|
+
helpStep6Expected: '运行时和模型就绪,存在 active 向量代际,已入向量数量增长;日志中的向量检索确实返回目标条目。',
|
|
1224
|
+
helpStep6Trouble: '安装完成不等于向量激活。区分引擎、embedding 运行时、模型、代际与重建错误;仅显示关键词回退不能证明向量验证通过。',
|
|
1225
|
+
helpStep7Title: '整理关系与候选',
|
|
1226
|
+
helpStep7: '打开关系图谱查看完整圆环,使用缩放或搜索定位节点。左键拖动可调整位置;右键固定或解除固定。在管理入口建立或移除连接,逐组核对相似实体候选。',
|
|
1227
|
+
helpStep7Expected: '连接显示正确的两端与关系类型;合并前核对来源与影响范围。名字相似只是候选,确认后才融合;排除/归档的结果可重新检查。',
|
|
1228
|
+
helpStep7Trouble: '缩到最小时屏幕上的点可能挤在一起,进入簇后再检查。看不到候选时检查库和域筛选;不要把名字相近当作同一实体的证据。',
|
|
1005
1229
|
helpGoTo: '前往 →',
|
|
1006
1230
|
helpStep1: '新建一个私有库:在「记忆库」页新建。成功时列表里出现当前项目的库,文件夹页也能看到它。',
|
|
1007
1231
|
helpStep2: '在会话里绑定库:在对话中让助手调用 memu_bind(或发送 /memu 绑定),或在新会话卡里选定作用域。成功后侧栏会话卡显示已绑定这个库。',
|
|
@@ -1034,8 +1258,8 @@ window.__ModuleLoader__.load({
|
|
|
1034
1258
|
helpVectorFallback: '向量未激活(只有 requested 或重建失败)时,召回自动回退词法检索:仍然可用,只是语义匹配更弱。',
|
|
1035
1259
|
helpVectorRebuild: '切换模型或修复失败要重建:新代际建成前旧代际保持只读,成功后的新记忆写入新代际;失败不会改当前代际,可以再点一次续建。',
|
|
1036
1260
|
helpAutoLink: '私有自动关联与实体枢纽',
|
|
1037
|
-
helpAutoLinkRule:
|
|
1038
|
-
helpAutoLinkHub: '
|
|
1261
|
+
helpAutoLinkRule: '先看「自动关联」设置:只出候选不写边;确定性写边只接受已确认实体的提及与可证明的字段证据。词面相似度或向量相近本身都不能建立关系。',
|
|
1262
|
+
helpAutoLinkHub: '实体枢纽把多条记忆关联到同一个明确的人或物。先核对名称、别名与来源;名字近似的两个实体仍可能是不同对象,不能只看编辑距离就融合。',
|
|
1039
1263
|
helpAutoLinkWorker: '拿不准的候选交给本次整理 worker(memu_private_link_suggest)带证据裁决;不会另起一次完整整理,也不重读转录;没有候选就不连。',
|
|
1040
1264
|
helpAutoLinkSafety: '自动关联只改图元数据:不改正文、不写向量、不删除。关系图显示「自动」标记和移除(×);实体删除仍按既有规则。',
|
|
1041
1265
|
helpLabels: '标注速查表',
|
|
@@ -1110,7 +1334,7 @@ window.__ModuleLoader__.load({
|
|
|
1110
1334
|
pageMemories: 'MemU Memory',
|
|
1111
1335
|
descMemories: 'Memories, provenance and status across libraries',
|
|
1112
1336
|
pageGraph: 'Relationship graph',
|
|
1113
|
-
descGraph: 'Force graph: drag to pin, spring-chain follow',
|
|
1337
|
+
descGraph: 'Force graph: drag to reposition, right-click to pin, spring-chain follow',
|
|
1114
1338
|
graphCenter: 'Center force',
|
|
1115
1339
|
graphPinned: 'Pinned',
|
|
1116
1340
|
graphUnpinAll: 'Unpin all',
|
|
@@ -1176,6 +1400,16 @@ window.__ModuleLoader__.load({
|
|
|
1176
1400
|
gsAllStatus: 'All statuses',
|
|
1177
1401
|
gsSort: 'Sort by',
|
|
1178
1402
|
gsNoMatch: 'No matching nodes',
|
|
1403
|
+
gsIncludeOrphans: 'Include unlinked entities',
|
|
1404
|
+
gsManagerScope: 'Management library',
|
|
1405
|
+
gsManagerChoose: 'Choose a management library',
|
|
1406
|
+
gsManagerPage: 'Page filters and sorting · Loaded {n} / query total {total}',
|
|
1407
|
+
gsManagerPrevious: 'Previous page',
|
|
1408
|
+
gsManagerNext: 'Next page',
|
|
1409
|
+
gsManagerBack: 'Back to management list',
|
|
1410
|
+
gsManagerFocus: 'Focused management · library {library} · ID {id}',
|
|
1411
|
+
gsManagerChanged: 'Management data keeps changing; refresh and try again',
|
|
1412
|
+
gsManagerUnavailable: 'This ID is not visible in the current session or domain; change scope only where authorized',
|
|
1179
1413
|
gsShortcuts: '+/- zoom · F fit · / search · left-drag moves · right-click locks/unlocks · Shift cluster · double-click focus',
|
|
1180
1414
|
gsLegendMemory: 'Long-term memory',
|
|
1181
1415
|
gsLegendMust: 'Must remember',
|
|
@@ -1198,6 +1432,42 @@ window.__ModuleLoader__.load({
|
|
|
1198
1432
|
pageDiagnostics: 'Diagnostics',
|
|
1199
1433
|
descDiagnostics: 'Internal faults and repairs (stderr, paths, repair actions), kept apart from the activity log',
|
|
1200
1434
|
diagEnvTitle: 'Environment check',
|
|
1435
|
+
diagReportTitle: 'Runtime and failure evidence',
|
|
1436
|
+
diagReportDesc: 'Read-only technical snapshot of the host, plugin, engine, vectors, storage and workers. Unknown states are not reported as healthy.',
|
|
1437
|
+
diagReportUnavailable: 'A complete redacted diagnostic report is not available. Run the check and retry.',
|
|
1438
|
+
diagReportPrivacy: 'Exports redacted technical metadata, counters and error call sites; settings, API keys, memory bodies and original conversations are excluded.',
|
|
1439
|
+
diagReportTime: 'Collected at',
|
|
1440
|
+
diagReportHost: 'DSH version',
|
|
1441
|
+
diagReportPlugin: 'Plugin version',
|
|
1442
|
+
diagReportNode: 'Node.js / ABI',
|
|
1443
|
+
diagReportOs: 'Operating system',
|
|
1444
|
+
diagReportSource: 'Evidence source',
|
|
1445
|
+
diagReportDetails: 'Expand complete technical details',
|
|
1446
|
+
diagReportDownload: 'Download redacted report',
|
|
1447
|
+
diagReportLayer: 'Failure layer',
|
|
1448
|
+
diagReportOperation: 'Operation',
|
|
1449
|
+
diagReportCorrelation: 'Request correlation',
|
|
1450
|
+
diagReportRetry: 'Retry policy',
|
|
1451
|
+
diagReportRetryAllowed: 'Retry after backoff',
|
|
1452
|
+
diagReportRetryManual: 'Inspect the cause before retrying',
|
|
1453
|
+
diagReportRetryAfter: 'Suggested delay (ms)',
|
|
1454
|
+
diagReportCause: 'Causes and call sites',
|
|
1455
|
+
diagReportContext: 'Technical context',
|
|
1456
|
+
diagReportLimitations: 'Evidence limits',
|
|
1457
|
+
diagLayerHost: 'DSH host',
|
|
1458
|
+
diagLayerPlugin: 'Plugin',
|
|
1459
|
+
diagLayerEngine: 'MemU engine',
|
|
1460
|
+
diagLayerVector: 'Vector model and index',
|
|
1461
|
+
diagLayerState: 'State and persistence',
|
|
1462
|
+
diagLayerRpc: 'RPC and admission',
|
|
1463
|
+
diagLayerWorkers: 'Workers and runtime',
|
|
1464
|
+
diagStatusObserved: 'Observed',
|
|
1465
|
+
diagStatusUnknown: 'Unknown / untested',
|
|
1466
|
+
diagStatusSkipped: 'Disabled / skipped',
|
|
1467
|
+
diagStatusNotBuilt: 'Not built yet',
|
|
1468
|
+
diagStatusAbsent: 'File absent',
|
|
1469
|
+
diagStatusError: 'Failure',
|
|
1470
|
+
diagStatusDegraded: 'Degraded',
|
|
1201
1471
|
diagHostSurface: 'Host shapes:',
|
|
1202
1472
|
diagHostSurfaceHint: 'These values come from this plugin\u2019s host capability probes and let you verify a row of the docs/host-versions.md ledger. The plugin never branches on them and never reads a host version.',
|
|
1203
1473
|
diagEnvDesc: 'Runs at startup and when this page opens: data dir, stale locks, engine, vector profile, runtime, model files',
|
|
@@ -1271,7 +1541,52 @@ window.__ModuleLoader__.load({
|
|
|
1271
1541
|
poolReview: 'Review',
|
|
1272
1542
|
poolInactive: 'Inactive',
|
|
1273
1543
|
wallReadError: 'Some libraries could not be read',
|
|
1274
|
-
wallLimit: '
|
|
1544
|
+
wallLimit: 'Loaded; scroll to the bottom for more',
|
|
1545
|
+
memoryLoaded: 'Loaded',
|
|
1546
|
+
memoryPageChanged: 'MEMORY_CHANGED: memories keep changing; refresh to resume paging',
|
|
1547
|
+
gsOverview: 'Overview',
|
|
1548
|
+
gsReview: 'Graph Actions',
|
|
1549
|
+
gsReviewLibrary: 'Action library',
|
|
1550
|
+
gsReviewScope: 'Candidates and actions below belong to the selected library, independently of canvas domain and node filters.',
|
|
1551
|
+
gsReviewLimit: 'At most {limit} similar pairs are shown per batch. Until scanning finishes, only discovered counts are shown. Confirm each pair separately; similar names are never merged automatically.',
|
|
1552
|
+
gsReviewUnavailable: 'Some candidates could not be read; pending counts are incomplete',
|
|
1553
|
+
gsReviewUnchecked: 'Not checked',
|
|
1554
|
+
gsReviewPartialCount: '≥{n} · incomplete',
|
|
1555
|
+
gsReviewDiscovered: 'Showing {shown} pairs in this batch; at least {total} discovered so far, not an exact library total',
|
|
1556
|
+
gsReviewScanProgress: 'Checked {scanned} / {space} entity pairs',
|
|
1557
|
+
gsReviewScanIncomplete: 'The scan is incomplete. Continue to check the next batch.',
|
|
1558
|
+
gsReviewScanComplete: 'This scan reached the end. Check from the start to revisit unresolved pairs in earlier batches.',
|
|
1559
|
+
gsReviewContinue: 'Continue scan',
|
|
1560
|
+
gsReviewRestart: 'Check from start',
|
|
1561
|
+
gsReviewScanReset: 'The candidate scan expired and has restarted from the beginning',
|
|
1562
|
+
gsReviewGroups: 'Similar entity groups',
|
|
1563
|
+
gsReviewShowing: 'Showing {shown} / {total} pairs',
|
|
1564
|
+
gsRejectMerge: 'Not the same entity',
|
|
1565
|
+
gsRestoreMerge: 'Restore candidate',
|
|
1566
|
+
gsRejectedMerges: 'Excluded similar pairs',
|
|
1567
|
+
gsRejectedMergeHint: 'Exclusion remembers this library’s decision about this pair and keeps both entities and their memories. Renaming, deleting or merging invalidates the decision; restore a candidate here.',
|
|
1568
|
+
gsMergeRejected: 'Pair excluded; both entities and their memories are retained',
|
|
1569
|
+
gsMergeRestored: 'Candidate restored; no merge was performed',
|
|
1570
|
+
gsReviewPending: 'Needs review',
|
|
1571
|
+
gsConfirmAction: 'Confirm action?',
|
|
1572
|
+
gsLinkSource: 'Source memory ID',
|
|
1573
|
+
gsLinkTarget: 'Target memory or entity ID',
|
|
1574
|
+
gsLinkConfidence: 'Link confidence',
|
|
1575
|
+
gsLinkHint: 'Expand a cluster and select a node, or enter IDs from this library. Evidence must contain 8–500 characters. Person links must target a person entity.',
|
|
1576
|
+
gsLinkDone: 'Link saved',
|
|
1577
|
+
gsUnlinkHint: 'Removing an auto edge also records a suppression marker so consolidation cannot recreate it. Manual edges are simply removed.',
|
|
1578
|
+
gsUnlinkDone: 'Removed {n} link(s)',
|
|
1579
|
+
gsSuppressionHint: 'Remove all auto edges applies to the whole library and keeps manual edges. Clearing deletion markers resets library-wide suppression and may rebuild auto edges in deterministic mode.',
|
|
1580
|
+
gsSuppressMemory: 'Exclude from automatic recall',
|
|
1581
|
+
gsSuppressMemoryHint: 'Mark this memory suppressed while keeping its body. Find it in the memory wall inactive pool to restore it.',
|
|
1582
|
+
gsMergeSource: 'Entity ID to merge from',
|
|
1583
|
+
gsMergeTarget: 'Entity ID to keep',
|
|
1584
|
+
gsReviewRefresh: 'Reload candidates',
|
|
1585
|
+
gsReviewEmpty: 'No candidates need review',
|
|
1586
|
+
gsReviewMore: 'Show more candidates',
|
|
1587
|
+
gsSuppressedDone: 'Excluded from automatic recall; the memory is retained',
|
|
1588
|
+
gsClusters: 'Clusters',
|
|
1589
|
+
gsExpandCluster: 'Expand cluster',
|
|
1275
1590
|
wallScopePrivate: 'Private',
|
|
1276
1591
|
wallScopeGlobal: 'Global',
|
|
1277
1592
|
wallFilterScope: 'Scope',
|
|
@@ -1293,6 +1608,35 @@ window.__ModuleLoader__.load({
|
|
|
1293
1608
|
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.',
|
|
1294
1609
|
entityMergeAction: 'Merge',
|
|
1295
1610
|
entityMergeConfirm: 'Confirm merge',
|
|
1611
|
+
entityReviewTitle: 'Entity reviews',
|
|
1612
|
+
entityReviewDesc: 'Unreviewed candidates go automatically to their conversation’s model. Only identity questions the model cannot safely resolve need your review.',
|
|
1613
|
+
entityReviewModel: 'Awaiting automatic AI review',
|
|
1614
|
+
entityReviewHuman: 'Needs human review',
|
|
1615
|
+
entityReviewAutoHint: 'The background worker uses each conversation’s model and visibility, in batches with retry backoff. No manual submission is needed. Disabling idle consolidation pauses automatic review.',
|
|
1616
|
+
entityReviewAllEmpty: 'No pending entity candidates in the selected libraries.',
|
|
1617
|
+
entityReviewLibrary: 'Candidate library',
|
|
1618
|
+
entityReviewLoading: 'Loading pending candidates…',
|
|
1619
|
+
entityReviewError: 'Could not load entity candidates',
|
|
1620
|
+
entityReviewEmpty: 'No pending entity candidates in this library.',
|
|
1621
|
+
entityReviewCountExact: 'Showing {shown} of {total} pending candidates',
|
|
1622
|
+
entityReviewCountApprox: 'Showing {shown}; the total is not exact (the scan may be incomplete)',
|
|
1623
|
+
entityReviewPair: 'Candidate entities',
|
|
1624
|
+
entityReviewSource: 'Entity A',
|
|
1625
|
+
entityReviewTarget: 'Entity B',
|
|
1626
|
+
entityReviewType: 'Type',
|
|
1627
|
+
entityReviewReason: 'Match reason',
|
|
1628
|
+
entityReviewEvidence: 'Visible memory evidence',
|
|
1629
|
+
entityReviewNoEvidence: 'The server returned no visible memory summaries.',
|
|
1630
|
+
entityReviewExclude: 'Not the same entity / exclude',
|
|
1631
|
+
entityReviewExcludeConfirm: 'Confirm exclusion?',
|
|
1632
|
+
entityReviewMergeDone: 'Entities merged.',
|
|
1633
|
+
entityReviewExcludeDone: 'Candidate excluded; both entities and their memories are retained.',
|
|
1634
|
+
entityReviewMissingToken: 'The candidate has no valid review token. Refresh and try again.',
|
|
1635
|
+
entityReviewMore: 'Load more candidates',
|
|
1636
|
+
entityReviewSidebarTitle: 'Entity candidates need review',
|
|
1637
|
+
entityReviewSidebarDesc: 'AI handles candidates with sufficient evidence first; please check the remaining uncertain pairs.',
|
|
1638
|
+
entityReviewSidebarOpen: 'Review candidates',
|
|
1639
|
+
entityReviewSidebarLater: 'Later',
|
|
1296
1640
|
entityMergeDone: 'Merged "{from}" into "{to}": {links} memory links redirected, {aliases} aliases in total',
|
|
1297
1641
|
entityMergeDropped: '({n} aliases over the cap were not folded in)',
|
|
1298
1642
|
entityMergeConflict: '({n} relationship snapshots clashed with the target side and were dropped)',
|
|
@@ -1407,6 +1751,8 @@ window.__ModuleLoader__.load({
|
|
|
1407
1751
|
settingsGroupLifecycleDesc: 'Permanent cap, short-term retention, open-loop reminders and archive cleanup.',
|
|
1408
1752
|
settingsGroupCuration: 'Curation & wake',
|
|
1409
1753
|
settingsGroupCurationDesc: 'Idle consolidation and global auto-curation cadence, plus salient-date wake.',
|
|
1754
|
+
settingsGroupRetention: 'Retention & cleanup',
|
|
1755
|
+
settingsGroupRetentionDesc: 'Safely clean caches and maintenance metadata; preview only by default.',
|
|
1410
1756
|
settingsGroupEngine: 'Engine & backend',
|
|
1411
1757
|
settingsGroupEngineDesc: 'MemU storage mode and engine auto-install.',
|
|
1412
1758
|
settingsGroupSession: 'Session & interface',
|
|
@@ -1427,6 +1773,58 @@ window.__ModuleLoader__.load({
|
|
|
1427
1773
|
dedupeTurns: 'Dedupe turns',
|
|
1428
1774
|
globalEveryNTurns: 'Global every N turns',
|
|
1429
1775
|
minUserChars: 'Min user chars',
|
|
1776
|
+
midTurnRecall: 'Supplement recall during long tool turns',
|
|
1777
|
+
midTurnHint: 'Supplemental recall shares the turn token ceiling. These thresholds control when it can run; they do not inject on every step.',
|
|
1778
|
+
midTurnMinSteps: 'Minimum tool steps for supplemental recall',
|
|
1779
|
+
midTurnMinUnits: 'Minimum context units for supplemental recall',
|
|
1780
|
+
midTurnMinChars: 'Minimum characters for supplemental recall',
|
|
1781
|
+
midTurnMaxPerTurn: 'Maximum supplemental recalls per turn',
|
|
1782
|
+
midTurnCooldownMs: 'Supplemental recall cooldown (ms)',
|
|
1783
|
+
midTurnTokens: 'Supplemental recall token ceiling',
|
|
1784
|
+
midTurnFullUnits: 'Context units for full supplemental recall',
|
|
1785
|
+
midTurnFullChars: 'Characters for full supplemental recall',
|
|
1786
|
+
consolidationTurnLog: 'Incremental turn log',
|
|
1787
|
+
consolidationTurnLogTools: 'Tool detail in turn logs',
|
|
1788
|
+
turnLogOff: 'Off',
|
|
1789
|
+
turnLogOn: 'On',
|
|
1790
|
+
turnLogNone: 'No tool rows',
|
|
1791
|
+
turnLogErrors: 'Tool errors only',
|
|
1792
|
+
turnLogSummary: 'Tool summaries',
|
|
1793
|
+
newSessionDefault: 'Default scope when new-session prompts are dismissed',
|
|
1794
|
+
sessionDefaultOff: 'Memory off',
|
|
1795
|
+
sessionDefaultAuto: 'Folder memory only',
|
|
1796
|
+
sessionDefaultGlobal: 'Global memory only',
|
|
1797
|
+
sessionDefaultBoth: 'Folder and global memory',
|
|
1798
|
+
sessionActions: 'Memory settings for a selected conversation',
|
|
1799
|
+
sessionActionsHint: 'The standalone WebUI has no current conversation. Select a target before changing its library, domain or context, or starting consolidation. Folder permissions still apply.',
|
|
1800
|
+
sessionActionsPick: 'Select target conversation',
|
|
1801
|
+
sessionActionsLibrary: 'Bind to library',
|
|
1802
|
+
sessionActionsBind: 'Bind selected library',
|
|
1803
|
+
sessionActionsBound: 'Conversation binding updated',
|
|
1804
|
+
sessionActionsOrganizing: 'Consolidation requested; inspect logs for progress and outcome',
|
|
1805
|
+
pipIndexes: 'Python package indexes (priority order)',
|
|
1806
|
+
pipIndexesHint: 'Comma-separated HTTP(S) index URLs; leave empty for built-in mirrors. Applies to future engine installs. URLs containing credentials are not accepted.',
|
|
1807
|
+
pipIndexesInvalid: 'Invalid address; not saved. Use HTTP(S) URLs without accounts, passwords or query credentials.',
|
|
1808
|
+
engineSource: 'Engine download source',
|
|
1809
|
+
engineSourceHint: 'Auto tries domestic mirrors then GitHub; Official prefers GitHub; Custom uses the mirror URLs below. This only affects engine installation, never the declared engine version.',
|
|
1810
|
+
engineSourceAuto: 'Auto (domestic mirrors first)',
|
|
1811
|
+
engineSourceMirror: 'Domestic mirrors first',
|
|
1812
|
+
engineSourceOfficial: 'GitHub first',
|
|
1813
|
+
engineSourceCustom: 'Custom mirrors only',
|
|
1814
|
+
engineUvMirror: 'Custom uv mirror base URL',
|
|
1815
|
+
engineUvMirrorHint: 'Optional. For example https://mirror.example/astral-sh/uv; requests go to <base>/<version>/<file>, and the file must match the GitHub release byte for byte.',
|
|
1816
|
+
enginePythonMirror: 'Custom CPython mirror base URL',
|
|
1817
|
+
enginePythonMirrorHint: 'Optional. For example https://mirror.example/astral-sh/python-build-standalone; used as uv\u2019s UV_PYTHON_INSTALL_MIRROR.',
|
|
1818
|
+
engineAllowUnpinned: 'Let mirrors serve their newest version',
|
|
1819
|
+
engineAllowUnpinnedHint: 'Off by default: install only the pinned uv 0.13.6 / Python 3.12.14 and fall back to the official source. When on, a rolling mirror may serve its newest release, verified against the mirror\u2019s sha256.sum; reproducibility gives way to installability.',
|
|
1820
|
+
policyReadonly: 'Internal policy (read-only)',
|
|
1821
|
+
policyReadonlyHint: 'These current values come from the server. The settings RPC does not yet allow changes; they are shown for inspection.',
|
|
1822
|
+
activeMemoryMinScore: 'Minimum active-memory score',
|
|
1823
|
+
activeMemoryStarvationMinutes: 'Active-memory starvation threshold (minutes)',
|
|
1824
|
+
activeMemoryCooldownMinutes: 'Active-memory consolidation cooldown (minutes)',
|
|
1825
|
+
activeMemoryRecallCooldownMinutes: 'Active-memory recall cooldown (minutes)',
|
|
1826
|
+
unpinBudgetPerSession: 'Unpin quota per conversation',
|
|
1827
|
+
unpinCooldownMinutes: 'Unpin cooldown (minutes)',
|
|
1430
1828
|
randomCueChance: 'Random cue chance',
|
|
1431
1829
|
openLoopRemindDays: 'Re-remind open loops every N days',
|
|
1432
1830
|
freshnessHint: 'Freshness hint',
|
|
@@ -1438,6 +1836,19 @@ window.__ModuleLoader__.load({
|
|
|
1438
1836
|
salientWakeHour: 'Wake time (HH:mm)',
|
|
1439
1837
|
salientWakeTimeZone: 'Wake time zone (empty = system)',
|
|
1440
1838
|
salientWakeHint: 'Experimental and off by default: a wake opens a full turn for the conversation, delivered by the host scheduler.\nIt only fires while the host process is alive; tasks stay visible (and deletable) in the host schedule UI.\nNot yet verified on a real install — try it on a test library first.',
|
|
1839
|
+
retentionDryRun: 'Retention cleanup is preview-only (dry-run)',
|
|
1840
|
+
retentionBoundTurnLogsEnabled: 'Check aged turn logs for bound sessions',
|
|
1841
|
+
retentionBoundTurnLogDays: 'Bound turn-log retention (days)',
|
|
1842
|
+
retentionOrphanTurnLogsEnabled: 'Allow orphan turn-log cleanup (explicit opt-in)',
|
|
1843
|
+
retentionOrphanTurnLogDays: 'Orphan turn-log retention (days)',
|
|
1844
|
+
retentionMaintenanceLedgerEnabled: 'Prune settled maintenance metadata',
|
|
1845
|
+
retentionMaintenanceLedgerDays: 'Maintenance-ledger retention (days)',
|
|
1846
|
+
retentionSessionBindingsEnabled: 'Allow stale session-binding cleanup (explicit opt-in)',
|
|
1847
|
+
retentionSessionBindingDays: 'Session-binding retention (days)',
|
|
1848
|
+
retentionVectorPruneEnabled: 'Prune old vector generations',
|
|
1849
|
+
retentionVectorKeepGenerations: 'Vector generations to keep',
|
|
1850
|
+
retentionVectorDays: 'Minimum old-vector retention (days)',
|
|
1851
|
+
retentionHint: 'This never deletes memories. Preview is the default; orphan logs and session bindings also require separate opt-in. Vector pruning defaults to preview.',
|
|
1441
1852
|
autoInstall: 'Auto-install engine',
|
|
1442
1853
|
sleepConsolidation: 'Consolidate after idle',
|
|
1443
1854
|
sleepAfterIdleMinutes: 'Idle minutes before consolidating',
|
|
@@ -1847,6 +2258,10 @@ window.__ModuleLoader__.load({
|
|
|
1847
2258
|
variables: 'Variables',
|
|
1848
2259
|
curation: 'Extract global memory',
|
|
1849
2260
|
startCuration: 'Start',
|
|
2261
|
+
curationExecutor: 'Executor conversation',
|
|
2262
|
+
curationExecutorPick: 'Choose an executor conversation',
|
|
2263
|
+
curationExecutorHint: 'The executor only supplies the curator runtime context. Checked source conversations below supply the material.',
|
|
2264
|
+
curationSources: 'Source conversations (select one or more)',
|
|
1850
2265
|
noLiveSession: 'No live conversation available as the curator parent.',
|
|
1851
2266
|
privateMemory: 'Private memory',
|
|
1852
2267
|
currentLibrary: 'Current library',
|
|
@@ -1959,7 +2374,7 @@ window.__ModuleLoader__.load({
|
|
|
1959
2374
|
lexiconPendingEmpty: 'No pending term proposals.',
|
|
1960
2375
|
lexiconHitsDetail: 'Hit detail: {candidate} candidates · {injection} injections · {query} queries',
|
|
1961
2376
|
orphanEntities: 'Unlinked entities ({n})',
|
|
1962
|
-
orphanPruneHint: '
|
|
2377
|
+
orphanPruneHint: 'These entities currently have no memory or relationship references. Startup cleanup may remove them; create a connection first if you want to keep them.',
|
|
1963
2378
|
entityEmpty: 'No entities in this library yet.',
|
|
1964
2379
|
// —— Auto-link: entities awaiting confirmation ——
|
|
1965
2380
|
anchorReviewTitle: 'Entities to confirm',
|
|
@@ -1985,14 +2400,47 @@ window.__ModuleLoader__.load({
|
|
|
1985
2400
|
autoLinkOff: 'Off',
|
|
1986
2401
|
autoLinkHint: '"Candidates only" writes no edges. "Deterministic edges" writes exactly two kinds: mentions of confirmed entities, and field evidence from conflicts_with / supersedes / the same fact_key. Lexical similarity and vectors never create an edge.',
|
|
1987
2402
|
autoRepairEntityFragments: 'Auto-merge name fragments after upgrade',
|
|
1988
|
-
autoRepairEntityFragmentsHint: 'Older versions turned sliding windows of a Chinese name into separate entities, so one person ended up as two nodes. On the first start after an upgrade the plugin scans once and backs up before writing, but merges only the provable class: fragments that overlap head-to-tail into a longer name which actually appears in a memory body, or a short name that never appears outside a longer one anywhere in the library. Merely similar names (edit distance, a shared character) are never
|
|
2403
|
+
autoRepairEntityFragmentsHint: 'Older versions turned sliding windows of a Chinese name into separate entities, so one person ended up as two nodes. On the first start after an upgrade the plugin scans once and backs up before writing, but merges only the provable class: fragments that overlap head-to-tail into a longer name which actually appears in a memory body, or a short name that never appears outside a longer one anywhere in the library. Merely similar names (edit distance, a shared character) are never merged automatically. Review candidates AI could not safely resolve in MemU memories under Entity reviews, using the memory evidence for each pair; the existing relationship graph management remains available. Off means even the provable class waits for you.',
|
|
1989
2404
|
firstRunTitle: 'Create a memory library first',
|
|
1990
2405
|
firstRunDesc: 'There are no libraries yet. Memories from your conversations need one to land in.',
|
|
1991
2406
|
firstRunGoLibraries: 'Create a library',
|
|
1992
2407
|
firstRunGuide: 'Quick start guide',
|
|
1993
2408
|
pageHelp: 'Help',
|
|
1994
|
-
descHelp: '
|
|
2409
|
+
descHelp: 'Verify your first memory, then learn vectors, graph management and troubleshooting',
|
|
1995
2410
|
helpQuickStart: 'Quick start',
|
|
2411
|
+
helpTutorialDesc: 'Follow each action, check its result, and use the troubleshooting link when needed. Browsing steps does not change data or settings.',
|
|
2412
|
+
helpTutorialSteps: 'Tutorial steps',
|
|
2413
|
+
helpTutorialProgress: 'Step',
|
|
2414
|
+
helpTutorialExpected: 'Check the result',
|
|
2415
|
+
helpTutorialTrouble: 'When the result is missing',
|
|
2416
|
+
helpTutorialPrevious: 'Previous step',
|
|
2417
|
+
helpTutorialNext: 'Next step',
|
|
2418
|
+
helpTutorialDiagnose: 'Open diagnostics',
|
|
2419
|
+
helpTutorialReference: 'Browse by task',
|
|
2420
|
+
helpTutorialReferenceHint: 'Start with your current task. Detailed explanations and the label reference follow below.',
|
|
2421
|
+
helpStep1Title: 'Create a library',
|
|
2422
|
+
helpStep1Expected: 'The new library appears under Libraries. Reuse an existing library when appropriate; each conversation does not need a new one.',
|
|
2423
|
+
helpStep1Trouble: 'Check directory permissions and diagnostics if creation fails. Confirm the target library before changing data; deleting and recreating it does not repair a read failure.',
|
|
2424
|
+
helpStep2Title: 'Bind the conversation',
|
|
2425
|
+
helpStep2Expected: 'The conversation sidebar names the target library with private memory enabled. Its channel, character, world and branch match the conversation.',
|
|
2426
|
+
helpStep2Trouble: 'A standalone WebUI may have no current conversation. Bind from the DSH conversation sidebar; conversation switches cannot override a disabled folder scope.',
|
|
2427
|
+
helpStep3Title: 'Enable and verify injection',
|
|
2428
|
+
helpStep3Expected: 'The selected mode appears in Settings. After the next real human message, collapsible memory rules or title cards appear. An empty library may have no recall cards.',
|
|
2429
|
+
helpStep3Trouble: 'Check off mode, folder and conversation switches, domain and context. Tool responses and heartbeats do not start another injection.',
|
|
2430
|
+
helpStep4Title: 'Write, find and correct',
|
|
2431
|
+
helpStep4Expected: 'Save a harmless test fact in the bound private library. Find it on the memory page and open the full text; after correcting it, search again to verify the change.',
|
|
2432
|
+
helpStep4Trouble: 'Writing and recall are separate paths. Check the library, domain and status, then the write and recall log entries. Pending, secret and unrelated-context content is excluded from automatic injection.',
|
|
2433
|
+
helpStep5Title: 'Maintain the lexicon',
|
|
2434
|
+
helpStep5Expected: 'The term is in use in the intended library and domain. Mention it naturally and check recall; archiving it should stop automatic injection.',
|
|
2435
|
+
helpStep5Trouble: 'Both literal and concept recall obey source, domain, context and sensitive-meaning restrictions. Only users may edit sensitive terms; broader permissions are not a workaround.',
|
|
2436
|
+
helpStep6Title: 'Activate real vectors',
|
|
2437
|
+
helpStep6: 'In Connection & vectors, download and verify the runtime and model, activate the profile, then rebuild. Ask about a saved fact using different wording and inspect the retrieval route and actual hit.',
|
|
2438
|
+
helpStep6Expected: 'The runtime and model are ready, an active generation exists, and the indexed count increases. Vector retrieval in the log returns the intended entry.',
|
|
2439
|
+
helpStep6Trouble: 'Installation alone does not activate vectors. Distinguish engine, embedding runtime, model, generation and rebuild errors. Keyword fallback is not evidence that vectors worked.',
|
|
2440
|
+
helpStep7Title: 'Manage graph relationships',
|
|
2441
|
+
helpStep7: 'Open the graph to see the complete circular layout, then zoom or search for a node. Left-drag to reposition; right-click to pin or unpin. Manage connections and review similar-entity candidates individually.',
|
|
2442
|
+
helpStep7Expected: 'Connections have the correct endpoints and relationship type. Review evidence and impact before merging. Similar names remain candidates until confirmed; inspect exclusion and archive results.',
|
|
2443
|
+
helpStep7Trouble: 'Zoomed-out screen points can be crowded; inspect a cluster before judging overlap. Check library and domain filters when candidates are missing. Similar names alone do not establish identity.',
|
|
1996
2444
|
helpGoTo: 'Go →',
|
|
1997
2445
|
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.',
|
|
1998
2446
|
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.',
|
|
@@ -2025,8 +2473,8 @@ window.__ModuleLoader__.load({
|
|
|
2025
2473
|
helpVectorFallback: 'With no active generation (only requested, or a failed rebuild) recall falls back to lexical search: still usable, weaker semantics.',
|
|
2026
2474
|
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.',
|
|
2027
2475
|
helpAutoLink: 'Private auto-links and entity hubs',
|
|
2028
|
-
helpAutoLinkRule:
|
|
2029
|
-
helpAutoLinkHub: '
|
|
2476
|
+
helpAutoLinkRule: 'Check Auto-link mode first: suggestions do not write edges. Deterministic mode accepts confirmed entity mentions and provable field evidence only. Lexical or vector similarity alone never establishes a relationship.',
|
|
2477
|
+
helpAutoLinkHub: 'An entity hub connects memories to a particular person or object. Review names, aliases and evidence first. Two similarly named entities can represent different objects; edit distance alone does not justify merging them.',
|
|
2030
2478
|
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.',
|
|
2031
2479
|
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.',
|
|
2032
2480
|
helpLabels: 'Label cheat sheet',
|
|
@@ -2174,6 +2622,7 @@ window.__ModuleLoader__.load({
|
|
|
2174
2622
|
.dshm-wall-item:hover .dshm-wall-cover img{transform:scale(1.04)}
|
|
2175
2623
|
.dshm-wall-cover-count{position:absolute;right:8px;bottom:8px;padding:1px 7px;border-radius:999px;font-size:11px;line-height:1.6;background:rgba(8,12,20,.6);color:#fff}
|
|
2176
2624
|
.dshm-inbound-tools{font:inherit;color:inherit;background:var(--dsw-alias-bg-layer-1,transparent);border:1px solid var(--dsw-alias-border-l1,#777);border-radius:4px;padding:7px;min-width:0;max-width:100%;flex:1}
|
|
2625
|
+
.dshm-setting-input{height:32px;padding:0 10px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.10));background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.07));color:var(--dsw-alias-label-primary,inherit);min-width:0;max-width:100%;font:inherit;font-size:12.5px;outline:none}
|
|
2177
2626
|
/* In-place detail drawer. The wall opens one card here instead of jumping to the
|
|
2178
2627
|
browser: the list keeps its filters, scroll position and context. */
|
|
2179
2628
|
.dshm-wall-views{margin:2px 0 4px}
|
|
@@ -2236,7 +2685,7 @@ window.__ModuleLoader__.load({
|
|
|
2236
2685
|
/* Graph Studio 工作台:按 graph-studio/index.html 的界面逐块复刻,尺寸按 WebUI 收敛,
|
|
2237
2686
|
颜色全部走 --dsw-alias-* token,自动跟随宿主明暗。画布本身仍由 graph-view.js 绘制。 */
|
|
2238
2687
|
.dshm-gs{--gs-panel:var(--dsw-alias-bg-layer-1,#fff);--gs-panel-2:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.07));--gs-border:var(--dsw-alias-border-l1,rgba(127,127,127,.20));--gs-border-soft:var(--dsw-alias-border-l2,rgba(127,127,127,.10));--gs-text:var(--dsw-alias-label-primary,#1a1e2b);--gs-dim:var(--dsw-alias-label-secondary,rgba(127,127,127,.9));--gs-faint:var(--dsw-alias-label-secondary,rgba(127,127,127,.65));--gs-accent:var(--dsw-alias-brand-primary,#3b5bdb);--gs-on-accent:var(--dsw-alias-brand-text,#fff);--gs-accent-soft:color-mix(in srgb,var(--gs-accent) 12%,transparent);--gs-radius:12px;--gs-radius-sm:8px;--gs-shadow:0 12px 32px rgba(20,30,60,.16);--gs-shadow-sm:0 3px 12px rgba(20,30,60,.12);
|
|
2239
|
-
display:grid;grid-template-columns:46px minmax(0,1fr) 344px;grid-template-rows:
|
|
2688
|
+
display:grid;grid-template-columns:46px minmax(0,1fr) 344px;grid-template-rows:auto minmax(0,1fr) 28px;
|
|
2240
2689
|
height:clamp(520px,calc(100vh - 210px),860px);min-height:420px;position:relative;overflow:hidden;
|
|
2241
2690
|
border:1px solid var(--gs-border);border-radius:var(--gs-radius);background:var(--dsw-alias-bg-base,transparent);
|
|
2242
2691
|
color:var(--gs-text);font-size:12px;line-height:1.5}
|
|
@@ -2251,7 +2700,7 @@ window.__ModuleLoader__.load({
|
|
|
2251
2700
|
.dshm-gs-c-memory{background:#618fcd}.dshm-gs-c-must{background:#d97768}.dshm-gs-c-short{background:#8a93a6}
|
|
2252
2701
|
.dshm-gs-c-entity{background:#36a582}.dshm-gs-c-provisional{background:#b9963f}.dshm-gs-c-global{background:#8b7bd8}.dshm-gs-c-missing{background:#92959c}
|
|
2253
2702
|
/* topbar */
|
|
2254
|
-
.dshm-gs-topbar{grid-column:1/-1;grid-row:1;display:flex;align-items:center;gap:9px;padding:
|
|
2703
|
+
.dshm-gs-topbar{grid-column:1/-1;grid-row:1;display:flex;flex-wrap:wrap;align-items:center;gap:9px;padding:8px 12px;min-height:50px;border-bottom:1px solid var(--gs-border);background:var(--gs-panel);z-index:20;min-width:0}
|
|
2255
2704
|
.dshm-gs-brand{display:flex;align-items:center;gap:9px;flex-shrink:0}
|
|
2256
2705
|
.dshm-gs-mark{width:28px;height:28px;border-radius:8px;display:grid;place-items:center;background:linear-gradient(140deg,var(--gs-accent),color-mix(in srgb,var(--gs-accent) 55%,#8b7bd8));color:var(--gs-on-accent);font-weight:750;font-size:14px;box-shadow:var(--gs-shadow-sm)}
|
|
2257
2706
|
.dshm-gs-brand-txt strong{display:block;font-size:12.5px;font-weight:680;line-height:1.15;white-space:nowrap}
|
|
@@ -2335,6 +2784,20 @@ html[data-standalone] .dshm-root .dshm-gs .dshm-gs-forcepop input[type=range]{he
|
|
|
2335
2784
|
.dshm-gs-ins-title h2{margin:0;font-size:12.5px;font-weight:680}
|
|
2336
2785
|
.dshm-gs-ins-head p{margin:3px 0 0;font-size:10.5px;color:var(--gs-dim)}
|
|
2337
2786
|
.dshm-gs-ins-body{flex:1;min-height:0;overflow-y:auto;padding:12px 14px 20px;display:flex;flex-direction:column;gap:12px}
|
|
2787
|
+
.dshm-gs-actions{min-width:0;font-size:11.5px;line-height:1.55}
|
|
2788
|
+
.dshm-gs-actions>summary{font-size:12px;font-weight:650;color:var(--gs-text)}
|
|
2789
|
+
.dshm-gs-actions p{overflow-wrap:anywhere;margin:7px 0;color:var(--gs-dim)}
|
|
2790
|
+
.dshm-gs-action-fields{display:grid;gap:7px;margin:9px 0}
|
|
2791
|
+
.dshm-gs-action-fields label{display:grid;gap:3px;min-width:0;color:var(--gs-dim)}
|
|
2792
|
+
.dshm-gs-action-fields .dshm-gs-field{width:100%;min-width:0;box-sizing:border-box}
|
|
2793
|
+
.dshm-gs-action-fields textarea{min-height:65px;padding:7px;resize:vertical;font:inherit}
|
|
2794
|
+
.dshm-gs-action-row{display:flex;gap:7px;align-items:center;flex-wrap:wrap;margin:7px 0}
|
|
2795
|
+
.dshm-gs-action-row>span:first-child{flex:1 1 150px;min-width:0;overflow-wrap:anywhere}
|
|
2796
|
+
.dshm-gs-merge-pair>span:first-child{flex-basis:100%}
|
|
2797
|
+
.dshm-gs-action-result{color:var(--gs-accent);overflow-wrap:anywhere}
|
|
2798
|
+
.dshm-gs-actions{flex-shrink:0}
|
|
2799
|
+
.dshm-gs-actions>details>summary{cursor:pointer;font-weight:600;overflow-wrap:anywhere}
|
|
2800
|
+
.dshm-gs-actions h3{margin:0;font-size:12.5px}
|
|
2338
2801
|
.dshm-gs-sec{border:1px solid var(--gs-border-soft);border-radius:var(--gs-radius);padding:11px;background:var(--gs-panel-2)}
|
|
2339
2802
|
.dshm-gs-sec-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:9px}
|
|
2340
2803
|
.dshm-gs-sec-head h3{margin:0;font-size:10.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--gs-faint);font-weight:680}
|
|
@@ -2370,6 +2833,9 @@ html[data-standalone] .dshm-root .dshm-gs .dshm-gs-forcepop input[type=range]{he
|
|
|
2370
2833
|
/* manager */
|
|
2371
2834
|
.dshm-gs-manager{grid-column:2/-1;grid-row:2;display:none;flex-direction:column;min-width:0;min-height:0;background:var(--gs-panel);z-index:12}
|
|
2372
2835
|
.dshm-gs-mgr-head{flex-shrink:0;display:flex;align-items:center;gap:8px;padding:9px 12px;border-bottom:1px solid var(--gs-border);background:var(--gs-panel-2);flex-wrap:wrap}
|
|
2836
|
+
.dshm-gs-mgr-head>.dshm-gs-field{max-width:100%;min-width:0}
|
|
2837
|
+
.dshm-gs-mgr-head>label{flex-shrink:0}
|
|
2838
|
+
.dshm-gs-mgr-focus{padding:8px 12px;overflow-wrap:anywhere;color:var(--gs-dim);font-size:11px;line-height:1.5}
|
|
2373
2839
|
.dshm-gs-mgr-add{display:grid;grid-template-columns:170px auto minmax(220px,1fr) 150px max-content;gap:8px;padding:10px 12px;border-bottom:1px solid var(--gs-border);background:var(--gs-panel-2);align-items:center}
|
|
2374
2840
|
.dshm-gs-mgr-add .dshm-gs-field,.dshm-gs-mgr-add .dshm-gs-btn{height:32px;min-width:0}
|
|
2375
2841
|
.dshm-gs-mgr-add .dshm-gs-seg{height:32px;align-items:center}
|
|
@@ -2393,10 +2859,18 @@ html[data-standalone] .dshm-root .dshm-gs .dshm-gs-forcepop input[type=range]{he
|
|
|
2393
2859
|
.dshm-gs-mgr-row.sel{background:var(--gs-accent-soft);box-shadow:inset 2px 0 0 var(--gs-accent)}
|
|
2394
2860
|
.dshm-gs-mgr-id{font-family:ui-monospace,monospace;font-size:11px;color:var(--gs-dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
2395
2861
|
.dshm-gs-mgr-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
2862
|
+
.dshm-gs-mgr-library{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--dsw-alias-label-secondary,#777);margin-top:3px}
|
|
2396
2863
|
.dshm-gs-mgr-row .num{text-align:right;font-variant-numeric:tabular-nums;color:var(--gs-dim)}
|
|
2397
2864
|
.dshm-gs-mgr-row .dshm-gs-mini{margin:0}
|
|
2398
2865
|
.dshm-gs-mgr-empty{padding:28px 16px;text-align:center;color:var(--gs-dim)}
|
|
2399
|
-
.dshm-gs-mgr-foot{flex-shrink:0;display:flex;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid var(--gs-border);background:var(--gs-panel-2);font-size:11px;color:var(--gs-dim)}
|
|
2866
|
+
.dshm-gs-mgr-foot{flex-shrink:0;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 12px;border-top:1px solid var(--gs-border);background:var(--gs-panel-2);font-size:11px;color:var(--gs-dim)}
|
|
2867
|
+
.dshm-gs-mgr-foot>span:first-child{max-width:100%;overflow-wrap:anywhere}
|
|
2868
|
+
.dshm-gs-mgr-foot>button{flex-shrink:0}
|
|
2869
|
+
@media (max-width:620px){
|
|
2870
|
+
.dshm-gs-mgr-add{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
|
|
2871
|
+
.dshm-gs-mgr-add textarea.dshm-gs-field{grid-column:1/-1}
|
|
2872
|
+
.dshm-gs-mgr-head>.dshm-gs-count{flex:1 0 100%;line-height:1.5}
|
|
2873
|
+
}
|
|
2400
2874
|
/* status */
|
|
2401
2875
|
.dshm-gs-status{grid-column:1/-1;grid-row:3;display:flex;align-items:center;gap:12px;padding:0 12px;border-top:1px solid var(--gs-border);background:var(--gs-panel);font-size:10px;color:var(--gs-dim);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden}
|
|
2402
2876
|
.dshm-gs-status b{color:var(--gs-text);font-weight:650}
|
|
@@ -2406,13 +2880,13 @@ html[data-standalone] .dshm-root .dshm-gs .dshm-gs-forcepop input[type=range]{he
|
|
|
2406
2880
|
.dshm-gs-live i{width:6px;height:6px;border-radius:50%;background:#36a582;box-shadow:0 0 0 3px color-mix(in srgb,#36a582 20%,transparent)}
|
|
2407
2881
|
@media (max-width:1100px){
|
|
2408
2882
|
.dshm-gs{grid-template-columns:46px minmax(0,1fr) 0}
|
|
2409
|
-
.dshm-gs-inspector{position:absolute;top:
|
|
2883
|
+
.dshm-gs-inspector{position:absolute;grid-column:2;grid-row:2;top:0;right:0;bottom:0;width:340px;max-width:100%;box-shadow:var(--gs-shadow);z-index:25}
|
|
2410
2884
|
.dshm-gs.is-collapsed .dshm-gs-inspector{display:none}
|
|
2411
2885
|
.dshm-gs-search{max-width:160px}
|
|
2412
2886
|
.dshm-gs-brand-txt small,.dshm-gs-themechip{display:none}
|
|
2413
2887
|
}
|
|
2414
2888
|
@media (max-width:760px){
|
|
2415
|
-
.dshm-gs,.dshm-gs.is-collapsed,.dshm-gs.is-manage{grid-template-columns:minmax(0,1fr);grid-template-rows:
|
|
2889
|
+
.dshm-gs,.dshm-gs.is-collapsed,.dshm-gs.is-manage{grid-template-columns:minmax(0,1fr);grid-template-rows:auto 38px minmax(0,1fr) 28px}
|
|
2416
2890
|
.dshm-gs-topbar{grid-column:1;grid-row:1;flex-wrap:wrap;align-content:center;gap:6px}
|
|
2417
2891
|
.dshm-gs-domain{order:20;flex:1 0 100%;min-width:0}
|
|
2418
2892
|
.dshm-gs-rail{grid-column:1;grid-row:2;flex-direction:row;justify-content:flex-start;padding:4px 8px;gap:4px;overflow-x:auto;border-right:0;border-bottom:1px solid var(--gs-border)}
|
|
@@ -2420,8 +2894,12 @@ html[data-standalone] .dshm-root .dshm-gs .dshm-gs-forcepop input[type=range]{he
|
|
|
2420
2894
|
.dshm-gs-rail-grow{display:none}
|
|
2421
2895
|
.dshm-gs-stage,.dshm-gs-manager{grid-column:1;grid-row:3}
|
|
2422
2896
|
.dshm-gs-status{grid-column:1;grid-row:4}
|
|
2423
|
-
.dshm-gs-inspector{top:
|
|
2424
|
-
.dshm-gs-
|
|
2897
|
+
.dshm-gs-inspector{grid-column:1;grid-row:3;top:0;width:min(300px,92vw)}
|
|
2898
|
+
.dshm-gs-status{overflow-x:auto;white-space:nowrap;gap:10px}
|
|
2899
|
+
.dshm-gs-status>span,.dshm-gs-status>button{flex-shrink:0}
|
|
2900
|
+
.dshm-gs-status-right{display:none}
|
|
2901
|
+
.dshm-gs-search{order:21;flex:1 0 100%;min-width:0;max-width:none}
|
|
2902
|
+
.dshm-gs-divider,.dshm-gs-popwrap{display:none}
|
|
2425
2903
|
.dshm-gs-mgr-thead,.dshm-gs-mgr-row{grid-template-columns:20px 58px minmax(90px,1fr) 70px 64px 130px;min-width:500px}
|
|
2426
2904
|
.dshm-gs-mgr-thead span:nth-child(6),.dshm-gs-mgr-row>span:nth-child(6),.dshm-gs-mgr-thead span:nth-child(7),.dshm-gs-mgr-row>span:nth-child(7),.dshm-gs-mgr-thead span:nth-child(8),.dshm-gs-mgr-row>span:nth-child(8){display:none}
|
|
2427
2905
|
}
|
|
@@ -2499,6 +2977,60 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
|
|
|
2499
2977
|
.dshm-scope-actions{grid-column:1/-1;display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:2px}
|
|
2500
2978
|
.dshm-scope-hint{grid-column:1/-1;margin:0;font-size:11px;line-height:1.5;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
2501
2979
|
.dshm-scope-note{font-size:11.5px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.8))}
|
|
2980
|
+
.dshm-session-form{container-type:inline-size;display:grid;gap:16px;min-width:0}
|
|
2981
|
+
.dshm-session-row{display:flex;align-items:end;gap:10px;min-width:0}
|
|
2982
|
+
.dshm-session-row>.dshm-scope-field{flex:1}
|
|
2983
|
+
.dshm-session-row>.dshm-btn{flex:0 0 auto;align-self:end;white-space:normal;max-width:100%}
|
|
2984
|
+
.dshm-session-options{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px 20px;align-items:center}
|
|
2985
|
+
.dshm-session-switch{display:flex;align-items:center;justify-content:flex-start;gap:10px;min-width:0;font-size:12px}
|
|
2986
|
+
.dshm-session-options>.dshm-scope-field{grid-column:1/-1}
|
|
2987
|
+
.dshm-session-form>.dshm-scope{margin:0}
|
|
2988
|
+
.dshm-session-footer{display:flex;justify-content:flex-end}
|
|
2989
|
+
.dshm-library-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;min-width:0}
|
|
2990
|
+
.dshm-library-identity{flex:1 1 180px;min-width:0;overflow-wrap:anywhere}
|
|
2991
|
+
.dshm-library-actions{display:flex;flex-wrap:wrap;gap:6px;min-width:0;max-width:100%}
|
|
2992
|
+
.dshm-library-scope{overflow-wrap:anywhere}
|
|
2993
|
+
.dshm-entity-review-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px}
|
|
2994
|
+
.dshm-entity-review-toolbar>select{flex:1;min-width:0;max-width:100%}
|
|
2995
|
+
.dshm-entity-review-list{display:grid;gap:12px;min-width:0}
|
|
2996
|
+
.dshm-entity-review-card{display:grid;gap:10px;min-width:0;padding:12px;border:1px solid var(--dsw-alias-border-l1,#ddd);border-radius:8px;overflow-wrap:anywhere}
|
|
2997
|
+
.dshm-entity-review-head,.dshm-entity-review-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0}
|
|
2998
|
+
.dshm-entity-review-pair{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,250px),1fr));gap:12px}
|
|
2999
|
+
.dshm-entity-review-auto{margin-top:14px;border-top:1px solid var(--dsw-alias-border-l1,#ddd);padding-top:12px;min-width:0}
|
|
3000
|
+
.dshm-entity-review-auto>summary{cursor:pointer;font-size:12px;font-weight:600;line-height:1.5}
|
|
3001
|
+
.dshm-entity-review-auto .dshm-entity-review-list{margin-top:12px}
|
|
3002
|
+
@container (max-width:520px){.dshm-session-row{flex-wrap:wrap}.dshm-session-row>.dshm-scope-field{flex-basis:100%}.dshm-session-row>.dshm-btn{margin-left:auto}.dshm-session-options{grid-template-columns:minmax(0,1fr)}}
|
|
3003
|
+
.dshm-help-guide{display:grid;grid-template-columns:minmax(150px,1fr) minmax(0,2.4fr);gap:18px;align-items:start}
|
|
3004
|
+
.dshm-help-steps{list-style:none;margin:0;padding:0;display:grid;gap:5px}
|
|
3005
|
+
.dshm-help-steps button{display:flex;align-items:center;gap:8px;width:100%;min-height:38px;padding:8px;text-align:left;white-space:normal;overflow-wrap:anywhere;line-height:1.5;border:1px solid transparent;border-radius:6px;background:transparent;color:inherit;font-size:12px;cursor:pointer}
|
|
3006
|
+
.dshm-help-steps button[aria-current="step"]{border-color:var(--dsw-alias-brand-primary,#2563eb);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#2563eb) 9%,transparent)}
|
|
3007
|
+
.dshm-help-steps button:focus-visible,.dshm-help-topics button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#2563eb);outline-offset:2px}
|
|
3008
|
+
.dshm-help-number{display:grid;place-items:center;flex:0 0 22px;height:22px;border:1px solid var(--dsw-alias-border-l2,#888);border-radius:50%;font-size:11px}
|
|
3009
|
+
.dshm-help-lesson{min-width:0;border-left:1px solid var(--dsw-alias-border-l1,#ddd);padding-left:18px}
|
|
3010
|
+
.dshm-help-lesson h3{font-size:15px;line-height:1.5;margin:5px 0 10px}
|
|
3011
|
+
.dshm-help-lesson p,.dshm-help-lesson dd{font-size:12.5px;line-height:1.75;overflow-wrap:anywhere;white-space:pre-wrap}
|
|
3012
|
+
.dshm-help-lesson p{margin:0 0 12px}
|
|
3013
|
+
.dshm-help-lesson dl{margin:0}
|
|
3014
|
+
.dshm-help-lesson dt{font-size:12px;font-weight:650;margin:12px 0 3px}
|
|
3015
|
+
.dshm-help-lesson dd{margin:0 0 8px;color:var(--dsw-alias-label-secondary,#777)}
|
|
3016
|
+
.dshm-help-progress{font-size:11px;color:var(--dsw-alias-label-secondary,#777)}
|
|
3017
|
+
.dshm-help-actions,.dshm-help-topics{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
|
|
3018
|
+
.dshm-help-topics button{min-height:32px;border:1px solid var(--dsw-alias-border-l1,#ddd);border-radius:5px;background:transparent;color:inherit;font:inherit;font-size:12px;padding:5px 9px;cursor:pointer}
|
|
3019
|
+
.dshm-help-copy-note{font-size:12px;line-height:1.65;color:var(--dsw-alias-label-secondary,#777)}
|
|
3020
|
+
.dshm-diag-facts{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:12px 18px;margin:0 0 16px}
|
|
3021
|
+
.dshm-diag-facts>div{min-width:0}
|
|
3022
|
+
.dshm-diag-facts dt{font-size:11px;color:var(--dsw-alias-label-secondary,#777);margin:0 0 3px}
|
|
3023
|
+
.dshm-diag-facts dd{font-size:12.5px;line-height:1.6;overflow-wrap:anywhere;white-space:pre-wrap;margin:0}
|
|
3024
|
+
.dshm-diag-head,.dshm-diag-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0}
|
|
3025
|
+
.dshm-diag-head{justify-content:space-between}
|
|
3026
|
+
.dshm-diag-layer{border-top:1px solid var(--dsw-alias-border-l1,#ddd);padding:12px 0;min-width:0}
|
|
3027
|
+
.dshm-diag-layer h3{font-size:12.5px;margin:0;overflow-wrap:anywhere}
|
|
3028
|
+
.dshm-diag-layer p,.dshm-diag-note{font-size:12px;line-height:1.65;overflow-wrap:anywhere;color:var(--dsw-alias-label-secondary,#777);margin:6px 0}
|
|
3029
|
+
.dshm-diag-details{margin-top:8px;min-width:0;font-size:12px}
|
|
3030
|
+
.dshm-diag-details summary{cursor:pointer;line-height:1.6;overflow-wrap:anywhere}
|
|
3031
|
+
.dshm-diag-details pre{margin:8px 0 0;font-family:var(--dshm-mono);font-size:11px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;max-height:420px;overflow:auto}
|
|
3032
|
+
.dshm-diag-code{font-family:var(--dshm-mono);font-size:11px;overflow-wrap:anywhere;min-width:0}
|
|
3033
|
+
@container (max-width:620px){.dshm-help-guide{grid-template-columns:minmax(0,1fr)}.dshm-help-steps{grid-template-columns:repeat(2,minmax(0,1fr))}.dshm-help-lesson{border-left:0;border-top:1px solid var(--dsw-alias-border-l1,#ddd);padding:14px 0 0}}
|
|
2502
3034
|
.dshm-media{margin:10px 0}
|
|
2503
3035
|
.dshm-media-grid{display:flex;flex-wrap:wrap;gap:10px;padding:10px 0}
|
|
2504
3036
|
.dshm-media-grid figure{margin:0;max-width:240px}
|
|
@@ -2601,7 +3133,7 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
|
|
|
2601
3133
|
.dshm-consolidation-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;width:100%;padding:0;border:0;background:transparent;cursor:pointer;text-align:left;color:inherit;font:inherit}
|
|
2602
3134
|
.dshm-consolidation-title{min-width:0;font-size:12.5px;font-weight:600;overflow-wrap:anywhere}
|
|
2603
3135
|
.dshm-consolidation-toggle{margin-left:auto;font-size:11px;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
|
|
2604
|
-
.dshm-consolidation-columns{display:grid;grid-template-columns:repeat(
|
|
3136
|
+
.dshm-consolidation-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:7px}
|
|
2605
3137
|
.dshm-consolidation-column,.dshm-consolidation-row{min-width:0}
|
|
2606
3138
|
.dshm-consolidation-column-head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary,rgba(127,127,127,.72))}
|
|
2607
3139
|
.dshm-consolidation-failed{color:var(--dsw-alias-state-error-primary,#c0392b)}
|
|
@@ -2685,7 +3217,7 @@ html[data-standalone]:has(.dshm-root.is-graph-navless) .stage{padding-left:28px;
|
|
|
2685
3217
|
|
|
2686
3218
|
async function rpc(ctx, endpoint, payload = {}) {
|
|
2687
3219
|
const res = await ctx.connection.rpc.call('/dsh-memu-memory', endpoint, payload)
|
|
2688
|
-
if (!res || res.ok !== true) throw new Error(res?.error?.message || `rpc ${endpoint} failed`)
|
|
3220
|
+
if (!res || res.ok !== true) throw Object.assign(new Error(res?.error?.message || `rpc ${endpoint} failed`), { code: res?.error?.code })
|
|
2689
3221
|
return res.value
|
|
2690
3222
|
}
|
|
2691
3223
|
|
|
@@ -3148,7 +3680,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3148
3680
|
return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot)
|
|
3149
3681
|
}
|
|
3150
3682
|
|
|
3151
|
-
function ContextScope({ binding, sessionId, call, t }) {
|
|
3683
|
+
function ContextScope({ binding, sessionId, call, t, onChanged }) {
|
|
3152
3684
|
const [notice, setNotice] = React.useState('')
|
|
3153
3685
|
React.useEffect(() => {
|
|
3154
3686
|
if (!notice) return undefined
|
|
@@ -3168,6 +3700,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3168
3700
|
try {
|
|
3169
3701
|
await call('setMemoryContext', { sessionId, context })
|
|
3170
3702
|
notifyMemoryWrite('context', binding.libraryId)
|
|
3703
|
+
await onChanged?.()
|
|
3171
3704
|
setNotice(t('saved'))
|
|
3172
3705
|
} catch (error) { setNotice(String(error.message || error)) }
|
|
3173
3706
|
},
|
|
@@ -3186,6 +3719,100 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3186
3719
|
notice ? h('span', { className: 'dshm-scope-note', role: 'status' }, notice) : null)))
|
|
3187
3720
|
}
|
|
3188
3721
|
|
|
3722
|
+
function SessionActionsPanel({ call, libraries, refreshKey, t }) {
|
|
3723
|
+
const [sessions, setSessions] = React.useState([])
|
|
3724
|
+
const [target, setTarget] = React.useState('')
|
|
3725
|
+
const [library, setLibrary] = React.useState('')
|
|
3726
|
+
const [view, setView] = React.useState(null)
|
|
3727
|
+
const [busy, setBusy] = React.useState(false)
|
|
3728
|
+
const [notice, setNotice] = React.useState('')
|
|
3729
|
+
const [reload, setReload] = React.useState(0)
|
|
3730
|
+
const ownerRef = React.useRef(null)
|
|
3731
|
+
if (ownerRef.current?.target !== target) {
|
|
3732
|
+
if (ownerRef.current) ownerRef.current.alive = false
|
|
3733
|
+
ownerRef.current = { target, alive: true, request: 0, busy: false }
|
|
3734
|
+
}
|
|
3735
|
+
const owner = ownerRef.current
|
|
3736
|
+
const current = () => ownerRef.current === owner && owner.alive
|
|
3737
|
+
const refresh = React.useCallback(async () => {
|
|
3738
|
+
if (!target || !current()) return null
|
|
3739
|
+
const request = ++owner.request
|
|
3740
|
+
const value = await call('getSidebarState', { sessionId: target })
|
|
3741
|
+
if (!current() || owner.request !== request) return null
|
|
3742
|
+
setView({ target, value })
|
|
3743
|
+
return value
|
|
3744
|
+
}, [call, target])
|
|
3745
|
+
React.useEffect(() => {
|
|
3746
|
+
owner.alive = true
|
|
3747
|
+
return () => { owner.alive = false; owner.request++ }
|
|
3748
|
+
}, [target])
|
|
3749
|
+
React.useEffect(() => {
|
|
3750
|
+
let alive = true
|
|
3751
|
+
void call('listSessions', { limit: 200 }).then(value => { if (alive) setSessions(value?.sessions || []) })
|
|
3752
|
+
.catch(error => { if (alive) setNotice(String(error?.message || error)) })
|
|
3753
|
+
return () => { alive = false }
|
|
3754
|
+
}, [call, reload])
|
|
3755
|
+
React.useEffect(() => {
|
|
3756
|
+
void refresh().catch(error => { if (current()) setNotice(String(error?.message || error)) })
|
|
3757
|
+
}, [refresh, refreshKey, reload])
|
|
3758
|
+
React.useEffect(() => {
|
|
3759
|
+
if (!notice) return undefined
|
|
3760
|
+
const timer = setTimeout(() => setNotice(''), 2600)
|
|
3761
|
+
return () => clearTimeout(timer)
|
|
3762
|
+
}, [notice])
|
|
3763
|
+
const data = view?.target === target ? view.value : null
|
|
3764
|
+
const row = sessions.find(item => item.id === target)
|
|
3765
|
+
const chosenLibrary = library || data?.binding?.libraryId || libraries[0]?.id || ''
|
|
3766
|
+
const act = async (method, payload, message, expected) => {
|
|
3767
|
+
if (!target || !current() || owner.busy) return
|
|
3768
|
+
owner.busy = true; setBusy(true)
|
|
3769
|
+
try {
|
|
3770
|
+
const result = await call(method, { sessionId: target, ...payload })
|
|
3771
|
+
if (method === 'generatePrivate' && result?.ok !== true && result?.error) throw new Error(String(result.error))
|
|
3772
|
+
notifyMemoryWrite(method === 'generatePrivate' ? 'memory' : 'context', data?.binding?.libraryId || chosenLibrary)
|
|
3773
|
+
if (!current()) return
|
|
3774
|
+
const next = await refresh()
|
|
3775
|
+
if (next && expected && !expected(next)) throw new Error(t('scopeNotApplied'))
|
|
3776
|
+
if (current()) setNotice(method === 'generatePrivate' ? t('sessionActionsOrganizing') : message)
|
|
3777
|
+
} catch (error) { if (current()) setNotice(String(error?.message || error)) }
|
|
3778
|
+
finally { owner.busy = false; if (current()) setBusy(false) }
|
|
3779
|
+
}
|
|
3780
|
+
return h(Section, { title: t('sessionActions'), desc: t('sessionActionsHint') },
|
|
3781
|
+
h('div', { className: 'dshm-session-form' },
|
|
3782
|
+
h('div', { className: 'dshm-session-row' },
|
|
3783
|
+
h('label', { className: 'dshm-scope-field' }, t('sessionActionsPick'),
|
|
3784
|
+
h('select', { className: 'dshm-setting-input', value: target, 'aria-label': t('sessionActionsPick'),
|
|
3785
|
+
onChange: event => { setTarget(event.target.value); setLibrary(''); setBusy(false); setNotice('') } },
|
|
3786
|
+
h('option', { value: '' }, t('sessionActionsPick')), sessions.map(item => h('option', { key: item.id, value: item.id }, sessionLabel(item))))),
|
|
3787
|
+
h(Button, { title: t('refresh'), onClick: () => setReload(value => value + 1) }, t('refresh'))),
|
|
3788
|
+
notice ? h('p', { className: 'dshm-scope-note', role: 'status' }, notice) : null,
|
|
3789
|
+
target && !data ? h(Empty, null, t('loading')) : null,
|
|
3790
|
+
data ? h(React.Fragment, null,
|
|
3791
|
+
h('div', { className: 'dshm-session-row' },
|
|
3792
|
+
h('label', { className: 'dshm-scope-field' }, t('sessionActionsLibrary'),
|
|
3793
|
+
h('select', { className: 'dshm-setting-input', value: chosenLibrary, 'aria-label': t('sessionActionsLibrary'), onChange: event => setLibrary(event.target.value) },
|
|
3794
|
+
libraries.map(item => h('option', { key: item.id, value: item.id }, libraryOptionLabel(item, libraries))))),
|
|
3795
|
+
h(Button, { title: data.binding || row?.cwd ? t('sessionActionsBind') : t('needsWorkspaceFirst'), disabled: busy || (!data.binding && !row?.cwd) || !chosenLibrary,
|
|
3796
|
+
onClick: () => void act(data.binding ? 'setLibrary' : 'initSession', { ...(!data.binding ? { cwd: row.cwd } : {}), libraryId: chosenLibrary }, t('sessionActionsBound'), next => next.binding?.libraryId === chosenLibrary) }, t('sessionActionsBind'))),
|
|
3797
|
+
!data.binding && !row?.cwd ? h('p', { className: 'dshm-scope-note' }, t('needsWorkspaceFirst')) : null,
|
|
3798
|
+
data.binding ? h(React.Fragment, null,
|
|
3799
|
+
h('div', { className: 'dshm-session-options' },
|
|
3800
|
+
['useLibrary', 'useGlobal'].map(key => h('div', { key, className: 'dshm-session-switch' },
|
|
3801
|
+
h('span', null, t(key === 'useLibrary' ? 'usePrivate' : 'useGlobal')),
|
|
3802
|
+
h(Toggle, { label: t(key === 'useLibrary' ? 'usePrivate' : 'useGlobal'),
|
|
3803
|
+
checked: data.effective?.[key] ?? data.binding[key] !== false, disabled: busy || data.folder?.[key] === false,
|
|
3804
|
+
title: data.folder?.[key] === false ? t('folderSwitchOff') : undefined,
|
|
3805
|
+
onChange: value => void act('setSessionScope', { [key]: value }, t('saved'), next => next.effective?.[key] === value) }))),
|
|
3806
|
+
h('label', { className: 'dshm-scope-field' }, t('domain'),
|
|
3807
|
+
h('select', { className: 'dshm-setting-input', value: data.domain || 'general', 'aria-label': t('domain'), disabled: busy,
|
|
3808
|
+
onChange: event => { const domain = event.target.value; void act('setDomain', { domain }, t('saved'), next => next.domain === domain) } },
|
|
3809
|
+
[...new Set(['general', 'rp', 'coding', 'mixed', ...(data.domains || []), data.domain].filter(Boolean))]
|
|
3810
|
+
.map(domain => h('option', { key: domain, value: domain }, domainText(t, domain)))))),
|
|
3811
|
+
h(ContextScope, { key: JSON.stringify([target, data.binding.memoryContext]), binding: data.binding, sessionId: target, call, t, onChanged: refresh }),
|
|
3812
|
+
h('div', { className: 'dshm-session-footer' },
|
|
3813
|
+
h(Button, { title: t('organize'), disabled: busy, onClick: () => void act('generatePrivate', {}, t('saved')) }, t('organize')))) : null) : null))
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3189
3816
|
function MemoryAttachments({ items, t, initialOpen = false }) {
|
|
3190
3817
|
const [open, setOpen] = React.useState(initialOpen)
|
|
3191
3818
|
const [failed, setFailed] = React.useState({})
|
|
@@ -3199,6 +3826,125 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3199
3826
|
item.hidden ? null : h('figcaption', null, item.caption || '[图片]')))) : null)
|
|
3200
3827
|
}
|
|
3201
3828
|
|
|
3829
|
+
function useDebouncedValue(value) {
|
|
3830
|
+
const [settled, setSettled] = React.useState(value)
|
|
3831
|
+
React.useEffect(() => {
|
|
3832
|
+
const timer = setTimeout(() => setSettled(value), 250)
|
|
3833
|
+
return () => clearTimeout(timer)
|
|
3834
|
+
}, [value])
|
|
3835
|
+
return settled
|
|
3836
|
+
}
|
|
3837
|
+
|
|
3838
|
+
// One snapshot per query. Continuations never run until requested by the reader.
|
|
3839
|
+
function useMemoryPages({ call, method, payload, rowsKey, enabled = true, refreshKey = '', nextLimit = 300, onFailure = null }) {
|
|
3840
|
+
const key = JSON.stringify([method, payload, enabled, refreshKey])
|
|
3841
|
+
const [view, setView] = React.useState({ key: '', data: { [rowsKey]: [], total: 0 }, loading: false, error: '' })
|
|
3842
|
+
const runtime = React.useRef(null)
|
|
3843
|
+
const options = React.useRef(null)
|
|
3844
|
+
if (runtime.current?.key !== key) runtime.current = null
|
|
3845
|
+
options.current = { payload, onFailure }
|
|
3846
|
+
const read = React.useCallback(async (reset = false) => {
|
|
3847
|
+
if (!enabled) return
|
|
3848
|
+
let page = runtime.current
|
|
3849
|
+
if (reset) {
|
|
3850
|
+
page = { key, offset: 0, revision: null, rows: [], total: null, busy: false, restarts: 0, stopped: false }
|
|
3851
|
+
runtime.current = page
|
|
3852
|
+
}
|
|
3853
|
+
if (!page || page.key !== key || page.busy || page.stopped || page.total !== null && page.offset >= page.total) return
|
|
3854
|
+
page.busy = true
|
|
3855
|
+
const current = () => runtime.current === page && page.key === key
|
|
3856
|
+
setView(previous => ({ ...previous, key, loading: true, error: '', ...(reset ? { data: { [rowsKey]: [], total: 0 } } : {}) }))
|
|
3857
|
+
try {
|
|
3858
|
+
for (;;) {
|
|
3859
|
+
try {
|
|
3860
|
+
const value = await call(method, { ...options.current.payload, limit: page.offset ? nextLimit : 60,
|
|
3861
|
+
offset: page.offset, ...(page.revision ? { snapshotRevision: page.revision } : {}) })
|
|
3862
|
+
if (!current()) return
|
|
3863
|
+
const batch = Array.isArray(value?.[rowsKey]) ? value[rowsKey] : []
|
|
3864
|
+
const total = Number.isFinite(value?.total) ? value.total : page.offset + batch.length
|
|
3865
|
+
const ids = new Set(page.rows.map(row => JSON.stringify([row.libraryId || null, row.id])))
|
|
3866
|
+
const overlap = batch.some(row => {
|
|
3867
|
+
const id = JSON.stringify([row.libraryId || null, row.id])
|
|
3868
|
+
if (ids.has(id)) return true
|
|
3869
|
+
ids.add(id)
|
|
3870
|
+
return false
|
|
3871
|
+
})
|
|
3872
|
+
if (overlap || page.offset && (!page.revision || value?.snapshotRevision !== page.revision || total !== page.total)
|
|
3873
|
+
|| value?.offset !== undefined && value.offset !== page.offset
|
|
3874
|
+
|| batch.length > (page.offset ? nextLimit : 60) || page.offset + batch.length > total
|
|
3875
|
+
|| !batch.length && page.offset < total || total > page.offset + batch.length && !value?.snapshotRevision) {
|
|
3876
|
+
throw new Error('MEMORY_CHANGED: inconsistent memory page')
|
|
3877
|
+
}
|
|
3878
|
+
page.rows = page.rows.concat(batch)
|
|
3879
|
+
page.offset += batch.length
|
|
3880
|
+
page.total = total
|
|
3881
|
+
page.revision = value?.snapshotRevision || null
|
|
3882
|
+
setView({ key, data: { ...value, [rowsKey]: page.rows, total }, loading: false, error: '' })
|
|
3883
|
+
return
|
|
3884
|
+
} catch (failure) {
|
|
3885
|
+
if (!current()) return
|
|
3886
|
+
if (failure?.code === 'MEMORY_CHANGED' || /MEMORY_CHANGED/.test(String(failure?.message || failure))) {
|
|
3887
|
+
// A duplicate is evidence of a broken snapshot, never a reason to drop a row.
|
|
3888
|
+
page.rows = []; page.offset = 0; page.total = null; page.revision = null
|
|
3889
|
+
setView({ key, data: { [rowsKey]: [], total: 0 }, loading: true, error: '' })
|
|
3890
|
+
if (++page.restarts <= 2) continue
|
|
3891
|
+
page.stopped = true
|
|
3892
|
+
throw new Error('MEMORY_CHANGED')
|
|
3893
|
+
}
|
|
3894
|
+
throw failure
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
} catch (failure) {
|
|
3898
|
+
if (!current()) return
|
|
3899
|
+
page.stopped = true
|
|
3900
|
+
if (options.current.onFailure?.(failure)) return
|
|
3901
|
+
setView(previous => ({ ...previous, loading: false, error: String(failure?.message || failure) }))
|
|
3902
|
+
} finally { if (current()) page.busy = false }
|
|
3903
|
+
}, [call, key, enabled, method, rowsKey, nextLimit])
|
|
3904
|
+
React.useEffect(() => {
|
|
3905
|
+
void read(true)
|
|
3906
|
+
return () => { runtime.current = null }
|
|
3907
|
+
}, [read])
|
|
3908
|
+
const data = view.key === key ? view.data : { [rowsKey]: [], total: 0 }
|
|
3909
|
+
return { data, pageKey: key, generation: runtime.current?.restarts || 0,
|
|
3910
|
+
loading: enabled && (view.key !== key || view.loading), error: view.key === key ? view.error : '',
|
|
3911
|
+
hasMore: !view.error && (data[rowsKey]?.length || 0) < data.total,
|
|
3912
|
+
more: read, reload: () => read(true) }
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
function MemoryPageMore({ pager, loaded, t }) {
|
|
3916
|
+
const sentinel = React.useRef(null)
|
|
3917
|
+
React.useEffect(() => {
|
|
3918
|
+
if (!pager.hasMore || pager.loading || !sentinel.current || typeof IntersectionObserver !== 'function') return undefined
|
|
3919
|
+
let triggered = false
|
|
3920
|
+
// A replaced snapshot can leave the browser anchored at its new end.
|
|
3921
|
+
// Require a fresh exit/entry after a restart; the More button stays usable.
|
|
3922
|
+
let enteredFromOutside = !pager.generation
|
|
3923
|
+
const observer = new IntersectionObserver(entries => {
|
|
3924
|
+
if (entries.some(entry => !entry.isIntersecting)) enteredFromOutside = true
|
|
3925
|
+
if (!triggered && enteredFromOutside && entries.some(entry => entry.isIntersecting)) {
|
|
3926
|
+
triggered = true
|
|
3927
|
+
observer.disconnect()
|
|
3928
|
+
void pager.more()
|
|
3929
|
+
}
|
|
3930
|
+
}, { rootMargin: '0px' })
|
|
3931
|
+
observer.observe(sentinel.current)
|
|
3932
|
+
return () => { triggered = true; observer.disconnect() }
|
|
3933
|
+
}, [pager.more, pager.hasMore, pager.loading, pager.generation, loaded])
|
|
3934
|
+
if (pager.error) return h('div', { className: 'dshm-settings-note', role: 'alert' },
|
|
3935
|
+
pager.error.includes('MEMORY_CHANGED') ? t('memoryPageChanged') : pager.error,
|
|
3936
|
+
h(Button, { onClick: pager.reload, title: t('reload') }, t('reload')))
|
|
3937
|
+
if (!pager.hasMore && !pager.loading) return null
|
|
3938
|
+
// Never let browser scroll anchoring follow a reused end marker into a new page/snapshot.
|
|
3939
|
+
return h('div', { key: JSON.stringify([pager.pageKey, pager.generation, loaded]), ref: sentinel, className: 'dshm-settings-note', role: 'status' },
|
|
3940
|
+
h(Button, { onClick: () => { void pager.more() }, disabled: pager.loading, title: t('browseLoadMore') },
|
|
3941
|
+
(pager.loading ? t('loading') : t('browseLoadMore')) + ` (${loaded}/${pager.data.total})`))
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
const memoryPool = item => item.status === 'pending_review' ? 'review' : item.status === 'archived' ? 'archived'
|
|
3945
|
+
: ['suppressed', 'expired', 'superseded'].includes(item.status) || item.expiresAt && Date.parse(item.expiresAt) <= Date.now() ? 'inactive' : 'active'
|
|
3946
|
+
const memoryPoolStatus = pool => pool === 'archived' ? 'archived' : pool === 'review' ? 'pending_review' : undefined
|
|
3947
|
+
|
|
3202
3948
|
// 每张可编辑记忆卡在内部维护 draft,并使用 memo,
|
|
3203
3949
|
// 避免单张卡输入时重渲染整个列表。
|
|
3204
3950
|
const BrowserMemoryCard = React.memo(function BrowserMemoryCard({ file: f, t, busy, browseBusy, onSave, onArchive, onResolve, onLoadFull }) {
|
|
@@ -3378,7 +4124,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3378
4124
|
// chrome=false 时外壳(rail / 参数弹层 / 状态栏)由 Graph Studio 工作台自己画,
|
|
3379
4125
|
// 画布与引擎保持同一份实现:拖动、pin、弹簧链、簇作用域都不变。
|
|
3380
4126
|
function GraphCanvas({ graph, focus, onFocus, t, chrome = true, options: controlledOptions = null,
|
|
3381
|
-
apiRef = null, onZoom = null, onPaint = null }) {
|
|
4127
|
+
apiRef = null, onZoom = null, onPaint = null, onViewport = null }) {
|
|
3382
4128
|
const ref = React.useRef(null)
|
|
3383
4129
|
const tooltipRef = React.useRef(null)
|
|
3384
4130
|
const viewRef = React.useRef(null)
|
|
@@ -3386,6 +4132,32 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3386
4132
|
latest.current = { graph, focus, onFocus, t }
|
|
3387
4133
|
const zoomNotify = React.useRef(onZoom)
|
|
3388
4134
|
zoomNotify.current = onZoom
|
|
4135
|
+
const viewportNotify = React.useRef(onViewport)
|
|
4136
|
+
viewportNotify.current = onViewport
|
|
4137
|
+
const updating = React.useRef(false)
|
|
4138
|
+
const fittedKey = React.useRef(null)
|
|
4139
|
+
const cameraReturn = React.useRef(null)
|
|
4140
|
+
const cameraScene = React.useRef(null)
|
|
4141
|
+
const update = (view, value, selected) => {
|
|
4142
|
+
if (!view) return
|
|
4143
|
+
updating.current = true
|
|
4144
|
+
try {
|
|
4145
|
+
const previous = cameraScene.current
|
|
4146
|
+
if (previous?.scope !== value.cameraScope) cameraReturn.current = null
|
|
4147
|
+
if (value.searchActive && previous && !previous.search && previous.scope === value.cameraScope) {
|
|
4148
|
+
cameraReturn.current = { scope: value.cameraScope, viewport: view.viewport?.() }
|
|
4149
|
+
}
|
|
4150
|
+
const restore = !value.searchActive && previous?.search && cameraReturn.current?.scope === value.cameraScope
|
|
4151
|
+
? cameraReturn.current.viewport : null
|
|
4152
|
+
view.update(value, selected)
|
|
4153
|
+
if (value.fitKey && fittedKey.current !== value.fitKey) {
|
|
4154
|
+
if (restore && typeof view.setViewport === 'function') view.setViewport(restore)
|
|
4155
|
+
else if (fittedKey.current !== null) view.fit()
|
|
4156
|
+
fittedKey.current = value.fitKey
|
|
4157
|
+
}
|
|
4158
|
+
cameraScene.current = { scope: value.cameraScope, search: value.searchActive === true }
|
|
4159
|
+
} finally { updating.current = false }
|
|
4160
|
+
}
|
|
3389
4161
|
const [zoom, setZoom] = React.useState(1)
|
|
3390
4162
|
const [settingsOpen, setSettingsOpen] = React.useState(false)
|
|
3391
4163
|
const [options, setOptions] = React.useState({ repulsion: 120, distance: 100, center: 0, labels: true, motion: true })
|
|
@@ -3404,6 +4176,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3404
4176
|
const view = module.createGraphView(canvas, {
|
|
3405
4177
|
onFocus: id => latest.current.onFocus(id),
|
|
3406
4178
|
onZoom: value => { setZoom(value); zoomNotify.current?.(value) },
|
|
4179
|
+
onViewport: value => { if (!updating.current) viewportNotify.current?.(value) },
|
|
3407
4180
|
// 主画布每重绘一次通知一次:缩略图由它直接驱动,不自己轮询。
|
|
3408
4181
|
onPaint: () => { onPaint?.() },
|
|
3409
4182
|
tooltip: tooltipRef.current,
|
|
@@ -3414,7 +4187,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3414
4187
|
// 只读句柄:浏览器验收与状态栏需要问「现在有几个节点被右键锁定」。
|
|
3415
4188
|
canvas.__dshmGraphView = view
|
|
3416
4189
|
view.configure(optionsRef.current)
|
|
3417
|
-
|
|
4190
|
+
update(view, latest.current.graph, latest.current.focus)
|
|
3418
4191
|
}).catch(() => { if (!disposed) setLoadError(true) })
|
|
3419
4192
|
return () => {
|
|
3420
4193
|
disposed = true
|
|
@@ -3422,13 +4195,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3422
4195
|
try { delete canvas.__dshmGraphView } catch {}
|
|
3423
4196
|
}
|
|
3424
4197
|
}, [attempt])
|
|
3425
|
-
React.useEffect(() => { viewRef.current
|
|
4198
|
+
React.useEffect(() => { update(viewRef.current, graph, focus) }, [graph, focus])
|
|
3426
4199
|
React.useEffect(() => { viewRef.current?.configure(effectiveOptions) }, [effectiveOptions])
|
|
3427
4200
|
React.useEffect(() => {
|
|
3428
4201
|
if (!apiRef) return undefined
|
|
3429
4202
|
apiRef.current = {
|
|
3430
4203
|
zoom: factor => viewRef.current?.zoom(factor),
|
|
3431
4204
|
fit: () => viewRef.current?.fit(),
|
|
4205
|
+
viewport: () => viewRef.current?.viewport?.(),
|
|
3432
4206
|
unpinAll: () => viewRef.current?.unpinAll?.(),
|
|
3433
4207
|
relayout: () => viewRef.current?.relayout?.(),
|
|
3434
4208
|
exportPng: () => ref.current?.toDataURL?.('image/png') || '',
|
|
@@ -3565,19 +4339,134 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3565
4339
|
const graphRuleOf = edge => edge.rule || (edge.source === 'auto' ? 'auto' : null)
|
|
3566
4340
|
const graphRuleText = (rule, t) => GS_RULE_LABEL_KEYS[rule] ? t(GS_RULE_LABEL_KEYS[rule]) : String(rule)
|
|
3567
4341
|
|
|
3568
|
-
function
|
|
3569
|
-
const [
|
|
4342
|
+
function useGraphManagement({ call, active, libraryId, libraries, sessionId, domain, query, includeOrphans, focusId, focusLibraryId, refreshKey, t }) {
|
|
4343
|
+
const [cursor, setCursor] = React.useState(null)
|
|
4344
|
+
const [retry, setRetry] = React.useState(0)
|
|
4345
|
+
const [page, setPage] = React.useState(null)
|
|
4346
|
+
const key = JSON.stringify([active, libraryId, libraries?.map(lib => lib.id), sessionId, domain, query, includeOrphans, focusId, focusLibraryId, refreshKey, retry])
|
|
4347
|
+
const offset = cursor?.key === key ? cursor.offset : 0
|
|
4348
|
+
const requestKey = JSON.stringify([key, offset, cursor?.key === key ? cursor.revision : null])
|
|
4349
|
+
const request = React.useRef(null)
|
|
4350
|
+
if (request.current?.key !== requestKey) {
|
|
4351
|
+
if (request.current) request.current.alive = false
|
|
4352
|
+
request.current = { key: requestKey, alive: true }
|
|
4353
|
+
}
|
|
4354
|
+
const owner = request.current
|
|
4355
|
+
React.useEffect(() => {
|
|
4356
|
+
owner.alive = true
|
|
4357
|
+
if (!active || !libraryId) return () => { owner.alive = false }
|
|
4358
|
+
const current = () => owner.alive && request.current === owner
|
|
4359
|
+
setPage({ key: requestKey, loading: true })
|
|
4360
|
+
void (async () => {
|
|
4361
|
+
let start = offset, expected = cursor?.key === key ? cursor.revision : undefined
|
|
4362
|
+
const changed = () => Object.assign(new Error(t('gsManagerChanged')), { code: 'GRAPH_MANAGEMENT_CHANGED' })
|
|
4363
|
+
const read = async (id, position, limit, revision) => {
|
|
4364
|
+
const args = { overview: true, libraryId: id, ...(sessionId && libraryId !== 'all' ? { sessionId } : {}),
|
|
4365
|
+
domain: domain || undefined, includeOrphans, depth: 0, limit, offset: position }
|
|
4366
|
+
let value, metadata
|
|
4367
|
+
if (focusId || query) value = await call('getGraph', { ...args, ...(focusId ? { focusId } : { query }) })
|
|
4368
|
+
else {
|
|
4369
|
+
metadata = await call('getGraph', { ...args, limit: 1, offset: 0 })
|
|
4370
|
+
if (!current()) return null
|
|
4371
|
+
if (metadata?.overview !== true) throw new Error('Graph management requires bounded overview responses')
|
|
4372
|
+
if (metadata.totals?.nodes === 0) value = { ...metadata, mode: 'detail', nodes: [], edges: [], total: 0, offset: 0, nextOffset: null }
|
|
4373
|
+
else {
|
|
4374
|
+
const box = metadata?.bbox
|
|
4375
|
+
if (!box || !['minX', 'minY', 'maxX', 'maxY'].every(name => Number.isFinite(box[name]))) throw changed()
|
|
4376
|
+
value = await call('getGraph', { ...args, bbox: box, zoom: 1 })
|
|
4377
|
+
}
|
|
4378
|
+
}
|
|
4379
|
+
if (!current()) return null
|
|
4380
|
+
if (revision !== undefined && value?.revision !== revision || metadata && (metadata.revision !== value?.revision
|
|
4381
|
+
|| metadata.totals?.nodes !== value?.totals?.nodes || value?.total !== value?.totals?.nodes)) throw changed()
|
|
4382
|
+
const nodes = value?.nodes, next = position + (nodes?.length || 0)
|
|
4383
|
+
if (value?.overview !== true || value.mode !== 'detail' || !Array.isArray(nodes) || nodes.length > limit
|
|
4384
|
+
|| !Number.isSafeInteger(value.total) || value.total < next
|
|
4385
|
+
|| nodes.some(node => typeof node.id !== 'string' || node.kind === 'cluster')
|
|
4386
|
+
|| new Set(nodes.map(node => node.id)).size !== nodes.length
|
|
4387
|
+
|| (value.nextOffset ?? null) !== (next < value.total ? next : null)
|
|
4388
|
+
|| next < value.total && (!nodes.length || !value.revision)) throw changed()
|
|
4389
|
+
return value
|
|
4390
|
+
}
|
|
4391
|
+
for (let attempt = 0; current(); attempt++) {
|
|
4392
|
+
try {
|
|
4393
|
+
let value
|
|
4394
|
+
if (libraryId === 'all') {
|
|
4395
|
+
const books = (libraries || []).filter(lib => !focusId || lib.id === focusLibraryId)
|
|
4396
|
+
const snapshots = new Array(books.length)
|
|
4397
|
+
let index = 0
|
|
4398
|
+
// Only metadata and one display page: no full-library fan-out.
|
|
4399
|
+
await Promise.all(Array.from({ length: Math.min(4, books.length) }, async () => {
|
|
4400
|
+
while (current() && index < books.length) {
|
|
4401
|
+
const i = index++
|
|
4402
|
+
snapshots[i] = await read(books[i].id, 0, 1)
|
|
4403
|
+
}
|
|
4404
|
+
}))
|
|
4405
|
+
if (!current()) return
|
|
4406
|
+
const revision = JSON.stringify(books.map((lib, i) => [lib.id, snapshots[i].revision, snapshots[i].total]))
|
|
4407
|
+
if (expected !== undefined && revision !== expected) throw changed()
|
|
4408
|
+
const total = snapshots.reduce((sum, snapshot) => sum + snapshot.total, 0)
|
|
4409
|
+
if (start > total) throw changed()
|
|
4410
|
+
const nodes = [], edges = []
|
|
4411
|
+
let base = 0
|
|
4412
|
+
for (let i = 0; i < books.length && nodes.length < 60; i++) {
|
|
4413
|
+
const snapshot = snapshots[i], id = books[i].id
|
|
4414
|
+
if (start < base + snapshot.total) {
|
|
4415
|
+
const offset = Math.max(0, start - base), limit = Math.min(60 - nodes.length, snapshot.total - offset)
|
|
4416
|
+
const page = await read(id, offset, limit, snapshot.revision)
|
|
4417
|
+
if (!current()) return
|
|
4418
|
+
if (page.total !== snapshot.total) throw changed()
|
|
4419
|
+
const key = raw => JSON.stringify([id, raw])
|
|
4420
|
+
nodes.push(...page.nodes.map(node => ({ ...node, rawId: node.id, id: key(node.id), libraryId: id })))
|
|
4421
|
+
edges.push(...(page.edges || []).map(edge => ({ ...edge, from: key(edge.from), to: key(edge.to), libraryId: id })))
|
|
4422
|
+
}
|
|
4423
|
+
base += snapshot.total
|
|
4424
|
+
}
|
|
4425
|
+
value = { nodes, edges, total, revision, nextOffset: start + nodes.length < total ? start + nodes.length : null }
|
|
4426
|
+
} else {
|
|
4427
|
+
value = await read(libraryId, start, 60, expected)
|
|
4428
|
+
if (!current()) return
|
|
4429
|
+
value = { ...value, nodes: value.nodes.map(node => ({ ...node, libraryId })) }
|
|
4430
|
+
}
|
|
4431
|
+
setPage({ ...value, key: requestKey, offset: start, loading: false })
|
|
4432
|
+
return
|
|
4433
|
+
} catch (failure) {
|
|
4434
|
+
if (!current()) return
|
|
4435
|
+
if (failure?.code === 'GRAPH_MANAGEMENT_CHANGED' && attempt < 2) { start = 0; expected = undefined; continue }
|
|
4436
|
+
setPage({ key: requestKey, nodes: [], edges: [], offset: 0, loading: false,
|
|
4437
|
+
error: (focusId ? t('gsManagerUnavailable') + ': ' : '') + String(failure?.message || failure) })
|
|
4438
|
+
return
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
})()
|
|
4442
|
+
return () => { owner.alive = false }
|
|
4443
|
+
}, [call, requestKey])
|
|
4444
|
+
const loaded = page?.key === requestKey ? page : null
|
|
4445
|
+
return { ...(loaded || {}), nodes: loaded?.nodes || [], edges: loaded?.edges || [],
|
|
4446
|
+
loading: !!active && !!libraryId && (!loaded || loaded.loading),
|
|
4447
|
+
previous: () => loaded && setCursor({ key, offset: Math.max(0, loaded.offset - 60), revision: loaded.revision }),
|
|
4448
|
+
next: () => Number.isInteger(loaded?.nextOffset) && setCursor({ key, offset: loaded.nextOffset, revision: loaded.revision }),
|
|
4449
|
+
refresh: () => { setCursor(null); setRetry(value => value + 1) } }
|
|
4450
|
+
}
|
|
4451
|
+
|
|
4452
|
+
function GraphStudioPanel({ call, libraries, revision, stamp, t, navHidden = false, onToggleNav = null, sessionId = null, initialLibraryId = '' }) {
|
|
4453
|
+
const [graphLib, setGraphLib] = React.useState(initialLibraryId)
|
|
3570
4454
|
// 默认落在有数据的私有库:全局图常常是空的,一进页面就空白会让人以为图坏了。
|
|
3571
4455
|
const firstPrivate = libraries[0]?.id || ''
|
|
3572
4456
|
const graphLibrary = graphLib === GLOBAL_GRAPH_ID ? GLOBAL_GRAPH_ID
|
|
3573
4457
|
: (graphLib && libraries.some(lib => lib.id === graphLib) ? graphLib : (firstPrivate || GLOBAL_GRAPH_ID))
|
|
3574
4458
|
const showGlobal = graphLibrary === GLOBAL_GRAPH_ID
|
|
3575
4459
|
const [graph, setGraph] = React.useState({ nodes: [], edges: [] })
|
|
3576
|
-
const [entities, setEntities] = React.useState([])
|
|
3577
4460
|
const [focus, setFocus] = React.useState('')
|
|
4461
|
+
const [graphBranch, setGraphBranch] = React.useState(null)
|
|
4462
|
+
const [graphCursor, setGraphCursor] = React.useState({ key: '', offset: 0 })
|
|
4463
|
+
const [graphViewport, setGraphViewport] = React.useState(null)
|
|
3578
4464
|
const [error, setError] = React.useState('')
|
|
3579
4465
|
const [view, setView] = React.useState('graph')
|
|
3580
4466
|
const [query, setQuery] = React.useState('')
|
|
4467
|
+
const rawGraphQuery = query.trim().slice(0, 256)
|
|
4468
|
+
const graphQuery = useDebouncedValue(rawGraphQuery)
|
|
4469
|
+
const queryPending = rawGraphQuery !== graphQuery
|
|
3581
4470
|
const [domain, setDomain] = React.useState('')
|
|
3582
4471
|
const graphDomain = domain.normalize('NFKC').trim().toLowerCase()
|
|
3583
4472
|
const [source, setSource] = React.useState('all')
|
|
@@ -3600,62 +4489,204 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3600
4489
|
const [mgrStatus, setMgrStatus] = React.useState('')
|
|
3601
4490
|
const [mgrSort, setMgrSort] = React.useState('degree')
|
|
3602
4491
|
const [mgrSelected, setMgrSelected] = React.useState('')
|
|
4492
|
+
const [mgrLib, setMgrLib] = React.useState('')
|
|
4493
|
+
const [addLib, setAddLib] = React.useState('')
|
|
4494
|
+
const [mgrOrphans, setMgrOrphans] = React.useState(false)
|
|
4495
|
+
const [mgrFocus, setMgrFocus] = React.useState(null)
|
|
3603
4496
|
const [branchWidth, setBranchWidth] = React.useState(360)
|
|
3604
4497
|
// 管理视图的增删节点:新增走 addMemory / createEntity,删除两段确认。
|
|
3605
4498
|
const [mgrBusy, setMgrBusy] = React.useState(false)
|
|
3606
4499
|
const [mgrArmed, setMgrArmed] = React.useState('')
|
|
3607
4500
|
const [mgrDeleteRefused, setMgrDeleteRefused] = React.useState('')
|
|
3608
4501
|
const [reloadKey, setReloadKey] = React.useState(0)
|
|
4502
|
+
const [homeKey, setHomeKey] = React.useState(0)
|
|
4503
|
+
const [reviewOpen, setReviewOpen] = React.useState(false)
|
|
4504
|
+
const [reviewLib, setReviewLib] = React.useState('')
|
|
4505
|
+
const [reviewSummary, setReviewSummary] = React.useState(null)
|
|
3609
4506
|
const [addOpen, setAddOpen] = React.useState(false)
|
|
3610
|
-
const [addLib, setAddLib] = React.useState('')
|
|
3611
4507
|
const [draft, setDraft] = React.useState({ type: 'memory', title: '', content: '', layer: 'long_term', name: '', kind: 'person' })
|
|
3612
|
-
// 编辑已有节点:记忆读 getMemory
|
|
4508
|
+
// 编辑已有节点:记忆读 getMemory,实体按 ID 有界读取,保留完整别名。
|
|
3613
4509
|
// 两者都与新增表单互斥,共用同一套网格样式。
|
|
3614
4510
|
const [editBusy, setEditBusy] = React.useState(false)
|
|
3615
4511
|
const [editOpen, setEditOpen] = React.useState(false)
|
|
3616
4512
|
const [editDraft, setEditDraft] = React.useState(null)
|
|
3617
4513
|
// 「全部记忆库」合并的是各私有库,新增必须选目标库;没有私有库时落到全局索引,只读。
|
|
3618
4514
|
const mergedScope = showGlobal && libraries.length > 0
|
|
4515
|
+
const reviewLibrary = mergedScope ? (libraries.some(lib => lib.id === reviewLib) ? reviewLib : firstPrivate) : showGlobal ? '' : graphLibrary
|
|
3619
4516
|
const writable = !showGlobal || mergedScope
|
|
3620
|
-
const
|
|
4517
|
+
const managementLibrary = mgrLib === 'all' ? 'all' : libraries.some(lib => lib.id === mgrLib) ? mgrLib
|
|
4518
|
+
: mergedScope ? 'all' : showGlobal ? '' : graphLibrary
|
|
4519
|
+
const addTargetLib = managementLibrary === 'all' ? (libraries.some(lib => lib.id === addLib) ? addLib : firstPrivate) : managementLibrary
|
|
4520
|
+
const managementCredentials = id => sessionId && id === (initialLibraryId || firstPrivate) ? { sessionId } : {}
|
|
4521
|
+
const managerId = (id, libraryId) => managementLibrary === 'all' ? JSON.stringify([libraryId, id]) : id
|
|
4522
|
+
const canvasId = node => mergedScope ? JSON.stringify([node.libraryId, node.rawId || node.id]) : node.rawId || node.id
|
|
4523
|
+
const locateManaged = node => {
|
|
4524
|
+
if (!node) return
|
|
4525
|
+
if (!mergedScope && graphLibrary !== node.libraryId) setGraphLib(node.libraryId)
|
|
4526
|
+
navigateGraph(canvasId(node)); setView('graph'); setInspectorOpen(true)
|
|
4527
|
+
}
|
|
3621
4528
|
const apiRef = React.useRef(null)
|
|
3622
4529
|
const searchRef = React.useRef(null)
|
|
3623
4530
|
// 缩略图的画笔登记处:主画布 onPaint 直接叫它,空闲期零定时器。
|
|
3624
4531
|
const minimapPaint = React.useRef(null)
|
|
3625
4532
|
const beat = `${revision ?? ''}:${stamp ?? ''}`
|
|
4533
|
+
const cameraScope = JSON.stringify([graphLibrary, graphDomain, graphBranch, homeKey, sessionId, libraries.map(lib => lib.id)])
|
|
4534
|
+
const navigationKey = JSON.stringify([cameraScope, graphQuery])
|
|
4535
|
+
const managementScope = JSON.stringify([graphLibrary, managementLibrary, sessionId, graphDomain])
|
|
4536
|
+
const managedFocus = mgrFocus?.scope === managementScope ? mgrFocus.id : ''
|
|
4537
|
+
const management = useGraphManagement({ call, active: view === 'manage' && !queryPending, libraryId: managementLibrary, libraries,
|
|
4538
|
+
sessionId: managementCredentials(managementLibrary).sessionId, domain: graphDomain, query: graphQuery,
|
|
4539
|
+
includeOrphans: mgrOrphans, focusId: managedFocus, focusLibraryId: mgrFocus?.libraryId,
|
|
4540
|
+
refreshKey: JSON.stringify([beat, reloadKey]), t })
|
|
4541
|
+
const managerNodes = management.nodes
|
|
4542
|
+
const selectedManagerNode = managerNodes.find(node => node.id === mgrSelected) || null
|
|
4543
|
+
const editOwnerKey = JSON.stringify([navigationKey, rawGraphQuery, managementScope, mgrOrphans, managedFocus, mgrSelected, view])
|
|
4544
|
+
const addOwner = React.useRef(null)
|
|
4545
|
+
const addOwnerKey = JSON.stringify([managementScope, addTargetLib, rawGraphQuery, mgrSelected, view, addOpen])
|
|
4546
|
+
if (addOwner.current?.key !== addOwnerKey) {
|
|
4547
|
+
if (addOwner.current) addOwner.current.alive = false
|
|
4548
|
+
addOwner.current = { key: addOwnerKey, alive: true }
|
|
4549
|
+
}
|
|
4550
|
+
const creationOwner = addOwner.current
|
|
4551
|
+
React.useEffect(() => { creationOwner.alive = true; setMgrBusy(false); return () => { creationOwner.alive = false } }, [addOwnerKey])
|
|
4552
|
+
const editRequest = React.useRef(null)
|
|
4553
|
+
if (editRequest.current?.key !== editOwnerKey) {
|
|
4554
|
+
if (editRequest.current) editRequest.current.alive = false
|
|
4555
|
+
editRequest.current = { key: editOwnerKey, alive: true, request: 0 }
|
|
4556
|
+
}
|
|
4557
|
+
const editOwner = editRequest.current
|
|
4558
|
+
const editCurrent = request => editRequest.current === editOwner && editOwner.alive && editOwner.request === request
|
|
4559
|
+
React.useEffect(() => {
|
|
4560
|
+
editOwner.alive = true
|
|
4561
|
+
setMgrBusy(false); setEditBusy(false); setEditOpen(false); setEditDraft(null)
|
|
4562
|
+
return () => { editOwner.alive = false; editOwner.request++ }
|
|
4563
|
+
}, [editOwnerKey])
|
|
4564
|
+
const viewportControl = React.useRef(null)
|
|
4565
|
+
const libraryLayout = React.useRef(null)
|
|
4566
|
+
if (viewportControl.current?.key !== navigationKey) {
|
|
4567
|
+
if (viewportControl.current) { clearTimeout(viewportControl.current.timer); viewportControl.current.alive = false }
|
|
4568
|
+
viewportControl.current = { key: navigationKey, epoch: 0, timer: null, signature: '', alive: true }
|
|
4569
|
+
}
|
|
4570
|
+
if (libraryLayout.current?.key !== cameraScope) libraryLayout.current = { key: cameraScope, transforms: {} }
|
|
4571
|
+
const viewportOwner = viewportControl.current
|
|
4572
|
+
const viewport = !graphQuery && graphViewport?.key === cameraScope ? graphViewport : null
|
|
4573
|
+
const nearViewport = viewport && viewport.zoom >= 1
|
|
4574
|
+
const graphKey = JSON.stringify([navigationKey, rawGraphQuery, beat, reloadKey, viewport])
|
|
4575
|
+
const graphOffset = graphCursor.key === graphKey ? graphCursor.offset : 0
|
|
4576
|
+
const graphRequestKey = JSON.stringify([graphKey, graphOffset])
|
|
4577
|
+
const graphRequest = React.useRef(graphRequestKey)
|
|
4578
|
+
graphRequest.current = graphRequestKey
|
|
4579
|
+
const viewportSource = React.useRef(null)
|
|
4580
|
+
viewportSource.current = { key: navigationKey, overview: !rawGraphQuery && !graphQuery && graph.overview === true
|
|
4581
|
+
&& graph.mode !== 'classic' && graph.fitKey === navigationKey }
|
|
4582
|
+
const onGraphViewport = React.useCallback(value => {
|
|
4583
|
+
const owner = viewportControl.current, box = value?.bbox
|
|
4584
|
+
if (!owner?.alive || owner.key !== navigationKey || !viewportSource.current?.overview
|
|
4585
|
+
|| viewportSource.current.key !== navigationKey || !(value?.zoom > 0)
|
|
4586
|
+
|| !box || !['minX', 'minY', 'maxX', 'maxY'].every(name => Number.isFinite(box[name]))
|
|
4587
|
+
|| box.minX >= box.maxX || box.minY >= box.maxY) return
|
|
4588
|
+
const signature = JSON.stringify([value.zoom, box])
|
|
4589
|
+
if (signature === owner.signature) return
|
|
4590
|
+
owner.signature = signature
|
|
4591
|
+
const epoch = ++owner.epoch
|
|
4592
|
+
clearTimeout(owner.timer)
|
|
4593
|
+
owner.timer = setTimeout(() => {
|
|
4594
|
+
if (viewportControl.current !== owner || !owner.alive || owner.epoch !== epoch) return
|
|
4595
|
+
setGraphViewport({ key: cameraScope, zoom: value.zoom, bbox: { ...box }, epoch })
|
|
4596
|
+
}, 250)
|
|
4597
|
+
}, [navigationKey, cameraScope])
|
|
4598
|
+
React.useEffect(() => {
|
|
4599
|
+
viewportOwner.alive = true
|
|
4600
|
+
return () => { viewportOwner.alive = false; clearTimeout(viewportOwner.timer) }
|
|
4601
|
+
}, [navigationKey])
|
|
3626
4602
|
const notify = message => setToast(message)
|
|
3627
4603
|
|
|
3628
4604
|
// 一切轮询仍走 SettingsPage 的心跳:revision/stamp 变动才重新取数。
|
|
3629
4605
|
React.useEffect(() => {
|
|
4606
|
+
if (queryPending) return undefined
|
|
4607
|
+
// A heartbeat during the trailing window must not read the previous camera.
|
|
4608
|
+
if (viewportOwner.epoch && viewport?.epoch !== viewportOwner.epoch) return undefined
|
|
3630
4609
|
let alive = true
|
|
4610
|
+
const epoch = viewportOwner.epoch
|
|
4611
|
+
const current = () => alive && viewportOwner.alive && viewportControl.current === viewportOwner
|
|
4612
|
+
&& viewportOwner.epoch === epoch && graphRequest.current === graphRequestKey
|
|
3631
4613
|
const load = async () => {
|
|
3632
4614
|
try {
|
|
3633
|
-
|
|
3634
|
-
const
|
|
4615
|
+
const layout = libraryLayout.current
|
|
4616
|
+
const credentials = sessionId && !mergedScope ? { sessionId } : {}
|
|
4617
|
+
const argsFor = (libraryId, limit) => {
|
|
4618
|
+
const shift = layout.transforms[libraryId]?.shiftX || 0
|
|
4619
|
+
return { overview: true, layout: 'classic', ...credentials, ...(libraryId ? { libraryId } : { scope: 'global' }),
|
|
4620
|
+
domain: graphDomain || undefined, depth: 2, limit, offset: graphOffset,
|
|
4621
|
+
...(graphQuery ? { query: graphQuery } : viewport ? { zoom: viewport.zoom, bbox: { ...viewport.bbox,
|
|
4622
|
+
minX: viewport.bbox.minX - shift, maxX: viewport.bbox.maxX - shift } }
|
|
4623
|
+
: graphBranch ? { clusterId: graphBranch.clusterId } : {}) }
|
|
4624
|
+
}
|
|
4625
|
+
// Assemble the classic graph before painting so fit/zoom always see every node.
|
|
4626
|
+
const readLibrary = async (libraryId, limit = 3000) => {
|
|
3635
4627
|
const nodes = new Map(), edges = new Map(), domains = new Set()
|
|
3636
|
-
let offset =
|
|
3637
|
-
while (
|
|
3638
|
-
const value = await call('getGraph', { libraryId,
|
|
3639
|
-
|
|
3640
|
-
|
|
4628
|
+
let offset = graphOffset, metadata = {}, pageLimit = graphQuery || graphBranch || nearViewport ? limit : 3000
|
|
4629
|
+
while (current()) {
|
|
4630
|
+
const value = await call('getGraph', { ...argsFor(libraryId, pageLimit), offset })
|
|
4631
|
+
if (value?.overview && value.mode !== 'classic') return value
|
|
4632
|
+
if (metadata.revision !== undefined && metadata.revision !== value?.revision) throw new Error('Graph changed while loading; refresh to retry')
|
|
4633
|
+
metadata = value || {}
|
|
3641
4634
|
for (const node of value?.nodes || []) nodes.set(node.id, node)
|
|
3642
4635
|
for (const edge of value?.edges || []) edges.set(JSON.stringify([edge.from, edge.to, edge.kind]), edge)
|
|
3643
4636
|
for (const valueDomain of value?.domains || []) domains.add(valueDomain)
|
|
3644
4637
|
if (!Number.isInteger(value?.nextOffset)) break
|
|
3645
4638
|
if (value.nextOffset <= offset) throw new Error('Invalid graph page offset')
|
|
3646
4639
|
offset = value.nextOffset
|
|
4640
|
+
if (value.mode === 'classic') pageLimit = 3000
|
|
3647
4641
|
}
|
|
3648
|
-
return { nodes: [...nodes.values()], edges: [...edges.values()], domains: [...domains] }
|
|
4642
|
+
return { ...metadata, nextOffset: null, truncated: false, nodes: [...nodes.values()], edges: [...edges.values()], domains: [...domains] }
|
|
4643
|
+
}
|
|
4644
|
+
const publish = value => {
|
|
4645
|
+
if (!current()) return
|
|
4646
|
+
if (graphOffset && graph.pageKey === graphKey && graph.revision !== value.revision) {
|
|
4647
|
+
setGraphCursor({ key: '', offset: 0 })
|
|
4648
|
+
setGraph({ nodes: [], edges: [] })
|
|
4649
|
+
return
|
|
4650
|
+
}
|
|
4651
|
+
setGraph(previous => {
|
|
4652
|
+
if (!graphOffset || previous.pageKey !== graphKey) return { ...value, pageKey: graphKey, fitKey: navigationKey, cameraScope, searchActive: !!graphQuery }
|
|
4653
|
+
const nodes = new Map([...previous.nodes, ...value.nodes].map(node => [node.id, node]))
|
|
4654
|
+
const edges = new Map([...previous.edges, ...value.edges].map(edge => [JSON.stringify([edge.from, edge.to, edge.kind]), edge]))
|
|
4655
|
+
return { ...value, pageKey: graphKey, fitKey: navigationKey, cameraScope, searchActive: !!graphQuery, nodes: [...nodes.values()], edges: [...edges.values()] }
|
|
4656
|
+
})
|
|
3649
4657
|
}
|
|
3650
4658
|
if (showGlobal && libraries.length) {
|
|
3651
|
-
const
|
|
4659
|
+
const allBooks = !graphQuery && graphBranch ? libraries.filter(lib => lib.id === graphBranch.libraryId) : libraries
|
|
4660
|
+
const books = allBooks.filter(lib => {
|
|
4661
|
+
const transform = layout.transforms[lib.id], bounds = transform?.bbox
|
|
4662
|
+
return !viewport || !bounds || bounds.maxX + transform.shiftX >= viewport.bbox.minX
|
|
4663
|
+
&& bounds.minX + transform.shiftX <= viewport.bbox.maxX && bounds.maxY >= viewport.bbox.minY && bounds.minY <= viewport.bbox.maxY
|
|
4664
|
+
}).slice(0, graphQuery || nearViewport ? 3000 : undefined)
|
|
4665
|
+
const limit = graphQuery || nearViewport ? Math.max(1, Math.floor(3000 / Math.max(1, books.length))) : graphBranch && !viewport ? 3000 : 200
|
|
4666
|
+
const results = await Promise.allSettled(books.map(lib => readLibrary(lib.id, limit)))
|
|
4667
|
+
if (!current()) return
|
|
3652
4668
|
const nodes = new Map(), edges = new Map(), domains = new Set(), failures = []
|
|
4669
|
+
const totals = {}, revisions = [], nextOffsets = []
|
|
4670
|
+
let nextLibraryX = 0
|
|
4671
|
+
let overview = false, mode = 'clusters'
|
|
3653
4672
|
for (let i = 0; i < results.length; i++) {
|
|
3654
|
-
const result = results[i], lib =
|
|
4673
|
+
const result = results[i], lib = books[i]
|
|
3655
4674
|
if (result.status === 'rejected') { failures.push(lib.name || lib.id); continue }
|
|
4675
|
+
overview ||= result.value.overview === true
|
|
4676
|
+
mode = result.value.mode || mode
|
|
4677
|
+
revisions.push([lib.id, result.value.revision])
|
|
4678
|
+
if (Number.isInteger(result.value.nextOffset)) nextOffsets.push(result.value.nextOffset)
|
|
3656
4679
|
const key = id => JSON.stringify([lib.id, id])
|
|
4680
|
+
// Each library has its own world origin; keep their prelaid-out graphs apart.
|
|
4681
|
+
const bounds = result.value.bbox
|
|
4682
|
+
const placed = result.value.overview && result.value.mode !== 'classic' && bounds && Number.isFinite(bounds.minX) && Number.isFinite(bounds.maxX)
|
|
4683
|
+
const shiftX = layout.transforms[lib.id]?.shiftX ?? (placed ? nextLibraryX - bounds.minX : 0)
|
|
4684
|
+
layout.transforms[lib.id] = { shiftX, bbox: bounds, totals: result.value.totals, revision: result.value.revision, domains: result.value.domains }
|
|
4685
|
+
if (placed) nextLibraryX = Math.max(nextLibraryX, shiftX + bounds.maxX + 200)
|
|
3657
4686
|
for (const node of result.value.nodes) nodes.set(key(node.id), {
|
|
3658
4687
|
...node, id: key(node.id), rawId: node.id, libraryId: lib.id,
|
|
4688
|
+
...(placed && Number.isFinite(node.x) ? { x: node.x + shiftX,
|
|
4689
|
+
...(node.bbox ? { bbox: { ...node.bbox, minX: node.bbox.minX + shiftX, maxX: node.bbox.maxX + shiftX } } : {}) } : {}),
|
|
3659
4690
|
})
|
|
3660
4691
|
for (const edge of result.value.edges) {
|
|
3661
4692
|
const from = key(edge.from), to = key(edge.to)
|
|
@@ -3663,32 +4694,32 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3663
4694
|
}
|
|
3664
4695
|
for (const valueDomain of result.value.domains) domains.add(valueDomain)
|
|
3665
4696
|
}
|
|
3666
|
-
|
|
3667
|
-
|
|
4697
|
+
for (const lib of allBooks) {
|
|
4698
|
+
for (const [name, count] of Object.entries(layout.transforms[lib.id]?.totals || {})) totals[name] = (totals[name] || 0) + count
|
|
4699
|
+
for (const valueDomain of layout.transforms[lib.id]?.domains || []) domains.add(valueDomain)
|
|
4700
|
+
}
|
|
4701
|
+
if (!current()) return
|
|
4702
|
+
if (!books.length) { overview = true; mode = graphQuery || nearViewport ? 'detail' : 'clusters' }
|
|
4703
|
+
publish({ nodes: [...nodes.values()], edges: [...edges.values()], domains: [...domains].sort(), overview, mode,
|
|
4704
|
+
totals: overview ? totals : undefined, revision: JSON.stringify(revisions),
|
|
4705
|
+
nextOffset: !nearViewport && nextOffsets.length ? Math.min(...nextOffsets) : null })
|
|
3668
4706
|
setError(failures.length ? t('gsLoadPartial') + failures.join(', ') : '')
|
|
3669
4707
|
} else {
|
|
3670
|
-
const value = showGlobal
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
:
|
|
3674
|
-
if (!alive) return
|
|
3675
|
-
setGraph(value && Array.isArray(value.nodes)
|
|
3676
|
-
? { nodes: value.nodes, edges: value.edges || [], domains: value.domains || [] } : { nodes: [], edges: [] })
|
|
4708
|
+
const value = await readLibrary(showGlobal ? null : graphLibrary)
|
|
4709
|
+
if (!current()) return
|
|
4710
|
+
publish(value && Array.isArray(value.nodes)
|
|
4711
|
+
? { ...value, ...(nearViewport ? { nextOffset: null } : {}), nodes: value.nodes, edges: value.edges || [], domains: value.domains || [] } : { nodes: [], edges: [] })
|
|
3677
4712
|
setError('')
|
|
3678
4713
|
}
|
|
3679
|
-
} catch (failure) { if (
|
|
4714
|
+
} catch (failure) { if (current()) { setGraph({ nodes: [], edges: [] }); setError(String(failure?.message || failure)) } }
|
|
3680
4715
|
}
|
|
3681
4716
|
void load()
|
|
3682
4717
|
return () => { alive = false }
|
|
3683
|
-
}, [call,
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
.then(value => { if (alive) setEntities(value?.items || []) })
|
|
3689
|
-
.catch(() => { if (alive) setEntities([]) })
|
|
3690
|
-
return () => { alive = false }
|
|
3691
|
-
}, [call, graphLibrary, showGlobal, beat, reloadKey])
|
|
4718
|
+
}, [call, graphKey, graphOffset, queryPending])
|
|
4719
|
+
// Overview must not be followed by an unbounded side read of every entity.
|
|
4720
|
+
const entities = React.useMemo(() => showGlobal ? [] : (graph.nodes || [])
|
|
4721
|
+
.filter(node => !['memory', 'global', 'cluster'].includes(node.kind) && !node.missing)
|
|
4722
|
+
.map(node => ({ ...node, name: node.title || node.id })), [graph, showGlobal])
|
|
3692
4723
|
React.useEffect(() => {
|
|
3693
4724
|
if (!toast) return undefined
|
|
3694
4725
|
const timer = setTimeout(() => setToast(''), 2200)
|
|
@@ -3733,29 +4764,43 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3733
4764
|
if (source === 'manual' && edge.source === 'auto') return false
|
|
3734
4765
|
const rule = graphRuleOf(edge)
|
|
3735
4766
|
if (rule && rulesOff.has(rule)) return false
|
|
3736
|
-
if (q && !matched.has(edge.from) && !matched.has(edge.to)) return false
|
|
4767
|
+
if (q && !graph.searchActive && !matched.has(edge.from) && !matched.has(edge.to)) return false
|
|
3737
4768
|
return true
|
|
3738
4769
|
})
|
|
3739
4770
|
}, [graph, q, source, rulesOff, nodeIds])
|
|
3740
|
-
const canvasGraph = React.useMemo(() => ({ nodes, edges: visibleEdges }), [graph, visibleEdges])
|
|
3741
|
-
//
|
|
4771
|
+
const canvasGraph = React.useMemo(() => ({ ...graph, nodes, edges: visibleEdges }), [graph, visibleEdges])
|
|
4772
|
+
// Search membership comes from RPC; the canvas query only highlights loaded nodes.
|
|
3742
4773
|
const canvasOptions = React.useMemo(() => ({ ...forces, labels, motion, grid, query: q }),
|
|
3743
4774
|
[forces, labels, motion, grid, q])
|
|
3744
4775
|
const titles = React.useMemo(() => new Map(nodes.map(node => [node.id, node.title || node.id])), [graph])
|
|
3745
4776
|
const panelFiles = React.useMemo(() => nodes.map(node => ({ id: node.id, title: node.title || node.id })), [graph])
|
|
3746
4777
|
const selected = nodes.find(node => node.id === focus) || null
|
|
4778
|
+
const navigateGraph = id => {
|
|
4779
|
+
const node = nodes.find(item => item.id === id)
|
|
4780
|
+
if (node?.kind === 'cluster') {
|
|
4781
|
+
setGraphBranch({ libraryId: node.libraryId || (showGlobal ? null : graphLibrary), clusterId: node.clusterId || node.rawId || node.id })
|
|
4782
|
+
setFocus(''); setMgrSelected('')
|
|
4783
|
+
} else setFocus(id || '')
|
|
4784
|
+
}
|
|
4785
|
+
const graphTotals = graph.totals || { nodes: nodes.length, edges: edges.length }
|
|
4786
|
+
const overviewControl = h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsOverview'),
|
|
4787
|
+
onClick: () => { setGraphBranch(null); setGraphCursor({ key: '', offset: 0 }); setFocus(''); setMgrSelected(''); setHomeKey(value => value + 1) } }, t('gsOverview'))
|
|
3747
4788
|
const focusEdges = edges.filter(edge => edge.from === focus || edge.to === focus)
|
|
3748
4789
|
const autoCount = edges.filter(edge => edge.source === 'auto').length
|
|
3749
|
-
const
|
|
3750
|
-
const
|
|
3751
|
-
|
|
4790
|
+
const reviewCurrent = reviewSummary?.libraryId === reviewLibrary ? reviewSummary : null
|
|
4791
|
+
const pendingCount = reviewCurrent?.pending == null ? t('gsReviewUnchecked')
|
|
4792
|
+
: reviewCurrent.capped ? t('gsReviewPartialCount').replace('{n}', String(reviewCurrent.pending))
|
|
4793
|
+
: `${reviewCurrent.pending}${reviewCurrent.incomplete ? '?' : ''}`
|
|
4794
|
+
const reviewChanged = React.useCallback(() => setReloadKey(value => value + 1), [])
|
|
4795
|
+
const manageRows = React.useMemo(() => managerNodes.filter(node => {
|
|
4796
|
+
if (managedFocus) return true
|
|
3752
4797
|
if (mgrKind && node.kind !== mgrKind) return false
|
|
3753
4798
|
if (mgrStatus && (node.status || 'confirmed') !== mgrStatus) return false
|
|
3754
4799
|
return true
|
|
3755
|
-
}).sort((a, b) => mgrSort === 'degree' ? (
|
|
4800
|
+
}).sort((a, b) => mgrSort === 'degree' ? (b.degree || 0) - (a.degree || 0)
|
|
3756
4801
|
: mgrSort === 'strength' ? (Number(b.strength) || 0) - (Number(a.strength) || 0)
|
|
3757
4802
|
: String(mgrSort === 'id' ? a.id : a.title || a.id).localeCompare(String(mgrSort === 'id' ? b.id : b.title || b.id))),
|
|
3758
|
-
[
|
|
4803
|
+
[managerNodes, managedFocus, mgrKind, mgrStatus, mgrSort])
|
|
3759
4804
|
|
|
3760
4805
|
const railBtn = (label, text, action, pressed) => h('button', {
|
|
3761
4806
|
type: 'button', title: t(label), 'aria-label': t(label),
|
|
@@ -3781,10 +4826,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3781
4826
|
const zoomBy = factor => apiRef.current?.zoom?.(factor)
|
|
3782
4827
|
// 增删节点:记忆走 addMemory(事实级去重会返回 deduped),实体走 createEntity
|
|
3783
4828
|
// (RPC 层强制 confirmed 并补提及边)。写入后立即重取图,不等心跳。
|
|
3784
|
-
const removeKey = mgrSelected ? 'remove
|
|
4829
|
+
const removeKey = mgrSelected ? JSON.stringify(['remove', managementScope, rawGraphQuery, mgrSelected, management.revision]) : ''
|
|
3785
4830
|
const canAdd = writable && Boolean(addTargetLib) && !mgrBusy
|
|
3786
4831
|
&& (draft.type === 'memory' ? Boolean(draft.content.trim()) : Boolean(draft.name.trim()))
|
|
3787
|
-
const canSave = Boolean(editDraft) && !editBusy
|
|
4832
|
+
const canSave = Boolean(editDraft) && editDraft.ownerKey === editOwnerKey && !editBusy
|
|
3788
4833
|
&& (editDraft.kind === 'memory' ? Boolean(editDraft.content.trim()) : Boolean(editDraft.name.trim()))
|
|
3789
4834
|
// updateMemory 只支持 short_term→long_term 升级与 must_remember 降级;
|
|
3790
4835
|
// 提升到 must_remember 必须走带 pin 理由的写入口,这里不提供。
|
|
@@ -3793,103 +4838,130 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3793
4838
|
: editDraft.layer === 'short_term' ? ['short_term', 'long_term'] : ['long_term']
|
|
3794
4839
|
const addNode = async () => {
|
|
3795
4840
|
if (!canAdd) return
|
|
4841
|
+
const owner = creationOwner, libraryId = addTargetLib, scope = managementScope
|
|
4842
|
+
const current = () => owner.alive && addOwner.current === owner
|
|
3796
4843
|
setMgrBusy(true)
|
|
3797
4844
|
try {
|
|
3798
4845
|
if (draft.type === 'entity') {
|
|
3799
4846
|
const name = draft.name.trim()
|
|
3800
|
-
const entity = await call('createEntity', { libraryId
|
|
3801
|
-
notifyMemoryWrite('relation',
|
|
3802
|
-
|
|
4847
|
+
const entity = await call('createEntity', { libraryId, ...managementCredentials(libraryId), name, kind: draft.kind })
|
|
4848
|
+
notifyMemoryWrite('relation', libraryId)
|
|
4849
|
+
if (!current()) return
|
|
4850
|
+
setMgrOrphans(true)
|
|
4851
|
+
setMgrFocus(entity?.id ? { scope, id: entity.id, libraryId } : null)
|
|
4852
|
+
setMgrSelected(entity?.id ? managerId(entity.id, libraryId) : '')
|
|
3803
4853
|
setDraft(value => ({ ...value, name: '' }))
|
|
3804
4854
|
notify(t('gsNodeCreated').replace('{name}', name))
|
|
3805
4855
|
} else {
|
|
3806
|
-
const payload = { libraryId
|
|
4856
|
+
const payload = { libraryId, ...managementCredentials(libraryId), content: draft.content.trim(), title: draft.title.trim() || undefined, layer: draft.layer }
|
|
3807
4857
|
if (draft.layer === 'must_remember') { payload.pinReason = 'user_explicit_note'; payload.pinSource = 'user_explicit' }
|
|
3808
4858
|
const created = await call('addMemory', payload)
|
|
4859
|
+
if (!current()) { if (!created?.deduped) notifyMemoryWrite('memory', libraryId); return }
|
|
3809
4860
|
if (created?.deduped === true) {
|
|
3810
4861
|
notify(t('dedupedNotice').replace('{id}', created.existingId || '?'))
|
|
3811
4862
|
return
|
|
3812
4863
|
}
|
|
3813
|
-
notifyMemoryWrite('memory',
|
|
3814
|
-
|
|
4864
|
+
notifyMemoryWrite('memory', libraryId)
|
|
4865
|
+
setMgrFocus(created?.id ? { scope, id: created.id, libraryId } : null)
|
|
4866
|
+
setMgrSelected(created?.id ? managerId(created.id, libraryId) : '')
|
|
3815
4867
|
setDraft(value => ({ ...value, title: '', content: '' }))
|
|
3816
4868
|
notify(t('memorySaved'))
|
|
3817
4869
|
}
|
|
4870
|
+
setAddOpen(false)
|
|
3818
4871
|
setReloadKey(value => value + 1)
|
|
3819
|
-
} catch (failure) { notify(String(failure?.message || failure)) } finally { setMgrBusy(false) }
|
|
4872
|
+
} catch (failure) { if (current()) notify(String(failure?.message || failure)) } finally { if (current()) setMgrBusy(false) }
|
|
3820
4873
|
}
|
|
3821
4874
|
const removeSelected = async () => {
|
|
3822
|
-
const node =
|
|
3823
|
-
const libraryId = node?.libraryId
|
|
3824
|
-
if (!node || !libraryId || !writable || mgrBusy) return
|
|
4875
|
+
const node = selectedManagerNode
|
|
4876
|
+
const libraryId = node?.libraryId
|
|
4877
|
+
if (!node || node.kind === 'cluster' || !libraryId || !writable || mgrBusy) return
|
|
3825
4878
|
if (mgrArmed !== removeKey) { setMgrArmed(removeKey); return }
|
|
4879
|
+
const request = ++editOwner.request
|
|
4880
|
+
const credentials = managementCredentials(libraryId)
|
|
3826
4881
|
setMgrBusy(true)
|
|
3827
4882
|
try {
|
|
3828
4883
|
if (node.kind === 'memory') {
|
|
3829
4884
|
// 永久删除只接受已归档条目:先归档再删;两段确认已由按钮承担。
|
|
3830
|
-
await call('archiveMemory', { libraryId, id: node.rawId || node.id })
|
|
3831
|
-
|
|
4885
|
+
await call('archiveMemory', { libraryId, ...credentials, id: node.rawId || node.id })
|
|
4886
|
+
// The archive is already committed even if the following delete is denied.
|
|
4887
|
+
notifyMemoryWrite('memory', libraryId)
|
|
4888
|
+
if (viewportControl.current === viewportOwner && viewportOwner.alive) setReloadKey(value => value + 1)
|
|
4889
|
+
await call('deleteMemory', { libraryId, ...credentials, id: node.rawId || node.id, confirmed: true })
|
|
3832
4890
|
notifyMemoryWrite('memory', libraryId)
|
|
3833
|
-
notify(t('memoryDeleted'))
|
|
3834
4891
|
} else {
|
|
3835
|
-
await call('deleteEntity', { libraryId, entityId: node.rawId || node.id, force: mgrDeleteRefused === node.id })
|
|
4892
|
+
await call('deleteEntity', { libraryId, ...credentials, entityId: node.rawId || node.id, force: mgrDeleteRefused === node.id })
|
|
3836
4893
|
notifyMemoryWrite('relation', libraryId)
|
|
3837
|
-
notify(t('gsNodeDeleted'))
|
|
3838
4894
|
}
|
|
3839
|
-
|
|
4895
|
+
if (!editCurrent(request)) return
|
|
4896
|
+
notify(t(node.kind === 'memory' ? 'memoryDeleted' : 'gsNodeDeleted'))
|
|
4897
|
+
setMgrArmed(''); setMgrDeleteRefused(''); setMgrSelected(''); setMgrFocus(null)
|
|
3840
4898
|
setEditOpen(false); setEditDraft(null)
|
|
3841
4899
|
if (focus === node.id) setFocus('')
|
|
3842
4900
|
setReloadKey(value => value + 1)
|
|
3843
4901
|
} catch (failure) {
|
|
4902
|
+
if (!editCurrent(request)) return
|
|
3844
4903
|
const message = String(failure?.message || failure)
|
|
3845
4904
|
// 实体仍被引用:保留 armed,再点一次升级为 force(连同引用一起删)。
|
|
3846
4905
|
if (/referenced|引用/.test(message)) setMgrDeleteRefused(node.id)
|
|
3847
4906
|
notify(message)
|
|
3848
|
-
} finally { setMgrBusy(false) }
|
|
4907
|
+
} finally { if (editCurrent(request)) setMgrBusy(false) }
|
|
3849
4908
|
}
|
|
3850
4909
|
// 编辑已有节点:先读完整数据再开表单,避免拿节点摘要当正文保存。
|
|
4910
|
+
const cancelEdit = () => {
|
|
4911
|
+
editOwner.request++
|
|
4912
|
+
setEditBusy(false); setEditOpen(false); setEditDraft(null)
|
|
4913
|
+
}
|
|
3851
4914
|
const editNode = async () => {
|
|
3852
|
-
const node =
|
|
3853
|
-
const libraryId = node?.libraryId
|
|
3854
|
-
if (!node || !libraryId || !writable || editBusy) return
|
|
4915
|
+
const node = selectedManagerNode
|
|
4916
|
+
const libraryId = node?.libraryId
|
|
4917
|
+
if (!node || node.kind === 'cluster' || !libraryId || !writable || editBusy) return
|
|
4918
|
+
const request = ++editOwner.request
|
|
3855
4919
|
setEditBusy(true)
|
|
3856
4920
|
try {
|
|
3857
4921
|
if (node.kind === 'memory') {
|
|
3858
|
-
const loaded = await call('getMemory', { libraryId, id: node.rawId || node.id })
|
|
4922
|
+
const loaded = await call('getMemory', { libraryId, ...managementCredentials(libraryId), id: node.rawId || node.id })
|
|
4923
|
+
if (!editCurrent(request)) return
|
|
3859
4924
|
const entry = loaded?.entry || {}
|
|
3860
|
-
setEditDraft({ id: node.rawId || node.id, kind: 'memory', libraryId,
|
|
4925
|
+
setEditDraft({ id: node.rawId || node.id, kind: 'memory', libraryId, ownerKey: editOwnerKey,
|
|
3861
4926
|
title: entry.title || '', content: entry.content || '', layer: entry.layer || 'long_term' })
|
|
3862
4927
|
} else {
|
|
3863
|
-
const list = await call('listEntities', { libraryId })
|
|
3864
|
-
|
|
3865
|
-
|
|
4928
|
+
const list = await call('listEntities', { libraryId, ...managementCredentials(libraryId), entityId: node.rawId || node.id })
|
|
4929
|
+
if (!editCurrent(request)) return
|
|
4930
|
+
if (list?.items?.length !== 1 || list.items[0].id !== (node.rawId || node.id)
|
|
4931
|
+
|| list.items[0].aliases !== undefined && !Array.isArray(list.items[0].aliases)) throw new Error(t('gsManagerUnavailable'))
|
|
4932
|
+
const found = list.items[0]
|
|
4933
|
+
setEditDraft({ id: node.rawId || node.id, kind: 'entity', libraryId, ownerKey: editOwnerKey,
|
|
3866
4934
|
name: found.name || node.title || '', aliases: (found.aliases || []).join(', ') })
|
|
3867
4935
|
}
|
|
3868
4936
|
setAddOpen(false)
|
|
3869
4937
|
setEditOpen(true)
|
|
3870
|
-
} catch (failure) { notify(String(failure?.message || failure)) }
|
|
4938
|
+
} catch (failure) { if (editCurrent(request)) notify(String(failure?.message || failure)) }
|
|
4939
|
+
finally { if (editCurrent(request)) setEditBusy(false) }
|
|
3871
4940
|
}
|
|
3872
4941
|
const saveEdit = async () => {
|
|
3873
4942
|
if (!canSave) return
|
|
4943
|
+
const request = ++editOwner.request
|
|
3874
4944
|
setEditBusy(true)
|
|
3875
4945
|
try {
|
|
3876
4946
|
if (editDraft.kind === 'memory') {
|
|
3877
4947
|
const patch = { content: editDraft.content.trim(), layer: editDraft.layer }
|
|
3878
4948
|
const title = editDraft.title.trim()
|
|
3879
4949
|
if (title) patch.title = title
|
|
3880
|
-
await call('updateMemory', { libraryId: editDraft.libraryId, id: editDraft.id, patch })
|
|
4950
|
+
await call('updateMemory', { libraryId: editDraft.libraryId, ...managementCredentials(editDraft.libraryId), id: editDraft.id, patch })
|
|
3881
4951
|
notifyMemoryWrite('memory', editDraft.libraryId)
|
|
3882
4952
|
} else {
|
|
3883
4953
|
// renameEntity 的 aliases 是整体替换:必须带上当前列表,否则会被清空。
|
|
3884
4954
|
const aliases = String(editDraft.aliases || '').split(',').map(value => value.trim()).filter(Boolean)
|
|
3885
|
-
await call('renameEntity', { libraryId: editDraft.libraryId, entityId: editDraft.id,
|
|
4955
|
+
await call('renameEntity', { libraryId: editDraft.libraryId, ...managementCredentials(editDraft.libraryId), entityId: editDraft.id,
|
|
3886
4956
|
name: editDraft.name.trim(), aliases })
|
|
3887
4957
|
notifyMemoryWrite('relation', editDraft.libraryId)
|
|
3888
4958
|
}
|
|
4959
|
+
if (!editCurrent(request)) return
|
|
3889
4960
|
notify(t('saved'))
|
|
3890
4961
|
setEditOpen(false); setEditDraft(null)
|
|
3891
4962
|
setReloadKey(value => value + 1)
|
|
3892
|
-
} catch (failure) { notify(String(failure?.message || failure)) }
|
|
4963
|
+
} catch (failure) { if (editCurrent(request)) notify(String(failure?.message || failure)) }
|
|
4964
|
+
finally { if (editCurrent(request)) setEditBusy(false) }
|
|
3893
4965
|
}
|
|
3894
4966
|
|
|
3895
4967
|
const topbar = h('header', { className: 'dshm-gs-topbar' },
|
|
@@ -3904,7 +4976,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3904
4976
|
className: 'dshm-gs-field', value: graphLibrary,
|
|
3905
4977
|
title: showGlobal ? t('gsAllLibraries') : (libraries.find(lib => lib.id === graphLibrary)?.scopeKey || t('currentLibrary')),
|
|
3906
4978
|
'aria-label': t('currentLibrary'), onChange: event => {
|
|
3907
|
-
setGraphLib(event.target.value); setFocus(''); setMgrSelected(''); setGraph({ nodes: [], edges: [] })
|
|
4979
|
+
setGraphLib(event.target.value); setGraphBranch(null); setFocus(''); setMgrSelected(''); setGraph({ nodes: [], edges: [] })
|
|
3908
4980
|
},
|
|
3909
4981
|
},
|
|
3910
4982
|
h('option', { value: GLOBAL_GRAPH_ID }, t('gsAllLibraries')),
|
|
@@ -3916,7 +4988,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3916
4988
|
const next = event.target.value
|
|
3917
4989
|
setDomain(next)
|
|
3918
4990
|
if (next.normalize('NFKC').trim().toLowerCase() !== graphDomain) {
|
|
3919
|
-
setFocus(''); setMgrSelected(''); setGraph({ nodes: [], edges: [] })
|
|
4991
|
+
setGraphBranch(null); setFocus(''); setMgrSelected(''); setGraph({ nodes: [], edges: [] })
|
|
3920
4992
|
}
|
|
3921
4993
|
} }),
|
|
3922
4994
|
h('datalist', { id: 'dshm-graph-domains' },
|
|
@@ -3925,8 +4997,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3925
4997
|
h('label', { className: 'dshm-gs-search' },
|
|
3926
4998
|
h('span', { className: 'dshm-gs-search-icon', 'aria-hidden': 'true' }, '⌕'),
|
|
3927
4999
|
h('input', { ref: searchRef, className: 'dshm-gs-field', type: 'search', value: query,
|
|
3928
|
-
placeholder: t('gsSearch'), 'aria-label': t('gsSearch'),
|
|
3929
|
-
onChange: event => setQuery(event.target.value) })),
|
|
5000
|
+
placeholder: t('gsSearch'), 'aria-label': t('gsSearch'), maxLength: 256,
|
|
5001
|
+
onChange: event => { setMgrFocus(null); setQuery(event.target.value) } })),
|
|
3930
5002
|
h('div', { className: 'dshm-gs-seg', role: 'group', 'aria-label': t('gsRules') },
|
|
3931
5003
|
segBtn('edgeFilterAll', 'all', source, setSource),
|
|
3932
5004
|
segBtn('edgeFilterAuto', 'auto', source, setSource),
|
|
@@ -3940,6 +5012,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3940
5012
|
h('input', { type: 'checkbox', checked: !rulesOff.has(rule), onChange: () => toggleRule(rule) }), graphRuleText(rule, t)))
|
|
3941
5013
|
: h('p', { className: 'dshm-gs-pop-empty' }, t('gsNoRules'))) : null),
|
|
3942
5014
|
h('div', { className: 'dshm-gs-spacer' }),
|
|
5015
|
+
reviewLibrary ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsReviewScope'),
|
|
5016
|
+
'aria-label': t('gsReview'), 'aria-expanded': String(reviewOpen), onClick: () => {
|
|
5017
|
+
setReviewOpen(value => !value); setInspectorOpen(true); setView('graph')
|
|
5018
|
+
} }, t('gsReview'), h('span', { className: 'dshm-gs-count' }, pendingCount)) : null,
|
|
3943
5019
|
h('span', { className: 'dshm-gs-themechip', 'aria-pressed': 'true' },
|
|
3944
5020
|
h('i', { className: 'dshm-gs-dot' }), t('gsLocalData')),
|
|
3945
5021
|
h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsExport'), onClick: exportPng }, t('gsExport')),
|
|
@@ -4002,13 +5078,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4002
5078
|
h('div', { className: 'dshm-gs-legend-row' }, h('i', { className: 'dshm-gs-line dashed' }), t('gsLegendManual'))) : null))
|
|
4003
5079
|
|
|
4004
5080
|
const stage = h('main', { className: 'dshm-gs-stage' },
|
|
4005
|
-
h(GraphCanvas, { graph: canvasGraph, focus, onFocus:
|
|
4006
|
-
options: canvasOptions, apiRef, onZoom: setZoom, onPaint: () => minimapPaint.current?.() }),
|
|
5081
|
+
h(GraphCanvas, { graph: canvasGraph, focus, onFocus: navigateGraph, t, chrome: false,
|
|
5082
|
+
options: canvasOptions, apiRef, onZoom: setZoom, onViewport: onGraphViewport, onPaint: () => minimapPaint.current?.() }),
|
|
4007
5083
|
canvasTools,
|
|
4008
5084
|
minimap ? h(GraphStudioMinimap, { active: true, t, notifyRef: minimapPaint }) : null,
|
|
4009
5085
|
h('div', { className: `dshm-gs-toast${toast ? ' show' : ''}`, role: 'status' }, toast),
|
|
4010
5086
|
error ? h('div', { className: 'dshm-gs-toast show', role: 'alert' }, error) : null,
|
|
4011
|
-
!visibleEdges.length && nodes.length
|
|
5087
|
+
!visibleEdges.length && nodes.length && graph.mode !== 'clusters'
|
|
4012
5088
|
? h('div', { className: 'dshm-gs-empty' }, showGlobal ? t('gsGlobalEmpty') : t('gsEmpty')) : null)
|
|
4013
5089
|
|
|
4014
5090
|
const inspectorBody = selected
|
|
@@ -4041,7 +5117,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4041
5117
|
`${titles.get(edge.from) || edge.from} → ${titles.get(edge.to) || edge.to}`),
|
|
4042
5118
|
h('span', { className: 'dshm-gs-conf' }, Number(edge.confidence || 0).toFixed(2))),
|
|
4043
5119
|
edge.note ? h('p', { className: 'dshm-gs-why' }, String(edge.note)) : null,
|
|
5120
|
+
edge.evidence ? h('p', { className: 'dshm-gs-why' },
|
|
5121
|
+
[edge.evidence.surface, edge.evidence.field, Number.isInteger(edge.evidence.offset) ? '@' + edge.evidence.offset : ''].filter(Boolean).join(' · ')) : null,
|
|
4044
5122
|
h('div', { className: 'dshm-gs-meta' },
|
|
5123
|
+
h('span', { className: 'dshm-gs-tag neutral' }, String(edge.kind || 'relation')),
|
|
5124
|
+
h('span', { className: 'dshm-gs-tag neutral' }, libraryOptionLabel(libraries.find(lib => lib.id === (edge.libraryId || graphLibrary)) || { id: edge.libraryId || graphLibrary }, libraries)),
|
|
4045
5125
|
h('span', { className: `dshm-gs-tag ${edge.source === 'auto' ? 'auto' : 'manual'}` },
|
|
4046
5126
|
edge.source === 'auto' ? t('graphAutoLink') : t('edgeFilterManual')),
|
|
4047
5127
|
edge.rule ? h('span', { className: 'dshm-gs-tag neutral' }, graphRuleText(edge.rule, t)) : null))
|
|
@@ -4051,7 +5131,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4051
5131
|
h(RelationshipPanel, { call, libraryId: graphLibrary, entities, files: panelFiles, t })))
|
|
4052
5132
|
: h(React.Fragment, null,
|
|
4053
5133
|
h('div', { className: 'dshm-gs-stats' },
|
|
4054
|
-
[[t('gsNodes'), nodes
|
|
5134
|
+
[[t('gsNodes'), graphTotals.nodes], [t('gsEdges'), graphTotals.edges],
|
|
4055
5135
|
[t('gsVisible'), visibleEdges.length], [t('gsAutoEdges'), autoCount],
|
|
4056
5136
|
[t('gsPending'), pendingCount]].map(([label, value]) =>
|
|
4057
5137
|
h('div', { key: label, className: 'dshm-gs-stat' }, h('b', null, String(value)), h('span', null, label)))),
|
|
@@ -4063,7 +5143,15 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4063
5143
|
h('h2', null, t('gsInspector')),
|
|
4064
5144
|
h('span', { className: 'dshm-gs-count' }, selected ? String(selected.title || selected.id) : t('gsNoSelection'))),
|
|
4065
5145
|
h('p', null, t('gsInspectorHint'))),
|
|
4066
|
-
h('div', { className: 'dshm-gs-ins-body' },
|
|
5146
|
+
h('div', { className: 'dshm-gs-ins-body' },
|
|
5147
|
+
reviewLibrary ? h(GraphActionsPanel, { key: reviewLibrary, call, libraryId: reviewLibrary,
|
|
5148
|
+
sessionId: mergedScope ? null : sessionId, nodes, edges: focusEdges, selected,
|
|
5149
|
+
refreshKey: beat + ':' + reloadKey, t, open: reviewOpen, onSummary: setReviewSummary, onChanged: reviewChanged,
|
|
5150
|
+
libraryControl: mergedScope ? h('label', { className: 'dshm-gs-action-fields' }, t('gsReviewLibrary'),
|
|
5151
|
+
h('select', { className: 'dshm-gs-field', value: reviewLibrary, 'aria-label': t('gsReviewLibrary'),
|
|
5152
|
+
onChange: event => setReviewLib(event.target.value) }, libraries.map(lib => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries)))))
|
|
5153
|
+
: h('p', null, libraryOptionLabel(libraries.find(lib => lib.id === reviewLibrary) || { id: reviewLibrary }, libraries)) }) : null,
|
|
5154
|
+
inspectorBody))
|
|
4067
5155
|
|
|
4068
5156
|
// 管理视图的「连接分支」侧栏:可拖动分隔条调宽度,复刻 HTML 的 br-resizer。
|
|
4069
5157
|
const startBranchResize = event => {
|
|
@@ -4078,24 +5166,26 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4078
5166
|
window.addEventListener?.('pointerup', onUp)
|
|
4079
5167
|
}
|
|
4080
5168
|
const branchId = mgrSelected || focus
|
|
4081
|
-
const
|
|
4082
|
-
const
|
|
5169
|
+
const branchNodes = view === 'manage' ? managerNodes : nodes
|
|
5170
|
+
const branchEdges = view === 'manage' ? management.edges : edges
|
|
5171
|
+
const branchNode = branchNodes.find(node => node.id === branchId) || null
|
|
5172
|
+
const tier1 = branchId ? branchEdges.filter(edge => edge.from === branchId || edge.to === branchId)
|
|
4083
5173
|
.map(edge => ({ id: edge.from === branchId ? edge.to : edge.from, edge })) : []
|
|
4084
5174
|
const tier1Ids = new Set(tier1.map(item => item.id))
|
|
4085
|
-
const tier2 = branchId ?
|
|
5175
|
+
const tier2 = branchId ? branchEdges.filter(edge => tier1Ids.has(edge.from) || tier1Ids.has(edge.to))
|
|
4086
5176
|
.map(edge => ({ id: tier1Ids.has(edge.from) ? edge.to : edge.from, edge }))
|
|
4087
5177
|
.filter(item => item.id !== branchId && !tier1Ids.has(item.id)) : []
|
|
4088
5178
|
const branchRow = item => {
|
|
4089
|
-
const other =
|
|
5179
|
+
const other = branchNodes.find(node => node.id === item.id) || { kind: 'memory' }
|
|
4090
5180
|
return h('div', { key: `${item.id}:${item.edge.from}:${item.edge.to}`, className: 'dshm-gs-br-item' },
|
|
4091
5181
|
h('i', { className: `dshm-gs-br-dot dshm-gs-c-${gsKind(other)}` }),
|
|
4092
5182
|
h('div', { className: 'dshm-gs-br-col' },
|
|
4093
|
-
h('div', { className: 'dshm-gs-br-nm', onClick: () => { setFocus(item.id); setView('graph') } },
|
|
4094
|
-
titles.get(item.id) || item.id),
|
|
5183
|
+
h('div', { className: 'dshm-gs-br-nm', onClick: () => { if (view === 'manage') locateManaged(other); else { setFocus(item.id); setView('graph') } } },
|
|
5184
|
+
other.title || titles.get(item.id) || item.id),
|
|
4095
5185
|
h('div', { className: 'dshm-gs-br-meta' },
|
|
4096
5186
|
`${item.edge.kind || 'link'} · ${item.edge.source === 'auto' ? t('graphAutoLink') : t('edgeFilterManual')}`)),
|
|
4097
5187
|
h('button', { type: 'button', className: 'dshm-gs-mini', title: t('gsLocate'),
|
|
4098
|
-
onClick: () => { setFocus(item.id); setView('graph'); setInspectorOpen(true) } }, t('gsLocate')))
|
|
5188
|
+
onClick: () => { if (view === 'manage') locateManaged(other); else { setFocus(item.id); setView('graph'); setInspectorOpen(true) } } }, t('gsLocate')))
|
|
4099
5189
|
}
|
|
4100
5190
|
const branchPanel = h('aside', { className: 'dshm-gs-branch' },
|
|
4101
5191
|
h('div', { className: 'dshm-gs-br-head' },
|
|
@@ -4106,7 +5196,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4106
5196
|
h('div', { className: `dshm-gs-glyph dshm-gs-c-${gsKind(branchNode)}` }, '◆'),
|
|
4107
5197
|
h('div', { className: 'dshm-gs-hero-t' },
|
|
4108
5198
|
h('b', null, String(branchNode.title || branchNode.id)),
|
|
4109
|
-
h('span', null, `${t('gsDegree')} ${degree.get(branchId)
|
|
5199
|
+
h('span', null, `${t('gsDegree')} ${branchNode.degree ?? degree.get(branchId) ?? 0}`))),
|
|
4110
5200
|
h('div', { className: 'dshm-gs-br-sec' },
|
|
4111
5201
|
h('h4', null, `${t('gsTier1')} (${tier1.length})`),
|
|
4112
5202
|
tier1.slice(0, 30).map(branchRow)),
|
|
@@ -4117,11 +5207,23 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4117
5207
|
|
|
4118
5208
|
const manager = h('section', { className: 'dshm-gs-manager' },
|
|
4119
5209
|
h('div', { className: 'dshm-gs-mgr-head' },
|
|
4120
|
-
h('
|
|
5210
|
+
h('select', { className: 'dshm-gs-field', value: managementLibrary, disabled: !libraries.length,
|
|
5211
|
+
title: t('gsManagerScope'), 'aria-label': t('gsManagerScope'), onChange: event => {
|
|
5212
|
+
setMgrLib(event.target.value); setMgrSelected(''); setMgrFocus(null); setMgrArmed(''); cancelEdit()
|
|
5213
|
+
} },
|
|
5214
|
+
h('option', { value: 'all' }, t('gsAllLibraries')),
|
|
5215
|
+
libraries
|
|
5216
|
+
.map(lib => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries)))),
|
|
5217
|
+
h('label', { className: 'dshm-gs-btn', title: t('gsIncludeOrphans') },
|
|
5218
|
+
h('input', { type: 'checkbox', checked: mgrOrphans, 'aria-label': t('gsIncludeOrphans'), onChange: event => {
|
|
5219
|
+
setMgrOrphans(event.target.checked); setMgrFocus(null); setMgrSelected(''); setMgrArmed('')
|
|
5220
|
+
} }), t('gsIncludeOrphans')),
|
|
5221
|
+
h('span', { className: 'dshm-gs-count' }, t('gsManagerPage').replace('{n}', String(managerNodes.length))
|
|
5222
|
+
.replace('{total}', String(management.total ?? '—'))),
|
|
4121
5223
|
h('select', { className: 'dshm-gs-field', value: mgrKind, 'aria-label': t('gsAllKinds'),
|
|
4122
5224
|
onChange: event => setMgrKind(event.target.value) },
|
|
4123
5225
|
h('option', { value: '' }, t('gsAllKinds')),
|
|
4124
|
-
['memory', 'person', 'place', 'thing', 'global'].map(kind =>
|
|
5226
|
+
['memory', 'person', 'place', 'thing', 'org', 'global'].map(kind =>
|
|
4125
5227
|
h('option', { key: kind, value: kind }, kind))),
|
|
4126
5228
|
h('select', { className: 'dshm-gs-field', value: mgrStatus, 'aria-label': t('gsAllStatus'),
|
|
4127
5229
|
onChange: event => setMgrStatus(event.target.value) },
|
|
@@ -4133,19 +5235,19 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4133
5235
|
[['degree', 'gsDegree'], ['strength', 'gsStrength'], ['title', 'gsTitle'], ['id', 'gsNodes']].map(([value, label]) =>
|
|
4134
5236
|
h('option', { key: value, value }, t(label)))),
|
|
4135
5237
|
writable ? h('button', { type: 'button', className: `dshm-gs-btn${mgrArmed === removeKey ? ' is-danger' : ''}`,
|
|
4136
|
-
title: t('gsRemoveNodeHint'), 'aria-label': t('gsRemoveNode'), disabled: !
|
|
5238
|
+
title: t('gsRemoveNodeHint'), 'aria-label': t('gsRemoveNode'), disabled: !selectedManagerNode || mgrBusy || management.loading,
|
|
4137
5239
|
onClick: () => { void removeSelected() } },
|
|
4138
5240
|
mgrArmed === removeKey ? (mgrDeleteRefused === mgrSelected ? t('relationConfirm') + '!' : t('confirmDelete')) : t('gsRemoveNode')) : null,
|
|
4139
5241
|
writable ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsEditNode'),
|
|
4140
|
-
'aria-label': t('gsEditNode'), disabled: !
|
|
5242
|
+
'aria-label': t('gsEditNode'), disabled: !selectedManagerNode || mgrBusy || editBusy || management.loading,
|
|
4141
5243
|
onClick: () => { void editNode() } }, t('gsEditNode')) : null,
|
|
4142
5244
|
writable ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsAddNode'),
|
|
4143
|
-
'aria-expanded': String(addOpen), onClick: () => {
|
|
5245
|
+
disabled: !managementLibrary, 'aria-expanded': String(addOpen), onClick: () => { cancelEdit(); setAddOpen(value => !value) } }, t('gsAddNode')) : null,
|
|
4144
5246
|
h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsExport'), onClick: exportPng }, t('gsExport'))),
|
|
4145
5247
|
addOpen && writable ? h('div', { className: 'dshm-gs-mgr-add' },
|
|
4146
5248
|
h('select', { className: 'dshm-gs-field', value: addTargetLib, title: t('gsAddLibrary'), 'aria-label': t('gsAddLibrary'),
|
|
4147
|
-
onChange: event => setAddLib(event.target.value) },
|
|
4148
|
-
|
|
5249
|
+
onChange: event => setAddLib(event.target.value), disabled: managementLibrary !== 'all' },
|
|
5250
|
+
libraries
|
|
4149
5251
|
.map(lib => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries)))),
|
|
4150
5252
|
h('div', { className: 'dshm-gs-seg', role: 'group', 'aria-label': t('gsAddNode') },
|
|
4151
5253
|
h('button', { type: 'button', 'aria-pressed': String(draft.type === 'memory'),
|
|
@@ -4171,7 +5273,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4171
5273
|
? h('textarea', { className: 'dshm-gs-field', value: draft.content, placeholder: t('memoryContent'), 'aria-label': t('memoryContent'),
|
|
4172
5274
|
onChange: event => setDraft(value => ({ ...value, content: event.target.value })) })
|
|
4173
5275
|
: null) : null,
|
|
4174
|
-
editOpen && editDraft ? h('div', { className: 'dshm-gs-mgr-add' },
|
|
5276
|
+
editOpen && editDraft?.ownerKey === editOwnerKey ? h('div', { className: 'dshm-gs-mgr-add' },
|
|
4175
5277
|
h('select', { className: 'dshm-gs-field', value: editDraft.libraryId, disabled: true, title: t('gsAddLibrary'), 'aria-label': t('gsAddLibrary') },
|
|
4176
5278
|
h('option', { value: editDraft.libraryId },
|
|
4177
5279
|
libraryOptionLabel(libraries.find(lib => lib.id === editDraft.libraryId) || { id: editDraft.libraryId }, libraries))),
|
|
@@ -4191,53 +5293,72 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4191
5293
|
onChange: event => setEditDraft(value => ({ ...value, aliases: event.target.value })) }),
|
|
4192
5294
|
h('div', { className: 'dshm-gs-add-actions' },
|
|
4193
5295
|
h('button', { type: 'button', className: 'dshm-gs-btn', disabled: !canSave, onClick: () => { void saveEdit() } }, t('save')),
|
|
4194
|
-
h('button', { type: 'button', className: 'dshm-gs-btn', onClick:
|
|
5296
|
+
h('button', { type: 'button', className: 'dshm-gs-btn', onClick: cancelEdit }, t('cancelDelete'))),
|
|
4195
5297
|
editDraft.kind === 'memory'
|
|
4196
5298
|
? h('textarea', { className: 'dshm-gs-field', value: editDraft.content, placeholder: t('memoryContent'), 'aria-label': t('memoryContent'),
|
|
4197
5299
|
onChange: event => setEditDraft(value => ({ ...value, content: event.target.value })) })
|
|
4198
5300
|
: null) : null,
|
|
4199
5301
|
h('div', { className: 'dshm-gs-mgr-body', style: { '--gs-br-w': `${branchWidth}px` } },
|
|
4200
5302
|
h('div', { className: 'dshm-gs-mgr-scroll' },
|
|
5303
|
+
mgrOrphans ? h('div', { className: 'dshm-gs-mgr-focus', role: 'note' }, t('orphanPruneHint')) : null,
|
|
5304
|
+
managedFocus ? h('div', { className: 'dshm-gs-mgr-focus', role: 'status' }, t('gsManagerFocus')
|
|
5305
|
+
.replace('{library}', mgrFocus.libraryId || managementLibrary).replace('{id}', managedFocus)) : null,
|
|
4201
5306
|
h('div', { className: 'dshm-gs-mgr-thead' },
|
|
4202
5307
|
h('span', null, ''), h('span', null, 'ID'), h('span', null, t('gsTitle')),
|
|
4203
5308
|
h('span', null, t('gsKind')), h('span', null, t('gsStatus')), h('span', null, t('gsLayer')),
|
|
4204
5309
|
h('span', { className: 'num' }, t('gsDegree')), h('span', { className: 'num' }, t('gsStrength')),
|
|
4205
5310
|
h('span', null, t('gsAction'))),
|
|
4206
|
-
|
|
5311
|
+
management.error ? h('div', { className: 'dshm-gs-mgr-empty', role: 'alert' }, management.error) : null,
|
|
5312
|
+
manageRows.length ? manageRows.map(node => h('div', {
|
|
4207
5313
|
key: node.id, className: `dshm-gs-mgr-row${mgrSelected === node.id ? ' sel' : ''}`,
|
|
4208
|
-
onClick: () => { setMgrSelected(node.id)
|
|
5314
|
+
onClick: () => { cancelEdit(); setMgrSelected(node.id) },
|
|
4209
5315
|
},
|
|
4210
5316
|
h('span', { className: 'dshm-gs-mgr-dot' }, h('i', { className: `dshm-gs-swatch dshm-gs-c-${gsKind(node)}` })),
|
|
4211
5317
|
h('span', { className: 'dshm-gs-mgr-id' }, String(node.rawId || node.id).slice(0, 8)),
|
|
4212
|
-
h('span', { className: 'dshm-gs-mgr-title' }, String(node.title || node.id)
|
|
5318
|
+
h('span', { className: 'dshm-gs-mgr-title' }, String(node.title || node.rawId || node.id),
|
|
5319
|
+
managementLibrary === 'all' ? h('small', { className: 'dshm-gs-mgr-library' },
|
|
5320
|
+
libraryOptionLabel(libraries.find(lib => lib.id === node.libraryId) || { id: node.libraryId }, libraries)) : null),
|
|
4213
5321
|
h('span', null, String(node.kind || 'memory')),
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
5322
|
+
h('span', null, node.kind === 'memory' ? enumText(t, STATUS_LABELS, node.status || 'active')
|
|
5323
|
+
: node.status === 'provisional' ? t('gsPending')
|
|
5324
|
+
: node.status === 'confirmed' ? t('gsConfirmed') : node.status === 'archived' ? t('stArchived') : '—'),
|
|
4217
5325
|
h('span', null, node.layer ? enumText(t, LAYER_LABELS, node.layer) : '—'),
|
|
4218
|
-
h('span', { className: 'num' }, String(
|
|
5326
|
+
h('span', { className: 'num' }, String(node.degree || 0)),
|
|
4219
5327
|
h('span', { className: 'num' }, Number(node.strength || 0).toFixed(2)),
|
|
4220
5328
|
h('span', { className: 'dshm-gs-mgr-ops' },
|
|
4221
5329
|
h('button', { type: 'button', className: 'dshm-gs-mini', title: t('gsViewBranch'),
|
|
4222
5330
|
onClick: event => { event.stopPropagation(); setMgrSelected(node.id); setView('manage') } }, t('gsViewBranch')),
|
|
4223
5331
|
h('button', { type: 'button', className: 'dshm-gs-mini', title: t('gsLocate'),
|
|
4224
|
-
onClick: event => { event.stopPropagation();
|
|
4225
|
-
: h('div', { className: 'dshm-gs-mgr-empty' }, t('gsNoMatch'))),
|
|
5332
|
+
onClick: event => { event.stopPropagation(); locateManaged(node) } }, t('gsLocate')))))
|
|
5333
|
+
: h('div', { className: 'dshm-gs-mgr-empty' }, t(!managementLibrary ? 'gsManagerChoose' : management.loading ? 'loading' : 'gsNoMatch'))),
|
|
4226
5334
|
h('button', { type: 'button', className: 'dshm-gs-br-resizer', title: t('gsResize'),
|
|
4227
5335
|
'aria-label': t('gsResize'), onPointerDown: startBranchResize }),
|
|
4228
5336
|
branchPanel),
|
|
4229
5337
|
h('div', { className: 'dshm-gs-mgr-foot' },
|
|
4230
|
-
h('span', null, mgrSelected || '—'),
|
|
5338
|
+
h('span', null, selectedManagerNode?.rawId || mgrSelected || '—'),
|
|
5339
|
+
managedFocus ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsManagerBack'),
|
|
5340
|
+
onClick: () => { setMgrFocus(null); setMgrSelected(''); cancelEdit() } }, t('gsManagerBack')) : null,
|
|
5341
|
+
h('button', { type: 'button', className: 'dshm-gs-btn', title: t('refresh'), disabled: !managementLibrary || management.loading,
|
|
5342
|
+
onClick: () => { cancelEdit(); setMgrArmed(''); management.refresh() } }, t('refresh')),
|
|
5343
|
+
!managedFocus ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsManagerPrevious'),
|
|
5344
|
+
disabled: management.loading || !management.offset, onClick: () => { cancelEdit(); setMgrSelected(''); setMgrArmed(''); management.previous() } }, t('gsManagerPrevious')) : null,
|
|
5345
|
+
!managedFocus ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('gsManagerNext'),
|
|
5346
|
+
disabled: management.loading || !Number.isInteger(management.nextOffset),
|
|
5347
|
+
onClick: () => { cancelEdit(); setMgrSelected(''); setMgrArmed(''); management.next() } }, t('gsManagerNext')) : null,
|
|
4231
5348
|
h('div', { className: 'dshm-gs-spacer' }),
|
|
4232
|
-
h('button', { type: 'button', className: 'dshm-gs-btn', disabled: !
|
|
4233
|
-
onClick: () =>
|
|
5349
|
+
h('button', { type: 'button', className: 'dshm-gs-btn', disabled: !selectedManagerNode,
|
|
5350
|
+
onClick: () => locateManaged(selectedManagerNode) }, t('gsLocate')),
|
|
4234
5351
|
h('button', { type: 'button', className: 'dshm-gs-btn primary', onClick: () => setView('graph') }, t('graphView'))))
|
|
4235
5352
|
|
|
4236
5353
|
const status = h('footer', { className: 'dshm-gs-status' },
|
|
5354
|
+
overviewControl,
|
|
5355
|
+
graph.overview ? h('span', null, t(graph.mode === 'clusters' ? 'gsClusters' : 'memoryLoaded'), ' ', String(nodes.length)) : null,
|
|
5356
|
+
Number.isInteger(graph.nextOffset) ? h('button', { type: 'button', className: 'dshm-gs-btn', title: t('browseLoadMore'),
|
|
5357
|
+
onClick: () => setGraphCursor({ key: graphKey, offset: graph.nextOffset }) }, t('browseLoadMore')) : null,
|
|
4237
5358
|
h('span', { className: 'dshm-gs-live' }, h('i'), t('gsLocalData')),
|
|
4238
5359
|
h('span', { className: 'dshm-gs-status-sep' }),
|
|
4239
|
-
h('span', null, t('gsNodes'), ' ', h('b', null, String(nodes
|
|
4240
|
-
h('span', null, t('gsEdges'), ' ', h('b', null, String(edges
|
|
5360
|
+
h('span', null, t('gsNodes'), ' ', h('b', null, String(graphTotals.nodes))),
|
|
5361
|
+
h('span', null, t('gsEdges'), ' ', h('b', null, String(graphTotals.edges))),
|
|
4241
5362
|
h('span', null, t('gsVisible'), ' ', h('b', null, String(visibleEdges.length))),
|
|
4242
5363
|
h('span', null, t('gsAutoEdges'), ' ', h('b', null, String(autoCount))),
|
|
4243
5364
|
h('span', null, t('gsPending'), ' ', h('b', null, String(pendingCount))),
|
|
@@ -4247,6 +5368,237 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4247
5368
|
return h('div', { className: `dshm-gs${inspectorOpen ? '' : ' is-collapsed'}${view === 'manage' ? ' is-manage' : ''}${minimap ? ' show-minimap' : ''}` },
|
|
4248
5369
|
topbar, rail, stage, inspector, manager, status)
|
|
4249
5370
|
}
|
|
5371
|
+
function GraphActionsPanel({ call, libraryId, sessionId, nodes = [], edges = [], selected,
|
|
5372
|
+
refreshKey, t, open, libraryControl, onSummary, onChanged }) {
|
|
5373
|
+
const [review, setReview] = React.useState(null)
|
|
5374
|
+
const [retry, setRetry] = React.useState(0)
|
|
5375
|
+
const [scanCursor, setScanCursor] = React.useState({ key: '', cursor: null })
|
|
5376
|
+
const [armed, setArmed] = React.useState('')
|
|
5377
|
+
const [busy, setBusy] = React.useState(false)
|
|
5378
|
+
const [notice, setNotice] = React.useState('')
|
|
5379
|
+
const [limit, setLimit] = React.useState(20)
|
|
5380
|
+
const [kinds, setKinds] = React.useState({})
|
|
5381
|
+
const [link, setLink] = React.useState({ fromId: '', toId: '', kind: 'relation', note: '', confidence: .7 })
|
|
5382
|
+
const [merge, setMerge] = React.useState({ sourceId: '', targetId: '' })
|
|
5383
|
+
const ownerRef = React.useRef(null)
|
|
5384
|
+
const identity = JSON.stringify([libraryId, sessionId])
|
|
5385
|
+
if (ownerRef.current?.identity !== identity) {
|
|
5386
|
+
if (ownerRef.current) ownerRef.current.alive = false
|
|
5387
|
+
ownerRef.current = { identity, alive: true, request: 0, busy: false }
|
|
5388
|
+
}
|
|
5389
|
+
const owner = ownerRef.current
|
|
5390
|
+
const current = () => owner.alive && ownerRef.current === owner
|
|
5391
|
+
const credentials = sessionId ? { sessionId } : {}
|
|
5392
|
+
const scanKey = JSON.stringify([identity, refreshKey, retry])
|
|
5393
|
+
const cursor = scanCursor.key === scanKey ? scanCursor.cursor : null
|
|
5394
|
+
React.useEffect(() => {
|
|
5395
|
+
owner.alive = true
|
|
5396
|
+
return () => { owner.alive = false; owner.request++ }
|
|
5397
|
+
}, [identity])
|
|
5398
|
+
React.useEffect(() => {
|
|
5399
|
+
const request = ++owner.request
|
|
5400
|
+
if (!open || review?.key === scanKey && review.cursor === cursor && !review.loading) return undefined
|
|
5401
|
+
const previous = review?.key === scanKey ? review : null
|
|
5402
|
+
setReview({ ...previous, key: scanKey, cursor, loading: true })
|
|
5403
|
+
void Promise.allSettled([
|
|
5404
|
+
call('suggestEntityMerges', { libraryId, ...credentials, ...(cursor ? { cursor } : {}) }),
|
|
5405
|
+
cursor && previous?.anchorReady ? Promise.resolve(previous.anchor) : call('getAnchorCandidates', { libraryId, ...credentials }),
|
|
5406
|
+
]).then(([merges, anchors]) => {
|
|
5407
|
+
if (!current() || owner.request !== request) return
|
|
5408
|
+
if (merges.status === 'rejected' && cursor) {
|
|
5409
|
+
setArmed(''); setReview(null); setScanCursor({ key: scanKey, cursor: null })
|
|
5410
|
+
setNotice(t('gsReviewScanReset') + ': ' + String(merges.reason?.code || merges.reason?.message || merges.reason))
|
|
5411
|
+
return
|
|
5412
|
+
}
|
|
5413
|
+
setReview({ key: scanKey, cursor, loading: false, mergeReady: merges.status === 'fulfilled',
|
|
5414
|
+
merges: merges.status === 'fulfilled' ? merges.value?.items || [] : [],
|
|
5415
|
+
mergeTotal: merges.status === 'fulfilled' && Number.isSafeInteger(merges.value?.total) ? merges.value.total : null,
|
|
5416
|
+
totalExact: merges.status === 'fulfilled' && merges.value?.totalExact !== false && merges.value?.scanComplete !== false
|
|
5417
|
+
&& Number.isSafeInteger(merges.value?.total),
|
|
5418
|
+
discoveredTotal: merges.status === 'fulfilled' ? (cursor ? previous?.discoveredTotal || 0 : 0)
|
|
5419
|
+
+ (Number.isSafeInteger(merges.value?.discoveredTotal) ? merges.value.discoveredTotal : merges.value?.items?.length || 0) : null,
|
|
5420
|
+
scanComplete: merges.status === 'fulfilled' && merges.value?.scanComplete !== false,
|
|
5421
|
+
nextCursor: merges.status === 'fulfilled' ? merges.value?.nextCursor || null : null,
|
|
5422
|
+
scannedPairs: merges.status === 'fulfilled' ? merges.value?.scannedPairs : null,
|
|
5423
|
+
pairSpace: merges.status === 'fulfilled' ? merges.value?.pairSpace : null,
|
|
5424
|
+
mergeTruncated: merges.status === 'fulfilled' && merges.value?.truncated === true,
|
|
5425
|
+
mergeLimit: merges.status === 'fulfilled' && Number.isSafeInteger(merges.value?.limit) ? merges.value.limit : 20,
|
|
5426
|
+
rejected: merges.status === 'fulfilled' ? merges.value?.rejectedItems || [] : [],
|
|
5427
|
+
rejectedTotal: merges.status === 'fulfilled' && Number.isSafeInteger(merges.value?.rejectedTotal) ? merges.value.rejectedTotal : 0,
|
|
5428
|
+
anchor: anchors.status === 'fulfilled' ? anchors.value : null, anchorReady: anchors.status === 'fulfilled',
|
|
5429
|
+
incomplete: merges.status === 'rejected' || anchors.status === 'rejected' })
|
|
5430
|
+
})
|
|
5431
|
+
return () => { if (owner.request === request) owner.request++ }
|
|
5432
|
+
}, [call, scanKey, cursor, open])
|
|
5433
|
+
React.useEffect(() => {
|
|
5434
|
+
if (!armed) return undefined
|
|
5435
|
+
const timer = setTimeout(() => setArmed(''), 2500)
|
|
5436
|
+
return () => clearTimeout(timer)
|
|
5437
|
+
}, [armed])
|
|
5438
|
+
React.useEffect(() => {
|
|
5439
|
+
if (!notice) return undefined
|
|
5440
|
+
const timer = setTimeout(() => setNotice(''), 9000)
|
|
5441
|
+
return () => clearTimeout(timer)
|
|
5442
|
+
}, [notice])
|
|
5443
|
+
const value = review?.key === scanKey ? review : null
|
|
5444
|
+
const reading = !!open && (!value || value.loading || value.cursor !== cursor)
|
|
5445
|
+
const provisional = value?.anchor?.entities?.provisional || []
|
|
5446
|
+
const candidates = [...(value?.anchor?.tiers?.tier1 || []), ...(value?.anchor?.tiers?.tier2 || [])]
|
|
5447
|
+
.filter(row => !row.entityId && row.entityStatus !== 'confirmed' && row.entityStatus !== 'archived')
|
|
5448
|
+
const pairs = value?.merges || []
|
|
5449
|
+
const rejected = value?.rejected || []
|
|
5450
|
+
const pairTotal = value?.totalExact ? value.mergeTotal : value?.discoveredTotal ?? pairs.length
|
|
5451
|
+
const pairTruncated = value?.mergeTruncated || (value?.mergeTotal == null && pairs.length >= (value?.mergeLimit || 20))
|
|
5452
|
+
const countCapped = !value?.totalExact || !value?.anchorReady
|
|
5453
|
+
const names = new Map([
|
|
5454
|
+
...nodes.filter(node => (!node.libraryId || node.libraryId === libraryId) && node.kind !== 'cluster')
|
|
5455
|
+
.map(node => [node.rawId || node.id, node.title || node.id]),
|
|
5456
|
+
...(value?.anchor?.entities?.confirmed || []).map(entity => [entity.id, entity.name]),
|
|
5457
|
+
...provisional.map(entity => [entity.id, entity.name]),
|
|
5458
|
+
])
|
|
5459
|
+
// Group only the server's suggested pairs; grouping never chooses or executes a merge.
|
|
5460
|
+
const groups = []
|
|
5461
|
+
for (const pair of pairs) {
|
|
5462
|
+
const matching = groups.filter(group => group.ids.has(pair.sourceId) || group.ids.has(pair.targetId))
|
|
5463
|
+
const group = matching[0] || { ids: new Set(), pairs: [] }
|
|
5464
|
+
if (!matching.length) groups.push(group)
|
|
5465
|
+
for (const other of matching.slice(1)) {
|
|
5466
|
+
for (const id of other.ids) group.ids.add(id)
|
|
5467
|
+
group.pairs.push(...other.pairs)
|
|
5468
|
+
groups.splice(groups.indexOf(other), 1)
|
|
5469
|
+
}
|
|
5470
|
+
group.ids.add(pair.sourceId); group.ids.add(pair.targetId); group.pairs.push(pair)
|
|
5471
|
+
}
|
|
5472
|
+
const pending = value?.mergeReady || value?.anchorReady ? provisional.length + candidates.length + pairTotal : null
|
|
5473
|
+
const pendingLabel = pending == null ? t('gsReviewUnchecked') : countCapped
|
|
5474
|
+
? t('gsReviewPartialCount').replace('{n}', String(pending)) : String(pending)
|
|
5475
|
+
const summaryKey = JSON.stringify([identity, pending, reading, countCapped, !!value?.incomplete])
|
|
5476
|
+
React.useEffect(() => {
|
|
5477
|
+
onSummary?.({ libraryId, pending, loading: reading, capped: countCapped, incomplete: !value || value.incomplete })
|
|
5478
|
+
}, [summaryKey])
|
|
5479
|
+
const actionKey = (method, payload) => JSON.stringify([identity, method, payload])
|
|
5480
|
+
const run = async (method, payload, receipt) => {
|
|
5481
|
+
if (!current() || owner.busy || reading) return
|
|
5482
|
+
const key = actionKey(method, payload)
|
|
5483
|
+
if (armed !== key) { setArmed(key); return }
|
|
5484
|
+
owner.busy = true; setBusy(true); setArmed('')
|
|
5485
|
+
try {
|
|
5486
|
+
const result = await call(method, { libraryId, ...credentials, ...payload })
|
|
5487
|
+
if (method === 'setEntityMergeRejection' && (result?.ok !== true || result.rejected !== payload.rejected)) throw new Error(t('scopeNotApplied'))
|
|
5488
|
+
notifyMemoryWrite(method === 'updateMemory' ? 'memory' : 'relation', libraryId)
|
|
5489
|
+
if (!current()) return
|
|
5490
|
+
setNotice(receipt(result)); setRetry(number => number + 1); onChanged?.()
|
|
5491
|
+
} catch (error) {
|
|
5492
|
+
if (current()) {
|
|
5493
|
+
const message = String(error?.message || error)
|
|
5494
|
+
const changed = error?.code === 'ENTITY_MERGE_CANDIDATE_CHANGED' || message.includes('ENTITY_MERGE_CANDIDATE_CHANGED')
|
|
5495
|
+
setNotice(changed && !message.includes('ENTITY_MERGE_CANDIDATE_CHANGED') ? 'ENTITY_MERGE_CANDIDATE_CHANGED: ' + message : message)
|
|
5496
|
+
if (method === 'setEntityMergeRejection' || method === 'mergeEntities' && changed) setRetry(number => number + 1)
|
|
5497
|
+
}
|
|
5498
|
+
} finally {
|
|
5499
|
+
owner.busy = false
|
|
5500
|
+
if (current()) setBusy(false)
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
const action = (label, method, payload, receipt, disabled = false, title = label) => h(Button, {
|
|
5504
|
+
title: t(title), disabled: busy || reading || disabled, onClick: () => void run(method, payload, receipt),
|
|
5505
|
+
}, armed === actionKey(method, payload) ? t('gsConfirmAction') : t(label))
|
|
5506
|
+
const mergeAction = pair => action('entityMergeAction', 'mergeEntities', { targetId: pair.targetId, sourceIds: [pair.sourceId],
|
|
5507
|
+
...(pair.reviewToken ? { reviewToken: pair.reviewToken } : {}) }, result => {
|
|
5508
|
+
let message = t('entityMergeDone').replace('{from}', names.get(pair.sourceId) || pair.sourceId)
|
|
5509
|
+
.replace('{to}', names.get(pair.targetId) || pair.targetId).replace('{links}', String(result?.remappedLinks ?? 0))
|
|
5510
|
+
.replace('{aliases}', String(result?.aliases?.length ?? 0))
|
|
5511
|
+
if (result?.droppedAliases?.length) message += ' ' + t('entityMergeDropped').replace('{n}', String(result.droppedAliases.length))
|
|
5512
|
+
if (result?.relationships?.conflicts?.length) message += ' ' + t('entityMergeConflict').replace('{n}', String(result.relationships.conflicts.length))
|
|
5513
|
+
return message
|
|
5514
|
+
}, !pair.sourceId || !pair.targetId || pair.sourceId === pair.targetId, 'entityMergeHint')
|
|
5515
|
+
const rejectAction = (pair, rejected) => action(rejected ? 'gsRejectMerge' : 'gsRestoreMerge', 'setEntityMergeRejection', {
|
|
5516
|
+
sourceId: pair.sourceId, targetId: pair.targetId, reviewToken: pair.reviewToken, rejected, confirmed: true,
|
|
5517
|
+
}, () => t(rejected ? 'gsMergeRejected' : 'gsMergeRestored'), !/^[a-f0-9]{64}$/i.test(pair.reviewToken || ''))
|
|
5518
|
+
const field = (label, element) => h('label', null, h('span', null, t(label)), element)
|
|
5519
|
+
const input = (label, inputValue, onChange, props = {}) => field(label,
|
|
5520
|
+
h('input', { className: 'dshm-gs-field', value: inputValue, 'aria-label': t(label), onChange: event => onChange(event.target.value), ...props }))
|
|
5521
|
+
const rawSelected = selected && (!selected.libraryId || selected.libraryId === libraryId) ? selected : null
|
|
5522
|
+
const visibleEdges = edges.filter(edge => !edge.libraryId || edge.libraryId === libraryId)
|
|
5523
|
+
const rawId = id => nodes.find(node => node.id === id)?.rawId || id
|
|
5524
|
+
if (!open) return null
|
|
5525
|
+
return h('section', { className: 'dshm-gs-actions', 'aria-label': t('gsReview') },
|
|
5526
|
+
h('h3', null, t('gsReview')),
|
|
5527
|
+
libraryControl,
|
|
5528
|
+
h('p', null, t('gsReviewScope')),
|
|
5529
|
+
h('div', { className: 'dshm-gs-action-row' },
|
|
5530
|
+
h('strong', null, t('gsReviewPending'), ' ', pendingLabel),
|
|
5531
|
+
h(Button, { title: t('gsReviewRefresh'), disabled: busy || reading, onClick: () => { setArmed(''); setRetry(number => number + 1) } }, t('gsReviewRestart'))),
|
|
5532
|
+
value?.incomplete ? h('p', { role: 'alert' }, t('gsReviewUnavailable')) : null,
|
|
5533
|
+
notice ? h('p', { className: 'dshm-gs-action-result', role: 'status' }, notice) : null,
|
|
5534
|
+
h('details', { open: true }, h('summary', null, t('gsReviewGroups'), ' ', String(groups.length), pairTruncated ? '+' : ''),
|
|
5535
|
+
h('p', null, t('entityMergeHint')), h('p', null, t('gsReviewLimit').replace('{limit}', String(value?.mergeLimit || 20))),
|
|
5536
|
+
h('p', null, t(value?.totalExact ? 'gsReviewShowing' : 'gsReviewDiscovered').replace('{shown}', String(pairs.length)).replace('{total}', String(pairTotal))),
|
|
5537
|
+
Number.isSafeInteger(value?.scannedPairs) && Number.isSafeInteger(value?.pairSpace)
|
|
5538
|
+
? h('p', null, t('gsReviewScanProgress').replace('{scanned}', String(value.scannedPairs)).replace('{space}', String(value.pairSpace))) : null,
|
|
5539
|
+
value?.mergeReady && !value.totalExact ? h('p', null, t(value.scanComplete ? 'gsReviewScanComplete' : 'gsReviewScanIncomplete')) : null,
|
|
5540
|
+
value?.nextCursor ? h(Button, { title: t('gsReviewContinue'), disabled: busy || reading, onClick: () => {
|
|
5541
|
+
setArmed(''); setScanCursor({ key: scanKey, cursor: value.nextCursor })
|
|
5542
|
+
} }, t('gsReviewContinue')) : null,
|
|
5543
|
+
groups.map(group => h('div', { className: 'dshm-gs-sec', key: [...group.ids].sort().join(':') },
|
|
5544
|
+
h('strong', null, [...group.ids].map(id => names.get(id) || id).join(' · ')),
|
|
5545
|
+
group.pairs.map(pair => h('div', { className: 'dshm-gs-action-row dshm-gs-merge-pair', key: pair.sourceId + ':' + pair.targetId },
|
|
5546
|
+
h('span', { title: pair.sourceId + ' → ' + pair.targetId }, (names.get(pair.sourceId) || pair.sourceId) + ' → ' + (names.get(pair.targetId) || pair.targetId)),
|
|
5547
|
+
h(Tag, null, t(MERGE_REASON_LABEL_KEYS[pair.reason] || 'mergeReasonDistance')), mergeAction(pair), rejectAction(pair, true))))),
|
|
5548
|
+
h('div', { className: 'dshm-gs-action-fields' },
|
|
5549
|
+
input('gsMergeSource', merge.sourceId, sourceId => setMerge(old => ({ ...old, sourceId }))),
|
|
5550
|
+
input('gsMergeTarget', merge.targetId, targetId => setMerge(old => ({ ...old, targetId }))), mergeAction(merge))),
|
|
5551
|
+
h('details', null, h('summary', null, t('gsRejectedMerges'), ' ', value?.mergeReady ? String(value.rejectedTotal) : t('gsReviewUnchecked')),
|
|
5552
|
+
h('p', null, t('gsRejectedMergeHint')),
|
|
5553
|
+
h('p', null, t('gsReviewShowing').replace('{shown}', String(rejected.length)).replace('{total}', String(value?.rejectedTotal || 0))),
|
|
5554
|
+
rejected.map(pair => h('div', { className: 'dshm-gs-action-row', key: pair.sourceId + ':' + pair.targetId },
|
|
5555
|
+
h('span', { title: pair.sourceId + ' / ' + pair.targetId }, (names.get(pair.sourceId) || pair.sourceId) + ' / ' + (names.get(pair.targetId) || pair.targetId)),
|
|
5556
|
+
rejectAction(pair, false)))),
|
|
5557
|
+
h('details', { open: true }, h('summary', null, t('anchorReviewTitle'), ' ', value?.anchorReady ? String(provisional.length + candidates.length) : t('gsReviewUnchecked')),
|
|
5558
|
+
!provisional.length && !candidates.length && value?.anchorReady ? h('p', null, t('gsReviewEmpty')) : null,
|
|
5559
|
+
provisional.slice(0, limit).map(entity => h('div', { className: 'dshm-gs-action-row', key: entity.id },
|
|
5560
|
+
h('span', { title: entity.id }, entity.name || entity.id), h(Tag, null, entity.kind),
|
|
5561
|
+
action('anchorConfirm', 'confirmEntities', { entityIds: [entity.id] }, result => t('anchorConfirmedDone').replace('{n}', String(result?.confirmed?.length ?? 0))))),
|
|
5562
|
+
candidates.slice(0, limit).map(row => h('div', { className: 'dshm-gs-action-row', key: row.term },
|
|
5563
|
+
h('span', null, row.term),
|
|
5564
|
+
h('small', null, t('anchorStats').replace('{df}', String(row.df)).replace('{cohesion}', String(row.cohesion)).replace('{freedom}', String(row.freedom))),
|
|
5565
|
+
h('select', { className: 'dshm-gs-field', 'aria-label': t('entityKind') + ': ' + row.term, value: kinds[row.term] || 'person',
|
|
5566
|
+
onChange: event => setKinds(old => ({ ...old, [row.term]: event.target.value })) },
|
|
5567
|
+
['person', 'place', 'thing', 'org'].map(kind => h('option', { key: kind, value: kind }, kind))),
|
|
5568
|
+
action('anchorConfirm', 'createEntity', { name: row.term, kind: kinds[row.term] || 'person' }, result =>
|
|
5569
|
+
result?.id ? t('gsNodeCreated').replace('{name}', result.name || row.term) : t('saved')))),
|
|
5570
|
+
provisional.length > limit || candidates.length > limit
|
|
5571
|
+
? h(Button, { title: t('gsReviewMore'), onClick: () => setLimit(number => number + 20) }, t('gsReviewMore')) : null),
|
|
5572
|
+
h('details', null, h('summary', null, t('relationCreate')),
|
|
5573
|
+
h('p', null, t('gsLinkHint')),
|
|
5574
|
+
h('div', { className: 'dshm-gs-action-fields' },
|
|
5575
|
+
input('gsLinkSource', link.fromId, fromId => setLink(old => ({ ...old, fromId }))),
|
|
5576
|
+
input('gsLinkTarget', link.toId, toId => setLink(old => ({ ...old, toId }))),
|
|
5577
|
+
field('relationKind', h('select', { className: 'dshm-gs-field', 'aria-label': t('relationKind'), value: link.kind,
|
|
5578
|
+
onChange: event => setLink(old => ({ ...old, kind: event.target.value })) },
|
|
5579
|
+
['relation', 'commitment', 'event', 'person', 'conflict', 'supersede'].map(kind => h('option', { key: kind, value: kind }, kind)))),
|
|
5580
|
+
input('gsLinkConfidence', link.confidence, confidence => setLink(old => ({ ...old, confidence })), { type: 'number', min: 0, max: 1, step: .05 }),
|
|
5581
|
+
field('relationNote', h('textarea', { className: 'dshm-gs-field', 'aria-label': t('relationNote'), value: link.note, maxLength: 500,
|
|
5582
|
+
onChange: event => setLink(old => ({ ...old, note: event.target.value })) })),
|
|
5583
|
+
rawSelected?.kind === 'memory' ? h(Button, { title: t('focusMemory'), onClick: () => setLink(old => ({ ...old, fromId: rawSelected.rawId || rawSelected.id })) }, t('focusMemory')) : null,
|
|
5584
|
+
action('relationCreate', 'linkEntries', { ...link, fromId: link.fromId.trim(), toId: link.toId.trim(), confidence: Number(link.confidence) }, () => t('gsLinkDone'),
|
|
5585
|
+
!link.fromId.trim() || !link.toId.trim() || link.fromId.trim() === link.toId.trim() || link.note.replace(/\s/g, '').length < 8
|
|
5586
|
+
|| link.note.length > 500 || link.confidence === '' || !Number.isFinite(Number(link.confidence)) || Number(link.confidence) < 0 || Number(link.confidence) > 1),
|
|
5587
|
+
h('p', null, t('gsUnlinkHint')),
|
|
5588
|
+
action('relationRemove', 'unlinkEntry', { fromId: link.fromId.trim(), toId: link.toId.trim(), kind: link.kind },
|
|
5589
|
+
result => t('gsUnlinkDone').replace('{n}', String(result?.removed ?? 0)), !link.fromId.trim() || !link.toId.trim()))),
|
|
5590
|
+
h('details', null, h('summary', null, t('relationRemove'), ' / ', t('gsSuppressMemory')),
|
|
5591
|
+
h('p', null, t('gsUnlinkHint')),
|
|
5592
|
+
visibleEdges.slice(0, 20).map(edge => h('div', { className: 'dshm-gs-action-row', key: JSON.stringify([edge.from, edge.to, edge.kind]) },
|
|
5593
|
+
h('span', null, `${names.get(rawId(edge.from)) || rawId(edge.from)} → ${names.get(rawId(edge.to)) || rawId(edge.to)} · ${edge.kind} · ${edge.source || 'manual'}`),
|
|
5594
|
+
action('relationRemove', 'unlinkEntry', { fromId: rawId(edge.from), toId: rawId(edge.to), kind: edge.kind }, result => t('gsUnlinkDone').replace('{n}', String(result?.removed ?? 0))))),
|
|
5595
|
+
rawSelected?.kind === 'memory' ? h('div', { className: 'dshm-gs-action-row' },
|
|
5596
|
+
h('p', null, t('gsSuppressMemoryHint')),
|
|
5597
|
+
action('gsSuppressMemory', 'updateMemory', { id: rawSelected.rawId || rawSelected.id, patch: { status: 'suppressed' } }, () => t('gsSuppressedDone'))) : null,
|
|
5598
|
+
h('p', null, t('gsSuppressionHint')),
|
|
5599
|
+
action('purgeAutoLinks', 'purgeAutoLinks', {}, result => t('purgeAutoDone').replace('{n}', String(result?.removed ?? 0))),
|
|
5600
|
+
action('clearSuppression', 'clearLinkSuppression', {}, result => t('clearSuppressionDone').replace('{n}', String(result?.cleared ?? 0)))))
|
|
5601
|
+
}
|
|
4250
5602
|
function GraphPanel({ call, libraryId, files, t, global = false }) {
|
|
4251
5603
|
const [graph, setGraph] = React.useState({ nodes: [], edges: [] })
|
|
4252
5604
|
const [entities, setEntities] = React.useState([])
|
|
@@ -4668,6 +6020,28 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4668
6020
|
})
|
|
4669
6021
|
}
|
|
4670
6022
|
|
|
6023
|
+
function PipIndexesInput({ values, onChange, t }) {
|
|
6024
|
+
const [text, setText] = React.useState(() => values.join(', '))
|
|
6025
|
+
const [invalid, setInvalid] = React.useState(false)
|
|
6026
|
+
const focused = React.useRef(false)
|
|
6027
|
+
const key = JSON.stringify(values)
|
|
6028
|
+
React.useEffect(() => { if (!focused.current) { setText(values.join(', ')); setInvalid(false) } }, [key])
|
|
6029
|
+
return h('span', null, h('input', {
|
|
6030
|
+
className: 'dshm-setting-input', type: 'text', value: text, 'aria-label': t('pipIndexes'), 'aria-invalid': invalid,
|
|
6031
|
+
onFocus: () => { focused.current = true }, onBlur: () => { focused.current = false },
|
|
6032
|
+
onChange: event => {
|
|
6033
|
+
setText(event.target.value)
|
|
6034
|
+
const next = [...new Set(event.target.value.split(',').map(value => value.trim()).filter(Boolean))]
|
|
6035
|
+
const valid = next.length <= 20 && next.every(value => {
|
|
6036
|
+
try { const url = new URL(value); return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash }
|
|
6037
|
+
catch { return false }
|
|
6038
|
+
})
|
|
6039
|
+
setInvalid(!valid)
|
|
6040
|
+
if (valid) onChange(next)
|
|
6041
|
+
},
|
|
6042
|
+
}), invalid ? h('span', { className: 'dshm-scope-note', role: 'alert' }, t('pipIndexesInvalid')) : null)
|
|
6043
|
+
}
|
|
6044
|
+
|
|
4671
6045
|
function WallCover({ item }) {
|
|
4672
6046
|
const [failed, setFailed] = React.useState(false)
|
|
4673
6047
|
const cover = (item.attachments || []).find(entry => entry.url && !entry.hidden && !entry.missing)
|
|
@@ -4677,11 +6051,232 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4677
6051
|
item.attachmentCount > 1 ? h('span', { className: 'dshm-wall-cover-count' }, '▧ ' + item.attachmentCount) : null)
|
|
4678
6052
|
}
|
|
4679
6053
|
|
|
6054
|
+
function EntityMergeReviewPanel({ call, libraries = [], initialLibraryId = '', sessionId = null, t }) {
|
|
6055
|
+
const [libraryId, setLibraryId] = React.useState(initialLibraryId || (libraries.length > 1 ? 'all' : libraries[0]?.id || 'all'))
|
|
6056
|
+
const [snapshot, setSnapshot] = React.useState(null)
|
|
6057
|
+
const [cursorState, setCursorState] = React.useState({ key: '', cursor: null })
|
|
6058
|
+
const [retry, setRetry] = React.useState(0)
|
|
6059
|
+
const [armed, setArmed] = React.useState('')
|
|
6060
|
+
const [busy, setBusy] = React.useState(false)
|
|
6061
|
+
const [error, setError] = React.useState('')
|
|
6062
|
+
const [notice, setNotice] = React.useState('')
|
|
6063
|
+
const requestRef = React.useRef(0)
|
|
6064
|
+
const activeLibraryId = libraryId === 'all' || libraries.some(lib => lib.id === libraryId) ? libraryId : 'all'
|
|
6065
|
+
const books = activeLibraryId === 'all' ? libraries : libraries.filter(lib => lib.id === activeLibraryId)
|
|
6066
|
+
const aggregate = activeLibraryId === 'all'
|
|
6067
|
+
const identity = JSON.stringify([activeLibraryId, sessionId, books.map(lib => lib.id)])
|
|
6068
|
+
const identityRef = React.useRef(identity)
|
|
6069
|
+
identityRef.current = identity
|
|
6070
|
+
const cursor = cursorState.key === identity ? cursorState.cursor : null
|
|
6071
|
+
const requestKey = JSON.stringify([identity, cursor, retry])
|
|
6072
|
+
|
|
6073
|
+
React.useEffect(() => {
|
|
6074
|
+
const request = ++requestRef.current
|
|
6075
|
+
let alive = true
|
|
6076
|
+
setArmed('')
|
|
6077
|
+
setError('')
|
|
6078
|
+
setBusy(false)
|
|
6079
|
+
if (!books.length) {
|
|
6080
|
+
setSnapshot({ key: requestKey, loading: false, items: [], total: null, totalExact: false })
|
|
6081
|
+
return () => { alive = false }
|
|
6082
|
+
}
|
|
6083
|
+
setSnapshot(previous => ({ ...previous, key: requestKey, loading: true }))
|
|
6084
|
+
const targets = books.filter(lib => !cursor || cursor[lib.id])
|
|
6085
|
+
const read = async lib => {
|
|
6086
|
+
const result = await call('listEntityMergeReviews', {
|
|
6087
|
+
libraryId: lib.id, ...(sessionId && !aggregate ? { sessionId } : {}), limit: 20,
|
|
6088
|
+
...(cursor?.[lib.id] ? { cursor: cursor[lib.id] } : {}),
|
|
6089
|
+
})
|
|
6090
|
+
return { ...result, libraryId: lib.id }
|
|
6091
|
+
}
|
|
6092
|
+
const fetchPages = async () => {
|
|
6093
|
+
const results = new Array(targets.length)
|
|
6094
|
+
let index = 0
|
|
6095
|
+
await Promise.all(Array.from({ length: Math.min(4, targets.length) }, async () => {
|
|
6096
|
+
while (alive && requestRef.current === request && index < targets.length) {
|
|
6097
|
+
const i = index++
|
|
6098
|
+
try { results[i] = { status: 'fulfilled', value: await read(targets[i]) } }
|
|
6099
|
+
catch (reason) { results[i] = { status: 'rejected', reason } }
|
|
6100
|
+
}
|
|
6101
|
+
}))
|
|
6102
|
+
return results
|
|
6103
|
+
}
|
|
6104
|
+
void fetchPages().then(results => {
|
|
6105
|
+
if (!alive || requestRef.current !== request) return
|
|
6106
|
+
const pages = results.filter(row => row.status === 'fulfilled').map(row => row.value)
|
|
6107
|
+
const failures = results.flatMap((row, index) => row.status === 'rejected'
|
|
6108
|
+
? [`${libraryOptionLabel(targets[index], libraries)}: ${String(row.reason?.message || row.reason)}`] : [])
|
|
6109
|
+
const exact = !cursor && !failures.length && pages.every(page => page.totalExact === true && Number.isSafeInteger(page.total) && page.total >= 0)
|
|
6110
|
+
const next = Object.fromEntries(pages.filter(page => typeof page.nextCursor === 'string' && page.nextCursor)
|
|
6111
|
+
.map(page => [page.libraryId, page.nextCursor]))
|
|
6112
|
+
setSnapshot({
|
|
6113
|
+
key: requestKey,
|
|
6114
|
+
loading: false,
|
|
6115
|
+
items: pages.flatMap(page => (Array.isArray(page.items) ? page.items : []).map(item => ({ ...item, libraryId: page.libraryId }))),
|
|
6116
|
+
total: exact ? pages.reduce((sum, page) => sum + page.total, 0) : null,
|
|
6117
|
+
totalExact: exact,
|
|
6118
|
+
nextCursor: Object.keys(next).length ? next : null,
|
|
6119
|
+
})
|
|
6120
|
+
setError(failures.join('\n'))
|
|
6121
|
+
}).catch(failure => {
|
|
6122
|
+
if (!alive || requestRef.current !== request) return
|
|
6123
|
+
setSnapshot({ key: requestKey, loading: false, items: [], total: null, totalExact: false, nextCursor: null })
|
|
6124
|
+
setError(String(failure?.message || failure))
|
|
6125
|
+
})
|
|
6126
|
+
return () => {
|
|
6127
|
+
alive = false
|
|
6128
|
+
if (requestRef.current === request) requestRef.current++
|
|
6129
|
+
}
|
|
6130
|
+
}, [call, identity, activeLibraryId, sessionId, cursor, retry])
|
|
6131
|
+
|
|
6132
|
+
React.useEffect(() => {
|
|
6133
|
+
if (!armed) return undefined
|
|
6134
|
+
const timer = setTimeout(() => setArmed(''), 2500)
|
|
6135
|
+
return () => clearTimeout(timer)
|
|
6136
|
+
}, [armed])
|
|
6137
|
+
|
|
6138
|
+
const current = snapshot?.key === requestKey ? snapshot : null
|
|
6139
|
+
const loading = !current || current.loading
|
|
6140
|
+
const pending = (Array.isArray(current?.items) ? current.items : []).filter(item =>
|
|
6141
|
+
item && item.pending !== false && (!item.status || item.status === 'pending' || item.status === 'pending_review'))
|
|
6142
|
+
const shown = pending.length
|
|
6143
|
+
const total = Number.isSafeInteger(current?.total) ? current.total : shown
|
|
6144
|
+
const countLabel = current?.totalExact
|
|
6145
|
+
? t('entityReviewCountExact').replace('{shown}', String(shown)).replace('{total}', String(total))
|
|
6146
|
+
: t('entityReviewCountApprox').replace('{shown}', String(shown))
|
|
6147
|
+
|
|
6148
|
+
const entityOf = (item, side) => {
|
|
6149
|
+
const nested = side === 'source'
|
|
6150
|
+
? item.source || item.sourceEntity || item.entities?.source
|
|
6151
|
+
: item.target || item.targetEntity || item.entities?.target
|
|
6152
|
+
const prefix = side === 'source' ? 'source' : 'target'
|
|
6153
|
+
return {
|
|
6154
|
+
id: nested?.id || item[`${prefix}Id`] || '',
|
|
6155
|
+
name: nested?.name || nested?.title || item[`${prefix}Name`] || item[`${prefix}Id`] || '',
|
|
6156
|
+
type: nested?.type || nested?.kind || item[`${prefix}Type`] || item[`${prefix}Kind`] || '',
|
|
6157
|
+
evidence: nested?.evidence || nested?.memories || item[`${prefix}Evidence`] || item[`${prefix}Memories`] || [],
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
const runAction = async (item, action) => {
|
|
6161
|
+
const source = entityOf(item, 'source')
|
|
6162
|
+
const target = entityOf(item, 'target')
|
|
6163
|
+
const token = item.reviewToken
|
|
6164
|
+
if (!/^[a-f0-9]{64}$/i.test(token || '') || !source.id || !target.id || source.id === target.id) {
|
|
6165
|
+
setError(t('entityReviewMissingToken'))
|
|
6166
|
+
setArmed('')
|
|
6167
|
+
return
|
|
6168
|
+
}
|
|
6169
|
+
const itemLibraryId = item.libraryId
|
|
6170
|
+
if (!books.some(lib => lib.id === itemLibraryId) || busy || loading) return
|
|
6171
|
+
const key = JSON.stringify([identity, itemLibraryId, source.id, target.id, token, action])
|
|
6172
|
+
if (armed !== key) { setArmed(key); return }
|
|
6173
|
+
setArmed('')
|
|
6174
|
+
setBusy(true)
|
|
6175
|
+
setError('')
|
|
6176
|
+
setNotice('')
|
|
6177
|
+
try {
|
|
6178
|
+
if (action === 'merge') {
|
|
6179
|
+
await call('mergeEntities', {
|
|
6180
|
+
libraryId: itemLibraryId, ...(sessionId && !aggregate ? { sessionId } : {}), targetId: target.id, sourceIds: [source.id], reviewToken: token,
|
|
6181
|
+
})
|
|
6182
|
+
} else {
|
|
6183
|
+
const result = await call('setEntityMergeRejection', {
|
|
6184
|
+
libraryId: itemLibraryId, ...(sessionId && !aggregate ? { sessionId } : {}), sourceId: source.id, targetId: target.id,
|
|
6185
|
+
reviewToken: token, rejected: true, confirmed: true,
|
|
6186
|
+
})
|
|
6187
|
+
if (result?.ok !== true || result.rejected !== true) throw new Error(t('scopeNotApplied'))
|
|
6188
|
+
}
|
|
6189
|
+
notifyMemoryWrite('relation', itemLibraryId)
|
|
6190
|
+
if (identityRef.current !== identity) return
|
|
6191
|
+
setNotice(t(action === 'merge' ? 'entityReviewMergeDone' : 'entityReviewExcludeDone'))
|
|
6192
|
+
setCursorState({ key: identity, cursor: null })
|
|
6193
|
+
setRetry(value => value + 1)
|
|
6194
|
+
} catch (failure) {
|
|
6195
|
+
if (identityRef.current === identity) setError(String(failure?.message || failure))
|
|
6196
|
+
} finally { if (identityRef.current === identity) setBusy(false) }
|
|
6197
|
+
}
|
|
6198
|
+
const evidenceRows = (entity) => {
|
|
6199
|
+
const rows = Array.isArray(entity.evidence) ? entity.evidence : entity.evidence ? [entity.evidence] : []
|
|
6200
|
+
if (!rows.length) return h('div', { style: { ...S.muted, overflowWrap: 'anywhere' } }, t('entityReviewNoEvidence'))
|
|
6201
|
+
return h('ul', { style: { margin: '5px 0 0', paddingLeft: 18, display: 'grid', gap: 5 } }, rows.slice(0, 5).map((entry, index) => {
|
|
6202
|
+
const title = typeof entry === 'string' ? '' : String(entry?.title || entry?.name || entry?.id || '')
|
|
6203
|
+
const summary = typeof entry === 'string' ? entry : String(entry?.summary || entry?.preview || entry?.content || entry?.text || '')
|
|
6204
|
+
const text = summary.length > 500 ? summary.slice(0, 500) + '…' : summary
|
|
6205
|
+
return h('li', { key: entry?.id || index, style: { fontSize: 12, lineHeight: 1.5, overflowWrap: 'anywhere' } },
|
|
6206
|
+
title ? h('strong', null, title, text ? ' · ' : '') : null, text || (title ? null : '—'))
|
|
6207
|
+
}))
|
|
6208
|
+
}
|
|
6209
|
+
const entityCard = (entity, label) => h('section', {
|
|
6210
|
+
key: label,
|
|
6211
|
+
style: { minWidth: 0, padding: 10, border: `1px solid ${V.borderSoft}`, borderRadius: V.radiusSm, background: V.surfaceRaised },
|
|
6212
|
+
},
|
|
6213
|
+
h('div', { style: { display: 'flex', alignItems: 'flex-start', gap: 7, flexWrap: 'wrap' } },
|
|
6214
|
+
h('span', { style: { ...S.muted, flex: '0 0 auto' } }, t(label)),
|
|
6215
|
+
h('strong', { style: { minWidth: 0, flex: '1 1 130px', overflowWrap: 'anywhere' } }, entity.name || entity.id || '—'),
|
|
6216
|
+
entity.type ? h(Tag, null, `${t('entityReviewType')}: ${entity.type}`) : null),
|
|
6217
|
+
h('div', { style: { marginTop: 8 } },
|
|
6218
|
+
h('div', { style: { ...S.muted, fontWeight: 600 } }, t('entityReviewEvidence')),
|
|
6219
|
+
evidenceRows(entity)))
|
|
6220
|
+
const candidateCard = item => {
|
|
6221
|
+
const source = entityOf(item, 'source')
|
|
6222
|
+
const target = entityOf(item, 'target')
|
|
6223
|
+
const token = item.reviewToken || ''
|
|
6224
|
+
const base = JSON.stringify([identity, item.libraryId, source.id, target.id, token])
|
|
6225
|
+
const mergeKey = JSON.stringify([identity, item.libraryId, source.id, target.id, token, 'merge'])
|
|
6226
|
+
const excludeKey = JSON.stringify([identity, item.libraryId, source.id, target.id, token, 'exclude'])
|
|
6227
|
+
const reason = item.reason || item.matchReason || item.reasonCode || ''
|
|
6228
|
+
const reasonKey = MERGE_REASON_LABEL_KEYS[reason]
|
|
6229
|
+
const reasonDetail = item.reasonDetail || item.matchDetail || item.explanation || ''
|
|
6230
|
+
const valid = /^[a-f0-9]{64}$/i.test(token) && source.id && target.id && source.id !== target.id
|
|
6231
|
+
return h('article', { key: base, className: 'dshm-entity-review-card', 'data-library-id': item.libraryId },
|
|
6232
|
+
h('div', { className: 'dshm-entity-review-head' },
|
|
6233
|
+
h('strong', { style: { overflowWrap: 'anywhere' } }, t('entityReviewPair')),
|
|
6234
|
+
h(Tag, { tone: 'info' }, libraryOptionLabel(libraries.find(lib => lib.id === item.libraryId) || { id: item.libraryId }, libraries)),
|
|
6235
|
+
h(Tag, { tone: item.reviewState === 'human' ? 'warn' : undefined }, t(item.reviewState === 'human' ? 'entityReviewHuman' : 'entityReviewModel')),
|
|
6236
|
+
h(Tag, { tone: 'warn' }, reasonKey ? t(reasonKey) : String(reason || '—')),
|
|
6237
|
+
reasonDetail ? h('span', { style: { minWidth: 0, flex: '1 1 160px', fontSize: 12, overflowWrap: 'anywhere' } }, String(reasonDetail)) : null),
|
|
6238
|
+
item.reviewReason ? h('p', { className: 'dshm-settings-note' }, item.reviewReason) : null,
|
|
6239
|
+
h('div', { className: 'dshm-entity-review-pair' },
|
|
6240
|
+
entityCard(source, 'entityReviewSource'), entityCard(target, 'entityReviewTarget')),
|
|
6241
|
+
h('div', { className: 'dshm-entity-review-actions' },
|
|
6242
|
+
h(Button, { primary: true, disabled: busy || loading || !valid, onClick: () => void runAction(item, 'merge') },
|
|
6243
|
+
armed === mergeKey ? t('entityMergeConfirm') : t('entityMergeAction')),
|
|
6244
|
+
h(Button, { style: S.ghost, disabled: busy || loading || !valid, onClick: () => void runAction(item, 'exclude') },
|
|
6245
|
+
armed === excludeKey ? t('entityReviewExcludeConfirm') : t('entityReviewExclude')),
|
|
6246
|
+
!valid ? h('span', { className: 'dshm-error', role: 'alert' }, t('entityReviewMissingToken')) : null))
|
|
6247
|
+
}
|
|
6248
|
+
|
|
6249
|
+
return h(Section, {
|
|
6250
|
+
title: t('entityReviewTitle'), desc: t('entityReviewDesc'), icon: GlyphLayers,
|
|
6251
|
+
right: h(Button, { style: S.ghost, disabled: busy || loading, onClick: () => { setArmed(''); setRetry(value => value + 1) } }, t('refresh')),
|
|
6252
|
+
},
|
|
6253
|
+
libraries.length
|
|
6254
|
+
? h('label', { className: 'dshm-entity-review-toolbar' },
|
|
6255
|
+
h('span', null, t('entityReviewLibrary')),
|
|
6256
|
+
h('select', { className: 'dshm-setting-input', value: activeLibraryId, 'aria-label': t('entityReviewLibrary'),
|
|
6257
|
+
onChange: event => { setArmed(''); setCursorState({ key: '', cursor: null }); setLibraryId(event.target.value) } },
|
|
6258
|
+
h('option', { value: 'all' }, t('allLibraries')),
|
|
6259
|
+
libraries.map(lib => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries)))))
|
|
6260
|
+
: h('div', { style: S.muted }, t('entityReviewEmpty')),
|
|
6261
|
+
loading ? h('div', { style: { ...S.muted, marginTop: 8 } }, t('entityReviewLoading')) : null,
|
|
6262
|
+
error ? h('div', { className: 'dshm-error', role: 'alert', style: { marginTop: 8, overflowWrap: 'anywhere' } }, `${t('entityReviewError')}: ${error}`) : null,
|
|
6263
|
+
current && activeLibraryId && !loading ? h('div', { style: { ...S.muted, margin: '8px 0', overflowWrap: 'anywhere' }, 'aria-live': 'polite' }, countLabel) : null,
|
|
6264
|
+
notice ? h('div', { role: 'status', style: { ...S.muted, margin: '8px 0', color: V.accent } }, notice) : null,
|
|
6265
|
+
activeLibraryId && !loading && !error && pending.length === 0 ? h(Empty, null, t('entityReviewAllEmpty')) : null,
|
|
6266
|
+
h('div', { className: 'dshm-entity-review-list' }, pending.filter(item => item.reviewState === 'human').map(candidateCard)),
|
|
6267
|
+
pending.some(item => item.reviewState !== 'human') ? h('details', { className: 'dshm-entity-review-auto' },
|
|
6268
|
+
h('summary', null, t('entityReviewModel'), ' · ', String(pending.filter(item => item.reviewState !== 'human').length)),
|
|
6269
|
+
h('p', { className: 'dshm-settings-note' }, t('entityReviewAutoHint')),
|
|
6270
|
+
h('div', { className: 'dshm-entity-review-list' }, pending.filter(item => item.reviewState !== 'human').map(candidateCard))) : null,
|
|
6271
|
+
current?.nextCursor ? h(Button, { style: { ...S.ghost, marginTop: 8 }, disabled: busy || loading, onClick: () => {
|
|
6272
|
+
setArmed(''); setCursorState({ key: identity, cursor: current.nextCursor })
|
|
6273
|
+
} }, t('entityReviewMore')) : null)
|
|
6274
|
+
}
|
|
6275
|
+
|
|
4680
6276
|
function MemoryWallPanel({ call, libraries, revision, stamp, onOpen, t, indexed = null, focus = null, onNotice = null, initialLibraryId = '' }) {
|
|
4681
6277
|
// 成功提示走宿主面板的 notice 通道(spec §6.2):失败仍走本面板的 error 通道,
|
|
4682
6278
|
// 同一动作只走一条。onNotice 缺省时静默(面板也可能在无 notice 通道的宿主里用)。
|
|
4683
6279
|
const notice = (message) => { if (typeof onNotice === 'function' && message) onNotice(message) }
|
|
4684
|
-
const [data, setData] = React.useState({ items: [], total: 0, errors: [] })
|
|
4685
6280
|
const [libraryId, setLibraryId] = React.useState(initialLibraryId || '')
|
|
4686
6281
|
const [multiBlocked, setMultiBlocked] = React.useState(false)
|
|
4687
6282
|
const [pool, setPool] = React.useState('active')
|
|
@@ -4689,6 +6284,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4689
6284
|
// 域筛选交给服务端:browseWall 一次最多回 300 条,客户端筛完再看计数会骗人。
|
|
4690
6285
|
const [wallDomain, setWallDomain] = React.useState('')
|
|
4691
6286
|
const [query, setQuery] = React.useState('')
|
|
6287
|
+
const wallQuery = useDebouncedValue(query.trim())
|
|
4692
6288
|
const [error, setError] = React.useState('')
|
|
4693
6289
|
const [version, setVersion] = React.useState(0)
|
|
4694
6290
|
// 组分类:私有 / 全局两块,默认私有、私有靠前。全局条目内容只读(curator 写),
|
|
@@ -4698,10 +6294,19 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4698
6294
|
const [selectedIds, setSelectedIds] = React.useState(() => new Set())
|
|
4699
6295
|
const [wallBusy, setWallBusy] = React.useState(false)
|
|
4700
6296
|
const [deleteArmedMulti, setDeleteArmedMulti] = React.useState(false)
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
6297
|
+
const firstLibraryId = libraries?.[0]?.id || ''
|
|
6298
|
+
const pager = useMemoryPages({ call, method: 'browseWall', rowsKey: 'items',
|
|
6299
|
+
enabled: query.trim() === wallQuery,
|
|
6300
|
+
payload: { libraryId: libraryId || null, domain: wallDomain || undefined, query: wallQuery || undefined,
|
|
6301
|
+
status: memoryPoolStatus(pool) }, refreshKey: `${revision ?? ''}:${stamp ?? ''}:${version}`,
|
|
6302
|
+
onFailure: failure => {
|
|
6303
|
+
if (!libraryId && firstLibraryId && /forbidden|403/i.test(String(failure?.message || failure))) {
|
|
6304
|
+
setMultiBlocked(true); setLibraryId(firstLibraryId)
|
|
6305
|
+
return true
|
|
6306
|
+
}
|
|
6307
|
+
return false
|
|
6308
|
+
} })
|
|
6309
|
+
const data = pager.data
|
|
4705
6310
|
// 二次确认不能无限期挂着:照 LexiconPanel / SettingsPage 的口径 2.5s 自动复原,
|
|
4706
6311
|
// 切池/层级/查询时立即失效,避免回来一次点击就批量删除。
|
|
4707
6312
|
React.useEffect(() => {
|
|
@@ -4723,85 +6328,6 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4723
6328
|
setScope(focus.libraryId ? 'private' : 'global')
|
|
4724
6329
|
void openDetail({ id: focus.id, libraryId: focus.libraryId || null, title: focus.title || focus.id })
|
|
4725
6330
|
}, [focus])
|
|
4726
|
-
const firstLibraryId = libraries?.[0]?.id || ''
|
|
4727
|
-
React.useEffect(() => {
|
|
4728
|
-
let alive = true
|
|
4729
|
-
const requestId = ++browseRequest.current
|
|
4730
|
-
const current = () => alive && requestId === browseRequest.current
|
|
4731
|
-
// 整库流式读取:首批立即上屏,之后逐批追加。记忆墙原先在 300 条处截断,
|
|
4732
|
-
// 读者看到的是“最近 300 条”而不是自己的库(2026-11-28)。每批之间让出
|
|
4733
|
-
// 一帧,卡片一批批出现,而不是最后一起跳出来。
|
|
4734
|
-
const stream = async (targetLibraryId) => {
|
|
4735
|
-
let items = []
|
|
4736
|
-
let total = 0
|
|
4737
|
-
let batches = 0
|
|
4738
|
-
let offset = 0
|
|
4739
|
-
// 去重集合:offset 分页在「两批之间有写入」时会把同一条再吐一次。
|
|
4740
|
-
const seen = new Set()
|
|
4741
|
-
for (;;) {
|
|
4742
|
-
// 活锁保护:库在读取过程中被持续写入时 total 会一直变大,没有这条上限
|
|
4743
|
-
// 这个循环可以永远转下去。40 批 × 300 = 12000 条,远超正常库规模,
|
|
4744
|
-
// 真的到顶就停在这里(界面会显示「超出单次读取上限」)。
|
|
4745
|
-
if (++batches > 40) return
|
|
4746
|
-
const value = await call('browseWall', {
|
|
4747
|
-
libraryId: targetLibraryId || null,
|
|
4748
|
-
// 首批小、后续大:300 张卡片一次性上屏时,浏览器要先付掉这 300 次
|
|
4749
|
-
// 组件渲染的账,读者看到的就是「进了 WebUI 卡一下才出来」。改为
|
|
4750
|
-
// 首批 60 张立刻上屏(多一次 26ms 的 RPC),其余按 300 追加。
|
|
4751
|
-
limit: batches === 1 ? 60 : 300,
|
|
4752
|
-
offset,
|
|
4753
|
-
domain: wallDomain || undefined,
|
|
4754
|
-
})
|
|
4755
|
-
if (!current()) return
|
|
4756
|
-
const batch = Array.isArray(value?.items) ? value.items : []
|
|
4757
|
-
// offset 记录服务端已消费的行数,去重只影响显示;整批重复也可能还有下一页。
|
|
4758
|
-
// 按库 + id 去重避免重复 key。并发排序移位仍不提供快照完整性。
|
|
4759
|
-
offset += batch.length
|
|
4760
|
-
const fresh = []
|
|
4761
|
-
for (const item of batch) {
|
|
4762
|
-
const key = `${item?.libraryId || targetLibraryId || ''}:${item?.id}`
|
|
4763
|
-
if (seen.has(key)) continue
|
|
4764
|
-
seen.add(key)
|
|
4765
|
-
fresh.push(item)
|
|
4766
|
-
}
|
|
4767
|
-
items = items.concat(fresh)
|
|
4768
|
-
total = Number(value?.total) || items.length
|
|
4769
|
-
setData({ ...value, items, total })
|
|
4770
|
-
setError('')
|
|
4771
|
-
if (!batch.length || offset >= total) return
|
|
4772
|
-
await new Promise(resolve => setTimeout(resolve, 0))
|
|
4773
|
-
if (!current()) return
|
|
4774
|
-
}
|
|
4775
|
-
}
|
|
4776
|
-
const load = async () => {
|
|
4777
|
-
try {
|
|
4778
|
-
await stream(libraryId)
|
|
4779
|
-
} catch (failure) {
|
|
4780
|
-
if (!current()) return
|
|
4781
|
-
const message = String(failure?.message || failure)
|
|
4782
|
-
// 宿主对“全部记忆库”多库读取返回 403(browseWall 无法表达为单库授权)时,
|
|
4783
|
-
// 退到第一个库并明确告知;单库 + 全局(browseWall 总会带全局)仍能出数据,
|
|
4784
|
-
// 不再整页空。用户可手动切换库;多库选项保留为禁用。
|
|
4785
|
-
if (!libraryId && firstLibraryId && /forbidden|403/i.test(message)) {
|
|
4786
|
-
try {
|
|
4787
|
-
await stream(firstLibraryId)
|
|
4788
|
-
// A newer selection owns the wall now; do not force the reader
|
|
4789
|
-
// back to the first library from a fallback they did not ask for.
|
|
4790
|
-
if (!current()) return
|
|
4791
|
-
setMultiBlocked(true)
|
|
4792
|
-
setLibraryId(firstLibraryId)
|
|
4793
|
-
return
|
|
4794
|
-
} catch (fallbackFailure) {
|
|
4795
|
-
if (current()) setError(String(fallbackFailure?.message || fallbackFailure))
|
|
4796
|
-
return
|
|
4797
|
-
}
|
|
4798
|
-
}
|
|
4799
|
-
setError(message)
|
|
4800
|
-
}
|
|
4801
|
-
}
|
|
4802
|
-
void load()
|
|
4803
|
-
return () => { alive = false }
|
|
4804
|
-
}, [call, libraryId, revision, stamp, version, firstLibraryId, wallDomain])
|
|
4805
6331
|
React.useEffect(() => {
|
|
4806
6332
|
if (!detail) return undefined
|
|
4807
6333
|
const onKey = (event) => { if (event.key === 'Escape') setDetail(null) }
|
|
@@ -4814,8 +6340,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4814
6340
|
}
|
|
4815
6341
|
}, [detail])
|
|
4816
6342
|
|
|
4817
|
-
const poolOf =
|
|
4818
|
-
: ['suppressed', 'expired', 'superseded'].includes(item.status) || item.expiresAt && Date.parse(item.expiresAt) <= Date.now() ? 'inactive' : 'active'
|
|
6343
|
+
const poolOf = memoryPool
|
|
4819
6344
|
const items = Array.isArray(data?.items) ? data.items : []
|
|
4820
6345
|
const inScope = item => scope === 'global' ? item.libraryId === null : item.libraryId !== null
|
|
4821
6346
|
const scoped = items.filter(inScope)
|
|
@@ -4823,8 +6348,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4823
6348
|
const keyOf = item => (item.libraryId || 'global') + ':' + item.id
|
|
4824
6349
|
const selectedRows = visible => visible.filter(item => selectedIds.has(keyOf(item)))
|
|
4825
6350
|
const layerMatch = (item, value) => value === 'all' || (value === 'anchor' ? item.layer === 'must_remember' && poolOf(item) === 'active' : item.layer === value)
|
|
4826
|
-
const
|
|
4827
|
-
const visible = rows.filter(item => layerMatch(item, layer) && (!text || [item.title, item.preview, (item.tags || []).join(' ')].join(' ').toLowerCase().includes(text)))
|
|
6351
|
+
const visible = rows.filter(item => layerMatch(item, layer))
|
|
4828
6352
|
|
|
4829
6353
|
const draftOf = (file) => ({
|
|
4830
6354
|
title: file.title || '',
|
|
@@ -5120,6 +6644,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5120
6644
|
onClick: () => { void setDetailStatus(detail.file.status === 'archived' ? 'active' : 'archived') },
|
|
5121
6645
|
}, detail.file.status === 'archived' ? t('restore') : t('archive'))
|
|
5122
6646
|
: null,
|
|
6647
|
+
detail.file?.status === 'suppressed'
|
|
6648
|
+
? h(Button, { style: S.ghost, disabled: detail.busy, onClick: () => { void setDetailStatus('active') } }, t('restore'))
|
|
6649
|
+
: null,
|
|
5123
6650
|
detail.file?.status === 'archived'
|
|
5124
6651
|
? deleteArmed
|
|
5125
6652
|
? h(React.Fragment, null,
|
|
@@ -5177,12 +6704,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5177
6704
|
})),
|
|
5178
6705
|
extra)
|
|
5179
6706
|
|
|
6707
|
+
const counted = count => t('memoryLoaded') + ' ' + count
|
|
5180
6708
|
const scopeItems = [['private', 'wallScopePrivate'], ['global', 'wallScopeGlobal']]
|
|
5181
|
-
.map(([value, key]) => [value, t(key) + ' (' + items.filter(item => value === 'global' ? item.libraryId === null : item.libraryId !== null).length + ')'])
|
|
6709
|
+
.map(([value, key]) => [value, t(key) + ' (' + counted(items.filter(item => value === 'global' ? item.libraryId === null : item.libraryId !== null).length) + ')'])
|
|
5182
6710
|
const poolItems = [['active', 'browseActiveTab'], ['archived', 'browseArchivedTab'], ['review', 'poolReview'], ['inactive', 'poolInactive']]
|
|
5183
|
-
.map(([value, key]) => [value, t(key) + ' (' + scoped.filter(item => poolOf(item) === value).length + ')'])
|
|
6711
|
+
.map(([value, key]) => [value, t(key) + ' (' + counted(scoped.filter(item => poolOf(item) === value).length) + ')'])
|
|
5184
6712
|
const layerItems = ['all', 'must_remember', 'long_term', 'short_term', 'anchor']
|
|
5185
|
-
.map(value => [value, (value === 'all' ? t('wallAllLayers') : enumText(t, LAYER_LABELS, value)) + ' (' + rows.filter(item => layerMatch(item, value)).length + ')'])
|
|
6713
|
+
.map(value => [value, (value === 'all' ? t('wallAllLayers') : enumText(t, LAYER_LABELS, value)) + ' (' + counted(rows.filter(item => layerMatch(item, value)).length) + ')'])
|
|
5186
6714
|
const selectedLibrary = libraries.find((lib) => lib.id === libraryId) || null
|
|
5187
6715
|
const librarySelect = scope === 'private' && libraries.length
|
|
5188
6716
|
? h('select', {
|
|
@@ -5287,7 +6815,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5287
6815
|
item.openLoop ? h(Tag, null, t('openLoopTag')) : null,
|
|
5288
6816
|
item.attachmentCount ? h(Tag, null, '▧ ' + item.attachmentCount) : null),
|
|
5289
6817
|
h('meter', { min: 0, max: 1, value: item.decay, 'aria-label': t('decay') }))))
|
|
5290
|
-
: h(Empty, null, t('noMemoriesView'))
|
|
6818
|
+
: h(Empty, null, pager.loading ? t('loading') : t('noMemoriesView')),
|
|
6819
|
+
h(MemoryPageMore, { pager, loaded: items.length, t })),
|
|
5291
6820
|
detailView)
|
|
5292
6821
|
}
|
|
5293
6822
|
|
|
@@ -5316,6 +6845,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5316
6845
|
const [data, setData] = React.useState(null)
|
|
5317
6846
|
const [status, setStatus] = React.useState('active')
|
|
5318
6847
|
const [kind, setKind] = React.useState('')
|
|
6848
|
+
const [domain, setDomain] = React.useState('')
|
|
5319
6849
|
const [queryInput, setQueryInput] = React.useState('')
|
|
5320
6850
|
const [query, setQuery] = React.useState('')
|
|
5321
6851
|
const [page, setPage] = React.useState(1)
|
|
@@ -5358,13 +6888,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5358
6888
|
: (libraries.find((lib) => lib.id === e?.libraryId)?.name || e?.libraryName || e?.libraryId || ''))
|
|
5359
6889
|
const emptyView = { items: [], total: 0, page: 1, pages: 1, counts: {}, statusCounts: { active: 0, archived: 0 } }
|
|
5360
6890
|
const loadSeq = React.useRef(0)
|
|
6891
|
+
const loadKey = JSON.stringify([activeLib, page, status, kind, query, domain, sessionId])
|
|
5361
6892
|
// load 的依赖里不放 libraries/t:它们可能每次渲染都是新引用(`|| []`、bind),
|
|
5362
6893
|
// 进了依赖会让 load 每渲染重建 → effect 重跑 → 再渲染,形成循环。用 ref 读最新值。
|
|
5363
|
-
const loadProps = React.useRef({ libraries, t })
|
|
5364
|
-
loadProps.current = { libraries, t }
|
|
6894
|
+
const loadProps = React.useRef({ libraries, t, key: loadKey })
|
|
6895
|
+
loadProps.current = { libraries, t, key: loadKey }
|
|
5365
6896
|
const load = React.useCallback(async () => {
|
|
6897
|
+
if (loadProps.current.key !== loadKey) return
|
|
5366
6898
|
if (!activeLib) { setData(emptyView); return }
|
|
5367
6899
|
const seq = ++loadSeq.current
|
|
6900
|
+
const current = () => seq === loadSeq.current && loadProps.current.key === loadKey
|
|
5368
6901
|
setBusy(true)
|
|
5369
6902
|
try {
|
|
5370
6903
|
// 只取当前页、当前页签:状态页签、kind、搜索、分页全在 RPC 侧收窄,
|
|
@@ -5373,16 +6906,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5373
6906
|
// (会话凭据表达不了多库授权),由宿主 capability 把关。
|
|
5374
6907
|
const res = await call('lexiconList', {
|
|
5375
6908
|
libraryId: activeLib, ...(isAllLib ? {} : { sessionId: sessionId || undefined }), page, pageSize: 50,
|
|
5376
|
-
status, kind: kind || undefined, q: query || undefined,
|
|
6909
|
+
status, kind: kind || undefined, q: query || undefined, domain: domain || undefined,
|
|
5377
6910
|
})
|
|
5378
|
-
if (
|
|
6911
|
+
if (!current()) return
|
|
5379
6912
|
setData(res || emptyView)
|
|
5380
6913
|
setError('')
|
|
5381
6914
|
if (isAllLib && Array.isArray(res?.errors) && res.errors.length > 0) {
|
|
5382
6915
|
setNotice(loadProps.current.t('lexiconAllPartial').split('{books}').join(res.errors.map((x) => x.libraryId).join(', ')))
|
|
5383
6916
|
}
|
|
5384
6917
|
} catch (e) {
|
|
5385
|
-
if (
|
|
6918
|
+
if (!current()) return
|
|
5386
6919
|
const message = String(e?.message || e)
|
|
5387
6920
|
if (isAllLib && /forbidden|403/i.test(message)) {
|
|
5388
6921
|
const books = loadProps.current.libraries
|
|
@@ -5393,10 +6926,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5393
6926
|
}
|
|
5394
6927
|
setError(message)
|
|
5395
6928
|
} finally {
|
|
5396
|
-
if (
|
|
6929
|
+
if (current()) setBusy(false)
|
|
5397
6930
|
}
|
|
5398
|
-
}, [call, activeLib, page, status, kind, query, sessionId])
|
|
5399
|
-
React.useEffect(() => { void load() }, [load])
|
|
6931
|
+
}, [call, activeLib, page, status, kind, query, domain, sessionId])
|
|
6932
|
+
React.useEffect(() => { void load(); return () => { loadSeq.current++ } }, [load])
|
|
5400
6933
|
React.useEffect(() => {
|
|
5401
6934
|
if (!error && !notice) return undefined
|
|
5402
6935
|
const timer = setTimeout(() => { setError(''); setNotice('') }, 2600)
|
|
@@ -5418,7 +6951,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5418
6951
|
|
|
5419
6952
|
const resetSelection = () => { setSelectedIds(new Set()); setDeleteArmed(''); setArmedBulk('') }
|
|
5420
6953
|
const resetTransient = () => { setEditingId(''); setEditDraft(null); setCreating(false); setMulti(false); resetSelection() }
|
|
5421
|
-
const changeLibrary = (value) => { setLibraryId(value); setPage(1); resetTransient() }
|
|
6954
|
+
const changeLibrary = (value) => { setLibraryId(value); setDomain(''); setPage(1); resetTransient() }
|
|
5422
6955
|
const changeStatus = (value) => {
|
|
5423
6956
|
if (value === status) return
|
|
5424
6957
|
setStatus(value); setPage(1); setEditingId(''); setEditDraft(null); resetSelection()
|
|
@@ -5619,6 +7152,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5619
7152
|
}, t(key), h('b', { style: { fontWeight: 650, color: selected ? V.accent : V.text } }, String(n)))
|
|
5620
7153
|
}))
|
|
5621
7154
|
const filterRow = h('div', { className: 'dshm-graph-tools', style: { flexWrap: 'wrap', marginTop: 0 } },
|
|
7155
|
+
h('select', { value: domain, title: t('wallDomainHint'), 'aria-label': t('wallFilterDomain'),
|
|
7156
|
+
onChange: event => changeFilter(setDomain)(event.target.value) },
|
|
7157
|
+
h('option', { value: '' }, t('wallDomainAll')),
|
|
7158
|
+
[...new Set([...(Array.isArray(data?.domains) ? data.domains : []), domain].filter(Boolean))].sort()
|
|
7159
|
+
.map(value => h('option', { key: value, value },
|
|
7160
|
+
domainText(t, value) + ` (${Number(data?.domainCounts?.[value]) || 0})`))),
|
|
5622
7161
|
h('input', {
|
|
5623
7162
|
type: 'search', style: S.input, value: safeQueryInput, placeholder: t('lexiconSearch'),
|
|
5624
7163
|
'aria-label': t('lexiconSearch'),
|
|
@@ -5663,6 +7202,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5663
7202
|
h('h3', { className: 'dshm-drawer-title' }, editingTerm.term || editingTerm.id),
|
|
5664
7203
|
h('div', { className: 'dshm-drawer-meta' },
|
|
5665
7204
|
h(Tag, null, enumText(t, LEXICON_KIND_LABELS, editingTerm.kind)),
|
|
7205
|
+
h(Tag, { title: t('wallDomainHint') }, domainText(t, editingTerm.domain || (bookOf(editingTerm) === GLOBAL_LEXICON_ID ? 'unknown' : 'general'))),
|
|
5666
7206
|
editingTerm.sensitivity === 'sensitive' ? h(Tag, { tone: 'warn' }, t('lexiconSensitive')) : null)),
|
|
5667
7207
|
h('button', { type: 'button', className: 'dshm-x', 'aria-label': t('close'), onClick: closeEdit }, '×')),
|
|
5668
7208
|
h('div', { className: 'dshm-drawer-form' },
|
|
@@ -5712,6 +7252,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5712
7252
|
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,
|
|
5713
7253
|
h('strong', { style: { fontSize: 15, fontWeight: 650, lineHeight: 1.3, overflowWrap: 'anywhere', flex: '1 1 120px' } }, e.term || e.id),
|
|
5714
7254
|
h(Tag, null, enumText(t, LEXICON_KIND_LABELS, e.kind)),
|
|
7255
|
+
!domain ? h(Tag, { title: t('wallDomainHint') }, domainText(t, e.domain || (bookOf(e) === GLOBAL_LEXICON_ID ? 'unknown' : 'general'))) : null,
|
|
5715
7256
|
isAllLib && bookLabel ? h(Tag, null, bookLabel) : null,
|
|
5716
7257
|
e.sensitivity === 'sensitive' ? h(Tag, { tone: 'warn' }, t('lexiconSensitive')) : null),
|
|
5717
7258
|
h('p', { style: { margin: 0, fontSize: 12.5, lineHeight: 1.55, overflowWrap: 'anywhere', display: '-webkit-box', WebkitLineClamp: 3, WebkitBoxOrient: 'vertical', overflow: 'hidden' } },
|
|
@@ -5804,7 +7345,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5804
7345
|
error && typeof error === 'string' ? h('div', { className: 'dshm-error', role: 'alert' }, error) : null,
|
|
5805
7346
|
notice && typeof notice === 'string' ? h('div', { style: { ...S.muted, marginTop: 6, color: V.accent } }, notice) : null,
|
|
5806
7347
|
items.length === 0
|
|
5807
|
-
? h(Empty, null, query || kind ? t('lexiconNoMatch')
|
|
7348
|
+
? h(Empty, null, query || kind || domain ? t('lexiconNoMatch')
|
|
5808
7349
|
: status === 'archived' ? t('lexiconArchivedEmpty') : t('lexiconEmpty'))
|
|
5809
7350
|
: h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(280px, 100%), 1fr))', gap: 10, marginTop: 10 } }, items.map(renderCard)),
|
|
5810
7351
|
pager)),
|
|
@@ -5843,6 +7384,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5843
7384
|
const [globalFiles, setGlobalFiles] = React.useState([])
|
|
5844
7385
|
const [globalLoaded, setGlobalLoaded] = React.useState(false)
|
|
5845
7386
|
const [selected, setSelected] = React.useState([])
|
|
7387
|
+
const [curationParent, setCurationParent] = React.useState('')
|
|
5846
7388
|
const [job, setJob] = React.useState(null)
|
|
5847
7389
|
const [error, setError] = React.useState('')
|
|
5848
7390
|
const [busy, setBusy] = React.useState(false)
|
|
@@ -5868,6 +7410,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5868
7410
|
? (SETTINGS_PAGES.includes(String(window.location.hash || '').replace(/^#\/settings\//, ''))
|
|
5869
7411
|
? SETTINGS_PAGES.indexOf(String(window.location.hash || '').replace(/^#\/settings\//, '')) : PAGE.memories)
|
|
5870
7412
|
: 0)
|
|
7413
|
+
const curationKey = JSON.stringify([curationParent, selected, page])
|
|
7414
|
+
const curationSelection = React.useRef(null)
|
|
7415
|
+
if (curationSelection.current?.key !== curationKey) curationSelection.current = { key: curationKey }
|
|
7416
|
+
const curationOwner = curationSelection.current
|
|
7417
|
+
const curationPending = React.useRef(false)
|
|
7418
|
+
React.useEffect(() => () => { curationSelection.current = null }, [])
|
|
5871
7419
|
const pendingSettings = React.useRef({})
|
|
5872
7420
|
// 保存失败的 patch 单独存放:绝不放回 pending(否则 adoptState 每次心跳把
|
|
5873
7421
|
// 失败值盖到服务端返回值上,永远回滚不了),并驱动一个不自动消失的标记。
|
|
@@ -5899,39 +7447,55 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5899
7447
|
const [diagRows, setDiagRows] = React.useState([])
|
|
5900
7448
|
const [diagStats, setDiagStats] = React.useState(null)
|
|
5901
7449
|
const [diagEnv, setDiagEnv] = React.useState(null)
|
|
7450
|
+
const [diagReport, setDiagReport] = React.useState(null)
|
|
5902
7451
|
const [diagBusy, setDiagBusy] = React.useState(false)
|
|
5903
7452
|
const [diagNotice, setDiagNotice] = React.useState('')
|
|
5904
7453
|
const [diagLevel, setDiagLevel] = React.useState('')
|
|
5905
7454
|
const [diagQueryInput, setDiagQueryInput] = React.useState('')
|
|
5906
7455
|
const [diagQuery, setDiagQuery] = React.useState('')
|
|
7456
|
+
const [helpStep, setHelpStep] = React.useState('helpStep1')
|
|
7457
|
+
const diagRequest = React.useRef(0)
|
|
5907
7458
|
// 启动提醒:只在主页弹一次;确认后写进服务端的 acknowledged.json,之后的"新"按
|
|
5908
7459
|
// 累积次数判断,所以同一问题不会每次开机都弹。
|
|
5909
7460
|
const [startupAlerts, setStartupAlerts] = React.useState([])
|
|
5910
7461
|
const loadDiagnostics = React.useCallback(async (withCheck = false) => {
|
|
7462
|
+
const request = ++diagRequest.current
|
|
5911
7463
|
setDiagBusy(true)
|
|
5912
7464
|
try {
|
|
5913
|
-
const
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
7465
|
+
const results = await Promise.allSettled([
|
|
7466
|
+
call('getDiagnostics', { limit: 300, level: diagLevel || undefined, q: diagQuery || undefined }),
|
|
7467
|
+
call('getDiagnosticReport', { limit: 100 }),
|
|
7468
|
+
withCheck || !diagEnv ? call('runEnvironmentCheck', {}) : Promise.resolve(null),
|
|
7469
|
+
])
|
|
7470
|
+
if (request !== diagRequest.current) return
|
|
7471
|
+
if (results[0].status === 'fulfilled') {
|
|
7472
|
+
const data = results[0].value
|
|
7473
|
+
setDiagRows(Array.isArray(data?.items) ? data.items : [])
|
|
7474
|
+
setDiagStats(data?.stats || null)
|
|
7475
|
+
}
|
|
7476
|
+
if (results[1].status === 'fulfilled') setDiagReport(results[1].value)
|
|
7477
|
+
if (results[2].status === 'fulfilled' && results[2].value) setDiagEnv(results[2].value)
|
|
7478
|
+
setDiagNotice(results.filter(result => result.status === 'rejected').map(result => String(result.reason?.message || result.reason)).join('; '))
|
|
7479
|
+
} catch (error) { if (request === diagRequest.current) setDiagNotice(String(error?.message || error)) }
|
|
7480
|
+
finally { if (request === diagRequest.current) setDiagBusy(false) }
|
|
5922
7481
|
}, [call, diagLevel, diagQuery, diagEnv])
|
|
5923
|
-
React.useEffect(() => {
|
|
7482
|
+
React.useEffect(() => {
|
|
7483
|
+
if (page !== PAGE.diagnostics) return undefined
|
|
7484
|
+
void loadDiagnostics()
|
|
7485
|
+
return () => { diagRequest.current++ }
|
|
7486
|
+
}, [loadDiagnostics, page])
|
|
5924
7487
|
const runRepair = React.useCallback(async (actions) => {
|
|
5925
7488
|
if (!Array.isArray(actions) || !actions.length) return
|
|
5926
7489
|
setDiagBusy(true)
|
|
5927
7490
|
try {
|
|
5928
7491
|
const outcome = await call('repairEnvironment', { actions, confirmed: true })
|
|
5929
7492
|
const failed = (outcome?.results || []).filter(result => !result.ok)
|
|
5930
|
-
|
|
7493
|
+
const message = failed.length
|
|
5931
7494
|
? `${t('diagRepairFailedMsg')}: ${failed.map(result => `${result.action} ${result.detail}`).join('; ')}`
|
|
5932
|
-
: t('diagRepairDone')
|
|
7495
|
+
: t('diagRepairDone')
|
|
5933
7496
|
setDiagEnv(outcome?.after || null)
|
|
5934
7497
|
await loadDiagnostics()
|
|
7498
|
+
setDiagNotice(message)
|
|
5935
7499
|
} catch (error) { setDiagNotice(String(error?.message || error)) } finally { setDiagBusy(false) }
|
|
5936
7500
|
}, [call, loadDiagnostics, t])
|
|
5937
7501
|
React.useEffect(() => {
|
|
@@ -5971,41 +7535,25 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5971
7535
|
const [expandedFolders, setExpandedFolders] = React.useState(() => new Set())
|
|
5972
7536
|
const [folderSessions, setFolderSessions] = React.useState({})
|
|
5973
7537
|
const [newLibName, setNewLibName] = React.useState('')
|
|
5974
|
-
const [
|
|
5975
|
-
const [
|
|
5976
|
-
const [browseSource, setBrowseSource] = React.useState('')
|
|
5977
|
-
// Same stale-reply guard as the wall: the browser page can be pointed at a
|
|
5978
|
-
// different library while its previous request is still in flight.
|
|
5979
|
-
const browseLibraryRequest = React.useRef(0)
|
|
7538
|
+
const [entryLibraryId] = React.useState(() => standalone ? new URLSearchParams(window.location.search).get('libraryId') || '' : '')
|
|
7539
|
+
const [browseLibId, setBrowseLibId] = React.useState(entryLibraryId)
|
|
5980
7540
|
const reviewsRequest = React.useRef(0)
|
|
5981
7541
|
const statsRequest = React.useRef(0)
|
|
5982
|
-
// 浏览页一次挂载多少张卡:先 60 张,滚到底自动追加。几百张卡一次性建完
|
|
5983
|
-
// 会明显卡(每张卡有 6 个可编辑控件),而它们之间没有共享状态。
|
|
5984
|
-
const [browseShown, setBrowseShown] = React.useState(60)
|
|
5985
|
-
const browseMoreRef = React.useRef(null)
|
|
5986
|
-
// 渲染期写入、effect 只读:archShown 在 loading 分支之后才定义,而 hook
|
|
5987
|
-
// 顺序契约要求 effect 必须放在那之前(见下方 Hook order 注释)。
|
|
5988
|
-
const browseTotalRef = React.useRef(0)
|
|
5989
7542
|
const [browseBusy, setBrowseBusy] = React.useState(false)
|
|
5990
7543
|
// 'active' | 'archived'. Archiving used to be a one-way door in the UI: the entry
|
|
5991
7544
|
// stayed in the same list with a different tag, so the mess you were trying to
|
|
5992
7545
|
// tidy up never actually left. Two lists, and only the archived one offers delete.
|
|
5993
7546
|
const [browseView, setBrowseView] = React.useState('active')
|
|
5994
|
-
// 当前库内的即时过滤:列表本来就已取回(browseLibrary),不再加一次 RPC。
|
|
5995
7547
|
const [browseQuery, setBrowseQuery] = React.useState('')
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
}, { rootMargin: '600px 0px' })
|
|
6006
|
-
observer.observe(node)
|
|
6007
|
-
return () => observer.disconnect()
|
|
6008
|
-
}, [browseShown, browseView, browseQuery, browseLibId])
|
|
7548
|
+
const [browseDomain, setBrowseDomain] = React.useState('')
|
|
7549
|
+
const browseSearch = useDebouncedValue(browseQuery.trim())
|
|
7550
|
+
const browsePager = useMemoryPages({ call, method: 'browseLibrary', rowsKey: 'files', nextLimit: 120,
|
|
7551
|
+
enabled: page === PAGE.browser && !!browseLibId && browseQuery.trim() === browseSearch,
|
|
7552
|
+
payload: { libraryId: browseLibId, sessionId: sessionId || undefined, query: browseSearch || undefined,
|
|
7553
|
+
domain: browseDomain || undefined, status: memoryPoolStatus(browseView) },
|
|
7554
|
+
refreshKey: `${state?.revision ?? ''}:${state?.stamp ?? ''}` })
|
|
7555
|
+
const browseFiles = browsePager.data.files || []
|
|
7556
|
+
const browseSource = browsePager.data.source || ''
|
|
6009
7557
|
// Permanent deletion is two clicks, and only for the row that was armed.
|
|
6010
7558
|
const [deleteArmed, setDeleteArmed] = React.useState('')
|
|
6011
7559
|
React.useEffect(() => {
|
|
@@ -6333,18 +7881,6 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6333
7881
|
if (mode !== 'host' && mode !== 'custom') return
|
|
6334
7882
|
if (forkCatalogState === 'idle') void loadForkCatalog()
|
|
6335
7883
|
}, [state?.settings?.consolidationModelMode, forkCatalogState, loadForkCatalog])
|
|
6336
|
-
React.useEffect(() => {
|
|
6337
|
-
if (page !== PAGE.browser || !browseLibId) return undefined
|
|
6338
|
-
let alive = true
|
|
6339
|
-
const requestId = ++browseLibraryRequest.current
|
|
6340
|
-
const current = () => alive && requestId === browseLibraryRequest.current
|
|
6341
|
-
void call('browseLibrary', { libraryId: browseLibId, sessionId: sessionId || undefined }).then(result => {
|
|
6342
|
-
if (!current()) return
|
|
6343
|
-
setBrowseFiles(result.files || [])
|
|
6344
|
-
setBrowseSource(result.source || '')
|
|
6345
|
-
}).catch(error => { if (current()) setError(String(error.message || error)) })
|
|
6346
|
-
return () => { alive = false }
|
|
6347
|
-
}, [call, page, browseLibId, sessionId, state?.revision, state?.stamp])
|
|
6348
7884
|
// Statistics are per library and read the whole index for the scatter, so they
|
|
6349
7885
|
// load only when that page is open. Every settings refresh (a heartbeat heard a
|
|
6350
7886
|
// write) re-reads them, which is what keeps the page honest.
|
|
@@ -6508,17 +8044,23 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6508
8044
|
await loadPrompts()
|
|
6509
8045
|
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
6510
8046
|
}
|
|
6511
|
-
const
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
if (
|
|
8047
|
+
const startSelectedCuration = async () => {
|
|
8048
|
+
if (curationSelection.current !== curationOwner || curationPending.current) return
|
|
8049
|
+
const parent = sessions.find((s) => s.id === curationParent && s.live)?.id
|
|
8050
|
+
if (!parent) { setError(t('curationExecutorPick')); return }
|
|
8051
|
+
const sessionIds = [...selected]
|
|
8052
|
+
if (sessionIds.length === 0) return
|
|
8053
|
+
curationPending.current = true
|
|
6515
8054
|
setBusy(true)
|
|
6516
8055
|
try {
|
|
6517
|
-
const created = await call('generateGlobal', { sessionId: parent, sessionIds
|
|
8056
|
+
const created = await call('generateGlobal', { sessionId: parent, sessionIds })
|
|
8057
|
+
if (curationSelection.current !== curationOwner) return
|
|
6518
8058
|
setJob(created)
|
|
6519
8059
|
setSelected([])
|
|
6520
8060
|
await refresh()
|
|
6521
|
-
} catch (e) {
|
|
8061
|
+
} catch (e) {
|
|
8062
|
+
if (curationSelection.current === curationOwner) setError(String(e?.message || e))
|
|
8063
|
+
} finally { curationPending.current = false; setBusy(false) }
|
|
6522
8064
|
}
|
|
6523
8065
|
const setSetting = (key, value) => {
|
|
6524
8066
|
setState((prev) => prev ? { ...prev, settings: { ...prev.settings, [key]: value } } : prev)
|
|
@@ -6597,26 +8139,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6597
8139
|
setBusy(true)
|
|
6598
8140
|
try {
|
|
6599
8141
|
await call('deleteLibrary', { libraryId: lib.id })
|
|
6600
|
-
if (browseLibId === lib.id)
|
|
8142
|
+
if (browseLibId === lib.id) setBrowseLibId('')
|
|
6601
8143
|
await refresh()
|
|
6602
8144
|
} catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
|
|
6603
8145
|
}
|
|
6604
8146
|
const openBrowser = async (libraryId) => {
|
|
6605
8147
|
const id = libraryId || browseLibId
|
|
6606
8148
|
if (!id) return
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
// same counter when browseLibId changes) cannot be overwritten by this one.
|
|
6611
|
-
const requestId = ++browseLibraryRequest.current
|
|
6612
|
-
try {
|
|
6613
|
-
const res = await call('browseLibrary', { libraryId: id })
|
|
6614
|
-
if (requestId !== browseLibraryRequest.current) return
|
|
6615
|
-
setBrowseFiles(res?.files || [])
|
|
6616
|
-
setBrowseSource(res?.source || 'engine')
|
|
6617
|
-
setBrowseShown(60)
|
|
6618
|
-
setDeleteArmed('')
|
|
6619
|
-
} catch (e) { if (requestId === browseLibraryRequest.current) setError(String(e?.message || e)) } finally { if (requestId === browseLibraryRequest.current) setBrowseBusy(false) }
|
|
8149
|
+
setDeleteArmed('')
|
|
8150
|
+
if (id !== browseLibId) { setBrowseLibId(id); return }
|
|
8151
|
+
await browsePager.reload()
|
|
6620
8152
|
}
|
|
6621
8153
|
const openBrowserFromLibrary = (libraryId) => {
|
|
6622
8154
|
setPage(PAGE.browser)
|
|
@@ -7659,6 +9191,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7659
9191
|
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)) })),
|
|
7660
9192
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('freshnessHintHint')),
|
|
7661
9193
|
h(Field, { label: t('habitsInjection') }, h(Toggle, { checked: settings.habitsInjection !== false, label: t('habitsInjection'), onChange: value => setSetting('habitsInjection', value) }))),
|
|
9194
|
+
settingsGroup(t('midTurnRecall'), t('midTurnHint'),
|
|
9195
|
+
h(Field, { label: t('midTurnRecall') }, h(Toggle, { checked: settings.midTurnRecall !== false, label: t('midTurnRecall'), onChange: value => setSetting('midTurnRecall', value) })),
|
|
9196
|
+
h(Field, { label: t('midTurnMinSteps') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 1, max: 64, value: settings.midTurnMinSteps ?? 4, onChange: e => setSetting('midTurnMinSteps', Number(e.target.value)) })),
|
|
9197
|
+
h(Field, { label: t('midTurnMinUnits') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 1, max: 200, value: settings.midTurnMinUnits ?? 3, onChange: e => setSetting('midTurnMinUnits', Number(e.target.value)) })),
|
|
9198
|
+
h(Field, { label: t('midTurnMinChars') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 0, max: 200000, value: settings.midTurnMinChars ?? 6000, onChange: e => setSetting('midTurnMinChars', Number(e.target.value)) })),
|
|
9199
|
+
h(Field, { label: t('midTurnMaxPerTurn') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 1, max: 10, value: settings.midTurnMaxPerTurn ?? 2, onChange: e => setSetting('midTurnMaxPerTurn', Number(e.target.value)) })),
|
|
9200
|
+
h(Field, { label: t('midTurnCooldownMs') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 0, max: 600000, value: settings.midTurnCooldownMs ?? 60000, onChange: e => setSetting('midTurnCooldownMs', Number(e.target.value)) })),
|
|
9201
|
+
h(Field, { label: t('midTurnTokens') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 120, max: 2000, value: settings.midTurnTokens ?? 400, onChange: e => setSetting('midTurnTokens', Number(e.target.value)) })),
|
|
9202
|
+
h(Field, { label: t('midTurnFullUnits') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 1, max: 200, value: settings.midTurnFullUnits ?? 6, onChange: e => setSetting('midTurnFullUnits', Number(e.target.value)) })),
|
|
9203
|
+
h(Field, { label: t('midTurnFullChars') }, h('input', { className: 'dshm-setting-input', type: 'number', min: 0, max: 200000, value: settings.midTurnFullChars ?? 15000, onChange: e => setSetting('midTurnFullChars', Number(e.target.value)) }))),
|
|
7662
9204
|
settingsGroup(t('settingsGroupLifecycle'), t('settingsGroupLifecycleDesc'),
|
|
7663
9205
|
h(Field, { label: t('mustRememberCap') }, h('input', { type: 'number', style: S.input, value: settings.mustRememberCap ?? 12, onChange: (e) => setSetting('mustRememberCap', Number(e.target.value)) })),
|
|
7664
9206
|
h(Field, { label: t('shortTermTtlHours') }, h('input', { type: 'number', min: 0, style: S.input, value: settings.shortTermTtlHours ?? 72, onChange: (e) => setSetting('shortTermTtlHours', Number(e.target.value)) })),
|
|
@@ -7683,6 +9225,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7683
9225
|
h('option', { value: 'fork' }, t('consolidationRunnerFork')),
|
|
7684
9226
|
h('option', { value: 'worker' }, t('consolidationRunnerWorker')))),
|
|
7685
9227
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('consolidationRunnerHint')),
|
|
9228
|
+
h(Field, { label: t('consolidationTurnLog') }, h('select', { className: 'dshm-setting-input', 'aria-label': t('consolidationTurnLog'), value: settings.consolidationTurnLog || 'on',
|
|
9229
|
+
onChange: e => setSetting('consolidationTurnLog', e.target.value) },
|
|
9230
|
+
h('option', { value: 'on' }, t('turnLogOn')), h('option', { value: 'off' }, t('turnLogOff')))),
|
|
9231
|
+
h(Field, { label: t('consolidationTurnLogTools') }, h('select', { className: 'dshm-setting-input', 'aria-label': t('consolidationTurnLogTools'), value: settings.consolidationTurnLogTools || 'none',
|
|
9232
|
+
onChange: e => setSetting('consolidationTurnLogTools', e.target.value) },
|
|
9233
|
+
h('option', { value: 'none' }, t('turnLogNone')), h('option', { value: 'errors' }, t('turnLogErrors')), h('option', { value: 'summary' }, t('turnLogSummary')))),
|
|
7686
9234
|
h(Field, { label: t('consolidationModelMode') },
|
|
7687
9235
|
h('select', { style: S.input, value: consolidationMode, onChange: (e) => setSetting('consolidationModelMode', e.target.value) },
|
|
7688
9236
|
h('option', { value: 'inherit' }, t('consolidationModeInherit')),
|
|
@@ -7706,43 +9254,80 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7706
9254
|
h(Field, { label: t('salientWakeHour') }, h('input', { type: 'time', style: S.input, value: settings.salientWakeHour || '09:00', onChange: (e) => setSetting('salientWakeHour', e.target.value) })),
|
|
7707
9255
|
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) })),
|
|
7708
9256
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('salientWakeHint'))),
|
|
9257
|
+
settingsGroup(t('settingsGroupRetention'), t('settingsGroupRetentionDesc'),
|
|
9258
|
+
h(Field, { label: t('retentionDryRun') }, h(Toggle, { checked: settings.retentionDryRun !== false, label: t('retentionDryRun'), onChange: value => setSetting('retentionDryRun', value) })),
|
|
9259
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('retentionHint')),
|
|
9260
|
+
h(Field, { label: t('retentionBoundTurnLogsEnabled') }, h(Toggle, { checked: settings.retentionBoundTurnLogsEnabled !== false, label: t('retentionBoundTurnLogsEnabled'), onChange: value => setSetting('retentionBoundTurnLogsEnabled', value) })),
|
|
9261
|
+
h(Field, { label: t('retentionBoundTurnLogDays') }, h('input', { type: 'number', min: 1, max: 36500, style: S.input, value: settings.retentionBoundTurnLogDays ?? 30, onChange: e => setSetting('retentionBoundTurnLogDays', Number(e.target.value)) })),
|
|
9262
|
+
h(Field, { label: t('retentionOrphanTurnLogsEnabled') }, h(Toggle, { checked: settings.retentionOrphanTurnLogsEnabled === true, label: t('retentionOrphanTurnLogsEnabled'), onChange: value => setSetting('retentionOrphanTurnLogsEnabled', value) })),
|
|
9263
|
+
h(Field, { label: t('retentionOrphanTurnLogDays') }, h('input', { type: 'number', min: 1, max: 36500, style: S.input, value: settings.retentionOrphanTurnLogDays ?? 90, onChange: e => setSetting('retentionOrphanTurnLogDays', Number(e.target.value)) })),
|
|
9264
|
+
h(Field, { label: t('retentionMaintenanceLedgerEnabled') }, h(Toggle, { checked: settings.retentionMaintenanceLedgerEnabled !== false, label: t('retentionMaintenanceLedgerEnabled'), onChange: value => setSetting('retentionMaintenanceLedgerEnabled', value) })),
|
|
9265
|
+
h(Field, { label: t('retentionMaintenanceLedgerDays') }, h('input', { type: 'number', min: 1, max: 36500, style: S.input, value: settings.retentionMaintenanceLedgerDays ?? 180, onChange: e => setSetting('retentionMaintenanceLedgerDays', Number(e.target.value)) })),
|
|
9266
|
+
h(Field, { label: t('retentionSessionBindingsEnabled') }, h(Toggle, { checked: settings.retentionSessionBindingsEnabled === true, label: t('retentionSessionBindingsEnabled'), onChange: value => setSetting('retentionSessionBindingsEnabled', value) })),
|
|
9267
|
+
h(Field, { label: t('retentionSessionBindingDays') }, h('input', { type: 'number', min: 1, max: 36500, style: S.input, value: settings.retentionSessionBindingDays ?? 180, onChange: e => setSetting('retentionSessionBindingDays', Number(e.target.value)) })),
|
|
9268
|
+
h(Field, { label: t('retentionVectorPruneEnabled') }, h(Toggle, { checked: settings.retentionVectorPruneEnabled !== false, label: t('retentionVectorPruneEnabled'), onChange: value => setSetting('retentionVectorPruneEnabled', value) })),
|
|
9269
|
+
h(Field, { label: t('retentionVectorKeepGenerations') }, h('input', { type: 'number', min: 1, max: 100, style: S.input, value: settings.retentionVectorKeepGenerations ?? 2, onChange: e => setSetting('retentionVectorKeepGenerations', Number(e.target.value)) })),
|
|
9270
|
+
h(Field, { label: t('retentionVectorDays') }, h('input', { type: 'number', min: 1, max: 36500, style: S.input, value: settings.retentionVectorDays ?? 7, onChange: e => setSetting('retentionVectorDays', Number(e.target.value)) }))),
|
|
7709
9271
|
settingsGroup(t('settingsGroupEngine'), t('settingsGroupEngineDesc'),
|
|
7710
9272
|
h(Field, { label: t('memoryMode') },
|
|
7711
9273
|
h('select', { style: S.input, value: settings.memoryMode || 'local', onChange: (e) => setSetting('memoryMode', e.target.value) },
|
|
7712
9274
|
['local', 'cloud'].map((v) => h('option', { key: v, value: v }, v)))),
|
|
7713
9275
|
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('memoryModeHint')),
|
|
7714
|
-
h(Field, { label: t('autoInstall') }, h(Toggle, { checked: settings.autoInstallEngine !== false, label: t('autoInstall'), onChange: value => setSetting('autoInstallEngine', value) }))
|
|
9276
|
+
h(Field, { label: t('autoInstall') }, h(Toggle, { checked: settings.autoInstallEngine !== false, label: t('autoInstall'), onChange: value => setSetting('autoInstallEngine', value) })),
|
|
9277
|
+
h(Field, { label: t('pipIndexes') }, h(PipIndexesInput, { values: settings.pipIndexes || [], onChange: values => setSetting('pipIndexes', values), t })),
|
|
9278
|
+
h('p', { className: 'dshm-settings-note' }, t('pipIndexesHint')),
|
|
9279
|
+
h(Field, { label: t('engineSource') },
|
|
9280
|
+
h('select', { style: S.input, value: settings.engineSource || 'auto', onChange: e => setSetting('engineSource', e.target.value) },
|
|
9281
|
+
h('option', { value: 'auto' }, t('engineSourceAuto')),
|
|
9282
|
+
h('option', { value: 'mirror' }, t('engineSourceMirror')),
|
|
9283
|
+
h('option', { value: 'official' }, t('engineSourceOfficial')),
|
|
9284
|
+
h('option', { value: 'custom' }, t('engineSourceCustom')))),
|
|
9285
|
+
h('p', { className: 'dshm-settings-note' }, t('engineSourceHint')),
|
|
9286
|
+
h(Field, { label: t('engineUvMirror') }, h('input', { type: 'text', style: S.input, placeholder: 'https://\u2026/astral-sh/uv', value: settings.engineUvMirror || '', onChange: e => setSetting('engineUvMirror', e.target.value) })),
|
|
9287
|
+
h('p', { className: 'dshm-settings-note' }, t('engineUvMirrorHint')),
|
|
9288
|
+
h(Field, { label: t('enginePythonMirror') }, h('input', { type: 'text', style: S.input, placeholder: 'https://\u2026/python-build-standalone', value: settings.enginePythonMirror || '', onChange: e => setSetting('enginePythonMirror', e.target.value) })),
|
|
9289
|
+
h('p', { className: 'dshm-settings-note' }, t('enginePythonMirrorHint')),
|
|
9290
|
+
h(Field, { label: t('engineAllowUnpinned') }, h(Toggle, { checked: settings.engineAllowUnpinned === true, label: t('engineAllowUnpinned'), onChange: value => setSetting('engineAllowUnpinned', value) })),
|
|
9291
|
+
h('p', { className: 'dshm-settings-note' }, t('engineAllowUnpinnedHint'))),
|
|
7715
9292
|
settingsGroup(t('settingsGroupSession'), t('settingsGroupSessionDesc'),
|
|
7716
9293
|
h(Field, { label: t('newSessionPrompt') }, h(Toggle, { checked: settings.newSessionPromptDismissed !== true, label: t('newSessionPrompt'), onChange: value => setSetting('newSessionPromptDismissed', !value) })),
|
|
9294
|
+
h(Field, { label: t('newSessionDefault') }, h('select', { className: 'dshm-setting-input', 'aria-label': t('newSessionDefault'), value: settings.newSessionDefault || 'both',
|
|
9295
|
+
onChange: e => setSetting('newSessionDefault', e.target.value) },
|
|
9296
|
+
h('option', { value: 'off' }, t('sessionDefaultOff')), h('option', { value: 'auto' }, t('sessionDefaultAuto')),
|
|
9297
|
+
h('option', { value: 'global' }, t('sessionDefaultGlobal')), h('option', { value: 'both' }, t('sessionDefaultBoth')))),
|
|
7717
9298
|
h(Field, { label: t('sidebarSettings') }, h(Toggle, { checked: settings.sidebarSettings === true, label: t('sidebarSettings'), onChange: value => setSetting('sidebarSettings', value) })),
|
|
7718
9299
|
h(Field, { label: t('visionCaptionEnabled') }, h(Toggle, { checked: settings.visionCaptionEnabled === true, label: t('visionCaptionEnabled'), onChange: value => setSetting('visionCaptionEnabled', value) }))),
|
|
7719
9300
|
settingsGroup(t('settingsGroupIntegration'), t('settingsGroupIntegrationDesc'),
|
|
7720
9301
|
h(Field, { label: t('inboundToolNames') }, h(InboundToolsInput, {
|
|
7721
9302
|
names: settings.inboundToolNames || [], onChange: values => setSetting('inboundToolNames', values),
|
|
7722
9303
|
}))),
|
|
9304
|
+
settingsGroup(t('policyReadonly'), t('policyReadonlyHint'),
|
|
9305
|
+
...['activeMemoryMinScore', 'activeMemoryStarvationMinutes', 'activeMemoryCooldownMinutes', 'activeMemoryRecallCooldownMinutes',
|
|
9306
|
+
'unpinBudgetPerSession', 'unpinCooldownMinutes'].map(key => h(Field, { key, label: t(key) },
|
|
9307
|
+
h('output', { 'aria-label': t(key) }, settings[key] == null ? '—' : String(settings[key]))))),
|
|
7723
9308
|
h(Section, { title: t('visionService') }, h(VisionConfigPanel, { call, config: state.visionConfig, t })))
|
|
7724
9309
|
|
|
7725
9310
|
const renderLibraryItem = (lib) => h('div', { key: lib.id, style: S.item },
|
|
7726
|
-
h('div', {
|
|
7727
|
-
h('div', {
|
|
9311
|
+
h('div', { className: 'dshm-library-head' },
|
|
9312
|
+
h('div', { className: 'dshm-library-identity' },
|
|
7728
9313
|
h('strong', null, lib.name || lib.id),
|
|
7729
9314
|
h('div', { style: S.muted }, lib.id)),
|
|
7730
|
-
h('div', {
|
|
9315
|
+
h('div', { className: 'dshm-library-actions' },
|
|
7731
9316
|
consolidateButton(lib.id),
|
|
7732
9317
|
h(Button, { onClick: () => openBrowserFromLibrary(lib.id) }, t('browse')),
|
|
7733
9318
|
h(Button, { onClick: () => archiveLibrary(lib.id), disabled: busy }, t('archive')))),
|
|
7734
|
-
h('div', { style: S.muted }, `${t('scope')}: ${lib.scopeKey || '—'}`),
|
|
9319
|
+
h('div', { className: 'dshm-library-scope', style: S.muted }, `${t('scope')}: ${lib.scopeKey || '—'}`),
|
|
7735
9320
|
h('div', { style: S.row },
|
|
7736
9321
|
h(Tag, null, `${t('privateCount')}: ${lib.privateCount ?? 0}`),
|
|
7737
9322
|
h(Tag, null, `${t('pinned')}: ${lib.pinnedCount ?? 0}`),
|
|
7738
9323
|
h(Tag, null, `${t('bound')}: ${lib.boundSessions ?? 0}`)))
|
|
7739
9324
|
|
|
7740
9325
|
const renderArchivedItem = (lib) => h('div', { key: lib.id, style: S.item },
|
|
7741
|
-
h('div', {
|
|
7742
|
-
h('div', {
|
|
9326
|
+
h('div', { className: 'dshm-library-head' },
|
|
9327
|
+
h('div', { className: 'dshm-library-identity' },
|
|
7743
9328
|
h('strong', null, lib.name || lib.id),
|
|
7744
9329
|
h('div', { style: S.muted }, `${t('scope')}: ${lib.scopeKey || '—'}`)),
|
|
7745
|
-
h('div', {
|
|
9330
|
+
h('div', { className: 'dshm-library-actions' },
|
|
7746
9331
|
h(Button, { onClick: () => restoreLibraryNow(lib.id), disabled: busy, style: S.ghost }, t('restore')),
|
|
7747
9332
|
h(Button, { onClick: () => deleteLibraryNow(lib), disabled: busy, style: S.ghost }, actionLabel('library:' + lib.id, t('deleteLibrary'))))),
|
|
7748
9333
|
h('div', { style: S.row },
|
|
@@ -7751,6 +9336,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7751
9336
|
lib.archivedAt ? h('span', { style: S.muted }, `${String(lib.archivedAt).slice(0, 10)}`) : null))
|
|
7752
9337
|
|
|
7753
9338
|
const librariesBlock = h(React.Fragment, null,
|
|
9339
|
+
standalone && page === PAGE.libraries ? h(SessionActionsPanel, { call, libraries: state.libraries || [], refreshKey: `${state.revision}:${state.stamp}`, t }) : null,
|
|
7754
9340
|
h(Section, { title: t('newLibrary') },
|
|
7755
9341
|
h('div', { style: S.row },
|
|
7756
9342
|
h('input', {
|
|
@@ -7835,7 +9421,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7835
9421
|
h('input', {
|
|
7836
9422
|
type: 'checkbox',
|
|
7837
9423
|
checked: selected.includes(s.id),
|
|
7838
|
-
onChange: (e) => setSelected((prev) => e.target.checked ? [...prev, s.id] : prev.filter((id) => id !== s.id)),
|
|
9424
|
+
onChange: (e) => { curationSelection.current = null; setSelected((prev) => e.target.checked ? [...prev, s.id] : prev.filter((id) => id !== s.id)) },
|
|
7839
9425
|
}),
|
|
7840
9426
|
h('div', { style: { minWidth: 0 } },
|
|
7841
9427
|
h('div', null, sessionLabel(s), s.live ? h('span', { style: S.muted }, ' · live') : null),
|
|
@@ -7901,12 +9487,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
7901
9487
|
h(Section, {
|
|
7902
9488
|
title: t('curation'),
|
|
7903
9489
|
right: h(Button, {
|
|
7904
|
-
onClick:
|
|
7905
|
-
disabled: busy || selected.length === 0 || !sessions.some((x) => x.live),
|
|
9490
|
+
onClick: startSelectedCuration,
|
|
9491
|
+
disabled: busy || selected.length === 0 || !sessions.some((x) => x.id === curationParent && x.live),
|
|
7906
9492
|
primary: true,
|
|
7907
9493
|
}, `${t('startCuration')} (${selected.length})`),
|
|
7908
9494
|
},
|
|
7909
9495
|
!sessions.some((x) => x.live) ? h('div', { style: S.muted }, t('noLiveSession')) : null,
|
|
9496
|
+
h(Field, { label: t('curationExecutor') },
|
|
9497
|
+
h('select', { className: 'dshm-setting-input', value: sessions.some((x) => x.id === curationParent && x.live) ? curationParent : '',
|
|
9498
|
+
'aria-label': t('curationExecutor'), disabled: !sessions.some((x) => x.live),
|
|
9499
|
+
onChange: (e) => { curationSelection.current = null; setCurationParent(e.target.value) } },
|
|
9500
|
+
h('option', { value: '' }, t('curationExecutorPick')),
|
|
9501
|
+
sessions.filter((x) => x.live).map((s) => h('option', { key: s.id, value: s.id }, sessionLabel(s))))),
|
|
9502
|
+
h('p', { className: 'dshm-settings-note' }, t('curationExecutorHint')),
|
|
9503
|
+
h('div', { className: 'dshm-settings-note' }, t('curationSources')),
|
|
7910
9504
|
h('div', { style: { ...S.list, maxHeight: 320, overflow: 'auto', marginTop: 8 } },
|
|
7911
9505
|
sessions.filter((x) => x.origin !== 'subagent').map(renderSessionChoice)
|
|
7912
9506
|
),
|
|
@@ -8017,16 +9611,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8017
9611
|
: null),
|
|
8018
9612
|
promptPageBody))
|
|
8019
9613
|
|
|
8020
|
-
const browsePool =
|
|
8021
|
-
|
|
8022
|
-
const
|
|
8023
|
-
const browseMatched = file => !browseQueryText
|
|
8024
|
-
|| [file.title, file.content, file.id, ...(Array.isArray(file.tags) ? file.tags : [])]
|
|
8025
|
-
.some(value => String(value || '').toLowerCase().includes(browseQueryText))
|
|
8026
|
-
const archShown = browseFiles.filter(file => browsePool(file) === browseView && browseMatched(file))
|
|
8027
|
-
// 供滚到底部自动追加用(effect 在 loading 分支之前,拿不到这里的局部值)。
|
|
8028
|
-
browseTotalRef.current = archShown.length
|
|
8029
|
-
const browseVisible = browseView === 'archived' ? archShown : archShown.slice(0, browseShown)
|
|
9614
|
+
const browsePool = memoryPool
|
|
9615
|
+
const archShown = browseFiles.filter(file => browsePool(file) === browseView)
|
|
9616
|
+
const browseVisible = archShown
|
|
8030
9617
|
// An archived row is a body you are deciding about, not a draft you are editing:
|
|
8031
9618
|
// no title/content/tag fields, just enough to recognise it plus the two exits.
|
|
8032
9619
|
const renderArchivedMemory = (f) => h('div', { key: f.id, style: S.item },
|
|
@@ -8092,19 +9679,22 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8092
9679
|
h('select', {
|
|
8093
9680
|
style: { ...S.input, flex: 1 }, value: browseLibId,
|
|
8094
9681
|
title: (state.libraries || []).find((lib) => lib.id === browseLibId)?.scopeKey || t('currentLibrary'),
|
|
8095
|
-
onChange: (e) => { setBrowseLibId(e.target.value); setBrowseQuery('');
|
|
9682
|
+
onChange: (e) => { setBrowseLibId(e.target.value); setBrowseQuery(''); setBrowseDomain('') },
|
|
8096
9683
|
}, (state.libraries || []).map((l) => h('option', { key: l.id, value: l.id }, libraryOptionLabel(l, state.libraries || []))))),
|
|
8097
9684
|
browseView === 'relations' ? null : h('div', { style: S.row },
|
|
8098
9685
|
h('span', { style: S.label }, t('browseSearch')),
|
|
8099
9686
|
h('input', {
|
|
8100
9687
|
style: { ...S.input, flex: 1 }, type: 'search', value: browseQuery,
|
|
8101
9688
|
placeholder: t('browseSearchPlaceholder'), 'aria-label': t('browseSearch'),
|
|
8102
|
-
onChange: (e) =>
|
|
9689
|
+
onChange: (e) => setBrowseQuery(e.target.value),
|
|
8103
9690
|
}),
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
9691
|
+
h('select', { value: browseDomain, title: t('wallDomainHint'), 'aria-label': t('wallFilterDomain'),
|
|
9692
|
+
onChange: event => setBrowseDomain(event.target.value) },
|
|
9693
|
+
h('option', { value: '' }, t('wallDomainAll')),
|
|
9694
|
+
[...new Set([...(browsePager.data.domains || []), browseDomain].filter(Boolean))].sort()
|
|
9695
|
+
.map(value => h('option', { key: value, value }, domainText(t, value)))),
|
|
9696
|
+
h('span', { className: 'dshm-settings-note', role: 'status' },
|
|
9697
|
+
`${t('memoryLoaded')} ${browseFiles.length} / ${browsePager.data.total}`),
|
|
8108
9698
|
browseQuery
|
|
8109
9699
|
? h(Button, { style: S.ghost, onClick: () => setBrowseQuery(''), title: t('browseSearchClear') }, t('browseSearchClear'))
|
|
8110
9700
|
: null),
|
|
@@ -8114,23 +9704,28 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8114
9704
|
h('div', { className: 'dshm-nav-list is-row', role: 'tablist', style: { marginTop: 10 } },
|
|
8115
9705
|
[['active', t('browseActiveTab')], ['archived', t('browseArchivedTab')], ['review', t('poolReview')], ['inactive', t('poolInactive')], ['relations', t('relations')]].map((pair) => {
|
|
8116
9706
|
const value = pair[0]
|
|
8117
|
-
const count = browseFiles.filter(file => browsePool(file) === value
|
|
9707
|
+
const count = browseFiles.filter(file => browsePool(file) === value).length
|
|
8118
9708
|
return h('button', {
|
|
8119
9709
|
key: value,
|
|
8120
9710
|
type: 'button',
|
|
8121
9711
|
role: 'tab',
|
|
8122
9712
|
'aria-selected': browseView === value,
|
|
8123
9713
|
className: `dshm-nav-item${browseView === value ? ' on' : ''}`,
|
|
8124
|
-
onClick: () => { setBrowseView(value);
|
|
8125
|
-
}, value === 'relations' ? pair[1] : pair[1] + ' (' + count + ')')
|
|
9714
|
+
onClick: () => { setBrowseView(value); setDeleteArmed('') },
|
|
9715
|
+
}, value === 'relations' ? pair[1] : pair[1] + ' (' + t('memoryLoaded') + ' ' + count + ')')
|
|
8126
9716
|
})),
|
|
8127
9717
|
browseView === 'archived' && archShown.length > 0
|
|
8128
9718
|
? h('div', { style: { ...S.muted, marginTop: 6 } }, t('browseArchivedHint'))
|
|
8129
9719
|
: null,
|
|
8130
9720
|
browseView === 'relations'
|
|
8131
|
-
? h(
|
|
9721
|
+
? h('div', { className: 'dshm-graph-tools' },
|
|
9722
|
+
h(Tag, null, libraryOptionLabel((state.libraries || []).find(lib => lib.id === browseLibId) || { id: browseLibId }, state.libraries || [])),
|
|
9723
|
+
h(Button, { primary: true, disabled: !browseLibId, title: t('openGraphStudioHint'), onClick: () => {
|
|
9724
|
+
if (standalone) setPage(PAGE.graph)
|
|
9725
|
+
else openWebUiPage('graph', { libraryId: browseLibId })
|
|
9726
|
+
} }, t('openGraphStudio')))
|
|
8132
9727
|
: archShown.length === 0
|
|
8133
|
-
? h(Empty, null, browseView === 'archived' ? t('browseArchivedEmpty') : t('noMemoriesView'))
|
|
9728
|
+
? h(Empty, null, browsePager.loading ? t('loading') : browseView === 'archived' ? t('browseArchivedEmpty') : t('noMemoriesView'))
|
|
8134
9729
|
: h('div', { style: { ...S.list, marginTop: 10 } },
|
|
8135
9730
|
browseVisible.map(browseView === 'archived' ? renderArchivedMemory : (file) => h(BrowserMemoryCard, {
|
|
8136
9731
|
key: file.id,
|
|
@@ -8142,15 +9737,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8142
9737
|
onArchive: cardArchive,
|
|
8143
9738
|
onResolve: cardResolve,
|
|
8144
9739
|
onLoadFull: cardLoadFull,
|
|
8145
|
-
})),
|
|
8146
|
-
|
|
8147
|
-
? h('div', { ref: browseMoreRef, style: { ...S.muted, marginTop: 10 }, role: 'status' },
|
|
8148
|
-
h(Button, {
|
|
8149
|
-
onClick: () => setBrowseShown((count) => count + 120),
|
|
8150
|
-
style: S.ghost,
|
|
8151
|
-
title: t('browseLoadMore'),
|
|
8152
|
-
}, t('browseLoadMore') + ` (${browseVisible.length}/${archShown.length})`))
|
|
8153
|
-
: null)))
|
|
9740
|
+
}))),
|
|
9741
|
+
browseView !== 'relations' ? h(MemoryPageMore, { pager: browsePager, loaded: browseFiles.length, t }) : null))
|
|
8154
9742
|
|
|
8155
9743
|
const renderFolderItem = (folder) => {
|
|
8156
9744
|
const disabled = folderBusy === folder.scopeKey
|
|
@@ -8399,6 +9987,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8399
9987
|
h(Button, { style: S.ghost, onClick: () => setPage(PAGE.help) }, t('firstRunGuide'))))
|
|
8400
9988
|
: null
|
|
8401
9989
|
const memoriesBlock = h(React.Fragment, null, firstRunCard,
|
|
9990
|
+
h(EntityMergeReviewPanel, { call, libraries: state.libraries || [], initialLibraryId: entryLibraryId, t }),
|
|
8402
9991
|
h(MemoryWallPanel, { call, libraries: state.libraries || [], revision: state.revision, stamp: state.stamp, t,
|
|
8403
9992
|
indexed: localVector.vector?.indexed || null,
|
|
8404
9993
|
focus: wallFocus,
|
|
@@ -8415,6 +10004,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8415
10004
|
const graphBlock = standalone
|
|
8416
10005
|
? h(GraphStudioPanel, {
|
|
8417
10006
|
call, libraries: state.libraries || [], revision: state.revision, stamp: state.stamp, t,
|
|
10007
|
+
initialLibraryId: browseLibId,
|
|
8418
10008
|
navHidden: graphNavHidden, onToggleNav: () => setGraphNavHidden(value => !value),
|
|
8419
10009
|
})
|
|
8420
10010
|
: h(Section, { title: t('pageGraph'), desc: t('descGraph'), icon: GlyphChart },
|
|
@@ -8435,32 +10025,30 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8435
10025
|
})
|
|
8436
10026
|
|
|
8437
10027
|
// 帮助页:快速开始、功能说明、常见问题与反馈入口。
|
|
8438
|
-
//
|
|
8439
|
-
// getSettingsState 已有快照(复用上方 copyText);正文全部走 i18n,段落/列表/
|
|
8440
|
-
// 表格只由本地小助手拼装,样式复用 Section/Tag/Button 与 S 里的既有 token。
|
|
10028
|
+
// 页面跳转复用 setPage;诊断统一取服务端脱敏报告,不在浏览器拼接配置或库名。
|
|
8441
10029
|
const helpStepTargets = [
|
|
8442
10030
|
{ key: 'helpStep1', to: PAGE.libraries },
|
|
8443
10031
|
{ key: 'helpStep2', to: null }, // 绑定发生在会话侧,页面里只能给文案指引
|
|
8444
10032
|
{ key: 'helpStep3', to: PAGE.settings },
|
|
8445
10033
|
{ key: 'helpStep4', to: PAGE.memories },
|
|
8446
10034
|
{ key: 'helpStep5', to: PAGE.lexicon },
|
|
10035
|
+
{ key: 'helpStep6', to: PAGE.connection },
|
|
10036
|
+
{ key: 'helpStep7', to: PAGE.graph },
|
|
8447
10037
|
]
|
|
10038
|
+
const helpStepIndex = Math.max(0, helpStepTargets.findIndex(step => step.key === helpStep))
|
|
10039
|
+
const helpLesson = helpStepTargets[helpStepIndex]
|
|
10040
|
+
const helpTopics = ['helpScopes', 'helpTitleCards', 'helpArchiveDelete', 'helpVector', 'helpAutoLink', 'helpLabels', 'helpSidebar', 'helpFaq']
|
|
10041
|
+
const helpTopic = (key, content) => h('div', { key, 'data-help-topic': key }, content)
|
|
8448
10042
|
const copyDiagnostics = async () => {
|
|
8449
10043
|
try {
|
|
8450
|
-
const
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
engine: { status: engine.status, installed: engine.installed, versions: engine.versions || [] },
|
|
8455
|
-
settings: snapshot.settings || {},
|
|
8456
|
-
libraries: (snapshot.libraries || []).map(lib => ({ id: lib.id, name: lib.name, scopeKey: lib.scopeKey, privateCount: lib.privateCount })),
|
|
8457
|
-
}, null, 2)
|
|
8458
|
-
const ok = await copyText(summary)
|
|
10044
|
+
const report = await call('getDiagnosticReport', { limit: 100 })
|
|
10045
|
+
setDiagReport(report)
|
|
10046
|
+
if (report?.redacted !== true || typeof report.text !== 'string') throw new Error(t('diagReportUnavailable'))
|
|
10047
|
+
const ok = await copyText(report.text)
|
|
8459
10048
|
setNotice(ok ? t('copied') : t('copyFailed'))
|
|
8460
10049
|
} catch (failure) { setError(String(failure?.message || failure)) }
|
|
8461
10050
|
}
|
|
8462
|
-
//
|
|
8463
|
-
// 不持有状态,也不做交互——帮助页是说明书,不是教程。
|
|
10051
|
+
// 教程状态与记忆设置分开;主题索引在页内滚动,不改独立页的 hash 路由。
|
|
8464
10052
|
const helpPara = key => h('p', { style: { ...S.muted, margin: '0 0 6px', fontSize: 12.5, lineHeight: 1.7 } }, t(key))
|
|
8465
10053
|
const helpBullets = keys => h('ul', {
|
|
8466
10054
|
style: { margin: '0 0 6px', padding: '0 0 0 18px', fontSize: 12.5, lineHeight: 1.7 },
|
|
@@ -8488,48 +10076,64 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8488
10076
|
[t('helpLabelLexicon'), t('helpLabelLexiconMeaning'), 'helpLabelLexicon'],
|
|
8489
10077
|
]
|
|
8490
10078
|
const helpBlock = h(React.Fragment, null,
|
|
8491
|
-
h(Section, { title: t('helpQuickStart'), desc: t('
|
|
8492
|
-
|
|
8493
|
-
h(
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
10079
|
+
h(Section, { title: t('helpQuickStart'), desc: t('helpTutorialDesc'), icon: GlyphLayers },
|
|
10080
|
+
h('div', { className: 'dshm-help-guide' },
|
|
10081
|
+
h('ol', { className: 'dshm-help-steps', 'aria-label': t('helpTutorialSteps') },
|
|
10082
|
+
helpStepTargets.map((step, index) => h('li', { key: step.key },
|
|
10083
|
+
h('button', { type: 'button', 'aria-current': step.key === helpLesson.key ? 'step' : undefined,
|
|
10084
|
+
'aria-controls': 'dshm-help-lesson', title: t(step.key + 'Title'), onClick: () => setHelpStep(step.key) },
|
|
10085
|
+
h('span', { className: 'dshm-help-number', 'aria-hidden': true }, String(index + 1)), t(step.key + 'Title'))))),
|
|
10086
|
+
h('article', { className: 'dshm-help-lesson', id: 'dshm-help-lesson', 'aria-live': 'polite', 'aria-atomic': true },
|
|
10087
|
+
h('div', { className: 'dshm-help-progress' }, `${t('helpTutorialProgress')} ${helpStepIndex + 1} / ${helpStepTargets.length}`),
|
|
10088
|
+
h('h3', null, t(helpLesson.key + 'Title')),
|
|
10089
|
+
h('p', { 'data-help-action': helpLesson.key }, t(helpLesson.key)),
|
|
10090
|
+
h('dl', null,
|
|
10091
|
+
h('dt', null, t('helpTutorialExpected')), h('dd', null, t(helpLesson.key + 'Expected')),
|
|
10092
|
+
h('dt', null, t('helpTutorialTrouble')), h('dd', null, t(helpLesson.key + 'Trouble'))),
|
|
10093
|
+
h('div', { className: 'dshm-help-actions' },
|
|
10094
|
+
helpLesson.to !== null ? h(Button, { primary: true, onClick: () => setPage(helpLesson.to) }, t('helpGoTo')) : null,
|
|
10095
|
+
h(Button, { onClick: () => setPage(PAGE.diagnostics) }, t('helpTutorialDiagnose'))),
|
|
10096
|
+
h('div', { className: 'dshm-help-actions' },
|
|
10097
|
+
h(Button, { disabled: helpStepIndex === 0, onClick: () => setHelpStep(helpStepTargets[Math.max(0, helpStepIndex - 1)].key) }, t('helpTutorialPrevious')),
|
|
10098
|
+
h(Button, { disabled: helpStepIndex === helpStepTargets.length - 1, onClick: () => setHelpStep(helpStepTargets[Math.min(helpStepTargets.length - 1, helpStepIndex + 1)].key) }, t('helpTutorialNext')))))),
|
|
10099
|
+
h(Section, { title: t('helpTutorialReference'), desc: t('helpTutorialReferenceHint'), icon: GlyphQuestion },
|
|
10100
|
+
h('nav', { className: 'dshm-help-topics', 'aria-label': t('helpTutorialReference') }, helpTopics.map(key =>
|
|
10101
|
+
h('button', { key, type: 'button', onClick: () => document.querySelector(`[data-help-topic="${key}"]`)?.scrollIntoView?.({ block: 'start', behavior: 'auto' }) }, t(key))))),
|
|
10102
|
+
helpTopic('helpScopes', h(Section, { title: t('helpScopes'), desc: t('helpScopesDesc'), icon: GlyphFolder },
|
|
8499
10103
|
helpPara('helpScopesChain'),
|
|
8500
10104
|
h('div', { style: S.row }, ['useLibrary', 'useGlobal', 'effectiveScope'].map(key => h(Tag, { key, tone: 'info' }, key))),
|
|
8501
10105
|
helpPara('helpScopesPrivate'),
|
|
8502
10106
|
helpPara('helpScopesGlobal'),
|
|
8503
10107
|
helpPara('helpScopesWhere'),
|
|
8504
10108
|
h('div', { style: { ...S.muted, margin: '8px 0 4px', fontWeight: 600 } }, t('helpScopesPitfallsTitle')),
|
|
8505
|
-
helpBullets(['helpScopesPitfall1', 'helpScopesPitfall2', 'helpScopesPitfall3'])),
|
|
8506
|
-
h(Section, { title: t('helpTitleCards'), icon: GlyphLayers },
|
|
10109
|
+
helpBullets(['helpScopesPitfall1', 'helpScopesPitfall2', 'helpScopesPitfall3']))),
|
|
10110
|
+
helpTopic('helpTitleCards', h(Section, { title: t('helpTitleCards'), icon: GlyphLayers },
|
|
8507
10111
|
helpPara('helpTitleCardsBody'),
|
|
8508
10112
|
helpPara('helpTitleCardsRecall'),
|
|
8509
|
-
helpPara('helpTitleCardsRule')),
|
|
8510
|
-
h(Section, { title: t('helpArchiveDelete'), icon: GlyphStack },
|
|
10113
|
+
helpPara('helpTitleCardsRule'))),
|
|
10114
|
+
helpTopic('helpArchiveDelete', h(Section, { title: t('helpArchiveDelete'), icon: GlyphStack },
|
|
8511
10115
|
helpBullets(['helpArchiveDeleteArchive', 'helpArchiveDeleteDelete', 'helpArchiveDeleteLexicon',
|
|
8512
|
-
'helpArchiveDeleteAbsorb', 'helpArchiveDeleteSessionGone'])),
|
|
8513
|
-
h(Section, { title: t('helpVector'), icon: GlyphGauge },
|
|
10116
|
+
'helpArchiveDeleteAbsorb', 'helpArchiveDeleteSessionGone']))),
|
|
10117
|
+
helpTopic('helpVector', h(Section, { title: t('helpVector'), icon: GlyphGauge },
|
|
8514
10118
|
helpPara('helpVectorSetup'),
|
|
8515
10119
|
helpPara('helpVectorCount'),
|
|
8516
10120
|
helpPara('helpVectorFallback'),
|
|
8517
|
-
helpPara('helpVectorRebuild')),
|
|
8518
|
-
h(Section, { title: t('helpAutoLink'), icon: GlyphGlobe },
|
|
10121
|
+
helpPara('helpVectorRebuild'))),
|
|
10122
|
+
helpTopic('helpAutoLink', h(Section, { title: t('helpAutoLink'), icon: GlyphGlobe },
|
|
8519
10123
|
helpPara('helpAutoLinkRule'),
|
|
8520
10124
|
h('div', { style: S.row }, h(Tag, { tone: 'info' }, 'source=auto'), h(Tag, null, 'memu_private_link_suggest')),
|
|
8521
10125
|
helpPara('helpAutoLinkHub'),
|
|
8522
10126
|
helpPara('helpAutoLinkWorker'),
|
|
8523
|
-
helpPara('helpAutoLinkSafety')),
|
|
8524
|
-
h(Section, { title: t('helpLabels'), desc: t('helpLabelsDesc'), icon: GlyphText },
|
|
8525
|
-
helpTable(helpLabelRows)),
|
|
8526
|
-
h(Section, { title: t('helpSidebar'), desc: t('helpSidebarDesc'), icon: GlyphSliders },
|
|
10127
|
+
helpPara('helpAutoLinkSafety'))),
|
|
10128
|
+
helpTopic('helpLabels', h(Section, { title: t('helpLabels'), desc: t('helpLabelsDesc'), icon: GlyphText },
|
|
10129
|
+
helpTable(helpLabelRows))),
|
|
10130
|
+
helpTopic('helpSidebar', h(Section, { title: t('helpSidebar'), desc: t('helpSidebarDesc'), icon: GlyphSliders },
|
|
8527
10131
|
helpBullets(['helpSidebarAlerts', 'helpSidebarReview', 'helpSidebarRunLog',
|
|
8528
|
-
'helpSidebarReviewMode', 'helpSidebarFirstRun', 'helpSidebarFallback', 'helpSidebarScope'])),
|
|
8529
|
-
h(Section, { title: t('helpFaq'), icon: GlyphQuestion },
|
|
10132
|
+
'helpSidebarReviewMode', 'helpSidebarFirstRun', 'helpSidebarFallback', 'helpSidebarScope']))),
|
|
10133
|
+
helpTopic('helpFaq', h(Section, { title: t('helpFaq'), icon: GlyphQuestion },
|
|
8530
10134
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(n => h('details', { key: 'helpFaq' + n, style: { margin: '0 0 8px' } },
|
|
8531
10135
|
h('summary', { style: { cursor: 'pointer', fontSize: 12.5, fontWeight: 600, lineHeight: 1.5 } }, t('helpFaq' + n)),
|
|
8532
|
-
h('div', { style: { ...S.muted, marginTop: 5, fontSize: 12, lineHeight: 1.7 } }, t('helpFaq' + n + 'A'))))),
|
|
10136
|
+
h('div', { style: { ...S.muted, marginTop: 5, fontSize: 12, lineHeight: 1.7 } }, t('helpFaq' + n + 'A')))))),
|
|
8533
10137
|
h(Section, { title: t('helpFeedback'), icon: GlyphGlobe },
|
|
8534
10138
|
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap' } },
|
|
8535
10139
|
h(Button, {
|
|
@@ -8642,6 +10246,27 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8642
10246
|
: level === 'info' ? t('diagLevelInfo') : String(level || ''))
|
|
8643
10247
|
const diagTone = (level) => (level === 'error' ? 'danger' : level === 'warn' ? 'warn' : undefined)
|
|
8644
10248
|
const diagMuted = { ...S.muted, marginTop: 4, whiteSpace: 'pre-wrap', wordBreak: 'break-all' }
|
|
10249
|
+
const diagLayerNames = { host: t('diagLayerHost'), plugin: t('diagLayerPlugin'), engine: t('diagLayerEngine'), vector: t('diagLayerVector'), state: t('diagLayerState'), rpc: t('diagLayerRpc'), workers: t('diagLayerWorkers') }
|
|
10250
|
+
const diagStatusNames = { observed: t('diagStatusObserved'), unknown: t('diagStatusUnknown'), skipped: t('diagStatusSkipped'), 'not-built': t('diagStatusNotBuilt'), absent: t('diagStatusAbsent'), error: t('diagStatusError'), degraded: t('diagStatusDegraded') }
|
|
10251
|
+
const diagTechnical = (label, value) => value == null ? null : h('details', { className: 'dshm-diag-details' },
|
|
10252
|
+
h('summary', null, label), h('pre', null, typeof value === 'string' ? value : JSON.stringify(value, null, 2)))
|
|
10253
|
+
const fetchDiagnosticReport = async () => {
|
|
10254
|
+
const report = await call('getDiagnosticReport', { limit: 100 })
|
|
10255
|
+
if (report?.redacted !== true || typeof report.text !== 'string') throw new Error(t('diagReportUnavailable'))
|
|
10256
|
+
setDiagReport(report)
|
|
10257
|
+
return report
|
|
10258
|
+
}
|
|
10259
|
+
const downloadDiagnosticReport = async () => {
|
|
10260
|
+
try {
|
|
10261
|
+
const report = await fetchDiagnosticReport()
|
|
10262
|
+
const url = URL.createObjectURL(new Blob([report.text], { type: 'application/json;charset=utf-8' }))
|
|
10263
|
+
const link = document.createElement('a')
|
|
10264
|
+
link.href = url
|
|
10265
|
+
link.download = `dsh-memu-memory-diagnostics-${String(report.generatedAt || '').replace(/[^0-9T]/g, '') || 'report'}.json`
|
|
10266
|
+
document.body.appendChild(link)
|
|
10267
|
+
try { link.click() } finally { link.remove(); setTimeout(() => URL.revokeObjectURL(url), 1000) }
|
|
10268
|
+
} catch (error) { setDiagNotice(String(error?.message || error)) }
|
|
10269
|
+
}
|
|
8645
10270
|
const diagButtons = h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap' } },
|
|
8646
10271
|
h(Button, { onClick: () => { void loadDiagnostics(true) }, disabled: diagBusy }, t('diagRefresh')),
|
|
8647
10272
|
(diagEnv?.autoRepairs || []).length > 0
|
|
@@ -8654,27 +10279,53 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8654
10279
|
h(Button, {
|
|
8655
10280
|
style: S.ghost,
|
|
8656
10281
|
onClick: async () => {
|
|
8657
|
-
|
|
8658
|
-
|
|
10282
|
+
try {
|
|
10283
|
+
const report = await fetchDiagnosticReport()
|
|
10284
|
+
const ok = await copyText(report.text)
|
|
10285
|
+
setDiagNotice(ok ? t('copied') : t('copyFailed'))
|
|
10286
|
+
} catch (error) { setDiagNotice(String(error?.message || error)) }
|
|
8659
10287
|
},
|
|
8660
10288
|
}, t('diagCopyAll')),
|
|
10289
|
+
h(Button, { onClick: () => { void downloadDiagnosticReport() }, disabled: diagBusy }, t('diagReportDownload')),
|
|
8661
10290
|
h(Button, {
|
|
8662
10291
|
style: S.ghost,
|
|
8663
10292
|
onClick: async () => {
|
|
10293
|
+
if (!confirmAction('clear-diagnostics')) return
|
|
8664
10294
|
try {
|
|
8665
10295
|
await call('clearDiagnostics', { confirmed: true })
|
|
8666
10296
|
await loadDiagnostics(true)
|
|
8667
10297
|
} catch (error) { setDiagNotice(String(error?.message || error)) }
|
|
8668
10298
|
},
|
|
8669
|
-
}, t('diagClear')))
|
|
10299
|
+
}, actionLabel('clear-diagnostics', t('diagClear'))))
|
|
10300
|
+
const diagRuntime = diagReport?.runtime
|
|
10301
|
+
const diagFact = (label, value) => h('div', { key: label }, h('dt', null, label), h('dd', null, value || t('diagStatusUnknown')))
|
|
10302
|
+
const diagRuntimeSection = h(Section, { title: t('diagReportTitle'), desc: t('diagReportDesc'), right: diagButtons },
|
|
10303
|
+
diagNotice ? h('div', { className: 'dshm-diag-note', role: 'status' }, diagNotice) : null,
|
|
10304
|
+
h('p', { className: 'dshm-diag-note' }, t('diagReportPrivacy')),
|
|
10305
|
+
diagRuntime ? h('dl', { className: 'dshm-diag-facts' },
|
|
10306
|
+
diagFact(t('diagReportHost'), diagRuntime.host?.version),
|
|
10307
|
+
diagFact(t('diagReportPlugin'), diagRuntime.plugin?.version),
|
|
10308
|
+
diagFact(t('diagReportNode'), [diagRuntime.node?.version, diagRuntime.node?.modules].filter(Boolean).join(' / ')),
|
|
10309
|
+
diagFact(t('diagReportOs'), [diagRuntime.os?.platform, diagRuntime.os?.arch, diagRuntime.os?.release].filter(Boolean).join(' ')),
|
|
10310
|
+
diagFact(t('diagReportSource'), diagRuntime.host?.source),
|
|
10311
|
+
diagFact(t('diagReportTime'), diagReport.generatedAt)) : h(Empty, null, diagBusy ? t('diagCheckRunning') : t('diagReportUnavailable')),
|
|
10312
|
+
Object.entries(diagReport?.components || {}).map(([key, layer]) => h('article', { key, className: 'dshm-diag-layer', 'data-diag-layer': key },
|
|
10313
|
+
h('div', { className: 'dshm-diag-head' },
|
|
10314
|
+
h('h3', null, diagLayerNames[key] || key),
|
|
10315
|
+
h(Tag, { tone: layer.status === 'error' ? 'danger' : layer.status === 'degraded' ? 'warn' : undefined }, diagStatusNames[layer.status] || layer.status)),
|
|
10316
|
+
layer.code ? h('p', { className: 'dshm-diag-code' }, layer.code) : null,
|
|
10317
|
+
layer.error?.message ? h('p', null, layer.error.message) : null,
|
|
10318
|
+
layer.action ? h('p', null, `${t('diagHint')}: ${layer.action}`) : null,
|
|
10319
|
+
diagTechnical(t('diagReportDetails'), { source: layer.source, evidence: layer.evidence, error: layer.error, retry: layer.retry }))),
|
|
10320
|
+
diagTechnical(t('diagReportLimitations'), diagReport?.health?.limitations))
|
|
8670
10321
|
const diagEnvRow = (entry) => h('div', { key: entry.id, style: S.item },
|
|
8671
|
-
h('div', {
|
|
10322
|
+
h('div', { className: 'dshm-diag-head' },
|
|
8672
10323
|
h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap', minWidth: 0 } },
|
|
8673
10324
|
h(Tag, { tone: diagTone(entry.level) }, diagLevelLabel(entry.level)),
|
|
8674
10325
|
h('span', null, entry.title),
|
|
8675
10326
|
entry.manual && entry.repair ? h(Tag, null, t('diagManual')) : null),
|
|
8676
10327
|
entry.repair
|
|
8677
|
-
? h(Button, { style: S.ghost, disabled: diagBusy, onClick: () => { void runRepair([entry.repair]) } }, t('diagRepair'))
|
|
10328
|
+
? h(Button, { style: S.ghost, disabled: diagBusy, onClick: () => { if (confirmAction('repair:' + entry.repair)) void runRepair([entry.repair]) } }, actionLabel('repair:' + entry.repair, t('diagRepair')))
|
|
8678
10329
|
: null),
|
|
8679
10330
|
entry.detail ? h('div', { style: diagMuted }, entry.detail) : null,
|
|
8680
10331
|
entry.repair ? h('div', { style: diagMuted }, `${t('diagAction')}: ${entry.repair}`) : null,
|
|
@@ -8685,9 +10336,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8685
10336
|
const diagEnvSection = h(Section, {
|
|
8686
10337
|
title: t('diagEnvTitle'),
|
|
8687
10338
|
desc: t('diagEnvDesc'),
|
|
8688
|
-
right: diagButtons,
|
|
8689
10339
|
},
|
|
8690
|
-
diagNotice ? h('div', { style: { ...S.muted, marginBottom: 8, color: V.accent } }, diagNotice) : null,
|
|
8691
10340
|
// 展示已探测到的宿主接口形状,供核对 docs/host-versions.md §13.6。
|
|
8692
10341
|
state?.hostSurface ? h('div', {
|
|
8693
10342
|
style: { ...S.muted, marginBottom: 8, fontFamily: 'monospace', fontSize: 12, overflowWrap: 'anywhere' },
|
|
@@ -8695,11 +10344,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8695
10344
|
}, `${t('diagHostSurface')} ${Object.entries(state.hostSurface).map(([name, value]) => `${name}=${value}`).join(' ')}`) : null,
|
|
8696
10345
|
diagEnvList)
|
|
8697
10346
|
const diagEventRow = (entry) => h('div', { key: entry.id, style: S.item },
|
|
8698
|
-
h('div', {
|
|
10347
|
+
h('div', { className: 'dshm-diag-head' },
|
|
8699
10348
|
h('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap', minWidth: 0 } },
|
|
8700
10349
|
h(Tag, { tone: diagTone(entry.level) }, diagLevelLabel(entry.level)),
|
|
8701
10350
|
h(Tag, null, entry.scope),
|
|
8702
|
-
h('span', {
|
|
10351
|
+
h('span', { className: 'dshm-diag-code' }, entry.code),
|
|
8703
10352
|
Number(entry.count) > 1 ? h('span', { style: S.muted }, `x${entry.count}`) : null,
|
|
8704
10353
|
h('span', { style: S.muted }, new Date(entry.lastAt || entry.at).toLocaleString())),
|
|
8705
10354
|
h(Button, {
|
|
@@ -8710,16 +10359,18 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8710
10359
|
},
|
|
8711
10360
|
}, t('logCopyOne'))),
|
|
8712
10361
|
h('div', { style: { marginTop: 4, whiteSpace: 'pre-wrap' } }, entry.message),
|
|
10362
|
+
h('div', { className: 'dshm-diag-note' }, `${t('diagReportLayer')}: ${diagLayerNames[entry.layer] || entry.layer || entry.scope || '-'}${entry.operation ? ` · ${t('diagReportOperation')}: ${entry.operation}` : ''}`),
|
|
10363
|
+
entry.correlationId ? h('div', { className: 'dshm-diag-code' }, `${t('diagReportCorrelation')}: ${entry.correlationId}`) : null,
|
|
8713
10364
|
entry.hint ? h('div', { style: diagMuted }, `${t('diagHint')}: ${entry.hint}`) : null,
|
|
10365
|
+
entry.action ? h('div', { className: 'dshm-diag-note' }, `${t('diagHint')}: ${entry.action}`) : null,
|
|
10366
|
+
entry.retry ? h('div', { className: 'dshm-diag-note' }, `${t('diagReportRetry')}: ${entry.retry.retryable ? t('diagReportRetryAllowed') : t('diagReportRetryManual')}${entry.retry.afterMs != null ? ` · ${t('diagReportRetryAfter')}: ${entry.retry.afterMs}` : ''}`) : null,
|
|
8714
10367
|
entry.repair
|
|
8715
10368
|
? h('div', { style: { marginTop: 6 } },
|
|
8716
|
-
h(Button, { style: S.ghost, disabled: diagBusy, onClick: () => { void runRepair([entry.repair]) } }, `${t('diagRepair')}: ${entry.repair}`))
|
|
10369
|
+
h(Button, { style: S.ghost, disabled: diagBusy, onClick: () => { if (confirmAction('repair:' + entry.repair)) void runRepair([entry.repair]) } }, actionLabel('repair:' + entry.repair, `${t('diagRepair')}: ${entry.repair}`)))
|
|
8717
10370
|
: null,
|
|
8718
|
-
entry.
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
}, JSON.stringify(entry.detail).slice(0, 1200))
|
|
8722
|
-
: null)
|
|
10371
|
+
diagTechnical(t('diagReportCause'), entry.error),
|
|
10372
|
+
diagTechnical(t('diagReportContext'), entry.context),
|
|
10373
|
+
diagTechnical(t('diagReportDetails'), entry.detail))
|
|
8723
10374
|
const diagFilters = h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
|
|
8724
10375
|
h('select', {
|
|
8725
10376
|
style: S.input,
|
|
@@ -8748,7 +10399,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8748
10399
|
diagRows.length === 0
|
|
8749
10400
|
? h(Empty, null, t('diagEmpty'))
|
|
8750
10401
|
: h('div', { style: S.list }, diagRows.map(diagEventRow)))
|
|
8751
|
-
const diagnosticsBlock = h(React.Fragment, null, diagEnvSection, diagEventsSection)
|
|
10402
|
+
const diagnosticsBlock = h(React.Fragment, null, diagRuntimeSection, diagEnvSection, diagEventsSection)
|
|
8752
10403
|
const pageBlocks = [engineBlock, connectionBlock, settingsBlock, foldersBlock, librariesBlock, browserBlock, globalBlock, promptsBlock, statsBlock, memoriesBlock, graphBlock, logsBlock, lexiconBlock, helpBlock, diagnosticsBlock]
|
|
8753
10404
|
|
|
8754
10405
|
// Settings uses a left nav with a sliding indicator (the sidebar keeps its
|
|
@@ -8955,6 +10606,29 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8955
10606
|
const refreshRequest = React.useRef(0)
|
|
8956
10607
|
const currentSession = React.useRef(sessionId)
|
|
8957
10608
|
currentSession.current = sessionId
|
|
10609
|
+
const [entityReviewReminder, setEntityReviewReminder] = React.useState(null)
|
|
10610
|
+
const [snoozedEntityReviewKey, setSnoozedEntityReviewKey] = React.useState('')
|
|
10611
|
+
const entityReviewRequest = React.useRef(0)
|
|
10612
|
+
const loadEntityReviewReminder = React.useCallback(async (libraryId) => {
|
|
10613
|
+
const request = ++entityReviewRequest.current
|
|
10614
|
+
if (!libraryId) { setEntityReviewReminder(null); return }
|
|
10615
|
+
try {
|
|
10616
|
+
const result = await call('listEntityMergeReviews', { libraryId, sessionId, limit: 1, reviewState: 'human' })
|
|
10617
|
+
if (request !== entityReviewRequest.current || currentSession.current !== sessionId) return
|
|
10618
|
+
const rows = (Array.isArray(result?.items) ? result.items : []).filter(item =>
|
|
10619
|
+
item && item.pending !== false && (!item.status || item.status === 'pending' || item.status === 'pending_review'))
|
|
10620
|
+
const total = Number.isSafeInteger(result?.total) && result.total >= 0 ? result.total : null
|
|
10621
|
+
const first = rows[0]
|
|
10622
|
+
const signature = JSON.stringify([libraryId, total, result?.totalExact === true,
|
|
10623
|
+
first?.sourceId || first?.source?.id || first?.sourceEntity?.id || '',
|
|
10624
|
+
first?.targetId || first?.target?.id || first?.targetEntity?.id || '', first?.reviewToken || ''])
|
|
10625
|
+
setEntityReviewReminder({ libraryId, signature, pending: rows.length > 0 || total > 0 })
|
|
10626
|
+
} catch {
|
|
10627
|
+
if (request === entityReviewRequest.current && currentSession.current === sessionId) setEntityReviewReminder(null)
|
|
10628
|
+
}
|
|
10629
|
+
}, [call, sessionId])
|
|
10630
|
+
const loadEntityReviewReminderRef = React.useRef(loadEntityReviewReminder)
|
|
10631
|
+
loadEntityReviewReminderRef.current = loadEntityReviewReminder
|
|
8958
10632
|
|
|
8959
10633
|
const refresh = React.useCallback(async () => {
|
|
8960
10634
|
if (!sessionId || currentSession.current !== sessionId) return
|
|
@@ -8981,6 +10655,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
8981
10655
|
setPrivateFiles(files)
|
|
8982
10656
|
setGlobalFiles(st.global?.items || [])
|
|
8983
10657
|
markerRef.current = sidebarMarker(st)
|
|
10658
|
+
void loadEntityReviewReminderRef.current?.(st.binding?.libraryId || '')
|
|
8984
10659
|
setError('')
|
|
8985
10660
|
setLoadFailed(false)
|
|
8986
10661
|
} catch (e) {
|
|
@@ -9203,6 +10878,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
9203
10878
|
h('span', { style: S.muted }, new Date(row.at).toLocaleTimeString())),
|
|
9204
10879
|
h('div', { style: { marginTop: 2, whiteSpace: 'pre-wrap', fontSize: 12 } }, row.message))
|
|
9205
10880
|
|
|
10881
|
+
const reminder = screenReady && binding?.libraryId && entityReviewReminder?.libraryId === binding.libraryId
|
|
10882
|
+
&& entityReviewReminder.pending && snoozedEntityReviewKey !== entityReviewReminder.signature
|
|
10883
|
+
const entityReviewReminderBlock = reminder
|
|
10884
|
+
? h('section', { role: 'status', style: { ...S.section, border: `1px solid ${V.warn}`, borderLeftWidth: 4 } },
|
|
10885
|
+
h('strong', { style: { display: 'block', overflowWrap: 'anywhere' } }, t('entityReviewSidebarTitle')),
|
|
10886
|
+
h('div', { style: { ...S.muted, marginTop: 5, lineHeight: 1.5, overflowWrap: 'anywhere' } }, t('entityReviewSidebarDesc')),
|
|
10887
|
+
h('div', { style: { display: 'flex', gap: 7, flexWrap: 'wrap', marginTop: 9 } },
|
|
10888
|
+
h(Button, { primary: true, onClick: () => openWebUiPage('memories', { libraryId: binding.libraryId }) }, t('entityReviewSidebarOpen')),
|
|
10889
|
+
h(Button, { style: S.ghost, onClick: () => setSnoozedEntityReviewKey(entityReviewReminder.signature) }, t('entityReviewSidebarLater'))))
|
|
10890
|
+
: null
|
|
10891
|
+
|
|
9206
10892
|
// 加载完成前不能由 null binding 判定未绑定,避免短暂显示错误的初始化提示。
|
|
9207
10893
|
// 加载失败时显示可重试错误;成功后再根据绑定状态渲染。
|
|
9208
10894
|
const bindingBlock = loaded && loadFailed
|
|
@@ -9250,6 +10936,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
9250
10936
|
.map((d) => h('option', { key: d, value: d }, domainText(t, d))))),
|
|
9251
10937
|
h('div', { style: { display: 'flex', gap: 8, marginTop: 8, flexWrap: 'wrap' } },
|
|
9252
10938
|
h(Button, { onClick: organize, disabled: busy, primary: true }, t('organize'))),
|
|
10939
|
+
entityReviewReminderBlock,
|
|
9253
10940
|
// 整理提醒在记忆设置卡之下、整理记录之上:跨会话的失败提醒离整理入口最近,
|
|
9254
10941
|
// 但不再压住页头。数据不按当前对话过滤,展开后失败/成功两列各看最新 6 条。
|
|
9255
10942
|
alertBlock,
|
|
@@ -9818,4 +11505,4 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
9818
11505
|
|
|
9819
11506
|
return module.exports
|
|
9820
11507
|
},
|
|
9821
|
-
})
|
|
11508
|
+
})
|