@restregular/dsh-memory 0.14.5 → 0.14.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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  本项目的版本记录。安装 id 与 npm 版本一一对应。
4
4
 
5
+ ## 0.14.6 — 审计记忆 ID 跳转后自动展开并滚到目标记录
6
+
7
+ - **现象**:在审计详情里点某个记忆 ID,会切到记录页,但目标记录没有展开,看起来像没跳成功。
8
+ - **原因**:`openRecord` 只设置了 `focusRecord`,没有把目标记录滚进可视区;目标记录如果不在当前筛选/已加载结果里,列表里甚至没有这张卡,自然也无法展开。
9
+ - **修复**:`RecordCard` 在 `focus` 时先展开,再用 `scrollIntoView({block:'center'})` 把卡片滚到视口中央;`openRecord` 同时接收记录对象,目标不在当前列表时把它补到列表最前面,保证跳过去一定能看到并展开。
10
+ - 回归测试:带 `focus` 的记录卡自动展开。
11
+
5
12
  ## 0.14.5 — 修复记忆面板审计「在轨迹中定位」不生效
6
13
 
7
14
  - **根因**:主面板把 `jumpAuditEntryToTrajectory`(签名是 `(entry) => Promise`)当成 `openTrajectory(focus)` 回调传给 `AuditTab`。按钮把 `callId` 字符串传进去,`jumpAuditEntryToTrajectory` 读不到 `entry.sessionId`,直接按 `no_session` 返回,实际什么都没发生;UI 还误报“已定位到轨迹”。
package/lib/client.js CHANGED
@@ -796,7 +796,18 @@ window.__ModuleLoader__.load({
796
796
  const [copied, setCopied] = React.useState(false)
797
797
 
798
798
  // 从审计页点 memory ID 跳过来时自动展开目标记录。
799
- React.useEffect(() => { if (focus) setExpanded(true) }, [focus])
799
+ // 记录列表可能很长,展开后还要把它滚进视口,否则用户看到的是列表顶部。
800
+ const cardRef = React.useRef(null)
801
+ React.useEffect(() => {
802
+ if (!focus) return undefined
803
+ setExpanded(true)
804
+ const node = cardRef.current
805
+ if (node === null || typeof node.scrollIntoView !== 'function') return undefined
806
+ const timer = setTimeout(() => {
807
+ try { node.scrollIntoView({ block: 'center', behavior: 'smooth' }) } catch { /* 滚动失败不影响展开 */ }
808
+ }, 60)
809
+ return () => clearTimeout(timer)
810
+ }, [focus])
800
811
 
801
812
  const copyId = () => {
802
813
  try {
@@ -837,7 +848,7 @@ window.__ModuleLoader__.load({
837
848
  setTags(rec.tags.join(', ')); setImportance(rec.importance)
838
849
  }
839
850
 
840
- return h('div', { className: 'rec' + (focus ? ' focus' : '') },
851
+ return h('div', { className: 'rec' + (focus ? ' focus' : ''), ref: cardRef },
841
852
  h('div', {
842
853
  className: 'rec-head',
843
854
  role: 'button',
@@ -2687,7 +2698,7 @@ window.__ModuleLoader__.load({
2687
2698
  const openMemoryId = async (id) => {
2688
2699
  const record = findRecord(id) || await fetchRecord(id)
2689
2700
  hideTip()
2690
- if (typeof openRecord === 'function') openRecord(record?.id ?? id, record?.scope)
2701
+ if (typeof openRecord === 'function') openRecord(record?.id ?? id, record?.scope, record)
2691
2702
  }
2692
2703
  const openSessionId = (id) => {
2693
2704
  hideTip()
@@ -3155,6 +3166,7 @@ window.__ModuleLoader__.load({
3155
3166
  const [semantic, setSemantic] = React.useState(false)
3156
3167
  const [searchInfo, setSearchInfo] = React.useState(null)
3157
3168
  const [focusRecord, setFocusRecord] = React.useState(null)
3169
+ const [focusRecordData, setFocusRecordData] = React.useState(null)
3158
3170
  const [loading, setLoading] = React.useState(true)
3159
3171
  const [error, setError] = React.useState('')
3160
3172
  const [tab, setTab] = React.useState('data')
@@ -3212,8 +3224,11 @@ window.__ModuleLoader__.load({
3212
3224
  React.useEffect(() => { load('', '') }, [])
3213
3225
 
3214
3226
  /** 审计里的记忆 ID → 切到「记录」页并展开对应记录。 */
3215
- const openRecord = (id, scope) => {
3227
+ const openRecord = (id, scope, record = null) => {
3216
3228
  setFocusRecord(id)
3229
+ // 目标记录可能不在当前筛选结果里(作用域/搜索/分页),先把它拿在手上,
3230
+ // 列表里没有时补一张卡,保证跳过去一定能展开。
3231
+ setFocusRecordData(record && record.id ? record : null)
3217
3232
  setTab('data')
3218
3233
  setQ('')
3219
3234
  // 语义模式是按查询排名的:跳转要看到那条记录,必须回到普通列表。
@@ -3568,12 +3583,17 @@ window.__ModuleLoader__.load({
3568
3583
  })
3569
3584
  : null
3570
3585
  const emptyText = searchInfo ? '没有语义相关的记忆' : filtering ? '没有匹配的记忆' : '还没有记忆'
3571
- const listBody = !loading && !error && records.length === 0
3586
+ // 从审计跳过来的目标记录如果不在当前加载结果里,先把它补到列表最前面,
3587
+ // 否则跳转后列表里根本没有这张卡,focus 自然也无法展开。
3588
+ const displayRecords = focusRecordData !== null && !records.some((rec) => rec.id === focusRecordData.id)
3589
+ ? [focusRecordData, ...records]
3590
+ : records
3591
+ const listBody = !loading && !error && displayRecords.length === 0
3572
3592
  ? h('div', { className: 'empty' },
3573
3593
  emptyText,
3574
3594
  searchInfo ? h('div', { className: 'muted' }, '换个说法试试;刚写入的记录可能还没嵌入向量。') : null)
3575
3595
  : h('div', { className: 'list' },
3576
- records.map((rec) => h(RecordCard, { key: rec.id, rec, score: rec.score, focus: focusRecord === rec.id, vectorOn: configured && vectorEnabled, labels: labels, onSaved: () => { setPendingTick(0); load() }, onDeleted: () => { setPendingTick(0); load() } })))
3596
+ displayRecords.map((rec) => h(RecordCard, { key: rec.id, rec, score: rec.score, focus: focusRecord === rec.id, vectorOn: configured && vectorEnabled, labels: labels, onSaved: () => { setPendingTick(0); load() }, onDeleted: () => { setPendingTick(0); load() } })))
3577
3597
 
3578
3598
  // 服务页底部:一句号召 + 两个外链(Star / issue)。放在内容最后,不打扰上面的状态卡。
3579
3599
  const footer = h('div', { className: 'footer' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.14.5",
3
+ "version": "0.14.6",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",