Repository navigation
feat(message-edit): 编辑已发送的消息并重新发送(关联 #319) - #320
Merged
Merged
Conversation
Add @eduwork/dsh-message-edit. A pencil next to each user message opens an editor; sending forks the conversation just before the message, sends the edited message as the branch's next turn, and lets the branch replace the original, which is archived unchanged. The editor keeps the message's attachments, removable one by one, and accepts new ones, uploaded before any branch exists. A Host Remote re-stages stored attachments into the branch, with access control checking both conversations. References to other conversations follow the user's edits. Steered messages show an unavailable pencil, and editing their turn says they are replaced too. Register the package for checks and publication. Its build and tests resolve DSH packages from the locked 0.2.2-rc.1 Runtime; a local browser acceptance runs the main scenarios against a synthetic model.
…tore The Remote decoded references with copies of DSH's attachment shapes, which would strip any field a later DSH adds before the Host reads the attachment. Check only the fields the method reads and keep the rest.
An editor opened before a Turn began could still fork and resend mid-Turn, leaving the original running beside its replacement. Send now waits like the pencil does, and the source is checked again right before the branch is prompted. A refusal whose unused branch cannot be archived says so. The browser acceptance now also covers queued input, resending kept stored attachments, and the pin and user title of the replacement.
JunieXD
force-pushed
the
feat/message-edit
branch
from
November 26, 2026 15:00
ed10515 to
1b771d3
Compare
JunieXD
marked this pull request as ready for review
November 26, 2026 16:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与修改
关联 #319。DSH 不支持编辑已发出的消息:会话记录只能追加,用户消息的按钮行也没有插件扩展位。本 PR 新增公共插件
@eduwork/dsh-message-edit(packages/dsh-message-edit),不修改 DSH 的 Runtime 或界面 bundle:conversation.chat.user.before入口找到所在行,再把按钮挂进这一行的按钮栏。点击后,消息气泡原地换成编辑框:Enter 发送,Shift+Enter 换行,Esc 取消,输入法选词时不抢键。eduworkMessageEdit/stageAttachments在主机内把附件登记成新对话的上传凭证,内容不经过浏览器。存储引用按 DSH 自己读附件的规则处理(session/attachment也是按引用读、不查历史),这次调用读原对话、写新对话,所以访问控制两个对话都检查;owner 以外的调用方需要访问策略明确放行这个方法。@标题文字,被引用对话的快照另存一条,直接重发会丢掉引用。编辑框按位置跟踪每个引用,发送时还原成 DSH 的引用格式,让新对话重新抓快照。规则是拿不准就去掉:改动、删除或用同样文字覆盖了引用,引用就去掉,不会把用户删掉的引用发出去。编辑框下方显示“引用会话 · …”。shell.overlay组件找到插话行再挂上去。docs/PACKAGES*.md加入这个包。构建和测试通过EDUWORK_MESSAGE_EDIT_RUNTIME使用锁定的 DSH 0.2.2-rc.3 Runtime。已实现:上面这些。计划(不在本 PR):npm 发布后另开 PR 接入桌面装配;用户消息按钮行的扩展位可以向 DSH 上游提议(
MessageIconActions已有extraActions参数),有了以后改用正式入口。验证
node scripts/packages/manage.mjs check dsh-message-edit(Node 24.22.1,锁定 rc.3 Runtime):17 项通过。覆盖分叉切点、引用的定位和跟随编辑(结果交给 DSH 自己的引用解析器核对,含转义、前缀重名、粘贴覆盖、删除方向、撤销等),以及附件重新登记、错误转换、两个会话的资源声明;附件引用里插件不读的字段原样交给 DSH 的附件存储。node --test tests/package-maintenance.test.mjs tests/ci-changes.test.mjs tests/eduwork-source-audit.test.mjs:23 项通过,1 项是需要手动开启的压力测试,跳过;pack dsh-message-edit归档检查通过(9 个文件)。node scripts/browser-test.mjs(包内本地验收,不进 CI):在锁定的 rc.3 Runtime 上起独立的 DSH 网页版,接入合成模型,DSH 数据、HOME 和默认工作区都放在输出目录。28 项通过,控制台无报错(rc.1 上 23 项也通过过)。覆盖:本机真机验收(本地 QA 应用 0.4.12,DSH 0.2.2-rc.1,学校模型):用原型做过 8 组真实发送,都通过:
搬进
packages/后,主机 Remote 增加了原对话参数。之后用本 PR 的提交1b771d3(DSH 0.2.2-rc.3)构建了本地开发版 QA 应用,注入本包,接学校模型人工试用,没有发现问题。未执行:Windows 和桌面装配验收(本 PR 不改装配)。
兼容性与后续事项
>=0.2.2-rc.1 <0.2.3-0,在 0.2.2-rc.1 和 0.2.2-rc.3 上验证过。conversation.chat.user.before所在行的[data-clock]按钮栏、data-chat-flow-kind="steering"。DSH 改了这些时,铅笔可能不显示,不影响对话本身。这些结构和分叉切点规则都由包内浏览器验收覆盖,升级 DSH 锁时需要在本地跑一次;npm run check在锁定 Runtime 变化时会由 CI 自动跑。