[F967] chat 图表消息渲染引用解析后的最新版本(编辑保存后消息内不刷新即更新,刷新后仍保留)
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 7m
- Merged PRs (30d)
- 969
Description
## 交付契约(user_visible_behavior)
在项目线程里,一条含 mermaid/工作坊画布围栏的消息「最大化」编辑并保存后:关闭编辑器(不刷新页面)即可在消息气泡的只读预览里看到编辑后的内容;整页刷新后重新打开该线程,消息气泡里仍是编辑后的内容,不再退回消息发出那一刻的原始文本。消息正文本身不可变、不被改写;编辑产生的每个版本继续独立落成 chat_artifact_landings 行(可查历史,不覆盖旧行)——只读预览渲染的是「这条消息名下最新的落地版本」,不是消息 text 字面内容。个人线程(无项目上下文)行为不变,仍渲染消息原始文本。
## Story
[requirements/08-chat/uc-8-3-对话产出落地.md](https://github.com/boardx/workspacex/blob/main/phases/phase-01-run-a-project/requirements/08-chat/uc-8-3-对话产出落地.md) — 章节 `R6`
## 验证(完成的唯一标准:每条命令退出码 0)
- [ ] `pnpm --filter web run typecheck`
- [ ] `pnpm --filter web exec vitest run tests/ui/chat-diagram-saved-readback.test.tsx tests/ui/chat-diagram-save-gate.test.tsx tests/ui/markdown-message.test.tsx tests/ui/chat-canvas-fence.test.tsx`
- [ ] `pnpm exec tsx .harness/scripts/with-test-isolation.ts -- pnpm --filter web exec playwright test e2e/chat-diagram-save-reopen-roundtrip.spec.ts --config playwright.chat-read.config.ts`
证据落盘:`phases/phase-01-run-a-project/sprints/sprint-19/evidence/F967.verify.log`
## 实现指引(notes)
依据等级:[人类直接裁决,issue #1668,2026-08-20]。人类原话:「评估回写原消息的实现,并执行,所有的图表应该是独立的存储,类似于一个独立的文件可以被引用和搜索,自然也可以独立的编辑和迭代」。技术方案见 design-delta `chat-diagram-artifact-reference`(phases/phase-01-run-a-project/design-deltas/chat-diagram-artifact-reference/contract.md)——不改 packages/contracts/src/chat.ts(零契约面变化),复用 design-delta chat-persona-roundtrip(G1,confirmed 2026-08-18)已签核实现的 (threadId,messageId)→最新落地 artifact 读回机制,把它从「只服务编辑器重开」扩到「也服务消息只读渲染」,并给编辑器保存加 onSaved 回调做即时回显(不必等下一次网络往返)。改动文件:apps/web/lib/chat/diagram-readback.ts(新增 useLiveDiagramSource hook)、chat-diagram-fabric.tsx/chat-diagram-canvas-modal.tsx(mermaid 标准图表)、chat-canvas-fabric.tsx/chat-canvas-modal.tsx(工作坊画布模板围栏,与 mermaid 共享同一套 G1 读回逻辑,一并同步修,避免修一半留下新的不一致,见 contract.md §4)。真栈 e2e 追加在既有 chat-diagram-save-reopen-roundtrip.spec.ts 里(同一条覆盖 G2 路径的用例,新增两条正向反证:不刷新即更新 / 刷新后仍保留,均用只读预览 canvas 的像素级 dataURL 对照断言,因为 fabric 渲染到 canvas 没有可断言的文本节点)。属 chat 束内部渲染路径收敛,不新增用户可见的持久化能力面。
## 设计参照
(无 UI 或沿用现有界面)
## 前置依赖
- 无
## 元数据
| phase | sprint | 能力平面 | 优先级 | wave | area |
|---|---|---|---|---|---|
| 01 | 19 | - | Pundefined | - | undefined |
## 开工流程(agent 必读)
> 本 issue 是仓库的**只读投影**;权威是 [`phases/phase-01-run-a-project/feature_list.json`](https://github.com/boardx/workspacex/blob/main/phases/phase-01-run-a-project/feature_list.json)。若两者不一致,以仓库为准。
1. 环境:`./init.sh`(验证失败先修基础状态,别在坏地基上开工)。
2. 认领:`pnpm harness claim --phase 01 --feature F967 --owner <你的-agent-id>`(同一 owner 同时最多一个 in_progress)。
3. 读上下文:[`requirements/`](https://github.com/boardx/workspacex/blob/main/phases/phase-01-run-a-project/requirements)(原始需求)、[`contracts/`](https://github.com/boardx/workspacex/blob/main/phases/phase-01-run-a-project/contracts)(本 feature 所属契约束:`ui.md` 给组件落点与 data-testid,`usecases.md` 给失败模式,`design-signoff.md` 给签核状态)、[`sprints/sprint-19/session-handoff.md`](https://github.com/boardx/workspacex/blob/main/phases/phase-01-run-a-project/sprints/sprint-19/session-handoff.md)(上一轮交接)。
4. 实现:只做本 feature 的最小实现,不顺手重构无关区域;不碰 `active-features.json`(脚本派生只读)。
5. 验证:逐条跑上方 verification,输出留到 `phases/phase-01-run-a-project/sprints/sprint-19/evidence/F967.verify.log`;然后 `pnpm harness verify --sprint 01/19 --feature F967` 门控转 passing——**不允许手改 status**。
6. 提交:分支 `worker/-01-f967-`,PR 关联本 issue(`Closes #<本 issue 号>`),收尾更新 progress.md 与 session-handoff.md。
完整硬约束见 [`AGENTS.md`](https://github.com/boardx/workspacex/blob/main/AGENTS.md);多 agent 协作规则见 [`.harness/instructions/multi-agent-coordination.md`](https://github.com/boardx/workspacex/blob/main/.harness/instructions/multi-agent-coordination.md)。
Contributor guide
No contributing guide indexed for this repository
Research direction
Read apps/web/lib/chat/diagram-readback.ts and the four listed chat diagram/canvas components, then inspect chat-diagram-save-reopen-roundtrip.spec.ts and the referenced Vitest tests. Run the three verification commands. Done means project-thread read-only previews show the latest saved artifact immediately and after reload, while personal threads and the original message text remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- playwright, typescript
- Domain
- frontend, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100