@240xu/dsh-message-ops 0.23.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.
Files changed (3) hide show
  1. package/README.md +30 -0
  2. package/package.json +1 -1
  3. package/src/client.js +131 -591
package/README.md CHANGED
@@ -1372,3 +1372,33 @@ Lead 逐条复核后落地 3 个修复。汇总见 `design-demos/audit-round-sum
1372
1372
 
1373
1373
  过程中 Lead 误删 `ensureBtn` 导致用户消息按钮全失效,已从 git 取回并真机复验
1374
1374
  `mopsRevert=9 / mopsEdit=9`。测试 360(356 pass / 4 skip),`prettier --check` 全绿。
1375
+
1376
+ ### 0.24.0 · 四项专项收敛(删 553 行死代码 / 文案瘦身 43% / 入口改名 / 跨会话隔离)
1377
+
1378
+ 用户要求「分配专项专家子代理进行处理」,针对审计留下的 4 项待拍板问题。
1379
+ 4 个专项并行,各自独立改代码,Lead 统一收口。
1380
+
1381
+ 1. **删 OpsDialog 死代码**:`src/client.js` **5115 → 4562 行(净减 553)**。
1382
+ OpsDialog 函数体 413 行 + 11 个独占样式常量 86 行 + `Modal` 导入 +
1383
+ 24 个 i18n key(zh/en 各 24)。它只能通过一个**全仓库从未有人设置**的
1384
+ `window.__MOPS_LEGACY_DIALOG` 到达。保留 3 个名字带 `dialog.` 前缀但
1385
+ 实际被 OpsPanel / MsgSlotActions 使用的 key(`dialog.title`/`cancel`/`runningWarn`)。
1386
+ 功能无空洞:遮蔽单条、删整条会话、服务端 `/delete` 全在 OpsPanel。
1387
+ 2. **回撤确认瘦身 130 → 74 字(-43%)**:把独立的 56 字隐私告知条合并进
1388
+ 确认正文,成功 toast 30 → 13 字。隐私信息一条没少,只是不再分四层说。
1389
+ 3. **入口改名消除同名不同义**:行内铅笔「编辑并重发」→ **「编辑并回撤重发」**
1390
+ (en `Edit & revert-resend`)。此前它和已装的第三方 message-edit 插件
1391
+ 文案一字不差、后果却相反(我们毁源会话、它 fork 保留源会话)。
1392
+ 现在名字差异 = 后果差异。`slot.editHint` 同步说清「会回撤此条及之后」。
1393
+ 4. **`__inputActions` 跨会话污染修复**(真 bug):宿主 `assistant-actions` 是
1394
+ `scope: "session"` 且按 messageId 逐条渲染,每个会话的 InputActions 是
1395
+ 不同对象;旧实现用模块级单变量,后挂载的覆盖先挂载的。反向验证实测
1396
+ `getOld('session-aaa')` 返回 B、未登记会话也串到别人 —— 最严重时
1397
+ `submitEditedText` 会把编辑后的文本**发进别的会话**。
1398
+ 改成 `Map<sessionId, InputActions>` + 三个访问器,两个捕获点改
1399
+ `useEffect` 注册/卸载(顺带补上原来完全没有的清理),4 个读取点全部
1400
+ 按会话取、取不到走明确失败。
1401
+
1402
+ 测试 364(360 pass / 4 skip),新增 4 条跨会话隔离真执行测试(旧实现下会挂)。
1403
+ `prettier --check` 全绿,i18n zh/en 115/115 序列一致。
1404
+ 真机 Chromium:`revert=9 / edit=9 / fork=0`、官方 branch=3、无隐藏。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@240xu/dsh-message-ops",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "DSH web 插件:消息级回滚 / 删除 / 恢复 / 分叉 / 编辑重发(补 dsh 官方没有的部分)。",
5
5
  "type": "module",
6
6
  "license": "MIT",
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': '把这条及之后的对话从 AI 可见内容里隐藏;原文仍保留,可以放回。',
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,16 +150,8 @@ 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': '已回滚(原文仍保留在本地会话文件,可被恢复);刷新页面后生效',
154
+ 'done.revert': '已回滚,原文可从恢复区放回',
176
155
  'done.revertNoRefill': '已回滚,但原文未能放回输入框(会话可能尚未挂载);可重试或从消息操作面板手动复制',
177
156
  'done.delete': '已遮蔽,刷新页面后生效',
178
157
  'action.reload': '刷新页面',
@@ -218,12 +197,10 @@ window.__ModuleLoader__.load({
218
197
  'panel.revert': '回滚到此条',
219
198
  'panel.revertHint': '包含此条及其后的可见消息',
220
199
  'panel.revertConfirmTitle': '回滚到 #{seq}?',
221
- 'panel.revertConfirmBody': '将遮蔽 #{start}–#{end} 的 {n} 条消息,其中可见 {v} 条;日志仍保留,可恢复。',
222
- // 0.21.0:隐私预期落差修正。回撤不是「删除」,别让用户以为内容消失了。
223
- // 实测(design-demos/revert-data-semantics.md):AI 看不到(模型只读 surface.nodes),
224
- // 但被回撤消息的原文仍逐字留在本地 session.v4.jsonl.zstd 里,翻文件拿得到。
225
- 'panel.revertPrivacyNote':
226
- '注意:这不是删除。AI 将看不到这些消息,但原文仍完整保留在本地会话文件中,可被恢复;直接翻看会话文件仍能读到。',
200
+ // 0.23.0:隐私告知并入确认正文(原 body 37 字 + privacy 56 字 = 93 字,合并后 55 字)。
201
+ // 告知内容一条没少:AI 看不到 / 原文仍在本地文件 / 可恢复。只是不再分两层说。
202
+ 'panel.revertConfirmBody':
203
+ '将遮蔽 #{start}–#{end} 共 {n} 条消息(可见 {v} 条)。AI 将看不到它们,但原文仍保留在本地会话文件、可恢复。',
227
204
  'panel.deleteConfirmTitle': '仅删除 #{seq}?',
228
205
  'panel.deleteConfirmBody': '将遮蔽这 1 条消息,其他内容不动;日志仍保留,可恢复。',
229
206
  'panel.confirmRevert': '确认回滚',
@@ -267,25 +244,7 @@ window.__ModuleLoader__.load({
267
244
  'button.title': 'Message ops (revert / delete / branch)',
268
245
  'dialog.title': 'Message ops',
269
246
  'dialog.cancel': 'Close',
270
- 'dialog.loading': 'Loading messages…',
271
- 'dialog.loadFail': 'Failed to load messages: ',
272
- 'dialog.empty': 'No operable messages in this session.',
273
- 'dialog.session': 'Session: ',
274
247
  'dialog.runningWarn': '⚠ Session is running: stop it before revert / delete / branch.',
275
- 'dialog.pick': 'Pick a message:',
276
- 'dialog.pickFirst': 'Step 1 · pick a message below, then choose an operation here.',
277
- 'dialog.pickedAs': 'Selected #{seq} · {text}',
278
- 'dialog.invisible': ' (shadowed, log-only)',
279
- 'dialog.showMore': 'Show more ({n} older)',
280
- 'dialog.more': '…(showing latest 200 of {n})',
281
- 'op.revert': 'Revert to here',
282
- 'op.revertDesc':
283
- 'Shadows the picked message and all later visible content; the log stays append-only so context can be restored by re-sending.',
284
- 'op.delete': 'Hide this message',
285
- 'op.deleteDesc': 'Shadows only the picked message; everything else stays.',
286
- 'op.branch': 'Fork into a new session from here',
287
- 'op.branchDesc':
288
- 'Copies the conversation above the picked message into a new session and puts this message back in the new composer (original untouched, non-destructive).',
289
248
  'slot.revert': 'Revert to here',
290
249
  'slot.revertPrivacyHint': 'Revert to here (not deletion: hidden from the AI, but the original text stays in the local session file)',
291
250
  'slot.revertUnmatched':
@@ -294,12 +253,16 @@ window.__ModuleLoader__.load({
294
253
  'slot.forkHint': 'Copies the conversation above this message into a new session and puts this message back in the new composer',
295
254
  'slot.forkDone': 'Branched: new session {id}',
296
255
  'slot.forkUnavailable': 'Branch unavailable: the session is running, or the host provides no session/fork',
297
- // 0.20.0: pencil edit overlay on the user-message action row (revert-then-send).
298
- 'slot.edit': 'Edit and resend',
299
- '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.',
300
263
  'slot.editNoText': 'This message has no text to edit',
301
264
  'slot.editUnmatched': 'Cannot locate this message seq in the log, so it cannot be edited yet',
302
- 'edit.title': 'Edit and resend',
265
+ 'edit.title': 'Edit & revert-resend',
303
266
  'edit.subtitle': 'This message · seq #{seq}',
304
267
  'edit.loading': 'Loading the original text…',
305
268
  'edit.loadFail': 'Could not load the original text: ',
@@ -320,16 +283,8 @@ window.__ModuleLoader__.load({
320
283
  'fork.official': 'Branched (official fork): new session {id}',
321
284
  'fork.unavailable':
322
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.',
323
- 'ack.revert': 'I understand: revert shadows the picked message and everything after it',
324
- 'ack.delete': 'I understand: this message will be shadowed (kept in the log)',
325
- 'confirm.revert': 'Revert',
326
- 'confirm.delete': 'Delete',
327
- 'confirm.branch': 'Branch',
328
- 'busy.revert': 'Reverting…',
329
- 'busy.delete': 'Deleting…',
330
- 'busy.branch': 'Branching…',
331
286
  'done.restore': 'Restored: replayed {n}, skipped non-replayable {s}',
332
- 'done.revert': 'Reverted (original text stays in the local session file and can be restored); reload to apply',
287
+ 'done.revert': 'Reverted — restore the original from the restore area',
333
288
  'done.revertNoRefill':
334
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',
335
290
  'done.delete': 'Hidden; reload to apply',
@@ -377,9 +332,7 @@ window.__ModuleLoader__.load({
377
332
  'panel.revertHint': 'Includes this message and all visible messages after it',
378
333
  'panel.revertConfirmTitle': 'Revert to #{seq}?',
379
334
  'panel.revertConfirmBody':
380
- 'This shadows {n} messages (#{start}–#{end}), including {v} visible. The original text stays in the local session file and can be put back.',
381
- 'panel.revertPrivacyNote':
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.',
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.',
383
336
  'panel.deleteConfirmTitle': 'Delete only #{seq}?',
384
337
  'panel.deleteConfirmBody': 'This shadows this one message; everything else stays. The log stays append-only and can be restored.',
385
338
  'panel.confirmRevert': 'Confirm revert',
@@ -418,7 +371,61 @@ window.__ModuleLoader__.load({
418
371
 
419
372
  var __locale = null
420
373
  var __sessionsSvc = null
421
- 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
+ }
422
429
  var __uiWorkspace = null
423
430
  var __currentSessionId = null
424
431
  // 0.9.1:视图重建后刷新 transcript 可见性的钩子。
@@ -482,92 +489,6 @@ window.__ModuleLoader__.load({
482
489
  cursor: 'pointer',
483
490
  flex: 'none',
484
491
  }
485
- const metaStyle = {
486
- color: 'var(--dsw-alias-label-secondary, #8a8a8e)',
487
- fontSize: 13,
488
- lineHeight: '20px',
489
- margin: '0 0 8px',
490
- overflow: 'hidden',
491
- textOverflow: 'ellipsis',
492
- }
493
- const warnStyle = {
494
- color: 'var(--dsw-alias-state-warn-primary, #f5a524)',
495
- fontSize: 13,
496
- lineHeight: '20px',
497
- margin: '0 0 10px',
498
- }
499
- const errStyle = {
500
- color: 'var(--dsw-alias-state-error-primary, #e5484d)',
501
- fontSize: 12,
502
- lineHeight: '16px',
503
- marginTop: 8,
504
- }
505
- const statusStyle = {
506
- color: 'var(--dsw-alias-label-secondary, #8a8a8e)',
507
- fontSize: 12,
508
- lineHeight: '16px',
509
- marginTop: 8,
510
- }
511
- const listStyle = {
512
- maxHeight: 260,
513
- overflowY: 'auto',
514
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.35))',
515
- borderRadius: 8,
516
- margin: '8px 0 4px',
517
- padding: '4px 0',
518
- }
519
- const rowStyle = {
520
- display: 'flex',
521
- alignItems: 'flex-start',
522
- gap: 8,
523
- padding: '4px 10px',
524
- fontSize: 13,
525
- lineHeight: '18px',
526
- cursor: 'pointer',
527
- }
528
- const descStyle = {
529
- color: 'var(--dsw-alias-label-secondary, #8a8a8e)',
530
- fontSize: 12,
531
- lineHeight: '17px',
532
- margin: '6px 0 0',
533
- }
534
- const cancelBtnStyle = {
535
- padding: '6px 14px',
536
- borderRadius: 8,
537
- border: '1px solid var(--dsw-alias-border-l2, rgba(128,128,128,.4))',
538
- background: 'transparent',
539
- color: 'var(--dsw-alias-label-primary, inherit)',
540
- fontSize: 13,
541
- cursor: 'pointer',
542
- marginRight: 8,
543
- }
544
- const primaryBtnStyle = {
545
- padding: '6px 14px',
546
- borderRadius: 8,
547
- border: 'none',
548
- background: 'var(--dsw-alias-brand-primary, #4d6bfe)',
549
- color: '#fff',
550
- fontSize: 13,
551
- cursor: 'pointer',
552
- }
553
- const dangerBtnStyle = {
554
- padding: '6px 14px',
555
- borderRadius: 8,
556
- border: '1px solid var(--dsw-alias-state-error-primary, #e5484d)',
557
- background: 'var(--dsw-alias-state-error-primary, #e5484d)',
558
- color: '#fff',
559
- fontSize: 13,
560
- cursor: 'pointer',
561
- }
562
- const optStyle = {
563
- display: 'flex',
564
- alignItems: 'center',
565
- gap: 8,
566
- fontSize: 13,
567
- lineHeight: '20px',
568
- color: 'var(--dsw-alias-label-primary, inherit)',
569
- marginTop: 10,
570
- }
571
492
 
572
493
  // 头部按钮图标:三叉分支(git-branch 风格,16x16)。
573
494
  // ⚠️ 这条 path 是按**描边**(stroke)设计的:圆点用 arc 画、连接线用
@@ -667,419 +588,6 @@ window.__ModuleLoader__.load({
667
588
  )
668
589
  }
669
590
 
670
- // --- 共享对话框 -------------------------------------------------------------
671
- // 模块级缓存最近一次 target,事件驱动打开。
672
- const MAX_RENDER = 200
673
- const PAGE_SIZE = 50 // 低成本分批渲染:先渲 50 条,按钮渐进展开
674
-
675
- function OpsDialog(props) {
676
- const t = (props && props.t) || __t
677
- useLocaleRevision()
678
- const [target, setTarget] = useState(null) // {sessionId, title, running}
679
- const [state, setState] = useState('idle') // idle|loading|ready|busy|done
680
- const [messages, setMessages] = useState([])
681
- const [sessionMeta, setSessionMeta] = useState(null)
682
- const [picked, setPicked] = useState(null) // seq
683
- const [mode, setMode] = useState(null) // revert|delete|branch|restore
684
- const [childId, setChildId] = useState(null) // 官方 fork 成功后的子会话 id
685
- const [acknowledged, setAcknowledged] = useState(false)
686
- const [busyMsg, setBusyMsg] = useState('')
687
- const [renderLimit, setRenderLimit] = useState(PAGE_SIZE) // 已展开的渲染条数
688
- const [doneMsg, setDoneMsg] = useState('')
689
- const [error, setError] = useState(null)
690
-
691
- useEffect(() => {
692
- const handler = e => {
693
- const d = e && e.detail ? e.detail : {}
694
- setTarget({ sessionId: d.sessionId || null, title: d.title || null, running: d.running === true })
695
- setState('loading')
696
- setMessages([])
697
- setSessionMeta(null)
698
- // 槽按钮预置:携带 seq(picked)与 mode 直接进入确认态
699
- setPicked(typeof d.seq === 'number' ? d.seq : null)
700
- setMode(typeof d.mode === 'string' ? d.mode : null)
701
- setAcknowledged(false)
702
- setError(null)
703
- setDoneMsg('')
704
- setRenderLimit(PAGE_SIZE)
705
- }
706
- window.addEventListener(EVENT, handler)
707
- return () => window.removeEventListener(EVENT, handler)
708
- }, [])
709
-
710
- useEffect(() => {
711
- if (state !== 'loading' || !target || !target.sessionId) return
712
- let cancelled = false
713
- fetchMessagesJson('/api/message-ops/messages?sessionId=' + encodeURIComponent(target.sessionId))
714
- .then(data => {
715
- if (cancelled) return
716
- if (!data || !data.ok) throw new Error(data && data.error ? data.error : `HTTP ${data && data.status}`)
717
- setMessages(data.messages || [])
718
- setSessionMeta(data.session || null)
719
- if (data.running === true) setTarget(prev => ({ ...(prev || {}), running: true }))
720
- setState('ready')
721
- })
722
- .catch(reason => {
723
- if (cancelled) return
724
- setError(t('dialog.loadFail') + (reason && reason.message ? reason.message : String(reason)))
725
- setState('ready')
726
- })
727
- return () => {
728
- cancelled = true
729
- }
730
- }, [state, target, t])
731
-
732
- const close = useCallback(() => {
733
- if (state === 'busy') return
734
- setTarget(null)
735
- setError(null)
736
- }, [state])
737
-
738
- const pick = useCallback(
739
- m => {
740
- if (state === 'busy') return
741
- setPicked(m.seq)
742
- setMode(null)
743
- setAcknowledged(false)
744
- setError(null)
745
- },
746
- [state],
747
- )
748
-
749
- const chooseMode = useCallback(
750
- m => {
751
- if (picked == null || state === 'busy') return
752
- setMode(m)
753
- setAcknowledged(false)
754
- setError(null)
755
- },
756
- [picked, state],
757
- )
758
-
759
- const run = useCallback(() => {
760
- if (state === 'busy' || picked == null || !mode) return
761
- if (mode !== 'branch' && !acknowledged) return
762
- setBusyMsg(t('busy.' + (mode === 'revert' || mode === 'delete' ? mode : 'branch')))
763
- setState('busy')
764
- setError(null)
765
- if (mode === 'branch') {
766
- // 0.12.0:与面板/消息行同一实现 —— opencode 的 before 语义
767
- // (新会话不含此条,原文回新会话输入框)。只对用户消息成立;
768
- // 分支不再回落写盘(被删的磁盘 applyBranch 语义复盘见 README)。
769
- const pickedRow = picked != null ? messages.find(m => m.seq === picked) : null
770
- if (!pickedRow || pickedRow.role !== 'user') {
771
- setError(t('panel.branchUserOnly'))
772
- setBusyMsg('')
773
- setState('error')
774
- return
775
- }
776
- Promise.resolve()
777
- .then(() =>
778
- forkFromUserMessage(target.sessionId, picked, pickedRow.fullText || pickedRow.snippet || '', pickedRow.turnStartSeq),
779
- )
780
- .then(childId => {
781
- setDoneMsg(t('fork.official', { id: String(childId || '') }))
782
- setBusyMsg('')
783
- setChildId(childId || null)
784
- setState('done')
785
- notifyDone(t('fork.official', { id: String(childId || '') }))
786
- })
787
- .catch(reason => {
788
- setError(String((reason && reason.message) || reason || t('fork.unavailable')))
789
- setBusyMsg('')
790
- setState('error')
791
- })
792
- return
793
- }
794
- const path = mode
795
- const body = { sessionId: target.sessionId, seq: picked }
796
- Promise.resolve()
797
- .then(() =>
798
- fetch('/api/message-ops/' + path, {
799
- method: 'POST',
800
- headers: { 'content-type': 'application/json' },
801
- body: JSON.stringify(body),
802
- }),
803
- )
804
- .then(async res => {
805
- let data = {}
806
- try {
807
- data = await res.json()
808
- } catch {
809
- /* keep {} */
810
- }
811
- if (!res.ok || !data.ok) throw new Error(data.error || `HTTP ${res.status}`)
812
- // S6 修复(G-M1):不再 900ms 裸 location.reload。成功走 devkit
813
- // 标准 toast(无 devkit 时降级为对话框内 doneMsg),并提供手动
814
- // 「刷新页面」按钮。
815
- // 0.9.7:补回 ec862d6(0.9.0) 误删的 `const okMsg =`——留下悬挂的
816
- // `? :` 会让成功路径抛 ReferenceError 落进 .catch(用户看到「操作失败」,
817
- // notifyDone/emitChanged/openSession/回填全不执行),失败路径则恒走
818
- // `?` 分支把成功文案当错误抛出。对话框 mode 只有 revert|delete|branch,
819
- // branch 在上面已 return,故 done.restore 分支在此不可达,一并删掉。
820
- const okMsg = mode === 'revert' ? t('done.revert') : t('done.delete')
821
- // 0.19.0:回填统一由 refillComposer 承担;老 setDraft 路径已删(见 spec §9)。
822
- setDoneMsg(okMsg)
823
- setBusyMsg('')
824
- setState('done')
825
- notifyDone(okMsg)
826
- emitChanged()
827
- // 0.5.7:store-miss 的磁盘追加没有 live 投影事件 —— 成功后强制
828
- // 重建视图(与 restoreRow 同款 openSession 模式),遮蔽即刻可见。
829
- try {
830
- if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(target.sessionId)
831
- } catch {
832
- /* 视图重建失败不阻断成功反馈 */
833
- }
834
- })
835
- .catch(reason => {
836
- setBusyMsg('')
837
- setState('ready')
838
- setError(t('errorPrefix') + (reason && reason.message ? reason.message : String(reason)))
839
- })
840
- }, [state, picked, mode, acknowledged, target, t])
841
-
842
- if (!target) return null
843
-
844
- // 0.6.0:system prompt 行不可作为回滚/删除/分支目标(引擎拒之以 node0 守卫,
845
- // 但不该给用户一个必然500的选项)——列表直接排除 role=system。
846
- const visible = messages.filter(m => m.visible !== false && m.role !== 'system')
847
- const shownBase = visible.slice(-MAX_RENDER)
848
- const hiddenCount = visible.length - shownBase.length
849
- // 分批渲染(评审 M1):只渲染 renderLimit 条,更早的留给「显示更多」
850
- // 渐进展开,避免 200 行 radio 列表一次进 DOM。
851
- const shown = shownBase.slice(-renderLimit)
852
- const pagedCount = shownBase.length - shown.length
853
- const pickedMsg = picked != null ? messages.find(m => m.seq === picked) : null
854
-
855
- // 0.9.0 可发现性:操作区固定在**消息列表之前**。
856
- // 原先它在列表之后,而列表是 260px 滚动 + 分批渲染 50 条/页 ——
857
- // 未选中消息时三个 radio 完全不在视野内,用户以为「只有列表、没有操作」。
858
- // 未选中时给明确指引,而不是空着。
859
- const opsPanel = pickedMsg
860
- ? React.createElement(
861
- 'div',
862
- { key: 'ops', style: { margin: '8px 0 0' } },
863
- React.createElement(
864
- 'div',
865
- { style: { ...metaStyle, margin: '0 0 4px' } },
866
- t('dialog.pickedAs', { seq: String(pickedMsg.seq), text: (pickedMsg.snippet || '').slice(0, 60) }),
867
- ),
868
- ['revert', 'delete', 'branch'].map((m, i) =>
869
- React.createElement(
870
- 'div',
871
- { key: m, style: { marginTop: i === 0 ? 6 : 4 } },
872
- React.createElement(
873
- 'label',
874
- { style: optStyle },
875
- React.createElement('input', {
876
- type: 'radio',
877
- name: 'dsh-message-ops-mode',
878
- checked: mode === m,
879
- onChange: () => chooseMode(m),
880
- disabled: state === 'busy',
881
- }),
882
- t('op.' + m),
883
- ),
884
- mode === m ? React.createElement('div', { style: descStyle }, t('op.' + m + 'Desc')) : null,
885
- ),
886
- ),
887
- mode && mode !== 'branch'
888
- ? React.createElement(
889
- 'label',
890
- { key: 'ack', style: optStyle },
891
- React.createElement('input', {
892
- type: 'checkbox',
893
- checked: acknowledged,
894
- disabled: state === 'busy',
895
- onChange: e => setAcknowledged(e.target.checked),
896
- }),
897
- t(mode === 'revert' ? 'ack.revert' : 'ack.delete'),
898
- )
899
- : null,
900
- )
901
- : React.createElement(
902
- 'div',
903
- {
904
- key: 'opshint',
905
- style: {
906
- ...metaStyle,
907
- margin: '8px 0 0',
908
- padding: '6px 8px',
909
- borderRadius: 6,
910
- background: 'var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.1))',
911
- },
912
- },
913
- t('dialog.pickFirst'),
914
- )
915
-
916
- let body
917
- if (state === 'loading') {
918
- body = React.createElement('div', { key: 'load', style: statusStyle }, t('dialog.loading'))
919
- } else if (!messages.length) {
920
- body = React.createElement('div', { key: 'empty', style: statusStyle }, t('dialog.empty'))
921
- } else {
922
- body = React.createElement(React.Fragment, null, [
923
- target.running ? React.createElement('div', { key: 'warn', style: warnStyle }, t('dialog.runningWarn')) : null,
924
- opsPanel,
925
- React.createElement('div', { key: 'pick', style: metaStyle }, t('dialog.pick')),
926
- React.createElement(
927
- 'div',
928
- { key: 'list', style: listStyle },
929
- hiddenCount > 0
930
- ? React.createElement(
931
- 'div',
932
- { key: 'more', style: { ...rowStyle, cursor: 'default', color: 'var(--dsw-alias-label-secondary,#8a8a8e)' } },
933
- t('dialog.more', { n: String(visible.length) }),
934
- )
935
- : null,
936
- pagedCount > 0
937
- ? React.createElement(
938
- 'button',
939
- {
940
- key: 'show-more',
941
- type: 'button',
942
- style: {
943
- ...rowStyle,
944
- border: 'none',
945
- width: '100%',
946
- color: 'var(--dsw-alias-label-secondary,#8a8a8e)',
947
- cursor: 'pointer',
948
- },
949
- onClick: () => setRenderLimit(l => Math.min(l + PAGE_SIZE, MAX_RENDER)),
950
- },
951
- t('dialog.showMore', { n: String(pagedCount) }),
952
- )
953
- : null,
954
- shown.map((m, i) =>
955
- React.createElement(
956
- 'label',
957
- {
958
- key: m.seq + '-' + i,
959
- style: {
960
- ...rowStyle,
961
- background: picked === m.seq ? 'var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.14))' : 'transparent',
962
- },
963
- },
964
- React.createElement('input', {
965
- type: 'radio',
966
- name: 'dsh-message-ops-pick',
967
- checked: picked === m.seq,
968
- onChange: () => pick(m),
969
- disabled: state === 'busy',
970
- }),
971
- React.createElement(
972
- 'span',
973
- {
974
- style: {
975
- flex: 1,
976
- minWidth: 0,
977
- overflow: 'hidden',
978
- textOverflow: 'ellipsis',
979
- whiteSpace: 'nowrap',
980
- color: m.visible === false ? 'var(--dsw-alias-label-tertiary,#b0b0b4)' : 'inherit',
981
- },
982
- },
983
- '#' + m.seq + ' ' + (m.role || '') + ' · ' + (m.snippet || '') + (m.visible === false ? t('dialog.invisible') : ''),
984
- ),
985
- ),
986
- ),
987
- ),
988
- // 0.9.7:删掉列表**之后**的旧 opsPanel——0.9.0 把操作区挪到列表之前时
989
- // 没删旧位置,两组同名 radio(name='dsh-message-ops-mode')互抢,
990
- // checked 状态在两份 DOM 之间互相顶掉。
991
- ])
992
- }
993
-
994
- const canRun = state !== 'busy' && state !== 'loading' && picked != null && mode != null && (mode === 'branch' || acknowledged)
995
- const confirmLabel = busyMsg || (mode ? t('confirm.' + mode) : t('dialog.cancel'))
996
-
997
- return React.createElement(
998
- Modal,
999
- {
1000
- open: true,
1001
- onClose: close,
1002
- title: t('dialog.title'),
1003
- closeLabel: t('dialog.cancel'),
1004
- description: t('dialog.session') + (target.title || target.sessionId || ''),
1005
- footer: [
1006
- React.createElement(
1007
- 'button',
1008
- {
1009
- key: 'cancel',
1010
- type: 'button',
1011
- disabled: state === 'busy',
1012
- onClick: close,
1013
- style: { ...cancelBtnStyle, ...(state === 'busy' ? { opacity: 0.5, cursor: 'default' } : {}) },
1014
- },
1015
- t('dialog.cancel'),
1016
- ),
1017
- React.createElement(
1018
- 'button',
1019
- {
1020
- key: 'confirm',
1021
- type: 'button',
1022
- disabled: !canRun,
1023
- onClick: run,
1024
- style: {
1025
- ...(mode === 'delete' || mode === 'revert' ? dangerBtnStyle : primaryBtnStyle),
1026
- ...(!canRun ? { opacity: 0.5, cursor: 'default' } : {}),
1027
- },
1028
- },
1029
- confirmLabel,
1030
- ),
1031
- ...(state === 'done' && (mode === 'revert' || mode === 'delete')
1032
- ? [
1033
- React.createElement(
1034
- 'button',
1035
- {
1036
- key: 'reload',
1037
- type: 'button',
1038
- onClick: () => {
1039
- try {
1040
- window.location.reload()
1041
- } catch {
1042
- /* non-browser guard */
1043
- }
1044
- },
1045
- style: primaryBtnStyle,
1046
- },
1047
- t('action.reload'),
1048
- ),
1049
- ]
1050
- : []),
1051
- ...(state === 'done' && mode === 'branch' && childId
1052
- ? [
1053
- React.createElement(
1054
- 'button',
1055
- {
1056
- key: 'open-new',
1057
- type: 'button',
1058
- onClick: () => {
1059
- try {
1060
- // 0.2.0+:uiWorkspace.openSession 是宿主唯一打开通道
1061
- if (__uiWorkspace && typeof __uiWorkspace.openSession === 'function') __uiWorkspace.openSession(childId)
1062
- } catch {
1063
- /* 打开失败不阻断 */
1064
- }
1065
- },
1066
- style: primaryBtnStyle,
1067
- },
1068
- t('toast.openNew'),
1069
- ),
1070
- ]
1071
- : []),
1072
- ],
1073
- },
1074
- [
1075
- React.createElement('div', { key: 'meta', style: metaStyle }, t('dialog.session'), target.sessionId || ''),
1076
- body,
1077
- doneMsg ? React.createElement('div', { key: 'done', style: statusStyle }, doneMsg) : null,
1078
- error ? React.createElement('div', { key: 'err', style: errStyle, role: 'alert' }, error) : null,
1079
- ],
1080
- )
1081
- }
1082
-
1083
591
  // --- A · 功能主义抽屉 -------------------------------------------------------
1084
592
 
1085
593
  const PANEL_ROW_H = 46
@@ -2261,11 +1769,6 @@ window.__ModuleLoader__.load({
2261
1769
  })
2262
1770
  : t('panel.deleteConfirmBody'),
2263
1771
  ),
2264
- // 0.21.0:revert 的常显隐私告知(零副作用、纯文案)。
2265
- // 只在回滚确认态出现;删除确认不需要(删单条同样遮蔽,但语义不同)。
2266
- confirmAction === 'revert'
2267
- ? React.createElement('div', { className: 'mopsPrivacyNote', role: 'note' }, t('panel.revertPrivacyNote'))
2268
- : null,
2269
1772
  React.createElement(
2270
1773
  'div',
2271
1774
  { className: 'mopsConfirmRow' },
@@ -2497,21 +2000,26 @@ window.__ModuleLoader__.load({
2497
2000
  /**
2498
2001
  * 有界等待 composer 重挂后提交**一次**。
2499
2002
  *
2500
- * 判据:`__inputActions` 换成新对象 = 宿主重挂了编辑器(openSession 之后必然发生)。
2003
+ * 判据:该会话的 InputActions 换成新对象 = 宿主重挂了编辑器(openSession 之后必然发生)。
2501
2004
  * 到上限仍没换(例如视图没重建的内联路径)就用当前这个提交一次 —— 宁可多一条
2502
2005
  * 兜底提示,也不要无限等。**只提交一次**:重复 submit 会发出两条消息,比失败更糟。
2503
2006
  *
2504
2007
  * @param text - 要提交的文本
2505
- * @param options - { attempts, intervalMs },测试注入更小值
2008
+ * @param options - { attempts, intervalMs, sessionId },测试注入更小值
2506
2009
  * @returns Promise<boolean> 是否成功调用了宿主 submit
2507
2010
  */
2508
2011
  function submitEditedText(text, options) {
2509
2012
  const opts = options || {}
2510
2013
  const attempts = Number.isSafeInteger(opts.attempts) && opts.attempts > 0 ? opts.attempts : EDIT_SUBMIT_ATTEMPTS
2511
2014
  const intervalMs = Number.isSafeInteger(opts.intervalMs) && opts.intervalMs >= 0 ? opts.intervalMs : EDIT_SUBMIT_INTERVAL_MS
2512
- // 0.23.0:允许真执行测试注入 inputActions(生产路径仍读模块级 __inputActions)。
2513
- // 之前测试把 deps.submitEdited 整个 stub 掉,真实提交逻辑从未被执行过。
2514
- const readInputActions = typeof opts.getInputActions === 'function' ? opts.getInputActions : () => __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)
2515
2023
  const before = readInputActions()
2516
2024
  return new Promise(resolve => {
2517
2025
  let n = 0
@@ -2602,12 +2110,25 @@ window.__ModuleLoader__.load({
2602
2110
  const doWrite = deps.writeSessionDraft || writeSessionDraft
2603
2111
  const doRead = deps.readSessionDraft || readSessionDraft
2604
2112
  const markShadowed = deps.markRowsShadowedFrom || markRowsShadowedFrom
2605
- 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
+ })
2606
2122
  const doPersistDraft =
2607
- 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
+ })
2608
2129
  const doEmitChanged = deps.emitChanged || emitChanged
2609
2130
  const doOpenSession = deps.openSessionById || openSessionById
2610
- const doSubmit = deps.submitEdited || submitEditedText
2131
+ const doSubmit = deps.submitEdited || (t => submitEditedText(t, { sessionId: rawSessionId }))
2611
2132
 
2612
2133
  // ② 防 409 护栏:本地缓存里 >= seq 的行立刻标成已遮蔽(与 runUserRevert/runUndo 同一函数)
2613
2134
  try {
@@ -3154,7 +2675,11 @@ window.__ModuleLoader__.load({
3154
2675
  const { messageId, sessionId, useSessions, inputActions, useChat } = props
3155
2676
  const t = (props && props.t) || __t
3156
2677
  useLocaleRevision()
3157
- 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])
3158
2683
  const sessions = useSessions ? useSessions(s => s) : undefined
3159
2684
  const summary = sessions && sessions.byId ? sessions.byId[sessionId] : undefined
3160
2685
  const running = summary ? summary.running === true : false
@@ -3433,9 +2958,9 @@ window.__ModuleLoader__.load({
3433
2958
  // 引用当前会话里未被遮蔽的消息 = 同一内容在 prompt 里出现两遍,纯冗余。
3434
2959
  // 所以正确做法是让位给宿主,不再重复造轮子。
3435
2960
  //
3436
- // ⚠️ 本组件**必须保留**:它负责捕获 inputActions 到 __inputActions
3437
- //(编辑框 / 面板 / 行内回填都依赖),删组件会让这些功能静默失效。
3438
- // 只 return null,不删注册。
2961
+ // ⚠️ 本组件**必须保留**:它负责按会话捕获 inputActions 到
2962
+ // __inputActionsBySession(编辑框 / 面板 / 行内回填都依赖),
2963
+ // 删组件会让这些功能静默失效。只 return null,不删注册。
3439
2964
  return null
3440
2965
  }
3441
2966
 
@@ -3496,7 +3021,11 @@ window.__ModuleLoader__.load({
3496
3021
  if (sessionId) __currentSessionId = sessionId
3497
3022
  const t = (props && props.t) || __t
3498
3023
  useLocaleRevision()
3499
- 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])
3500
3029
  const sessions = useSessions ? useSessions(s => s) : undefined
3501
3030
  const summary = sessions && sessions.byId ? sessions.byId[sessionId] : undefined
3502
3031
  const running = summary ? summary.running === true : false
@@ -4845,10 +4374,13 @@ window.__ModuleLoader__.load({
4845
4374
  // 编辑器是否已挂载、也不依赖 inputActions 此刻绑在哪个会话上。
4846
4375
  const persisted = writeSessionDraft(rawSid, text)
4847
4376
  // 再尽力更新活着的编辑器(视图没重建的路径,例如 dock 内联恢复)。
4377
+ // 0.24.0 P4:按 rawSid 取该会话自己的 InputActions;取不到就跳过 ——
4378
+ // 绝不能用别的会话的编辑器,那会把原文写进用户正在看的另一个会话。
4848
4379
  let editorSet = false
4849
- if (__inputActions && typeof __inputActions.setDraft === 'function') {
4380
+ const liveActions = inputActionsFor(rawSid)
4381
+ if (liveActions && typeof liveActions.setDraft === 'function') {
4850
4382
  try {
4851
- __inputActions.setDraft(text)
4383
+ liveActions.setDraft(text)
4852
4384
  editorSet = true
4853
4385
  } catch (e) {
4854
4386
  console.warn('[message-ops] setDraft failed:', e)
@@ -5079,7 +4611,9 @@ window.__ModuleLoader__.load({
5079
4611
  order: 101,
5080
4612
  ...(__locale ? { locale: NS } : {}),
5081
4613
  },
5082
- window.__MOPS_LEGACY_DIALOG === true ? OpsDialog : OpsPanel,
4614
+ // 0.24.0:旧对话框(约 407 行)已删除 —— 它只能通过一个从未有人
4615
+ // 设置的 LEGACY 开关到达(全仓库零处赋值)。面板是唯一实现。
4616
+ OpsPanel,
5083
4617
  ),
5084
4618
  )
5085
4619
  // 0.20.0:编辑并重发浮层(同族模态,order 102 排在 OpsPanel 之后 —— 两者互斥打开)
@@ -5108,6 +4642,12 @@ window.__ModuleLoader__.load({
5108
4642
  // 0.20.0:编辑并重发的编排层(可注入 deps 真执行断言时序)
5109
4643
  sendEditAndRevert,
5110
4644
  submitEditedText,
4645
+ // 0.24.0 P4:按会话隔离的 InputActions 访问面(真执行测试用)
4646
+ rememberInputActions,
4647
+ forgetInputActions,
4648
+ inputActionsFor,
4649
+ sessionKeyOf,
4650
+ __inputActionsBySession,
5111
4651
  EDIT_EVENT,
5112
4652
  EDIT_ID,
5113
4653
  },