@240xu/dsh-message-ops 0.8.0 → 0.9.2
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/README.md +162 -7
- package/package.json +2 -2
- package/src/client.js +312 -132
- package/src/index.js +114 -103
- package/src/ops-core.js +213 -65
- package/src/session-file.js +29 -1
- package/test/branch-export-removed.test.js +73 -0
- package/test/fence.test.js +0 -27
- package/test/injected-regex.test.js +62 -0
- package/test/legacy-format.test.js +0 -17
- package/test/ops-core.test.js +42 -45
- package/test/revert-contract.test.js +118 -0
- package/test/session-file.test.js +0 -24
- package/test/step-restore.test.js +16 -0
- package/test/surface-visibility.test.js +166 -0
- package/test/user-revert-anchor.test.js +103 -0
- package/src/branch.js +0 -57
package/src/client.js
CHANGED
|
@@ -41,6 +41,8 @@ window.__ModuleLoader__.load({
|
|
|
41
41
|
'dialog.session': '会话:',
|
|
42
42
|
'dialog.runningWarn': '⚠ 会话正在运行:请先停止该会话再执行回滚/删除/分支。',
|
|
43
43
|
'dialog.pick': '选择一条消息:',
|
|
44
|
+
'dialog.pickFirst': '第 1 步 · 在下方选择一条消息,第 2 步在这里选择操作。',
|
|
45
|
+
'dialog.pickedAs': '已选 #{seq} · {{text}}',
|
|
44
46
|
'dialog.invisible': '(已遮蔽,仅日志可见)',
|
|
45
47
|
'dialog.showMore': '显示更多(剩余 {n} 条)',
|
|
46
48
|
'dialog.more': '…(仅显示最近 200 条,共 {n} 条)',
|
|
@@ -63,18 +65,14 @@ window.__ModuleLoader__.load({
|
|
|
63
65
|
'done.delete': '删除完成,刷新页面后生效',
|
|
64
66
|
'action.reload': '刷新页面',
|
|
65
67
|
'errorPrefix': '操作失败:',
|
|
66
|
-
'op.restore': '恢复(重放被遮蔽的消息)',
|
|
67
|
-
'op.restoreDesc': '仅当选中行是回滚/删除标记时可用。这是重放而非取消遮蔽:被遮蔽的用户/助手消息会以新 seq 重新追加并带「[恢复]」前缀;不可重放的事件(如工具调用)会被跳过并计数。',
|
|
68
68
|
'slot.revert': '回滚到此条',
|
|
69
69
|
'slot.delete': '删除此条',
|
|
70
70
|
'slot.branch': '从此分支',
|
|
71
71
|
'toast.openNew': '打开新会话',
|
|
72
72
|
'fork.official': '分支完成:新会话 {id}',
|
|
73
|
-
'fork.
|
|
73
|
+
'fork.unavailable': '官方分支不可用:通常是因为会话正在运行,请先停止会话后重试。分支功能由 dsh 内置的 session/fork 提供。',
|
|
74
74
|
'done.restore': '恢复完成:重放 {n} 条,跳过不可重放 {s} 条',
|
|
75
75
|
'busy.restore': '恢复中…',
|
|
76
|
-
'confirm.restore': '恢复',
|
|
77
|
-
'ack.restore': '我已了解:恢复将以新 seq 重放被遮蔽的消息(原日志不变)',
|
|
78
76
|
'dock.title': '已回撤 {n} 条消息',
|
|
79
77
|
'dock.expand': '展开回撤列表',
|
|
80
78
|
'dock.collapse': '折叠回撤列表',
|
|
@@ -96,6 +94,8 @@ window.__ModuleLoader__.load({
|
|
|
96
94
|
'dialog.session': 'Session: ',
|
|
97
95
|
'dialog.runningWarn': '⚠ Session is running: stop it before revert / delete / branch.',
|
|
98
96
|
'dialog.pick': 'Pick a message:',
|
|
97
|
+
'dialog.pickFirst': 'Step 1 · pick a message below, then choose an operation here.',
|
|
98
|
+
'dialog.pickedAs': 'Selected #${seq} · ${text}',
|
|
99
99
|
'dialog.invisible': ' (shadowed, log-only)',
|
|
100
100
|
'dialog.showMore': 'Show more ({n} older)',
|
|
101
101
|
'dialog.more': '…(showing latest 200 of {n})',
|
|
@@ -105,14 +105,13 @@ window.__ModuleLoader__.load({
|
|
|
105
105
|
'op.deleteDesc': 'Shadows only the picked message; everything else stays.',
|
|
106
106
|
'op.branch': 'Branch into a new session from here',
|
|
107
107
|
'op.branchDesc': 'Copies everything up to and including the picked message into a new session (original untouched, non-destructive).',
|
|
108
|
-
'op.restore': 'Restore (replay shadowed messages)',
|
|
109
|
-
'op.restoreDesc': 'Only when the selected row is a revert/delete marker. This is a replay, not an un-shadow: shadowed user/assistant messages are re-appended with NEW seqs and a [Restored] prefix; non-replayable events (tool calls) are skipped and counted.',
|
|
110
108
|
'slot.revert': 'Revert to here',
|
|
109
|
+
'slot.revertUnmatched': 'Cannot locate this message seq in the log (usually the model-written summary drifted too far from the rendered text) — use the Message ops dialog instead.',
|
|
111
110
|
'slot.delete': 'Delete this message',
|
|
112
111
|
'slot.branch': 'Branch from here',
|
|
113
112
|
'toast.openNew': 'Open new session',
|
|
114
113
|
'fork.official': 'Branched (official fork): new session {id}',
|
|
115
|
-
'fork.
|
|
114
|
+
'fork.unavailable': 'Built-in branch unavailable — usually because the session is running. Stop it and retry. Branching is provided by the dsh built-in session/fork.',
|
|
116
115
|
'ack.revert': 'I understand: revert shadows the picked message and everything after it',
|
|
117
116
|
'ack.delete': 'I understand: this message will be shadowed (kept in the log)',
|
|
118
117
|
'confirm.revert': 'Revert',
|
|
@@ -124,8 +123,6 @@ window.__ModuleLoader__.load({
|
|
|
124
123
|
'done.branch': 'Branched: new session {id} (visible after list refresh)',
|
|
125
124
|
'done.restore': 'Restored: replayed {n}, skipped non-replayable {s}',
|
|
126
125
|
'busy.restore': 'Restoring…',
|
|
127
|
-
'confirm.restore': 'Restore',
|
|
128
|
-
'ack.restore': 'I understand: restore re-appends shadowed messages with new seqs (the log stays append-only)',
|
|
129
126
|
'done.revert': 'Reverted; reload to apply',
|
|
130
127
|
'done.delete': 'Deleted; reload to apply',
|
|
131
128
|
'action.reload': 'Reload page',
|
|
@@ -146,7 +143,12 @@ window.__ModuleLoader__.load({
|
|
|
146
143
|
var __sessionsSvc = null
|
|
147
144
|
var __inputActions = null // 0.4.0: 从 session 槽捕获(InputActions.setDraft → composer 回填)
|
|
148
145
|
var __uiWorkspace = null
|
|
149
|
-
var __currentSessionId = null
|
|
146
|
+
var __currentSessionId = null
|
|
147
|
+
// 0.9.1:视图重建后刷新 transcript 可见性的钩子。
|
|
148
|
+
// 之前 restore 路径里直接调 scan(),但 scan 定义在注入器的闭包里,
|
|
149
|
+
// dock 组件根本取不到 —— `typeof scan === 'function'` 静默跳过了,
|
|
150
|
+
// 结果「恢复后消息回来了但仍被藏 / dock 计数不变」,必须重载页面才对。
|
|
151
|
+
var __refreshSurface = null // 0.6.0:会话视图会话 id(RevertDock/MsgSlotActions 刷新)
|
|
150
152
|
// messageId→seq 索引缓存(每会话一次拉取;0.3.0 assistant-actions 槽用)
|
|
151
153
|
var __seqIndexCache = new Map()
|
|
152
154
|
// messageId→全文缓存(0.5.0 消息引用用)
|
|
@@ -323,72 +325,40 @@ window.__ModuleLoader__.load({
|
|
|
323
325
|
setMode(m); setAcknowledged(false); setError(null)
|
|
324
326
|
}, [picked, state])
|
|
325
327
|
|
|
326
|
-
// 磁盘分支回退(0.1.x / 官方 fork 失败时):POST /api/message-ops/branch
|
|
327
|
-
const diskBranch = (cause) => {
|
|
328
|
-
const finish = () => {
|
|
329
|
-
fetch('/api/message-ops/branch', {
|
|
330
|
-
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
331
|
-
body: JSON.stringify({ sessionId: target.sessionId, upToSeq: picked }),
|
|
332
|
-
})
|
|
333
|
-
.then(async (res) => {
|
|
334
|
-
let data = {}
|
|
335
|
-
try { data = await res.json() } catch { /* keep {} */ }
|
|
336
|
-
if (!res.ok || !data.ok) throw new Error(data.error || `HTTP ${res.status}`)
|
|
337
|
-
setDoneMsg(t('fork.disk', { id: data.newId || '' }))
|
|
338
|
-
setBusyMsg('')
|
|
339
|
-
setChildId(null)
|
|
340
|
-
setState('done')
|
|
341
|
-
// ISessions.refresh() 是宿主现行 API;refreshList 是旧名兜底。
|
|
342
|
-
if (__sessionsSvc) {
|
|
343
|
-
try {
|
|
344
|
-
const r = typeof __sessionsSvc.refresh === 'function'
|
|
345
|
-
? __sessionsSvc.refresh()
|
|
346
|
-
: (typeof __sessionsSvc.refreshList === 'function' ? __sessionsSvc.refreshList() : null)
|
|
347
|
-
if (r != null) Promise.resolve(r).catch(() => {})
|
|
348
|
-
} catch { /* ignore */ }
|
|
349
|
-
}
|
|
350
|
-
})
|
|
351
|
-
.catch((reason) => {
|
|
352
|
-
setBusyMsg('')
|
|
353
|
-
setState('ready')
|
|
354
|
-
setError(t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)))
|
|
355
|
-
})
|
|
356
|
-
}
|
|
357
|
-
if (cause) {
|
|
358
|
-
// 官方 fork 失败原因留痕后回退
|
|
359
|
-
setError(t('errorPrefix') + (cause && cause.message ? cause.message : String(cause)) + ' → fallback')
|
|
360
|
-
}
|
|
361
|
-
finish()
|
|
362
|
-
}
|
|
363
|
-
|
|
364
328
|
const run = useCallback(() => {
|
|
365
329
|
if (state === 'busy' || picked == null || !mode) return
|
|
366
|
-
if (mode !== 'branch' &&
|
|
367
|
-
setBusyMsg(t('busy.' + (mode === 'revert' || mode === 'delete'
|
|
330
|
+
if (mode !== 'branch' && !acknowledged) return
|
|
331
|
+
setBusyMsg(t('busy.' + (mode === 'revert' || mode === 'delete' ? mode : 'branch')))
|
|
368
332
|
setState('busy'); setError(null)
|
|
369
333
|
if (mode === 'branch') {
|
|
370
|
-
// 0.
|
|
371
|
-
//
|
|
334
|
+
// 0.9.0:分支**只走官方** sessions.fork({atSeq})。
|
|
335
|
+
// 原先有一条「官方失败 → 磁盘 applyBranch」的回落,但那个实现语义是错的:
|
|
336
|
+
// 它删掉 isSeeded(官方 fork 设 true)、不写 inheritedEventCount、
|
|
337
|
+
// 也不调 buildForkSeed 补 step/turn closers → 产出的子会话边界可能悬空。
|
|
338
|
+
// 官方 fork 失败通常意味着源会话正在运行,正确做法是拒绝而非绕过引擎写盘。
|
|
372
339
|
const forkPath = pickForkPath(__sessionsSvc)
|
|
373
|
-
if (forkPath.kind
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
setBusyMsg('')
|
|
378
|
-
setChildId(childId || null)
|
|
379
|
-
setState('done')
|
|
380
|
-
notifyDone(t('fork.official', { id: String(childId || '') }))
|
|
381
|
-
})
|
|
382
|
-
.catch((reason) => {
|
|
383
|
-
// 官方 fork 失败(如未编目)→ 回退磁盘分支,不中断用户
|
|
384
|
-
return diskBranch(reason)
|
|
385
|
-
})
|
|
340
|
+
if (forkPath.kind !== 'official') {
|
|
341
|
+
setError(t('fork.unavailable'))
|
|
342
|
+
setBusyMsg('')
|
|
343
|
+
setState('error')
|
|
386
344
|
return
|
|
387
345
|
}
|
|
388
|
-
|
|
346
|
+
forkPath.fork({ sessionId: target.sessionId, atSeq: picked, increaseTitle: true })
|
|
347
|
+
.then((childId) => {
|
|
348
|
+
setDoneMsg(t('fork.official', { id: String(childId || '') }))
|
|
349
|
+
setBusyMsg('')
|
|
350
|
+
setChildId(childId || null)
|
|
351
|
+
setState('done')
|
|
352
|
+
notifyDone(t('fork.official', { id: String(childId || '') }))
|
|
353
|
+
})
|
|
354
|
+
.catch((reason) => {
|
|
355
|
+
setError(String((reason && reason.message) || reason || t('fork.unavailable')))
|
|
356
|
+
setBusyMsg('')
|
|
357
|
+
setState('error')
|
|
358
|
+
})
|
|
389
359
|
return
|
|
390
360
|
}
|
|
391
|
-
const path = mode
|
|
361
|
+
const path = mode
|
|
392
362
|
const body = { sessionId: target.sessionId, seq: picked }
|
|
393
363
|
Promise.resolve()
|
|
394
364
|
.then(() => fetch('/api/message-ops/' + path, {
|
|
@@ -403,7 +373,6 @@ window.__ModuleLoader__.load({
|
|
|
403
373
|
// S6 修复(G-M1):不再 900ms 裸 location.reload。成功走 devkit
|
|
404
374
|
// 标准 toast(无 devkit 时降级为对话框内 doneMsg),并提供手动
|
|
405
375
|
// 「刷新页面」按钮。
|
|
406
|
-
const okMsg = mode === 'restore'
|
|
407
376
|
? t('done.restore', { n: String(data.restoredCount != null ? data.restoredCount : '?'), s: String(data.skipped != null ? data.skipped : 0) })
|
|
408
377
|
: t(mode === 'revert' ? 'done.revert' : 'done.delete')
|
|
409
378
|
// 0.4.0 composer 回填(opencode 式):回滚用户消息 → 原文回填输入框,「编辑重发」零按钮
|
|
@@ -442,6 +411,35 @@ window.__ModuleLoader__.load({
|
|
|
442
411
|
const pagedCount = shownBase.length - shown.length
|
|
443
412
|
const pickedMsg = picked != null ? messages.find((m) => m.seq === picked) : null
|
|
444
413
|
|
|
414
|
+
// 0.9.0 可发现性:操作区固定在**消息列表之前**。
|
|
415
|
+
// 原先它在列表之后,而列表是 260px 滚动 + 分批渲染 50 条/页 ——
|
|
416
|
+
// 未选中消息时三个 radio 完全不在视野内,用户以为「只有列表、没有操作」。
|
|
417
|
+
// 未选中时给明确指引,而不是空着。
|
|
418
|
+
const opsPanel = pickedMsg
|
|
419
|
+
? React.createElement('div', { key: 'ops', style: { margin: '8px 0 0' } },
|
|
420
|
+
React.createElement('div', { style: { ...metaStyle, margin: '0 0 4px' } },
|
|
421
|
+
t('dialog.pickedAs', { seq: String(pickedMsg.seq), text: (pickedMsg.snippet || '').slice(0, 60) })),
|
|
422
|
+
['revert', 'delete', 'branch'].map((m, i) => React.createElement('div', { key: m, style: { marginTop: i === 0 ? 6 : 4 } },
|
|
423
|
+
React.createElement('label', { style: optStyle },
|
|
424
|
+
React.createElement('input', {
|
|
425
|
+
type: 'radio', name: 'dsh-message-ops-mode', checked: mode === m,
|
|
426
|
+
onChange: () => chooseMode(m), disabled: state === 'busy',
|
|
427
|
+
}),
|
|
428
|
+
t('op.' + m)),
|
|
429
|
+
mode === m ? React.createElement('div', { style: descStyle }, t('op.' + m + 'Desc')) : null,
|
|
430
|
+
)),
|
|
431
|
+
mode && mode !== 'branch'
|
|
432
|
+
? React.createElement('label', { key: 'ack', style: optStyle },
|
|
433
|
+
React.createElement('input', {
|
|
434
|
+
type: 'checkbox', checked: acknowledged, disabled: state === 'busy',
|
|
435
|
+
onChange: (e) => setAcknowledged(e.target.checked),
|
|
436
|
+
}),
|
|
437
|
+
t(mode === 'revert' ? 'ack.revert' : 'ack.delete'))
|
|
438
|
+
: null,
|
|
439
|
+
)
|
|
440
|
+
: React.createElement('div', { key: 'opshint', style: { ...metaStyle, margin: '8px 0 0', padding: '6px 8px', borderRadius: 6, background: 'var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.1))' } },
|
|
441
|
+
t('dialog.pickFirst'))
|
|
442
|
+
|
|
445
443
|
let body
|
|
446
444
|
if (state === 'loading') {
|
|
447
445
|
body = React.createElement('div', { key: 'load', style: statusStyle }, t('dialog.loading'))
|
|
@@ -450,6 +448,7 @@ window.__ModuleLoader__.load({
|
|
|
450
448
|
} else {
|
|
451
449
|
body = React.createElement(React.Fragment, null, [
|
|
452
450
|
target.running ? React.createElement('div', { key: 'warn', style: warnStyle }, t('dialog.runningWarn')) : null,
|
|
451
|
+
opsPanel,
|
|
453
452
|
React.createElement('div', { key: 'pick', style: metaStyle }, t('dialog.pick')),
|
|
454
453
|
React.createElement('div', { key: 'list', style: listStyle },
|
|
455
454
|
hiddenCount > 0
|
|
@@ -482,26 +481,7 @@ window.__ModuleLoader__.load({
|
|
|
482
481
|
'#' + m.seq + ' ' + (m.role || '') + ' · ' + (m.snippet || '') + (m.visible === false ? t('dialog.invisible') : '')),
|
|
483
482
|
)),
|
|
484
483
|
),
|
|
485
|
-
|
|
486
|
-
// restore 仅对 revert/delete 落定的 replace 标记行提供(重放语义)
|
|
487
|
-
// 0.6.0(用户定调):恢复不进对话框——唯一入口是输入框上方贴条;
|
|
488
|
-
['revert', 'delete', 'branch'].map((m, i) => React.createElement('div', { key: m, style: { marginTop: i === 0 ? 8 : 4 } },
|
|
489
|
-
React.createElement('label', { style: optStyle },
|
|
490
|
-
React.createElement('input', {
|
|
491
|
-
type: 'radio', name: 'dsh-message-ops-mode', checked: mode === m,
|
|
492
|
-
onChange: () => chooseMode(m), disabled: state === 'busy',
|
|
493
|
-
}),
|
|
494
|
-
t('op.' + m)),
|
|
495
|
-
mode === m ? React.createElement('div', { style: descStyle }, t('op.' + m + 'Desc')) : null,
|
|
496
|
-
))) : null,
|
|
497
|
-
mode && mode !== 'branch'
|
|
498
|
-
? React.createElement('label', { key: 'ack', style: optStyle },
|
|
499
|
-
React.createElement('input', {
|
|
500
|
-
type: 'checkbox', checked: acknowledged, disabled: state === 'busy',
|
|
501
|
-
onChange: (e) => setAcknowledged(e.target.checked),
|
|
502
|
-
}),
|
|
503
|
-
t(mode === 'revert' ? 'ack.revert' : mode === 'restore' ? 'ack.restore' : 'ack.delete'))
|
|
504
|
-
: null,
|
|
484
|
+
opsPanel,
|
|
505
485
|
])
|
|
506
486
|
}
|
|
507
487
|
|
|
@@ -591,14 +571,14 @@ window.__ModuleLoader__.load({
|
|
|
591
571
|
}, React.createElement(BranchIcon))
|
|
592
572
|
}
|
|
593
573
|
|
|
594
|
-
// 官方图标适配:0.2.0 primitives 的 IconClock
|
|
574
|
+
// 官方图标适配:0.2.0 primitives 的 IconClock 与原生操作行同款;
|
|
595
575
|
// require 失败(0.1.x 或裁剪环境)回退内联 SVG,槽在 0.1.x 本就不存在,仅防御。
|
|
576
|
+
// 0.9.0:移除 IconTrash —— 消息级删除按钮从未渲染(删除只在对话框里),
|
|
577
|
+
// 专家核查确认 IconTrash/TrashFallback 零渲染点,是死代码。
|
|
596
578
|
var IconClock = null
|
|
597
|
-
var IconTrash = null
|
|
598
579
|
try {
|
|
599
580
|
const P = require('@deepseek-ai/dsh-client-ui-primitives')
|
|
600
581
|
IconClock = P && P.IconClockOutlineRegular
|
|
601
|
-
IconTrash = P && P.IconTrashOutlineRegular
|
|
602
582
|
} catch { /* fallback below */ }
|
|
603
583
|
if (!IconClock) IconClock = function ClockFallback() {
|
|
604
584
|
// 官方 IconClockOutlineArtwork 1:1 路径( Regular = 1px stroke)
|
|
@@ -615,14 +595,6 @@ window.__ModuleLoader__.load({
|
|
|
615
595
|
return React.createElement('svg', { width: 16, height: 16, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': true, stroke: 'currentColor', strokeWidth: 1 },
|
|
616
596
|
React.createElement('path', { d: 'M3 6.5A3.5 3.5 0 0 1 6.5 3H7v1.5h-.5A2 2 0 0 0 4.5 6.5V7H7v3.5H3V6.5ZM9 6.5A3.5 3.5 0 0 1 12.5 3H13v1.5h-.5A2 2 0 0 0 10.5 6.5V7H13v3.5H9V6.5Z' }))
|
|
617
597
|
}
|
|
618
|
-
if (!IconTrash) IconTrash = function TrashFallback() {
|
|
619
|
-
// 官方 IconTrashOutlineArtwork 1:1 路径
|
|
620
|
-
return React.createElement('svg', { width: 16, height: 16, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': true, stroke: 'currentColor', strokeWidth: 1 },
|
|
621
|
-
React.createElement('path', { d: 'M1.28149 3.88831H14.7187' }),
|
|
622
|
-
React.createElement('path', { d: 'M5.41602 3.88833V2.47962C5.41602 2.29282 5.52492 2.11366 5.71876 1.98157C5.9126 1.84948 6.17551 1.77527 6.44964 1.77527H9.55053C9.82466 1.77527 10.0876 1.84948 10.2814 1.98157C10.4752 2.11366 10.5841 2.29282 10.5841 2.47962V3.88833' }),
|
|
623
|
-
React.createElement('path', { d: 'M3.29749 5.10193L4.06585 13.0192C4.10899 13.4595 4.48223 13.7942 4.92504 13.7942H11.0751C11.5179 13.7942 11.8912 13.4595 11.9343 13.0192L12.7027 5.10193' }),
|
|
624
|
-
React.createElement('path', { d: 'M6.27637 7.51831V11.1829M9.72378 7.51831V11.1829' }))
|
|
625
|
-
}
|
|
626
598
|
|
|
627
599
|
// --- 0.3.0 assistant-actions 官方槽:每条 AI 消息旁的原生回撤按钮 ------------
|
|
628
600
|
// 契约(dsh-cordis-client-runner):scope session,条目组件收 { messageId } +
|
|
@@ -873,6 +845,12 @@ window.__ModuleLoader__.load({
|
|
|
873
845
|
try {
|
|
874
846
|
if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(sessionId)
|
|
875
847
|
} catch { /* fallthrough */ }
|
|
848
|
+
// 0.9.1:重放的消息带**新 seq**,被恢复的行必须解除 hidden,
|
|
849
|
+
// 同时 dock 的权威 marker 列表要重拉。
|
|
850
|
+
try { window.dispatchEvent(new Event(CHANGED_EVENT)) } catch { /* non-browser */ }
|
|
851
|
+
// 0.9.1:重放的消息带**新 seq**,被恢复的行必须解除 hidden;
|
|
852
|
+
// 同时 dock 的 marker 列表要按权威数据重算(restoreComplete 会变 true)。
|
|
853
|
+
for (const delay of [150, 700, 1600]) setTimeout(() => { if (__refreshSurface) __refreshSurface(sessionId) }, delay)
|
|
876
854
|
const fresh = await fetch('/api/message-ops/messages?sessionId=' + encodeURIComponent(sessionId)).then((r) => (r.ok ? r.json() : null)).catch(() => null)
|
|
877
855
|
if (fresh && fresh.ok) setMarkers(activeMarkers(fresh.messages || []))
|
|
878
856
|
})
|
|
@@ -956,22 +934,174 @@ window.__ModuleLoader__.load({
|
|
|
956
934
|
var rowsCache = { sid: null, rows: null, at: 0 }
|
|
957
935
|
var norm = (x) => String(x || '').replace(/\s+/g, '')
|
|
958
936
|
var fetchRows = (sid) => {
|
|
959
|
-
if (rowsCache.sid === sid && rowsCache.rows && Date.now() - rowsCache.at < 8000) return Promise.resolve(rowsCache
|
|
937
|
+
if (rowsCache.sid === sid && rowsCache.rows && Date.now() - rowsCache.at < 8000) return Promise.resolve(rowsCache)
|
|
960
938
|
return fetch('/api/message-ops/messages?sessionId=' + encodeURIComponent(sid))
|
|
961
939
|
.then((r) => (r.ok ? r.json() : null))
|
|
962
940
|
.then((d) => {
|
|
963
941
|
// 宿主会把 <system-reminder> / runtime context 等也记为 role=user 的行,
|
|
964
|
-
// DOM
|
|
965
|
-
|
|
942
|
+
// DOM 里并不渲���成"我的消息"块 —— 必须滤掉,否则按序配对会错位(0.7.0 根因)。
|
|
943
|
+
//
|
|
944
|
+
// 0.9.0 两个实机 bug(浏览器实测:4 个按钮 data-mops-seq 全为 null,点击必失败):
|
|
945
|
+
// ① 正则跑在 norm() 之后的串上,而 norm 是 replace(/\s+/g,'') —— 删掉**全部**空白,
|
|
946
|
+
// `current\s+runtime\s+context` 永远匹配不上 → runtime-context 伪行漏进配对。
|
|
947
|
+
// 修法:injected() 改判**原始 snippet**。
|
|
948
|
+
// ② 过滤了 `m.visible !== false`,但宿主聊天视图**不施��**遮蔽模型,照常渲染
|
|
949
|
+
// 被回滚遮蔽的消息 → 配对候选与 DOM 块零交集。
|
|
950
|
+
// 修法:DOM 配对必须覆盖全部 user 行(含遮蔽态)。
|
|
951
|
+
// 注意:对话框的「可回滚目标」列表仍应过滤 visible(那是另一套语义)。
|
|
952
|
+
const injected = (raw) => /^<system-reminder|current\s+runtime\s+context|^<system-Reminder/i.test(String(raw || ''))
|
|
966
953
|
const rows = ((d && d.messages) || [])
|
|
967
|
-
.filter((m) => m && m.role === 'user'
|
|
968
|
-
.map((m) => ({ seq: m.seq, sn: norm(m.snippet) }))
|
|
969
|
-
.filter((r) => r.sn && !injected(r.
|
|
970
|
-
|
|
971
|
-
|
|
954
|
+
.filter((m) => m && m.role === 'user')
|
|
955
|
+
.map((m) => ({ seq: m.seq, sn: norm(m.snippet), raw: String(m.snippet == null ? '' : m.snippet) }))
|
|
956
|
+
.filter((r) => r.sn && !injected(r.raw))
|
|
957
|
+
// 0.9.1:同时产出 node-key 查表索引(隐藏 transcript 用)
|
|
958
|
+
const idx = buildIndex(d)
|
|
959
|
+
rowsCache = { sid: sid, rows: rows, idx: idx, at: Date.now() }
|
|
960
|
+
return rowsCache
|
|
972
961
|
})
|
|
973
|
-
.catch(() => rowsCache.sid === sid ? rowsCache
|
|
962
|
+
.catch(() => (rowsCache.sid === sid ? rowsCache : null))
|
|
974
963
|
}
|
|
964
|
+
|
|
965
|
+
// ═══ 0.9.1 宿主 node-key ↔ 日志 seq 的精确映射 ═══════════════════════════
|
|
966
|
+
//
|
|
967
|
+
// 背景(浏览器实测 + 源码核实):dsh 的 transcript **刻意不做 surface 折叠**。
|
|
968
|
+
// 官方 surface.d.ts:51-63 明写 "replacement copies stay model-only" ——
|
|
969
|
+
// 我们写的 surfaceOp replace 只折叠**模型 surface**(实测 393→13 节点),
|
|
970
|
+
// 被遮蔽的消息在人类 transcript 里**照常渲染且完全可见**,连 marker 本身
|
|
971
|
+
// 都不渲染(systemMessageDefinition 对 surfaceOp !== 'append' 直接 return null)。
|
|
972
|
+
// 所以要让回滚「看得见」,只能在渲染层处理。
|
|
973
|
+
//
|
|
974
|
+
// 好消息:每一行的 `data-chat-node-key` 形如 `<len>:<kind><id>`,而 <id>
|
|
975
|
+
// 就是日志事件的字段(user → messageId、assistant-step → `<turn>:<step>`、
|
|
976
|
+
// tool-call → callId、turn-* → turn 号),客户端本来就已经建了
|
|
977
|
+
// messageId → seq 索引(__seqIndexCache)。**精确查表,零启发式。**
|
|
978
|
+
//
|
|
979
|
+
// 旧实现用「40 字符前缀包含匹配」配对 DOM 与日志,实测 4 条里错 2 条
|
|
980
|
+
// ("继续" 命中了 "继续,…"),已整体删除。
|
|
981
|
+
var parseNodeKey = (k) => {
|
|
982
|
+
var m = /^(\d+):/.exec(k || '');
|
|
983
|
+
if (!m) return null;
|
|
984
|
+
var digits = m[1].length;
|
|
985
|
+
var kindLen = Number(m[1]);
|
|
986
|
+
var start = digits + 1;
|
|
987
|
+
if (!Number.isSafeInteger(kindLen) || kindLen <= 0 || k.length < start + kindLen) return null;
|
|
988
|
+
return { kind: k.slice(start, start + kindLen), id: k.slice(start + kindLen) };
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* 从 /api/message-ops/messages 的响应构建全部查表。
|
|
993
|
+
* 三条铁律:① 索引只认唯一 id;② 缺数据一律返回 undefined(调用方保持可见);
|
|
994
|
+
* ③ visible 集合只收显式 true。
|
|
995
|
+
*/
|
|
996
|
+
var buildIndex = (payload) => {
|
|
997
|
+
var list = (payload && payload.messages) || []
|
|
998
|
+
// 0.9.1:回合页脚/过程条不是消息,用 turn/end 的 seq 定位(边界常落在 turn 内部,
|
|
999
|
+
// 用 turn/start 会漏判该回合的页脚)
|
|
1000
|
+
var turnEnd = (payload && payload.turnEndSeq) || null;
|
|
1001
|
+
var byMessageId = new Map();
|
|
1002
|
+
var byTurnStep = new Map();
|
|
1003
|
+
var byCallId = new Map();
|
|
1004
|
+
var byTurn = new Map();
|
|
1005
|
+
var visible = new Set();
|
|
1006
|
+
var reverted = new Set();
|
|
1007
|
+
var dupMessageId = 0
|
|
1008
|
+
var dupByMessageId = new Map();
|
|
1009
|
+
// 回合页脚/过程条锚到 turn/end 的 seq —— 那是**非消息**事件,永远不会出现在
|
|
1010
|
+
// reverted 集合里,所以隐藏判据必须直接对 fence 比较,不能用集合成员。
|
|
1011
|
+
var fences = Array.isArray(payload && payload.revertFences)
|
|
1012
|
+
? payload.revertFences.filter(function (n) { return Number.isSafeInteger(n); })
|
|
1013
|
+
: [];
|
|
1014
|
+
for (var i = 0; i < list.length; i++) {
|
|
1015
|
+
var m = list[i];
|
|
1016
|
+
if (!m || typeof m.seq !== 'number') continue;
|
|
1017
|
+
if (m.id != null) {
|
|
1018
|
+
var k = String(m.id);
|
|
1019
|
+
// restore 是「重放」语义 → 原件与副本可能同 id 并存。
|
|
1020
|
+
// 0.9.1:不再「保留最早」,而是收集**全部** seq,隐藏判据取「任一 seq 越过
|
|
1021
|
+
// fence」。回放副本才是当前 surface 上的那条,用最早的 seq 判会让
|
|
1022
|
+
// 「恢复后再回滚」漏藏(实测 fence=70、副本 seq=70、原件 seq=54)。
|
|
1023
|
+
if (byMessageId.has(k)) {
|
|
1024
|
+
dupMessageId++
|
|
1025
|
+
const arr = dupByMessageId.get(k) || [byMessageId.get(k)]
|
|
1026
|
+
arr.push(m.seq)
|
|
1027
|
+
dupByMessageId.set(k, arr)
|
|
1028
|
+
byMessageId.set(k, m.seq) // 指向最新的
|
|
1029
|
+
} else { byMessageId.set(k, m.seq) }
|
|
1030
|
+
byMessageId.set(k, m.seq);
|
|
1031
|
+
}
|
|
1032
|
+
if (m.type === 'assistant/message' && m.turn != null && m.step != null) {
|
|
1033
|
+
byTurnStep.set(m.turn + ':' + m.step, m.seq);
|
|
1034
|
+
}
|
|
1035
|
+
if (m.type === 'tool/call' && m.id != null) byCallId.set(String(m.id), m.seq);
|
|
1036
|
+
if (m.turn != null && !byTurn.has(String(m.turn))) byTurn.set(String(m.turn), m.seq);
|
|
1037
|
+
if (m.visible === true) visible.add(m.seq);
|
|
1038
|
+
// 0.9.1:reverted 才是「该藏」的口径(见 index.js 的注释:visible 会误藏
|
|
1039
|
+
// 所有非 surface 事件行,如 tool/call)
|
|
1040
|
+
if (m.reverted === true) reverted.add(m.seq);
|
|
1041
|
+
}
|
|
1042
|
+
// turnEnd 优先:它对「该 turn 内一条消息都没有」的情况仍然有效
|
|
1043
|
+
if (turnEnd) for (const k in turnEnd) if (Object.prototype.hasOwnProperty.call(turnEnd, k)) byTurn.set(k, turnEnd[k])
|
|
1044
|
+
return { byMessageId, dupByMessageId, byTurnStep, byCallId, byTurn, visible, reverted, fences, dupMessageId, total: list.length };
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
/** node-key → { seq, all }(all = 同 id 的全部 seq,处理 restore 重放副本)。 */
|
|
1048
|
+
var seqOfNodeKey = (key, idx) => {
|
|
1049
|
+
var parsed = parseNodeKey(key);
|
|
1050
|
+
if (!parsed || !idx) return null;
|
|
1051
|
+
var id = parsed.id;
|
|
1052
|
+
switch (parsed.kind) {
|
|
1053
|
+
case 'input-message': // user / steering / turn-trigger
|
|
1054
|
+
case 'developer-message':
|
|
1055
|
+
case 'trajectory-note': {
|
|
1056
|
+
const hit = idx.byMessageId.get(id)
|
|
1057
|
+
if (hit === undefined) return null
|
|
1058
|
+
return { seq: hit, all: idx.dupByMessageId.get(id) || [hit] }
|
|
1059
|
+
}
|
|
1060
|
+
case 'assistant-step': {
|
|
1061
|
+
const hit = idx.byTurnStep.get(id)
|
|
1062
|
+
return hit === undefined ? null : { seq: hit, all: [hit] }
|
|
1063
|
+
}
|
|
1064
|
+
case 'tool-call': {
|
|
1065
|
+
const hit = idx.byCallId.get(id)
|
|
1066
|
+
return hit === undefined ? null : { seq: hit, all: [hit] }
|
|
1067
|
+
}
|
|
1068
|
+
case 'turn-tail':
|
|
1069
|
+
case 'turn-process':
|
|
1070
|
+
case 'turn-error':
|
|
1071
|
+
case 'turn-max-tokens':
|
|
1072
|
+
case 'model-retry': {
|
|
1073
|
+
const hit = idx.byTurn.get(id)
|
|
1074
|
+
return hit === undefined ? null : { seq: hit, all: [hit] }
|
|
1075
|
+
}
|
|
1076
|
+
default:
|
|
1077
|
+
return null; // compaction / command / workflow-run 等不参与
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* 把 transcript 行按模型 surface 可见性打上 hidden。
|
|
1083
|
+
* 用 `hidden="until-found"`(与宿主 useSearchableHidden 同款):Ctrl+F 仍能搜到,
|
|
1084
|
+
* 且宿主的分页锚点选择器 `[data-chat-paging-anchor]:not(:empty):not([hidden])`
|
|
1085
|
+
* 会自动跳过这些行,滚动恢复不受影响。
|
|
1086
|
+
*
|
|
1087
|
+
* ⚠️ `seq == null` ⇒ **移除 hidden**(保持可见)。把「查不到」当成「被遮蔽」
|
|
1088
|
+
* 是唯一会误藏用户内容的路径。
|
|
1089
|
+
*/
|
|
1090
|
+
var applySurfaceVisibility = (root, idx) => {
|
|
1091
|
+
if (!idx) return { hidden: 0, unresolved: 0, shown: 0 };
|
|
1092
|
+
var rows = (root || document).querySelectorAll('[data-chat-node-key]');
|
|
1093
|
+
var hidden = 0, unresolved = 0, shown = 0;
|
|
1094
|
+
for (var i = 0; i < rows.length; i++) {
|
|
1095
|
+
var row = rows[i];
|
|
1096
|
+
var seq = seqOfNodeKey(row.getAttribute('data-chat-node-key'), idx);
|
|
1097
|
+
if (seq === null) { unresolved++; row.removeAttribute('hidden'); continue; }
|
|
1098
|
+
var isReverted = idx.fences.length ? idx.fences.some(function (f) { return seq >= f; }) : idx.reverted.has(seq)
|
|
1099
|
+
if (isReverted) { hidden++; row.setAttribute('hidden', 'until-found'); }
|
|
1100
|
+
else { shown++; row.removeAttribute('hidden'); }
|
|
1101
|
+
}
|
|
1102
|
+
return { hidden, unresolved, shown };
|
|
1103
|
+
};
|
|
1104
|
+
|
|
975
1105
|
// 用户消息锚点:优先官方 Sixlwa_userRow(含 .xzv4MW_actions),回退 flow-kind 属性
|
|
976
1106
|
// 锚点 = 每条用户消息自己的容器(一个块只算一次):
|
|
977
1107
|
// 从官方动作行 .xzv4MW_actions 反查最近的消息容器,最贴近"一条消息"的粒度。
|
|
@@ -981,31 +1111,68 @@ window.__ModuleLoader__.load({
|
|
|
981
1111
|
const add = (el) => { if (el && !seen.has(el)) { seen.add(el); out.push(el) } }
|
|
982
1112
|
const rows = Array.from(document.querySelectorAll('[class*="xzv4MW_actions"]'))
|
|
983
1113
|
for (const r of rows) {
|
|
984
|
-
const block = r.closest('[data-chat-flow-kind="user"]')
|
|
985
|
-
|
|
986
|
-
|
|
1114
|
+
const block = r.closest('[data-chat-flow-kind="user"]')
|
|
1115
|
+
|| r.closest('[class*="_userRow"], [class*="_userStack"], [class*="_bubble"]')
|
|
1116
|
+
|| r.parentElement
|
|
1117
|
+
// 0.9.0:只按**稳定属性** + hash-immune 类名后缀判定,不再匹配 CSS-module
|
|
1118
|
+
// 生成的前缀(`Sixlwa_*`)。dsh 0.2.0-rc.2 的哈希已变为 `EvIC1a_flowItem`,
|
|
1119
|
+
// 旧前缀正则把所有块都滤掉 → anchors 为空 → 按钮拿不到 seq → 点击必失败。
|
|
1120
|
+
//
|
|
1121
|
+
// ⚠️ 不要把 `_flowItem` 当兜底:那是**通用**流块,官方把 branch 按钮��放在
|
|
1122
|
+
// `data-chat-flow-kind="turn-tail"` 的 _flowItem 里(实测会把 turn-tail 当成
|
|
1123
|
+
// 用户消息,给它挂上回滚按钮)。只用 user 属性 + user 类名后缀。
|
|
1124
|
+
if (block) {
|
|
1125
|
+
const flow = block.getAttribute('data-chat-flow-kind')
|
|
1126
|
+
const isUser = flow === 'user' || /_userRow|_userStack|_bubble/.test(block.className || '')
|
|
1127
|
+
if (isUser) add(block)
|
|
1128
|
+
}
|
|
987
1129
|
}
|
|
988
1130
|
// 回退:属性锚点
|
|
989
1131
|
for (const k of document.querySelectorAll('[data-chat-flow-kind="user"]')) add(k)
|
|
990
1132
|
return out
|
|
991
1133
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1134
|
+
// 0.9.0:把配对结果反映到按钮可用性上。
|
|
1135
|
+
// 配不上(data-mops-unmatched)→ 禁用 + 说明原因,绝不留装饰按钮。
|
|
1136
|
+
var syncEnabled = (block, btn) => {
|
|
1137
|
+
if (!btn) return
|
|
1138
|
+
const ok = block.getAttribute('data-mops-seq')
|
|
1139
|
+
if (ok) {
|
|
1140
|
+
btn.disabled = false
|
|
1141
|
+
btn.title = __t('slot.revert')
|
|
1142
|
+
btn.removeAttribute('data-mops-unmatched')
|
|
1143
|
+
} else {
|
|
1144
|
+
btn.disabled = true
|
|
1145
|
+
btn.title = __t('slot.revertUnmatched')
|
|
1146
|
+
btn.setAttribute('data-mops-unmatched', '1')
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
var assignSeqs = (sid, cache) => {
|
|
1150
|
+
const idx = cache && cache.idx
|
|
1151
|
+
if (!idx) return
|
|
1152
|
+
// 0.9.1:node-key 查表,替代旧的 40 字符前缀包含匹配(实测 4 条错 2 条)
|
|
1153
|
+
for (const b of userAnchors()) {
|
|
997
1154
|
b.removeAttribute('data-mops-seq')
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1155
|
+
b.removeAttribute('data-mops-unmatched')
|
|
1156
|
+
const hit = seqOfNodeKey(b.getAttribute('data-chat-node-key'), idx)
|
|
1157
|
+
const seq = hit === null ? null : hit.seq
|
|
1158
|
+
if (seq === null || seq === undefined) {
|
|
1159
|
+
b.setAttribute('data-mops-unmatched', '1')
|
|
1160
|
+
syncEnabled(b, b.querySelector && b.querySelector('.mopsUserRevert'))
|
|
1161
|
+
continue
|
|
1004
1162
|
}
|
|
1005
|
-
|
|
1163
|
+
b.setAttribute('data-mops-seq', String(seq))
|
|
1164
|
+
syncEnabled(b, b.querySelector && b.querySelector('.mopsUserRevert'))
|
|
1006
1165
|
}
|
|
1007
1166
|
}
|
|
1008
|
-
|
|
1167
|
+
// 按钮可用性在 assignSeqs 内部**同步**更新(与打标同一次循环)——
|
|
1168
|
+
// 之前放在 fetch 回调里做事后全局扫描,会与 DOM 注入/重排竞态,导致
|
|
1169
|
+
// 块已打上 seq 而按钮仍是禁用态(实测:block seq=[8,54],按钮 disabled=true)。
|
|
1170
|
+
// 按钮可用性与 transcript 隐藏都在这里统一落地(同一批数据,避免竞态)
|
|
1171
|
+
var ensureAssign = (sid) => fetchRows(sid).then((cache) => {
|
|
1172
|
+
assignSeqs(sid, cache)
|
|
1173
|
+
if (cache && cache.idx) applySurfaceVisibility(document, cache.idx)
|
|
1174
|
+
return cache
|
|
1175
|
+
})
|
|
1009
1176
|
// 0.7.0:点击时先**同步完成**配对(打标是异步 fetch 的结果,
|
|
1010
1177
|
// 早先点在未打标的按钮上会静默失败 = 用户反馈的"点了没用")。
|
|
1011
1178
|
var runUserRevert = (btn, block) => {
|
|
@@ -1015,15 +1182,15 @@ window.__ModuleLoader__.load({
|
|
|
1015
1182
|
Promise.resolve()
|
|
1016
1183
|
.then(() => ensureAssign(sid))
|
|
1017
1184
|
.then(() => fetchRows(sid))
|
|
1018
|
-
.then((
|
|
1185
|
+
.then((cache) => {
|
|
1186
|
+
const rows = cache && cache.rows
|
|
1187
|
+
// 0.9.1:seq 来自 node-key 精确查表,**不再**做文本前缀匹配验证
|
|
1188
|
+
// (旧的前缀包含匹配实测 4 条错 2 条 —— "继续" 命中 "继续,…")。
|
|
1019
1189
|
const seq = Number(block.getAttribute('data-mops-seq'))
|
|
1020
|
-
const head = norm((block.innerText || '').slice(0, 240))
|
|
1021
1190
|
const row = rows && rows.find((r) => r.seq === seq)
|
|
1022
|
-
|
|
1023
|
-
const b2 = (head || '').slice(0, 40)
|
|
1024
|
-
if (!row || !head || !(head.includes(a2) || row.sn.includes(b2))) {
|
|
1191
|
+
if (!row) {
|
|
1025
1192
|
ensureAssign(sid)
|
|
1026
|
-
notifyDone(__t('errorPrefix') + 'revert target verification failed', 'error')
|
|
1193
|
+
notifyDone(__t('errorPrefix') + (__t('revert.unresolved') || 'revert target verification failed'), 'error')
|
|
1027
1194
|
return
|
|
1028
1195
|
}
|
|
1029
1196
|
btn.disabled = true
|
|
@@ -1041,6 +1208,10 @@ window.__ModuleLoader__.load({
|
|
|
1041
1208
|
try {
|
|
1042
1209
|
if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(sid)
|
|
1043
1210
|
} catch { /* 视图重建失败不阻断 */ }
|
|
1211
|
+
// 0.9.1:视图重建后重新拉权威可见性并隐藏被遮蔽的行。
|
|
1212
|
+
// openSession 会重挂 DOM,旧节点上的 hidden 属性随之失效,必须重刷。
|
|
1213
|
+
if (rowsCache) rowsCache.at = 0
|
|
1214
|
+
for (const delay of [150, 700, 1600]) setTimeout(() => { if (__refreshSurface) __refreshSurface(sid) }, delay)
|
|
1044
1215
|
})
|
|
1045
1216
|
.catch((reason) => {
|
|
1046
1217
|
notifyDone(__t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)), 'error')
|
|
@@ -1072,13 +1243,22 @@ window.__ModuleLoader__.load({
|
|
|
1072
1243
|
host.appendChild(btn)
|
|
1073
1244
|
return btn
|
|
1074
1245
|
}
|
|
1246
|
+
__refreshSurface = (sid) => {
|
|
1247
|
+
const id = sid || __currentSessionId
|
|
1248
|
+
if (!id) return
|
|
1249
|
+
if (rowsCache) rowsCache.at = 0 // 强制重取权威数据
|
|
1250
|
+
try { fetchRows(id).then((cache) => { if (cache && cache.idx) applySurfaceVisibility(document, cache.idx) }) } catch { /* noop */ }
|
|
1251
|
+
}
|
|
1075
1252
|
var scan = () => {
|
|
1076
1253
|
try {
|
|
1077
1254
|
const sid = __currentSessionId
|
|
1078
1255
|
if (!sid) return
|
|
1079
1256
|
const blocks = userAnchors()
|
|
1080
1257
|
for (const b of blocks) ensureBtn(b)
|
|
1081
|
-
|
|
1258
|
+
// 0.9.1:**始终**刷新(原先只在按钮未打标时刷)——
|
|
1259
|
+
// 打标后 transcript 再变化(openSession 重建 / 分页 / restore 重放)
|
|
1260
|
+
// 就再也不会重算隐藏,导致「界面停在旧状态,必须重载页面才对」。
|
|
1261
|
+
ensureAssign(sid)
|
|
1082
1262
|
} catch { /* 注入失败不影响会话 */ }
|
|
1083
1263
|
}
|
|
1084
1264
|
// 触发:hover / 滚动 / DOM 变化 / 变更事件
|