Files
mnote/.codex/reasonix-tasks/2026-05-25-batch-a2-worker-d-3-20-local-upload-insert-runtime.md
T

62 lines
2.3 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 A2 / Worker D3-20 local upload insert helper 外置实现
Project root`/mnt/Data1T/mnote-worktrees/0525-a2-upload-insert-current`
## 目标
在独立 worktree 中产出候选 patch:把 `SIDEBAR_TREE_JS``insertUploadedAssetIntoEditor(asset, targetRoot)` 的实现同构迁入 `rust/crates/mnote-web/browser/local-upload-runtime.js``layout.rs` 只保留委托 wrapper 和 fallback。不得改变上传落盘、资源归属或 editor 插入行为。
## 允许修改
- `rust/crates/mnote-web/browser/local-upload-runtime.js`
- `rust/crates/mnote-web/src/ssr/pages/layout.rs`
必要时只更新同文件内现有字符串断言测试。
## 实现要求
- `local-upload-runtime.js` 新增导出到 `window.__mnoteLocalUploadRuntime.insertUploadedAssetIntoEditor`
- `layout.rs` 中原 `insertUploadedAssetIntoEditor` 优先委托外置 runtimeruntime 不存在时保留原 fallback。
- 外置 runtime 通过 deps 接收现有 helper,不复制 resource/open 业务语义:
- `uploadedAssetTitle`
- `localAssetOpenUrl`
- `uploadedAssetUrl`
- `uploadedAssetType`
- `isLocalUploadedAsset`
- `buildOnlyOfficeAssetOpenUrl`
- `fetchCurrentOnlyOfficeUserId`
- `buildOnlyOfficeOpenPath`
- `inferOnlyOfficeFileType`
- `currentDocumentId`
- `uploadedAttachmentClass`
- `uploadedFileSize`
- `cssEscape`
- `enhanceEditorAttachmentLinks`
- 保持 `data-mnote-last-upload-inserted``data-mnote-last-upload-asset-id``data-mnote-last-upload-insert-error` 行为不变。
## 禁止事项
- 不迁 `uploadFileToMediaAsset` / `uploadFilesWithResolvedTarget` 主流程。
- 不改 `/api/local-folder/assets/upload` 合同。
- 不改 resource open / OnlyOffice URL 语义。
- 不修改设计文档、AGENTS、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 sidebar_upload_runtime_routes_local_markdown_assets_to_local_folder -- --test-threads=1
```
## 输出要求
handoff 必须列出:
- 修改文件。
- 委托 deps 清单。
- 是否保持 fallback。
- 验收命令和结果。
- 未覆盖风险。