dsh-message-rewind 1.2.4 → 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 +38 -20
- package/README.md +40 -22
- package/client.js +21 -24
- package/index.js +2 -2
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
- package/rewind.js +1 -1
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
|
-
|
|
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)
|
|
16
|
+
[](https://www.npmjs.com/package/dsh-message-rewind)
|
|
17
|
+
[](https://www.npmjs.com/package/dsh-message-rewind)
|
|
18
|
+
[](#install)
|
|
19
|
+
[](#install)
|
|
20
|
+
|
|
21
|
+
</div>
|
|
4
22
|
|
|
5
|
-
Edit
|
|
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?
|
|
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
|
-
|
|
|
19
|
-
| Restore files too | When
|
|
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/
|
|
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 /
|
|
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.
|
|
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 |
|
|
50
|
+
| Edit popover | Rollback confirmation |
|
|
33
51
|
| :---: | :---: |
|
|
34
|
-
| <img src="https://raw.githubusercontent.com/xCube007/dsh-message-rewind/main/img/edit-dialog-v1.
|
|
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.
|
|
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.
|
|
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 /
|
|
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
|
|
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 **
|
|
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, removes the original from the sidebar, and deletes its log directory directly; the normal path writes no archive entry. Repeated edits therefore do not pile up same-titled archive entries. If you referenced that session ID elsewhere, fetch it again. When the first message is
|
|
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
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
|
|
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
|
|
137
|
-
Stop the running task first; the buttons stay disabled until the turn ends. Also note that queued prompts are discarded together with the
|
|
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
|
-
|
|
9
|
+
**发错了,改掉重发**
|
|
10
|
+
|
|
11
|
+
[简体中文](README.md) · [English](README.en.md)
|
|
12
|
+
|
|
13
|
+
[功能](#它能做什么) · [界面](#界面) · [安装](#安装) · [文件回滚](#文件回滚什么能回什么回不了) · [常见问题](#常见问题)
|
|
14
|
+
|
|
15
|
+
[](LICENSE)
|
|
16
|
+
[](https://www.npmjs.com/package/dsh-message-rewind)
|
|
17
|
+
[](https://www.npmjs.com/package/dsh-message-rewind)
|
|
18
|
+
[](#%E5%AE%89%E8%A3%85)
|
|
19
|
+
[](#%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 **
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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: '
|
|
10
|
+
edit: '编辑并重发', remove: '回滚这条消息及其后的对话', copy: '复制', copied: '已复制',
|
|
11
11
|
'clock.md': '{m}月{d}日', 'clock.ymd': '{y}年{m}月{d}日',
|
|
12
|
-
cancel: '取消', loading: '正在检查文件改动…', save: '保存并重发', deleteConfirm: '
|
|
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: '
|
|
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: '
|
|
57
|
-
editTitle: 'Edit message', deleteTitle: '
|
|
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
|
|
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
|
|
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
|
|
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
|
|
86
|
-
'error.attachments': 'Messages with attachments can only be
|
|
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
|
|
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
|
|
|
@@ -582,7 +579,7 @@ window.__ModuleLoader__.load({
|
|
|
582
579
|
},
|
|
583
580
|
}, t('save'))
|
|
584
581
|
: h('button', {
|
|
585
|
-
className: 'dmr-button dmr-
|
|
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:
|
|
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(
|
|
668
|
+
button(IconRollback,
|
|
672
669
|
running ? t('running') : t('remove'),
|
|
673
670
|
(event) => openFrom('delete', event),
|
|
674
|
-
{
|
|
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() : '';
|
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
|
|
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
package/package.json
CHANGED
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--) {
|