- Início
- Plugins
- Sessões e mensagens
- dsh-edit-resend-branch
dsh-edit-resend-branch
avdice-bird/dsh-edit-resend-branch
Edits a sent message in the native composer and restores the workspace files changed after it, branching the Session at the previous turn and keeping one conversation with a version picker.
Instalar
dsh plugin --profile web add github:avdice-bird/dsh-edit-resend-branchREADME
dsh-edit-resend-branch
给 DSH 对话里的每条已发送用户消息加上 复制 / 编辑 按钮。编辑发生在底部输入栏:点编辑后在该消息之前分叉会话、把原文本和图片预填进输入框,发送时先回退这条消息之后的文件改动,再重新生成——类似 zcode 的消息编辑。
- 包名:
dsh-edit-resend-branch,profile 条目 id:edit-resend - 类型:bundle(Host
index.js+ Web Clientclient.js),无第三方依赖 - 许可:MIT(见 LICENSE)
它做什么
- 每轮自动快照:助手每次开始新一轮(
turn/start)之前,把会话工作目录提交到影子 Git 仓库。不碰你项目自己的.git,不改提交历史,也不在目录里留下任何文件。 - 消息按钮:用户消息气泡下方是复制图标和「编辑」胶囊按钮(悬停显示,触屏常显)。
- 在输入栏里编辑:
- 点「编辑」后,会话在上一轮
turn/end处分叉并自动切到分支(不是按“消息 seq−1”切,避免把原提问自己的事件带进新分支);输入框上方出现「正在编辑上一条消息 · 对话 + 文件重置 · 取消」。 - 原消息文本与图片预填进分支输入框;文档附件不会带入,提示条会标出「文件需重新添加」。
- 发送时先停掉原会话里仍在跑的回合,再在分支的第一次模型请求之前回退这条消息之后的文件改动。
- 发送后原会话被归档、分支标题改回原标题,侧栏只保留一个对话;标题旁的「版本」下拉可切回旧版本。
- 点「编辑」后,会话在上一轮
使用
- 安装并启用(插件页 → 添加插件 → 选择本目录,或
plugin_manager install_bundle)。安装后若消息上没有按钮,刷新一次页面(Ctrl+R)。 - 鼠标移到某条自己的消息上,出现复制和「编辑」。
- 点「编辑」→ 自动切到分支,输入框里已经是这条消息的文本(和图片);可以直接改、删图、换图。
- 点发送(或原生发送箭头)→ 中断原回合、回退文件、重新生成。
- 点「取消」→ 回到原会话,进入编辑前的草稿会恢复,空分支被归档。
- 编辑过程中刷新或失败:输入框上方会出现「上次编辑未发送 · 恢复编辑 / 丢弃」,恢复会重新 arm 回退并重新预填草稿。
配置
当前 DSH 版本的设置页不会把 bundle 行自己的 Config 投影成表单(ctx.settings.describe() 不列出本条目),所以两个配置项走各自的通道:
渲染优先级 priority:默认 -100,存在浏览器 localStorage:
localStorage.setItem('dsh-edit-resend-branch.priority', '-50') // 数字越小越优先;取 -1000…-1
localStorage.removeItem('dsh-edit-resend-branch.priority') // 恢复默认
改完刷新页面重新注册。与其他“消息按钮”插件冲突时用它让位或抢占。
快照目录 storeDir:bundle 的 Config 字段(patch 行可写 config: { storeDir: '...' }),或环境变量。解析顺序:
EDIT_RESEND_HOME → storeDir 配置 → DSH_PROFILE_DIR/edit-resend → ~/.dsh/edit-resend。
激活时日志会打印 [edit-resend] snapshot root: <路径>。
快照默认忽略:node_modules、.git、dist、build、out、.next、.nuxt、.svelte-kit、.turbo、.cache、target、coverage、虚拟环境、__pycache__、*.pyc、.DS_Store、Thumbs.db。
依赖与扩展点(声明)
Host 端:
export const inject = ['commands'];以ctx.get('workingDirectory')可选读取会话目录,缺失时退回session.header.cwd。- 注册隐藏命令
edit-resend(recordInput: false):arm <parent-session> <seq>登记待回退、cancel撤销、revert <seq>手动补救。 - 监听
agent/pre-step:分支第一次模型请求之前执行回退并等待完成。 - 监听
session/event的turn/start做每轮快照。
Client 端:
inject = ['slots', 'sessions', 'uiWorkspace', 'uiConversation', 'conversation', 'locale']- 使用的 slot:
conversation.chat.node,keyuser,替换官方占用(replaceRisk: shadows-shipped-ui),默认priority: -100;官方占用仍注册着,卸载后恢复。conversation.chat.commandview,keyedit-resend,渲染null,隐藏内部命令卡片。conversation.input.dock,idedit-resend:输入框上方的编辑/恢复提示条。conversation.session.header.actions,idedit-resend-versions:版本下拉。
- 使用的官方能力:
conversation.chat.user.contentFactory、ctx.sessions.binding/fork/retain/scope、ISession.command/cancel/rename/loadOlder、ctx.uiConversation(读取 Turn 边界)、ctx.conversation.input.requestDraftInitialization(预填草稿)、ctx.uiWorkspace.openSession/archiveSession/unarchiveSession、ctx.locale。 - 图片按内容寻址存储,重新读字节上传不会产生新对象;公开的 prompt/draft API 不接受既有
attachmentRef,因此无法直接按引用复用。 retain使用自定义引用来源标签editResend(SessionReferenceSourceMap可合并扩展)。
样式使用主题变量,不覆盖全局样式,不读取其他插件的 DOM 或样式。
兼容性
- 目标:DSH Web / Desktop 的 Web GUI;CLI、TUI 没有这套 slot,不适用。
engines.dsh >= 0.2.2-rc.5。 - 已验证 DSH Desktop
0.2.2-rc.5;升级后若 Chat 渲染契约或 Session Client API 变动需要同步修改。替换官方user渲染是主要版本风险点。 - 只使用官方 DSH/Cordis 接口,不依赖任何 Desktop 私有实现;没有 Desktop service 时照常加载。
- 需要系统有
git(PATH 中,或GIT_EXE指向可执行文件)。
已知行为
- 编辑是分叉,不是原地改写:在上一轮
turn/end处fork,旧会话归档、标题沿用,顶部「版本」可切回;DSH 会话日志只追加,没有删除会话的接口。 - 同一条消息只占一个分支:再次编辑同一条消息复用已有分支(必要时取消归档),不会每次新建;编辑另一条消息时,上一个没发送的分支会被归档。发送过的分支是真会话,不再复用。
- 回退发生在发送之后、模型第一步之前:发送前取消不会改文件。回退范围是该消息之后的整个工作目录(含手动改动),忽略目录里的改动不还原。
- 编辑期间不打断正在运行的回合;只有发送时才
cancel()原回合,等收敛后继续。 - 取消会恢复进入编辑前的草稿(文本与浏览器端附件);文档类附件不会带入分支;
@引用与引用块不恢复。 - 快照仓库包含工作目录中的普通文件,机密文件请自行注意。
分发
- GitHub 源码安装:
dsh plugin --profile <profile> add "github:avdice-bird/dsh-edit-resend-branch",或插件页「添加插件」粘贴仓库地址;无构建步骤。 - Release 包:仓库 Releases 附
dsh-edit-resend-branch-<version>.tgz。 - 社区目录:已提交 awesome-dsh-plugin PR,合并后会出现在插件市场的「发现」里。
- 插件市场目前没有投稿/安装器(官方市场仍在设计阶段),Community Fabric 只是 RFC;以上是当前可用的分发路径。
English
What it does — Adds copy/edit actions to every sent user message. Edit branches the Session at the previous Turn's end, opens the branch, pre-fills its composer with the text and images, and shows a bar above the composer (Editing the previous message · Conversation + files reset · Cancel). Sending stops the abandoned Turn, restores the files changed after the message before the branch's first model step, renames the branch to the original title and archives the original; a Versions picker in the header switches back.
Install — dsh plugin --profile <profile> add "github:avdice-bird/dsh-edit-resend-branch" or a local directory bundle; reload the page once. Requires git on PATH (or GIT_EXE).
Config — Renderer priority (default -100, lower wins): localStorage.setItem('dsh-edit-resend-branch.priority', '-50'), then reload. Snapshot root: EDIT_RESEND_HOME → the bundle's storeDir config → $DSH_PROFILE_DIR/edit-resend → ~/.dsh/edit-resend.
Behaviour — Editing forks instead of rewriting: the original is archived under the same title and the branch becomes the single visible conversation, with a version picker to go back. Cancel restores the composer draft you had before editing and archives the empty branch. The file restore runs after the send and before the first model request, so cancelling never touches the workspace.
Compatibility — Official DSH/Cordis APIs only, verified on DSH Desktop 0.2.2-rc.5; it replaces the shipped conversation.chat.node renderer for key user, which is the only way to add actions to a user row.
Plugins relacionados
billion-context
ranxianglei/billion-context
dsh-web-ui (dsh-chat-recovery)
zhu1090093659/dsh-web-ui
dsh-synapse
liangmianya/dsh-synapse
EduWork (dsh-side-chat)
ecnu/eduwork