@restregular/dsh-memory 0.12.5 → 0.12.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/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/lib/client.js +232 -15
- package/lib/panel.js +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
本项目的版本记录。安装 id 与 npm 版本一一对应。
|
|
4
4
|
|
|
5
|
+
## 0.12.6 — 审计详情分类、滚动与关联跳转
|
|
6
|
+
|
|
7
|
+
- **详情完整可滚动**:审计页采用固定视口高度 + `grid-template-rows:minmax(0,1fr)`,详情面板 `height:100%` 独立滚动,长内容可以滚到底部;整页不滚动。
|
|
8
|
+
- **选择与省略分类展示**:详情里按组显示「选中正文 / 本次新增 / 标签索引 / 省略(按原因分组)/ 去重跳过」,每组有数量;候选与可枚举 ID 的关系有说明,不再混成一排。
|
|
9
|
+
- **记忆 ID 浮窗**:hover 显示记录类型、作用域、重要度、标签与原文摘要;点击跳到「记录」页并自动展开该记录(`RecordCard` 新增 focus 展开)。记录不在当前列表时通过 `/records?id=` 精确补查。
|
|
10
|
+
- **会话 ID 浮窗与跳转**:hover 显示会话标题/cwd/更新时间/运行状态;点击通过宿主 `uiWorkspace.openSession` 打开会话(旧宿主退回 hash 路由)。
|
|
11
|
+
- 面板 `/records` 新增 `id`(精确或前缀)过滤,供审计详情按 ID 补查。
|
|
12
|
+
- 测试补充:详情 ID 分组、记忆/会话 ID hover 浮窗与点击回调、记录页自动展开;全量 323 项 322 通过 1 跳过。
|
|
13
|
+
|
|
5
14
|
## 0.12.5 — 审计表头与行严格对齐
|
|
6
15
|
|
|
7
16
|
- 表头移入滚动容器内部并设为 sticky:表头与行共享同一个内容宽度(含滚动条),不再出现标题比内容偏左。
|
package/README.md
CHANGED
|
@@ -415,6 +415,7 @@ npm run verify # 构建到 .verify/,不落 packages/
|
|
|
415
415
|
|
|
416
416
|
## 更新日志
|
|
417
417
|
|
|
418
|
+
- **0.12.6** —— 审计详情分类展示选中/新增/标签/省略/去重 ID;记忆与会话 ID 支持 hover 浮窗和点击跳转;详情独立滚动可到底。
|
|
418
419
|
- **0.12.5** —— 审计表头移入滚动容器并 sticky,与行严格对齐;重分配列宽,行内预算改紧凑条。
|
|
419
420
|
- **0.12.4** —— 审计页默认每 0.5 秒自动刷新(可关/可调间隔);移除顶部标题与气泡,整页固定在窗口内,仅列表滚动;新增表头并优化列宽;复制/导出提示就地显示。
|
|
420
421
|
- **0.12.3** —— 审计页筛选改为两行紧凑布局与自绘时间范围/开关;事件列表放入独立滚动容器。
|
package/lib/client.js
CHANGED
|
@@ -361,7 +361,7 @@ window.__ModuleLoader__.load({
|
|
|
361
361
|
'.memp .audit-switch .switch.on .knob{left:16px}',
|
|
362
362
|
'.memp .audit-filter-sub{padding-top:1px}',
|
|
363
363
|
'.memp .audit-range-sep{color:var(--dsw-alias-label-secondary);font-size:11px;flex:none}',
|
|
364
|
-
'.memp .audit-split{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;min-height:0;flex:1;overflow:hidden;align-items:stretch}',
|
|
364
|
+
'.memp .audit-split{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);gap:10px;min-height:0;flex:1;overflow:hidden;align-items:stretch}',
|
|
365
365
|
'.memp .audit-split.has-detail{grid-template-columns:minmax(0,1fr) minmax(300px,360px)}',
|
|
366
366
|
'.memp .audit-list-wrap{display:flex;flex-direction:column;min-height:0;min-width:0;overflow:hidden}',
|
|
367
367
|
'.memp .audit-table-head{display:grid;grid-template-columns:62px 140px minmax(150px,1.3fr) minmax(110px,0.8fr) 112px minmax(108px,0.9fr) 92px;gap:8px;align-items:center;position:sticky;top:0;z-index:2;box-sizing:border-box;padding:6px 9px;margin-bottom:2px;font-size:10px;letter-spacing:.03em;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1);border:1px solid transparent;border-bottom-color:var(--dsw-alias-border-l1)}',
|
|
@@ -385,7 +385,7 @@ window.__ModuleLoader__.load({
|
|
|
385
385
|
'.memp .audit-pill.bad{color:var(--dsw-alias-label-danger, #e05555);border-color:color-mix(in srgb,var(--dsw-alias-label-danger, #e05555) 42%,var(--dsw-alias-border-l1))}',
|
|
386
386
|
'.memp .audit-pill.mute{color:var(--dsw-alias-label-secondary)}',
|
|
387
387
|
'.memp .audit-empty{border:1px dashed var(--dsw-alias-border-l1);border-radius:10px;padding:26px 16px;text-align:center;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.65}',
|
|
388
|
-
'.memp .audit-detail{border:1px solid var(--dsw-alias-border-l1);border-radius:11px;background:var(--dsw-alias-bg-layer-1);padding:10px 11px;display:flex;flex-direction:column;gap:9px;max-height:100%;min-height:0;overflow:auto;scrollbar-width:thin}',
|
|
388
|
+
'.memp .audit-detail{border:1px solid var(--dsw-alias-border-l1);border-radius:11px;background:var(--dsw-alias-bg-layer-1);padding:10px 11px;display:flex;flex-direction:column;gap:9px;height:100%;max-height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}',
|
|
389
389
|
'.memp .audit-detail-head{display:flex;gap:7px;align-items:center}',
|
|
390
390
|
'.memp .audit-detail-head b{font-size:12.5px}',
|
|
391
391
|
'.memp .audit-detail-head .spacer{flex:1}',
|
|
@@ -408,6 +408,21 @@ window.__ModuleLoader__.load({
|
|
|
408
408
|
'.memp .audit-json{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:10px;line-height:1.45;white-space:pre-wrap;word-break:break-word;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:7px;max-height:220px;overflow:auto}',
|
|
409
409
|
'.memp .audit-pager{display:flex;gap:6px;align-items:center;justify-content:flex-end;font-size:11px;color:var(--dsw-alias-label-secondary)}',
|
|
410
410
|
'.memp .audit-flat{display:flex;flex-wrap:wrap;gap:4px}',
|
|
411
|
+
'.memp .audit-id{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:10px;line-height:1.65;padding:1px 6px;border-radius:6px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
412
|
+
'.memp .audit-id:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}',
|
|
413
|
+
'.memp .audit-id.omit{color:color-mix(in srgb,#D9A441 78%,var(--dsw-alias-label-primary));border-color:color-mix(in srgb,#D9A441 32%,var(--dsw-alias-border-l1))}',
|
|
414
|
+
'.memp .audit-id.dedup{opacity:.75}',
|
|
415
|
+
'.memp .audit-id-group{display:flex;flex-direction:column;gap:5px;padding:7px 8px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-2) 55%,transparent)}',
|
|
416
|
+
'.memp .audit-id-group-title{display:flex;align-items:center;gap:6px;font-size:10.5px;color:var(--dsw-alias-label-secondary);letter-spacing:.02em}',
|
|
417
|
+
'.memp .audit-id-group-title b{font-weight:600;color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}',
|
|
418
|
+
'.memp .audit-id-sub{font-size:9.5px;color:var(--dsw-alias-label-secondary);opacity:.85}',
|
|
419
|
+
'.memp .audit-tip{position:fixed;z-index:120;max-width:min(380px,calc(100vw - 24px));max-height:min(300px,60vh);overflow:hidden;padding:9px 10px;border:1px solid var(--dsw-alias-border-l2,var(--dsw-alias-border-l1));border-radius:10px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 97%,black 3%);box-shadow:0 14px 36px rgba(0,0,0,.28);pointer-events:none;color:var(--dsw-alias-label-primary)}',
|
|
420
|
+
'.memp .audit-tip-head{display:flex;align-items:center;gap:6px;margin-bottom:5px;font-size:11px;color:var(--dsw-alias-label-secondary)}',
|
|
421
|
+
'.memp .audit-tip-title{font-weight:600;color:var(--dsw-alias-label-primary);font-size:11.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}',
|
|
422
|
+
'.memp .audit-tip-meta{display:flex;flex-wrap:wrap;gap:4px;margin-bottom:5px}',
|
|
423
|
+
'.memp .audit-tip-content{font-size:11px;line-height:1.55;white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-primary);max-height:170px;overflow:hidden}',
|
|
424
|
+
'.memp .audit-tip-foot{margin-top:6px;font-size:9.5px;color:var(--dsw-alias-label-secondary)}',
|
|
425
|
+
'.memp .rec.focus{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-brand-primary) 25%,transparent)}',
|
|
411
426
|
'@media (max-width:900px){.memp .audit-split.has-detail{grid-template-columns:minmax(0,1fr)}.memp .audit-row{grid-template-columns:54px 120px 120px minmax(100px,1fr) 96px 100px 80px}.memp .audit-table-head{grid-template-columns:54px 120px 120px minmax(100px,1fr) 96px 100px 80px}}',
|
|
412
427
|
'@media (max-width:620px){.memp .audit-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.memp .audit-table-head{display:none}.memp .audit-row{display:flex;flex-wrap:wrap;gap:4px 8px}.memp .audit-row .col-trigger,.memp .audit-row .col-budget{display:none}.memp .audit-row .col-nums{margin-left:auto}.memp .audit-row .col-time{order:1}.memp .audit-row .col-channel{order:2}.memp .audit-row .col-delivery{order:3}.memp .audit-row .col-outcome{order:4;margin-left:auto}.memp .audit-filter-row input[type=text],.memp .audit-filter-row input[type=search]{max-width:none;flex:1}.memp .audit{height:calc(100vh - 120px);max-height:calc(100vh - 120px)}}',
|
|
413
428
|
].join('')
|
|
@@ -710,7 +725,7 @@ window.__ModuleLoader__.load({
|
|
|
710
725
|
})
|
|
711
726
|
}
|
|
712
727
|
|
|
713
|
-
function RecordCard({ rec, vectorOn, labels, onSaved, onDeleted }) {
|
|
728
|
+
function RecordCard({ rec, vectorOn, labels, onSaved, onDeleted, focus = false }) {
|
|
714
729
|
// collapsed by default: the list stays scannable, full text on demand
|
|
715
730
|
const [expanded, setExpanded] = React.useState(false)
|
|
716
731
|
const [editing, setEditing] = React.useState(false)
|
|
@@ -722,6 +737,9 @@ window.__ModuleLoader__.load({
|
|
|
722
737
|
const [error, setError] = React.useState('')
|
|
723
738
|
const [copied, setCopied] = React.useState(false)
|
|
724
739
|
|
|
740
|
+
// 从审计页点 memory ID 跳过来时自动展开目标记录。
|
|
741
|
+
React.useEffect(() => { if (focus) setExpanded(true) }, [focus])
|
|
742
|
+
|
|
725
743
|
const copyId = () => {
|
|
726
744
|
try {
|
|
727
745
|
if (navigator?.clipboard?.writeText) void navigator.clipboard.writeText(rec.id)
|
|
@@ -761,7 +779,7 @@ window.__ModuleLoader__.load({
|
|
|
761
779
|
setTags(rec.tags.join(', ')); setImportance(rec.importance)
|
|
762
780
|
}
|
|
763
781
|
|
|
764
|
-
return h('div', { className: 'rec' },
|
|
782
|
+
return h('div', { className: 'rec' + (focus ? ' focus' : '') },
|
|
765
783
|
h('div', {
|
|
766
784
|
className: 'rec-head',
|
|
767
785
|
role: 'button',
|
|
@@ -2123,7 +2141,12 @@ window.__ModuleLoader__.load({
|
|
|
2123
2141
|
{ value: 'custom', label: '自定义日期…', ms: null },
|
|
2124
2142
|
]
|
|
2125
2143
|
|
|
2126
|
-
|
|
2144
|
+
const AUDIT_OMIT_LABEL = {
|
|
2145
|
+
top_k: '条数上限', budget: '预算', superseded: '已退役', expired: '已过期',
|
|
2146
|
+
tag_mismatch: '标签不匹配', dedup: '去重', excluded: '被排除', skipped: '跳过',
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
function AuditTab({ scopes, records = [], openRecord, openSession, sessionInfo }) {
|
|
2127
2150
|
const [entries, setEntries] = React.useState([])
|
|
2128
2151
|
const [stats, setStats] = React.useState(null)
|
|
2129
2152
|
const [total, setTotal] = React.useState(0)
|
|
@@ -2148,6 +2171,8 @@ window.__ModuleLoader__.load({
|
|
|
2148
2171
|
const [until, setUntil] = React.useState('')
|
|
2149
2172
|
const [selectedId, setSelectedId] = React.useState(null)
|
|
2150
2173
|
const [reloadTick, setReloadTick] = React.useState(0)
|
|
2174
|
+
const [tip, setTip] = React.useState(null)
|
|
2175
|
+
const [recordCache, setRecordCache] = React.useState({})
|
|
2151
2176
|
|
|
2152
2177
|
function queryParams(cursorValue) {
|
|
2153
2178
|
const params = new URLSearchParams()
|
|
@@ -2211,6 +2236,73 @@ window.__ModuleLoader__.load({
|
|
|
2211
2236
|
|
|
2212
2237
|
const resetAndReload = () => { setCursor(''); setCursorStack([]); setReloadTick((n) => n + 1) }
|
|
2213
2238
|
const selected = selectedId === null ? null : entries.find((entry) => entry.id === selectedId) || null
|
|
2239
|
+
|
|
2240
|
+
// 记忆 ID / 会话 ID 的悬停浮窗与跳转。
|
|
2241
|
+
const recordMap = {}
|
|
2242
|
+
for (const rec of records) if (rec && rec.id) recordMap[rec.id] = rec
|
|
2243
|
+
for (const [id, rec] of Object.entries(recordCache)) if (!recordMap[id]) recordMap[id] = rec
|
|
2244
|
+
const findRecord = (id) => {
|
|
2245
|
+
if (recordMap[id]) return recordMap[id]
|
|
2246
|
+
return records.find((rec) => rec && rec.id && rec.id.startsWith(id)) || recordCache[id]
|
|
2247
|
+
}
|
|
2248
|
+
const fetchRecord = async (id) => {
|
|
2249
|
+
const known = findRecord(id)
|
|
2250
|
+
if (known) return known
|
|
2251
|
+
try {
|
|
2252
|
+
const value = await api(`records?id=${encodeURIComponent(id)}`)
|
|
2253
|
+
const rec = Array.isArray(value.records) ? value.records[0] : undefined
|
|
2254
|
+
if (rec !== undefined) setRecordCache((prev) => ({ ...prev, [rec.id]: rec, [id]: rec }))
|
|
2255
|
+
return rec
|
|
2256
|
+
} catch {
|
|
2257
|
+
return undefined
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
const tipPosition = (event) => {
|
|
2261
|
+
const width = typeof window !== 'undefined' ? window.innerWidth : 1200
|
|
2262
|
+
const height = typeof window !== 'undefined' ? window.innerHeight : 800
|
|
2263
|
+
return {
|
|
2264
|
+
x: Math.max(8, Math.min(event.clientX + 14, width - 390)),
|
|
2265
|
+
y: Math.max(8, Math.min(event.clientY + 14, height - 320)),
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
const moveTip = (event) => {
|
|
2269
|
+
if (!event || typeof event.clientX !== 'number') return
|
|
2270
|
+
setTip((prev) => prev === null ? prev : { ...prev, ...tipPosition(event) })
|
|
2271
|
+
}
|
|
2272
|
+
const hideTip = () => setTip(null)
|
|
2273
|
+
const showMemoryTip = (id, event) => {
|
|
2274
|
+
const pos = tipPosition(event)
|
|
2275
|
+
const known = findRecord(id)
|
|
2276
|
+
setTip({ type: 'memory', id, record: known, loading: known === undefined, ...pos })
|
|
2277
|
+
if (known === undefined) {
|
|
2278
|
+
fetchRecord(id).then((record) => {
|
|
2279
|
+
if (record !== undefined) setTip((prev) => prev !== null && prev.id === id ? { ...prev, record, loading: false } : prev)
|
|
2280
|
+
})
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
const showSessionTip = (id, event) => {
|
|
2284
|
+
const summary = typeof sessionInfo === 'function' ? (() => { try { return sessionInfo(id) } catch { return undefined } })() : undefined
|
|
2285
|
+
setTip({ type: 'session', id, summary, ...tipPosition(event) })
|
|
2286
|
+
}
|
|
2287
|
+
const openMemoryId = async (id) => {
|
|
2288
|
+
const record = findRecord(id) || await fetchRecord(id)
|
|
2289
|
+
hideTip()
|
|
2290
|
+
if (typeof openRecord === 'function') openRecord(record?.id ?? id, record?.scope)
|
|
2291
|
+
}
|
|
2292
|
+
const openSessionId = (id) => {
|
|
2293
|
+
hideTip()
|
|
2294
|
+
if (typeof openSession === 'function') openSession(id)
|
|
2295
|
+
}
|
|
2296
|
+
const idChip = (id, tone = '', title = undefined) => h('button', {
|
|
2297
|
+
key: `${tone}:${id}`,
|
|
2298
|
+
className: 'audit-id' + (tone ? ` ${tone}` : ''),
|
|
2299
|
+
title: title || id,
|
|
2300
|
+
onMouseEnter: (event) => showMemoryTip(id, event),
|
|
2301
|
+
onMouseMove: moveTip,
|
|
2302
|
+
onMouseLeave: hideTip,
|
|
2303
|
+
onClick: () => openMemoryId(id),
|
|
2304
|
+
}, id.length > 12 ? `${id.slice(0, 8)}…${id.slice(-4)}` : id)
|
|
2305
|
+
|
|
2214
2306
|
const prepared = entries.filter((entry) => entry.delivery && entry.delivery.status === 'unknown' && entry.reasonCode === 'prepared').length
|
|
2215
2307
|
const suppressed = entries.filter((entry) => entry.delivery && (entry.delivery.status === 'suppressed' || entry.delivery.status === 'not_attempted')).length
|
|
2216
2308
|
const failed = entries.filter((entry) => entry.outcome === 'failed').length
|
|
@@ -2380,10 +2472,36 @@ window.__ModuleLoader__.load({
|
|
|
2380
2472
|
})
|
|
2381
2473
|
const selectedIds = selected.selected ? selected.selected.contentIds : (selected.contentIds || [])
|
|
2382
2474
|
const hintIds = selected.selected ? selected.selected.hintIds : (selected.hintIds || [])
|
|
2475
|
+
const newlyAddedIds = selected.selected && Array.isArray(selected.selected.newlyAddedIds) ? selected.selected.newlyAddedIds : []
|
|
2383
2476
|
const omitted = Array.isArray(selected.omitted) ? selected.omitted : []
|
|
2477
|
+
const dedupIds = selected.dedup && Array.isArray(selected.dedup.ids) ? selected.dedup.ids : []
|
|
2478
|
+
const omitGroups = new Map()
|
|
2479
|
+
for (const item of omitted) {
|
|
2480
|
+
const reason = item.reason || 'other'
|
|
2481
|
+
if (!omitGroups.has(reason)) omitGroups.set(reason, [])
|
|
2482
|
+
omitGroups.get(reason).push(item)
|
|
2483
|
+
}
|
|
2484
|
+
const sameIdSet = (a, b) => a.length === b.length && a.every((id) => b.includes(id))
|
|
2485
|
+
const idGroup = (label, ids, tone, empty = '无', titleOf = undefined) => h('div', { className: 'audit-id-group' },
|
|
2486
|
+
h('div', { className: 'audit-id-group-title' }, h('span', null, label), h('b', null, String(ids.length))),
|
|
2487
|
+
ids.length > 0
|
|
2488
|
+
? h('div', { className: 'audit-flat' }, ids.map((id) => idChip(id, tone, titleOf ? titleOf(id) : undefined)))
|
|
2489
|
+
: h('span', { className: 'audit-id-sub' }, empty),
|
|
2490
|
+
)
|
|
2384
2491
|
const kv = (label, value) => (value === undefined || value === null || value === '')
|
|
2385
2492
|
? null
|
|
2386
2493
|
: [h('span', { className: 'k', key: `k-${label}` }, label), h('span', { className: 'v', key: `v-${label}` }, String(value))]
|
|
2494
|
+
const sessionNode = selected.sessionId
|
|
2495
|
+
? [h('span', { className: 'k', key: 'k-session' }, '会话'),
|
|
2496
|
+
h('span', { className: 'v', key: 'v-session' }, h('button', {
|
|
2497
|
+
className: 'audit-id',
|
|
2498
|
+
title: selected.sessionId,
|
|
2499
|
+
onMouseEnter: (event) => showSessionTip(selected.sessionId, event),
|
|
2500
|
+
onMouseMove: moveTip,
|
|
2501
|
+
onMouseLeave: hideTip,
|
|
2502
|
+
onClick: () => openSessionId(selected.sessionId),
|
|
2503
|
+
}, selected.sessionId))]
|
|
2504
|
+
: null
|
|
2387
2505
|
const json = JSON.stringify(selected, null, 2)
|
|
2388
2506
|
return h('div', { className: 'audit-detail' },
|
|
2389
2507
|
h('div', { className: 'audit-detail-head' },
|
|
@@ -2398,7 +2516,7 @@ window.__ModuleLoader__.load({
|
|
|
2398
2516
|
kv('序号', selected.seq),
|
|
2399
2517
|
kv('时间', fmtTime(selected.at)),
|
|
2400
2518
|
kv('schema', selected.schemaVersion || '旧版'),
|
|
2401
|
-
|
|
2519
|
+
sessionNode,
|
|
2402
2520
|
kv('step', selected.step),
|
|
2403
2521
|
kv('通道', `${auditChannelLabel(selected.channel)} / ${selected.kind}`),
|
|
2404
2522
|
kv('阶段', selected.stage),
|
|
@@ -2428,10 +2546,29 @@ window.__ModuleLoader__.load({
|
|
|
2428
2546
|
kv('选中', selectedIds.length),
|
|
2429
2547
|
kv('新增', selected.selected && selected.selected.newlyAddedIds ? selected.selected.newlyAddedIds.length : '—'),
|
|
2430
2548
|
kv('hint', hintIds.length),
|
|
2549
|
+
kv('省略', omitted.length),
|
|
2431
2550
|
kv('去重跳过', selected.dedup ? selected.dedup.skipped : '—'),
|
|
2432
2551
|
),
|
|
2433
|
-
|
|
2434
|
-
|
|
2552
|
+
h('div', { className: 'audit-id-sub' }, '候选中的可枚举 ID = 选中 + 省略;标签过滤 / 退役排除只在上方计数里。'),
|
|
2553
|
+
idGroup(selected.channel === 'rules' ? '选中规则' : '选中正文', selectedIds, '', '没有选中 ID'),
|
|
2554
|
+
newlyAddedIds.length > 0 && !sameIdSet(newlyAddedIds, selectedIds)
|
|
2555
|
+
? idGroup('本次新增到消息', newlyAddedIds, '', '无')
|
|
2556
|
+
: null,
|
|
2557
|
+
hintIds.length > 0 ? idGroup('标签索引(只给 ID,未注入正文)', hintIds, '', '无') : null,
|
|
2558
|
+
...Array.from(omitGroups.entries()).map(([reason, items]) => idGroup(
|
|
2559
|
+
`省略 · ${AUDIT_OMIT_LABEL[reason] || reason}`,
|
|
2560
|
+
items.map((item) => item.id),
|
|
2561
|
+
'omit',
|
|
2562
|
+
'无',
|
|
2563
|
+
(id) => {
|
|
2564
|
+
const item = items.find((entry) => entry.id === id)
|
|
2565
|
+
return `${id}${item && item.tags && item.tags.length > 0 ? ` · ${item.tags.join(', ')}` : ''}`
|
|
2566
|
+
},
|
|
2567
|
+
)),
|
|
2568
|
+
dedupIds.length > 0 ? idGroup('去重跳过', dedupIds, 'dedup', '无') : null,
|
|
2569
|
+
selectedIds.length + hintIds.length + omitted.length + dedupIds.length === 0
|
|
2570
|
+
? h('div', { className: 'audit-id-sub' }, '这条事件没有可枚举的记忆 ID。')
|
|
2571
|
+
: null,
|
|
2435
2572
|
),
|
|
2436
2573
|
budgetRows.length > 0 ? h('div', { className: 'audit-sec' },
|
|
2437
2574
|
h('div', { className: 'audit-sec-title' }, '预算'),
|
|
@@ -2492,6 +2629,43 @@ window.__ModuleLoader__.load({
|
|
|
2492
2629
|
: h('div', { className: 'audit-list' }, listHeader, entries.map(row))
|
|
2493
2630
|
const listArea = h('div', { className: 'audit-list-wrap' }, listBody)
|
|
2494
2631
|
|
|
2632
|
+
const tipNode = tip === null ? null : (() => {
|
|
2633
|
+
if (tip.type === 'session') {
|
|
2634
|
+
const summary = tip.summary || {}
|
|
2635
|
+
const title = summary.title || summary.name || `会话 ${String(tip.id).slice(0, 8)}`
|
|
2636
|
+
return h('div', { className: 'audit-tip', style: { left: tip.x, top: tip.y } },
|
|
2637
|
+
h('div', { className: 'audit-tip-head' }, h('span', null, '会话'), h('span', { className: 'audit-tip-title' }, title)),
|
|
2638
|
+
h('div', { className: 'audit-tip-meta' },
|
|
2639
|
+
auditPill(String(tip.id).slice(0, 8) + '…', 'mute'),
|
|
2640
|
+
summary.running === true ? auditPill('运行中', 'ok') : null,
|
|
2641
|
+
summary.archived === true ? auditPill('已归档', 'warn') : null,
|
|
2642
|
+
),
|
|
2643
|
+
summary.cwd ? h('div', { className: 'audit-tip-content' }, summary.cwd) : null,
|
|
2644
|
+
summary.updatedAt ? h('div', { className: 'audit-tip-foot' }, `更新于 ${fmtTime(summary.updatedAt)}`) : null,
|
|
2645
|
+
h('div', { className: 'audit-tip-foot' }, '点击打开会话'),
|
|
2646
|
+
)
|
|
2647
|
+
}
|
|
2648
|
+
const record = tip.record
|
|
2649
|
+
return h('div', { className: 'audit-tip', style: { left: tip.x, top: tip.y } },
|
|
2650
|
+
h('div', { className: 'audit-tip-head' }, h('span', null, '记忆'), h('span', { className: 'audit-tip-title' }, record ? record.id : tip.id)),
|
|
2651
|
+
record
|
|
2652
|
+
? h('div', null,
|
|
2653
|
+
h('div', { className: 'audit-tip-meta' },
|
|
2654
|
+
auditPill(record.kind, 'mute'),
|
|
2655
|
+
auditPill(record.scope, 'mute'),
|
|
2656
|
+
auditPill(`重要度 ${Number(record.importance ?? 0).toFixed(2)}`, 'mute'),
|
|
2657
|
+
),
|
|
2658
|
+
record.tags && record.tags.length > 0
|
|
2659
|
+
? h('div', { className: 'audit-flat' }, record.tags.map((tag) => h('span', { className: 'tag', key: tag }, tag)))
|
|
2660
|
+
: null,
|
|
2661
|
+
h('div', { className: 'audit-tip-content' }, `${String(record.content || '').slice(0, 700)}${String(record.content || '').length > 700 ? '…' : ''}`),
|
|
2662
|
+
)
|
|
2663
|
+
: h('div', { className: 'audit-tip-content' }, tip.loading ? '加载记录…' : '记录未找到(可能已删除或不在已加载作用域)'),
|
|
2664
|
+
h('div', { className: 'audit-tip-foot' }, '点击跳转到「记录」页并展开'),
|
|
2665
|
+
)
|
|
2666
|
+
})()
|
|
2667
|
+
|
|
2668
|
+
|
|
2495
2669
|
return h('div', { className: 'audit' },
|
|
2496
2670
|
...banner,
|
|
2497
2671
|
h('div', { className: 'audit-stats' },
|
|
@@ -2521,13 +2695,14 @@ window.__ModuleLoader__.load({
|
|
|
2521
2695
|
load(nextCursor, stack)
|
|
2522
2696
|
} }, '下一页'),
|
|
2523
2697
|
),
|
|
2698
|
+
tipNode,
|
|
2524
2699
|
)
|
|
2525
2700
|
}
|
|
2526
2701
|
|
|
2527
2702
|
/** 待嵌入自动刷新:最多 300 次 × 1.5s(后端挂着时不无限轮询)。 */
|
|
2528
2703
|
const PENDING_POLL_LIMIT = 300
|
|
2529
2704
|
|
|
2530
|
-
function MemoryPanel() {
|
|
2705
|
+
function MemoryPanel({ openSession, sessionInfo } = {}) {
|
|
2531
2706
|
const [records, setRecords] = React.useState([])
|
|
2532
2707
|
const [scopes, setScopes] = React.useState([])
|
|
2533
2708
|
const [embedServer, setEmbedServer] = React.useState(null)
|
|
@@ -2537,6 +2712,7 @@ window.__ModuleLoader__.load({
|
|
|
2537
2712
|
const [dangerAsk, setDangerAsk] = React.useState('')
|
|
2538
2713
|
const [scopeFilter, setScopeFilter] = React.useState('')
|
|
2539
2714
|
const [q, setQ] = React.useState('')
|
|
2715
|
+
const [focusRecord, setFocusRecord] = React.useState(null)
|
|
2540
2716
|
const [loading, setLoading] = React.useState(true)
|
|
2541
2717
|
const [error, setError] = React.useState('')
|
|
2542
2718
|
const [tab, setTab] = React.useState('data')
|
|
@@ -2562,6 +2738,16 @@ window.__ModuleLoader__.load({
|
|
|
2562
2738
|
setLoading(false)
|
|
2563
2739
|
}
|
|
2564
2740
|
React.useEffect(() => { load('', '') }, [])
|
|
2741
|
+
|
|
2742
|
+
/** 审计里的记忆 ID → 切到「记录」页并展开对应记录。 */
|
|
2743
|
+
const openRecord = (id, scope) => {
|
|
2744
|
+
setFocusRecord(id)
|
|
2745
|
+
setTab('data')
|
|
2746
|
+
setQ('')
|
|
2747
|
+
const nextScope = scope || ''
|
|
2748
|
+
setScopeFilter(nextScope)
|
|
2749
|
+
load('', nextScope)
|
|
2750
|
+
}
|
|
2565
2751
|
// 导入完成后从设置页切换回记录页时,列表要能看到新数据(事件由设置页发出)。
|
|
2566
2752
|
React.useEffect(() => {
|
|
2567
2753
|
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
|
|
@@ -2855,7 +3041,7 @@ window.__ModuleLoader__.load({
|
|
|
2855
3041
|
const listBody = !loading && !error && records.length === 0
|
|
2856
3042
|
? h('div', { className: 'empty' }, filtering ? '没有匹配的记忆' : '还没有记忆')
|
|
2857
3043
|
: h('div', { className: 'list' },
|
|
2858
|
-
records.map((rec) => h(RecordCard, { key: rec.id, rec, vectorOn: configured && vectorEnabled, labels: labels, onSaved: () => { setPendingTick(0); load() }, onDeleted: () => { setPendingTick(0); load() } })))
|
|
3044
|
+
records.map((rec) => h(RecordCard, { key: rec.id, rec, focus: focusRecord === rec.id, vectorOn: configured && vectorEnabled, labels: labels, onSaved: () => { setPendingTick(0); load() }, onDeleted: () => { setPendingTick(0); load() } })))
|
|
2859
3045
|
|
|
2860
3046
|
// 服务页底部:一句号召 + 两个外链(Star / issue)。放在内容最后,不打扰上面的状态卡。
|
|
2861
3047
|
const footer = h('div', { className: 'footer' },
|
|
@@ -2901,7 +3087,7 @@ window.__ModuleLoader__.load({
|
|
|
2901
3087
|
: tab === 'tree'
|
|
2902
3088
|
? treeBody
|
|
2903
3089
|
: tab === 'audit'
|
|
2904
|
-
? h(AuditTab, { scopes })
|
|
3090
|
+
? h(AuditTab, { scopes, records, openRecord, openSession, sessionInfo })
|
|
2905
3091
|
: overviewBody,
|
|
2906
3092
|
)
|
|
2907
3093
|
}
|
|
@@ -2909,10 +3095,10 @@ window.__ModuleLoader__.load({
|
|
|
2909
3095
|
const inject = ['slots']
|
|
2910
3096
|
|
|
2911
3097
|
/** 侧栏入口打开的主界面页面(整块可滚动,内容就是面板本体)。 */
|
|
2912
|
-
function MemoryPage() {
|
|
3098
|
+
function MemoryPage({ openSession, sessionInfo } = {}) {
|
|
2913
3099
|
return h('div', { className: 'mem-page' },
|
|
2914
3100
|
h('div', { className: 'mem-page-head' }, h('h2', null, '记忆系统')),
|
|
2915
|
-
h(MemoryPanel, {}),
|
|
3101
|
+
h(MemoryPanel, { openSession, sessionInfo }),
|
|
2916
3102
|
)
|
|
2917
3103
|
}
|
|
2918
3104
|
|
|
@@ -2955,9 +3141,40 @@ window.__ModuleLoader__.load({
|
|
|
2955
3141
|
|
|
2956
3142
|
const slots = ctx.get('slots')
|
|
2957
3143
|
if (slots === undefined) return
|
|
3144
|
+
|
|
3145
|
+
/** 宿主 uiWorkspace 服务:打开会话 / 读取会话摘要(旧宿主缺失时静默降级)。 */
|
|
3146
|
+
const workspaceService = () => {
|
|
3147
|
+
try { return ctx.get('uiWorkspace') } catch { return undefined }
|
|
3148
|
+
}
|
|
3149
|
+
const openSession = (id) => {
|
|
3150
|
+
try {
|
|
3151
|
+
const workspace = workspaceService()
|
|
3152
|
+
if (workspace && typeof workspace.openSession === 'function') {
|
|
3153
|
+
workspace.openSession(id)
|
|
3154
|
+
return
|
|
3155
|
+
}
|
|
3156
|
+
// 没有 uiWorkspace(极旧宿主/独立预览)时退回 hash 路由;不保证宿主识别。
|
|
3157
|
+
if (typeof window !== 'undefined') window.location.hash = `#/s/${encodeURIComponent(id)}`
|
|
3158
|
+
} catch (error) {
|
|
3159
|
+
console.warn('[dsh-memory] 打开会话失败:', error?.message)
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
const sessionInfo = (id) => {
|
|
3163
|
+
try {
|
|
3164
|
+
const workspace = workspaceService()
|
|
3165
|
+
const summary = workspace?.sessions?.list?.getSnapshot?.()?.byId?.[id]
|
|
3166
|
+
if (summary !== undefined) return summary
|
|
3167
|
+
const session = ctx.get('sessions')?.get?.(id)
|
|
3168
|
+
if (session === undefined) return undefined
|
|
3169
|
+
return session.summary ?? session
|
|
3170
|
+
} catch {
|
|
3171
|
+
return undefined
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
|
|
2958
3175
|
slots.inject('settings.section', () => slots.register(
|
|
2959
3176
|
{ name: 'settings.section', id: 'memory', order: 24, label: NAV_LABEL },
|
|
2960
|
-
() => React.createElement(MemoryPanel),
|
|
3177
|
+
() => React.createElement(MemoryPanel, { openSession, sessionInfo }),
|
|
2961
3178
|
))
|
|
2962
3179
|
|
|
2963
3180
|
// 侧栏入口(可选):开启后在左侧栏「插件」下方多一个「记忆系统」,点击在主界面打开面板。
|
|
@@ -2976,7 +3193,7 @@ window.__ModuleLoader__.load({
|
|
|
2976
3193
|
}
|
|
2977
3194
|
try {
|
|
2978
3195
|
sidebarDisposers = [
|
|
2979
|
-
slots.inject('main', () => slots.register({ name: 'main', key: 'memory' }, () => React.createElement(MemoryPage))),
|
|
3196
|
+
slots.inject('main', () => slots.register({ name: 'main', key: 'memory' }, () => React.createElement(MemoryPage, { openSession, sessionInfo }))),
|
|
2980
3197
|
slots.inject('sidebar.panellist', () => slots.register(
|
|
2981
3198
|
{ name: 'sidebar.panellist', id: 'memory', order: 20, label: () => NAV_LABEL },
|
|
2982
3199
|
() => React.createElement(NavLineIcon),
|
package/lib/panel.js
CHANGED
|
@@ -592,6 +592,7 @@ async function handle(ctx, routePath, req, res) {
|
|
|
592
592
|
if (method === 'GET' && path === '/records') {
|
|
593
593
|
const rawScope = url.searchParams.get('scope')
|
|
594
594
|
const query = (url.searchParams.get('q') ?? '').trim().toLowerCase()
|
|
595
|
+
const idQuery = (url.searchParams.get('id') ?? '').trim()
|
|
595
596
|
// scope 先过同一套规范化:非法 → 400(而不是当成一个陌生 scope 去建文件);
|
|
596
597
|
// 合法但不存在的 scope → 空列表。`peek`/`peekScope`,**绝不通过 store.scope() 创建**。
|
|
597
598
|
let scope = null
|
|
@@ -624,6 +625,9 @@ async function handle(ctx, routePath, req, res) {
|
|
|
624
625
|
|| r.kind.toLowerCase().includes(query)
|
|
625
626
|
|| r.tags.some((t) => t.toLowerCase().includes(query)))
|
|
626
627
|
}
|
|
628
|
+
if (idQuery) {
|
|
629
|
+
records = records.filter((r) => r.id === idQuery || r.id.startsWith(idQuery))
|
|
630
|
+
}
|
|
627
631
|
writeJson(res, { ok: true, value: { records } })
|
|
628
632
|
return
|
|
629
633
|
}
|