Files
mnote/bugs/04-tree-domain/done/4-38-filetree-mindmap-click-active-row-flicker-v1.md
T
lix-2026 274779c0d8 fix(tree): stabilize filetree mindmap switching
Open filetree mindmap assets inside the primary document pane so the sidebar root is not rebuilt during rapid mindmap/page switching.

Keep filetree active rows on doc:<documentId> and asset:<mindmapId>, shorten generated mindmap filenames, and preserve legacy index rows only as compatibility input.

Add task438-task445 browser smokes and close the 4-27/4-38/4-39/4-40 tree-domain bug records.
2026-05-16 07:11:06 +08:00

60 lines
2.6 KiB
Markdown
Raw 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.
# 4-38 文件树 mindmap 点击后选中态闪回父页面
## 状态
- 状态:done
- 分类:04-tree-domain
- 发现时间:2026-05-15
- 修复时间:2026-05-15
## 现象
点击页面树普通页面时视觉稳定;点击文件树中的思维导图资源行时,资源行会快速闪一下,随后文件树选中态回到父页面 `.md` 行。用户体感类似“点了 mindmap 文件,但文件树又跳回对应页面/index”。
## 根因
文件树资源点击路径先执行 `selectSidebarFileTreeRow()`,使 asset row 短暂 selected;随后 mindmap 资源通过 `tree.asset.open -> openConvexAssetFromFileTree()` 整页跳转到 `/mindmap/{documentId}/{mindmapId}`
旧实现中 `/mindmap` 对象页重新渲染文件树时只按当前 `documentId` 计算选中态:
```text
rowId === 'doc:' + activeId
```
因此页面重建或 tree live snapshot 重绘后,选中态会从 `asset:{mindmapId}` 回落到 `doc:{documentId}`,形成快速闪烁。
## 修复
- `mindmap_object_shell` 加载文件树时传入 active row:`asset:{mindmapId}`
- `collect_filetree_render_rows()` 新增 `active_row_id`,当存在 active row 时优先按 row id 选中,避免父页面 fallback 抢回 selected。
- `SIDEBAR_TREE_JS` 的 live snapshot renderer 新增 `currentFileTreeActiveRowId()`,在 `/mindmap/{doc}/{asset}` 路径下保持 `asset:{asset}` 选中,防止 SSE 重绘后再次闪回。
## 验证
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 mindmap_shell_returns_rust_object_shell_contract -- --nocapture
cargo test --manifest-path rust/Cargo.toml -p mnote-web filetree_rows_select_active_mindmap_asset_in_object_shell -- --nocapture
```
真实浏览器 smoke
```bash
MNOTE_UI_BASE_URL=http://127.0.0.1:3428 node scripts/task443-filetree-mindmap-click-active-row-smoke.js
```
验证结果:
- `tmp/task443-filetree-mindmap-click-active-row-smoke/result.json`
- 截图:`tmp/task443-filetree-mindmap-click-active-row-smoke/after-mindmap-click.png`
- 点击后 URL 为 `/mindmap/{documentId}/{mindmapId}`
- 点击前 selected row 为 `doc:{documentId}`
- 点击后 selected row 为 `asset:{mindmapId}`
- 点击后不再出现父页面 `doc:{documentId}` selected。
## 后续口径
mindmap、附件、table 等资源对象打开后,文件树 active/selected 不能只按父 `documentId` 回落到页面行;对象页或对象视图必须优先表达资源对象身份。页面正文才选中 `doc:{documentId}`