XSJUSTC/dsh-rewind
DSH(DeepSeek Harness)对话回退插件——回退至任意用户消息,中断正在进行的回合,从聊天视图和模型上下文中隐藏尾部内容,发送前可自由取消。
项目介绍Project Overview
DSH 会话回退插件,为 DeepSeek Harness 对话提供「撤销到任一用户消息」能力。点击用户消息旁的 ↺ 图标即打断当前回合、隐藏该消息及之后内容、将原文回填至输入框可编辑再发;待发送状态下输入框上方显示横幅,发送按钮左侧出现 ✕ 取消回溯。它通过修补 Session.deriveMessages() 在模型侧截断上下文,append-only 日志不删原消息,仅追加 hook/invoked 事件供跨重启重建。安装需 dsh plugin add 绝对路径后重启 DSH 并刷新页面;注意:仅用户消息可回退,DSH 助手消息无入口。
DSH rewind plugin for DeepSeek Harness lets users roll back chat to any prior user message. A ↺ icon next to each user message cancels the in-flight turn, hides that message and everything after it, and refills the original text into the input box for editing. A banner and an ✕ cancel button appear while the rollback is pending. Context truncation happens by patching Session.deriveMessages(), so the append-only log keeps all original events and only records phase transitions for crash-safe restoration. Install via dsh plugin --profile web add <path>, then restart DSH and refresh the browser. Caveat: only user messages expose the rewind entry; assistant messages cannot be rolled back.
请帮我了解并安装插件:【dsh-rewind】【https://github.com/XSJUSTC/dsh-rewind】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add github:XSJUSTC/dsh-rewind
把 XSJUSTC/dsh-rewind 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
@xsj/dsh-rewind
English | 简体中文
DSH(DeepSeek Harness)会话回退插件。永久 bundle 插件:宿主机半 + Web 客户端半,零依赖、零构建步骤。
功能

- 每条用户消息的操作行(复制图标旁)出现 ↺ 回退 图标。点击后:
- 若模型正在思考/输出,立即打断当前回合;
- 该消息及其后的所有内容在聊天视图中隐藏(如同从未发生);
- 该消息文本自动填入输入框,未发送、可编辑;
- 下一次发送时,模型只看到截断后的历史(回退点之前)+ 新消息。
- 回退待发送期间:
- 输入框上方出现提示横幅;
- 发送按钮左侧出现 ✕「取消回溯」:点击后恢复被隐藏的消息,草稿保持不变,不发送任何内容。
- 发送后(回退生效):被隐藏的消息永远不再出现在聊天视图,也不再进入模型上下文。
- 仅用户消息可回退;DSH(助手)消息没有回退入口(Host 侧强制校验事件类型)。
日志与可恢复性
- 会话日志(append-only 事件流)从不删除任何原始消息。
- 每次状态变化追加一条
hook/invoked事件,负载为{ source: 'xsj.rewind', phase: 'mark' | 'cancel' | 'commit', targetSeq, hiddenFrom?, hiddenTo?, preview? }。 该事件类型属于本构建的已知保留词条(无读写方),重载安全。 - 进程重启后打开会话,Host 半会回放这些记录重建隐藏区间:模型侧与 UI 侧的隐藏状态跨重启保持一致。
- 「轨迹」视图不渲染该保留事件类型;审计请直接查看会话 JSONL 日志。
安装
# 在任意目录执行(路径指向本仓库克隆位置):
dsh plugin --profile web add <本仓库目录的绝对路径>
# 重启 DSH 进程,并刷新浏览器页面
该命令会把包登记进 profile(~/.dsh/profiles/<name>/package.json 的
dependencies + dsh.profile.bundles),profile 启动时合并本包的
cordis.patch.yml 插入宿主机插件行,Web 客户端扫描自动加载 lib/client.js。
卸载
dsh plugin --profile web remove @xsj/dsh-rewind
# 重启 DSH。会话日志中的 rewind 记录无害保留(hook/invoked 为已知类型)。
实现要点
- 模型侧截断:按需修补 live
Session对象的deriveMessages(),按已提交区间过滤 surface 节点(带签名缓存)。请求构建、llm/stream重放不变量、图片检查全部走同一入口,天然一致。 日志不增删改任何消息事件。 - 打断:mark 时若代理正在运行,
agent.cancel({ kind: 'user' }, { keepInbox: true })中断当前回合;排队消息保留,随后从截断点继续。 - 生效点:
agent/pre-step瀑布中,待回退会话一旦有新输入消息进入步骤即提交隐藏区间[targetSeq, 当前日志末尾];新消息在此之后追加,不受影响。 - UI 隐藏:聊天行包裹元素带
data-chat-flow-key,插件按隐藏集合动态维护一条display:none样式;取消/切换会话即还原,不改动任何既有渲染器。 - 回退图标:以 priority
-1接管conversation.chat.node的user/steering渲染器(槽位系统的原生遮蔽机制),行内复刻原生气泡(MessageText / ImageGallery / Tooltip / writeClipboard),追加 ↺ 按钮。
移植
本插件无任何 npm 依赖:Host 半只用 Node 内置模块与注入服务,Client 半经
window.__ModuleLoader__ 从外壳的冻结模块表取 react /
@deepseek-ai/dsh-client-ui-primitives / @deepseek-ai/dsh-client-ui-attachment。
克隆本仓库到任意机器后按「安装」一节操作即可。
ruvnet/ruflo
amruthpillai/reactive-resume
volcengine/OpenViking
Molunerfinn/PicGo
titanwings/colleague-skill
nocobase/nocobase
Tencent/WeKnora