归档本轮 P0/P1 bug 修复、设计审查迁移、AI selection scope 收口与 stream contract 调整,并保留当前 05 主线迁移起点。
2.7 KiB
2.7 KiB
5-18 [done][bug] AI 写正文后本地 Page Aggregate content 可能不刷新 v1
发现时间:2026-05-17
状态:
[done]关联主线:
05-editor-mainline
1. 问题定义
页面 AI 写正文后,前端本地 Page Aggregate state 只更新 persisted meta,不保证同步正文快照。editorBridge.replaceWithSnapshot 在 editor host 内派发 runtime command,但没有直接回写 reducer content。
2. 证据
- DocumentAiAgentPanel.runtime.tsx 附近处理 AI 写入后的前端状态。
- document-content.tsx 附近接收 AI 结果。
- leptos-tiptap-island-editor-host.tsx
replaceWithSnapshot只通过 editor runtime command 更新 host。
3. 影响
- 用户连续两次问 AI 时,第二次 AI context 可能仍读旧
pageClientState.content。 - 编辑器显示与 Page Aggregate reducer 状态不一致。
- AI 写入验收如果只看编辑器 DOM,可能漏掉 context stale 问题。
4. 建议修复
- AI 写入成功后应触发 Page Aggregate 回读或统一 reducer content 更新。
- AI context 应从最新 Rust Page Aggregate snapshot 读取,而不是依赖可能过期的本地 reducer。
- 增加 smoke:AI 修改正文后不刷新页面连续再问一次 AI,断言第二次 context 包含新内容。
5. 修复
- web_shell.rs 文档 session 记录
pageAggregateScriptId,明确当前 pane 对应的 Page Aggregate JSON script。 - web_shell.rs 新增
syncPageAggregateScript,在外部写入刷新得到新 aggregate 后同步__MNOTE_PAGE_AGGREGATE__。 - web_shell.rs
refreshSessionFromExternalChange更新 sessionlatestAggregate后立即同步 JSON script,使下一次页面 AI context 从最新 Rust Page Aggregate 快照读取。 - web_shell.rs 增加 shell 合同测试,防止 AI 写入刷新只更新 editor session 而不更新 Page Aggregate script 缓存。
6. 验证
cargo test --manifest-path rust/Cargo.toml -p mnote-web document_shell_returns_page_aggregate_snapshot -- --nocapture- 结果:1 passed
cargo test --manifest-path rust/Cargo.toml -p mnote-web routes::web_shell::tests -- --nocapture- 结果:10 passed