Files
mnote/bugs/05-editor-mainline/done/5-34-starred-scope-pagetree-and-local-edit-save-v1.md

25 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 5-34 [done] 星标 scoped 文件夹 PageTree 错位与本地 Markdown 编辑不保存
## 现象
- 点击星标置顶的本地 `design` 文件夹后,FileTree 已切到 `design` scope,但 PageTree 仍显示旧 workspace/root 页面树或为空。
- 在“我的空间”本地 Markdown 页面输入 `111` 后,切换页面再回来内容消失。
## 根因
- 星标文件夹打开时,`/api/tree/projections/file` 已带 `parentRelativePath=design`,但 `/api/tree/projections/sidebar` 没有带同一 scope;后端 PageTree projection 也没有按 `parentRelativePath` 扫描子目录。
- `document-session-runtime.js` 拆分后继续直接使用 `hydrateMindmapAttrsFromDom` / `textToTiptapDocument`,但文件自身未导入这两个 conversion helper。编辑器变更能进入 dirty session,但保存计时器执行时抛出 `hydrateMindmapAttrsFromDom is not defined`,导致 `/api/page-body/write` 根本没有发出。
## 修复
- 星标 scoped folder 打开时同时给 sidebar projection 传 `parentRelativePath`,并确保 cloud/default 页面缺少 `#sidebar-tree-root` 时能在 PageTree panel 内创建 scoped PageTree host。
- 后端新增 scoped local PageTree snapshot:按 `rootUri + parentRelativePath` 扫描并缓存,`/api/tree/projections/sidebar` 在 local folder + `parentRelativePath` 下返回 scoped PageTree。
- `document-session-runtime.js` 显式导入 `hydrateMindmapAttrsFromDom``textToTiptapDocument`,恢复 dirty session 自动保存链路。
## 验证
- RED`node scripts/task498-starred-page-tree-scope-and-local-edit-smoke.js` 先失败于 scoped PageTree 未显示 `Brief`,修复 PageTree scope 后再失败于保存阶段 `hydrateMindmapAttrsFromDom is not defined`
- GREEN`node scripts/task498-starred-page-tree-scope-and-local-edit-smoke.js` 通过,覆盖星标 `design` 后 PageTree 只显示 design 内 Markdown、输入 `111``/api/page-body/write` 成功、磁盘 `Home.md` 包含 `111`、切到 `Other.md` 再回 `Home.md` 仍保留。
- 回归:`node scripts/task492-sidebar-starred-shortcuts-smoke.js``node scripts/task494-filetree-lazy-loading-dedup-smoke.js``node scripts/task497-local-page-tree-filetree-open-performance-smoke.js` 通过。
- Rust`local_folder_page_projection_can_scope_by_parent_path``local_folder_page_tree_snapshot_reuses_cache_until_watch_revision_changes``tree_projection_routes` 通过。