refactor: extract attachment link history commands

This commit is contained in:
lix-2026
2026-05-24 22:18:44 +08:00
parent db7c3cb319
commit 418f8ff8b0
7 changed files with 162 additions and 83 deletions
@@ -109,14 +109,14 @@ rust/spikes/leptos-tiptap-spike/src/
### P1:抽出附件链接和 history-safe delete
- [ ] 新增 `editor_runtime/attachment_links.rs`
- [ ] 迁出本地附件链接识别:
- [x] 新增 `editor_runtime/attachment_links.rs`
- [x] 迁出本地附件链接识别:
- DOM selection fallback。
- Tiptap editor state link attributes 判断。
- `/api/local-folder/files/open` 链接识别。
- [ ] 新增 `editor_runtime/history_safe_commands.rs`
- [ ] 将“选中附件链接文本后 Delete/Backspace”收口为命名函数,例如 `delete_selected_attachment_link_with_history(...)`
- [ ] 验证 `task488` 仍通过。
- [x] 新增 `editor_runtime/history_safe_commands.rs`
- [x] 将“选中附件链接文本后 Delete/Backspace”收口为命名函数,例如 `delete_selected_attachment_link_with_history(...)`
- [x] 验证 `task488` 仍通过。
### P2:抽出 command sync / persistence
@@ -261,6 +261,42 @@ Reasonix R2 run
- Reasonix 对大文件只读审计有效,但输出中的“行号和风险分级”只能作为候选事实;主控必须用本地 `rg` / 源码抽样复核。
- Reasonix runner 产出 `completed` 结果后底层 `reasonix acp` 进程未自动退出;主控必须在每批结束时检查并清理本轮启动进程。
### 10.2 Batch 1 执行记录(2026-05-24
Reasonix run
- run id: `reasonix-2026-05-24T14-00-12-979Z-1125fb29`
- worker worktree: `/mnt/Data1T/mnote-wt-5-28-attachment-history-b1`
- handoff: `/home/lix/.codex/runtime/reasonix-coding-worker/reasonix-2026-05-24T14-00-12-979Z-1125fb29/process-handoff.md`
- 类型:窄范围机械迁移,允许修改 `src/lib.rs``src/editor_runtime/{mod.rs,attachment_links.rs,history_safe_commands.rs}`
采纳内容:
- 新增 `editor_runtime/mod.rs`
- 新增 `editor_runtime/attachment_links.rs`,迁出本地附件链接的 DOM selection fallback 与 Tiptap editor state link attributes 判断。
- 新增 `editor_runtime/history_safe_commands.rs`,把选中本地附件链接后的 `Delete/Backspace` 删除收口到 `delete_selected_attachment_link_with_history(...)`
- `src/lib.rs` 只保留模块装配和 keydown handler 调用,不再直接承载本地附件链接识别函数。
Codex 主控复核修正:
- worker 初版把底层错误格式化为 `删除附件引用失败:{e}`,调用处也会加同一前缀;主控已改为 `error.to_string()`,避免用户反馈重复。
- worker 初版自报 `cargo check` 通过依赖临时 `reference-code` symlink;主控在 worktree 和主工作区分别重新验证。
- Reasonix runner 写出 completed 后底层 `reasonix acp` 残留,主控已清理本轮进程。
已通过验证:
- `cargo fmt --manifest-path rust/Cargo.toml --all --check`
- `cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`35 个既有 warning
- `cargo build --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml --target wasm32-unknown-unknown --release`
- `wasm-bindgen rust/spikes/leptos-tiptap-spike/target/wasm32-unknown-unknown/release/mnote_leptos_tiptap_spike.wasm --target web --out-dir rust/spikes/leptos-tiptap-spike/generated/island --out-name mnote-leptos-tiptap-spike-island`
- `node scripts/task488-local-attachment-link-delete-undo-smoke.js`
- 结果:`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`
- `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/*`
## 11. 测试与验收
### Rust 检查