58 lines
2.5 KiB
Markdown
58 lines
2.5 KiB
Markdown
# Reasonix Batch C / Worker C:3-20 uploadFileToMediaAsset runtime 外置候选
|
||
|
||
Project root:`/mnt/Data1T/mnote-worktrees/0525-c-worker-c-upload-media-asset`
|
||
|
||
## 目标
|
||
|
||
在独立 worktree 中产出候选 patch:把 `SIDEBAR_TREE_JS` 中 `uploadFileToMediaAsset(file, plan, options)` 的实现同构迁入 `rust/crates/mnote-web/browser/local-upload-runtime.js`,`layout.rs` 只保留委托 wrapper 和完整 inline fallback。不得改变上传落盘、资源归属、editor 插入、sidebar snapshot refresh 或事件语义。
|
||
|
||
## 允许修改
|
||
|
||
- `rust/crates/mnote-web/browser/local-upload-runtime.js`
|
||
- `rust/crates/mnote-web/src/ssr/pages/layout.rs`
|
||
|
||
必要时只更新 `layout.rs` 中现有字符串断言测试。
|
||
|
||
## 实现要求
|
||
|
||
- `local-upload-runtime.js` 新增并导出 `uploadFileToMediaAsset(file, plan, options, deps)`。
|
||
- `layout.rs` 中原 `uploadFileToMediaAsset(file, plan, options)` 优先委托 `localUploadRuntimeFunction('uploadFileToMediaAsset')`。
|
||
- runtime 不复制 editor / resource open 长期业务语义,必须通过 `deps` 接收既有 helper 或 callback。
|
||
- 保持以下行为完全不变:
|
||
- `resolveEditorUploadContext` 的调用和 options 透传。
|
||
- `uploadLocalFolderAsset` 的调用和 FormData 合同。
|
||
- `insertUploadedAssetIntoEditor` 的调用时机。
|
||
- `reloadSidebarTreeSnapshot()`、`wolai:local-assets-changed`、`data-mnote-last-upload-*` 相关行为。
|
||
- runtime 不存在时,inline fallback 继续执行原实现。
|
||
|
||
## 禁止事项
|
||
|
||
- 不迁 `uploadFilesWithResolvedTarget`。
|
||
- 不改 `/api/local-folder/assets/upload` 合同。
|
||
- 不改 resource open / OnlyOffice URL 语义。
|
||
- 不修改 document conflict runtime、editor island、AGENTS、设计文档或 git 状态。
|
||
- 不提交 git。
|
||
|
||
## 验收命令
|
||
|
||
```bash
|
||
node --check rust/crates/mnote-web/browser/local-upload-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 local_upload_runtime_contains_editor_upload_context_helpers -- --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 scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js
|
||
```
|
||
|
||
## 输出要求
|
||
|
||
handoff 必须列出:
|
||
|
||
- 修改文件。
|
||
- 委托 deps 清单。
|
||
- 是否保留 fallback。
|
||
- 验收命令和结果。
|
||
- 浏览器 smoke 证据路径。
|
||
- 未覆盖风险。
|
||
- `git diff --stat`。
|