dsh-rewind-plugin 0.1.7 → 0.1.9

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/lib/client.js +34 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  DeepSeek Harness 插件:**同一会话窗口的 in-place 对话回退**(Claude Code `/rewind` 语义)。主交互为**用户消息旁的「回退」按钮**,点击后选择回退模式;命令仅作辅助。
4
4
 
5
- > 状态:v0.1.7 已实现并发布(`dsh-rewind-plugin`,npm + GitHub Actions Trusted Publishing)。交互以 Claude Code 行为为参考,并贴合 dsh Web 实际 UI(利用现有 DOM 锚点与运行时快照,纯插件、不改仓库核心)。
5
+ > 状态:v0.1.9 已实现并发布(`dsh-rewind-plugin`,npm + GitHub Actions Trusted Publishing)。交互以 Claude Code 行为为参考,并贴合 dsh Web 实际 UI(利用现有 DOM 锚点与运行时快照,纯插件、不改仓库核心)。
6
6
 
7
- ## 实现状态(v0.1.7
7
+ ## 实现状态(v0.1.9
8
8
 
9
9
  - ✅ host 端 `/rewind` 命令(两步文本引导 + 直接执行 + `preview` 影响清单)
10
10
  - ✅ host 端变更台账(`tools/execute` 捕获 before、`tools/post-execute` 提交),按会话隔离
package/lib/client.js CHANGED
@@ -405,6 +405,7 @@ function hiddenSeqsOf(session) {
405
405
  if (node === void 0 || node.kind !== "command") continue;
406
406
  const command = node.data;
407
407
  if (command.name !== "rewind") continue;
408
+ if (command.outcome?.kind !== "success") continue;
408
409
  hidden.add(command.seq);
409
410
  const marker = command.outcome?.sourceEventSeq;
410
411
  const target = targetOfOutcome(command.outcome?.text);
@@ -500,27 +501,45 @@ function apply(ctx) {
500
501
  buttons.set(key, button);
501
502
  seat.setAttribute(REWIND_ATTACHED, "");
502
503
  };
504
+ let lastRewindSeq = -1;
505
+ let hiddenSeqsCache = null;
503
506
  const scan = () => {
504
507
  for (const [key, button] of buttons) {
505
508
  if (!button.isConnected) buttons.delete(key);
506
509
  }
507
510
  const session = sessionFor();
508
- const hiddenSeqs = session !== void 0 ? hiddenSeqsOf(session) : /* @__PURE__ */ new Set();
509
- let hiddenCount = 0;
510
- for (const seat of document.querySelectorAll(CHAT_SEAT_SELECTOR)) {
511
- const key = seat.dataset.chatAnchorKey;
512
- const anchor = key !== void 0 && session !== void 0 ? session.getSnapshot().chat.nodes.get(key)?.anchorSeq : void 0;
513
- if (anchor !== void 0 && hiddenSeqs.has(anchor)) {
514
- seat.style.display = "none";
515
- hidden.add(seat);
516
- hiddenCount += 1;
517
- } else if (hidden.has(seat)) {
518
- seat.style.display = "";
519
- hidden.delete(seat);
511
+ let newestRewind = -1;
512
+ if (session !== void 0) {
513
+ const snap = session.getSnapshot();
514
+ for (const key of snap.chat.order) {
515
+ const node = snap.chat.nodes.get(key);
516
+ if (node === void 0 || node.kind !== "command") continue;
517
+ const command = node.data;
518
+ if (command.name === "rewind" && command.outcome?.kind === "success" && command.seq > newestRewind) {
519
+ newestRewind = command.seq;
520
+ }
520
521
  }
521
522
  }
522
- if (session !== void 0) fillComposerForRewind(session, filledTargets);
523
- if (hiddenSeqs.size > 0 || hiddenCount > 0) {
523
+ if (newestRewind > lastRewindSeq) {
524
+ lastRewindSeq = newestRewind;
525
+ hiddenSeqsCache = session !== void 0 ? hiddenSeqsOf(session) : null;
526
+ if (session !== void 0) fillComposerForRewind(session, filledTargets);
527
+ }
528
+ const hiddenSeqs = hiddenSeqsCache;
529
+ let hiddenCount = 0;
530
+ if (hiddenSeqs !== null && hiddenSeqs.size > 0 && session !== void 0) {
531
+ for (const seat of document.querySelectorAll(CHAT_SEAT_SELECTOR)) {
532
+ const key = seat.dataset.chatAnchorKey;
533
+ const anchor = key !== void 0 ? session.getSnapshot().chat.nodes.get(key)?.anchorSeq : void 0;
534
+ if (anchor !== void 0 && hiddenSeqs.has(anchor)) {
535
+ seat.style.display = "none";
536
+ hidden.add(seat);
537
+ hiddenCount += 1;
538
+ } else if (hidden.has(seat)) {
539
+ seat.style.display = "";
540
+ hidden.delete(seat);
541
+ }
542
+ }
524
543
  console.info(
525
544
  `[dsh-rewind] hiding: ${hiddenCount} rows, seqs [${[...hiddenSeqs].slice(0, 20).join(", ")}${hiddenSeqs.size > 20 ? "\u2026" : ""}]`
526
545
  );
@@ -545,7 +564,7 @@ function apply(ctx) {
545
564
  }
546
565
  };
547
566
  observer = new MutationObserver(scan);
548
- observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["style"] });
567
+ observer.observe(document.body, { childList: true, subtree: true });
549
568
  scan();
550
569
  yield () => {
551
570
  observer?.disconnect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-rewind-plugin",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "DeepSeek Harness plugin: in-place conversation rewind in the same session window (Claude Code /rewind semantics) with optional workspace file restore",
5
5
  "keywords": [
6
6
  "deepseek-harness",