Files
mnote/.codex/reasonix-tasks/2026-05-25-batch-f-worker-b-3-20-filetree-upload-target.md
T

64 lines
2.8 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.
# Reasonix Batch F / Worker B3-20 filetree upload target helper 候选
Project root`/mnt/Data1T/mnote-worktrees/0525-f-worker-b-3-20-filetree-upload-target`
## 目标
在独立 worktree 中产出候选 patch,把 `SIDEBAR_TREE_JS` 中 file tree 上传目标解析的纯 fallback / plan 归一化 helper 外置到 `filetree-runtime.js`,为后续 `resolveFileTreeUploadTarget` 收口做准备。不得改变 local folder 文件拖入目标、editor markdown attach、preflight fallback 或资源归属语义。
优先迁出:
- `fallbackFileTreeUploadTarget(detail, deps)` 或等价 helper
- 如需要,可迁 `normalizeFileTreeUploadPlan(plan, detail)` 这类纯 plan 归一化 helper
不要整体迁 `resolveFileTreeUploadTarget` 的 async preflight 流程,除非只是在 `layout.rs` 中优先委托新 runtime helper 后保留完整 inline fallback。
## 允许修改
- `rust/crates/mnote-web/browser/filetree-runtime.js`
- `rust/crates/mnote-web/src/ssr/pages/layout.rs`
必要时只更新同文件内字符串断言测试。
## 禁止事项
- 不修改 `rust/crates/mnote-web/browser/document-conflict-panel-runtime.js``rust/crates/mnote-web/src/routes/web_shell.rs`,避免和当前 conflict panel 候选冲突。
- 不修改 `local-upload-runtime.js`
- 不改 `/api/filetree/upload-target``/api/local-folder/assets/upload``/api/media/upload` 合同。
- 不改 OnlyOffice URL / resource open 语义。
- 不修改 editor island、AGENTS、design、bugs 或 git 状态。
- 不提交 git。
## 实现要求
- `filetree-runtime.js` 新增并导出 fallback helper,依赖通过 `deps` 注入:
- `resolveWorkspaceId`
- `currentDocumentId`
- `layout.rs` 中原 `fallbackFileTreeUploadTarget(detail)` 优先委托 `fileTreeRuntimeFunction('fallbackFileTreeUploadTarget')`,runtime 不存在时保留完整原 inline fallback。
- 保持错误文案 `请选择一个目标页面后再拖入文件` 不变。
- 保持 upload intent 规则:
-`targetRelativePath` 时默认为 `filetree.folder.drop`
- 否则默认为 `editor.markdown.attach`
## 验收命令
```bash
node --check rust/crates/mnote-web/browser/filetree-runtime.js
cargo fmt --manifest-path rust/Cargo.toml --all --check
cargo check --manifest-path rust/Cargo.toml -p mnote-web
cargo test --manifest-path rust/Cargo.toml -p mnote-web sidebar_filetree_runtime_helpers_are_externalized_with_inline_fallback -- --test-threads=1
cargo test --manifest-path rust/Cargo.toml -p mnote-web sidebar_upload_runtime_routes_local_markdown_assets_to_local_folder -- --test-threads=1
NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js
```
## 输出要求
handoff 必须列出:
- 修改文件。
- 外置 helper 的职责和 deps 清单。
- fallback 是否保留。
- 验收命令和结果。
- 未覆盖风险。
- `git diff --stat`