dsh-message-rewind 1.5.0 → 1.5.1

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
@@ -88,7 +88,7 @@ If you prefer editing the profile yourself, the manual route is the same three s
88
88
  ```json
89
89
  {
90
90
  "dependencies": {
91
- "dsh-message-rewind": "^1.5.0"
91
+ "dsh-message-rewind": "^1.5.1"
92
92
  }
93
93
  }
94
94
  ```
@@ -154,6 +154,8 @@ The recorder compares newline-terminated text, so a restored file that had no fi
154
154
  **Q: Does the sidebar get an extra conversation after a rollback?**
155
155
  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
156
 
157
+ 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.
158
+
157
159
  **Q: Can the original record be recovered?**
158
160
  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
161
 
package/README.md CHANGED
@@ -90,7 +90,7 @@ dsh plugin --profile web add dsh-message-rewind
90
90
  ```json
91
91
  {
92
92
  "dependencies": {
93
- "dsh-message-rewind": "^1.5.0"
93
+ "dsh-message-rewind": "^1.5.1"
94
94
  }
95
95
  }
96
96
  ```
@@ -156,6 +156,8 @@ DSH 启动日志里会出现 `message-rewind` 且状态为 active;刷新页面
156
156
  **Q:回滚之后,侧边栏是不是会多出一条对话?**
157
157
  不会,始终只有一条对话(标题通常沿用原会话)。但底层会话 ID 会变:DSH 的会话日志是只追加的,没有「删掉中间一段」的接口,插件只能 fork 出一个截断后的分支,再把原会话从侧边栏摘掉并直接删除其日志目录;正常路径不写入归档。所以反复编辑/回滚不会在归档里堆出同名会话;如果你在别处引用过这个会话 ID,需要重新取一次。回滚的是第一条消息时,替换出来的新会话还没有标题,可能先显示默认标题。
158
158
 
159
+ 置顶会跟着新会话走(会排在置顶区最前);但「手动排序」的位置保存在浏览器本地,插件读不到,新行会落在分组末尾,需要手动拖回原位。
160
+
159
161
  **Q:原会话的记录还能找回吗?**
160
162
  正常情况下会被直接删除,不进入归档。只有当运行中的原会话摘不掉,或日志目录被占用、删不掉时,才会退回归档兜底;失败也不会静默丢日志。
161
163
 
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
- return forked.sessionId;
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
- // The first-message cut has no boundary to fork at, so it creates a fresh
198
- // session. A bare `cwd` is not attached to any workspace, while the fork
199
- // path is: reuse the source workspace so the conversation stays in its group.
200
- const request = {};
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-message-rewind",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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",