refactor: externalize local upload helpers

Add local-upload-runtime.js as a browser runtime module for upload and attachment helper functions, with sidebar fallback wrappers and a fixed runtime asset route.

While validating task479, fix the editor attachment delete path so DOM-selected local attachment links are mapped back to a Tiptap text selection before delete_selection(), preserving undo history and adjacent links.
This commit is contained in:
lix-2026
2026-05-24 22:42:53 +08:00
parent 418f8ff8b0
commit 0a03572601
10 changed files with 353 additions and 19 deletions
@@ -282,6 +282,7 @@ Codex 主控复核修正:
- worker 初版把底层错误格式化为 `删除附件引用失败:{e}`,调用处也会加同一前缀;主控已改为 `error.to_string()`,避免用户反馈重复。
- worker 初版自报 `cargo check` 通过依赖临时 `reference-code` symlink;主控在 worktree 和主工作区分别重新验证。
- Reasonix runner 写出 completed 后底层 `reasonix acp` 残留,主控已清理本轮进程。
- 后续 `task479` 暴露 DOM `range.selectNode(link)` + `Backspace` 场景下 Tiptap selection 可能未同步,导致相邻附件删除检查失败;主控已在 `history_safe_commands` 删除前把 DOM 选中的本地附件链接映射回 Tiptap text selection,再调用 `delete_selection()`
已通过验证:
@@ -293,6 +294,9 @@ Codex 主控复核修正:
- 结果:`ok=true`
- 步骤:`uploaded -> selected -> deleted -> undo -> redo`
- 证据:`tmp/task488-local-attachment-link-delete-undo-smoke/result.json``tmp/task488-local-attachment-link-delete-undo-smoke/after-redo.png`
- `node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js`
- 结果:`ok=true`
- 覆盖:单附件 `Backspace` 删除保留相邻附件、真实附件文件不被级联删除、刷新后被删引用不回来。
- `codegraph index . --force && codegraph status .`
- 结果:索引 318 个文件,状态 up to date。
- 复核:`delete_selected_attachment_link_with_history``selected_local_attachment_link_text``is_local_attachment_link_selected` 均可通过 CodeGraph 搜索定位到 `editor_runtime/*`