2026-05-18 17:01:35 +08:00
|
|
|
# 5-18 [done][bug] AI 写正文后本地 Page Aggregate content 可能不刷新 v1
|
2026-05-17 23:09:56 +08:00
|
|
|
|
|
|
|
|
> 发现时间:2026-05-17
|
|
|
|
|
>
|
2026-05-18 17:01:35 +08:00
|
|
|
> 状态:`[done]`
|
2026-05-17 23:09:56 +08:00
|
|
|
>
|
|
|
|
|
> 关联主线:`05-editor-mainline`
|
|
|
|
|
|
|
|
|
|
## 1. 问题定义
|
|
|
|
|
|
|
|
|
|
页面 AI 写正文后,前端本地 Page Aggregate state 只更新 persisted meta,不保证同步正文快照。`editorBridge.replaceWithSnapshot` 在 editor host 内派发 runtime command,但没有直接回写 reducer content。
|
|
|
|
|
|
|
|
|
|
## 2. 证据
|
|
|
|
|
|
|
|
|
|
- [DocumentAiAgentPanel.runtime.tsx](/mnt/Data1T/mnote/wolai-frontend/src/components/editor/DocumentAiAgentPanel.runtime.tsx:913) 附近处理 AI 写入后的前端状态。
|
|
|
|
|
- [document-content.tsx](/mnt/Data1T/mnote/wolai-frontend/src/components/editor/document-content.tsx:876) 附近接收 AI 结果。
|
|
|
|
|
- [leptos-tiptap-island-editor-host.tsx](/mnt/Data1T/mnote/wolai-frontend/src/components/editor/leptos-tiptap-island-editor-host.tsx:772) `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 包含新内容。
|
|
|
|
|
|
2026-05-18 17:01:35 +08:00
|
|
|
## 5. 修复
|
2026-05-17 23:09:56 +08:00
|
|
|
|
2026-05-18 17:01:35 +08:00
|
|
|
- [web_shell.rs](/mnt/Data1T/mnote/rust/crates/mnote-web/src/routes/web_shell.rs:1208) 文档 session 记录 `pageAggregateScriptId`,明确当前 pane 对应的 Page Aggregate JSON script。
|
|
|
|
|
- [web_shell.rs](/mnt/Data1T/mnote/rust/crates/mnote-web/src/routes/web_shell.rs:1213) 新增 `syncPageAggregateScript`,在外部写入刷新得到新 aggregate 后同步 `__MNOTE_PAGE_AGGREGATE__`。
|
|
|
|
|
- [web_shell.rs](/mnt/Data1T/mnote/rust/crates/mnote-web/src/routes/web_shell.rs:1624) `refreshSessionFromExternalChange` 更新 session `latestAggregate` 后立即同步 JSON script,使下一次页面 AI context 从最新 Rust Page Aggregate 快照读取。
|
|
|
|
|
- [web_shell.rs](/mnt/Data1T/mnote/rust/crates/mnote-web/src/routes/web_shell.rs:3085) 增加 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
|