@240xu/dsh-message-ops 0.22.0 → 0.24.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/src/client.js CHANGED
@@ -9,7 +9,8 @@ window.__ModuleLoader__.load({
9
9
  factory: require => {
10
10
  const React = require('react')
11
11
  const { useCallback, useEffect, useRef, useState } = React
12
- const { Modal } = require('@deepseek-ai/dsh-client-ui-primitives')
12
+ // 0.24.0:不再 require('@deepseek-ai/dsh-client-ui-primitives') 的 Modal ——
13
+ // 唯一使用者 OpsDialog 已删;面板/编辑框都是自绘浮层。
13
14
 
14
15
  const SLOT = 'conversation.session.header.actions'
15
16
  const ROW_ID = 'message-ops'
@@ -114,23 +115,7 @@ window.__ModuleLoader__.load({
114
115
  'button.title': '消息操作(回滚/删除/分支)',
115
116
  'dialog.title': '消息操作',
116
117
  'dialog.cancel': '关闭',
117
- 'dialog.loading': '正在读取消息列表…',
118
- 'dialog.loadFail': '消息列表读取失败:',
119
- 'dialog.empty': '该会话没有可操作的消息。',
120
- 'dialog.session': '会话:',
121
118
  'dialog.runningWarn': '⚠ 会话正在运行:请先停止该会话再执行回滚/删除/分支。',
122
- 'dialog.pick': '选择一条消息:',
123
- 'dialog.pickFirst': '第 1 步 · 在下方选择一条消息,第 2 步在这里选择操作。',
124
- 'dialog.pickedAs': '已选 #{seq} · {text}',
125
- 'dialog.invisible': '(已遮蔽,仅日志可见)',
126
- 'dialog.showMore': '显示更多(剩余 {n} 条)',
127
- 'dialog.more': '…(仅显示最近 200 条,共 {n} 条)',
128
- 'op.revert': '回滚到此条(含)之后全部移除',
129
- 'op.revertDesc': '遮蔽所选消息及其后所有可见内容;日志 append-only,可通过重新发送恢复语境。',
130
- 'op.delete': '仅删除这一条',
131
- 'op.deleteDesc': '仅遮蔽所选的一条消息;其余内容保持不变。',
132
- 'op.branch': '从此条分叉为新会话',
133
- 'op.branchDesc': '把此条之前的对话复制到新会话,并把此条原文放回新会话输入框(原会话不变,非破坏操作)。',
134
119
  'slot.revert': '回滚到此条',
135
120
  'slot.revertPrivacyHint': '回滚到此条(不是删除:AI 看不到,但原文仍在本地会话文件)',
136
121
  'slot.revertUnmatched': '在日志里定位不到这条消息的 seq(通常是模型写的摘要与渲染文本偏差过大)——请改用「消息操作」对话框。',
@@ -138,12 +123,14 @@ window.__ModuleLoader__.load({
138
123
  'slot.forkHint': '复制此条之前的对话到新会话,并把此条原文放回新会话输入框',
139
124
  'slot.forkDone': '已分叉:新会话 {id}',
140
125
  'slot.forkUnavailable': '分叉不可用:会话正在运行,或宿主未提供 session/fork',
141
- // 0.20.0:铅笔编辑框(用户消息动作行)。语义 = 先回撤再发,不是「只回填」。
142
- 'slot.edit': '编辑并重发',
143
- 'slot.editHint': '打开编辑框;点「发送并回撤」时才回撤此条及其后内容,再发出改后的文本',
126
+ // 0.24.0(P3 入口收敛):改名消除与外部插件 message-edit 的「同名不同义」。
127
+ // 外部插件在 turnTail 也叫「编辑并重发」,但它 fork 出新分支、源会话不动;
128
+ // 我们(铅笔)是**回撤源会话**再重发。同名让用户无法预判后果,故显式写出「回撤」。
129
+ 'slot.edit': '编辑并回撤重发',
130
+ 'slot.editHint': '打开编辑框;点「发送并回撤」会回撤此条及之后的全部可见消息,再把改后文本当新消息发出',
144
131
  'slot.editNoText': '这条消息没有可编辑的文本',
145
132
  'slot.editUnmatched': '在日志里定位不到这条消息的 seq,暂时无法编辑',
146
- 'edit.title': '编辑并重发',
133
+ 'edit.title': '编辑并回撤重发',
147
134
  'edit.subtitle': '这条消息 · seq #{seq}',
148
135
  'edit.loading': '正在读取原文…',
149
136
  'edit.loadFail': '原文读取失败:',
@@ -163,17 +150,10 @@ window.__ModuleLoader__.load({
163
150
  'toast.openNew': '打开新会话',
164
151
  'fork.official': '分支完成:新会话 {id}',
165
152
  'fork.unavailable': '官方分支不可用:通常是因为会话正在运行,请先停止会话后重试。分支功能由 dsh 内置的 session/fork 提供。',
166
- 'ack.revert': '我已了解:回滚会遮蔽所选消息及其后的全部内容',
167
- 'ack.delete': '我已了解:将遮蔽这一条消息(日志中仍保留)',
168
- 'confirm.revert': '回滚',
169
- 'confirm.delete': '删除',
170
- 'confirm.branch': '分支',
171
- 'busy.revert': '回滚中…',
172
- 'busy.delete': '删除中…',
173
- 'busy.branch': '分支中…',
174
153
  'done.restore': '恢复完成:重放 {n} 条,跳过不可重放 {s} 条',
175
- 'done.revert': '已回滚(原文仍保留在本地会话文件,可被恢复);刷新页面后生效',
176
- 'done.delete': '删除完成,刷新页面后生效',
154
+ 'done.revert': '已回滚,原文可从恢复区放回',
155
+ 'done.revertNoRefill': '已回滚,但原文未能放回输入框(会话可能尚未挂载);可重试或从消息操作面板手动复制',
156
+ 'done.delete': '已遮蔽,刷新页面后生效',
177
157
  'action.reload': '刷新页面',
178
158
  errorPrefix: '操作失败:',
179
159
  'dock.title': '已回撤 {n} 条消息',
@@ -217,21 +197,19 @@ window.__ModuleLoader__.load({
217
197
  'panel.revert': '回滚到此条',
218
198
  'panel.revertHint': '包含此条及其后的可见消息',
219
199
  'panel.revertConfirmTitle': '回滚到 #{seq}?',
220
- 'panel.revertConfirmBody': '将遮蔽 #{start}–#{end} 的 {n} 条消息,其中可见 {v} 条;日志仍保留,可恢复。',
221
- // 0.21.0:隐私预期落差修正。回撤不是「删除」,别让用户以为内容消失了。
222
- // 实测(design-demos/revert-data-semantics.md):AI 看不到(模型只读 surface.nodes),
223
- // 但被回撤消息的原文仍逐字留在本地 session.v4.jsonl.zstd 里,翻文件拿得到。
224
- 'panel.revertPrivacyNote':
225
- '注意:这不是删除。AI 将看不到这些消息,但原文仍完整保留在本地会话文件中,可被恢复;直接翻看会话文件仍能读到。',
200
+ // 0.23.0:隐私告知并入确认正文(原 body 37 字 + privacy 56 字 = 93 字,合并后 55 字)。
201
+ // 告知内容一条没少:AI 看不到 / 原文仍在本地文件 / 可恢复。只是不再分两层说。
202
+ 'panel.revertConfirmBody':
203
+ '将遮蔽 #{start}–#{end} 共 {n} 条消息(可见 {v} 条)。AI 将看不到它们,但原文仍保留在本地会话文件、可恢复。',
226
204
  'panel.deleteConfirmTitle': '仅删除 #{seq}?',
227
205
  'panel.deleteConfirmBody': '将遮蔽这 1 条消息,其他内容不动;日志仍保留,可恢复。',
228
206
  'panel.confirmRevert': '确认回滚',
229
- 'panel.confirmDeleteOne': '确认删除',
207
+ 'panel.confirmDeleteOne': '确认遮蔽',
230
208
  'panel.retry': '重试',
231
209
  'panel.searching': '搜索中…',
232
210
  'panel.deleteSessionImpact': '共 {n} 条消息;移入回收站后 7 天内可恢复。',
233
211
  'panel.deleteUnavailable': '会话信息尚未就绪,暂不能删除。',
234
- 'panel.delete': '仅删除此条',
212
+ 'panel.delete': '遮蔽此条',
235
213
  'panel.deleteHint': '只遮蔽这一条,其他消息不动',
236
214
  'panel.branch': '从此条分叉',
237
215
  'panel.branchHint': '复制此条之前的对话到新会话,并把此条原文放回新会话输入框',
@@ -242,7 +220,7 @@ window.__ModuleLoader__.load({
242
220
  // 原消息仍在,界面出现两条相似消息)。opencode 也没有消息级编辑。
243
221
  'panel.openNew': '打开新会话',
244
222
  'panel.revertDone': '回滚已生效',
245
- 'panel.deleteDone': '删除已生效',
223
+ 'panel.deleteDone': '已遮蔽',
246
224
  'panel.count': '共 {n} 条 · 可见 {v} · 已回滚 {s}',
247
225
  'panel.deleteSession': '删除整条会话',
248
226
  'panel.deleteSessionHint': '移入回收站,7 天内可恢复。请输入标题确认:',
@@ -266,25 +244,7 @@ window.__ModuleLoader__.load({
266
244
  'button.title': 'Message ops (revert / delete / branch)',
267
245
  'dialog.title': 'Message ops',
268
246
  'dialog.cancel': 'Close',
269
- 'dialog.loading': 'Loading messages…',
270
- 'dialog.loadFail': 'Failed to load messages: ',
271
- 'dialog.empty': 'No operable messages in this session.',
272
- 'dialog.session': 'Session: ',
273
247
  'dialog.runningWarn': '⚠ Session is running: stop it before revert / delete / branch.',
274
- 'dialog.pick': 'Pick a message:',
275
- 'dialog.pickFirst': 'Step 1 · pick a message below, then choose an operation here.',
276
- 'dialog.pickedAs': 'Selected #{seq} · {text}',
277
- 'dialog.invisible': ' (shadowed, log-only)',
278
- 'dialog.showMore': 'Show more ({n} older)',
279
- 'dialog.more': '…(showing latest 200 of {n})',
280
- 'op.revert': 'Revert: remove this message and everything after',
281
- 'op.revertDesc':
282
- 'Shadows the picked message and all later visible content; the log stays append-only so context can be restored by re-sending.',
283
- 'op.delete': 'Delete only this message',
284
- 'op.deleteDesc': 'Shadows only the picked message; everything else stays.',
285
- 'op.branch': 'Fork into a new session from here',
286
- 'op.branchDesc':
287
- 'Copies the conversation above the picked message into a new session and puts this message back in the new composer (original untouched, non-destructive).',
288
248
  'slot.revert': 'Revert to here',
289
249
  'slot.revertPrivacyHint': 'Revert to here (not deletion: hidden from the AI, but the original text stays in the local session file)',
290
250
  'slot.revertUnmatched':
@@ -293,12 +253,16 @@ window.__ModuleLoader__.load({
293
253
  'slot.forkHint': 'Copies the conversation above this message into a new session and puts this message back in the new composer',
294
254
  'slot.forkDone': 'Branched: new session {id}',
295
255
  'slot.forkUnavailable': 'Branch unavailable: the session is running, or the host provides no session/fork',
296
- // 0.20.0: pencil edit overlay on the user-message action row (revert-then-send).
297
- 'slot.edit': 'Edit and resend',
298
- 'slot.editHint': 'Opens the editor; nothing is reverted until you press "Send and revert"',
256
+ // 0.24.0 (P3): renamed to disambiguate from the third-party message-edit plugin,
257
+ // which also says "Edit and resend" but forks a NEW branch and leaves the source
258
+ // session untouched. This one REVERTS the source session. Same words, opposite
259
+ // consequences — so the revert is now spelled out in the label itself.
260
+ 'slot.edit': 'Edit & revert-resend',
261
+ 'slot.editHint':
262
+ 'Opens the editor. Pressing "Send and revert" reverts this message and every visible message after it, then sends the edited text as a new message.',
299
263
  'slot.editNoText': 'This message has no text to edit',
300
264
  'slot.editUnmatched': 'Cannot locate this message seq in the log, so it cannot be edited yet',
301
- 'edit.title': 'Edit and resend',
265
+ 'edit.title': 'Edit & revert-resend',
302
266
  'edit.subtitle': 'This message · seq #{seq}',
303
267
  'edit.loading': 'Loading the original text…',
304
268
  'edit.loadFail': 'Could not load the original text: ',
@@ -319,17 +283,11 @@ window.__ModuleLoader__.load({
319
283
  'fork.official': 'Branched (official fork): new session {id}',
320
284
  'fork.unavailable':
321
285
  'Built-in branch unavailable — usually because the session is running. Stop it and retry. Branching is provided by the dsh built-in session/fork.',
322
- 'ack.revert': 'I understand: revert shadows the picked message and everything after it',
323
- 'ack.delete': 'I understand: this message will be shadowed (kept in the log)',
324
- 'confirm.revert': 'Revert',
325
- 'confirm.delete': 'Delete',
326
- 'confirm.branch': 'Branch',
327
- 'busy.revert': 'Reverting…',
328
- 'busy.delete': 'Deleting…',
329
- 'busy.branch': 'Branching…',
330
286
  'done.restore': 'Restored: replayed {n}, skipped non-replayable {s}',
331
- 'done.revert': 'Reverted (original text stays in the local session file and can be restored); reload to apply',
332
- 'done.delete': 'Deleted; reload to apply',
287
+ 'done.revert': 'Reverted — restore the original from the restore area',
288
+ 'done.revertNoRefill':
289
+ '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',
290
+ 'done.delete': 'Hidden; reload to apply',
333
291
  'action.reload': 'Reload page',
334
292
  errorPrefix: 'Operation failed: ',
335
293
  'dock.title': '{n} rolled back messages',
@@ -374,18 +332,16 @@ window.__ModuleLoader__.load({
374
332
  'panel.revertHint': 'Includes this message and all visible messages after it',
375
333
  'panel.revertConfirmTitle': 'Revert to #{seq}?',
376
334
  'panel.revertConfirmBody':
377
- 'This shadows {n} messages (#{start}–#{end}), including {v} visible. The log stays append-only and can be restored.',
378
- 'panel.revertPrivacyNote':
379
- '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.',
335
+ 'Shadows {n} messages (#{start}–#{end}, {v} visible). The AI will no longer see them, but the original text stays in the local session file and can be restored.',
380
336
  'panel.deleteConfirmTitle': 'Delete only #{seq}?',
381
337
  'panel.deleteConfirmBody': 'This shadows this one message; everything else stays. The log stays append-only and can be restored.',
382
338
  'panel.confirmRevert': 'Confirm revert',
383
- 'panel.confirmDeleteOne': 'Confirm delete',
339
+ 'panel.confirmDeleteOne': 'Confirm hide',
384
340
  'panel.retry': 'Retry',
385
341
  'panel.searching': 'Searching…',
386
342
  'panel.deleteSessionImpact': 'Total {n} messages; recoverable from trash for 7 days.',
387
343
  'panel.deleteUnavailable': 'Session details are not ready yet; deletion is disabled.',
388
- 'panel.delete': 'Delete only this',
344
+ 'panel.delete': 'Hide this',
389
345
  'panel.deleteHint': 'Shadows only this message',
390
346
  'panel.branch': 'Fork from here',
391
347
  'panel.branchHint': 'Copy the conversation above this message into a new session and put this message back in the new composer',
@@ -393,7 +349,7 @@ window.__ModuleLoader__.load({
393
349
  'panel.branchUserOnly': 'Fork works on user messages only (assistant messages have no text to hand back)',
394
350
  'panel.openNew': 'Open new session',
395
351
  'panel.revertDone': 'Revert applied',
396
- 'panel.deleteDone': 'Delete applied',
352
+ 'panel.deleteDone': 'Hidden',
397
353
  'panel.count': 'Total {n} · visible {v} · shadowed {s}',
398
354
  'panel.deleteSession': 'Delete whole session',
399
355
  'panel.deleteSessionHint': 'Moves it to trash for 7 days. Type the title to confirm:',
@@ -415,7 +371,61 @@ window.__ModuleLoader__.load({
415
371
 
416
372
  var __locale = null
417
373
  var __sessionsSvc = null
418
- var __inputActions = null // 0.4.0: 从 session 槽捕获(InputActions.setDraft → composer 回填)
374
+ /**
375
+ * 0.24.0 P4:InputActions **按会话隔离**。
376
+ *
377
+ * 为什么必须隔离:宿主 `conversation.chat.assistant-actions` 槽声明
378
+ * `scope: "session"`(dsh-client-ui-chat:9238),且 `inputActions` 由
379
+ * `inputHub.shellFor(binding).actions` 提供(dsh-client-ui-conversation:22713)。
380
+ * `shellFor` 按 binding 缓存**独立的 SessionInputShell**(:16145-16147),
381
+ * 每个会话的 `.actions` 是不同对象。
382
+ *
383
+ * 旧实现用模块级单变量 `__inputActions`,写入点是 per-session 组件:
384
+ * · MsgSlotActions —— 每条 AI 消息一个实例
385
+ * · RevertDock —— 每个会话一个实例
386
+ * 多会话同时挂载 / 切会话 / HMR 时会被**最后挂载的会话**覆盖,
387
+ * 于是回填、编辑框提交、dock 内联恢复都可能写进**别的会话的 composer**。
388
+ *
389
+ * 现在:`sessionId -> InputActions`。读写一律按会话取,
390
+ * 取不到就走**明确失败路径**,绝不静默退到别的会话。
391
+ */
392
+ var __inputActionsBySession = new Map()
393
+ // 兜底:仅用于**确实拿不到 sessionId** 的全局路径(如无 session 上下文的
394
+ // 工具调用)。任何能拿到 sessionId 的地方都必须用上面的 Map,
395
+ // 不允许读这个变量 —— 它是「最后一次已知」,可能属于另一个会话。
396
+ var __inputActions = null
397
+
398
+ /** 会话键归一:`session-x` 与 `x` 视为同一会话(宿主两种拼写都会传)。 */
399
+ function sessionKeyOf(sessionId) {
400
+ if (typeof sessionId !== 'string' || sessionId === '') return null
401
+ return sessionId.startsWith('session-') ? sessionId.slice('session-'.length) : sessionId
402
+ }
403
+
404
+ /**
405
+ * 按会话取 InputActions。
406
+ * @returns 该会话的 InputActions,或 null(调用方必须显式处理 null,不得回退到别的会话)
407
+ */
408
+ function inputActionsFor(sessionId) {
409
+ const key = sessionKeyOf(sessionId)
410
+ if (key == null) return null
411
+ return __inputActionsBySession.get(key) || null
412
+ }
413
+
414
+ /** 捕获:会话挂载时登记它自己的 InputActions。 */
415
+ function rememberInputActions(sessionId, inputActions) {
416
+ if (!inputActions || typeof inputActions.setDraft !== 'function') return
417
+ const key = sessionKeyOf(sessionId)
418
+ __inputActions = inputActions // 仅供无 sessionId 的全局兜底
419
+ if (key == null) return
420
+ __inputActionsBySession.set(key, inputActions)
421
+ }
422
+
423
+ /** 卸载:只在登记的仍是这一个实例时才删,避免把同会话新挂的实例删掉。 */
424
+ function forgetInputActions(sessionId, inputActions) {
425
+ const key = sessionKeyOf(sessionId)
426
+ if (key == null) return
427
+ if (__inputActionsBySession.get(key) === inputActions) __inputActionsBySession.delete(key)
428
+ }
419
429
  var __uiWorkspace = null
420
430
  var __currentSessionId = null
421
431
  // 0.9.1:视图重建后刷新 transcript 可见性的钩子。
@@ -479,92 +489,6 @@ window.__ModuleLoader__.load({
479
489
  cursor: 'pointer',
480
490
  flex: 'none',
481
491
  }
482
- const metaStyle = {
483
- color: 'var(--dsw-alias-label-secondary, #8a8a8e)',
484
- fontSize: 13,
485
- lineHeight: '20px',
486
- margin: '0 0 8px',
487
- overflow: 'hidden',
488
- textOverflow: 'ellipsis',
489
- }
490
- const warnStyle = {
491
- color: 'var(--dsw-alias-state-warn-primary, #f5a524)',
492
- fontSize: 13,
493
- lineHeight: '20px',
494
- margin: '0 0 10px',
495
- }
496
- const errStyle = {
497
- color: 'var(--dsw-alias-state-error-primary, #e5484d)',
498
- fontSize: 12,
499
- lineHeight: '16px',
500
- marginTop: 8,
501
- }
502
- const statusStyle = {
503
- color: 'var(--dsw-alias-label-secondary, #8a8a8e)',
504
- fontSize: 12,
505
- lineHeight: '16px',
506
- marginTop: 8,
507
- }
508
- const listStyle = {
509
- maxHeight: 260,
510
- overflowY: 'auto',
511
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.35))',
512
- borderRadius: 8,
513
- margin: '8px 0 4px',
514
- padding: '4px 0',
515
- }
516
- const rowStyle = {
517
- display: 'flex',
518
- alignItems: 'flex-start',
519
- gap: 8,
520
- padding: '4px 10px',
521
- fontSize: 13,
522
- lineHeight: '18px',
523
- cursor: 'pointer',
524
- }
525
- const descStyle = {
526
- color: 'var(--dsw-alias-label-secondary, #8a8a8e)',
527
- fontSize: 12,
528
- lineHeight: '17px',
529
- margin: '6px 0 0',
530
- }
531
- const cancelBtnStyle = {
532
- padding: '6px 14px',
533
- borderRadius: 8,
534
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.4))',
535
- background: 'transparent',
536
- color: 'var(--dsw-alias-label-primary, inherit)',
537
- fontSize: 13,
538
- cursor: 'pointer',
539
- marginRight: 8,
540
- }
541
- const primaryBtnStyle = {
542
- padding: '6px 14px',
543
- borderRadius: 8,
544
- border: 'none',
545
- background: 'var(--dsw-alias-brand-primary, #4d6bfe)',
546
- color: '#fff',
547
- fontSize: 13,
548
- cursor: 'pointer',
549
- }
550
- const dangerBtnStyle = {
551
- padding: '6px 14px',
552
- borderRadius: 8,
553
- border: '1px solid var(--dsw-alias-state-error-primary, #e5484d)',
554
- background: 'var(--dsw-alias-state-error-primary, #e5484d)',
555
- color: '#fff',
556
- fontSize: 13,
557
- cursor: 'pointer',
558
- }
559
- const optStyle = {
560
- display: 'flex',
561
- alignItems: 'center',
562
- gap: 8,
563
- fontSize: 13,
564
- lineHeight: '20px',
565
- color: 'var(--dsw-alias-label-primary, inherit)',
566
- marginTop: 10,
567
- }
568
492
 
569
493
  // 头部按钮图标:三叉分支(git-branch 风格,16x16)。
570
494
  // ⚠️ 这条 path 是按**描边**(stroke)设计的:圆点用 arc 画、连接线用
@@ -664,419 +588,6 @@ window.__ModuleLoader__.load({
664
588
  )
665
589
  }
666
590
 
667
- // --- 共享对话框 -------------------------------------------------------------
668
- // 模块级缓存最近一次 target,事件驱动打开。
669
- const MAX_RENDER = 200
670
- const PAGE_SIZE = 50 // 低成本分批渲染:先渲 50 条,按钮渐进展开
671
-
672
- function OpsDialog(props) {
673
- const t = (props && props.t) || __t
674
- useLocaleRevision()
675
- const [target, setTarget] = useState(null) // {sessionId, title, running}
676
- const [state, setState] = useState('idle') // idle|loading|ready|busy|done
677
- const [messages, setMessages] = useState([])
678
- const [sessionMeta, setSessionMeta] = useState(null)
679
- const [picked, setPicked] = useState(null) // seq
680
- const [mode, setMode] = useState(null) // revert|delete|branch|restore
681
- const [childId, setChildId] = useState(null) // 官方 fork 成功后的子会话 id
682
- const [acknowledged, setAcknowledged] = useState(false)
683
- const [busyMsg, setBusyMsg] = useState('')
684
- const [renderLimit, setRenderLimit] = useState(PAGE_SIZE) // 已展开的渲染条数
685
- const [doneMsg, setDoneMsg] = useState('')
686
- const [error, setError] = useState(null)
687
-
688
- useEffect(() => {
689
- const handler = e => {
690
- const d = e && e.detail ? e.detail : {}
691
- setTarget({ sessionId: d.sessionId || null, title: d.title || null, running: d.running === true })
692
- setState('loading')
693
- setMessages([])
694
- setSessionMeta(null)
695
- // 槽按钮预置:携带 seq(picked)与 mode 直接进入确认态
696
- setPicked(typeof d.seq === 'number' ? d.seq : null)
697
- setMode(typeof d.mode === 'string' ? d.mode : null)
698
- setAcknowledged(false)
699
- setError(null)
700
- setDoneMsg('')
701
- setRenderLimit(PAGE_SIZE)
702
- }
703
- window.addEventListener(EVENT, handler)
704
- return () => window.removeEventListener(EVENT, handler)
705
- }, [])
706
-
707
- useEffect(() => {
708
- if (state !== 'loading' || !target || !target.sessionId) return
709
- let cancelled = false
710
- fetchMessagesJson('/api/message-ops/messages?sessionId=' + encodeURIComponent(target.sessionId))
711
- .then(data => {
712
- if (cancelled) return
713
- if (!data || !data.ok) throw new Error(data && data.error ? data.error : `HTTP ${data && data.status}`)
714
- setMessages(data.messages || [])
715
- setSessionMeta(data.session || null)
716
- if (data.running === true) setTarget(prev => ({ ...(prev || {}), running: true }))
717
- setState('ready')
718
- })
719
- .catch(reason => {
720
- if (cancelled) return
721
- setError(t('dialog.loadFail') + (reason && reason.message ? reason.message : String(reason)))
722
- setState('ready')
723
- })
724
- return () => {
725
- cancelled = true
726
- }
727
- }, [state, target, t])
728
-
729
- const close = useCallback(() => {
730
- if (state === 'busy') return
731
- setTarget(null)
732
- setError(null)
733
- }, [state])
734
-
735
- const pick = useCallback(
736
- m => {
737
- if (state === 'busy') return
738
- setPicked(m.seq)
739
- setMode(null)
740
- setAcknowledged(false)
741
- setError(null)
742
- },
743
- [state],
744
- )
745
-
746
- const chooseMode = useCallback(
747
- m => {
748
- if (picked == null || state === 'busy') return
749
- setMode(m)
750
- setAcknowledged(false)
751
- setError(null)
752
- },
753
- [picked, state],
754
- )
755
-
756
- const run = useCallback(() => {
757
- if (state === 'busy' || picked == null || !mode) return
758
- if (mode !== 'branch' && !acknowledged) return
759
- setBusyMsg(t('busy.' + (mode === 'revert' || mode === 'delete' ? mode : 'branch')))
760
- setState('busy')
761
- setError(null)
762
- if (mode === 'branch') {
763
- // 0.12.0:与面板/消息行同一实现 —— opencode 的 before 语义
764
- // (新会话不含此条,原文回新会话输入框)。只对用户消息成立;
765
- // 分支不再回落写盘(被删的磁盘 applyBranch 语义复盘见 README)。
766
- const pickedRow = picked != null ? messages.find(m => m.seq === picked) : null
767
- if (!pickedRow || pickedRow.role !== 'user') {
768
- setError(t('panel.branchUserOnly'))
769
- setBusyMsg('')
770
- setState('error')
771
- return
772
- }
773
- Promise.resolve()
774
- .then(() =>
775
- forkFromUserMessage(target.sessionId, picked, pickedRow.fullText || pickedRow.snippet || '', pickedRow.turnStartSeq),
776
- )
777
- .then(childId => {
778
- setDoneMsg(t('fork.official', { id: String(childId || '') }))
779
- setBusyMsg('')
780
- setChildId(childId || null)
781
- setState('done')
782
- notifyDone(t('fork.official', { id: String(childId || '') }))
783
- })
784
- .catch(reason => {
785
- setError(String((reason && reason.message) || reason || t('fork.unavailable')))
786
- setBusyMsg('')
787
- setState('error')
788
- })
789
- return
790
- }
791
- const path = mode
792
- const body = { sessionId: target.sessionId, seq: picked }
793
- Promise.resolve()
794
- .then(() =>
795
- fetch('/api/message-ops/' + path, {
796
- method: 'POST',
797
- headers: { 'content-type': 'application/json' },
798
- body: JSON.stringify(body),
799
- }),
800
- )
801
- .then(async res => {
802
- let data = {}
803
- try {
804
- data = await res.json()
805
- } catch {
806
- /* keep {} */
807
- }
808
- if (!res.ok || !data.ok) throw new Error(data.error || `HTTP ${res.status}`)
809
- // S6 修复(G-M1):不再 900ms 裸 location.reload。成功走 devkit
810
- // 标准 toast(无 devkit 时降级为对话框内 doneMsg),并提供手动
811
- // 「刷新页面」按钮。
812
- // 0.9.7:补回 ec862d6(0.9.0) 误删的 `const okMsg =`——留下悬挂的
813
- // `? :` 会让成功路径抛 ReferenceError 落进 .catch(用户看到「操作失败」,
814
- // notifyDone/emitChanged/openSession/回填全不执行),失败路径则恒走
815
- // `?` 分支把成功文案当错误抛出。对话框 mode 只有 revert|delete|branch,
816
- // branch 在上面已 return,故 done.restore 分支在此不可达,一并删掉。
817
- const okMsg = mode === 'revert' ? t('done.revert') : t('done.delete')
818
- // 0.19.0:回填统一由 refillComposer 承担;老 setDraft 路径已删(见 spec §9)。
819
- setDoneMsg(okMsg)
820
- setBusyMsg('')
821
- setState('done')
822
- notifyDone(okMsg)
823
- emitChanged()
824
- // 0.5.7:store-miss 的磁盘追加没有 live 投影事件 —— 成功后强制
825
- // 重建视图(与 restoreRow 同款 openSession 模式),遮蔽即刻可见。
826
- try {
827
- if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(target.sessionId)
828
- } catch {
829
- /* 视图重建失败不阻断成功反馈 */
830
- }
831
- })
832
- .catch(reason => {
833
- setBusyMsg('')
834
- setState('ready')
835
- setError(t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)))
836
- })
837
- }, [state, picked, mode, acknowledged, target, t])
838
-
839
- if (!target) return null
840
-
841
- // 0.6.0:system prompt 行不可作为回滚/删除/分支目标(引擎拒之以 node0 守卫,
842
- // 但不该给用户一个必然500的选项)——列表直接排除 role=system。
843
- const visible = messages.filter(m => m.visible !== false && m.role !== 'system')
844
- const shownBase = visible.slice(-MAX_RENDER)
845
- const hiddenCount = visible.length - shownBase.length
846
- // 分批渲染(评审 M1):只渲染 renderLimit 条,更早的留给「显示更多」
847
- // 渐进展开,避免 200 行 radio 列表一次进 DOM。
848
- const shown = shownBase.slice(-renderLimit)
849
- const pagedCount = shownBase.length - shown.length
850
- const pickedMsg = picked != null ? messages.find(m => m.seq === picked) : null
851
-
852
- // 0.9.0 可发现性:操作区固定在**消息列表之前**。
853
- // 原先它在列表之后,而列表是 260px 滚动 + 分批渲染 50 条/页 ——
854
- // 未选中消息时三个 radio 完全不在视野内,用户以为「只有列表、没有操作」。
855
- // 未选中时给明确指引,而不是空着。
856
- const opsPanel = pickedMsg
857
- ? React.createElement(
858
- 'div',
859
- { key: 'ops', style: { margin: '8px 0 0' } },
860
- React.createElement(
861
- 'div',
862
- { style: { ...metaStyle, margin: '0 0 4px' } },
863
- t('dialog.pickedAs', { seq: String(pickedMsg.seq), text: (pickedMsg.snippet || '').slice(0, 60) }),
864
- ),
865
- ['revert', 'delete', 'branch'].map((m, i) =>
866
- React.createElement(
867
- 'div',
868
- { key: m, style: { marginTop: i === 0 ? 6 : 4 } },
869
- React.createElement(
870
- 'label',
871
- { style: optStyle },
872
- React.createElement('input', {
873
- type: 'radio',
874
- name: 'dsh-message-ops-mode',
875
- checked: mode === m,
876
- onChange: () => chooseMode(m),
877
- disabled: state === 'busy',
878
- }),
879
- t('op.' + m),
880
- ),
881
- mode === m ? React.createElement('div', { style: descStyle }, t('op.' + m + 'Desc')) : null,
882
- ),
883
- ),
884
- mode && mode !== 'branch'
885
- ? React.createElement(
886
- 'label',
887
- { key: 'ack', style: optStyle },
888
- React.createElement('input', {
889
- type: 'checkbox',
890
- checked: acknowledged,
891
- disabled: state === 'busy',
892
- onChange: e => setAcknowledged(e.target.checked),
893
- }),
894
- t(mode === 'revert' ? 'ack.revert' : 'ack.delete'),
895
- )
896
- : null,
897
- )
898
- : React.createElement(
899
- 'div',
900
- {
901
- key: 'opshint',
902
- style: {
903
- ...metaStyle,
904
- margin: '8px 0 0',
905
- padding: '6px 8px',
906
- borderRadius: 6,
907
- background: 'var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.1))',
908
- },
909
- },
910
- t('dialog.pickFirst'),
911
- )
912
-
913
- let body
914
- if (state === 'loading') {
915
- body = React.createElement('div', { key: 'load', style: statusStyle }, t('dialog.loading'))
916
- } else if (!messages.length) {
917
- body = React.createElement('div', { key: 'empty', style: statusStyle }, t('dialog.empty'))
918
- } else {
919
- body = React.createElement(React.Fragment, null, [
920
- target.running ? React.createElement('div', { key: 'warn', style: warnStyle }, t('dialog.runningWarn')) : null,
921
- opsPanel,
922
- React.createElement('div', { key: 'pick', style: metaStyle }, t('dialog.pick')),
923
- React.createElement(
924
- 'div',
925
- { key: 'list', style: listStyle },
926
- hiddenCount > 0
927
- ? React.createElement(
928
- 'div',
929
- { key: 'more', style: { ...rowStyle, cursor: 'default', color: 'var(--dsw-alias-label-secondary,#8a8a8e)' } },
930
- t('dialog.more', { n: String(visible.length) }),
931
- )
932
- : null,
933
- pagedCount > 0
934
- ? React.createElement(
935
- 'button',
936
- {
937
- key: 'show-more',
938
- type: 'button',
939
- style: {
940
- ...rowStyle,
941
- border: 'none',
942
- width: '100%',
943
- color: 'var(--dsw-alias-label-secondary,#8a8a8e)',
944
- cursor: 'pointer',
945
- },
946
- onClick: () => setRenderLimit(l => Math.min(l + PAGE_SIZE, MAX_RENDER)),
947
- },
948
- t('dialog.showMore', { n: String(pagedCount) }),
949
- )
950
- : null,
951
- shown.map((m, i) =>
952
- React.createElement(
953
- 'label',
954
- {
955
- key: m.seq + '-' + i,
956
- style: {
957
- ...rowStyle,
958
- background: picked === m.seq ? 'var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.14))' : 'transparent',
959
- },
960
- },
961
- React.createElement('input', {
962
- type: 'radio',
963
- name: 'dsh-message-ops-pick',
964
- checked: picked === m.seq,
965
- onChange: () => pick(m),
966
- disabled: state === 'busy',
967
- }),
968
- React.createElement(
969
- 'span',
970
- {
971
- style: {
972
- flex: 1,
973
- minWidth: 0,
974
- overflow: 'hidden',
975
- textOverflow: 'ellipsis',
976
- whiteSpace: 'nowrap',
977
- color: m.visible === false ? 'var(--dsw-alias-label-tertiary,#b0b0b4)' : 'inherit',
978
- },
979
- },
980
- '#' + m.seq + ' ' + (m.role || '') + ' · ' + (m.snippet || '') + (m.visible === false ? t('dialog.invisible') : ''),
981
- ),
982
- ),
983
- ),
984
- ),
985
- // 0.9.7:删掉列表**之后**的旧 opsPanel——0.9.0 把操作区挪到列表之前时
986
- // 没删旧位置,两组同名 radio(name='dsh-message-ops-mode')互抢,
987
- // checked 状态在两份 DOM 之间互相顶掉。
988
- ])
989
- }
990
-
991
- const canRun = state !== 'busy' && state !== 'loading' && picked != null && mode != null && (mode === 'branch' || acknowledged)
992
- const confirmLabel = busyMsg || (mode ? t('confirm.' + mode) : t('dialog.cancel'))
993
-
994
- return React.createElement(
995
- Modal,
996
- {
997
- open: true,
998
- onClose: close,
999
- title: t('dialog.title'),
1000
- closeLabel: t('dialog.cancel'),
1001
- description: t('dialog.session') + (target.title || target.sessionId || ''),
1002
- footer: [
1003
- React.createElement(
1004
- 'button',
1005
- {
1006
- key: 'cancel',
1007
- type: 'button',
1008
- disabled: state === 'busy',
1009
- onClick: close,
1010
- style: { ...cancelBtnStyle, ...(state === 'busy' ? { opacity: 0.5, cursor: 'default' } : {}) },
1011
- },
1012
- t('dialog.cancel'),
1013
- ),
1014
- React.createElement(
1015
- 'button',
1016
- {
1017
- key: 'confirm',
1018
- type: 'button',
1019
- disabled: !canRun,
1020
- onClick: run,
1021
- style: {
1022
- ...(mode === 'delete' || mode === 'revert' ? dangerBtnStyle : primaryBtnStyle),
1023
- ...(!canRun ? { opacity: 0.5, cursor: 'default' } : {}),
1024
- },
1025
- },
1026
- confirmLabel,
1027
- ),
1028
- ...(state === 'done' && (mode === 'revert' || mode === 'delete')
1029
- ? [
1030
- React.createElement(
1031
- 'button',
1032
- {
1033
- key: 'reload',
1034
- type: 'button',
1035
- onClick: () => {
1036
- try {
1037
- window.location.reload()
1038
- } catch {
1039
- /* non-browser guard */
1040
- }
1041
- },
1042
- style: primaryBtnStyle,
1043
- },
1044
- t('action.reload'),
1045
- ),
1046
- ]
1047
- : []),
1048
- ...(state === 'done' && mode === 'branch' && childId
1049
- ? [
1050
- React.createElement(
1051
- 'button',
1052
- {
1053
- key: 'open-new',
1054
- type: 'button',
1055
- onClick: () => {
1056
- try {
1057
- // 0.2.0+:uiWorkspace.openSession 是宿主唯一打开通道
1058
- if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(childId)
1059
- } catch {
1060
- /* 打开失败不阻断 */
1061
- }
1062
- },
1063
- style: primaryBtnStyle,
1064
- },
1065
- t('toast.openNew'),
1066
- ),
1067
- ]
1068
- : []),
1069
- ],
1070
- },
1071
- [
1072
- React.createElement('div', { key: 'meta', style: metaStyle }, t('dialog.session'), target.sessionId || ''),
1073
- body,
1074
- doneMsg ? React.createElement('div', { key: 'done', style: statusStyle }, doneMsg) : null,
1075
- error ? React.createElement('div', { key: 'err', style: errStyle, role: 'alert' }, error) : null,
1076
- ],
1077
- )
1078
- }
1079
-
1080
591
  // --- A · 功能主义抽屉 -------------------------------------------------------
1081
592
 
1082
593
  const PANEL_ROW_H = 46
@@ -2258,11 +1769,6 @@ window.__ModuleLoader__.load({
2258
1769
  })
2259
1770
  : t('panel.deleteConfirmBody'),
2260
1771
  ),
2261
- // 0.21.0:revert 的常显隐私告知(零副作用、纯文案)。
2262
- // 只在回滚确认态出现;删除确认不需要(删单条同样遮蔽,但语义不同)。
2263
- confirmAction === 'revert'
2264
- ? React.createElement('div', { className: 'mopsPrivacyNote', role: 'note' }, t('panel.revertPrivacyNote'))
2265
- : null,
2266
1772
  React.createElement(
2267
1773
  'div',
2268
1774
  { className: 'mopsConfirmRow' },
@@ -2494,24 +2000,32 @@ window.__ModuleLoader__.load({
2494
2000
  /**
2495
2001
  * 有界等待 composer 重挂后提交**一次**。
2496
2002
  *
2497
- * 判据:`__inputActions` 换成新对象 = 宿主重挂了编辑器(openSession 之后必然发生)。
2003
+ * 判据:该会话的 InputActions 换成新对象 = 宿主重挂了编辑器(openSession 之后必然发生)。
2498
2004
  * 到上限仍没换(例如视图没重建的内联路径)就用当前这个提交一次 —— 宁可多一条
2499
2005
  * 兜底提示,也不要无限等。**只提交一次**:重复 submit 会发出两条消息,比失败更糟。
2500
2006
  *
2501
2007
  * @param text - 要提交的文本
2502
- * @param options - { attempts, intervalMs },测试注入更小值
2008
+ * @param options - { attempts, intervalMs, sessionId },测试注入更小值
2503
2009
  * @returns Promise<boolean> 是否成功调用了宿主 submit
2504
2010
  */
2505
2011
  function submitEditedText(text, options) {
2506
2012
  const opts = options || {}
2507
2013
  const attempts = Number.isSafeInteger(opts.attempts) && opts.attempts > 0 ? opts.attempts : EDIT_SUBMIT_ATTEMPTS
2508
2014
  const intervalMs = Number.isSafeInteger(opts.intervalMs) && opts.intervalMs >= 0 ? opts.intervalMs : EDIT_SUBMIT_INTERVAL_MS
2509
- const before = __inputActions
2015
+ // 0.24.0 P4:按会话读 InputActions。opts.getInputActions 保留给真执行测试注入。
2016
+ //
2017
+ // ⚠️ 判据语义变化:旧实现用「对象变了」= 宿主重挂编辑器。改成按会话隔离后,
2018
+ // 对象变化只说明**这一会话**的 shell 换了实例(重挂),跨会话不会误触发,
2019
+ // 比旧判据更准。读不到该会话的 InputActions 时**不提交** ——
2020
+ // 宁可让调用方提示手动回车,也不能拿别的会话的 submit 发出去。
2021
+ const targetSessionId = opts.sessionId
2022
+ const readInputActions = typeof opts.getInputActions === 'function' ? opts.getInputActions : () => inputActionsFor(targetSessionId)
2023
+ const before = readInputActions()
2510
2024
  return new Promise(resolve => {
2511
2025
  let n = 0
2512
2026
  const tick = () => {
2513
2027
  n += 1
2514
- const ia = __inputActions
2028
+ const ia = readInputActions()
2515
2029
  const usable = ia && typeof ia.submit === 'function' && typeof ia.setDraft === 'function'
2516
2030
  const remounted = !!ia && ia !== before
2517
2031
  if (usable && (remounted || n >= attempts)) {
@@ -2596,12 +2110,25 @@ window.__ModuleLoader__.load({
2596
2110
  const doWrite = deps.writeSessionDraft || writeSessionDraft
2597
2111
  const doRead = deps.readSessionDraft || readSessionDraft
2598
2112
  const markShadowed = deps.markRowsShadowedFrom || markRowsShadowedFrom
2599
- const doSetDraft = deps.setDraft || (v => (__inputActions && __inputActions.setDraft ? __inputActions.setDraft(v) : false))
2113
+ const doSetDraft =
2114
+ deps.setDraft ||
2115
+ (v => {
2116
+ // 0.24.0 P4:必须按会话取,取不到就明确失败(返回 false),
2117
+ // 绝不静默退到 __inputActions —— 那可能是别的会话的 composer。
2118
+ const ia = inputActionsFor(rawSessionId)
2119
+ if (!ia || typeof ia.setDraft !== 'function') return false
2120
+ return ia.setDraft(v)
2121
+ })
2600
2122
  const doPersistDraft =
2601
- deps.persistDraft || (() => (__inputActions && __inputActions.persistDraft ? __inputActions.persistDraft() : false))
2123
+ deps.persistDraft ||
2124
+ (() => {
2125
+ const ia = inputActionsFor(rawSessionId)
2126
+ if (!ia || typeof ia.persistDraft !== 'function') return false
2127
+ return ia.persistDraft()
2128
+ })
2602
2129
  const doEmitChanged = deps.emitChanged || emitChanged
2603
2130
  const doOpenSession = deps.openSessionById || openSessionById
2604
- const doSubmit = deps.submitEdited || submitEditedText
2131
+ const doSubmit = deps.submitEdited || (t => submitEditedText(t, { sessionId: rawSessionId }))
2605
2132
 
2606
2133
  // ② 防 409 护栏:本地缓存里 >= seq 的行立刻标成已遮蔽(与 runUserRevert/runUndo 同一函数)
2607
2134
  try {
@@ -2997,56 +2524,6 @@ window.__ModuleLoader__.load({
2997
2524
  return Number.isSafeInteger(seq) && seq > 0 ? seq - 1 : -1
2998
2525
  }
2999
2526
 
3000
- /**
3001
- * 官方 assistant turn-tail 的 branch 按钮识别(0.12.0)。
3002
- *
3003
- * 为什么不能靠 aria-label:官方文案有 8 种语言(zh/en/ja/es/fr/de/ru/pt),
3004
- * 逐个匹配等于把 i18n 表抄进来。也不能靠 class:CSS Modules 会哈希前缀
3005
- * (实测 0.2.0-rc.2 是 `xzv4MW_`,0.2.1 起变过)。
3006
- *
3007
- * ⚠️ 也不能靠 `<path d="…">`(0.12.0 的错误做法,0.13.1 修):0.2.2-alpha.2 的
3008
- * 图标已改为 **sprite 复用**,官方组件长这样(见已安装 app bundle 的工厂函数):
3009
- *
3010
- * <svg data-icon="dsw-icon-branch-outline-regular" aria-hidden="true">
3011
- * <use href="#dsw-icon-branch-outline-regular"/>
3012
- * </svg>
3013
- *
3014
- * DOM 里**根本没有 `<path>`**,`M13.0762…` 在整个已安装 dsh 里 0 次命中。
3015
- * 唯一稳定的是 `data-icon` 的 id:`dsw-icon-${name}-${size}`(工厂 `Qv`),
3016
- * name 来自 ui-primitives 的图标表,属契约级常量。
3017
- *
3018
- * 我们自己的分叉按钮也故意用同一图标,所以必须按 class 显式排除。
3019
- *
3020
- * @param btn - 候选按钮(任意元素;非 button 的宿主节点返回 false)
3021
- * @returns 是否官方 branch 按钮
3022
- */
3023
- const HOST_BRANCH_ICON_ID = 'dsw-icon-branch-outline-regular'
3024
- const HOST_BRANCH_CLASS = 'mopsUserFork'
3025
- function isHostBranchButton(btn) {
3026
- if (!btn || typeof btn.querySelector !== 'function') return false
3027
- const cls = String((btn.classList && btn.classList.value) || btn.className || '')
3028
- if (cls.split(/\s+/).includes(HOST_BRANCH_CLASS)) return false
3029
- // 首选 sprite 形态:<svg data-icon="dsw-icon-branch-outline-regular">
3030
- const svg = btn.querySelector('svg')
3031
- if (svg && svg.getAttribute('data-icon') === HOST_BRANCH_ICON_ID) return true
3032
- // 兼容旧宿主的内联 path 形态(0.2.0-rc.x):仍接受官方几何前缀
3033
- const path = btn.querySelector('svg path')
3034
- const d = path ? path.getAttribute('d') || '' : ''
3035
- return d.startsWith(HOST_BRANCH_D_PREFIX)
3036
- }
3037
-
3038
- /** 旧宿主的内联 path 几何前缀(仅作兼容回退,不是主判据)。 */
3039
- const HOST_BRANCH_D_PREFIX = 'M13.0762 1.37207'
3040
-
3041
- /**
3042
- * 把文本预置成某个会话的草稿(新会话刚 fork 出来时输入框是空的)。
3043
- *
3044
- * 为什么直接写 localStorage 而不是 `inputActions.setDraft`:fork 出来的是一个**还没
3045
- * 挂载**的会话,此刻 `inputActions` 仍绑定在源会话上;宿主挂载新会话时会用
3046
- * `readConversationDraft(sessionId)` 从 localStorage 初始化编辑器。所以**先落盘再
3047
- * openSession** 才是无竞态的路径(`{ draft: '<text>' }` 是宿主 `parseStoredDraft`
3048
- * 支持的字符串形态,见 dsh-client-ui-conversation:4455-4456)。
3049
- */
3050
2527
  function writeSessionDraft(childSessionId, text) {
3051
2528
  try {
3052
2529
  if (!childSessionId || typeof localStorage === 'undefined') return false
@@ -3198,7 +2675,11 @@ window.__ModuleLoader__.load({
3198
2675
  const { messageId, sessionId, useSessions, inputActions, useChat } = props
3199
2676
  const t = (props && props.t) || __t
3200
2677
  useLocaleRevision()
3201
- if (inputActions && typeof inputActions.setDraft === 'function') __inputActions = inputActions
2678
+ // 0.24.0 P4:按会话登记(本组件每条 AI 消息一个实例,必须带 sessionId 隔离)。
2679
+ React.useEffect(() => {
2680
+ rememberInputActions(sessionId, inputActions)
2681
+ return () => forgetInputActions(sessionId, inputActions)
2682
+ }, [sessionId, inputActions])
3202
2683
  const sessions = useSessions ? useSessions(s => s) : undefined
3203
2684
  const summary = sessions && sessions.byId ? sessions.byId[sessionId] : undefined
3204
2685
  const running = summary ? summary.running === true : false
@@ -3463,9 +2944,24 @@ window.__ModuleLoader__.load({
3463
2944
  },
3464
2945
  icon,
3465
2946
  )
3466
- // 0.19.0(spec §9):AI 消息动作区只留「引用」。
3467
- // 原时钟图标 = runRevert(回滚到此条),与用户消息回撤重复,用户要求删除。
3468
- return act(React.createElement(IconQuote, { size: 16 }), t('slot.quote'), 'quote', runQuote, false)
2947
+ // 0.23.0:AI 消息动作区**不再注入任何按钮**。
2948
+ //
2949
+ // 用户反馈:「引用不要每次把一整个上下文重新全部塞给 AI」。核查结论:
2950
+ // · 宿主自带完整划词引用 —— dsh-message-quotes/lib/client.js:48 调
2951
+ // inputActions.insertQuote(text),注册在 conversation.chat.text-interaction
2952
+ // 槽,只在用户选中文字(textInteraction.active !== null)时渲染,
2953
+ // 「选中多少引多少」,从不引整条。
2954
+ // · 我们旧按钮用 [data-chat-node-key] 判选区,与宿主的
2955
+ // [data-text-interaction-source] 体系不匹配 → 高频判不出选区 →
2956
+ // 退化成 clipQuote(fullText) 把 600 字塞进 composer。
2957
+ // · 而 deriveMessages() 本就遍历 surface.nodes 给出完整历史,
2958
+ // 引用当前会话里未被遮蔽的消息 = 同一内容在 prompt 里出现两遍,纯冗余。
2959
+ // 所以正确做法是让位给宿主,不再重复造轮子。
2960
+ //
2961
+ // ⚠️ 本组件**必须保留**:它负责按会话捕获 inputActions 到
2962
+ // __inputActionsBySession(编辑框 / 面板 / 行内回填都依赖),
2963
+ // 删组件会让这些功能静默失效。只 return null,不删注册。
2964
+ return null
3469
2965
  }
3470
2966
 
3471
2967
  // 0.4.2 引入(恢复的标记自动离开活跃列表 = opencode clear 语义)。
@@ -3525,7 +3021,11 @@ window.__ModuleLoader__.load({
3525
3021
  if (sessionId) __currentSessionId = sessionId
3526
3022
  const t = (props && props.t) || __t
3527
3023
  useLocaleRevision()
3528
- if (inputActions && typeof inputActions.setDraft === 'function') __inputActions = inputActions
3024
+ // 0.24.0 P4:dock 也是 per-session 实例,登记时必须带 sessionId。
3025
+ React.useEffect(() => {
3026
+ rememberInputActions(sessionId, inputActions)
3027
+ return () => forgetInputActions(sessionId, inputActions)
3028
+ }, [sessionId, inputActions])
3529
3029
  const sessions = useSessions ? useSessions(s => s) : undefined
3530
3030
  const summary = sessions && sessions.byId ? sessions.byId[sessionId] : undefined
3531
3031
  const running = summary ? summary.running === true : false
@@ -3608,8 +3108,12 @@ window.__ModuleLoader__.load({
3608
3108
  // 0.5.2(P2):标题口径 = 标记 range 内 visible=false 的去重 seq 数
3609
3109
  const seen = new Set()
3610
3110
  for (const mk of act) {
3611
- const start = mk.range && typeof mk.range.start === 'number' ? mk.range.start : mk.seq
3612
- const end = mk.range && typeof mk.range.end === 'number' ? mk.range.end : start
3111
+ // 0.23.0(深挖 S-2):服务端 buildDerived 用 readReplaceOp 把 range
3112
+ // 覆盖成 {startSeq,endSeq},而旧代码只读 {start,end} → 计数恒为 0。
3113
+ // 两种形状都兼容,并防御旧缓存里仍是 {start,end} 的情况。
3114
+ const rng = mk.range || {}
3115
+ const start = Number.isSafeInteger(rng.startSeq) ? rng.startSeq : Number.isSafeInteger(rng.start) ? rng.start : mk.seq
3116
+ const end = Number.isSafeInteger(rng.endSeq) ? rng.endSeq : Number.isSafeInteger(rng.end) ? rng.end : start
3613
3117
  for (const m of msgs) {
3614
3118
  if (m && m.visible === false && typeof m.seq === 'number' && m.seq >= start && m.seq <= end) seen.add(m.seq)
3615
3119
  }
@@ -4162,11 +3666,7 @@ window.__ModuleLoader__.load({
4162
3666
  // 0.18.0/0.20.0:三种按钮各有自己的提示文案(编辑按钮不能写 revert 的 hint)
4163
3667
  // 0.21.0:回滚按钮统一用「带隐私提示」的 title —— syncEnabled 会在
4164
3668
  // 注入后重设 title,若这里仍用 slot.revert 会覆盖掉 ensureBtn 里的隐私提示。
4165
- const hintKey = btn.classList.contains('mopsUserFork')
4166
- ? 'slot.forkHint'
4167
- : btn.classList.contains('mopsUserEdit')
4168
- ? 'slot.editHint'
4169
- : 'slot.revertPrivacyHint'
3669
+ const hintKey = btn.classList.contains('mopsUserEdit') ? 'slot.editHint' : 'slot.revertPrivacyHint'
4170
3670
  const ok = block.getAttribute('data-mops-seq')
4171
3671
  if (ok) {
4172
3672
  btn.disabled = false
@@ -4181,7 +3681,7 @@ window.__ModuleLoader__.load({
4181
3681
  /** 块内全部插件按钮一起同步(回滚 / 编辑 / 分叉同一动作行)。 */
4182
3682
  var syncBlockButtons = block => {
4183
3683
  if (!block || !block.querySelectorAll) return
4184
- for (const b of block.querySelectorAll('.mopsUserRevert, .mopsUserEdit, .mopsUserFork')) syncEnabled(block, b)
3684
+ for (const b of block.querySelectorAll('.mopsUserRevert, .mopsUserEdit')) syncEnabled(block, b)
4185
3685
  }
4186
3686
  var assignSeqs = (sid, cache, anchors) => {
4187
3687
  const idx = cache && cache.idx
@@ -4281,12 +3781,15 @@ window.__ModuleLoader__.load({
4281
3781
  /* keep {} */
4282
3782
  }
4283
3783
  if (!res.ok || !data.ok) throw new Error(data.error || 'HTTP ' + res.status)
4284
- notifyDone(__t('done.revert'))
3784
+ // 0.23.0(深挖):先回填再报成功,回填失败要让用户知道。
3785
+ // 旧实现先 notifyDone(done.revert) 再 refillComposer 且丢弃返回值 →
3786
+ // 用户看到「已回滚」却拿到空输入框(0.14.0 踩过的同一类静默失败)。
4285
3787
  // 0.17.0(冲突 C2):按钮路径原先漏了「立刻标遮蔽」,
4286
3788
  // 导致刷新窗口内重复点击会拿已遮蔽的 seq 去 POST → 409。
4287
3789
  markRowsShadowedFrom(row.seq)
4288
- // 0.9.6:统一回填出口 —— 这个入口原先也不回填
4289
- refillComposer(sid, row.seq)
3790
+ const filled = refillComposer(sid, row.seq)
3791
+ if (filled) notifyDone(__t('done.revert'))
3792
+ else notifyDone(__t('done.revertNoRefill'), 'warn')
4290
3793
  emitChanged()
4291
3794
  try {
4292
3795
  if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(sid)
@@ -4309,119 +3812,6 @@ window.__ModuleLoader__.load({
4309
3812
  })
4310
3813
  })
4311
3814
  }
4312
- /**
4313
- * 0.12.0 用户消息「从此条分叉」:非破坏操作,源会话一字不动。
4314
- *
4315
- * opencode 语义 = 复制此条**之前**的对话到一个新会话,并把此条原文放回
4316
- * 新会话的输入框,让用户改完再发。因此这里要三步:
4317
- * 1. 解析 seq(点击当下可能还没打标 → 先 ensureAssign 再 fetchRows)
4318
- * 2. 取该条用户消息的**原文**(列表只携带 snippet,长度会被截断)
4319
- * 3. fork(boundary = seq - 1) → 把原文写进子会话草稿 → 打开子会话
4320
- */
4321
- var runUserFork = (btn, block) => {
4322
- const sid = __currentSessionId
4323
- if (!sid) return
4324
- btn.disabled = true
4325
- Promise.resolve()
4326
- .then(() => ensureAssign(sid))
4327
- .then(() => fetchRows(sid))
4328
- .then(async cache => {
4329
- const rows = cache && cache.rows
4330
- const seq = Number(block.getAttribute('data-mops-seq'))
4331
- const row = rows && rows.find(r => r.seq === seq)
4332
- if (!row) {
4333
- notifyDone(__t('errorPrefix') + __t('slot.revertUnmatched'), 'error')
4334
- return
4335
- }
4336
- if (!(seq > 0)) {
4337
- notifyDone(__t('slot.forkUnavailable'), 'warn')
4338
- return
4339
- }
4340
- let text = typeof row.fullText === 'string' ? row.fullText : ''
4341
- if (!text) {
4342
- try {
4343
- const res = await fetch(
4344
- '/api/message-ops/text?sessionId=' + encodeURIComponent(bareSessionId(sid)) + '&seq=' + encodeURIComponent(seq),
4345
- )
4346
- const data = res.ok ? await res.json().catch(() => null) : null
4347
- if (data && data.ok && typeof data.text === 'string') text = data.text
4348
- } catch {
4349
- /* 取全文失败:分叉照做,只是输入框留空 */
4350
- }
4351
- }
4352
- const childId = await forkFromUserMessage(sid, seq, text, row.turnStartSeq)
4353
- notifyDone(__t('slot.forkDone', { id: String(childId || '') }))
4354
- if (childId) openSessionById(childId)
4355
- })
4356
- .catch(reason => {
4357
- notifyDone(__t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)), 'error')
4358
- })
4359
- .finally(() => {
4360
- btn.disabled = false
4361
- })
4362
- }
4363
-
4364
- var ensureBtn = block => {
4365
- // 官方动作行(含 Copy):把按钮放到这一行里,与 Copy 同级
4366
- let host = block.querySelector('[class*="xzv4MW_actions"]')
4367
- if (!host) {
4368
- host = document.createElement('div')
4369
- host.className = 'mopsUserActionsRow'
4370
- block.appendChild(host)
4371
- }
4372
- let btn = host.querySelector('.mopsUserRevert')
4373
- if (btn) return btn
4374
- btn = document.createElement('button')
4375
- btn.type = 'button'
4376
- btn.className = 'mopsUserRevert'
4377
- // 0.21.0:行内回滚按钮不经过面板确认框,隐私告知必须挂在这里(hover 可见)
4378
- btn.title = __t('slot.revertPrivacyHint')
4379
- btn.setAttribute('aria-label', __t('slot.revert'))
4380
- btn.innerHTML =
4381
- '<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>'
4382
- btn.addEventListener('click', e => {
4383
- e.preventDefault()
4384
- e.stopPropagation()
4385
- if (btn.disabled) return
4386
- runUserRevert(btn, block)
4387
- })
4388
- host.appendChild(btn)
4389
- // 0.9.7(P2-1):新按钮按块的**当前**打标状态立刻同步一次。
4390
- // 门控之后 assignSeqs 可能被跳过(签名未变),靠这里保证「宿主重建了
4391
- // 动作行 → 按钮重新挂上」这种情况仍然是 disabled/title 正确的。
4392
- syncEnabled(block, btn)
4393
- return btn
4394
- }
4395
-
4396
- /** 0.12.0 分叉按钮:与回滚按钮**同一动作行**(opencode 把 fork 放在 copy/undo 同组)。 */
4397
- var ensureForkBtn = block => {
4398
- let host = block.querySelector('[class*="xzv4MW_actions"]')
4399
- if (!host) {
4400
- host = document.createElement('div')
4401
- host.className = 'mopsUserActionsRow'
4402
- block.appendChild(host)
4403
- }
4404
- const existing = host.querySelector('.mopsUserFork')
4405
- if (existing) return existing
4406
- const btn = document.createElement('button')
4407
- btn.type = 'button'
4408
- btn.className = 'mopsUserFork'
4409
- btn.title = __t('slot.forkHint')
4410
- btn.setAttribute('aria-label', __t('slot.fork'))
4411
- // 官方 IconBranchOutline16 的 1:1 路径(packages/client/ui-primitives/src/icons/index.tsx:149)
4412
- btn.innerHTML =
4413
- '<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>'
4414
- btn.addEventListener('click', e => {
4415
- e.preventDefault()
4416
- e.stopPropagation()
4417
- if (btn.disabled) return
4418
- runUserFork(btn, block)
4419
- })
4420
- host.appendChild(btn)
4421
- syncEnabled(block, btn)
4422
- return btn
4423
- }
4424
-
4425
3815
  /**
4426
3816
  * 0.20.0 铅笔编辑按钮:与回滚**同一动作行**,插在回滚与分叉之间。
4427
3817
  *
@@ -4506,12 +3896,46 @@ window.__ModuleLoader__.load({
4506
3896
  }
4507
3897
 
4508
3898
  // 三个按钮的顺序由 DOM 顺序决定:回滚在前(破坏性更高),编辑居中,分叉最后(非破坏)。
3899
+ var ensureBtn = block => {
3900
+ // 官方动作行(含 Copy):把按钮放到这一行里,与 Copy 同级
3901
+ let host = block.querySelector('[class*="xzv4MW_actions"]')
3902
+ if (!host) {
3903
+ host = document.createElement('div')
3904
+ host.className = 'mopsUserActionsRow'
3905
+ block.appendChild(host)
3906
+ }
3907
+ let btn = host.querySelector('.mopsUserRevert')
3908
+ if (btn) return btn
3909
+ btn = document.createElement('button')
3910
+ btn.type = 'button'
3911
+ btn.className = 'mopsUserRevert'
3912
+ // 0.21.0:行内回滚按钮不经过面板确认框,隐私告知必须挂在这里(hover 可见)
3913
+ btn.title = __t('slot.revertPrivacyHint')
3914
+ btn.setAttribute('aria-label', __t('slot.revert'))
3915
+ btn.innerHTML =
3916
+ '<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>'
3917
+ btn.addEventListener('click', e => {
3918
+ e.preventDefault()
3919
+ e.stopPropagation()
3920
+ if (btn.disabled) return
3921
+ runUserRevert(btn, block)
3922
+ })
3923
+ host.appendChild(btn)
3924
+ // 0.9.7(P2-1):新按钮按块的**当前**打标状态立刻同步一次。
3925
+ // 门控之后 assignSeqs 可能被跳过(签名未变),靠这里保证「宿主重建了
3926
+ // 动作行 → 按钮重新挂上」这种情况仍然是 disabled/title 正确的。
3927
+ syncEnabled(block, btn)
3928
+ return btn
3929
+ }
3930
+
4509
3931
  var ensureUserActions = block => {
4510
3932
  // 0.20.0:铅笔回归,但语义变了 —— 独立编辑框 + 点「发送并回撤」才写,
4511
3933
  // 不再是 0.18.0 那种「只回填 composer」的伪编辑。
3934
+ // 0.23.0:行内 fork 按钮已删 —— dsh 官方在 AI 回合尾部已有
3935
+ // sessions.fork(conversation.chat.assistant-actions / TurnTailNodeView)。
3936
+ // 分叉能力统一由官方按钮 + 面板 branch(同样走官方 sessions.fork)承担。
4512
3937
  ensureBtn(block)
4513
3938
  ensureEditBtn(block)
4514
- ensureForkBtn(block)
4515
3939
  }
4516
3940
  // 0.9.7(P0-2 读合并):把 150/700/1600ms 三档并成**一次**真网络请求,
4517
3941
  // 落点 = 本 burst 第一档 + 1500ms ≈ 原来的 1600ms 那一档。
@@ -4553,7 +3977,6 @@ window.__ModuleLoader__.load({
4553
3977
  if (!sid) return
4554
3978
  const blocks = userAnchors()
4555
3979
  for (const b of blocks) ensureUserActions(b)
4556
- suppressHostBranch()
4557
3980
  // 0.9.1:**始终**刷新(原先只在按钮未打标时刷)——
4558
3981
  // 打标后 transcript 再变化(openSession 重建 / 分页 / restore 重放)
4559
3982
  // 就再也不会重算隐藏,导致「界面停在旧状态,必须重载页面才对」。
@@ -4562,33 +3985,6 @@ window.__ModuleLoader__.load({
4562
3985
  /* 注入失败不影响会话 */
4563
3986
  }
4564
3987
  }
4565
- /**
4566
- * 0.12.0 隐藏官方 assistant turn-tail 上的 branch 按钮。
4567
- *
4568
- * 产品决定:分叉只属于**用户消息**(opencode 语义 —— fork 的目的是「这句话说错了,
4569
- * 拿回输入框重说」,AI 消息没有可回填的原文,分叉出去只会得到一个半截对话)。
4570
- * 官方把 branch 画在 MessageIconActions 里,与 copy 同一行;官方没有开关
4571
- * (ui-chat 的 Config 只有折叠/性能/链接几项),所以只能在渲染层隐藏。
4572
- *
4573
- * 识别方式不用 aria-label(8 种语言各不同),也不用哈希 class,而用
4574
- * **图标路径前缀**:官方 IconBranchOutline16 的 d 是固定字符串
4575
- * (packages/client/ui-primitives/src/icons/index.tsx:149)。作用域限定在
4576
- * `[data-turn-tail]`(官方 TurnTailNodeView 渲染的稳定属性),
4577
- * 并排除我们自己注入的 .mopsUserFork(它复用同一 path)。
4578
- */
4579
- var suppressHostBranch = () => {
4580
- let hidden = 0
4581
- for (const btn of document.querySelectorAll('[data-turn-tail] button')) {
4582
- if (!isHostBranchButton(btn)) continue
4583
- hidden++
4584
- if (btn.getAttribute('data-mops-host-branch') !== 'hidden') {
4585
- btn.setAttribute('data-mops-host-branch', 'hidden')
4586
- btn.style.display = 'none'
4587
- }
4588
- }
4589
- return hidden
4590
- }
4591
-
4592
3988
  // 触发:hover / 滚动 / DOM 变化 / 变更事件
4593
3989
  document.addEventListener(
4594
3990
  'mouseover',
@@ -4700,11 +4096,11 @@ window.__ModuleLoader__.load({
4700
4096
  // (宿主 .xzv4MW_actions 已定 height:28px,改小会撑裂行高)。
4701
4097
  // · 无淡入动画(opencode 源码注释明写 "Hover actions show and hide
4702
4098
  // at once, without a fade")—— 显隐完全交给宿主 [data-actions-reveal]。
4703
- '.mopsUserRevert,.mopsUserEdit,.mopsUserFork{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}',
4704
- '.mopsUserRevert svg,.mopsUserEdit svg,.mopsUserFork svg{width:14px;height:14px;display:block}',
4705
- '.mopsUserRevert:hover,.mopsUserEdit:hover,.mopsUserFork:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-secondary,#6b6b70)}',
4706
- '.mopsUserRevert:disabled,.mopsUserEdit:disabled,.mopsUserFork:disabled{opacity:.4;cursor:default;background:transparent}',
4707
- '.mopsUserRevert:focus-visible,.mopsUserEdit:focus-visible,.mopsUserFork:focus-visible{outline:2px solid var(--dsw-alias-border-l2,#b8b8b8);outline-offset:1px}',
4099
+ '.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}',
4100
+ '.mopsUserRevert svg,.mopsUserEdit svg{width:14px;height:14px;display:block}',
4101
+ '.mopsUserRevert:hover,.mopsUserEdit:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.12));color:var(--dsw-alias-label-secondary,#6b6b70)}',
4102
+ '.mopsUserRevert:disabled,.mopsUserEdit:disabled{opacity:.4;cursor:default;background:transparent}',
4103
+ '.mopsUserRevert:focus-visible,.mopsUserEdit:focus-visible{outline:2px solid var(--dsw-alias-border-l2,#b8b8b8);outline-offset:1px}',
4708
4104
  // 0.18.0:用户反馈「点时间图标也会回撤」——根因不是绑定错误,而是
4709
4105
  // 我们的按钮被 appendChild 到宿主 .actions 行末尾,而该行在
4710
4106
  // data-clock="start"(用户消息)时第一个子元素就是**时间文本**:
@@ -4978,10 +4374,13 @@ window.__ModuleLoader__.load({
4978
4374
  // 编辑器是否已挂载、也不依赖 inputActions 此刻绑在哪个会话上。
4979
4375
  const persisted = writeSessionDraft(rawSid, text)
4980
4376
  // 再尽力更新活着的编辑器(视图没重建的路径,例如 dock 内联恢复)。
4377
+ // 0.24.0 P4:按 rawSid 取该会话自己的 InputActions;取不到就跳过 ——
4378
+ // 绝不能用别的会话的编辑器,那会把原文写进用户正在看的另一个会话。
4981
4379
  let editorSet = false
4982
- if (__inputActions && typeof __inputActions.setDraft === 'function') {
4380
+ const liveActions = inputActionsFor(rawSid)
4381
+ if (liveActions && typeof liveActions.setDraft === 'function') {
4983
4382
  try {
4984
- __inputActions.setDraft(text)
4383
+ liveActions.setDraft(text)
4985
4384
  editorSet = true
4986
4385
  } catch (e) {
4987
4386
  console.warn('[message-ops] setDraft failed:', e)
@@ -5212,7 +4611,9 @@ window.__ModuleLoader__.load({
5212
4611
  order: 101,
5213
4612
  ...(__locale ? { locale: NS } : {}),
5214
4613
  },
5215
- window.__MOPS_LEGACY_DIALOG === true ? OpsDialog : OpsPanel,
4614
+ // 0.24.0:旧对话框(约 407 行)已删除 —— 它只能通过一个从未有人
4615
+ // 设置的 LEGACY 开关到达(全仓库零处赋值)。面板是唯一实现。
4616
+ OpsPanel,
5216
4617
  ),
5217
4618
  )
5218
4619
  // 0.20.0:编辑并重发浮层(同族模态,order 102 排在 OpsPanel 之后 —— 两者互斥打开)
@@ -5237,13 +4638,16 @@ window.__ModuleLoader__.load({
5237
4638
  __test: {
5238
4639
  activityTransition,
5239
4640
  forkBoundaryBefore,
5240
- isHostBranchButton,
5241
4641
  writeSessionDraft,
5242
- HOST_BRANCH_ICON_ID,
5243
- HOST_BRANCH_D_PREFIX,
5244
4642
  // 0.20.0:编辑并重发的编排层(可注入 deps 真执行断言时序)
5245
4643
  sendEditAndRevert,
5246
4644
  submitEditedText,
4645
+ // 0.24.0 P4:按会话隔离的 InputActions 访问面(真执行测试用)
4646
+ rememberInputActions,
4647
+ forgetInputActions,
4648
+ inputActionsFor,
4649
+ sessionKeyOf,
4650
+ __inputActionsBySession,
5247
4651
  EDIT_EVENT,
5248
4652
  EDIT_ID,
5249
4653
  },