fix(mnote-web): 即时显示页面内新建思维导图
This commit is contained in:
+12
-4
@@ -145,6 +145,10 @@
|
||||
- `create` 成功后立即插入 Page Tree 行,以及 File Tree 的 `doc:<id>` / `index:<id>` 行。
|
||||
- `purge/delete/archive` 成功后立即从 Page Tree 与 File Tree 移除目标页面行。
|
||||
- 命令成功后清理按钮 pending 状态,避免无整页刷新时按钮残留禁用。
|
||||
6. `rust/crates/mnote-web/src/ssr/pages/layout.rs`
|
||||
- 追加修复 Rust 3000 页面内 mindmap 创建路径:主文档壳现在同时监听 `wolai:assets-changed`,并观察同页 `/api/mindmap/<doc>/<mindmap>` POST 成功请求。
|
||||
- mindmap 创建成功后立即把 `mindmap-<id>.json` 作为 File Tree asset row 插入当前页面下,避免等刷新后 projection 才出现。
|
||||
- 这覆盖 Leptos/Rust island 未触发 React `emitAssetsChanged()` 的路径。
|
||||
|
||||
2026-05-14 回归复现与补修:
|
||||
|
||||
@@ -152,6 +156,8 @@
|
||||
- 复现证据:旧 3000 进程为 `/mnt/Data1T/mnote/rust/target/debug/mnote-web (deleted)`;点击“新建页面”后接口返回成功并跳转到 `/documents/tree_1778714360642_10?...`,但 5 秒后 `#sidebar-tree-root` 仍不包含该 document id。
|
||||
- 当前源码 3002 在补修前也复现同类问题:新建后跳转到 `/documents/tree_1778714400752_12?...`,但 Page Tree DOM 不包含当前 document id。
|
||||
- 补修后已重启 3000,并在 3000 主入口完成新建/删除无刷新 smoke。
|
||||
- 用户继续复测确认页面新建/删除已恢复,但页面内新建思维导图仍需刷新。真实 smoke 复核后确认:3000 页面内导图创建会走 `/api/mindmap/<doc>/<mindmap>` 写入链路,主文档壳原先没有把该成功写入同步 materialize 到 File Tree asset row。
|
||||
- 补修后已在 3000 主入口通过 slash 菜单真实新建思维导图,并确认 File Tree 无刷新出现 `asset:<mindmapId>` 行。
|
||||
|
||||
## 7. 验收标准
|
||||
|
||||
@@ -159,7 +165,7 @@
|
||||
|
||||
1. [x] 在 `http://127.0.0.1:3000/documents/<id>` 主页面壳中新建页面后,不刷新浏览器即可在 Page Tree 与 File Tree 中看到新页面。代码证据:React Sidebar 路径由 `handleCreate()` 本地 upsert documents;Rust 3000 主文档壳由 `tree:local-command` 本地插入 Page Tree 行与 File Tree `doc:<id>` / `index:<id>` 行;单测覆盖:`sidebar-local-projection.test.ts`,Rust runtime 覆盖:`cargo test -p mnote-web sidebar_tree_runtime -- --nocapture`。
|
||||
2. [x] 在主页面壳中删除页面后,不刷新浏览器即可在 Page Tree 与 File Tree 中看到目标页面消失。代码证据:React Sidebar 路径由 `handleDelete()` / `handleDeleteResourceSelection()` 同步 `removeSidebarDocumentRecords()`;Rust 3000 主文档壳由 `tree:local-command` 在 `purge/delete/archive` 成功后调用 remove delta 本地移除;单测覆盖:`sidebar-local-projection.test.ts` 与 `sidebar-delete-preflight-source.test.ts`,Rust runtime 覆盖:`cargo test -p mnote-web sidebar_tree_runtime -- --nocapture`。
|
||||
3. [x] 在主页面壳中新建 mindmap 后,不刷新浏览器即可在 File Tree 中看到对应 `mindmap-<id>.json` 行。代码证据:`emitAssetsChanged(asset)` 已进入本地 `mindmapAssets`,`localFileTreeProjection` 用本地 mindmap assets 重建 asset row;单测覆盖:`sidebar-local-projection.test.ts`。
|
||||
3. [x] 在主页面壳中新建 mindmap 后,不刷新浏览器即可在 File Tree 中看到对应 `mindmap-<id>.json` 行。代码证据:React Sidebar 路径由 `emitAssetsChanged(asset)` 进入本地 `mindmapAssets` 并重建 asset row;Rust 3000 主文档壳由 `wolai:assets-changed` listener 和 `/api/mindmap/<doc>/<mindmap>` POST observer 本地插入 File Tree asset row;单测覆盖:`sidebar-local-projection.test.ts`,Rust runtime 覆盖:`cargo test -p mnote-web sidebar_tree_runtime -- --nocapture`。
|
||||
4. [x] 上述三条路径均不得依赖 `window.location.reload()` 或顶层 navigation。代码证据:本轮没有新增 reload;create/delete 以本地 state/projection apply 为主,显式 refetch 仅作 snapshot 校准。
|
||||
5. [x] smoke 需要记录事件或本地 apply 标记、最终 DOM 状态与相关网络请求。React Sidebar 路径保留 `tmp/task426-sidebar-main-no-reload-smoke/result.json` 作为 Next/3001 与 mindmap asset 证据;Rust 3000 主文档壳新增 `tmp/task426-mnote-web-main-no-reload-smoke/result.json`,覆盖真实 3000 页面新建/删除无刷新 DOM 结果。代码级测试同时覆盖:`sidebar-delete-preflight-source.test.ts` 锁定 create/delete 事件与本地 documents apply;`use-sidebar-data.test.tsx` 锁定 Convex live 显式 refetch 会真实拉 `/api/sidebar`;`cargo test -p mnote-web sidebar_tree_runtime -- --nocapture` 锁定 Rust 主文档壳 runtime 基础行为。
|
||||
6. [x] 修复后补测试,防止 `sidebarQuery.refetch()` 在 Convex live 模式下继续作为空操作吞掉显式刷新请求。测试覆盖:`use-sidebar-data.test.tsx`。
|
||||
@@ -195,10 +201,12 @@ MNOTE_UI_BASE_URL=http://127.0.0.1:3000 node scripts/task426-mnote-web-main-no-r
|
||||
|
||||
- `ok=true`
|
||||
- `baseUrl=http://127.0.0.1:3000`
|
||||
- `createdDocumentId=tree_1778715292685_1`
|
||||
- 新建后:`localApplied=create`、`pageRows=1`、`fileRows=["doc:tree_1778715292685_1","index:tree_1778715292685_1"]`
|
||||
- `createdDocumentId=tree_1778720530823_2`
|
||||
- `mindmapId=mindmap_1778720531308`
|
||||
- 新建页面后:`localApplied=create`、`pageRows=1`、`fileRows=["doc:tree_1778720530823_2","index:tree_1778720530823_2"]`
|
||||
- 新建思维导图后:`localApplied=true`、`rows=[{"rowId":"asset:mindmap_1778720531308","docId":"tree_1778720530823_2","title":"mindmap-mindmap_1778720531308.json…","kind":"mindmap"}]`
|
||||
- 删除后:`localApplied=remove`、`pageRows=0`、`fileRows=[]`
|
||||
- `requests` 仅包含两次 `POST /api/tree/commands`,无浏览器刷新依赖
|
||||
- `requests` 包含两次 `POST /api/tree/commands`、一次 mindmap projection GET、两次 `/api/mindmap/<doc>/<mindmap>` POST;无浏览器刷新依赖
|
||||
- 结果文件:`tmp/task426-mnote-web-main-no-reload-smoke/result.json`
|
||||
|
||||
补充对比:
|
||||
|
||||
Reference in New Issue
Block a user