dsh-memu-memory 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -1
- package/README.md +9 -9
- package/README.zh.md +6 -6
- package/docs/binding-lifecycle.md +1 -1
- package/docs/env-and-commands.md +4 -1
- package/docs/host-adaptation.md +318 -0
- package/docs/host-api.md +29 -5
- package/docs/memory-semantics.md +45 -9
- package/docs/troubleshooting.md +27 -8
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +246 -56
- package/lib/consolidation-ledger.js +46 -1
- package/lib/consolidation-worker.js +1 -0
- package/lib/cycle.js +51 -17
- package/lib/embedding-catalog.js +14 -0
- package/lib/embedding-runtime.js +202 -25
- package/lib/global-graph.js +99 -1
- package/lib/index.js +8 -0
- package/lib/inject.js +71 -33
- package/lib/lexicon-scope.js +143 -0
- package/lib/lexicon.js +31 -4
- package/lib/local-vector-service.js +82 -6
- package/lib/memory.js +186 -12
- package/lib/memu.js +318 -3
- package/lib/private.js +310 -67
- package/lib/rpc.js +183 -23
- package/lib/salient-wake.js +38 -2
- package/lib/state.js +7 -5
- package/lib/tools.js +40 -17
- package/lib/vector-migration.js +13 -1
- package/lib/webui/graph-view.bundle.js +1 -1
- package/lib/webui/graph-view.js +4 -1
- package/package.json +1 -1
- package/tests/absorb-review.test.mjs +2 -1
- package/tests/backend-compensation.test.mjs +1 -1
- package/tests/browser.test.mjs +58 -1
- package/tests/client-render.test.mjs +39 -0
- package/tests/consolidation-fork.test.mjs +81 -6
- package/tests/cross-library-recall.test.mjs +113 -0
- package/tests/curator-absorb.test.mjs +2 -1
- package/tests/curator-clusters.test.mjs +2 -1
- package/tests/curator-commit.test.mjs +2 -1
- package/tests/curator-link.test.mjs +2 -1
- package/tests/curator-review-mode.test.mjs +2 -1
- package/tests/cycle.test.mjs +2 -2
- package/tests/embedding-runtime.test.mjs +53 -1
- package/tests/global-graph.test.mjs +90 -0
- package/tests/lexicon-scope.test.mjs +256 -0
- package/tests/lexicon-ui.test.mjs +23 -0
- package/tests/managed-memory.test.mjs +1 -1
- package/tests/recall-dedup.test.mjs +1 -1
- package/tests/salient-wake.test.mjs +28 -1
- package/tests/settings-plumbing.test.mjs +1 -0
- package/tests/stubs/dsh-schedule.js +35 -0
- package/tests/ui-defaults.test.mjs +1 -1
- package/tests/vector-migration.test.mjs +20 -0
- package/tests/webui-auth.test.mjs +28 -0
package/lib/client.js
CHANGED
|
@@ -259,6 +259,8 @@ window.__ModuleLoader__.load({
|
|
|
259
259
|
graphLabels: '显示标签',
|
|
260
260
|
graphMotion: '动态布局',
|
|
261
261
|
graphLoadError: '图谱加载失败,请重试',
|
|
262
|
+
graphGlobalScope: '全局记忆',
|
|
263
|
+
graphGlobalReadonly: '全局关联在这里是只读视图;要移除边请到全局记忆列表操作。',
|
|
262
264
|
nav: 'MemU 记忆',
|
|
263
265
|
guideDesc: '记忆库、注入与全局记忆',
|
|
264
266
|
engine: 'MemU 引擎',
|
|
@@ -275,6 +277,8 @@ window.__ModuleLoader__.load({
|
|
|
275
277
|
autoInject: '注入模式',
|
|
276
278
|
privateTopK: '私有 topK',
|
|
277
279
|
globalTopK: '全局 topK',
|
|
280
|
+
crossLibraryRecall: '跨库召回(仅同领域)',
|
|
281
|
+
crossLibraryRecallHint: '开启后,自动召回、memu_private_recall、memu_private_list 与侧栏私有列表会合并其它“同领域”私有记忆库;词典的锚点摘要、本回合匹配与 memu_lexicon_search 走同一个作用域。显式浏览某个库时仍只显示该库。写入仍只写当前库(全局词典只有你能写)。跨文件夹读取会改变隔离边界,默认关闭。',
|
|
278
282
|
mustRememberCap: '永久记忆软上限',
|
|
279
283
|
shortTermTtlHours: '短期记忆保留(小时,0=关闭)',
|
|
280
284
|
anchorTokens: '锚点 token',
|
|
@@ -420,6 +424,14 @@ window.__ModuleLoader__.load({
|
|
|
420
424
|
managedVectorRuntimeFailed: '运行时安装失败',
|
|
421
425
|
managedVectorRuntimeUnsupported: '此平台没有已核实的运行时制品',
|
|
422
426
|
managedVectorRuntimeInstall: '下载运行时',
|
|
427
|
+
managedVectorRuntimeSource: '运行时下载源',
|
|
428
|
+
managedVectorRuntimeSourceHint: '下载中请先停止再切换源;已下载的字节会保留,并从新源续传。每个制品仍要过目录里 pin 住的 sha256。',
|
|
429
|
+
managedVectorPause: '暂停',
|
|
430
|
+
managedVectorStop: '停止',
|
|
431
|
+
managedVectorResume: '继续下载',
|
|
432
|
+
managedVectorPaused: '已暂停',
|
|
433
|
+
managedVectorStopped: '已停止',
|
|
434
|
+
managedVectorSpeed: '速度',
|
|
423
435
|
managedVectorRuntimeTitle: '运行环境',
|
|
424
436
|
managedVectorModelsTitle: '模型',
|
|
425
437
|
managedVectorSource: '下载来源',
|
|
@@ -694,9 +706,12 @@ window.__ModuleLoader__.load({
|
|
|
694
706
|
later: '稍后',
|
|
695
707
|
// —— 词典页 ——
|
|
696
708
|
pageLexicon: '词典',
|
|
697
|
-
descLexicon: '
|
|
709
|
+
descLexicon: '每个记忆库一本词典,另加一本全局词典:黑话、梗、触发词与术语的释义、归档与命中统计。',
|
|
698
710
|
lexiconScope: '词条管理',
|
|
699
|
-
lexiconNoLibrary: '
|
|
711
|
+
lexiconNoLibrary: '还没有记忆库;词典随私有记忆库创建,全局词典现在就能用。',
|
|
712
|
+
lexiconGlobalScope: '全局词典',
|
|
713
|
+
lexiconGlobalHint: '全局词典与全局记忆同构:每个会话都读得到它(锚点摘要、本回合匹配、memu_lexicon_search),但只有你能写——模型与整理链路只写各自的私有记忆库。没写领域的词条不分领域都可见。',
|
|
714
|
+
lexiconBrowseScopeHint: '这里选的是「正在看哪一本」:只列该库(或全局词典)自己的词条。注入与模型检索按召回作用域合并——当前库 + 全局词典,开了「跨库召回」再加上同领域的其它库(见记忆设置页)。',
|
|
700
715
|
lexiconTotal: '共 {total} 条',
|
|
701
716
|
lexiconTerm: '词条',
|
|
702
717
|
lexiconKind: '类型',
|
|
@@ -1013,6 +1028,8 @@ window.__ModuleLoader__.load({
|
|
|
1013
1028
|
graphLabels: 'Show labels',
|
|
1014
1029
|
graphMotion: 'Live layout',
|
|
1015
1030
|
graphLoadError: 'Graph failed to load. Retry',
|
|
1031
|
+
graphGlobalScope: 'Global memory',
|
|
1032
|
+
graphGlobalReadonly: 'Global links are read-only here; remove an edge from the global memory list.',
|
|
1016
1033
|
nav: 'MemU memory',
|
|
1017
1034
|
guideDesc: 'Memory libraries, injection, and global memory',
|
|
1018
1035
|
engine: 'MemU engine',
|
|
@@ -1029,6 +1046,8 @@ window.__ModuleLoader__.load({
|
|
|
1029
1046
|
autoInject: 'Injection mode',
|
|
1030
1047
|
privateTopK: 'Private topK',
|
|
1031
1048
|
globalTopK: 'Global topK',
|
|
1049
|
+
crossLibraryRecall: 'Cross-library recall (same domain)',
|
|
1050
|
+
crossLibraryRecallHint: 'When on, automatic recall, memu_private_recall, memu_private_list and the sidebar private list merge other private libraries that use the same domain; the lexicon anchor, this-turn match and memu_lexicon_search follow the same scope. An explicit library browser still shows only that library. Writes still go to the bound library only (the global lexicon is yours alone to write). Reading across folders changes the isolation boundary, so this is off by default.',
|
|
1032
1051
|
mustRememberCap: 'Permanent memory cap',
|
|
1033
1052
|
shortTermTtlHours: 'Short-term TTL in hours (0=off)',
|
|
1034
1053
|
anchorTokens: 'Anchor tokens',
|
|
@@ -1174,6 +1193,14 @@ window.__ModuleLoader__.load({
|
|
|
1174
1193
|
managedVectorRuntimeFailed: 'Runtime install failed',
|
|
1175
1194
|
managedVectorRuntimeUnsupported: 'No verified runtime artifacts for this platform',
|
|
1176
1195
|
managedVectorRuntimeInstall: 'Download runtime',
|
|
1196
|
+
managedVectorRuntimeSource: 'Runtime download source',
|
|
1197
|
+
managedVectorRuntimeSourceHint: 'Stop the download before switching source; downloaded bytes are kept and resumed from the new source. Every artifact still has to match the pinned sha256.',
|
|
1198
|
+
managedVectorPause: 'Pause',
|
|
1199
|
+
managedVectorStop: 'Stop',
|
|
1200
|
+
managedVectorResume: 'Resume download',
|
|
1201
|
+
managedVectorPaused: 'Paused',
|
|
1202
|
+
managedVectorStopped: 'Stopped',
|
|
1203
|
+
managedVectorSpeed: 'Speed',
|
|
1177
1204
|
managedVectorRuntimeTitle: 'Runtime',
|
|
1178
1205
|
managedVectorSource: 'Download source',
|
|
1179
1206
|
managedVectorSourceHint: 'The same files from one pinned commit. Switching source does not change the vector space: every file is verified against the sha256 pinned in the catalog.',
|
|
@@ -1447,9 +1474,12 @@ window.__ModuleLoader__.load({
|
|
|
1447
1474
|
later: 'Later',
|
|
1448
1475
|
// —— Lexicon page ——
|
|
1449
1476
|
pageLexicon: 'Lexicon',
|
|
1450
|
-
descLexicon: 'One lexicon per memory library: slang, memes, triggers and terms with meanings, archive and hit counts.',
|
|
1477
|
+
descLexicon: 'One lexicon per memory library plus a global one: slang, memes, triggers and terms with meanings, archive and hit counts.',
|
|
1451
1478
|
lexiconScope: 'Terms',
|
|
1452
|
-
lexiconNoLibrary: 'No memory libraries yet; a lexicon comes with each private library.',
|
|
1479
|
+
lexiconNoLibrary: 'No memory libraries yet; a lexicon comes with each private library. The global lexicon is already usable.',
|
|
1480
|
+
lexiconGlobalScope: 'Global lexicon',
|
|
1481
|
+
lexiconGlobalHint: 'The global lexicon mirrors global memory: every conversation reads it (anchor summary, this-turn match, memu_lexicon_search), but only you write it — the model and consolidation only ever write their own private library. Terms without a domain are visible in every domain.',
|
|
1482
|
+
lexiconBrowseScopeHint: 'This picker answers "which book am I reading": it lists only that library (or the global lexicon). Injection and the model search merge by recall scope — bound library + global lexicon, plus same-domain libraries when cross-library recall is on (see Memory settings).',
|
|
1453
1483
|
lexiconTotal: '{total} terms',
|
|
1454
1484
|
lexiconTerm: 'Term',
|
|
1455
1485
|
lexiconKind: 'Kind',
|
|
@@ -2273,18 +2303,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2273
2303
|
return enumText(t, DOMAIN_LABELS, raw)
|
|
2274
2304
|
}
|
|
2275
2305
|
|
|
2276
|
-
//
|
|
2306
|
+
// 情绪构成:四轴按固定顺序完整输出(喜/怒/哀/惧),不截断、不重排。
|
|
2307
|
+
// 只显示 top-2 会让“喜0.6/哀0.4”看起来像只有两种情绪,而构成本来就是四维;
|
|
2308
|
+
// 同理,阈值过滤会把小分量的轴吞掉,看不出“四轴各是多少”。
|
|
2277
2309
|
// 四轴固定且术语极短,就地映射,不为四个轴各加一个 i18n key。
|
|
2278
2310
|
const EMOTION_TAG_LABELS = { joy: '喜', anger: '怒', sorrow: '哀', fear: '惧' }
|
|
2279
2311
|
function emotionTagText(emotion) {
|
|
2280
2312
|
if (!emotion || typeof emotion !== 'object') return ''
|
|
2281
|
-
|
|
2313
|
+
const axes = Object.entries(EMOTION_TAG_LABELS)
|
|
2282
2314
|
.map(([axis, label]) => ({ label, share: Number(emotion[axis]) || 0 }))
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
.slice(0, 2)
|
|
2286
|
-
.map((item) => `${item.label}${item.share.toFixed(1)}`)
|
|
2287
|
-
.join('/')
|
|
2315
|
+
if (!axes.some((item) => item.share > 0)) return ''
|
|
2316
|
+
return axes.map((item) => `${item.label}${item.share.toFixed(2)}`).join('/')
|
|
2288
2317
|
}
|
|
2289
2318
|
|
|
2290
2319
|
const EMOTION_SOURCE_LABELS = {
|
|
@@ -2599,7 +2628,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2599
2628
|
message ? h('p', { role: 'status' }, message) : null)
|
|
2600
2629
|
}
|
|
2601
2630
|
|
|
2602
|
-
|
|
2631
|
+
// 关系图的库选择器里,全局记忆不是一个私有库;用一个不可能与库 id 冲突的
|
|
2632
|
+
// 占位值走同一套选择控件,避免再加一排 scope 按钮。
|
|
2633
|
+
const GLOBAL_GRAPH_ID = '__global__'
|
|
2634
|
+
function GraphPanel({ call, libraryId, files, t, global = false }) {
|
|
2603
2635
|
const [graph, setGraph] = React.useState({ nodes: [], edges: [] })
|
|
2604
2636
|
const [entities, setEntities] = React.useState([])
|
|
2605
2637
|
const [focus, setFocus] = React.useState('')
|
|
@@ -2624,6 +2656,19 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2624
2656
|
}, [])
|
|
2625
2657
|
const refresh = React.useCallback(async () => {
|
|
2626
2658
|
const id = ++requestId.current
|
|
2659
|
+
// Global edges live inside the global index and have no entities or merge
|
|
2660
|
+
// candidates, so the whole read is one call and the panel stays read-only.
|
|
2661
|
+
if (global) {
|
|
2662
|
+
try {
|
|
2663
|
+
const next = await call('getGraph', { scope: 'global', focusId: focus || null, depth: 2, limit: 200 })
|
|
2664
|
+
if (mounted.current && id === requestId.current) {
|
|
2665
|
+
setGraph(next); setEntities([]); setMerges([]); setError('')
|
|
2666
|
+
}
|
|
2667
|
+
} catch (error) {
|
|
2668
|
+
if (mounted.current && id === requestId.current) setError(String(error?.message || error))
|
|
2669
|
+
}
|
|
2670
|
+
return
|
|
2671
|
+
}
|
|
2627
2672
|
const [next, list, suggested] = await Promise.all([
|
|
2628
2673
|
call('getGraph', { libraryId, focusId: focus || null, depth: 2, limit: 200 }),
|
|
2629
2674
|
call('listEntities', { libraryId }),
|
|
@@ -2632,12 +2677,12 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2632
2677
|
if (mounted.current && id === requestId.current) {
|
|
2633
2678
|
setGraph(next); setEntities(list.items || []); setMerges(suggested?.items || []); setError('')
|
|
2634
2679
|
}
|
|
2635
|
-
}, [call, libraryId, focus])
|
|
2680
|
+
}, [call, libraryId, focus, global])
|
|
2636
2681
|
React.useEffect(() => {
|
|
2637
2682
|
let active = true
|
|
2638
|
-
if (libraryId) refresh().catch(error => { if (active) setError(String(error.message || error)) })
|
|
2683
|
+
if (libraryId || global) refresh().catch(error => { if (active) setError(String(error.message || error)) })
|
|
2639
2684
|
return () => { active = false; requestId.current++ }
|
|
2640
|
-
}, [refresh, files])
|
|
2685
|
+
}, [refresh, files, global])
|
|
2641
2686
|
React.useEffect(() => {
|
|
2642
2687
|
if (!armed) return undefined
|
|
2643
2688
|
const timer = setTimeout(() => setArmed(''), 2500)
|
|
@@ -2685,6 +2730,25 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
2685
2730
|
}
|
|
2686
2731
|
const titles = new Map(graph.nodes.map(node => [node.id, node.missing ? t('deletedNode') : node.title]))
|
|
2687
2732
|
const edges = graph.edges.filter(edge => !focus || edge.from === focus || edge.to === focus).sort((a, b) => b.confidence - a.confidence)
|
|
2733
|
+
if (global) {
|
|
2734
|
+
return h('div', null,
|
|
2735
|
+
error ? h('div', { className: 'dshm-toast', role: 'status' }, error) : null,
|
|
2736
|
+
h('div', { className: 'dshm-graph-tools' },
|
|
2737
|
+
h('select', { value: focus, title: t('focusMemory'), onChange: event => setFocus(event.target.value) },
|
|
2738
|
+
h('option', { value: '' }, t('focusMemory')),
|
|
2739
|
+
files.map(file => h('option', { key: file.id, value: file.id }, file.title || file.id)))),
|
|
2740
|
+
graph.truncated ? h('p', null, t('graphLimited')) : null,
|
|
2741
|
+
h('div', { className: 'dshm-graph-stage' },
|
|
2742
|
+
h(GraphCanvas, { key: 'global', graph, focus, onFocus: setFocus, t }),
|
|
2743
|
+
h('div', { className: 'dshm-graph-list' }, edges.length ? edges.map(edge => h('div', { key: edge.from + edge.to + edge.kind, className: 'dshm-graph-edge' },
|
|
2744
|
+
h('div', null,
|
|
2745
|
+
h('button', { type: 'button', className: 'dshm-graph-node', onClick: () => setFocus(edge.from) }, titles.get(edge.from) || edge.from),
|
|
2746
|
+
' → ',
|
|
2747
|
+
h('button', { type: 'button', className: 'dshm-graph-node', onClick: () => setFocus(edge.to) }, titles.get(edge.to) || edge.to),
|
|
2748
|
+
h('small', null, edge.kind + ' · ' + Math.round(edge.confidence * 100) + '% · ' + edge.note)))
|
|
2749
|
+
) : h(Empty, null, t('graphEmpty')))),
|
|
2750
|
+
h('p', { style: S.muted }, t('graphGlobalReadonly')))
|
|
2751
|
+
}
|
|
2688
2752
|
// 实体行:改名表单 + 删除按钮。删除是文字按钮(§6.4 包 D,原灰色 × 读不出
|
|
2689
2753
|
// 语义):未 armed 显示「删除」,armed 显示「确认删除」,后端拒绝过(仍被
|
|
2690
2754
|
// 引用)再点确认升级为 force——「确认删除!」,连同引用一起删,force 明示的
|
|
@@ -3036,6 +3100,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3036
3100
|
}
|
|
3037
3101
|
|
|
3038
3102
|
const shown = detail ? { ...detail.item, ...(detail.file || {}) } : null
|
|
3103
|
+
// 详情抽屉与卡片共用同一份情绪行:四轴构成 + 激活/掌控/来源,缺哪段就少哪段。
|
|
3104
|
+
const affectText = shown
|
|
3105
|
+
? [emotionTagText(shown.emotion) ? `${t('moodTag')} ${emotionTagText(shown.emotion)}` : '', emotionMetaText(shown, t)]
|
|
3106
|
+
.filter(Boolean).join(' · ')
|
|
3107
|
+
: ''
|
|
3039
3108
|
const detailForm = detail && detail.file && !detail.readonly
|
|
3040
3109
|
? h('div', { className: 'dshm-drawer-form' },
|
|
3041
3110
|
h('input', {
|
|
@@ -3080,7 +3149,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3080
3149
|
h('div', { className: 'dshm-drawer-note' },
|
|
3081
3150
|
t('decay') + ' ' + Math.round((Number(shown.decay) || 0) * 100) + '% · ' +
|
|
3082
3151
|
(shown.updatedAt ? String(shown.updatedAt).slice(0, 16).replace('T', ' ') : '')),
|
|
3083
|
-
|
|
3152
|
+
affectText ? h('div', { className: 'dshm-drawer-note' }, affectText) : null)
|
|
3084
3153
|
: detail && detail.file && detail.readonly
|
|
3085
3154
|
? (() => {
|
|
3086
3155
|
// 全局条目只读(spec §6.7 UI):详情抽屉里只读展示 links / absorbedFrom,
|
|
@@ -3180,24 +3249,33 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3180
3249
|
: null
|
|
3181
3250
|
|
|
3182
3251
|
const validLib = (id) => id && libraries.some((lib) => lib.id === id) ? id : ''
|
|
3183
|
-
|
|
3252
|
+
// No private library is still a meaningful graph state: global edges do not
|
|
3253
|
+
// belong to any library, so the selector defaults to them instead of an
|
|
3254
|
+
// empty "no libraries" card.
|
|
3255
|
+
const graphLibrary = graphLib === GLOBAL_GRAPH_ID || libraries.length === 0
|
|
3256
|
+
? GLOBAL_GRAPH_ID
|
|
3257
|
+
: (validLib(graphLib) || validLib(libraryId) || libraries[0].id)
|
|
3258
|
+
const showGlobalGraph = graphLibrary === GLOBAL_GRAPH_ID
|
|
3184
3259
|
const graphFiles = React.useMemo(() => items
|
|
3185
|
-
.filter(item => item.libraryId === graphLibrary)
|
|
3186
|
-
.map(item => ({ id: item.id, title: item.title })), [items, graphLibrary])
|
|
3260
|
+
.filter(item => showGlobalGraph ? item.libraryId === null : item.libraryId === graphLibrary)
|
|
3261
|
+
.map(item => ({ id: item.id, title: item.title })), [items, graphLibrary, showGlobalGraph])
|
|
3187
3262
|
const graphView = h('div', { className: 'dshm-card dshm-wall-graph' },
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3263
|
+
h(React.Fragment, null,
|
|
3264
|
+
h('div', { className: 'dshm-graph-tools' },
|
|
3265
|
+
h('select', {
|
|
3266
|
+
value: graphLibrary,
|
|
3267
|
+
title: showGlobalGraph ? t('graphGlobalScope') : (libraries.find((lib) => lib.id === graphLibrary)?.scopeKey || t('currentLibrary')),
|
|
3268
|
+
// One selection drives both views, otherwise the graph's focus list can
|
|
3269
|
+
// be empty when the wall is filtered to a different library.
|
|
3270
|
+
onChange: (event) => {
|
|
3271
|
+
const value = event.target.value
|
|
3272
|
+
setGraphLib(value)
|
|
3273
|
+
if (value !== GLOBAL_GRAPH_ID) setLibraryId(value)
|
|
3198
3274
|
},
|
|
3199
|
-
|
|
3200
|
-
h(
|
|
3275
|
+
},
|
|
3276
|
+
h('option', { key: GLOBAL_GRAPH_ID, value: GLOBAL_GRAPH_ID }, t('graphGlobalScope')),
|
|
3277
|
+
libraries.map(lib => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))),
|
|
3278
|
+
h(GraphPanel, { key: graphLibrary, call, libraryId: showGlobalGraph ? null : graphLibrary, files: graphFiles, t, global: showGlobalGraph })))
|
|
3201
3279
|
|
|
3202
3280
|
// Category filters used to reuse the compact nav pills (2px gap, 30px high) and
|
|
3203
3281
|
// stacked directly on top of each other. Give every group its own segmented
|
|
@@ -3344,6 +3422,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3344
3422
|
const LEXICON_KIND_LABELS = { slang: 'lexiconKindSlang', meme: 'lexiconKindMeme', trigger: 'lexiconKindTrigger', term: 'lexiconKindTerm' }
|
|
3345
3423
|
// 公开生命周期两档:页签文案带计数占位符,数字来自 RPC 的 statusCounts。
|
|
3346
3424
|
const LEXICON_TAB_LABELS = { active: 'lexiconTabActive', archived: 'lexiconTabArchived' }
|
|
3425
|
+
// 全局词典的保留存储名,与服务端 lib/lexicon.js 的 GLOBAL_LEXICON_ID 同一个值:
|
|
3426
|
+
// 私有库 id 恒为 `lib_<hex>`,所以它不可能撞上某本私有库。
|
|
3427
|
+
const GLOBAL_LEXICON_ID = 'global'
|
|
3347
3428
|
const EMPTY_LEXICON_DRAFT = { term: '', kind: 'term', meaning: '', usage: '', aliases: '', examples: '' }
|
|
3348
3429
|
|
|
3349
3430
|
// 词典页(§2.4):公开生命周期只有 active / archived,卡片流对齐记忆墙的
|
|
@@ -3351,6 +3432,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3351
3432
|
// ——模型写入直接生效,用户只做编辑 / 归档 / 恢复 / 删除。归档与恢复可逆、一击
|
|
3352
3433
|
// 生效;删除是管理面独有的永久动作,两段确认。带 sourceMemoryId 的词条可跳回
|
|
3353
3434
|
// 记忆墙对应条目(wallFocus 接力棒,见 SettingsPage)。
|
|
3435
|
+
// 作用域选择器与记忆墙节点图同一个做法:「全局词典」是选择器里的第一项,不是一个
|
|
3436
|
+
// 私有库,所以没有库时这一页照样可用(全局词典由用户手写,不依赖任何库)。
|
|
3354
3437
|
function LexiconPanel({ call, libraries, t, onFocusMemory, sessionId }) {
|
|
3355
3438
|
const [libraryId, setLibraryId] = React.useState('')
|
|
3356
3439
|
const [data, setData] = React.useState(null)
|
|
@@ -3377,7 +3460,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3377
3460
|
const safeQueryInput = typeof queryInput === 'string' ? queryInput : ''
|
|
3378
3461
|
const chosenIds = () => selectedIds instanceof Set ? selectedIds : new Set()
|
|
3379
3462
|
|
|
3380
|
-
const activeLib = libraryId || libraries[0]?.id ||
|
|
3463
|
+
const activeLib = libraryId || libraries[0]?.id || GLOBAL_LEXICON_ID
|
|
3464
|
+
const isGlobalLib = activeLib === GLOBAL_LEXICON_ID
|
|
3381
3465
|
const emptyView = { items: [], total: 0, page: 1, pages: 1, counts: {}, statusCounts: { active: 0, archived: 0 } }
|
|
3382
3466
|
const load = React.useCallback(async () => {
|
|
3383
3467
|
if (!activeLib) { setData(emptyView); return }
|
|
@@ -3673,7 +3757,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3673
3757
|
e.sourceMemoryId ? h(Button, {
|
|
3674
3758
|
style: { ...S.ghost, padding: '1px 7px', flexShrink: 0 },
|
|
3675
3759
|
title: t('lexiconSourceMemory'),
|
|
3676
|
-
onClick: () => onFocusMemory?.({ id: e.sourceMemoryId, libraryId: activeLib, title: e.term || e.id, at: Date.now() }),
|
|
3760
|
+
onClick: () => onFocusMemory?.({ id: e.sourceMemoryId, libraryId: isGlobalLib ? null : activeLib, title: e.term || e.id, at: Date.now() }),
|
|
3677
3761
|
}, t('lexiconSourceMemory')) : null),
|
|
3678
3762
|
h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', alignItems: 'center' } },
|
|
3679
3763
|
h(Button, { style: { ...S.ghost, padding: '2px 9px' }, disabled: busy, onClick: () => { setDeleteArmed(''); setArmedBulk(''); toggleEdit(e) } }, editing ? t('cancelDelete') : t('lexiconEdit')),
|
|
@@ -3734,15 +3818,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3734
3818
|
h('div', { style: S.row },
|
|
3735
3819
|
h('span', { style: S.label }, t('currentLibrary')),
|
|
3736
3820
|
h('select', {
|
|
3737
|
-
|
|
3738
|
-
|
|
3821
|
+
// value 用 activeLib 而不是 libraryId:没选过也要显示真正在看的这一本
|
|
3822
|
+
// (没有私有库时就是全局词典),否则选择器和数据会各说各话。
|
|
3823
|
+
style: { ...S.input, flex: 1 }, value: activeLib,
|
|
3824
|
+
title: isGlobalLib ? t('lexiconGlobalScope') : (libraries.find((lib) => lib.id === activeLib)?.scopeKey || t('currentLibrary')),
|
|
3739
3825
|
onChange: (e) => changeLibrary(e.target.value),
|
|
3740
3826
|
},
|
|
3741
|
-
|
|
3827
|
+
h('option', { value: GLOBAL_LEXICON_ID }, t('lexiconGlobalScope')),
|
|
3742
3828
|
libraries.map((lib) => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))),
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3829
|
+
// 口径说明(样式与记忆设置页的开关说明同一款):浏览只看一本,注入与模型检索
|
|
3830
|
+
// 按召回作用域合并——不解释清楚,用户会以为「跨库了却没看见别的库的词」。
|
|
3831
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } },
|
|
3832
|
+
isGlobalLib ? t('lexiconGlobalHint') : t('lexiconBrowseScopeHint')),
|
|
3833
|
+
libraries.length === 0 ? h('div', { style: { ...S.muted, marginTop: 4 } }, t('lexiconNoLibrary')) : null,
|
|
3834
|
+
h(React.Fragment, null, statusTabs, countsRow, filterRow, multiBar, newForm,
|
|
3746
3835
|
error && typeof error === 'string' ? h('div', { className: 'dshm-error', role: 'alert' }, error) : null,
|
|
3747
3836
|
notice && typeof notice === 'string' ? h('div', { style: { ...S.muted, marginTop: 6, color: V.accent } }, notice) : null,
|
|
3748
3837
|
items.length === 0
|
|
@@ -3787,6 +3876,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
3787
3876
|
const [vectorError, setVectorError] = React.useState('')
|
|
3788
3877
|
// 每张卡片各自记下载来源;没选过就用目录的默认顺序(第一个已固定的 provider)。
|
|
3789
3878
|
const [vectorProvider, setVectorProvider] = React.useState({})
|
|
3879
|
+
const [runtimeSource, setRuntimeSource] = React.useState('')
|
|
3880
|
+
// Polling gives us bytes every 2.5s; this turns consecutive samples into a
|
|
3881
|
+
// client-side MB/s fallback when the backend has not produced one yet.
|
|
3882
|
+
const progressSpeedRef = React.useRef(new Map())
|
|
3790
3883
|
// 全局记忆页"查看此记忆"的接力棒:带着 id 切到 MemU 记忆页,墙直接开对应抽屉。
|
|
3791
3884
|
const [wallFocus, setWallFocus] = React.useState(null)
|
|
3792
3885
|
// Success messages need their own slot: reusing `error` would paint a good
|
|
@@ -4595,6 +4688,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4595
4688
|
const requestedModel = localVector.vector?.requested?.catalogId
|
|
4596
4689
|
const requestedInstall = localVector.installations?.[requestedModel] || {}
|
|
4597
4690
|
const vectorCanSwitch = localVector.runtime?.ready === true && requestedInstall.installed === true && requestedInstall.fingerprintMatches !== false
|
|
4691
|
+
const runtimeState = localVector.runtime || {}
|
|
4692
|
+
const runtimeSources = Array.isArray(runtimeState.sources) ? runtimeState.sources : []
|
|
4693
|
+
const chosenRuntimeSource = runtimeSource || runtimeState.downloadSource || runtimeSources[0]?.id || ''
|
|
4598
4694
|
const vectorSource = settings.vectorSource || memuConfig.source || 'local'
|
|
4599
4695
|
const isLocalEmbed = vectorSource === 'local'
|
|
4600
4696
|
const draft = configDraft || {
|
|
@@ -4679,8 +4775,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4679
4775
|
setNotice('')
|
|
4680
4776
|
setVectorError('')
|
|
4681
4777
|
try {
|
|
4682
|
-
await call(endpoint, payload)
|
|
4683
|
-
|
|
4778
|
+
const result = await call(endpoint, payload)
|
|
4779
|
+
if (endpoint === 'installLocalVectorRuntime' && result?.paused) {
|
|
4780
|
+
setNotice(`${t('managedVectorStatus')}: ${t('managedVectorPaused')}`)
|
|
4781
|
+
} else if (endpoint === 'installLocalVectorRuntime' && result?.stopped) {
|
|
4782
|
+
setNotice(`${t('managedVectorStatus')}: ${t('managedVectorStopped')}`)
|
|
4783
|
+
} else {
|
|
4784
|
+
setNotice(`${t('managedVectorStatus')}: ${t(labels[endpoint] || 'managedVectorStatus')}`)
|
|
4785
|
+
}
|
|
4684
4786
|
} catch (e) {
|
|
4685
4787
|
const message = String(e?.message || e)
|
|
4686
4788
|
setVectorError(message)
|
|
@@ -4707,17 +4809,59 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
4707
4809
|
}
|
|
4708
4810
|
const managedVectorRuntimeInstall = async () => {
|
|
4709
4811
|
if (!confirmAction('runtime')) return
|
|
4710
|
-
await managedVectorAction('installLocalVectorRuntime', {
|
|
4812
|
+
await managedVectorAction('installLocalVectorRuntime', {
|
|
4813
|
+
confirmed: true,
|
|
4814
|
+
...(chosenRuntimeSource ? { source: chosenRuntimeSource } : {}),
|
|
4815
|
+
})
|
|
4816
|
+
}
|
|
4817
|
+
const controlRuntime = async (action) => {
|
|
4818
|
+
try {
|
|
4819
|
+
await call('installLocalVectorRuntime', { action })
|
|
4820
|
+
await refresh()
|
|
4821
|
+
} catch (e) {
|
|
4822
|
+
setVectorError(String(e?.message || e))
|
|
4823
|
+
setError(String(e?.message || e))
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4827
|
+
const formatVectorAmount = (bytes) => {
|
|
4828
|
+
const value = Number(bytes) || 0
|
|
4829
|
+
if (value >= 1048576) return `${(value / 1048576).toFixed(value >= 10485760 ? 0 : 1)} MB`
|
|
4830
|
+
if (value >= 1024) return `${Math.max(1, Math.round(value / 1024))} KB`
|
|
4831
|
+
return `${value} B`
|
|
4832
|
+
}
|
|
4833
|
+
const formatVectorSpeed = (bytesPerSecond) => {
|
|
4834
|
+
const value = Number(bytesPerSecond) || 0
|
|
4835
|
+
if (value <= 0) return ''
|
|
4836
|
+
return `${(value / 1048576).toFixed(value >= 1048576 ? 1 : 2)} MB/s`
|
|
4837
|
+
}
|
|
4838
|
+
const progressSpeed = (key, bytes, provided) => {
|
|
4839
|
+
const fromBackend = Number(provided) || 0
|
|
4840
|
+
if (!key) return fromBackend
|
|
4841
|
+
const now = Date.now()
|
|
4842
|
+
const previous = progressSpeedRef.current.get(key)
|
|
4843
|
+
let sampled = 0
|
|
4844
|
+
if (previous && now > previous.at && bytes >= previous.bytes) {
|
|
4845
|
+
const elapsed = (now - previous.at) / 1000
|
|
4846
|
+
if (elapsed >= 0.5) sampled = (bytes - previous.bytes) / elapsed
|
|
4847
|
+
}
|
|
4848
|
+
progressSpeedRef.current.set(key, { bytes, at: now })
|
|
4849
|
+
return fromBackend > 0 ? fromBackend : sampled
|
|
4711
4850
|
}
|
|
4712
4851
|
|
|
4713
|
-
const renderVectorProgress = (progress, migration = false) => {
|
|
4852
|
+
const renderVectorProgress = (progress, migration = false, key = '') => {
|
|
4714
4853
|
if (!progress) return null
|
|
4715
4854
|
const total = Number(migration ? progress.total : progress.totalBytes) || 0
|
|
4716
4855
|
const done = Number(migration ? progress.completed : progress.bytes) || 0
|
|
4717
4856
|
const label = t(migration ? 'managedVectorRebuilding' : 'managedVectorProgress')
|
|
4718
4857
|
const current = migration ? progress.current?.itemId : progress.current
|
|
4858
|
+
const percent = !migration && total > 0 ? Math.min(100, Math.floor(done / total * 100)) : null
|
|
4859
|
+
const speed = migration ? 0 : progressSpeed(key, done, progress.speedBps)
|
|
4860
|
+
const amount = migration
|
|
4861
|
+
? `${done} / ${total}`
|
|
4862
|
+
: `${percent == null ? '' : percent + '% · '}${formatVectorAmount(done)} / ${total > 0 ? formatVectorAmount(total) : '?'}${speed > 0 ? ' · ' + formatVectorSpeed(speed) : ''}`
|
|
4719
4863
|
return h('div', { className: 'dshm-vector-progress' },
|
|
4720
|
-
h('div', { role: 'status', 'aria-live': 'polite' }, `${label}: ${
|
|
4864
|
+
h('div', { role: 'status', 'aria-live': 'polite' }, `${label}: ${amount}${migration ? ` · ${t('managedVectorGeneration')} ${progress.generation} · ${progress.stage}` : ''}`),
|
|
4721
4865
|
h('progress', { max: total || 1, value: total > 0 ? Math.min(done, total) : undefined, 'aria-label': label }),
|
|
4722
4866
|
current ? h('div', { style: S.muted }, `${t('managedVectorCurrent')}: ${current}`) : null)
|
|
4723
4867
|
}
|
|
@@ -5045,15 +5189,20 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5045
5189
|
})(),
|
|
5046
5190
|
// 步骤 1:运行环境
|
|
5047
5191
|
(() => {
|
|
5048
|
-
const runtime =
|
|
5192
|
+
const runtime = runtimeState
|
|
5049
5193
|
const busyRuntime = ['downloading', 'verifying', 'installing'].includes(runtime.status)
|
|
5194
|
+
const downloading = runtime.status === 'downloading'
|
|
5195
|
+
const paused = runtime.status === 'paused'
|
|
5196
|
+
const stopped = runtime.status === 'stopped'
|
|
5050
5197
|
const ready = runtime.ready === true
|
|
5051
5198
|
const label = ready
|
|
5052
5199
|
? (runtime.source === 'env' ? t('managedVectorRuntimeConfigured') : t('managedVectorRuntimeInstalled'))
|
|
5053
5200
|
: runtime.status === 'unsupported' ? t('managedVectorRuntimeUnsupported')
|
|
5054
5201
|
: runtime.status === 'failed' ? t('managedVectorRuntimeFailed')
|
|
5055
|
-
:
|
|
5056
|
-
|
|
5202
|
+
: paused ? t('managedVectorPaused')
|
|
5203
|
+
: stopped ? t('managedVectorStopped')
|
|
5204
|
+
: busyRuntime ? t('managedVectorRuntimeInstalling') : t('managedVectorRuntimeMissing')
|
|
5205
|
+
const announce = busyRuntime || paused || stopped || Boolean(runtime.error?.message)
|
|
5057
5206
|
return h('div', { className: 'dshm-step', ...(announce ? { role: 'status', 'aria-live': 'polite' } : {}) },
|
|
5058
5207
|
h('div', { className: 'dshm-step-head' },
|
|
5059
5208
|
h('span', { className: 'dshm-step-title' }, '1 · ' + t('managedVectorRuntimeTitle')),
|
|
@@ -5061,12 +5210,36 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5061
5210
|
ready
|
|
5062
5211
|
? h('div', { style: S.muted }, runtime.version ? `v${runtime.version}` : t('managedVectorReady'))
|
|
5063
5212
|
: h('div', { style: S.muted }, t('managedVectorRuntimeHint')),
|
|
5064
|
-
!ready &&
|
|
5065
|
-
? h(
|
|
5066
|
-
h(
|
|
5213
|
+
!ready && runtime.status !== 'unsupported' && runtimeSources.length > 1
|
|
5214
|
+
? h(React.Fragment, null,
|
|
5215
|
+
h('div', { className: 'dshm-nav-list is-row', role: 'tablist', 'aria-label': t('managedVectorRuntimeSource') },
|
|
5216
|
+
runtimeSources.map(item => h('button', {
|
|
5217
|
+
key: item.id,
|
|
5218
|
+
type: 'button',
|
|
5219
|
+
role: 'tab',
|
|
5220
|
+
title: t('managedVectorRuntimeSourceHint'),
|
|
5221
|
+
'aria-selected': chosenRuntimeSource === item.id,
|
|
5222
|
+
disabled: busy || downloading,
|
|
5223
|
+
className: `dshm-nav-item${chosenRuntimeSource === item.id ? ' on' : ''}`,
|
|
5224
|
+
onClick: () => setRuntimeSource(item.id),
|
|
5225
|
+
}, item.label))),
|
|
5226
|
+
h('div', { style: { ...S.muted, marginTop: 4, lineHeight: 1.5 } }, t('managedVectorRuntimeSourceHint')))
|
|
5067
5227
|
: null,
|
|
5228
|
+
downloading
|
|
5229
|
+
? h('div', { className: 'dshm-step-actions' },
|
|
5230
|
+
h(Button, { onClick: () => controlRuntime('pause'), style: S.ghost, title: t('managedVectorPause') }, t('managedVectorPause')),
|
|
5231
|
+
h(Button, { onClick: () => controlRuntime('stop'), style: S.ghost, title: t('managedVectorStop') }, t('managedVectorStop')))
|
|
5232
|
+
: !ready && runtime.status !== 'unsupported'
|
|
5233
|
+
? h('div', { className: 'dshm-step-actions' },
|
|
5234
|
+
h(Button, {
|
|
5235
|
+
onClick: managedVectorRuntimeInstall,
|
|
5236
|
+
disabled: busy,
|
|
5237
|
+
primary: true,
|
|
5238
|
+
title: paused || stopped ? t('managedVectorResume') : t('managedVectorRuntimeInstall'),
|
|
5239
|
+
}, actionLabel('runtime', paused || stopped ? t('managedVectorResume') : t('managedVectorRuntimeInstall'))))
|
|
5240
|
+
: null,
|
|
5068
5241
|
runtime.error?.message ? h('div', { style: { ...S.muted, color: V.danger } }, runtime.error.message) : null,
|
|
5069
|
-
renderVectorProgress(runtime.progress))
|
|
5242
|
+
renderVectorProgress(runtime.progress, false, 'runtime'))
|
|
5070
5243
|
})(),
|
|
5071
5244
|
// 步骤 2:模型
|
|
5072
5245
|
h('div', { className: 'dshm-step' },
|
|
@@ -5122,7 +5295,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5122
5295
|
install.error?.message || (entry.pendingReasons || []).length
|
|
5123
5296
|
? h('div', { style: S.muted, role: 'status' }, install.error?.message || (entry.pendingReasons || []).join(';'))
|
|
5124
5297
|
: null,
|
|
5125
|
-
renderVectorProgress(install.progress))
|
|
5298
|
+
renderVectorProgress(install.progress, false, 'model:' + entry.id))
|
|
5126
5299
|
})))
|
|
5127
5300
|
) : null,
|
|
5128
5301
|
|
|
@@ -5144,6 +5317,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5144
5317
|
// 一致性由 tests/ui-defaults.test.mjs 守着。
|
|
5145
5318
|
h(Field, { label: t('privateTopK') }, h('input', { type: 'number', style: S.input, value: settings.privateTopK ?? 5, onChange: (e) => setSetting('privateTopK', Number(e.target.value)) })),
|
|
5146
5319
|
h(Field, { label: t('globalTopK') }, h('input', { type: 'number', style: S.input, value: settings.globalTopK ?? 5, onChange: (e) => setSetting('globalTopK', Number(e.target.value)) })),
|
|
5320
|
+
h(Field, { label: t('crossLibraryRecall') }, h(Toggle, { checked: settings.crossLibraryRecall === true, label: t('crossLibraryRecall'), onChange: value => setSetting('crossLibraryRecall', value) })),
|
|
5321
|
+
h('div', { className: 'dshm-settings-note', style: { ...S.muted, marginTop: 6, lineHeight: 1.55 } }, t('crossLibraryRecallHint')),
|
|
5147
5322
|
h(Field, { label: t('mustRememberCap') }, h('input', { type: 'number', style: S.input, value: settings.mustRememberCap ?? 12, onChange: (e) => setSetting('mustRememberCap', Number(e.target.value)) })),
|
|
5148
5323
|
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)) })),
|
|
5149
5324
|
h(Field, { label: t('anchorTokens') }, h('input', { type: 'number', style: S.input, value: settings.anchorTokens ?? 800, onChange: (e) => setSetting('anchorTokens', Number(e.target.value)) })),
|
|
@@ -5174,7 +5349,7 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5174
5349
|
names: settings.inboundToolNames || [], onChange: values => setSetting('inboundToolNames', values),
|
|
5175
5350
|
})),
|
|
5176
5351
|
h(Field, { label: t('sleepConsolidation') }, h('input', { type: 'checkbox', checked: settings.sleepConsolidation === true, onChange: (e) => setSetting('sleepConsolidation', e.target.checked) })),
|
|
5177
|
-
h(Field, { label: t('sleepAfterIdleMinutes') }, h('input', { type: 'number', min: 1, style: S.input, value: settings.sleepAfterIdleMinutes ??
|
|
5352
|
+
h(Field, { label: t('sleepAfterIdleMinutes') }, h('input', { type: 'number', min: 1, style: S.input, value: settings.sleepAfterIdleMinutes ?? 2, onChange: (e) => setSetting('sleepAfterIdleMinutes', Number(e.target.value)) })),
|
|
5178
5353
|
h(Field, { label: t('autoCurateEveryHours') }, h('input', { type: 'number', min: 0, style: S.input, value: settings.autoCurateEveryHours ?? 0, onChange: (e) => setSetting('autoCurateEveryHours', Number(e.target.value)) })),
|
|
5179
5354
|
h(Field, { label: t('autoCurateSessionLimit') }, h('input', { type: 'number', min: 1, max: 30, style: S.input, value: settings.autoCurateSessionLimit ?? 8, onChange: (e) => setSetting('autoCurateSessionLimit', Number(e.target.value)) })),
|
|
5180
5355
|
h(Field, { label: t('purgeArchivedAfterDays') }, h('input', { type: 'number', min: 0, style: S.input, value: settings.purgeArchivedAfterDays ?? 0, onChange: (e) => setSetting('purgeArchivedAfterDays', Number(e.target.value)) })),
|
|
@@ -5499,7 +5674,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
5499
5674
|
f.salientDate
|
|
5500
5675
|
? h(Tag, null, `${/^\d{4}-\d{2}-\d{2}$/.test(f.salientDate) ? t('dueDateTag') : t('anniversaryTag')} ${f.salientDate}`)
|
|
5501
5676
|
: null,
|
|
5502
|
-
|
|
5677
|
+
// 四轴构成放在 Tag 里;激活/掌控/来源直接可见,不再只藏在悬停提示里。
|
|
5678
|
+
moodText ? h(Tag, null, `${t('moodTag')} ${moodText}`) : null,
|
|
5679
|
+
emotionMetaText(f, t) ? h('span', { style: S.muted }, emotionMetaText(f, t)) : null,
|
|
5503
5680
|
typeof f.accuracy === 'number' && typeof f.confidence === 'number' && f.accuracy <= 0.6 && f.accuracy < f.confidence - 0.1
|
|
5504
5681
|
? h(Tag, { tone: 'warn' }, `${t('accuracyTag')} ${f.accuracy}`) : null,
|
|
5505
5682
|
h(Tag, null, enumText(t, STATUS_LABELS, f.status || 'active'))),
|
|
@@ -6266,13 +6443,21 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6266
6443
|
// server-side, so opening a 500-entry library no longer ships every body.
|
|
6267
6444
|
try {
|
|
6268
6445
|
const st = await call('getSidebarState', { sessionId })
|
|
6446
|
+
let files = st.private?.items || []
|
|
6447
|
+
// Older servers painted a bound-library-only preview. Ask `listPrivate`
|
|
6448
|
+
// for the cross-library list only in that case; a current server says
|
|
6449
|
+
// crossLibrary:true and already returned the same rows in one trip.
|
|
6450
|
+
if (st.private && st.private.crossLibrary !== true) {
|
|
6451
|
+
const privateList = await call('listPrivate', { sessionId, limit: 120, previewChars: 160 }).catch(() => null)
|
|
6452
|
+
if (privateList?.files) files = privateList.files
|
|
6453
|
+
}
|
|
6269
6454
|
setState({
|
|
6270
6455
|
...st,
|
|
6271
6456
|
pinnedCount: st.private?.pinned ?? 0,
|
|
6272
|
-
privateCount:
|
|
6457
|
+
privateCount: files.length,
|
|
6273
6458
|
globalCount: st.global?.active ?? 0,
|
|
6274
6459
|
})
|
|
6275
|
-
setPrivateFiles(
|
|
6460
|
+
setPrivateFiles(files)
|
|
6276
6461
|
setGlobalFiles(st.global?.items || [])
|
|
6277
6462
|
markerRef.current = sidebarMarker(st)
|
|
6278
6463
|
setError('')
|
|
@@ -6543,6 +6728,11 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
|
|
|
6543
6728
|
h('strong', null, f.title || f.id),
|
|
6544
6729
|
h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
|
|
6545
6730
|
h(Tag, null, enumText(t, LAYER_LABELS, f.layer || 'long_term')),
|
|
6731
|
+
// Cross-library rows carry the owning library; the sidebar is narrow,
|
|
6732
|
+
// so only rows that do not belong to the bound library get the tag.
|
|
6733
|
+
f.libraryName && f.libraryId && f.libraryId !== state?.binding?.libraryId
|
|
6734
|
+
? h(Tag, { tone: 'info' }, f.libraryName)
|
|
6735
|
+
: null,
|
|
6546
6736
|
f.marginalized ? h(Tag, null, t('marginalizedTag')) : null,
|
|
6547
6737
|
f.openLoop ? h(Tag, null, t('openLoopTag')) : null,
|
|
6548
6738
|
// The sidebar is narrow, so only the two values that change how a memory
|