117 lines
5.0 KiB
Markdown
117 lines
5.0 KiB
Markdown
# 4-39 文件树新建不更新与 `.md` 后缀被缓存/标题同步覆盖
|
||||
|
|
|
|||
|
|
## 状态
|
|||
|
|
|
|||
|
|
- 状态:done
|
|||
|
|
- 分类:04-tree-domain
|
|||
|
|
- 发现时间:2026-05-15
|
|||
|
|
- 关联:`4-27`、`4-35`、`4-38`
|
|||
|
|
|
|||
|
|
## 现象
|
|||
|
|
|
|||
|
|
1. File Tree 中点击新建页面后,树不再稳定更新;刷新后最新页面显示也异常。
|
|||
|
|
2. 页面树显示为 `新页面`,文件树应显示为 `新页面.md`,但部分路径会显示成 `新页面`。
|
|||
|
|
3. 点击 File Tree 的 mindmap 资源 `mindmap-mindmap...` 后,再点击 `新页面.md`,文件树标题会变成 `新页面`,`.md` 消失。
|
|||
|
|
|
|||
|
|
截图证据:
|
|||
|
|
|
|||
|
|
- `/mnt/Data1T/mnote/tmp/image copy 103.png`
|
|||
|
|
- `/mnt/Data1T/mnote/tmp/image copy 104.png`
|
|||
|
|
|
|||
|
|
## 已确认冲突点
|
|||
|
|
|
|||
|
|
### 1. live snapshot filetree renderer 引用了未定义变量
|
|||
|
|
|
|||
|
|
`rust/crates/mnote-web/src/ssr/pages/layout.rs` 中,`renderFileRows()` 使用了 `activeRowId`,但旧函数签名没有把它作为参数传入。tree live snapshot / delta 调用 `renderSidebarSnapshot()` 时会进入该函数,可能抛出 `ReferenceError`,导致“新建后不更新”。
|
|||
|
|
|
|||
|
|
修复方向:
|
|||
|
|
|
|||
|
|
- `renderFileRows(parentId, grouped, activeId, activeRowId)` 显式传入 active row。
|
|||
|
|
- 递归调用也继续传入 active row。
|
|||
|
|
- `renderFileProjection()` 调用 `currentFileTreeActiveRowId()` 后传入。
|
|||
|
|
|
|||
|
|
### 2. live snapshot 使用原始页面标题,绕过 `.md` 文件树显示口径
|
|||
|
|
|
|||
|
|
本地 create 补偿路径 `applyCreatedDocumentLocally() -> upsertFileDocumentRows()` 会把页面标题 `新页面` 显示成 `新页面.md`。
|
|||
|
|
|
|||
|
|
但 live snapshot / SSR projection 路径直接使用 projection item 的 `title`,导致文件树页面行被重绘成 `新页面`。
|
|||
|
|
|
|||
|
|
修复方向:
|
|||
|
|
|
|||
|
|
- live `renderFileRows()` 对 document/doc/markdown 且非 asset 的行统一使用 `fileTreePageTitle(rawTitle)`。
|
|||
|
|
- 资源行仍显示资源自身标题,不套页面 `.md` 规则。
|
|||
|
|
|
|||
|
|
### 3. 文档 pane 标题同步绕过 `.md` 文件树显示口径
|
|||
|
|
|
|||
|
|
`rust/crates/mnote-web/src/routes/web_shell.rs` 的 `render_document_title_controller_script()` 中,`updateVisibleTitle()` 更新文件树 row title 时使用原始 `title`,没有经过 `fileTreePageTitle()`。
|
|||
|
|
|
|||
|
|
这解释了“点击 mindmap 后再点 `新页面.md`,`.md` 消失”:pane 内导航/标题同步链路覆盖了文件树行标题。
|
|||
|
|
|
|||
|
|
修复方向:
|
|||
|
|
|
|||
|
|
- 在 title controller 中加入同等 `fileTreePageTitle()`。
|
|||
|
|
- page tree / breadcrumb 仍显示页面标题 `新页面`。
|
|||
|
|
- filetree document row 显示 `新页面.md`。
|
|||
|
|
|
|||
|
|
### 4. pane 内导航仍用旧 `index:<documentId>` 选中规则
|
|||
|
|
|
|||
|
|
`web_shell.rs` 的 `updatePaneChrome()` 中,primary pane 导航后 filetree selected 判断仍是 `index:${documentId}`。
|
|||
|
|
|
|||
|
|
当前 4-35 口径中,Convex 页面正文默认 row 已迁移为 `doc:<documentId>`,旧 `index` 规则会导致 selection 与 active row 不稳定。
|
|||
|
|
|
|||
|
|
修复方向:
|
|||
|
|
|
|||
|
|
- pane 内 primary navigation 统一使用 `doc:<documentId>`。
|
|||
|
|
|
|||
|
|
## VSCode 参考原则
|
|||
|
|
|
|||
|
|
参考 `/mnt/Data1T/mnote/design/05-editor-mainline/reference-code/vscode`:
|
|||
|
|
|
|||
|
|
- 点击打开、active、selection、reveal 是分离状态,不能互相无条件覆盖。
|
|||
|
|
- refresh 应更新局部 children / item,不应无条件清空重建整棵树。
|
|||
|
|
- label 显示必须由单一口径生成;不能一条路径显示后缀,另一条路径丢后缀。
|
|||
|
|
- selection/focus 需要去重,相同 selection 不应重复提交。
|
|||
|
|
|
|||
|
|
## 验收标准
|
|||
|
|
|
|||
|
|
- 在 File Tree 点击 `+` 新建页面后,不刷新即可出现新页面 row。
|
|||
|
|
- 新建后本地补偿、tree live snapshot、刷新后文件树页面行都显示 `{title}.md`。
|
|||
|
|
- 页面树仍显示 `{title}`,不显示 `.md`。
|
|||
|
|
- 点击 mindmap 资源后,再点击同页面或其它页面的 filetree `{title}.md`,标题不丢 `.md`。
|
|||
|
|
- tree live snapshot / delta 不再因为 `activeRowId is not defined` 中断。
|
|||
|
|
|
|||
|
|
## 已验证
|
|||
|
|
|
|||
|
|
- 已新增真实浏览器 smoke,覆盖 create -> live snapshot -> mindmap click -> filetree page click -> `.md` 保持。
|
|||
|
|
|
|||
|
|
## 验证结果
|
|||
|
|
|
|||
|
|
Rust 定向测试:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cargo test --manifest-path rust/Cargo.toml -p mnote-web sidebar_filetree_runtime_uses_markdown_page_row_without_local_index_child -- --nocapture
|
|||
|
|
cargo test --manifest-path rust/Cargo.toml -p mnote-web document_shell_returns_page_aggregate_snapshot -- --nocapture
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
真实浏览器 smoke:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
MNOTE_UI_BASE_URL=http://127.0.0.1:3428 node scripts/task444-filetree-create-mindmap-title-cache-smoke.js
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
结果文件:
|
|||
|
|
|
|||
|
|
- `tmp/task444-filetree-create-mindmap-title-cache-smoke/result.json`
|
|||
|
|
- `tmp/task444-filetree-create-mindmap-title-cache-smoke/after-page-click.png`
|
|||
|
|
|
|||
|
|
关键断言:
|
|||
|
|
|
|||
|
|
- `fileTreeCreated.title = "新页面.md"`
|
|||
|
|
- `afterLive.title = "新页面.md"`
|
|||
|
|
- `afterMindmapClick.title = "新页面.md"`
|
|||
|
|
- `afterPageClick.title = "新页面.md"`
|
|||
|
|
- `afterPageClick.selected = "true"`
|
|||
|
|
- 未出现 `activeRowId` / `ReferenceError`。
|
|||
|
|
|
|||
|
|
备注:smoke 中出现一次 `mnote standalone mindmap mount failed TypeError: Failed to fetch`,但不影响本 bug 的文件树 title / selected 验证;如后续稳定复现,应另归 05-editor-mainline 或 mindmap runtime 方向排查。
|