Complete workbench P0 resource tab cutover

This commit is contained in:
lix-2026
2026-05-20 20:13:24 +08:00
parent acf1305a7e
commit e0b0e70fb8
12 changed files with 1159 additions and 3 deletions
@@ -0,0 +1,54 @@
# 4-39 FileTree Open Target 与 Resource Identity Checklist v1
> 状态:process
>
> 日期:2026-05-20
>
> OwnerFile Tree runtime / open target 合同
## 1. 目标
补齐 P0-4:扩展 `FileTreeOpenTarget` 和 runtime API,使 File Tree 能稳定表达 local raw file、directory、asset folder、office/image/pdf/code/mindmap/table 等资源身份,而不是只靠 UI 侧字符串分流。
## 2. 允许修改范围
- `rust/crates/mnote-web/src/tree_shell/filetree_runtime.rs`
- `rust/crates/mnote-web/src/tree_shell/runtime_api.rs`
- `rust/crates/mnote-web/src/routes/tree.rs`
- `rust/crates/mnote-web/src/routes/local_folder_source.rs`
- 相关 Rust 单测
## 3. 禁止事项
- 不改前端打开 UI 大流程;只输出更稳定的 open target / intent 合同。
- 不做 resource lifecycle delete/restore/purge cutover;该项由 4-40 处理。
- 不引入新的树真相层,Resource Tree / File Tree / Page Tree 口径保持不变。
## 4. Checklist
- [x] 扩展 `FileTreeOpenTarget` 或新增字段,能表达 `local_file``directory``asset_folder``office``image``pdf``code/text``mindmap``table`
- [x] open target 包含 canonical resource identity、resource kind、relative path、document id / parent id(若有)。
- [x] `parse_open_target_from_row` 支持现有 row dataset,不破坏 document/index/asset-folder/asset。
- [x] runtime API 序列化保持 camelCase,旧字段兼容。
- [x] Rust 单测覆盖 local raw file、directory、office/image/pdf/code/mindmap/table open target。
## 5. 验收
- [x] `cargo test -p mnote-web filetree_runtime -- --test-threads=1`
- [x] `cargo test -p mnote-web runtime_api -- --test-threads=1`
- [x] `cargo test -p mnote-web tree_shell_filetree_mode_embeds_asset_state -- --test-threads=1`
## 6. 本轮执行记录
- 已完成:
- `FileTreeOpenTarget::Asset` 已补可选 `resourceKind`,并新增 `LocalFile` / `Directory` variant。
- `resolve_open_target` 支持 `local-file` / `directory` / `office` / `image` / `pdf` / `code` / `text` / `mindmap` / `table` row kind。
- 新增序列化合同测试,覆盖 resource kind、local file 中文路径、directory。
- 未完成:
- 后续仍需把更多上游 row dataset 补齐真实 `rootUri`,当前 `LocalFile` / `Directory` variant 的 rootUri 仍为空字符串占位。
- 风险:`FileTreeOpenTarget` schema 已扩展,需保留旧 `Asset` JSON 兼容;当前 `resourceKind=None` 时不序列化。
## 7. 非目标
- 不改变资源实际打开方式。
- 不处理 OnlyOffice 回源。
@@ -0,0 +1,60 @@
# 4-40 Resource Lifecycle Command Cutover 与垃圾箱 Smoke Checklist v1
> 状态:process
>
> 日期:2026-05-20
>
> Ownerresource lifecycle / tree.resource.* / local trash smoke
## 1. 目标
补齐 P0-5:前端本地资源删除、恢复、永久删除优先走 `/api/tree/commands``tree.resource.*` 语义,并用浏览器 smoke 覆盖“资源行删除 -> 垃圾箱可见 -> 恢复 -> purge”的全链路。
## 2. 允许修改范围
- `rust/crates/mnote-web/src/ssr/pages/layout.rs`
- `rust/crates/mnote-web/src/routes/tree.rs`
- `rust/crates/mnote-web/src/routes/local_folder_source.rs`
- `rust/crates/mnote-web/src/routes/resource_trash.rs`
- `rust/crates/mnote-web/src/routes/gateway.rs`
- `scripts/task437-local-folder-asset-trash-lifecycle-smoke.js`
- 可新增聚焦 smoke
## 3. 禁止事项
- 不删除旧兼容 resource_trash route;只让新主路径优先 tree command。
- 不改变云端 Convex resource lifecycle 语义。
- 不实现 undo/redo。
## 4. Checklist
- [ ] 前端 local resource delete/bulk delete 优先调用 `/api/tree/commands` archive/purge/restore。
- [x]`/api/mindmap``/api/media``/api/tables` lifecycle route 保留为兼容 fallback。
- [x] tree command response 保留 `canonicalCommand` / artifact / trash index 信息,前端可刷新对应行。
- [x] 垃圾箱页面或 modal 能显示 local resource trash entry,并支持 restore/purge。
- [x] 新增浏览器 smoke:本地文件夹页面上传或创建资源,单独删除资源,垃圾箱可见,恢复回原路径,再永久删除清理索引。
- [x] smoke 隔离 tmp root,不复用历史云 workspace。
## 5. 验收
- [x] `node --check scripts/task437-local-folder-asset-trash-lifecycle-smoke.js`
- [x] `node scripts/task437-local-folder-asset-trash-lifecycle-smoke.js`
- [x] 新增 resource trash browser smoke 通过。
- [x] `cargo test -p mnote-web resource_trash -- --test-threads=1`
- [x] `cargo test -p mnote-web tree_command_local_folder -- --test-threads=1`
## 6. 本轮执行记录
- 已完成:
- `/api/tree/commands` 支持 local resource archive / restore / purge,并返回 `tree.resource.*` canonical command。
- local trash workbench 已从 `trash-index.json` 渲染 resource row,并通过 `/api/tree/commands` restore / purge。
- `scripts/task437-local-folder-asset-trash-lifecycle-smoke.js` 覆盖 API 级 delete / restore / purge。
- 新增 `scripts/task464-local-folder-resource-trash-ui-smoke.js`,覆盖真实垃圾箱页面 resource row 可见、UI 恢复、UI 彻底删除和索引清理。
- 未完成:
- 前端 bulk delete 场景尚未覆盖 tree command。
- 风险:无
## 7. 非目标
- 不做完整 trash undo。
- 不做 Convex 云端 parity。