Files
mnote/design/04-tree-domain/done/4-29-vscode-explorer-cut-paste-move-v1.md
T
lix-2026 384da4e44c feat(tree): checkpoint resource lifecycle work
提交当前顶层 mnote Git 工作区,范围集中在 04-tree-domain 的 resource/trash/filetree 生命周期、mnote-web resource_trash 路由、Convex/Next 兼容接口、sidebar/file-tree 客户端适配、smoke 脚本与对应设计/bug 记录。

不包含被 ignore 的 design/05-editor-mainline/reference-code/leptos-tiptap 嵌套仓库改动。新增 smoke 的测试密码改为运行时读取 MNOTE_E2E_PASSWORD,避免提交明文 credential assignment。
2026-05-16 07:38:45 +08:00

69 lines
3.2 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-29 VSCode Explorer Cut Paste Move v1
> 状态:done
> 创建时间:2026-05-15
> 所属主线:04-tree-domain / VSCode Explorer 文件树与垃圾箱闭环
> 来源:`design/10-review/07-vscode-explorer-filetree-trash-gap-review.md` 阶段 7
## 1. 目标
先收口阶段 7 的最小可执行项:文件树 `Ctrl/Cmd+X``Ctrl/Cmd+V` 必须执行移动,而不是复制或 no-op。
## 2. 范围
- `wolai-frontend` 主 Sidebar 文件树剪贴板 action 从 `copy` 扩展为 `copy | cut`
- `Ctrl/Cmd+C` 写入 `copy` payload`Ctrl/Cmd+X` 写入 `cut` payload。
- `Ctrl/Cmd+V` 读取 `cut` payload 时:
- Rust family renderer 复用 `tree.filetree.drop.preflight` 的 move plan。
- 页面移动走 `moveDocumentCommand`
- 普通附件移动走 `moveFileTreeResourceAssets`
- 成功后清空剪贴板并刷新/广播相关树变化。
- `copy` 路径保持原行为。
## 3. 非目标
- F2 inline rename、右键菜单补齐、DnD readonly / 冲突确认不在本小阶段内实现,继续留在阶段 7 后续子项。
- 不扩展 `tree.filetree.paste.preflight` 的 Rust plancut 粘贴复用 drop preflight,是当前最小改动。
## 4. 验收标准
- `decodeFileTreeClipboardPayload` 能识别 `copy | cut`,拒绝其它 action。
- Sidebar 快捷键监听同时处理 `Ctrl/Cmd+C``Ctrl/Cmd+X``Ctrl/Cmd+V`
- cut paste 分支不调用 `copyTreeCommand` / `copyFileTreeResourceAssets`,而调用 `moveDocumentCommand` / `moveFileTreeResourceAssets`
- 成功 cut paste 后清空剪贴板,避免二次粘贴重复移动。
## 5. 已落地
- `src/lib/file-tree/clipboard.ts`
- `FileTreeClipboardAction` 扩展为 `copy | cut`
- decoder 允许 `cut`,继续拒绝其它 action。
- 新增 `clearFileTreeClipboardPayload`
- `src/components/sidebar/sidebar.tsx`
- 全局文件树快捷键支持 `Ctrl/Cmd+X`
- Rust family renderer 的 cut paste 复用 `preflightFileTreeInternalDrop(... copy: false)`
- cut paste 执行页面移动与附件移动,成功后清空剪贴板。
- `src/components/sidebar/tree-pane-bindings.ts` 透出清空剪贴板 helper。
## 6. 验证命令
```bash
cd /mnt/Data1T/mnote/wolai-frontend
pnpm test src/lib/file-tree/clipboard.test.ts src/components/sidebar/sidebar-paste-preflight-source.test.ts
```
结果:2 个测试文件通过,7 项测试通过。
局部 TypeScript 筛查:
```bash
pnpm exec tsc --noEmit --pretty false 2>&1 | rg "(src/lib/file-tree/clipboard.ts|src/components/sidebar/tree-pane-bindings.ts|src/components/sidebar/sidebar.tsx)"
```
结果:无输出,本轮修改文件无新增 TypeScript 报错。全量 `tsc` 仍受仓库既有错误影响。
## 7. 待补
- 2026-05-15 已补 3000 主入口真实浏览器 smoke:`MNOTE_UI_BASE_URL=http://127.0.0.1:3000 node scripts/task430-vscode-explorer-stage7-smoke.js`
- `task430` 使用一次性用户 / workspace,验证页面行 `Ctrl/Cmd+X` 后聚焦目标页面并 `Ctrl/Cmd+V`,捕获 `/api/tree/commands action=move`,并通过 Convex 查询确认子页面 `parent_id` 变为目标父页面。
- 普通附件 cut-paste move 的执行路径已有代码与 preflight 设计,真实附件 move 全矩阵仍归入后续资源树 / DnD 综合 smoke,不阻塞本小阶段“页面 cut-paste move”验收。