@240xu/dsh-message-ops 0.21.0 → 0.23.0
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 +56 -0
- package/package.json +1 -1
- package/src/client.js +111 -234
- package/src/ops-core.js +6 -2
- package/src/session-file.js +7 -1
package/README.md
CHANGED
|
@@ -1316,3 +1316,59 @@ textarea 预填真实全文 89 字(非 snippet)
|
|
|
1316
1316
|
之后翻文件也拿不到原文 —— 正好对上用户「后续几次能恢复、之后彻底删」的诉求
|
|
1317
1317
|
|
|
1318
1318
|
测试 353(349 pass / 4 skip),`prettier --check` 全绿。
|
|
1319
|
+
|
|
1320
|
+
### 0.22.0 · 深挖审计修复(grapheme 截断 / 全文口径 / 编辑框告知)
|
|
1321
|
+
|
|
1322
|
+
用户要求「分配多项专家子代理,对内容的 bug 还有 UX 进行深挖」。两轮 8 名专项成员
|
|
1323
|
+
全部中途失败、无报告落盘,但半截结论与 `.audit-tmp/` 里的真执行脚本有效。
|
|
1324
|
+
Lead 逐条复核后落地 3 个修复。汇总见 `design-demos/audit-round-summary.md`。
|
|
1325
|
+
|
|
1326
|
+
1. **引用截断按 grapheme 切**(真 bug):`clipQuote` 原按 `Array.from`(code point)
|
|
1327
|
+
切 600 字,会拆散 grapheme cluster。真执行实测 `a×598 + 👨👩👧👦` 被切成
|
|
1328
|
+
`U+1f468 U+200d U+2026`(悬空 ZWJ + 半个家庭 emoji)。改用
|
|
1329
|
+
`Intl.Segmenter('zh', {granularity:'grapheme'})`,切点只落在 grapheme 边界。
|
|
1330
|
+
2. **fullText 与 /text 同口径**(真 bug):`listMessages` 的 `fullText` 原用
|
|
1331
|
+
`messageText`(首段),而 `/text` 用 `messageTextFull`(全段)。宿主把长文本拆成
|
|
1332
|
+
多段时,`refillComposer` / `forkFromUserMessage` 回填丢后半段。
|
|
1333
|
+
现 `snippet` 仍用首段(摘要本就该短),`fullText` 显式改用 `messageTextFull`。
|
|
1334
|
+
3. **编辑框隐私告知覆盖**(UX 缺口):0.21 的告知只覆盖面板确认框与行内按钮,
|
|
1335
|
+
但 `EditResendOverlay` 点「发送并回撤」也走 `/revert`。把 `edit.replaceHint`
|
|
1336
|
+
的 zh/en 文案补成「这不是删除——AI 看不到,但原文仍在本地会话文件、
|
|
1337
|
+
可被恢复、翻文件仍能读到」,不新增 UI 元素以免「一堵字」。
|
|
1338
|
+
|
|
1339
|
+
新增 `test/audit-deep-fixes.test.js`(4 条,含 3 条真执行);更新 2 条过期的
|
|
1340
|
+
0.20 契约(code point → grapheme)。测试 357(353 pass / 4 skip),
|
|
1341
|
+
`prettier --check` 全绿。
|
|
1342
|
+
|
|
1343
|
+
### 0.23.0 · 引用让位宿主 + 恢复官方分支 + 深挖真 bug 修复
|
|
1344
|
+
|
|
1345
|
+
用户:「引用做得巧妙点,不要每次把整个上下文塞给 AI」+「把犯蠢做的东西全部审计
|
|
1346
|
+
修一下」+「dsh 官方似乎已经有消息分支」。智能体团队 11 份专项报告,Lead 逐条
|
|
1347
|
+
复核落地。汇总见 `design-demos/audit-round2-summary.md`。
|
|
1348
|
+
|
|
1349
|
+
1. **引用按钮删除(让位宿主划词引用)**:实证宿主 `dsh-message-quotes` 已有
|
|
1350
|
+
完整划词引用(`data-text-interaction-source` + `selectionchange` +
|
|
1351
|
+
`inputActions.insertQuote`),只在选中文字时、选中多少引多少。我们旧按钮
|
|
1352
|
+
选区体系不匹配 → 退化成塞 600 字全文;而 `deriveMessages()` 本就给出完整
|
|
1353
|
+
历史 → 引用未遮蔽消息 = 同一内容进 prompt 两遍。AI 动作槽改 `return null`,
|
|
1354
|
+
组件保留(它捕获 `inputActions`,删了会让编辑框/面板/回填失效)。
|
|
1355
|
+
真机:选中 20 字 → QuoteNode 正好 20 字,宿主 toolbar 出现,无重复注入。
|
|
1356
|
+
2. **恢复官方消息分支**:官方 `TurnTailNodeView` 的 `MessageIconActions` 本就有
|
|
1357
|
+
`sessions.fork({atSeq: turn-tail seq})` 分支按钮。0.12 起我们把它藏了
|
|
1358
|
+
(`suppressHostBranch`)又自己造 `mopsUserFork`,是重复造轮子。
|
|
1359
|
+
删抑制 + 删行内 fork,恢复官方按钮;面板 branch 保留(底层本来就是官方 fork)。
|
|
1360
|
+
真机:`hostBranchIconBtns=3 / hidden=0 / mopsFork=0`。
|
|
1361
|
+
3. **S-1 restore 重放丢段**(HIGH):`planRestore` 用 `messageText`(首段),
|
|
1362
|
+
多段消息恢复后永久丢后半段,实测 898 条受影响、175 万字符。改 `messageTextFull`。
|
|
1363
|
+
4. **S-2 dock 遮蔽计数恒 0**(HIGH):服务端 range 是 `{startSeq,endSeq}`,
|
|
1364
|
+
client 只读 `{start,end}`。改成兼容两种形状。
|
|
1365
|
+
5. **文案自我打脸**:`op.delete` 说「删除」但实现是遮蔽,而隐私告知自己写着
|
|
1366
|
+
「这不是删除」。6 个 key 改成「遮蔽此条」,去掉给外行看的 `append-only`。
|
|
1367
|
+
6. **回填失败仍报成功**:`runUserRevert` 先报成功再回填且丢弃返回值。
|
|
1368
|
+
改成先回填、按结果报成功/`warn`(新增 `done.revertNoRefill`)。
|
|
1369
|
+
7. **测试假绿灯**:变异测试抓到 3 类高危(submitEditedText 被 stub、
|
|
1370
|
+
`assert.ok(true)` 守卫、i18n 值语义盲区),补 3 条真执行提交测试 +
|
|
1371
|
+
硬失败守卫 + 反义值检测。
|
|
1372
|
+
|
|
1373
|
+
过程中 Lead 误删 `ensureBtn` 导致用户消息按钮全失效,已从 git 取回并真机复验
|
|
1374
|
+
`mopsRevert=9 / mopsEdit=9`。测试 360(356 pass / 4 skip),`prettier --check` 全绿。
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -125,9 +125,9 @@ window.__ModuleLoader__.load({
|
|
|
125
125
|
'dialog.invisible': '(已遮蔽,仅日志可见)',
|
|
126
126
|
'dialog.showMore': '显示更多(剩余 {n} 条)',
|
|
127
127
|
'dialog.more': '…(仅显示最近 200 条,共 {n} 条)',
|
|
128
|
-
'op.revert': '
|
|
129
|
-
'op.revertDesc': '
|
|
130
|
-
'op.delete': '
|
|
128
|
+
'op.revert': '回撤到此条及之后',
|
|
129
|
+
'op.revertDesc': '把这条及之后的对话从 AI 可见内容里隐藏;原文仍保留,可以放回。',
|
|
130
|
+
'op.delete': '遮蔽此条',
|
|
131
131
|
'op.deleteDesc': '仅遮蔽所选的一条消息;其余内容保持不变。',
|
|
132
132
|
'op.branch': '从此条分叉为新会话',
|
|
133
133
|
'op.branchDesc': '把此条之前的对话复制到新会话,并把此条原文放回新会话输入框(原会话不变,非破坏操作)。',
|
|
@@ -158,7 +158,8 @@ window.__ModuleLoader__.load({
|
|
|
158
158
|
'edit.doneSubmitted': '已回撤,改后的消息已提交',
|
|
159
159
|
'edit.manual': '已回撤,改后的文本已放进输入框——请按回车发送',
|
|
160
160
|
'edit.running': '会话正在运行:需先停止会话再编辑重发',
|
|
161
|
-
'edit.replaceHint':
|
|
161
|
+
'edit.replaceHint':
|
|
162
|
+
'发送会先回撤此条及其之后的全部可见消息,再把改后的文本作为新消息发出。注意:这不是删除——AI 看不到被回撤的内容,但原文仍保留在本地会话文件、可被恢复,直接翻看会话文件仍能读到。',
|
|
162
163
|
'toast.openNew': '打开新会话',
|
|
163
164
|
'fork.official': '分支完成:新会话 {id}',
|
|
164
165
|
'fork.unavailable': '官方分支不可用:通常是因为会话正在运行,请先停止会话后重试。分支功能由 dsh 内置的 session/fork 提供。',
|
|
@@ -172,7 +173,8 @@ window.__ModuleLoader__.load({
|
|
|
172
173
|
'busy.branch': '分支中…',
|
|
173
174
|
'done.restore': '恢复完成:重放 {n} 条,跳过不可重放 {s} 条',
|
|
174
175
|
'done.revert': '已回滚(原文仍保留在本地会话文件,可被恢复);刷新页面后生效',
|
|
175
|
-
'done.
|
|
176
|
+
'done.revertNoRefill': '已回滚,但原文未能放回输入框(会话可能尚未挂载);可重试或从消息操作面板手动复制',
|
|
177
|
+
'done.delete': '已遮蔽,刷新页面后生效',
|
|
176
178
|
'action.reload': '刷新页面',
|
|
177
179
|
errorPrefix: '操作失败:',
|
|
178
180
|
'dock.title': '已回撤 {n} 条消息',
|
|
@@ -225,12 +227,12 @@ window.__ModuleLoader__.load({
|
|
|
225
227
|
'panel.deleteConfirmTitle': '仅删除 #{seq}?',
|
|
226
228
|
'panel.deleteConfirmBody': '将遮蔽这 1 条消息,其他内容不动;日志仍保留,可恢复。',
|
|
227
229
|
'panel.confirmRevert': '确认回滚',
|
|
228
|
-
'panel.confirmDeleteOne': '
|
|
230
|
+
'panel.confirmDeleteOne': '确认遮蔽',
|
|
229
231
|
'panel.retry': '重试',
|
|
230
232
|
'panel.searching': '搜索中…',
|
|
231
233
|
'panel.deleteSessionImpact': '共 {n} 条消息;移入回收站后 7 天内可恢复。',
|
|
232
234
|
'panel.deleteUnavailable': '会话信息尚未就绪,暂不能删除。',
|
|
233
|
-
'panel.delete': '
|
|
235
|
+
'panel.delete': '遮蔽此条',
|
|
234
236
|
'panel.deleteHint': '只遮蔽这一条,其他消息不动',
|
|
235
237
|
'panel.branch': '从此条分叉',
|
|
236
238
|
'panel.branchHint': '复制此条之前的对话到新会话,并把此条原文放回新会话输入框',
|
|
@@ -241,7 +243,7 @@ window.__ModuleLoader__.load({
|
|
|
241
243
|
// 原消息仍在,界面出现两条相似消息)。opencode 也没有消息级编辑。
|
|
242
244
|
'panel.openNew': '打开新会话',
|
|
243
245
|
'panel.revertDone': '回滚已生效',
|
|
244
|
-
'panel.deleteDone': '
|
|
246
|
+
'panel.deleteDone': '已遮蔽',
|
|
245
247
|
'panel.count': '共 {n} 条 · 可见 {v} · 已回滚 {s}',
|
|
246
248
|
'panel.deleteSession': '删除整条会话',
|
|
247
249
|
'panel.deleteSessionHint': '移入回收站,7 天内可恢复。请输入标题确认:',
|
|
@@ -276,10 +278,10 @@ window.__ModuleLoader__.load({
|
|
|
276
278
|
'dialog.invisible': ' (shadowed, log-only)',
|
|
277
279
|
'dialog.showMore': 'Show more ({n} older)',
|
|
278
280
|
'dialog.more': '…(showing latest 200 of {n})',
|
|
279
|
-
'op.revert': 'Revert
|
|
281
|
+
'op.revert': 'Revert to here',
|
|
280
282
|
'op.revertDesc':
|
|
281
283
|
'Shadows the picked message and all later visible content; the log stays append-only so context can be restored by re-sending.',
|
|
282
|
-
'op.delete': '
|
|
284
|
+
'op.delete': 'Hide this message',
|
|
283
285
|
'op.deleteDesc': 'Shadows only the picked message; everything else stays.',
|
|
284
286
|
'op.branch': 'Fork into a new session from here',
|
|
285
287
|
'op.branchDesc':
|
|
@@ -313,7 +315,7 @@ window.__ModuleLoader__.load({
|
|
|
313
315
|
'edit.manual': 'Reverted; the edited text is in the composer — press Enter to send',
|
|
314
316
|
'edit.running': 'The session is running: stop it before editing and resending',
|
|
315
317
|
'edit.replaceHint':
|
|
316
|
-
'Sending reverts this message and every visible message after it, then sends the edited text as a new message.
|
|
318
|
+
'Sending reverts this message and every visible message after it, then sends the edited text as a new message. Note: this is not deletion — the AI will not see the reverted content, but the original text stays in the local session file, can be restored, and is still readable by opening that file directly.',
|
|
317
319
|
'toast.openNew': 'Open new session',
|
|
318
320
|
'fork.official': 'Branched (official fork): new session {id}',
|
|
319
321
|
'fork.unavailable':
|
|
@@ -328,7 +330,9 @@ window.__ModuleLoader__.load({
|
|
|
328
330
|
'busy.branch': 'Branching…',
|
|
329
331
|
'done.restore': 'Restored: replayed {n}, skipped non-replayable {s}',
|
|
330
332
|
'done.revert': 'Reverted (original text stays in the local session file and can be restored); reload to apply',
|
|
331
|
-
'done.
|
|
333
|
+
'done.revertNoRefill':
|
|
334
|
+
'Reverted, but the original text could not be put back in the composer (the view may not be mounted yet); retry or copy it manually from Message Ops',
|
|
335
|
+
'done.delete': 'Hidden; reload to apply',
|
|
332
336
|
'action.reload': 'Reload page',
|
|
333
337
|
errorPrefix: 'Operation failed: ',
|
|
334
338
|
'dock.title': '{n} rolled back messages',
|
|
@@ -373,18 +377,18 @@ window.__ModuleLoader__.load({
|
|
|
373
377
|
'panel.revertHint': 'Includes this message and all visible messages after it',
|
|
374
378
|
'panel.revertConfirmTitle': 'Revert to #{seq}?',
|
|
375
379
|
'panel.revertConfirmBody':
|
|
376
|
-
'This shadows {n} messages (#{start}–#{end}), including {v} visible. The
|
|
380
|
+
'This shadows {n} messages (#{start}–#{end}), including {v} visible. The original text stays in the local session file and can be put back.',
|
|
377
381
|
'panel.revertPrivacyNote':
|
|
378
382
|
'Note: this is not deletion. The AI will no longer see these messages, but the original text stays in the local session file and can be recovered — reading the session file directly still reveals it.',
|
|
379
383
|
'panel.deleteConfirmTitle': 'Delete only #{seq}?',
|
|
380
384
|
'panel.deleteConfirmBody': 'This shadows this one message; everything else stays. The log stays append-only and can be restored.',
|
|
381
385
|
'panel.confirmRevert': 'Confirm revert',
|
|
382
|
-
'panel.confirmDeleteOne': 'Confirm
|
|
386
|
+
'panel.confirmDeleteOne': 'Confirm hide',
|
|
383
387
|
'panel.retry': 'Retry',
|
|
384
388
|
'panel.searching': 'Searching…',
|
|
385
389
|
'panel.deleteSessionImpact': 'Total {n} messages; recoverable from trash for 7 days.',
|
|
386
390
|
'panel.deleteUnavailable': 'Session details are not ready yet; deletion is disabled.',
|
|
387
|
-
'panel.delete': '
|
|
391
|
+
'panel.delete': 'Hide this',
|
|
388
392
|
'panel.deleteHint': 'Shadows only this message',
|
|
389
393
|
'panel.branch': 'Fork from here',
|
|
390
394
|
'panel.branchHint': 'Copy the conversation above this message into a new session and put this message back in the new composer',
|
|
@@ -392,7 +396,7 @@ window.__ModuleLoader__.load({
|
|
|
392
396
|
'panel.branchUserOnly': 'Fork works on user messages only (assistant messages have no text to hand back)',
|
|
393
397
|
'panel.openNew': 'Open new session',
|
|
394
398
|
'panel.revertDone': 'Revert applied',
|
|
395
|
-
'panel.deleteDone': '
|
|
399
|
+
'panel.deleteDone': 'Hidden',
|
|
396
400
|
'panel.count': 'Total {n} · visible {v} · shadowed {s}',
|
|
397
401
|
'panel.deleteSession': 'Delete whole session',
|
|
398
402
|
'panel.deleteSessionHint': 'Moves it to trash for 7 days. Type the title to confirm:',
|
|
@@ -2505,12 +2509,15 @@ window.__ModuleLoader__.load({
|
|
|
2505
2509
|
const opts = options || {}
|
|
2506
2510
|
const attempts = Number.isSafeInteger(opts.attempts) && opts.attempts > 0 ? opts.attempts : EDIT_SUBMIT_ATTEMPTS
|
|
2507
2511
|
const intervalMs = Number.isSafeInteger(opts.intervalMs) && opts.intervalMs >= 0 ? opts.intervalMs : EDIT_SUBMIT_INTERVAL_MS
|
|
2508
|
-
|
|
2512
|
+
// 0.23.0:允许真执行测试注入 inputActions(生产路径仍读模块级 __inputActions)。
|
|
2513
|
+
// 之前测试把 deps.submitEdited 整个 stub 掉,真实提交逻辑从未被执行过。
|
|
2514
|
+
const readInputActions = typeof opts.getInputActions === 'function' ? opts.getInputActions : () => __inputActions
|
|
2515
|
+
const before = readInputActions()
|
|
2509
2516
|
return new Promise(resolve => {
|
|
2510
2517
|
let n = 0
|
|
2511
2518
|
const tick = () => {
|
|
2512
2519
|
n += 1
|
|
2513
|
-
const ia =
|
|
2520
|
+
const ia = readInputActions()
|
|
2514
2521
|
const usable = ia && typeof ia.submit === 'function' && typeof ia.setDraft === 'function'
|
|
2515
2522
|
const remounted = !!ia && ia !== before
|
|
2516
2523
|
if (usable && (remounted || n >= attempts)) {
|
|
@@ -2996,56 +3003,6 @@ window.__ModuleLoader__.load({
|
|
|
2996
3003
|
return Number.isSafeInteger(seq) && seq > 0 ? seq - 1 : -1
|
|
2997
3004
|
}
|
|
2998
3005
|
|
|
2999
|
-
/**
|
|
3000
|
-
* 官方 assistant turn-tail 的 branch 按钮识别(0.12.0)。
|
|
3001
|
-
*
|
|
3002
|
-
* 为什么不能靠 aria-label:官方文案有 8 种语言(zh/en/ja/es/fr/de/ru/pt),
|
|
3003
|
-
* 逐个匹配等于把 i18n 表抄进来。也不能靠 class:CSS Modules 会哈希前缀
|
|
3004
|
-
* (实测 0.2.0-rc.2 是 `xzv4MW_`,0.2.1 起变过)。
|
|
3005
|
-
*
|
|
3006
|
-
* ⚠️ 也不能靠 `<path d="…">`(0.12.0 的错误做法,0.13.1 修):0.2.2-alpha.2 的
|
|
3007
|
-
* 图标已改为 **sprite 复用**,官方组件长这样(见已安装 app bundle 的工厂函数):
|
|
3008
|
-
*
|
|
3009
|
-
* <svg data-icon="dsw-icon-branch-outline-regular" aria-hidden="true">
|
|
3010
|
-
* <use href="#dsw-icon-branch-outline-regular"/>
|
|
3011
|
-
* </svg>
|
|
3012
|
-
*
|
|
3013
|
-
* DOM 里**根本没有 `<path>`**,`M13.0762…` 在整个已安装 dsh 里 0 次命中。
|
|
3014
|
-
* 唯一稳定的是 `data-icon` 的 id:`dsw-icon-${name}-${size}`(工厂 `Qv`),
|
|
3015
|
-
* name 来自 ui-primitives 的图标表,属契约级常量。
|
|
3016
|
-
*
|
|
3017
|
-
* 我们自己的分叉按钮也故意用同一图标,所以必须按 class 显式排除。
|
|
3018
|
-
*
|
|
3019
|
-
* @param btn - 候选按钮(任意元素;非 button 的宿主节点返回 false)
|
|
3020
|
-
* @returns 是否官方 branch 按钮
|
|
3021
|
-
*/
|
|
3022
|
-
const HOST_BRANCH_ICON_ID = 'dsw-icon-branch-outline-regular'
|
|
3023
|
-
const HOST_BRANCH_CLASS = 'mopsUserFork'
|
|
3024
|
-
function isHostBranchButton(btn) {
|
|
3025
|
-
if (!btn || typeof btn.querySelector !== 'function') return false
|
|
3026
|
-
const cls = String((btn.classList && btn.classList.value) || btn.className || '')
|
|
3027
|
-
if (cls.split(/\s+/).includes(HOST_BRANCH_CLASS)) return false
|
|
3028
|
-
// 首选 sprite 形态:<svg data-icon="dsw-icon-branch-outline-regular">
|
|
3029
|
-
const svg = btn.querySelector('svg')
|
|
3030
|
-
if (svg && svg.getAttribute('data-icon') === HOST_BRANCH_ICON_ID) return true
|
|
3031
|
-
// 兼容旧宿主的内联 path 形态(0.2.0-rc.x):仍接受官方几何前缀
|
|
3032
|
-
const path = btn.querySelector('svg path')
|
|
3033
|
-
const d = path ? path.getAttribute('d') || '' : ''
|
|
3034
|
-
return d.startsWith(HOST_BRANCH_D_PREFIX)
|
|
3035
|
-
}
|
|
3036
|
-
|
|
3037
|
-
/** 旧宿主的内联 path 几何前缀(仅作兼容回退,不是主判据)。 */
|
|
3038
|
-
const HOST_BRANCH_D_PREFIX = 'M13.0762 1.37207'
|
|
3039
|
-
|
|
3040
|
-
/**
|
|
3041
|
-
* 把文本预置成某个会话的草稿(新会话刚 fork 出来时输入框是空的)。
|
|
3042
|
-
*
|
|
3043
|
-
* 为什么直接写 localStorage 而不是 `inputActions.setDraft`:fork 出来的是一个**还没
|
|
3044
|
-
* 挂载**的会话,此刻 `inputActions` 仍绑定在源会话上;宿主挂载新会话时会用
|
|
3045
|
-
* `readConversationDraft(sessionId)` 从 localStorage 初始化编辑器。所以**先落盘再
|
|
3046
|
-
* openSession** 才是无竞态的路径(`{ draft: '<text>' }` 是宿主 `parseStoredDraft`
|
|
3047
|
-
* 支持的字符串形态,见 dsh-client-ui-conversation:4455-4456)。
|
|
3048
|
-
*/
|
|
3049
3006
|
function writeSessionDraft(childSessionId, text) {
|
|
3050
3007
|
try {
|
|
3051
3008
|
if (!childSessionId || typeof localStorage === 'undefined') return false
|
|
@@ -3337,11 +3294,23 @@ window.__ModuleLoader__.load({
|
|
|
3337
3294
|
const QUOTE_MAX_CHARS = 600
|
|
3338
3295
|
// 0.20.0(bug-hunt M-1):按 Unicode code point 截断,且尽量在换行/空格处收尾,
|
|
3339
3296
|
// 避免把 emoji(代理对)或 markdown 围栏 ``` 从中间切坏。
|
|
3297
|
+
// 0.22.0(真执行实测):按 code point 切会拆散 grapheme cluster。
|
|
3298
|
+
// 实测 'a'.repeat(598) + '👨👩👧👦' → 尾部 U+1f468 U+200d U+2026,
|
|
3299
|
+
// 家庭 emoji 被切成单人 + 悬空 ZWJ。改用 Intl.Segmenter 按 grapheme 切。
|
|
3300
|
+
let quoteSegmenter = null
|
|
3301
|
+
const graphemes = raw => {
|
|
3302
|
+
if (typeof Intl !== 'undefined' && Intl.Segmenter) {
|
|
3303
|
+
quoteSegmenter ||= new Intl.Segmenter('zh', { granularity: 'grapheme' })
|
|
3304
|
+
return Array.from(quoteSegmenter.segment(String(raw)), part => part.segment)
|
|
3305
|
+
}
|
|
3306
|
+
return Array.from(String(raw))
|
|
3307
|
+
}
|
|
3340
3308
|
const clipQuote = raw => {
|
|
3341
|
-
const chars =
|
|
3309
|
+
const chars = graphemes(raw)
|
|
3342
3310
|
if (chars.length <= QUOTE_MAX_CHARS) return chars.join('')
|
|
3343
3311
|
let end = QUOTE_MAX_CHARS
|
|
3344
|
-
// 往前找最近的空白/换行边界(最多回退 40
|
|
3312
|
+
// 往前找最近的空白/换行边界(最多回退 40 个 grapheme),不破坏单词;
|
|
3313
|
+
// 找不到就硬切(此时至少不会拆散单个 grapheme)
|
|
3345
3314
|
for (let i = end; i > Math.max(0, end - 40); i--) {
|
|
3346
3315
|
if (/[\s\n]/.test(chars[i - 1])) {
|
|
3347
3316
|
end = i
|
|
@@ -3450,9 +3419,24 @@ window.__ModuleLoader__.load({
|
|
|
3450
3419
|
},
|
|
3451
3420
|
icon,
|
|
3452
3421
|
)
|
|
3453
|
-
// 0.
|
|
3454
|
-
//
|
|
3455
|
-
|
|
3422
|
+
// 0.23.0:AI 消息动作区**不再注入任何按钮**。
|
|
3423
|
+
//
|
|
3424
|
+
// 用户反馈:「引用不要每次把一整个上下文重新全部塞给 AI」。核查结论:
|
|
3425
|
+
// · 宿主自带完整划词引用 —— dsh-message-quotes/lib/client.js:48 调
|
|
3426
|
+
// inputActions.insertQuote(text),注册在 conversation.chat.text-interaction
|
|
3427
|
+
// 槽,只在用户选中文字(textInteraction.active !== null)时渲染,
|
|
3428
|
+
// 「选中多少引多少」,从不引整条。
|
|
3429
|
+
// · 我们旧按钮用 [data-chat-node-key] 判选区,与宿主的
|
|
3430
|
+
// [data-text-interaction-source] 体系不匹配 → 高频判不出选区 →
|
|
3431
|
+
// 退化成 clipQuote(fullText) 把 600 字塞进 composer。
|
|
3432
|
+
// · 而 deriveMessages() 本就遍历 surface.nodes 给出完整历史,
|
|
3433
|
+
// 引用当前会话里未被遮蔽的消息 = 同一内容在 prompt 里出现两遍,纯冗余。
|
|
3434
|
+
// 所以正确做法是让位给宿主,不再重复造轮子。
|
|
3435
|
+
//
|
|
3436
|
+
// ⚠️ 本组件**必须保留**:它负责捕获 inputActions 到 __inputActions
|
|
3437
|
+
//(编辑框 / 面板 / 行内回填都依赖),删组件会让这些功能静默失效。
|
|
3438
|
+
// 只 return null,不删注册。
|
|
3439
|
+
return null
|
|
3456
3440
|
}
|
|
3457
3441
|
|
|
3458
3442
|
// 0.4.2 引入(恢复的标记自动离开活跃列表 = opencode clear 语义)。
|
|
@@ -3595,8 +3579,12 @@ window.__ModuleLoader__.load({
|
|
|
3595
3579
|
// 0.5.2(P2):标题口径 = 标记 range 内 visible=false 的去重 seq 数
|
|
3596
3580
|
const seen = new Set()
|
|
3597
3581
|
for (const mk of act) {
|
|
3598
|
-
|
|
3599
|
-
|
|
3582
|
+
// 0.23.0(深挖 S-2):服务端 buildDerived 用 readReplaceOp 把 range
|
|
3583
|
+
// 覆盖成 {startSeq,endSeq},而旧代码只读 {start,end} → 计数恒为 0。
|
|
3584
|
+
// 两种形状都兼容,并防御旧缓存里仍是 {start,end} 的情况。
|
|
3585
|
+
const rng = mk.range || {}
|
|
3586
|
+
const start = Number.isSafeInteger(rng.startSeq) ? rng.startSeq : Number.isSafeInteger(rng.start) ? rng.start : mk.seq
|
|
3587
|
+
const end = Number.isSafeInteger(rng.endSeq) ? rng.endSeq : Number.isSafeInteger(rng.end) ? rng.end : start
|
|
3600
3588
|
for (const m of msgs) {
|
|
3601
3589
|
if (m && m.visible === false && typeof m.seq === 'number' && m.seq >= start && m.seq <= end) seen.add(m.seq)
|
|
3602
3590
|
}
|
|
@@ -4149,11 +4137,7 @@ window.__ModuleLoader__.load({
|
|
|
4149
4137
|
// 0.18.0/0.20.0:三种按钮各有自己的提示文案(编辑按钮不能写 revert 的 hint)
|
|
4150
4138
|
// 0.21.0:回滚按钮统一用「带隐私提示」的 title —— syncEnabled 会在
|
|
4151
4139
|
// 注入后重设 title,若这里仍用 slot.revert 会覆盖掉 ensureBtn 里的隐私提示。
|
|
4152
|
-
const hintKey = btn.classList.contains('
|
|
4153
|
-
? 'slot.forkHint'
|
|
4154
|
-
: btn.classList.contains('mopsUserEdit')
|
|
4155
|
-
? 'slot.editHint'
|
|
4156
|
-
: 'slot.revertPrivacyHint'
|
|
4140
|
+
const hintKey = btn.classList.contains('mopsUserEdit') ? 'slot.editHint' : 'slot.revertPrivacyHint'
|
|
4157
4141
|
const ok = block.getAttribute('data-mops-seq')
|
|
4158
4142
|
if (ok) {
|
|
4159
4143
|
btn.disabled = false
|
|
@@ -4168,7 +4152,7 @@ window.__ModuleLoader__.load({
|
|
|
4168
4152
|
/** 块内全部插件按钮一起同步(回滚 / 编辑 / 分叉同一动作行)。 */
|
|
4169
4153
|
var syncBlockButtons = block => {
|
|
4170
4154
|
if (!block || !block.querySelectorAll) return
|
|
4171
|
-
for (const b of block.querySelectorAll('.mopsUserRevert, .mopsUserEdit
|
|
4155
|
+
for (const b of block.querySelectorAll('.mopsUserRevert, .mopsUserEdit')) syncEnabled(block, b)
|
|
4172
4156
|
}
|
|
4173
4157
|
var assignSeqs = (sid, cache, anchors) => {
|
|
4174
4158
|
const idx = cache && cache.idx
|
|
@@ -4268,12 +4252,15 @@ window.__ModuleLoader__.load({
|
|
|
4268
4252
|
/* keep {} */
|
|
4269
4253
|
}
|
|
4270
4254
|
if (!res.ok || !data.ok) throw new Error(data.error || 'HTTP ' + res.status)
|
|
4271
|
-
|
|
4255
|
+
// 0.23.0(深挖):先回填再报成功,回填失败要让用户知道。
|
|
4256
|
+
// 旧实现先 notifyDone(done.revert) 再 refillComposer 且丢弃返回值 →
|
|
4257
|
+
// 用户看到「已回滚」却拿到空输入框(0.14.0 踩过的同一类静默失败)。
|
|
4272
4258
|
// 0.17.0(冲突 C2):按钮路径原先漏了「立刻标遮蔽」,
|
|
4273
4259
|
// 导致刷新窗口内重复点击会拿已遮蔽的 seq 去 POST → 409。
|
|
4274
4260
|
markRowsShadowedFrom(row.seq)
|
|
4275
|
-
|
|
4276
|
-
|
|
4261
|
+
const filled = refillComposer(sid, row.seq)
|
|
4262
|
+
if (filled) notifyDone(__t('done.revert'))
|
|
4263
|
+
else notifyDone(__t('done.revertNoRefill'), 'warn')
|
|
4277
4264
|
emitChanged()
|
|
4278
4265
|
try {
|
|
4279
4266
|
if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(sid)
|
|
@@ -4296,119 +4283,6 @@ window.__ModuleLoader__.load({
|
|
|
4296
4283
|
})
|
|
4297
4284
|
})
|
|
4298
4285
|
}
|
|
4299
|
-
/**
|
|
4300
|
-
* 0.12.0 用户消息「从此条分叉」:非破坏操作,源会话一字不动。
|
|
4301
|
-
*
|
|
4302
|
-
* opencode 语义 = 复制此条**之前**的对话到一个新会话,并把此条原文放回
|
|
4303
|
-
* 新会话的输入框,让用户改完再发。因此这里要三步:
|
|
4304
|
-
* 1. 解析 seq(点击当下可能还没打标 → 先 ensureAssign 再 fetchRows)
|
|
4305
|
-
* 2. 取该条用户消息的**原文**(列表只携带 snippet,长度会被截断)
|
|
4306
|
-
* 3. fork(boundary = seq - 1) → 把原文写进子会话草稿 → 打开子会话
|
|
4307
|
-
*/
|
|
4308
|
-
var runUserFork = (btn, block) => {
|
|
4309
|
-
const sid = __currentSessionId
|
|
4310
|
-
if (!sid) return
|
|
4311
|
-
btn.disabled = true
|
|
4312
|
-
Promise.resolve()
|
|
4313
|
-
.then(() => ensureAssign(sid))
|
|
4314
|
-
.then(() => fetchRows(sid))
|
|
4315
|
-
.then(async cache => {
|
|
4316
|
-
const rows = cache && cache.rows
|
|
4317
|
-
const seq = Number(block.getAttribute('data-mops-seq'))
|
|
4318
|
-
const row = rows && rows.find(r => r.seq === seq)
|
|
4319
|
-
if (!row) {
|
|
4320
|
-
notifyDone(__t('errorPrefix') + __t('slot.revertUnmatched'), 'error')
|
|
4321
|
-
return
|
|
4322
|
-
}
|
|
4323
|
-
if (!(seq > 0)) {
|
|
4324
|
-
notifyDone(__t('slot.forkUnavailable'), 'warn')
|
|
4325
|
-
return
|
|
4326
|
-
}
|
|
4327
|
-
let text = typeof row.fullText === 'string' ? row.fullText : ''
|
|
4328
|
-
if (!text) {
|
|
4329
|
-
try {
|
|
4330
|
-
const res = await fetch(
|
|
4331
|
-
'/api/message-ops/text?sessionId=' + encodeURIComponent(bareSessionId(sid)) + '&seq=' + encodeURIComponent(seq),
|
|
4332
|
-
)
|
|
4333
|
-
const data = res.ok ? await res.json().catch(() => null) : null
|
|
4334
|
-
if (data && data.ok && typeof data.text === 'string') text = data.text
|
|
4335
|
-
} catch {
|
|
4336
|
-
/* 取全文失败:分叉照做,只是输入框留空 */
|
|
4337
|
-
}
|
|
4338
|
-
}
|
|
4339
|
-
const childId = await forkFromUserMessage(sid, seq, text, row.turnStartSeq)
|
|
4340
|
-
notifyDone(__t('slot.forkDone', { id: String(childId || '') }))
|
|
4341
|
-
if (childId) openSessionById(childId)
|
|
4342
|
-
})
|
|
4343
|
-
.catch(reason => {
|
|
4344
|
-
notifyDone(__t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)), 'error')
|
|
4345
|
-
})
|
|
4346
|
-
.finally(() => {
|
|
4347
|
-
btn.disabled = false
|
|
4348
|
-
})
|
|
4349
|
-
}
|
|
4350
|
-
|
|
4351
|
-
var ensureBtn = block => {
|
|
4352
|
-
// 官方动作行(含 Copy):把按钮放到这一行里,与 Copy 同级
|
|
4353
|
-
let host = block.querySelector('[class*="xzv4MW_actions"]')
|
|
4354
|
-
if (!host) {
|
|
4355
|
-
host = document.createElement('div')
|
|
4356
|
-
host.className = 'mopsUserActionsRow'
|
|
4357
|
-
block.appendChild(host)
|
|
4358
|
-
}
|
|
4359
|
-
let btn = host.querySelector('.mopsUserRevert')
|
|
4360
|
-
if (btn) return btn
|
|
4361
|
-
btn = document.createElement('button')
|
|
4362
|
-
btn.type = 'button'
|
|
4363
|
-
btn.className = 'mopsUserRevert'
|
|
4364
|
-
// 0.21.0:行内回滚按钮不经过面板确认框,隐私告知必须挂在这里(hover 可见)
|
|
4365
|
-
btn.title = __t('slot.revertPrivacyHint')
|
|
4366
|
-
btn.setAttribute('aria-label', __t('slot.revert'))
|
|
4367
|
-
btn.innerHTML =
|
|
4368
|
-
'<svg width="14" height="14" viewBox="0 0 16 16" fill="none"><path d="M2.5 8a5.5 5.5 0 1 0 1.6-3.9" stroke="currentColor" stroke-width="1.2"/><path d="M2.2 2.8v3h3" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>'
|
|
4369
|
-
btn.addEventListener('click', e => {
|
|
4370
|
-
e.preventDefault()
|
|
4371
|
-
e.stopPropagation()
|
|
4372
|
-
if (btn.disabled) return
|
|
4373
|
-
runUserRevert(btn, block)
|
|
4374
|
-
})
|
|
4375
|
-
host.appendChild(btn)
|
|
4376
|
-
// 0.9.7(P2-1):新按钮按块的**当前**打标状态立刻同步一次。
|
|
4377
|
-
// 门控之后 assignSeqs 可能被跳过(签名未变),靠这里保证「宿主重建了
|
|
4378
|
-
// 动作行 → 按钮重新挂上」这种情况仍然是 disabled/title 正确的。
|
|
4379
|
-
syncEnabled(block, btn)
|
|
4380
|
-
return btn
|
|
4381
|
-
}
|
|
4382
|
-
|
|
4383
|
-
/** 0.12.0 分叉按钮:与回滚按钮**同一动作行**(opencode 把 fork 放在 copy/undo 同组)。 */
|
|
4384
|
-
var ensureForkBtn = block => {
|
|
4385
|
-
let host = block.querySelector('[class*="xzv4MW_actions"]')
|
|
4386
|
-
if (!host) {
|
|
4387
|
-
host = document.createElement('div')
|
|
4388
|
-
host.className = 'mopsUserActionsRow'
|
|
4389
|
-
block.appendChild(host)
|
|
4390
|
-
}
|
|
4391
|
-
const existing = host.querySelector('.mopsUserFork')
|
|
4392
|
-
if (existing) return existing
|
|
4393
|
-
const btn = document.createElement('button')
|
|
4394
|
-
btn.type = 'button'
|
|
4395
|
-
btn.className = 'mopsUserFork'
|
|
4396
|
-
btn.title = __t('slot.forkHint')
|
|
4397
|
-
btn.setAttribute('aria-label', __t('slot.fork'))
|
|
4398
|
-
// 官方 IconBranchOutline16 的 1:1 路径(packages/client/ui-primitives/src/icons/index.tsx:149)
|
|
4399
|
-
btn.innerHTML =
|
|
4400
|
-
'<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M13.0762 1.37207C14.0846 1.37228 14.9021 2.19077 14.9023 3.19922C14.9022 4.20772 14.0847 5.02518 13.0762 5.02539C12.2967 5.02539 11.6325 4.53691 11.3701 3.84961H4.35547C4.79397 4.26458 5.15861 4.7644 5.41699 5.33496L7.10645 9.06738C7.88526 10.7875 9.55104 11.9228 11.4189 12.0371C11.7085 11.4109 12.3411 10.9756 13.0762 10.9756C14.0843 10.9759 14.9023 11.7936 14.9023 12.8018C14.9023 13.81 14.0843 14.6277 13.0762 14.6279C12.2534 14.6279 11.5574 14.0832 11.3291 13.335C8.9868 13.1879 6.89981 11.7612 5.92285 9.60352L4.23242 5.87109C3.67503 4.64033 2.44878 3.84961 1.09766 3.84961V2.54883C1.10665 2.54883 1.11601 2.54975 1.125 2.5498L11.3701 2.54883C11.6326 1.86151 12.2969 1.37207 13.0762 1.37207ZM13.0762 12.2764C12.7858 12.2764 12.5508 12.5114 12.5508 12.8018C12.5508 13.0921 12.7858 13.3281 13.0762 13.3281C13.3664 13.3279 13.6025 13.092 13.6025 12.8018C13.6025 12.5115 13.3664 12.2766 13.0762 12.2764ZM13.0762 2.67285C12.7855 2.67285 12.55 2.90861 12.5498 3.19922C12.5499 3.48987 12.7855 3.72559 13.0762 3.72559C13.3667 3.72538 13.6024 3.48975 13.6025 3.19922C13.6023 2.90874 13.3666 2.67306 13.0762 2.67285Z"/></svg>'
|
|
4401
|
-
btn.addEventListener('click', e => {
|
|
4402
|
-
e.preventDefault()
|
|
4403
|
-
e.stopPropagation()
|
|
4404
|
-
if (btn.disabled) return
|
|
4405
|
-
runUserFork(btn, block)
|
|
4406
|
-
})
|
|
4407
|
-
host.appendChild(btn)
|
|
4408
|
-
syncEnabled(block, btn)
|
|
4409
|
-
return btn
|
|
4410
|
-
}
|
|
4411
|
-
|
|
4412
4286
|
/**
|
|
4413
4287
|
* 0.20.0 铅笔编辑按钮:与回滚**同一动作行**,插在回滚与分叉之间。
|
|
4414
4288
|
*
|
|
@@ -4493,12 +4367,46 @@ window.__ModuleLoader__.load({
|
|
|
4493
4367
|
}
|
|
4494
4368
|
|
|
4495
4369
|
// 三个按钮的顺序由 DOM 顺序决定:回滚在前(破坏性更高),编辑居中,分叉最后(非破坏)。
|
|
4370
|
+
var ensureBtn = block => {
|
|
4371
|
+
// 官方动作行(含 Copy):把按钮放到这一行里,与 Copy 同级
|
|
4372
|
+
let host = block.querySelector('[class*="xzv4MW_actions"]')
|
|
4373
|
+
if (!host) {
|
|
4374
|
+
host = document.createElement('div')
|
|
4375
|
+
host.className = 'mopsUserActionsRow'
|
|
4376
|
+
block.appendChild(host)
|
|
4377
|
+
}
|
|
4378
|
+
let btn = host.querySelector('.mopsUserRevert')
|
|
4379
|
+
if (btn) return btn
|
|
4380
|
+
btn = document.createElement('button')
|
|
4381
|
+
btn.type = 'button'
|
|
4382
|
+
btn.className = 'mopsUserRevert'
|
|
4383
|
+
// 0.21.0:行内回滚按钮不经过面板确认框,隐私告知必须挂在这里(hover 可见)
|
|
4384
|
+
btn.title = __t('slot.revertPrivacyHint')
|
|
4385
|
+
btn.setAttribute('aria-label', __t('slot.revert'))
|
|
4386
|
+
btn.innerHTML =
|
|
4387
|
+
'<svg width="14" height="14" viewBox="0 0 16 16" fill="none"><path d="M2.5 8a5.5 5.5 0 1 0 1.6-3.9" stroke="currentColor" stroke-width="1.2"/><path d="M2.2 2.8v3h3" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>'
|
|
4388
|
+
btn.addEventListener('click', e => {
|
|
4389
|
+
e.preventDefault()
|
|
4390
|
+
e.stopPropagation()
|
|
4391
|
+
if (btn.disabled) return
|
|
4392
|
+
runUserRevert(btn, block)
|
|
4393
|
+
})
|
|
4394
|
+
host.appendChild(btn)
|
|
4395
|
+
// 0.9.7(P2-1):新按钮按块的**当前**打标状态立刻同步一次。
|
|
4396
|
+
// 门控之后 assignSeqs 可能被跳过(签名未变),靠这里保证「宿主重建了
|
|
4397
|
+
// 动作行 → 按钮重新挂上」这种情况仍然是 disabled/title 正确的。
|
|
4398
|
+
syncEnabled(block, btn)
|
|
4399
|
+
return btn
|
|
4400
|
+
}
|
|
4401
|
+
|
|
4496
4402
|
var ensureUserActions = block => {
|
|
4497
4403
|
// 0.20.0:铅笔回归,但语义变了 —— 独立编辑框 + 点「发送并回撤」才写,
|
|
4498
4404
|
// 不再是 0.18.0 那种「只回填 composer」的伪编辑。
|
|
4405
|
+
// 0.23.0:行内 fork 按钮已删 —— dsh 官方在 AI 回合尾部已有
|
|
4406
|
+
// sessions.fork(conversation.chat.assistant-actions / TurnTailNodeView)。
|
|
4407
|
+
// 分叉能力统一由官方按钮 + 面板 branch(同样走官方 sessions.fork)承担。
|
|
4499
4408
|
ensureBtn(block)
|
|
4500
4409
|
ensureEditBtn(block)
|
|
4501
|
-
ensureForkBtn(block)
|
|
4502
4410
|
}
|
|
4503
4411
|
// 0.9.7(P0-2 读合并):把 150/700/1600ms 三档并成**一次**真网络请求,
|
|
4504
4412
|
// 落点 = 本 burst 第一档 + 1500ms ≈ 原来的 1600ms 那一档。
|
|
@@ -4540,7 +4448,6 @@ window.__ModuleLoader__.load({
|
|
|
4540
4448
|
if (!sid) return
|
|
4541
4449
|
const blocks = userAnchors()
|
|
4542
4450
|
for (const b of blocks) ensureUserActions(b)
|
|
4543
|
-
suppressHostBranch()
|
|
4544
4451
|
// 0.9.1:**始终**刷新(原先只在按钮未打标时刷)——
|
|
4545
4452
|
// 打标后 transcript 再变化(openSession 重建 / 分页 / restore 重放)
|
|
4546
4453
|
// 就再也不会重算隐藏,导致「界面停在旧状态,必须重载页面才对」。
|
|
@@ -4549,33 +4456,6 @@ window.__ModuleLoader__.load({
|
|
|
4549
4456
|
/* 注入失败不影响会话 */
|
|
4550
4457
|
}
|
|
4551
4458
|
}
|
|
4552
|
-
/**
|
|
4553
|
-
* 0.12.0 隐藏官方 assistant turn-tail 上的 branch 按钮。
|
|
4554
|
-
*
|
|
4555
|
-
* 产品决定:分叉只属于**用户消息**(opencode 语义 —— fork 的目的是「这句话说错了,
|
|
4556
|
-
* 拿回输入框重说」,AI 消息没有可回填的原文,分叉出去只会得到一个半截对话)。
|
|
4557
|
-
* 官方把 branch 画在 MessageIconActions 里,与 copy 同一行;官方没有开关
|
|
4558
|
-
* (ui-chat 的 Config 只有折叠/性能/链接几项),所以只能在渲染层隐藏。
|
|
4559
|
-
*
|
|
4560
|
-
* 识别方式不用 aria-label(8 种语言各不同),也不用哈希 class,而用
|
|
4561
|
-
* **图标路径前缀**:官方 IconBranchOutline16 的 d 是固定字符串
|
|
4562
|
-
* (packages/client/ui-primitives/src/icons/index.tsx:149)。作用域限定在
|
|
4563
|
-
* `[data-turn-tail]`(官方 TurnTailNodeView 渲染的稳定属性),
|
|
4564
|
-
* 并排除我们自己注入的 .mopsUserFork(它复用同一 path)。
|
|
4565
|
-
*/
|
|
4566
|
-
var suppressHostBranch = () => {
|
|
4567
|
-
let hidden = 0
|
|
4568
|
-
for (const btn of document.querySelectorAll('[data-turn-tail] button')) {
|
|
4569
|
-
if (!isHostBranchButton(btn)) continue
|
|
4570
|
-
hidden++
|
|
4571
|
-
if (btn.getAttribute('data-mops-host-branch') !== 'hidden') {
|
|
4572
|
-
btn.setAttribute('data-mops-host-branch', 'hidden')
|
|
4573
|
-
btn.style.display = 'none'
|
|
4574
|
-
}
|
|
4575
|
-
}
|
|
4576
|
-
return hidden
|
|
4577
|
-
}
|
|
4578
|
-
|
|
4579
4459
|
// 触发:hover / 滚动 / DOM 变化 / 变更事件
|
|
4580
4460
|
document.addEventListener(
|
|
4581
4461
|
'mouseover',
|
|
@@ -4687,11 +4567,11 @@ window.__ModuleLoader__.load({
|
|
|
4687
4567
|
// (宿主 .xzv4MW_actions 已定 height:28px,改小会撑裂行高)。
|
|
4688
4568
|
// · 无淡入动画(opencode 源码注释明写 "Hover actions show and hide
|
|
4689
4569
|
// at once, without a fade")—— 显隐完全交给宿主 [data-actions-reveal]。
|
|
4690
|
-
'.mopsUserRevert,.mopsUserEdit
|
|
4691
|
-
'.mopsUserRevert svg,.mopsUserEdit svg
|
|
4692
|
-
'.mopsUserRevert:hover,.mopsUserEdit:hover
|
|
4693
|
-
'.mopsUserRevert:disabled,.mopsUserEdit:disabled
|
|
4694
|
-
'.mopsUserRevert:focus-visible,.mopsUserEdit:focus-visible
|
|
4570
|
+
'.mopsUserRevert,.mopsUserEdit{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--dsw-alias-label-tertiary,#808080);cursor:pointer;padding:0;flex:none}',
|
|
4571
|
+
'.mopsUserRevert svg,.mopsUserEdit svg{width:14px;height:14px;display:block}',
|
|
4572
|
+
'.mopsUserRevert:hover,.mopsUserEdit:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-secondary,#6b6b70)}',
|
|
4573
|
+
'.mopsUserRevert:disabled,.mopsUserEdit:disabled{opacity:.4;cursor:default;background:transparent}',
|
|
4574
|
+
'.mopsUserRevert:focus-visible,.mopsUserEdit:focus-visible{outline:2px solid var(--dsw-alias-border-l2,#b8b8b8);outline-offset:1px}',
|
|
4695
4575
|
// 0.18.0:用户反馈「点时间图标也会回撤」——根因不是绑定错误,而是
|
|
4696
4576
|
// 我们的按钮被 appendChild 到宿主 .actions 行末尾,而该行在
|
|
4697
4577
|
// data-clock="start"(用户消息)时第一个子元素就是**时间文本**:
|
|
@@ -5224,10 +5104,7 @@ window.__ModuleLoader__.load({
|
|
|
5224
5104
|
__test: {
|
|
5225
5105
|
activityTransition,
|
|
5226
5106
|
forkBoundaryBefore,
|
|
5227
|
-
isHostBranchButton,
|
|
5228
5107
|
writeSessionDraft,
|
|
5229
|
-
HOST_BRANCH_ICON_ID,
|
|
5230
|
-
HOST_BRANCH_D_PREFIX,
|
|
5231
5108
|
// 0.20.0:编辑并重发的编排层(可注入 deps 真执行断言时序)
|
|
5232
5109
|
sendEditAndRevert,
|
|
5233
5110
|
submitEditedText,
|
package/src/ops-core.js
CHANGED
|
@@ -21,7 +21,7 @@ import { OpsError } from './session-file.js'
|
|
|
21
21
|
* @module dsh-message-ops/ops-core
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { readReplaceOp, messageText, computeShadowed } from './session-file.js'
|
|
24
|
+
import { readReplaceOp, messageText, messageTextFull, computeShadowed } from './session-file.js'
|
|
25
25
|
|
|
26
26
|
// messageText 的单点实现在 session-file.js(listMessages 同用);此处转出保持
|
|
27
27
|
// 既有导入面兼容(ops-core 的 messageText 调用方不受影响)。
|
|
@@ -447,7 +447,11 @@ export function planRestore(events, restoreSeq, upToSeq, excludeSeqs) {
|
|
|
447
447
|
if (!e || typeof e.seq !== 'number' || e.seq < startSeq || e.seq > cap) continue
|
|
448
448
|
if (e.type === 'user/message' || e.type === 'assistant/message') {
|
|
449
449
|
if (excluded && excluded.has(e.seq)) continue
|
|
450
|
-
|
|
450
|
+
// 0.23.0(深挖 S-1):重放必须取**全段**。宿主把长文本拆成多个 content
|
|
451
|
+
// 段(compaction checkpoint 实测 321+7954+20 三段),旧实现用 messageText
|
|
452
|
+
// 只取首段 → 恢复副本永久丢掉后半段。实测 898 条多段消息受影响、
|
|
453
|
+
// 累计丢 175 万字符,其中 133 条是真人输入。
|
|
454
|
+
const text = messageTextFull(e)
|
|
451
455
|
if (!text.trim()) {
|
|
452
456
|
skipped++
|
|
453
457
|
continue
|
package/src/session-file.js
CHANGED
|
@@ -335,7 +335,13 @@ export function listMessages(events) {
|
|
|
335
335
|
// 前提是这些事件必须先出现在我们的消息列表里、并带上 id,否则
|
|
336
336
|
// byMessageId 查不到 → seqOfNodeKey 返回 null → 调用方「保持可见」。
|
|
337
337
|
if (e.type === 'user/message' || e.type === 'assistant/message' || e.type === 'system/message' || e.type === 'developer/message') {
|
|
338
|
+
// 0.22.0:`snippet` 用首段即可,但 `fullText` 必须用**全段**。
|
|
339
|
+
// 旧实现两者共用 messageText(首段),当宿主把长文本拆成多个 content 段
|
|
340
|
+
// (compaction checkpoint 实测 321+7954+20 三段)时,fullText 只有第一段
|
|
341
|
+
// → refillComposer / fork 回填丢掉后半段,与 /text 接口(messageTextFull)
|
|
342
|
+
// 口径分裂。这里显式分开。
|
|
338
343
|
const text = messageText(e)
|
|
344
|
+
const fullTextValue = messageTextFull(e)
|
|
339
345
|
const msg = e.data && e.data.message
|
|
340
346
|
// id:宿主持久化的消息身份(user 在 data.id、assistant 在 data.message.id),
|
|
341
347
|
// 供 0.2.0 assistant-actions 槽(ownerProps={messageId})反查 seq。
|
|
@@ -357,7 +363,7 @@ export function listMessages(events) {
|
|
|
357
363
|
marker: isReplaceMarker,
|
|
358
364
|
snippet: text.replace(/\s+/g, ' ').trim().slice(0, 160),
|
|
359
365
|
// 0.4.0 composer 回填:user 消息携带全文(revert 后 setDraft 原文)
|
|
360
|
-
fullText: e.type === 'user/message' ?
|
|
366
|
+
fullText: e.type === 'user/message' ? fullTextValue : null,
|
|
361
367
|
// 0.4.1 dock:replace 标记携带范围与来源(区分手工回撤 vs compaction)
|
|
362
368
|
range:
|
|
363
369
|
isReplaceMarker && e.surfaceOp.startSeq != null && e.surfaceOp.endSeq != null
|