@morlay/ui-conversation-message-actions 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @morlay/ui-conversation-message-actions
2
2
 
3
- `rewind / retry / fork` 的**编排层**:在 `@morlay/session-branch` 的 provider
3
+ `rewind / retry / recall / fork` 的**编排层**:在 `@morlay/session-branch` 的 provider
4
4
  抽象之上组装完整功能(产品语义对齐 [dsh-message-edit](https://github.com/Moeblack/dsh-message-edit)),
5
- 并提供**浏览器半**(client bundle):替换 `conversation.chat.node` 渲染,
6
- user 消息行内直接挂编辑 / 重试入口。
5
+ 并提供**浏览器半**(client bundle):替换 `conversation.chat.node`
6
+ `user` / `steering` 渲染,在 user 消息行内直接挂编辑 / 重试入口。
7
7
 
8
8
  ## 服务面(`ctx.sessionEditor`)
9
9
 
@@ -13,6 +13,7 @@
13
13
  | `reroll` | 重生成最后一条已落定助手回复(使用原用户输入) |
14
14
  | `retry` | 重试任意历史回合(`truncate` 只重放目标输入 / `preserve` 重放后续全部) |
15
15
  | `rewind` | 截断式回退:原会话回退到闭合 `turn/end` 边界 |
16
+ | `recall` | 撤回 user 消息到输入框:只 `rewind` 截断,不重写、不重放(交给用户改后重发) |
16
17
  | `fork` | 从任意闭合边界派生**新会话**(唯一产生新 id 的操作) |
17
18
  | `timeline` | 版本树投影(HTTP:`GET /session-editor?sessionId=…`) |
18
19
 
@@ -28,8 +29,11 @@
28
29
  点不开的空项与轮号空洞;manualTurn 的轮号同样按保留前缀收敛(正常会话
29
30
  等于目标轮号)。版本效果仍记录**原**目标轮号(操作历史);
30
31
  - **只有 `fork` 创建新 id**(`ForkOperation` / `forkFrom`,纯 append 派生);
31
- - 版本效果事件(`session-branch/version`)携带 `ignorable: true`:live log 可见、
32
- **不落 canonical log**(rdb 持久化时过滤并稠密化剩余事件);
32
+ - **`recall` 只截断不重写**:边界与 `edit` 的轮首 user 一致(轮首整轮截断到前一轮
33
+ `turn/end`,轮内 followup exclusive drop),但只 `rewind` 即返回——不写版本效果、
34
+ 不重放;被撤回的 user 文本由浏览器半回填到 composer,用户修改后自行发送;
35
+ - 版本效果事件(`session-branch/version`)携带 `ignorable: true`:**原样落库**
36
+ (rdb 不按信封过滤,与 JSONL 一致),非 branch 读者凭信封跳过;
33
37
  - 重放输入经 agent 驱动(见下)排队到原会话,agent 基于截断后历史回复。
34
38
 
35
39
  ## agent 驱动(重放排队输入)
@@ -39,7 +43,7 @@
39
43
 
40
44
  - **live agent**(会话驻留 / 已恢复):直接 `followup` 排队,不重建、不换 id;
41
45
  编辑前只等 agent 停下(`whenIdle`),残留排队输入由 rewind 在截断后强制
42
- durable 取消(session-rdb 的 `LiveSessionHooks.inbox.clear`);
46
+ durable 取消(session-rdb 的 live 会话钩子 `inbox.clear`);
43
47
  - **cold 会话**:`resume` 已持久化会话(`create` 对已持久化日志必失败),
44
48
  resume 后 agent 驻留(不 dispose,避免 session 被移出 store 破坏客户端窗口);
45
49
  - 模型 provider/model 在 **rewind 之前**从 `request/header` 解析(就地编辑
@@ -47,15 +51,15 @@
47
51
 
48
52
  ## 浏览器半(client bundle)
49
53
 
50
- `lib/client.js` 经 `__ModuleLoader__.load` 手递,替换整个 `conversation.chat.node`:
54
+ `dist/client.js` 经 `__ModuleLoader__.load` 手递,替换 `conversation.chat.node`
55
+ 的 `user` / `steering` 渲染:
51
56
 
52
- - **shadow 注册**:12 个 key(user / steering / context / assistant-step /
53
- command / manual-compaction / compaction / model-retry / turn-error /
54
- turn-max-tokens / turn-tail / unknown)全部以 `priority: -1` 重新注册,
55
- 最低优先级渲染,shadow 上游渲染器;
56
- - **编辑 / 重试按钮只挂在 user 消息**(`UserMessageNodeView`):编辑弹窗复用
57
- dsh settings 同款 `Modal` + `Button`,输入框复用 composer-card 视觉与自动
58
- 增长;重试先弹确认;未闭合轮次不显示重试;
57
+ - **shadow 注册**:`user` / `steering` 两个 key `priority: -1` 重新注册
58
+ (最低优先级渲染,shadow 上游默认注册);其余 key 沿用上游渲染器;
59
+ - **编辑 / 重试按钮只挂在 user 消息**(`UserMessageNodeView`):编辑不再打开编辑
60
+ 弹窗,而是确认(`Modal` + `Button`)后调用 `recall`——服务端只 `rewind` 截断,
61
+ 客户端把消息文本 `setDraft` 回填到主输入框(`conversation.input`),交给用户
62
+ 修改后自行发送;重试仍先弹确认;未闭合轮次不显示重试;
59
63
  - **操作后刷新**:就地编辑后优先调用客户端会话级 `resync()`(重置窗口并重新
60
64
  拉取历史,不整页重载——rewind 的删除无法经 append-only 事件流表达,seq
61
65
  回退只做增量会残留旧节点),随后丢弃该会话的全部投影行
@@ -63,30 +67,30 @@
63
67
  前的高 seq 旧值,截断后的正确值 seq 更小,永远覆盖不上(轮次导航残留已
64
68
  删除的轮次);不可用时回退 `location.reload()`;
65
69
  - **构建约束**:client bundle 必须是**单文件**(client-modules 只服务/加载
66
- `client.js`)——`noExternal` 全内联第三方 + `inlineDynamicImports` 合并
67
- 动态 import,`@deepseek-ai/*` 一律 external(平台 seed 词或独立插件,
68
- 内联会把别的插件的 `__ModuleLoader__.load` 嵌进来导致 duplicate factory);
69
- CSS Modules 经 lightningcss 内联 + `<style data-plugin>` 注入。
70
+ `client.js`)——`deps.neverBundle` 保持 react `@deepseek-ai/*` external
71
+ (平台 seed 词或独立插件,内联会把别的插件的 `__ModuleLoader__.load` 嵌进来
72
+ 导致 duplicate factory),其余依赖全部内联,`inlineDynamicImports` 合并动态
73
+ import;CSS Modules 经 lightningcss 内联 + `<style data-plugin>` 注入。
70
74
 
71
75
  ## 分层边界
72
76
 
73
- - 数据层(`forkFrom` / `rewind` / `readBranchPrefix` / `syncLiveCursor`)来自
77
+ - 数据层(`forkFrom` / `rewind` / `readBranchPrefix`)来自
74
78
  `ctx.sessionBranch`(provider 实现,如 `@morlay/session-rdb`);
75
79
  - 本服务只做**编排**:闭合轮次扫描、版本效果事件构造、派生 seed 组装、
76
80
  rewind 命令透传、agent 驱动、HTTP 面(`POST /session-editor` 执行
77
- edit / reroll / retry / rewind / fork)。
81
+ edit / reroll / retry / rewind / recall / fork)。
78
82
 
79
83
  ## 装配
80
84
 
81
85
  ```yaml
82
86
  # cordis.patch.yml
83
87
  - insert:
84
- - id: session-editor
88
+ - id: ui-conversation-message-actions
85
89
  name: "@morlay/ui-conversation-message-actions"
86
90
  ```
87
91
 
88
- 依赖 `ctx.sessionBranch`(需先装配 `@morlay/session-rdb`
89
- provider 实现)与 `ctx.sessions`(dsh-session);`agents` 可选。
92
+ 依赖 `ctx.sessionBranch` / `ctx.sessionPersistence`(需先装配
93
+ `@morlay/session-rdb` 等 provider 实现)与 `ctx.sessions`;`agents` 可选。
90
94
 
91
95
  端到端装配真实 rdb 后端,验证 retry / rewind / fork / timeline 闭环,
92
- 以及 live 会话的 rewind(内存 log / coordinator cursor 同步)与 agent 重放。
96
+ 以及 live 会话的 rewind(内存 log 截断 / handle cursor 对齐)与 agent 重放。
package/dist/client.js CHANGED
@@ -82,6 +82,11 @@ window.__ModuleLoader__.load({
82
82
  sessionId: this.sessionId,
83
83
  toBoundary
84
84
  }),
85
+ recall: (message) => this.mutate({
86
+ action: "recall",
87
+ sessionId: this.sessionId,
88
+ eventSeq: message.eventSeq
89
+ }, () => this.setComposerDraft(message.text)),
85
90
  importSession: (file) => this.importSession(file),
86
91
  openVersion: (sessionId) => this.openWhenListed(sessionId)
87
92
  };
@@ -158,7 +163,7 @@ window.__ModuleLoader__.load({
158
163
  });
159
164
  }
160
165
  }
161
- async mutate(operation) {
166
+ async mutate(operation, onApplied) {
162
167
  if (this.store.getSnapshot().pending !== null) return false;
163
168
  this.store.update((state) => {
164
169
  state.pending = operation.action;
@@ -182,6 +187,7 @@ window.__ModuleLoader__.load({
182
187
  this.store.update((state) => {
183
188
  state.pending = null;
184
189
  });
190
+ onApplied?.();
185
191
  const result = value;
186
192
  if (String(result.sessionId) !== String(this.sessionId)) {
187
193
  await this.openWhenListed(result.sessionId);
@@ -211,6 +217,17 @@ window.__ModuleLoader__.load({
211
217
  return false;
212
218
  }
213
219
  }
220
+ /**
221
+ * 把撤回的消息文本回填到该会话的 composer 草稿(`conversation.input` 的
222
+ * `setDraft`,即主输入框的整段替换语义)。会话 scope / binding / conversation
223
+ * 服务缺失时静默跳过——撤回本身已成功,草稿回填失败不应回滚会话状态。
224
+ */
225
+ setComposerDraft(text) {
226
+ if (this.sessions.binding(this.sessionId) === void 0) return;
227
+ const scoped = this.sessions.scope(this.sessionId);
228
+ if (scoped === void 0) return;
229
+ scoped.get("conversation")?.input?.for(scoped).setDraft(text);
230
+ }
214
231
  async importSession(file) {
215
232
  if (this.store.getSnapshot().pending !== null) return false;
216
233
  this.store.update((state) => {
@@ -351,22 +368,22 @@ window.__ModuleLoader__.load({
351
368
  }
352
369
  //#endregion
353
370
  //#region \0dsh-css:/Users/morlay/src/github.com/morlay/better-session/packages/ui-conversation-message-actions/src/client/chat-node/MessageIconActions.module.css.mjs
354
- const css$2 = ".lKOSUG_actions{align-items:center;gap:10px;height:28px;display:flex}.lKOSUG_timeStart{color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px;font-size:14px;line-height:24px}.lKOSUG_timeEnd{color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-left:12px;font-size:14px;line-height:24px}.lKOSUG_runTimeDot{margin:0 10px}@media (hover:hover){[data-time-hover-root] :is(.lKOSUG_timeStart,.lKOSUG_timeEnd){opacity:0;transition:opacity 80ms}[data-time-hover-root]:hover :is(.lKOSUG_timeStart,.lKOSUG_timeEnd),[data-time-hover-root]:focus-within :is(.lKOSUG_timeStart,.lKOSUG_timeEnd){opacity:1}}.lKOSUG_action{width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:28px;justify-content:center;align-items:center;padding:6px;display:inline-flex}.lKOSUG_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.lKOSUG_action[data-unavailable]{cursor:default;opacity:.4}.lKOSUG_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.lKOSUG_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}";
355
- const tagId$2 = "@morlay/ui-conversation-message-actions/MessageIconActions.module.css";
356
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
371
+ const css$1 = ".lKOSUG_actions{align-items:center;gap:10px;height:28px;display:flex}.lKOSUG_timeStart{color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-right:12px;font-size:14px;line-height:24px}.lKOSUG_timeEnd{color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-left:12px;font-size:14px;line-height:24px}.lKOSUG_runTimeDot{margin:0 10px}@media (hover:hover){[data-time-hover-root] :is(.lKOSUG_timeStart,.lKOSUG_timeEnd){opacity:0;transition:opacity 80ms}[data-time-hover-root]:hover :is(.lKOSUG_timeStart,.lKOSUG_timeEnd),[data-time-hover-root]:focus-within :is(.lKOSUG_timeStart,.lKOSUG_timeEnd){opacity:1}}.lKOSUG_action{width:28px;height:28px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:none;border-radius:28px;justify-content:center;align-items:center;padding:6px;display:inline-flex}.lKOSUG_action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}.lKOSUG_action[data-unavailable]{cursor:default;opacity:.4}.lKOSUG_action[data-unavailable]:hover{color:var(--dsw-alias-label-tertiary);background:0 0}.lKOSUG_visuallyHidden{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}";
372
+ const tagId$1 = "@morlay/ui-conversation-message-actions/MessageIconActions.module.css";
373
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
357
374
  const tag = document.createElement("style");
358
375
  tag.dataset.plugin = "@morlay/ui-conversation-message-actions";
359
- tag.dataset.pluginCss = tagId$2;
360
- tag.textContent = css$2;
376
+ tag.dataset.pluginCss = tagId$1;
377
+ tag.textContent = css$1;
361
378
  document.head.appendChild(tag);
362
379
  }
363
380
  var MessageIconActions_module_css_default = {
364
- "runTimeDot": "lKOSUG_runTimeDot",
365
- "action": "lKOSUG_action",
381
+ "visuallyHidden": "lKOSUG_visuallyHidden",
366
382
  "actions": "lKOSUG_actions",
367
- "timeStart": "lKOSUG_timeStart",
368
383
  "timeEnd": "lKOSUG_timeEnd",
369
- "visuallyHidden": "lKOSUG_visuallyHidden"
384
+ "timeStart": "lKOSUG_timeStart",
385
+ "action": "lKOSUG_action",
386
+ "runTimeDot": "lKOSUG_runTimeDot"
370
387
  };
371
388
  //#endregion
372
389
  //#region src/client/chat-node/MessageIconActions.tsx
@@ -497,78 +514,6 @@ window.__ModuleLoader__.load({
497
514
  });
498
515
  }
499
516
  //#endregion
500
- //#region \0dsh-css:/Users/morlay/src/github.com/morlay/better-session/packages/ui-conversation-message-actions/src/client/chat-node/MessageEditDialog.module.css.mjs
501
- const css$1 = "._7VqDXa_input{box-sizing:border-box;width:100%;min-height:96px;font:inherit;border:1px solid var(--dsw-alias-border-l2-darkmode-thin);background:var(--dsw-specific-input-major);box-shadow:var(--dsw-shadow-lv2);color:var(--dsw-text,inherit);resize:none;border-radius:22px;padding:10px 16px;font-size:16px;line-height:24px;overflow-y:auto}._7VqDXa_actions{justify-content:flex-end;gap:8px;display:flex}";
502
- const tagId$1 = "@morlay/ui-conversation-message-actions/MessageEditDialog.module.css";
503
- if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
504
- const tag = document.createElement("style");
505
- tag.dataset.plugin = "@morlay/ui-conversation-message-actions";
506
- tag.dataset.pluginCss = tagId$1;
507
- tag.textContent = css$1;
508
- document.head.appendChild(tag);
509
- }
510
- var MessageEditDialog_module_css_default = {
511
- "input": "_7VqDXa_input",
512
- "actions": "_7VqDXa_actions"
513
- };
514
- //#endregion
515
- //#region src/client/chat-node/MessageEditDialog.tsx
516
- const BLOCK_TITLE = {
517
- user: "编辑用户消息",
518
- "assistant.reasoning": "编辑助手思考",
519
- "assistant.response": "编辑助手回复"
520
- };
521
- function MessageEditDialog({ block, onSave, onClose }) {
522
- const [text, setText] = (0, react.useState)(block.text);
523
- const [saving, setSaving] = (0, react.useState)(false);
524
- const inputRef = (0, react.useRef)(null);
525
- const autosize = () => {
526
- const el = inputRef.current;
527
- if (el === null) return;
528
- el.style.height = "auto";
529
- el.style.height = `${el.scrollHeight}px`;
530
- };
531
- const save = () => {
532
- if (saving) return;
533
- setSaving(true);
534
- onSave(text).then((applied) => {
535
- if (applied) onClose();
536
- else setSaving(false);
537
- });
538
- };
539
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
540
- open: true,
541
- onClose,
542
- title: BLOCK_TITLE[block.kind],
543
- closeLabel: "关闭",
544
- footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
545
- className: MessageEditDialog_module_css_default.actions,
546
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
547
- variant: "outline",
548
- onClick: onClose,
549
- disabled: saving,
550
- children: "取消"
551
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
552
- variant: "primary",
553
- onClick: save,
554
- disabled: saving,
555
- children: saving ? "保存中…" : "保存"
556
- })]
557
- }),
558
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
559
- ref: inputRef,
560
- className: MessageEditDialog_module_css_default.input,
561
- value: text,
562
- onChange: (event) => {
563
- setText(event.target.value);
564
- autosize();
565
- },
566
- autoFocus: true,
567
- rows: 4
568
- })
569
- });
570
- }
571
- //#endregion
572
517
  //#region \0dsh-css:/Users/morlay/src/github.com/morlay/better-session/packages/ui-conversation-message-actions/src/client/chat-node/MessageItem.module.css.mjs
573
518
  const css = ".okW0Ua_userRow{flex-direction:column;align-items:flex-end;gap:6px;display:flex}.okW0Ua_userStack{flex-direction:column;align-items:flex-end;gap:8px;min-width:0;max-width:min(525px,82%);display:flex}.okW0Ua_bubble{background:var(--dsw-specific-bubble);max-width:100%;color:var(--dsw-alias-label-primary);border-radius:22px;padding:10px 16px;font-size:16px;line-height:24px}.okW0Ua_contextRow,.okW0Ua_compactionRow{padding:2px 0}.okW0Ua_compactionButton{width:100%;min-width:0;height:24px;color:inherit;font:inherit;text-align:left;background:0 0;border:none;border-radius:6px;align-items:center;padding:0;display:flex}.okW0Ua_compactionButton:not(:disabled){cursor:pointer}.okW0Ua_compactionButton:not(:disabled):hover{background:var(--dsw-alias-interactive-bg-hover)}.okW0Ua_compactionLeading{width:16px;height:16px;color:var(--dsw-alias-label-secondary);flex:none;place-items:center;margin-right:6px;display:inline-grid}.okW0Ua_compactionContextIcon,.okW0Ua_compactionDisclosureIcon{grid-area:1/1;justify-content:center;align-items:center;display:inline-flex}.okW0Ua_compactionDisclosureIcon,.okW0Ua_compactionButton:not(:disabled):hover .okW0Ua_compactionContextIcon,.okW0Ua_compactionButton:not(:disabled):focus-visible .okW0Ua_compactionContextIcon{opacity:0}.okW0Ua_compactionButton:not(:disabled):hover .okW0Ua_compactionDisclosureIcon,.okW0Ua_compactionButton:not(:disabled):focus-visible .okW0Ua_compactionDisclosureIcon{opacity:1}.okW0Ua_compactionTitle{color:var(--dsw-alias-label-primary-dimmed);flex:none;font-size:14px;line-height:24px}.okW0Ua_compactionSep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}.okW0Ua_compactionSummary{min-width:0;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;flex:auto;font-size:14px;line-height:24px;overflow:hidden}.okW0Ua_compactionBody{color:var(--dsw-alias-label-tertiary);padding:4px 0 4px 22px;font-size:14px;line-height:24px}.okW0Ua_retryRow{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}.okW0Ua_retrySummary{width:fit-content;color:inherit;cursor:pointer;user-select:none;border-radius:3px;align-items:center;gap:7px;padding:2px 0;list-style:none;display:inline-flex}.okW0Ua_retrySummary::-webkit-details-marker{display:none}.okW0Ua_retrySummary:after{content:\"\";opacity:.8;border-bottom:1.5px solid;border-right:1.5px solid;width:6px;height:6px;transition:transform .12s;transform:rotate(-45deg)}.okW0Ua_retrySummary:hover{color:var(--dsw-alias-label-secondary)}.okW0Ua_retrySummary:focus-visible{outline:1.5px solid var(--dsw-alias-button-info-fill);outline-offset:2px}.okW0Ua_retryText{color:inherit}.okW0Ua_retryRow[data-active] .okW0Ua_retryText{background:linear-gradient(90deg, var(--dsw-alias-label-tertiary) 0%, var(--dsw-alias-label-tertiary) 40%, var(--dsw-alias-label-secondary) 50%, var(--dsw-alias-label-tertiary) 60%, var(--dsw-alias-label-tertiary) 100%);color:#0000;background-position:100%;background-size:200% 100%;background-clip:text;animation:1.6s ease-in-out infinite okW0Ua_retry-shimmer}.okW0Ua_retryRow[open] .okW0Ua_retrySummary:after{transform:rotate(45deg)}.okW0Ua_retryDetails{overflow-wrap:anywhere;gap:2px;margin-top:3px;padding-left:14px;font-size:12px;line-height:18px;display:grid}.okW0Ua_retryDetailLabel{color:var(--dsw-alias-label-secondary)}.okW0Ua_turnErrorRow{grid-template-columns:10px minmax(0,1fr) auto;align-items:start;gap:8px;padding:2px 0;font-size:13px;line-height:20px;display:grid}.okW0Ua_turnErrorDot{margin-top:5px}.okW0Ua_turnErrorCopy{overflow-wrap:anywhere;min-width:0}.okW0Ua_turnErrorTitle{color:var(--dsw-alias-state-error-primary);margin-right:6px;font-weight:600}.okW0Ua_turnErrorMessage{color:var(--dsw-alias-label-secondary)}.okW0Ua_turnErrorCode{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-markdown-code-block-small)}.okW0Ua_maxTokensTitle{color:var(--dsw-alias-state-warn-primary);margin-right:6px;font-weight:600}@keyframes okW0Ua_retry-shimmer{0%{background-position:100%}to{background-position:0}}@media (prefers-reduced-motion:reduce){.okW0Ua_retryRow[data-active] .okW0Ua_retryText{color:inherit;background:0 0;animation:none}}.okW0Ua_refChip{color:var(--dsw-alias-label-primary);white-space:nowrap;vertical-align:baseline;background:#6187d838;border-radius:6px;margin:0 2px;padding:0 8px;font-size:.85em;line-height:1.6;display:inline-block}.okW0Ua_confirmActions{justify-content:flex-end;gap:8px;display:flex}";
574
519
  const tagId = "@morlay/ui-conversation-message-actions/MessageItem.module.css";
@@ -580,34 +525,34 @@ window.__ModuleLoader__.load({
580
525
  document.head.appendChild(tag);
581
526
  }
582
527
  var MessageItem_module_css_default = {
583
- "compactionContextIcon": "okW0Ua_compactionContextIcon",
528
+ "retrySummary": "okW0Ua_retrySummary",
529
+ "compactionButton": "okW0Ua_compactionButton",
530
+ "contextRow": "okW0Ua_contextRow",
531
+ "retryDetailLabel": "okW0Ua_retryDetailLabel",
532
+ "compactionTitle": "okW0Ua_compactionTitle",
533
+ "compactionRow": "okW0Ua_compactionRow",
534
+ "turnErrorCopy": "okW0Ua_turnErrorCopy",
535
+ "retryDetails": "okW0Ua_retryDetails",
584
536
  "compactionDisclosureIcon": "okW0Ua_compactionDisclosureIcon",
585
537
  "compactionBody": "okW0Ua_compactionBody",
586
- "retryDetails": "okW0Ua_retryDetails",
587
- "turnErrorMessage": "okW0Ua_turnErrorMessage",
588
- "retryRow": "okW0Ua_retryRow",
538
+ "retry-shimmer": "okW0Ua_retry-shimmer",
589
539
  "bubble": "okW0Ua_bubble",
590
- "retryText": "okW0Ua_retryText",
591
- "turnErrorCode": "okW0Ua_turnErrorCode",
592
- "turnErrorRow": "okW0Ua_turnErrorRow",
593
- "maxTokensTitle": "okW0Ua_maxTokensTitle",
594
- "turnErrorCopy": "okW0Ua_turnErrorCopy",
595
- "compactionSummary": "okW0Ua_compactionSummary",
596
540
  "userRow": "okW0Ua_userRow",
597
541
  "compactionSep": "okW0Ua_compactionSep",
598
- "compactionButton": "okW0Ua_compactionButton",
599
- "contextRow": "okW0Ua_contextRow",
600
- "refChip": "okW0Ua_refChip",
601
- "userStack": "okW0Ua_userStack",
602
- "retry-shimmer": "okW0Ua_retry-shimmer",
542
+ "retryRow": "okW0Ua_retryRow",
543
+ "compactionSummary": "okW0Ua_compactionSummary",
544
+ "turnErrorTitle": "okW0Ua_turnErrorTitle",
545
+ "turnErrorCode": "okW0Ua_turnErrorCode",
603
546
  "compactionLeading": "okW0Ua_compactionLeading",
604
- "compactionRow": "okW0Ua_compactionRow",
605
- "retrySummary": "okW0Ua_retrySummary",
547
+ "turnErrorRow": "okW0Ua_turnErrorRow",
548
+ "maxTokensTitle": "okW0Ua_maxTokensTitle",
549
+ "turnErrorMessage": "okW0Ua_turnErrorMessage",
550
+ "compactionContextIcon": "okW0Ua_compactionContextIcon",
606
551
  "confirmActions": "okW0Ua_confirmActions",
607
- "retryDetailLabel": "okW0Ua_retryDetailLabel",
608
552
  "turnErrorDot": "okW0Ua_turnErrorDot",
609
- "turnErrorTitle": "okW0Ua_turnErrorTitle",
610
- "compactionTitle": "okW0Ua_compactionTitle"
553
+ "refChip": "okW0Ua_refChip",
554
+ "retryText": "okW0Ua_retryText",
555
+ "userStack": "okW0Ua_userStack"
611
556
  };
612
557
  //#endregion
613
558
  //#region src/client/chat-node/MessageItem.tsx
@@ -670,9 +615,9 @@ window.__ModuleLoader__.load({
670
615
  }), actions?.(text)]
671
616
  });
672
617
  }
673
- const UserMessageNodeView = (0, react.memo)(function UserMessageNodeView({ node, renderMessageImages, t, edit, retry }) {
618
+ const UserMessageNodeView = (0, react.memo)(function UserMessageNodeView({ node, renderMessageImages, t, recall, retry }) {
674
619
  const data = node.data;
675
- const [editing, setEditing] = (0, react.useState)(null);
620
+ const [confirmingRecall, setConfirmingRecall] = (0, react.useState)(null);
676
621
  const [confirmingRetry, setConfirmingRetry] = (0, react.useState)(false);
677
622
  const turnLocation = node.location.kind === "turn" || node.location.kind === "step" ? node.location.turn : void 0;
678
623
  const turn = turnLocation?.turn;
@@ -680,7 +625,7 @@ window.__ModuleLoader__.load({
680
625
  const textBlockIndex = data.content.findIndex((block) => block.type === "text");
681
626
  const textBlock = textBlockIndex === -1 ? void 0 : data.content[textBlockIndex];
682
627
  const onEdit = textBlock === void 0 || turn === void 0 ? void 0 : () => {
683
- setEditing({
628
+ setConfirmingRecall({
684
629
  key: `${node.anchorSeq}:${String(textBlockIndex)}`,
685
630
  turn,
686
631
  eventSeq: node.anchorSeq,
@@ -694,10 +639,28 @@ window.__ModuleLoader__.load({
694
639
  setConfirmingRetry(true);
695
640
  } : void 0;
696
641
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
697
- editing !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MessageEditDialog, {
698
- block: editing,
699
- onSave: (text) => edit(editing, text, "truncate"),
700
- onClose: () => setEditing(null)
642
+ confirmingRecall !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
643
+ open: true,
644
+ onClose: () => setConfirmingRecall(null),
645
+ title: "编辑消息",
646
+ closeLabel: "关闭",
647
+ description: "将撤回该消息及其之后的对话内容到输入框,请修改后重新发送。",
648
+ footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
649
+ className: MessageItem_module_css_default.confirmActions,
650
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
651
+ variant: "outline",
652
+ onClick: () => setConfirmingRecall(null),
653
+ children: "取消"
654
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
655
+ variant: "primary",
656
+ onClick: () => {
657
+ const target = confirmingRecall;
658
+ setConfirmingRecall(null);
659
+ recall(target);
660
+ },
661
+ children: "撤回并编辑"
662
+ })]
663
+ })
701
664
  }),
702
665
  confirmingRetry && turn !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
703
666
  open: true,
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as SessionEditorOperation, d as EditOperation, f as EditableMessageBlock, g as RewindOperation, h as RetryableTurn, m as RetryOperation, o as editableMessages, p as RerollOperation, r as closedTurns, u as retryableTurns, v as SessionEditorResult } from "./plan-BdU_mnTv.mjs";
1
+ import { _ as RewindOperation, d as EditOperation, f as EditableMessageBlock, g as RetryableTurn, h as RetryOperation, m as RerollOperation, o as editableMessages, p as RecallOperation, r as closedTurns, u as retryableTurns, v as SessionEditorOperation, y as SessionEditorResult } from "./plan-Cn3TPTa0.mjs";
2
2
  import { Context, Service } from "@deepseek-ai/cordis";
3
3
  import { Session, SessionEvent, SessionId } from "@deepseek-ai/dsh-session";
4
4
  import { BranchBoundary, BranchTimeline, BranchTimeline as BranchTimeline$1, CascadePolicy, EditableBlockKind, SESSION_BRANCH_VERSION_SCHEMA, SessionBranchVersionEvent } from "@morlay/session-branch";
@@ -58,9 +58,21 @@ declare class SessionEditor extends Service {
58
58
  edit(operation: EditOperation, signal?: AbortSignal): Promise<SessionEditorResult>;
59
59
  reroll(operation: RerollOperation, signal?: AbortSignal): Promise<SessionEditorResult>;
60
60
  retry(operation: RetryOperation, signal?: AbortSignal): Promise<SessionEditorResult>;
61
+ recall(operation: RecallOperation, signal?: AbortSignal): Promise<SessionEditorResult>;
61
62
  editableMessages(sessionId: SessionId, signal?: AbortSignal): Promise<EditableMessageBlock[]>;
62
63
  retryableTurns(sessionId: SessionId, signal?: AbortSignal): Promise<RetryableTurn[]>;
63
64
  private branchOperation;
65
+ /**
66
+ * 撤回(recall):只 rewind 截断,不重写、不重放——被撤回的 user 消息文本
67
+ * 由客户端回填到输入框,交给用户修改后重新发送。
68
+ *
69
+ * 边界与 edit 的轮首 user 一致:轮首消息整轮截断到前一轮 `turn/end`
70
+ * (无前轮则 -1),轮内 followup 只截断到该消息本身(exclusive drop),
71
+ * 避免留下悬空 `turn/start` 让下一次发送开到错误轮号。
72
+ */
73
+ private recallOperation;
74
+ /** rewind 前等待驻留 agent 到达 quiescence(无 agent / 无 live owner 时空操作)。 */
75
+ private prepareIdle;
64
76
  private readEvents;
65
77
  /**
66
78
  * rewind 前确保 agent 可驱动重放:live agent 先等待其停下(rewind 会截断其
@@ -94,4 +106,4 @@ declare module "@deepseek-ai/cordis" {
94
106
  }
95
107
  }
96
108
  //#endregion
97
- export { type BranchTimeline, type CascadePolicy, type EditOperation, type EditableBlockKind, type EditableMessageBlock, EditorAgent, EditorAgentHandle, EditorAgentRegistry, type RerollOperation, type RetryOperation, type RetryableTurn, type RewindOperation, SESSION_BRANCH_VERSION_SCHEMA, type SessionBranchVersionEvent, SessionEditor, SessionEditor as default, type SessionEditorOperation, type SessionEditorResult, closedTurns, editableMessages, retryableTurns };
109
+ export { type BranchTimeline, type CascadePolicy, type EditOperation, type EditableBlockKind, type EditableMessageBlock, EditorAgent, EditorAgentHandle, EditorAgentRegistry, type RecallOperation, type RerollOperation, type RetryOperation, type RetryableTurn, type RewindOperation, SESSION_BRANCH_VERSION_SCHEMA, type SessionBranchVersionEvent, SessionEditor, SessionEditor as default, type SessionEditorOperation, type SessionEditorResult, closedTurns, editableMessages, retryableTurns };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as SessionEditor, t as SESSION_BRANCH_VERSION_SCHEMA } from "./src-ks167MhO.mjs";
1
+ import { n as SessionEditor, t as SESSION_BRANCH_VERSION_SCHEMA } from "./src-Dq1X3rOO.mjs";
2
2
  import { closedTurns, editableMessages, retryableTurns } from "./plan.mjs";
3
3
  export { SESSION_BRANCH_VERSION_SCHEMA, SessionEditor, SessionEditor as default, closedTurns, editableMessages, retryableTurns };
@@ -25,13 +25,18 @@ interface RewindOperation {
25
25
  sessionId: SessionId;
26
26
  toBoundary: number;
27
27
  }
28
+ interface RecallOperation {
29
+ action: "recall";
30
+ sessionId: SessionId;
31
+ eventSeq: number;
32
+ }
28
33
  interface ForkOperation {
29
34
  action: "fork";
30
35
  sessionId: SessionId;
31
36
  atSeq?: number;
32
37
  childSessionId?: SessionId;
33
38
  }
34
- type SessionEditorOperation = EditOperation | RerollOperation | RetryOperation | RewindOperation | ForkOperation;
39
+ type SessionEditorOperation = EditOperation | RerollOperation | RetryOperation | RewindOperation | RecallOperation | ForkOperation;
35
40
  interface SessionEditorResult {
36
41
  sessionId: SessionId;
37
42
  queuedTurns: number;
@@ -90,4 +95,4 @@ declare function editPlan(operation: EditOperation, turns: readonly ClosedTurn[]
90
95
  declare function retryPlan(operation: RetryOperation, turns: readonly ClosedTurn[]): OperationPlan;
91
96
  declare function rerollPlan(operation: RerollOperation, turns: readonly ClosedTurn[]): OperationPlan;
92
97
  //#endregion
93
- export { SessionEditorOperation as _, editPlan as a, rerollPlan as c, EditOperation as d, EditableMessageBlock as f, RewindOperation as g, RetryableTurn as h, downstreamUsers as i, retryPlan as l, RetryOperation as m, OperationPlan as n, editableMessages as o, RerollOperation as p, closedTurns as r, precedingContentIndex as s, ClosedTurn as t, retryableTurns as u, SessionEditorResult as v };
98
+ export { RewindOperation as _, editPlan as a, rerollPlan as c, EditOperation as d, EditableMessageBlock as f, RetryableTurn as g, RetryOperation as h, downstreamUsers as i, retryPlan as l, RerollOperation as m, OperationPlan as n, editableMessages as o, RecallOperation as p, closedTurns as r, precedingContentIndex as s, ClosedTurn as t, retryableTurns as u, SessionEditorOperation as v, SessionEditorResult as y };
package/dist/plan.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as editPlan, c as rerollPlan, i as downstreamUsers, l as retryPlan, n as OperationPlan, o as editableMessages, r as closedTurns, s as precedingContentIndex, t as ClosedTurn, u as retryableTurns } from "./plan-BdU_mnTv.mjs";
1
+ import { a as editPlan, c as rerollPlan, i as downstreamUsers, l as retryPlan, n as OperationPlan, o as editableMessages, r as closedTurns, s as precedingContentIndex, t as ClosedTurn, u as retryableTurns } from "./plan-Cn3TPTa0.mjs";
2
2
  export { ClosedTurn, OperationPlan, closedTurns, downstreamUsers, editPlan, editableMessages, precedingContentIndex, rerollPlan, retryPlan, retryableTurns };
@@ -159,6 +159,9 @@ var SessionEditor = class extends Service {
159
159
  retry(operation, signal) {
160
160
  return this.branchOperation(operation, signal);
161
161
  }
162
+ recall(operation, signal) {
163
+ return this.recallOperation(operation, signal);
164
+ }
162
165
  async editableMessages(sessionId, signal) {
163
166
  const events = await this.readEvents(sessionId, signal);
164
167
  return editableMessages(closedTurns(events));
@@ -225,6 +228,41 @@ var SessionEditor = class extends Service {
225
228
  live: this.ctx.sessions.get(operation.sessionId) !== void 0
226
229
  };
227
230
  }
231
+ /**
232
+ * 撤回(recall):只 rewind 截断,不重写、不重放——被撤回的 user 消息文本
233
+ * 由客户端回填到输入框,交给用户修改后重新发送。
234
+ *
235
+ * 边界与 edit 的轮首 user 一致:轮首消息整轮截断到前一轮 `turn/end`
236
+ * (无前轮则 -1),轮内 followup 只截断到该消息本身(exclusive drop),
237
+ * 避免留下悬空 `turn/start` 让下一次发送开到错误轮号。
238
+ */
239
+ async recallOperation(operation, signal) {
240
+ signal?.throwIfAborted();
241
+ const events = await this.readEvents(operation.sessionId, signal);
242
+ const turns = closedTurns(events);
243
+ const turnIndex = turns.findIndex((turn) => operation.eventSeq > turn.startSeq && (turn.endSeq === void 0 || operation.eventSeq < turn.endSeq));
244
+ const turn = turns[turnIndex];
245
+ if (turn === void 0) throw new SessionBranchError("所选消息不属于已落定回合。", "INVALID_BOUNDARY");
246
+ const userIndex = turn.users.findIndex((user) => user.seq === operation.eventSeq);
247
+ if (userIndex === -1) throw new SessionBranchError("所选消息不存在或不可撤回。", "INVALID_BOUNDARY");
248
+ const preceding = precedingContentIndex(turns, turnIndex);
249
+ const boundary = userIndex === 0 ? preceding < 0 ? -1 : turns[preceding].endSeq : operation.eventSeq;
250
+ await this.prepareIdle(operation.sessionId, signal);
251
+ await this.ctx.sessionBranch.rewind(operation.sessionId, boundary, signal);
252
+ return {
253
+ sessionId: operation.sessionId,
254
+ queuedTurns: 0,
255
+ live: this.ctx.sessions.get(operation.sessionId) !== void 0
256
+ };
257
+ }
258
+ /** rewind 前等待驻留 agent 到达 quiescence(无 agent / 无 live owner 时空操作)。 */
259
+ async prepareIdle(sessionId, signal) {
260
+ signal?.throwIfAborted();
261
+ const existing = this.ctx.get("agents")?.get(sessionId);
262
+ if (existing === void 0) return;
263
+ await existing.whenIdle();
264
+ signal?.throwIfAborted();
265
+ }
228
266
  async readEvents(sessionId, signal) {
229
267
  const live = this.ctx.sessions.get(sessionId);
230
268
  if (live !== void 0) return live.snapshotEvents();
@@ -320,13 +358,18 @@ function decodeOperation(value) {
320
358
  sessionId,
321
359
  toBoundary: integerOf(record["toBoundary"], "toBoundary")
322
360
  };
361
+ case "recall": return {
362
+ action: "recall",
363
+ sessionId,
364
+ eventSeq: integerOf(record["eventSeq"], "eventSeq")
365
+ };
323
366
  case "fork": return {
324
367
  action: "fork",
325
368
  sessionId,
326
369
  ...record["atSeq"] === void 0 ? {} : { atSeq: integerOf(record["atSeq"], "atSeq") },
327
370
  ...record["childSessionId"] === void 0 ? {} : { childSessionId: sessionIdOf(record["childSessionId"]) }
328
371
  };
329
- default: throw new TypeError("action 必须是 edit、reroll、retry、rewind 或 fork。");
372
+ default: throw new TypeError("action 必须是 edit、reroll、retry、rewind、recall 或 fork。");
330
373
  }
331
374
  }
332
375
  function requestJson(request) {
@@ -389,6 +432,14 @@ async function runOperation(editor, operation) {
389
432
  sessionId: operation.sessionId,
390
433
  queuedTurns: 0
391
434
  };
435
+ case "recall": {
436
+ const result = await editor.recall(operation);
437
+ return {
438
+ sessionId: result.sessionId,
439
+ queuedTurns: result.queuedTurns,
440
+ ...result.live === void 0 ? {} : { live: result.live }
441
+ };
442
+ }
392
443
  case "fork": return {
393
444
  sessionId: await editor.fork(operation.sessionId, operation.atSeq, operation.childSessionId),
394
445
  queuedTurns: 0