dsh-message-rewind 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -1,11 +1,29 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/cover-v1.3.0.png" alt="dsh-message-rewind: sent it wrong? fix it and resend — edit a sent message, roll back everything after it, or roll the recorded file changes back" width="100%">
3
+ </p>
4
+
5
+ <div align="center">
6
+
1
7
  # dsh-message-rewind
2
8
 
3
- [简体中文](README.md) | **English**
9
+ **Sent it wrong? Fix it and resend.**
10
+
11
+ [简体中文](README.md) · [English](README.en.md)
12
+
13
+ [Features](#what-it-does) · [Screenshots](#screenshots) · [Install](#install) · [File rollback](#file-rollback-what-can-and-cannot-be-restored) · [FAQ](#faq)
14
+
15
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
16
+ [![npm package](https://img.shields.io/npm/v/dsh-message-rewind.svg?label=npm%20package&color=brightgreen)](https://www.npmjs.com/package/dsh-message-rewind)
17
+ [![npm downloads](https://img.shields.io/npm/dt/dsh-message-rewind.svg?label=npm%20downloads&color=orange)](https://www.npmjs.com/package/dsh-message-rewind)
18
+ [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](#install)
19
+ [![DSH up to 0.2.2-rc.3](https://img.shields.io/badge/DSH-up%20to%200.2.2--rc.3-2563eb.svg)](#install)
20
+
21
+ </div>
4
22
 
5
- Edit and delete your own messages in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness).
23
+ Edit or roll back your own messages in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness).
6
24
 
7
25
  - Typo in a sent prompt? Fix it, and the conversation continues from the edited text — no need to start over.
8
- - Said something you regret? Delete that message and every turn after it disappears with it.
26
+ - Said something you regret? Roll back that message, and every turn after it disappears with it.
9
27
  - Files changed during that turn? Optionally roll them back to the state before the message.
10
28
 
11
29
  ---
@@ -15,35 +33,35 @@ Edit and delete your own messages in [DeepSeek Harness](https://github.com/deeps
15
33
  | You want to | What the plugin does |
16
34
  | --- | --- |
17
35
  | Change a sent message | Click the pencil under your bubble, edit the text, then click **Save and resend**. Everything after that message is truncated and the conversation restarts from your edited text. |
18
- | Drop an out-of-line message | Click the trash icon and confirm. That message and every following turn are deleted. |
19
- | Restore files too | When deleting or editing, if that turn recorded file changes and the record is complete, the popover lets you choose **messages only** or **messages and files**. |
36
+ | Roll back an out-of-line message | Click the rollback icon (the undo arrow) and confirm. The conversation returns to before that message, and every following turn is discarded. |
37
+ | Restore files too | When rolling back or editing, if that turn recorded file changes and the record is complete, the popover lets you choose **messages only** or **messages and files**. |
20
38
  | Stay out of a running task | The action is refused while a turn is still running, so it never races the agent's writes. |
21
39
 
22
- Only your regular messages have these buttons; steering rows injected during a running turn do not offer edit/delete. The **Copy** button is still there, in the same position.
40
+ Only your regular messages have these buttons; steering rows injected during a running turn do not offer edit/rollback. The **Copy** button is still there, in the same position.
23
41
 
24
42
  ## Screenshots
25
43
 
26
- Your own messages get **edit / delete / copy** buttons under the bubble:
44
+ Your own messages get **edit / rollback / copy** buttons under the bubble:
27
45
 
28
- <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/message-actions-v1.2.1.png" alt="Edit, delete and copy buttons under a user message" width="760">
46
+ <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/message-actions-v1.3.0.png" alt="Edit, rollback and copy buttons under a user message" width="760">
29
47
 
30
48
  The popover opens right under the button you clicked and points at it with a small arrow; click outside or press Esc to dismiss it. The editor reads the file changes recorded after that message as soon as it opens — collapsed into one **N file changes recorded** line unless you expand it — and a two-way switch decides whether files are restored too. When the record is incomplete the switch is not offered, so only a messages-only rollback is possible:
31
49
 
32
- | Edit popover | Delete confirmation |
50
+ | Edit popover | Rollback confirmation |
33
51
  | :---: | :---: |
34
- | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/edit-dialog-v1.2.1.png" alt="Edit popover: file changes collapse to one line, rollback scope is a two-way switch" width="360"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/delete-dialog-v1.2.1.png" alt="Delete confirmation: a one-line confirm when no files changed" width="360"> |
52
+ | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/edit-dialog-v1.3.0.png" alt="Edit popover: file changes collapse to one line, rollback scope is a two-way switch" width="360"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/rollback-dialog-v1.3.0.png" alt="Rollback confirmation: a one-line confirm when no files changed" width="360"> |
35
53
 
36
54
  The popover follows its button: it flips above when there is no room below, narrows to the screen width on small viewports, and keeps the same layering in the light theme:
37
55
 
38
56
  | Flips above near the bottom | Narrow screen (390px) | Light theme |
39
57
  | :---: | :---: | :---: |
40
- | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-flip-v1.2.1.png" alt="Popover flipped above the button, arrow pointing down at it" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-narrow-v1.2.1.png" alt="Popover narrowed to a 390px viewport" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-light-v1.2.1.png" alt="Delete popover in the light theme" width="240"> |
58
+ | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-flip-v1.3.0.png" alt="Popover flipped above the button, arrow pointing down at it" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-narrow-v1.3.0.png" alt="Popover narrowed to a 390px viewport" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-light-v1.3.0.png" alt="Rollback popover in the light theme" width="240"> |
41
59
 
42
60
  When file changes were recorded, snapshot and Git-worktree limits are shown in the popover itself, not after a failed operation.
43
61
 
44
62
  ## Install
45
63
 
46
- Requires DSH 0.2.2-rc.1 or newer (0.2.x) and Node.js ≥ 20; verified on 0.2.2-rc.1. DSH validates `engines.dsh` at startup and refuses to load the plugin on an older host.
64
+ Requires DSH 0.2.2-rc.1 or newer (0.2.x) and Node.js ≥ 20; verified on 0.2.2-rc.1 and 0.2.2-rc.3. DSH validates `engines.dsh` at startup and refuses to load the plugin on an older host.
47
65
 
48
66
  ### From npm (recommended)
49
67
 
@@ -64,7 +82,7 @@ If you prefer editing the profile yourself, the manual route is the same three s
64
82
  ```json
65
83
  {
66
84
  "dependencies": {
67
- "dsh-message-rewind": "^1.2.3"
85
+ "dsh-message-rewind": "^1.3.0"
68
86
  }
69
87
  }
70
88
  ```
@@ -93,16 +111,16 @@ Use a link dependency; the remaining steps are the same:
93
111
 
94
112
  ### After installing
95
113
 
96
- The DSH startup log lists `message-rewind` as active. Refresh the page and your own message bubbles get **edit / delete / copy** buttons.
114
+ The DSH startup log lists `message-rewind` as active. Refresh the page and your own message bubbles get **edit / rollback / copy** buttons.
97
115
 
98
116
  ## Usage
99
117
 
100
118
  1. Click the pencil → a popover opens under the button; change the text and click **Save and resend**.
101
- 2. Click the trash icon → click **Delete** to remove that message and every following turn.
119
+ 2. Click the rollback icon (the undo arrow) → click **Roll back** to return to before that message; every following turn is discarded.
102
120
  3. The popover reads the file changes recorded after that message as soon as it opens and keeps them collapsed into one line; when files changed and their record is complete it also offers a two-way **Rollback scope**:
103
121
  - **Messages only** (default) — leave files untouched;
104
122
  - **Messages + files** — restore files to their content before that message;
105
- - pick the scope, then click **Save and resend** or **Delete**.
123
+ - pick the scope, then click **Save and resend** or **Roll back**.
106
124
 
107
125
  Lost or truncated snapshots, queued prompts, and non-Git workspaces are called out in one-line notes inside the popover.
108
126
 
@@ -125,16 +143,16 @@ Lost or truncated snapshots, queued prompts, and non-Git workspaces are called o
125
143
  ## FAQ
126
144
 
127
145
  **Q: Does the sidebar get an extra conversation after a rollback?**
128
- No — there is always just one conversation, and its title normally carries over. The underlying session ID does change, though: DSH session logs are append-only and have no "delete a middle chunk" API, so the plugin forks a truncated branch, archives the original out of the sidebar, and deletes its log directory. If you referenced that session ID elsewhere, fetch it again. When the first message is deleted, the replacement is a new conversation that has not been titled yet, so it may show the default title.
146
+ No — there is always just one conversation, and its title normally carries over. The underlying session ID does change, though: DSH session logs are append-only and have no "delete a middle chunk" API, so the plugin forks a truncated branch, removes the original from the sidebar, and deletes its log directory directly; the normal path writes no archive entry. Repeated edits and rollbacks therefore do not pile up same-titled archive entries. If you referenced that session ID elsewhere, fetch it again. When the first message is rolled back, the replacement is a new conversation that has not been titled yet, so it may show the default title.
129
147
 
130
148
  **Q: Can the original record be recovered?**
131
- Normally it is deleted. Only when its log directory is still held open and cannot be removed does the original stay in the archive.
149
+ Normally it is deleted outright and never reaches the archive. Only when the live session cannot be detached, or its log directory is still held open and cannot be removed, does the plugin fall back to archiving it; the log is not silently lost.
132
150
 
133
151
  **Q: Why can't messages with attachments be edited?**
134
- Attachments are stored as part of the message content, and editing only supports plain-text messages. Messages with attachments can still be deleted.
152
+ Attachments are stored as part of the message content, and editing only supports plain-text messages. Messages with attachments can still be rolled back.
135
153
 
136
- **Q: The edit and delete buttons are greyed out with a "turn is still running" note?**
137
- Stop the running task first; the buttons stay disabled until the turn ends. Also note that queued prompts are discarded together with the deleted record — the popover warns you about this.
154
+ **Q: The edit and rollback buttons are greyed out with a "turn is still running" note?**
155
+ Stop the running task first; the buttons stay disabled until the turn ends. Also note that queued prompts are discarded together with the rolled-back record — the popover warns you about this.
138
156
 
139
157
  **Q: I don't see the buttons.**
140
158
  Check that the plugin is enabled under **Settings → Plugins** and that you refreshed the page. Only messages you sent have these buttons.
package/README.md CHANGED
@@ -1,14 +1,32 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/cover-v1.3.0.png" alt="dsh-message-rewind:发错了,改掉重发 —— 编辑已发送的消息、回滚越界的对话、连文件一起回滚" width="100%">
3
+ </p>
4
+
5
+ <div align="center">
6
+
1
7
  # dsh-message-rewind
2
8
 
3
- **简体中文** | [English](README.en.md)
9
+ **发错了,改掉重发**
10
+
11
+ [简体中文](README.md) · [English](README.en.md)
12
+
13
+ [功能](#它能做什么) · [界面](#界面) · [安装](#安装) · [文件回滚](#文件回滚什么能回什么回不了) · [常见问题](#常见问题)
14
+
15
+ [![许可证 MIT](https://img.shields.io/badge/%E8%AE%B8%E5%8F%AF%E8%AF%81-MIT-blue.svg)](LICENSE)
16
+ [![npm package](https://img.shields.io/npm/v/dsh-message-rewind.svg?label=npm%20package&color=brightgreen)](https://www.npmjs.com/package/dsh-message-rewind)
17
+ [![npm 下载量](https://img.shields.io/npm/dt/dsh-message-rewind.svg?label=npm%20%E4%B8%8B%E8%BD%BD%E9%87%8F&color=orange)](https://www.npmjs.com/package/dsh-message-rewind)
18
+ [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](#%E5%AE%89%E8%A3%85)
19
+ [![DSH 支持至 0.2.2-rc.3](https://img.shields.io/badge/DSH-%E6%94%AF%E6%8C%81%E8%87%B3%200.2.2--rc.3-2563eb.svg)](#%E5%AE%89%E8%A3%85)
20
+
21
+ </div>
4
22
 
5
- 给 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 的消息气泡加两个按钮:**编辑**和**删除**。
23
+ 给 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 的消息气泡加两个按钮:**编辑**和**回滚**。
6
24
 
7
25
  - 发错字了?改一下,直接从改后的内容重新开始,不用重开对话。
8
- - 说话越界了?删掉这条,它之后的所有对话一起消失。
26
+ - 说话越界了?回滚这条消息,它之后的所有对话一起消失。
9
27
  - 那一轮还改过文件?可以顺手把文件也还原到这条消息之前的样子。
10
28
 
11
- > A DSH plugin that adds **edit** and **delete** to your own message bubbles. Deleting truncates every following turn and can optionally roll the recorded file changes back.
29
+ > A DSH plugin that adds **edit** and **rollback** to your own message bubbles. Rolling back truncates every following turn and can optionally roll the recorded file changes back.
12
30
 
13
31
  ---
14
32
 
@@ -17,35 +35,35 @@
17
35
  | 你想要的 | 插件怎么帮你 |
18
36
  | --- | --- |
19
37
  | 改掉已发送的消息 | 点消息气泡下方的铅笔,改完点「保存并重发」,这条消息之后的内容会被截断,然后按你改后的内容重新开始 |
20
- | 撤掉一条越界的消息 | 点垃圾桶,确认后这条消息连同它之后的所有对话一起删除 |
21
- | 连文件一起还原 | 删除/编辑时,如果那一轮动过文件且改动记录完整,按钮下方的小窗会让你选「只回滚消息」还是「连文件一起回滚」 |
38
+ | 回滚一条越界的消息 | 点回滚按钮(撤销箭头),确认后回到这条消息之前,之后的对话一并丢弃 |
39
+ | 连文件一起还原 | 回滚或编辑时,如果那一轮动过文件且改动记录完整,按钮下方的小窗会让你选「只回滚消息」还是「连文件一起回滚」 |
22
40
  | 不打扰正在跑的任务 | 有未结束的轮次时直接拒绝操作,不会和正在执行的 turn 抢写 |
23
41
 
24
- 只有你自己发出的普通消息才有这两个按钮;一轮运行中被追加的 steering 行不提供编辑/删除。「复制」按钮仍在,位置不变。
42
+ 只有你自己发出的普通消息才有这两个按钮;一轮运行中被追加的 steering 行不提供编辑/回滚。「复制」按钮仍在,位置不变。
25
43
 
26
44
  ## 界面
27
45
 
28
- 自己发出的消息,气泡下方会多出「编辑 / 删除 / 复制」三个按钮:
46
+ 自己发出的消息,气泡下方会多出「编辑 / 回滚 / 复制」三个按钮:
29
47
 
30
- <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/message-actions-v1.2.1.png" alt="消息气泡下方的编辑、删除、复制按钮" width="760">
48
+ <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/message-actions-v1.3.0.png" alt="消息气泡下方的编辑、回滚、复制按钮" width="760">
31
49
 
32
- 点铅笔或垃圾桶之后,小窗直接出现在那个按钮正下方,并用一个小箭头指向它;点窗外或按 Esc 就收起。编辑窗一打开就会读出这条消息之后记录到的文件改动,默认只显示一行「已记录 N 处文件改动」,展开才看具体路径;要不要连文件一起还原,用一个二选一的开关决定(记录不完整时开关不出现,只能回滚消息):
50
+ 点铅笔或回滚按钮之后,小窗直接出现在那个按钮正下方,并用一个小箭头指向它;点窗外或按 Esc 就收起。编辑窗一打开就会读出这条消息之后记录到的文件改动,默认只显示一行「已记录 N 处文件改动」,展开才看具体路径;要不要连文件一起还原,用一个二选一的开关决定(记录不完整时开关不出现,只能回滚消息):
33
51
 
34
- | 编辑小窗 | 删除确认 |
52
+ | 编辑小窗 | 回滚确认 |
35
53
  | :---: | :---: |
36
- | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/edit-dialog-v1.2.1.png" alt="编辑小窗:文件改动收起成一行,回滚范围二选一" width="360"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/delete-dialog-v1.2.1.png" alt="删除确认:没有文件改动时只剩一行确认" width="360"> |
54
+ | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/edit-dialog-v1.3.0.png" alt="编辑小窗:文件改动收起成一行,回滚范围二选一" width="360"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/rollback-dialog-v1.3.0.png" alt="回滚确认:没有文件改动时只剩一行确认" width="360"> |
37
55
 
38
56
  小窗跟着按钮走:窗口底部放不下时自动翻到按钮上方,窄屏下收窄到屏幕宽度,亮色主题也保持同一套层级:
39
57
 
40
58
  | 靠近底部时翻到上方 | 窄屏(390px) | 亮色主题 |
41
59
  | :---: | :---: | :---: |
42
- | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-flip-v1.2.1.png" alt="小窗翻到按钮上方,箭头朝下指向按钮" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-narrow-v1.2.1.png" alt="窄屏下小窗收窄到屏幕宽度" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-light-v1.2.1.png" alt="亮色主题下的删除小窗" width="240"> |
60
+ | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-flip-v1.3.0.png" alt="小窗翻到按钮上方,箭头朝下指向按钮" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-narrow-v1.3.0.png" alt="窄屏下小窗收窄到屏幕宽度" width="240"> | <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/popover-light-v1.3.0.png" alt="亮色主题下的回滚小窗" width="240"> |
43
61
 
44
62
  有文件改动时,快照失效或记录不完整、工作区不在 Git 仓库等限制也会直接标在小窗里,不用等到操作失败才知道。
45
63
 
46
64
  ## 安装
47
65
 
48
- 需要 DSH 0.2.2-rc.1 及以上(0.2.x),Node.js ≥ 20;已在 0.2.2-rc.1 上验证。宿主启动时会按 `engines.dsh` 校验,低于该版本会拒绝加载。
66
+ 需要 DSH 0.2.2-rc.1 及以上(0.2.x),Node.js ≥ 20;已在 0.2.2-rc.1 与 0.2.2-rc.3 上验证。宿主启动时会按 `engines.dsh` 校验,低于该版本会拒绝加载。
49
67
 
50
68
  ### 从 npm 安装(推荐)
51
69
 
@@ -66,7 +84,7 @@ dsh plugin --profile web add dsh-message-rewind
66
84
  ```json
67
85
  {
68
86
  "dependencies": {
69
- "dsh-message-rewind": "^1.2.3"
87
+ "dsh-message-rewind": "^1.3.0"
70
88
  }
71
89
  }
72
90
  ```
@@ -95,16 +113,16 @@ git clone https://github.com/xCube007/dsh-message-rewind.git D:/Code/dsh-message
95
113
 
96
114
  ### 装好之后
97
115
 
98
- DSH 启动日志里会出现 `message-rewind` 且状态为 active;刷新页面,你自己消息的气泡下方就会多出「编辑 / 删除 / 复制」三个按钮。
116
+ DSH 启动日志里会出现 `message-rewind` 且状态为 active;刷新页面,你自己消息的气泡下方就会多出「编辑 / 回滚 / 复制」三个按钮。
99
117
 
100
118
  ## 使用
101
119
 
102
120
  1. 点铅笔 → 按钮下方弹出小窗,改完点「保存并重发」。
103
- 2. 点垃圾桶 → 点「删除」,删除这条消息及其后的全部对话。
121
+ 2. 点回滚按钮(撤销箭头)→ 点「回滚」,回滚这条消息及其后的全部对话。
104
122
  3. 小窗打开时就会读取这条消息之后记录到的文件改动:默认折叠成一行「已记录 N 处文件改动」,点开可看路径;改动记录完整且有改动时还会多出一个二选一的回滚范围:
105
123
  - **只回滚消息**(默认):文件保持现状;
106
124
  - **连文件一起回滚**:文件恢复成这条消息之前的内容;
107
- - 选好范围后,点「保存并重发」或「删除」执行。
125
+ - 选好范围后,点「保存并重发」或「回滚」执行。
108
126
 
109
127
  快照失效或记录不完整、还有排队中的消息、工作区不在 Git 仓库等情况会在小窗里用一行提示说明。
110
128
 
@@ -127,16 +145,16 @@ DSH 启动日志里会出现 `message-rewind` 且状态为 active;刷新页面
127
145
  ## 常见问题
128
146
 
129
147
  **Q:回滚之后,侧边栏是不是会多出一条对话?**
130
- 不会,始终只有一条对话(标题通常沿用原会话)。但底层会话 ID 会变:DSH 的会话日志是只追加的,没有「删掉中间一段」的接口,插件只能 fork 出一个截断后的分支,再把原会话移出侧边栏并删除其日志目录。所以如果你在别处引用过这个会话 ID,需要重新取一次。删除的是第一条消息时,替换出来的新会话还没有标题,可能先显示默认标题。
148
+ 不会,始终只有一条对话(标题通常沿用原会话)。但底层会话 ID 会变:DSH 的会话日志是只追加的,没有「删掉中间一段」的接口,插件只能 fork 出一个截断后的分支,再把原会话从侧边栏摘掉并直接删除其日志目录;正常路径不写入归档。所以反复编辑/回滚不会在归档里堆出同名会话;如果你在别处引用过这个会话 ID,需要重新取一次。回滚的是第一条消息时,替换出来的新会话还没有标题,可能先显示默认标题。
131
149
 
132
150
  **Q:原会话的记录还能找回吗?**
133
- 正常情况下会被删除。只有当日志目录被占用删不掉时,原会话会保留在归档里。
151
+ 正常情况下会被直接删除,不进入归档。只有当运行中的原会话摘不掉,或日志目录被占用、删不掉时,才会退回归档兜底;失败也不会静默丢日志。
134
152
 
135
153
  **Q:为什么带附件的消息不能编辑?**
136
- 附件是作为消息内容的一部分存下来的,编辑只支持纯文本消息。带附件的消息可以删除。
154
+ 附件是作为消息内容的一部分存下来的,编辑只支持纯文本消息。带附件的消息可以回滚。
137
155
 
138
- **Q:编辑/删除按钮是灰的,提示「当前有未结束的轮次」?**
139
- 先停止正在运行的任务再操作;轮次结束前按钮不可用。另外,如果有排队中的消息,它们会随被删除的记录一起作废——小窗里会提示。
156
+ **Q:编辑/回滚按钮是灰的,提示「当前有未结束的轮次」?**
157
+ 先停止正在运行的任务再操作;轮次结束前按钮不可用。另外,如果有排队中的消息,它们会随被回滚的记录一起作废——小窗里会提示。
140
158
 
141
159
  **Q:看不到按钮?**
142
160
  确认插件已在「设置 → 插件」里启用、并且刷新过一次页面;另外只有你自己发的消息才有这两个按钮。
package/client.js CHANGED
@@ -7,12 +7,12 @@ window.__ModuleLoader__.load({
7
7
  const CHANNEL = '/message-rewind';
8
8
 
9
9
  const zh = {
10
- edit: '编辑并重发', remove: '删除这条消息及其后的对话', copy: '复制', copied: '已复制',
10
+ edit: '编辑并重发', remove: '回滚这条消息及其后的对话', copy: '复制', copied: '已复制',
11
11
  'clock.md': '{m}月{d}日', 'clock.ymd': '{y}年{m}月{d}日',
12
- cancel: '取消', loading: '正在检查文件改动…', save: '保存并重发', deleteConfirm: '删除', scope: '回滚范围', body: '消息内容',
13
- editTitle: '编辑消息', deleteTitle: '删除这条消息?',
12
+ cancel: '取消', loading: '正在检查文件改动…', save: '保存并重发', deleteConfirm: '回滚', scope: '回滚范围', body: '消息内容',
13
+ editTitle: '编辑消息', deleteTitle: '回滚这条消息?',
14
14
  editNote: '截断之后的对话,再按新内容重发。',
15
- deleteNote: '之后的对话会一起删除,无法恢复。',
15
+ deleteNote: '之后的对话会一起回滚,无法恢复。',
16
16
  filesCount: '已记录 {n} 处文件改动',
17
17
  messagesOnly: '只回滚消息', withFiles: '连文件一起回滚',
18
18
  fileWarning: '文件会还原到这条消息之前。',
@@ -20,11 +20,11 @@ window.__ModuleLoader__.load({
20
20
  running: '当前有未结束的轮次,请先停止运行',
21
21
  queued: '排队中的消息会一并作废。',
22
22
  noGit: '工作区不在 Git 仓库内:只有 DSH 文件工具的改动可回滚。',
23
- attachments: '含附件的消息暂时只能删除,不能编辑',
23
+ attachments: '含附件的消息暂时只能回滚,不能编辑',
24
24
  failed: '操作失败,请重试。',
25
25
  'error.invalid-message': '消息位置无效。',
26
26
  'error.stale-message': '这条消息已不在当前对话记录里,请刷新后重试。',
27
- 'error.not-user-message': '只能编辑或删除你发送的消息。',
27
+ 'error.not-user-message': '只能编辑或回滚你发送的消息。',
28
28
  'error.file-changed': '文件在记录之后又被修改过,已停止回滚,未覆盖任何文件。',
29
29
  'error.unsupported-diff': '这份文件差异暂不支持回滚。',
30
30
  'error.file-unreadable': '有文件无法读取,未回滚任何文件。',
@@ -38,8 +38,8 @@ window.__ModuleLoader__.load({
38
38
  'error.binary-file': '只能回滚文本文件。',
39
39
  'error.coarse-diff': '改动过大,无法安全回滚。',
40
40
  'error.bad-action': '操作类型无效。',
41
- 'error.open-turn': '请先停止当前运行,再编辑或删除消息。',
42
- 'error.attachments': '含附件的消息暂时只能删除,不能编辑。',
41
+ 'error.open-turn': '请先停止当前运行,再编辑或回滚消息。',
42
+ 'error.attachments': '含附件的消息暂时只能回滚,不能编辑。',
43
43
  'error.empty-message': '消息不能为空。',
44
44
  'error.incomplete-snapshot': '部分文件改动快照不可用或改动记录不完整,只能回滚消息。',
45
45
  'error.no-workspace': '这个会话没有工作区,只能回滚消息。',
@@ -51,12 +51,12 @@ window.__ModuleLoader__.load({
51
51
  'error.unknown': '操作失败,请重试。',
52
52
  };
53
53
  const en = {
54
- edit: 'Edit and resend', remove: 'Delete this message and every following turn', copy: 'Copy', copied: 'Copied',
54
+ edit: 'Edit and resend', remove: 'Roll back this message and every following turn', copy: 'Copy', copied: 'Copied',
55
55
  'clock.md': '{m}/{d}', 'clock.ymd': '{y}-{m}-{d}',
56
- cancel: 'Cancel', loading: 'Checking file changes…', save: 'Save and resend', deleteConfirm: 'Delete', scope: 'Rollback scope', body: 'Message text',
57
- editTitle: 'Edit message', deleteTitle: 'Delete this message?',
56
+ cancel: 'Cancel', loading: 'Checking file changes…', save: 'Save and resend', deleteConfirm: 'Roll back', scope: 'Rollback scope', body: 'Message text',
57
+ editTitle: 'Edit message', deleteTitle: 'Roll back this message?',
58
58
  editNote: 'Cuts off later turns, then resends.',
59
- deleteNote: 'Following turns are deleted too, for good.',
59
+ deleteNote: 'Following turns are rolled back too, for good.',
60
60
  filesCount: '{n} file changes recorded',
61
61
  messagesOnly: 'Messages only', withFiles: 'Messages + files',
62
62
  fileWarning: 'Files are restored to their state before this message.',
@@ -64,11 +64,11 @@ window.__ModuleLoader__.load({
64
64
  running: 'A turn is still running — stop it first',
65
65
  queued: 'Queued prompts are discarded too.',
66
66
  noGit: 'No Git here: only DSH file-tool edits can be rolled back.',
67
- attachments: 'Messages with attachments can only be deleted, not edited',
67
+ attachments: 'Messages with attachments can only be rolled back, not edited',
68
68
  failed: 'Operation failed. Please try again.',
69
69
  'error.invalid-message': 'Invalid message position.',
70
70
  'error.stale-message': 'This message is no longer in the conversation. Refresh and try again.',
71
- 'error.not-user-message': 'Only messages you sent can be edited or deleted.',
71
+ 'error.not-user-message': 'Only messages you sent can be edited or rolled back.',
72
72
  'error.file-changed': 'A file changed after it was recorded, so nothing was rolled back.',
73
73
  'error.unsupported-diff': 'This file diff cannot be rolled back.',
74
74
  'error.file-unreadable': 'A file could not be read, so nothing was rolled back.',
@@ -82,8 +82,8 @@ window.__ModuleLoader__.load({
82
82
  'error.binary-file': 'Only text files can be rolled back.',
83
83
  'error.coarse-diff': 'The change is too large to roll back safely.',
84
84
  'error.bad-action': 'Invalid operation.',
85
- 'error.open-turn': 'Stop the running turn before editing or deleting messages.',
86
- 'error.attachments': 'Messages with attachments can only be deleted.',
85
+ 'error.open-turn': 'Stop the running turn before editing or rolling back messages.',
86
+ 'error.attachments': 'Messages with attachments can only be rolled back.',
87
87
  'error.empty-message': 'The message cannot be empty.',
88
88
  'error.incomplete-snapshot': 'Some file snapshots are unavailable or the change record is incomplete; roll back messages only.',
89
89
  'error.no-workspace': 'This conversation has no workspace; roll back messages only.',
@@ -105,7 +105,6 @@ window.__ModuleLoader__.load({
105
105
  .dmr-action:disabled,.dmr-action[data-unavailable]{cursor:default;opacity:.4}
106
106
  .dmr-action:disabled:hover{background:0 0;color:var(--dsw-alias-label-tertiary)}
107
107
  .dmr-action:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
108
- .dmr-danger:not(:disabled):hover{color:var(--dsw-alias-state-error-primary)}
109
108
  .dmr-layer{position:fixed;inset:0;z-index:1000;pointer-events:none}
110
109
  .dmr-pop{position:fixed;z-index:1;box-sizing:border-box;visibility:hidden;pointer-events:auto;padding:14px 14px 12px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);box-shadow:var(--dsw-elevation-prominent);font-size:13px;line-height:20px}
111
110
  .dmr-pop-edit{width:min(420px,calc(100vw - 16px))}
@@ -153,8 +152,6 @@ window.__ModuleLoader__.load({
153
152
  .dmr-button:disabled{opacity:.45;cursor:not-allowed}
154
153
  .dmr-primary{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);font-weight:500;padding:5px 12px}
155
154
  .dmr-primary:not(:disabled):hover{background:var(--dsw-alias-button-primary-hover);color:var(--dsw-alias-label-primary-foreground)}
156
- .dmr-destructive{background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground);font-weight:500;padding:5px 12px}
157
- .dmr-destructive:not(:disabled):hover{background:var(--dsw-alias-state-error-primary);box-shadow:inset 0 0 0 999px rgba(0,0,0,.12);color:var(--dsw-alias-label-primary-foreground)}
158
155
  @media (prefers-reduced-motion:reduce){.dmr-pop[data-ready]{animation:none}.dmr-spinner{animation-duration:2.4s}}
159
156
  @media (max-width:480px){.dmr-pop{padding:12px 12px 10px}.dmr-pop-edit,.dmr-pop-delete{width:calc(100vw - 16px)}}
160
157
  `;
@@ -174,7 +171,7 @@ window.__ModuleLoader__.load({
174
171
  // not a plugin contract, and a missing export would blank the Chat row.
175
172
  const iconProps = { viewBox: '0 0 16 16', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, focusable: 'false' };
176
173
  function IconEdit() { return h('svg', iconProps, h('path', { d: 'M10.4 2.8l2.8 2.8L5 13.8H2.2v-2.8l8.2-8.2z' }), h('path', { d: 'M9 4.2l2.8 2.8' })); }
177
- function IconTrash() { return h('svg', iconProps, h('path', { d: 'M2.8 4.4h10.4' }), h('path', { d: 'M6.2 4.4V2.8h3.6v1.6' }), h('path', { d: 'M4.4 4.4l.6 8.8h6l.6-8.8' })); }
174
+ function IconRollback() { return h('svg', iconProps, h('path', { d: 'M5.7 3 3 5.7l2.7 2.7' }), h('path', { d: 'M3 5.7h5.8a3.6 3.6 0 0 1 0 7.2H5.5' })); }
178
175
  function IconCopy() { return h('svg', iconProps, h('rect', { x: '5.4', y: '5.4', width: '7.8', height: '7.8', rx: '1.4' }), h('path', { d: 'M3.4 10.6V4.2a1.4 1.4 0 0 1 1.4-1.4h6.4' })); }
179
176
  function IconCheck() { return h('svg', iconProps, h('path', { d: 'M2.8 8.6l3.4 3.2 7-7.4' })); }
180
177
 
@@ -457,7 +454,7 @@ window.__ModuleLoader__.load({
457
454
  .then(() => new Promise((resolveDelay) => window.setTimeout(resolveDelay, 200)))
458
455
  .then(() => remote('purge', { sessionId: source }, typeof AbortSignal.timeout === 'function' ? AbortSignal.timeout(REQUEST_TIMEOUT) : undefined))
459
456
  .then((outcome) => {
460
- if (!outcome || outcome.removed !== true) console.warn('[message-rewind] source session kept in archive:', outcome?.message ?? 'log not deleted');
457
+ if (!outcome || outcome.removed !== true) console.warn('[message-rewind] source session not fully removed:', outcome?.message ?? 'log not deleted');
461
458
  })
462
459
  .catch((error) => { console.warn('[message-rewind] purge failed:', error instanceof Error ? error.message : String(error)); });
463
460
  }
@@ -582,7 +579,7 @@ window.__ModuleLoader__.load({
582
579
  },
583
580
  }, t('save'))
584
581
  : h('button', {
585
- className: 'dmr-button dmr-destructive',
582
+ className: 'dmr-button dmr-primary',
586
583
  type: 'button',
587
584
  disabled: dialog.busy || blocked,
588
585
  onClick: () => void execute(canRollback && selected),
@@ -644,7 +641,7 @@ window.__ModuleLoader__.load({
644
641
  // never reachable, so it cannot be mis-clicked while a turn runs.
645
642
  const button = (Icon, label, onClick, options = {}) => h('button', {
646
643
  type: 'button',
647
- className: `dmr-action${options.danger ? ' dmr-danger' : ''}`,
644
+ className: 'dmr-action',
648
645
  'aria-label': label,
649
646
  'aria-disabled': options.disabled ? true : undefined,
650
647
  'data-unavailable': options.disabled ? true : undefined,
@@ -668,10 +665,10 @@ window.__ModuleLoader__.load({
668
665
  attachmentBlocked ? t('attachments') : running ? t('running') : t('edit'),
669
666
  (event) => openFrom('edit', event),
670
667
  { disabled: running || attachmentBlocked }),
671
- button(IconTrash,
668
+ button(IconRollback,
672
669
  running ? t('running') : t('remove'),
673
670
  (event) => openFrom('delete', event),
674
- { danger: true, disabled: running }),
671
+ { disabled: running }),
675
672
  button(copied ? IconCheck : IconCopy,
676
673
  copied ? t('copied') : t('copy'),
677
674
  () => copyText())));
package/index.js CHANGED
@@ -220,8 +220,8 @@ export function apply(ctx) {
220
220
  if (action !== 'delete' && action !== 'edit') throw userError('bad-action', '操作类型无效。');
221
221
  const withFiles = request?.rewindFiles === true;
222
222
  const { inspection, cut, records } = await load(sessionId, request?.seq);
223
- if (cut.hasOpenTurn) throw userError('open-turn', '请先停止当前运行,再编辑或删除消息。');
224
- if (action === 'edit' && cut.content.some((block) => block.type !== 'text')) throw userError('attachments', '含附件的消息暂时只能删除,不能编辑。');
223
+ if (cut.hasOpenTurn) throw userError('open-turn', '请先停止当前运行,再编辑或回滚消息。');
224
+ if (action === 'edit' && cut.content.some((block) => block.type !== 'text')) throw userError('attachments', '含附件的消息暂时只能回滚,不能编辑。');
225
225
  let content = cut.content;
226
226
  if (action === 'edit') {
227
227
  const replacement = typeof request?.text === 'string' ? request.text.trim() : '';
@@ -259,43 +259,123 @@ export function apply(ctx) {
259
259
  }
260
260
 
261
261
  /**
262
- * Remove a rolled-back source session for good. The harness keeps session logs
263
- * append-only and offers no delete API, so this retires the artifact instead:
264
- * archive it out of the sidebar, delete its directory, and report whether the
265
- * bytes are gone.
266
- *
267
- * The archive only cancels the running turn — the Agent stays in the session
268
- * store for this Host's lifetime — so waiting for `sessions.get()` to clear
269
- * would never finish. Deletion is attempted directly and its outcome is
270
- * reported, with liveness used only to explain a failure.
262
+ * Detach one live source Session. The store's disposal event closes its
263
+ * persistence writer and makes the harness publish `api-session/removed`, so
264
+ * the log can be deleted after the write handle is gone.
265
+ * @param sessionId - session to detach.
266
+ * @returns true when a live session was detached, false when it was cold.
267
+ * @throws when a live session is still attached afterwards.
271
268
  */
272
- async function purge(sessionId) {
269
+ async function detachSession(sessionId) {
270
+ const sessions = ctx.get('sessions');
271
+ const live = sessions?.get?.(sessionId);
272
+ if (live === undefined) return false;
273
+ // Archive used to stop queued work before hiding the session; keep that
274
+ // stop without writing an archive entry.
275
+ try { await ctx.parallel?.('workspace/session-stop', { sessionId }); } catch { /* stop is best effort */ }
276
+ try { await sessions.flush?.(live); } catch { /* the log is about to be deleted */ }
273
277
  try {
274
- await ctx.workspaceController.archiveSession({ sessionId, stopActivity: true });
278
+ const entry = sessions.liveEntryFor?.(live);
279
+ if (entry !== undefined) sessions.detachEntered?.(entry);
275
280
  } catch (error) {
276
- // Without the archive the session would stay visible after its log is gone.
277
- return { removed: false, archivedOnly: false, message: `会话归档失败,未删除任何内容:${text(error)}` };
281
+ throw new Error(`会话仍在本进程中运行,无法移除:${text(error)}`);
282
+ }
283
+ if (sessions.get?.(sessionId) !== undefined) throw new Error('会话仍在本进程中运行,无法移除。');
284
+ return true;
285
+ }
286
+
287
+ /**
288
+ * Drop the traces a deleted source session leaves outside its log: the
289
+ * archived/pinned registry flags, workspace accounting, and projection cache.
290
+ * @param sessionId - deleted session.
291
+ * @param detachedLive - whether {@link detachSession} already published its removal.
292
+ */
293
+ async function cleanupSession(sessionId, detachedLive) {
294
+ if (!detachedLive) {
295
+ try { ctx.emit?.('api-session/removed', sessionId); } catch { /* client refresh is the fallback */ }
296
+ }
297
+ const registry = ctx.get('workspaceRegistry');
298
+ try {
299
+ if (registry?.archivedSessionIds?.includes?.(sessionId) === true) {
300
+ await ctx.workspaceController.unarchiveSession({ sessionId });
301
+ }
302
+ } catch {
303
+ /* a stale archive id is cleaned up by the harness/archive surfaces */
304
+ }
305
+ try {
306
+ if (registry?.pinnedSessionIds?.includes?.(sessionId) === true) {
307
+ await ctx.workspaceController.unpinSession({ sessionId });
308
+ }
309
+ } catch {
310
+ /* a stale pin never renders a row without a session */
311
+ }
312
+ try {
313
+ const table = ctx.get('sessionProjectionCache')?.requireTable?.();
314
+ if (table !== undefined) await table.delete(sessionId);
315
+ } catch {
316
+ /* the projection cache is a fold shortcut, not an authority */
278
317
  }
318
+ try {
319
+ for (const workspace of registry?.list?.() ?? []) {
320
+ if (typeof workspace.detachSession === 'function') await workspace.detachSession(sessionId);
321
+ }
322
+ } catch {
323
+ /* stale accounting never shows a row without a live or persisted session */
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Remove a rolled-back source session for good. The harness keeps session logs
329
+ * append-only and offers no delete API, so this retires the artifact itself:
330
+ * detach the live Session, delete its directory, and drop its archive flag /
331
+ * workspace accounting / projection cache. The normal path never archives, so
332
+ * repeated rewinds cannot fill the archive with copies of one conversation.
333
+ */
334
+ async function purge(sessionId) {
279
335
  const directory = await sessionDirectory(SESSIONS_ROOT, sessionId);
280
- if (directory === undefined) return { removed: false, archivedOnly: false, message: '未找到会话日志目录,未删除任何内容。' };
281
- const live = ctx.get('sessions')?.get(sessionId) !== undefined;
336
+ let detachedLive = false;
337
+ if (directory === undefined) {
338
+ // A log another surface already removed still needs its row cleaned up.
339
+ try { detachedLive = await detachSession(sessionId); } catch { /* remove the row below */ }
340
+ await cleanupSession(sessionId, detachedLive);
341
+ return { removed: false, archivedOnly: false, message: '未找到会话日志目录,未删除任何内容。' };
342
+ }
343
+ if (ctx.get('sessions')?.get?.(sessionId) !== undefined) {
344
+ try {
345
+ detachedLive = await detachSession(sessionId);
346
+ } catch (error) {
347
+ // Leaving a live session with its log is better than deleting the log
348
+ // out from under it; hide the row with the old archive fallback.
349
+ try {
350
+ await ctx.workspaceController.archiveSession({ sessionId, stopActivity: true });
351
+ return { removed: false, archivedOnly: true, message: `${text(error)},已移出侧边栏` };
352
+ } catch (archiveError) {
353
+ return { removed: false, archivedOnly: false, message: `${text(error)};${text(archiveError)}` };
354
+ }
355
+ }
356
+ }
282
357
  let failure;
283
358
  for (let attempt = 0; attempt < 6; attempt += 1) {
284
359
  try {
285
360
  await fsp.rm(directory, { recursive: true, force: true });
286
- return { removed: true, archivedOnly: false };
361
+ failure = undefined;
362
+ break;
287
363
  } catch (error) {
288
364
  failure = error;
289
365
  await delay(250);
290
366
  }
291
367
  }
292
- return {
293
- removed: false,
294
- archivedOnly: true,
295
- message: live
296
- ? `会话仍在本进程中运行,日志目录无法删除,已移出侧边栏:${text(failure)}`
297
- : `日志目录无法删除,已移出侧边栏:${text(failure)}`,
298
- };
368
+ if (failure !== undefined) {
369
+ // Keep the old fallback only when the bytes could not be removed.
370
+ try {
371
+ await ctx.workspaceController.archiveSession({ sessionId, stopActivity: true });
372
+ return { removed: false, archivedOnly: true, message: `日志目录无法删除,已移出侧边栏:${text(failure)}` };
373
+ } catch (archiveError) {
374
+ return { removed: false, archivedOnly: false, message: `日志目录无法删除,且未能移出侧边栏:${text(failure)};${text(archiveError)}` };
375
+ }
376
+ }
377
+ await cleanupSession(sessionId, detachedLive);
378
+ return { removed: true, archivedOnly: false };
299
379
  }
300
380
 
301
381
  async function dispatch(endpoint, payload) {
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Message Edit & Rollback",
4
- "description": "Edit sent prompts or branch before a message, with an optional guarded rollback of recorded text-file changes."
4
+ "description": "Edit sent prompts or roll back a message and every following turn, with an optional guarded rollback of recorded text-file changes."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "消息编辑与回滚",
4
- "description": "编辑已发送的消息、删除该消息及后续对话,并可选择安全回滚已记录的文本文件改动。"
4
+ "description": "编辑已发送的消息、回滚该消息之后的对话,并可选择安全回滚已记录的文本文件改动。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-message-rewind",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "DeepSeek Harness plugin: edit sent messages and roll back following turns, optionally restoring recorded file changes.",
5
5
  "license": "MIT",
6
6
  "author": "xCube007",
package/rewind.js CHANGED
@@ -27,7 +27,7 @@ export function prepareCut(events, seq) {
27
27
  const position = index.get(seq);
28
28
  const target = position === undefined ? undefined : events[position];
29
29
  if (target === undefined) throw userError('stale-message', '这条消息已不在当前对话记录里,请刷新后重试。');
30
- if (target.type !== 'user/message' || target.data?.source?.kind !== 'user') throw userError('not-user-message', '只能编辑或删除你发送的消息。');
30
+ if (target.type !== 'user/message' || target.data?.source?.kind !== 'user') throw userError('not-user-message', '只能编辑或回滚你发送的消息。');
31
31
  const content = structuredClone(target.data.content ?? []);
32
32
  let boundary = position > 0 ? events[position - 1].seq : undefined;
33
33
  for (let cursor = position - 1; cursor >= 0; cursor--) {