dsh-message-rewind 1.5.0 → 1.6.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 +5 -2
- package/README.md +5 -2
- package/client.js +29 -9
- package/index.js +35 -11
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -34,6 +34,7 @@ Edit or roll back your own messages in [DeepSeek Harness](https://github.com/dee
|
|
|
34
34
|
| --- | --- |
|
|
35
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. |
|
|
36
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
|
+
| Fix it before resending | A rollback puts that message's text back into the composer below, so you can edit and send it again without retyping. |
|
|
37
38
|
| 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**. |
|
|
38
39
|
| Stay out of a running task | The action is refused while a turn is still running, so it never races the agent's writes. |
|
|
39
40
|
|
|
@@ -88,7 +89,7 @@ If you prefer editing the profile yourself, the manual route is the same three s
|
|
|
88
89
|
```json
|
|
89
90
|
{
|
|
90
91
|
"dependencies": {
|
|
91
|
-
"dsh-message-rewind": "^1.
|
|
92
|
+
"dsh-message-rewind": "^1.6.0"
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
```
|
|
@@ -122,7 +123,7 @@ The DSH startup log lists `message-rewind` as active. Refresh the page and your
|
|
|
122
123
|
## Usage
|
|
123
124
|
|
|
124
125
|
1. Click the pencil → a popover opens under the button; change the text and click **Save and resend**.
|
|
125
|
-
2. Click the rollback icon (the undo arrow) → click **Roll back** to return to before that message; every following turn is discarded.
|
|
126
|
+
2. Click the rollback icon (the undo arrow) → click **Roll back** to return to before that message; every following turn is discarded. The rolled-back message's text is put back into the composer below for editing and resending (text only; attachments do not return).
|
|
126
127
|
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**:
|
|
127
128
|
- **Messages only** (default) — leave files untouched;
|
|
128
129
|
- **Messages + files** — restore files to their content before that message;
|
|
@@ -154,6 +155,8 @@ The recorder compares newline-terminated text, so a restored file that had no fi
|
|
|
154
155
|
**Q: Does the sidebar get an extra conversation after a rollback?**
|
|
155
156
|
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.
|
|
156
157
|
|
|
158
|
+
The pin follows the replacement (it moves to the front of the pinned rows); the **manual sort position** is stored in the browser, which the plugin cannot read, so the row lands at the end of its group — drag it back manually.
|
|
159
|
+
|
|
157
160
|
**Q: Can the original record be recovered?**
|
|
158
161
|
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.
|
|
159
162
|
|
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
| --- | --- |
|
|
37
37
|
| 改掉已发送的消息 | 点消息气泡下方的铅笔,改完点「保存并重发」,这条消息之后的内容会被截断,然后按你改后的内容重新开始 |
|
|
38
38
|
| 回滚一条越界的消息 | 点回滚按钮(撤销箭头),确认后回到这条消息之前,之后的对话一并丢弃 |
|
|
39
|
+
| 回滚后改一改再发 | 回滚会把这条消息的文字放回下面的输入框,直接改、直接发,不用重新打字 |
|
|
39
40
|
| 连文件一起还原 | 回滚或编辑时,如果那一轮动过文件且改动记录完整,按钮下方的小窗会让你选「只回滚消息」还是「连文件一起回滚」 |
|
|
40
41
|
| 不打扰正在跑的任务 | 有未结束的轮次时直接拒绝操作,不会和正在执行的 turn 抢写 |
|
|
41
42
|
|
|
@@ -90,7 +91,7 @@ dsh plugin --profile web add dsh-message-rewind
|
|
|
90
91
|
```json
|
|
91
92
|
{
|
|
92
93
|
"dependencies": {
|
|
93
|
-
"dsh-message-rewind": "^1.
|
|
94
|
+
"dsh-message-rewind": "^1.6.0"
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
```
|
|
@@ -124,7 +125,7 @@ DSH 启动日志里会出现 `message-rewind` 且状态为 active;刷新页面
|
|
|
124
125
|
## 使用
|
|
125
126
|
|
|
126
127
|
1. 点铅笔 → 按钮下方弹出小窗,改完点「保存并重发」。
|
|
127
|
-
2. 点回滚按钮(撤销箭头)→
|
|
128
|
+
2. 点回滚按钮(撤销箭头)→ 点「回滚」,回滚这条消息及其后的全部对话;被回滚这条消息的文字会放回下方输入框,方便改完重发(只回填文字,附件不会回到输入框)。
|
|
128
129
|
3. 小窗打开时就会读取这条消息之后记录到的文件改动:默认折叠成一行「已记录 N 处文件改动」,点开可看路径;改动记录完整且有改动时还会多出一个二选一的回滚范围:
|
|
129
130
|
- **只回滚消息**(默认):文件保持现状;
|
|
130
131
|
- **连文件一起回滚**:文件恢复成这条消息之前的内容;
|
|
@@ -156,6 +157,8 @@ DSH 启动日志里会出现 `message-rewind` 且状态为 active;刷新页面
|
|
|
156
157
|
**Q:回滚之后,侧边栏是不是会多出一条对话?**
|
|
157
158
|
不会,始终只有一条对话(标题通常沿用原会话)。但底层会话 ID 会变:DSH 的会话日志是只追加的,没有「删掉中间一段」的接口,插件只能 fork 出一个截断后的分支,再把原会话从侧边栏摘掉并直接删除其日志目录;正常路径不写入归档。所以反复编辑/回滚不会在归档里堆出同名会话;如果你在别处引用过这个会话 ID,需要重新取一次。回滚的是第一条消息时,替换出来的新会话还没有标题,可能先显示默认标题。
|
|
158
159
|
|
|
160
|
+
置顶会跟着新会话走(会排在置顶区最前);但「手动排序」的位置保存在浏览器本地,插件读不到,新行会落在分组末尾,需要手动拖回原位。
|
|
161
|
+
|
|
159
162
|
**Q:原会话的记录还能找回吗?**
|
|
160
163
|
正常情况下会被直接删除,不进入归档。只有当运行中的原会话摘不掉,或日志目录被占用、删不掉时,才会退回归档兜底;失败也不会静默丢日志。
|
|
161
164
|
|
package/client.js
CHANGED
|
@@ -107,7 +107,7 @@ window.__ModuleLoader__.load({
|
|
|
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
108
|
.dmr-layer{position:fixed;inset:0;z-index:1000;pointer-events:none}
|
|
109
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}
|
|
110
|
-
.dmr-pop-edit{width:min(
|
|
110
|
+
.dmr-pop-edit{width:min(520px,calc(100vw - 16px))}
|
|
111
111
|
.dmr-pop-delete{width:min(320px,calc(100vw - 16px))}
|
|
112
112
|
.dmr-pop[data-ready]{visibility:visible}
|
|
113
113
|
.dmr-pop[data-ready][data-side=bottom]{animation:dmr-drop .15s cubic-bezier(.2,.9,.3,1) both}
|
|
@@ -121,9 +121,9 @@ window.__ModuleLoader__.load({
|
|
|
121
121
|
.dmr-head{margin:0 0 8px}
|
|
122
122
|
.dmr-title{font-size:13px;font-weight:600;line-height:19px;margin:0;color:var(--dsw-alias-label-primary)}
|
|
123
123
|
.dmr-note{font-size:12px;line-height:17px;margin:3px 0 0;color:var(--dsw-alias-label-tertiary)}
|
|
124
|
-
.dmr-body{max-height:min(
|
|
124
|
+
.dmr-body{max-height:min(72vh,calc(100vh - 150px),560px);overflow:auto;overscroll-behavior:contain}
|
|
125
125
|
.dmr-body>:first-child{margin-top:0}
|
|
126
|
-
.dmr-text{display:block;box-sizing:border-box;width:100%;min-height:
|
|
126
|
+
.dmr-text{display:block;box-sizing:border-box;width:100%;min-height:min(180px,32vh);max-height:min(52vh,480px);resize:vertical;margin:0;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);background:0 0;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;padding:8px 10px;transition:border-color .12s}
|
|
127
127
|
.dmr-text:hover{border-color:var(--dsw-alias-border-l3)}
|
|
128
128
|
.dmr-text:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
129
129
|
.dmr-files-block{margin:10px 0 0}
|
|
@@ -417,7 +417,7 @@ window.__ModuleLoader__.load({
|
|
|
417
417
|
// Session-added frame that races this reply, so pull the Session list
|
|
418
418
|
// (a refresh) until the row lands before navigating; otherwise
|
|
419
419
|
// `openSession` throws and strands the user on the source conversation.
|
|
420
|
-
async function openCreated(sessionId) {
|
|
420
|
+
async function openCreated(sessionId, draftText) {
|
|
421
421
|
const catalogued = () => {
|
|
422
422
|
try {
|
|
423
423
|
return ctx.sessions.list.getSnapshot().byId[sessionId] !== undefined;
|
|
@@ -430,6 +430,26 @@ window.__ModuleLoader__.load({
|
|
|
430
430
|
await ctx.sessions.refresh().catch(() => {});
|
|
431
431
|
}
|
|
432
432
|
ctx.uiWorkspace.openSession(sessionId);
|
|
433
|
+
restoreDraft(sessionId, draftText);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* A rollback removes the message itself, so put its text back into the
|
|
438
|
+
* replacement conversation's composer: the user can then edit and resend
|
|
439
|
+
* without retyping. The Conversation input hub exposes this draft seed
|
|
440
|
+
* (ui-workspace starts new sessions through it too); a failure must never
|
|
441
|
+
* undo the rollback that already happened.
|
|
442
|
+
*/
|
|
443
|
+
function restoreDraft(sessionId, text) {
|
|
444
|
+
if (typeof text !== 'string' || text.trim() === '') return;
|
|
445
|
+
try {
|
|
446
|
+
const binding = ctx.sessions.binding?.(sessionId);
|
|
447
|
+
const conversation = ctx.get?.('conversation');
|
|
448
|
+
if (binding === undefined || conversation === undefined) return;
|
|
449
|
+
conversation.input?.requestDraftInitialization?.(binding, { prompt: text, whenDraftExists: 'replace' });
|
|
450
|
+
} catch (error) {
|
|
451
|
+
console.warn('[message-rewind] could not put the rolled-back message back into the composer:', error instanceof Error ? error.message : String(error));
|
|
452
|
+
}
|
|
433
453
|
}
|
|
434
454
|
|
|
435
455
|
async function execute(rewindFiles) {
|
|
@@ -447,7 +467,7 @@ window.__ModuleLoader__.load({
|
|
|
447
467
|
sessionId: request.sessionId,
|
|
448
468
|
seq: request.seq,
|
|
449
469
|
action: request.kind,
|
|
450
|
-
text: request.text,
|
|
470
|
+
text: request.kind === 'edit' ? request.text : '',
|
|
451
471
|
rewindFiles,
|
|
452
472
|
clientTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
453
473
|
});
|
|
@@ -457,7 +477,7 @@ window.__ModuleLoader__.load({
|
|
|
457
477
|
// Navigate first so the source's client reference is released, then let
|
|
458
478
|
// the host retire its log: the sidebar keeps exactly one conversation.
|
|
459
479
|
try {
|
|
460
|
-
await openCreated(result.sessionId);
|
|
480
|
+
await openCreated(result.sessionId, request.kind === 'delete' ? request.text : undefined);
|
|
461
481
|
} catch (error) {
|
|
462
482
|
// The rollback happened; never retire the source the UI still shows.
|
|
463
483
|
console.warn('[message-rewind] the new conversation could not be opened:', error instanceof Error ? error.message : String(error));
|
|
@@ -520,9 +540,9 @@ window.__ModuleLoader__.load({
|
|
|
520
540
|
void inspectEdit(dialog);
|
|
521
541
|
}
|
|
522
542
|
|
|
523
|
-
function openDelete(sessionId, seq, anchor) {
|
|
543
|
+
function openDelete(sessionId, seq, text, anchor) {
|
|
524
544
|
if (writing()) return;
|
|
525
|
-
publish({ token: {}, instance: ++opens, kind: 'delete', sessionId, seq, text
|
|
545
|
+
publish({ token: {}, instance: ++opens, kind: 'delete', sessionId, seq, text, anchor: anchor ?? null, phase: 'loading', busy: true, error: null, details: null, abort: new AbortController() });
|
|
526
546
|
void check();
|
|
527
547
|
}
|
|
528
548
|
|
|
@@ -672,7 +692,7 @@ window.__ModuleLoader__.load({
|
|
|
672
692
|
const anchor = event?.currentTarget ?? null;
|
|
673
693
|
if (isOpenFor(kind, sessionId, data.seq)) { close(); return; }
|
|
674
694
|
if (kind === 'edit') openEdit(sessionId, data.seq, parts.text, anchor);
|
|
675
|
-
else openDelete(sessionId, data.seq, anchor);
|
|
695
|
+
else openDelete(sessionId, data.seq, parts.text, anchor);
|
|
676
696
|
};
|
|
677
697
|
return h('div', { className: 'dmr-row' },
|
|
678
698
|
renderFactorySlot('conversation.chat.user.content', { content, loadImage, facts, interactive: true }),
|
package/index.js
CHANGED
|
@@ -189,21 +189,45 @@ export function apply(ctx) {
|
|
|
189
189
|
return registry.list().find((workspace) => workspace.sessionIds.includes(sessionId));
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Move a source pin to the replacement branch. The registry pin set is keyed
|
|
194
|
+
* by session id, so a fork starts unpinned; `pinSession` prepends, which puts
|
|
195
|
+
* the replacement at the front of the pinned rows. Best effort on purpose: a
|
|
196
|
+
* rejected pin must never fail the rewind itself.
|
|
197
|
+
* @param sessionId - the cut source, still pinned at this point.
|
|
198
|
+
* @param childId - the replacement that receives the pin.
|
|
199
|
+
*/
|
|
200
|
+
async function carryPin(sessionId, childId) {
|
|
201
|
+
const pinned = ctx.get('workspaceRegistry')?.pinnedSessionIds;
|
|
202
|
+
if (!Array.isArray(pinned) || !pinned.includes(sessionId)) return;
|
|
203
|
+
try {
|
|
204
|
+
await ctx.workspaceController.pinSession({ sessionId: childId });
|
|
205
|
+
} catch {
|
|
206
|
+
/* the branch is live and attached; an unexpected pin refusal leaves it unpinned */
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
192
210
|
async function forkOrCreate(sessionId, boundary, meta) {
|
|
211
|
+
let childId;
|
|
193
212
|
if (boundary !== undefined) {
|
|
194
213
|
const forked = await ctx.sessionController.fork({ sessionId, atSeq: boundary });
|
|
195
|
-
|
|
214
|
+
childId = forked.sessionId;
|
|
215
|
+
} else {
|
|
216
|
+
// The first-message cut has no boundary to fork at, so it creates a fresh
|
|
217
|
+
// session. A bare `cwd` is not attached to any workspace, while the fork
|
|
218
|
+
// path is: reuse the source workspace so the conversation stays in its group.
|
|
219
|
+
const request = {};
|
|
220
|
+
const workspace = workspaceFor(sessionId);
|
|
221
|
+
if (workspace !== undefined) request.workspaceId = workspace.id;
|
|
222
|
+
else if (meta.cwd !== undefined) request.cwd = meta.cwd;
|
|
223
|
+
if (meta.agentPreset !== undefined) request.agentPreset = meta.agentPreset;
|
|
224
|
+
const created = await ctx.sessionController.create(request);
|
|
225
|
+
childId = created.sessionId;
|
|
196
226
|
}
|
|
197
|
-
//
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const workspace = workspaceFor(sessionId);
|
|
202
|
-
if (workspace !== undefined) request.workspaceId = workspace.id;
|
|
203
|
-
else if (meta.cwd !== undefined) request.cwd = meta.cwd;
|
|
204
|
-
if (meta.agentPreset !== undefined) request.agentPreset = meta.agentPreset;
|
|
205
|
-
const created = await ctx.sessionController.create(request);
|
|
206
|
-
return created.sessionId;
|
|
227
|
+
// Pin the replacement before the client can open it and before `purge`
|
|
228
|
+
// retires the source; the sidebar then shows it straight away.
|
|
229
|
+
await carryPin(sessionId, childId);
|
|
230
|
+
return childId;
|
|
207
231
|
}
|
|
208
232
|
|
|
209
233
|
async function inspect(sessionId, seq) {
|
package/package.json
CHANGED