refactor: extract editor dnd helpers

This commit is contained in:
lix-2026
2026-05-25 03:05:57 +08:00
parent fa3dc76d53
commit 3361a5e1b1
8 changed files with 173 additions and 38 deletions
@@ -6,7 +6,7 @@
## 1. 目标
`3-19` 已归档的基础上,继续把仍留在 Rust inline / 主壳大 runtime 中的浏览器行为切成可审计模块。Codex 维护本文件作为事实源,Reasonix 只承接短批次审计、窄范围实现或浏览器 smoke;每批最多 4 个 worker。
`3-19` 已归档的基础上,继续把仍留在 Rust inline / 主壳大 runtime 中的浏览器行为切成可审计模块。Codex 维护本文件作为事实源,Reasonix 只承接短批次审计、窄范围实现或浏览器 smoke;每批最多 2 个 worker。
## 2. 本轮边界
@@ -63,7 +63,7 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
## 6. 本轮执行记录
- 2026-05-25Codex 创建本续跑事实源。
- 2026-05-25:修正执行约束:本文件遵循当前 goal 的“每批最多 4 个 worker”;实现 worker 必须在独立 worktree 产出候选 patchCodex 复核后再选择性合入。
- 2026-05-25:修正执行约束:本文件遵循当前 goal 的“每批最多 2 个 worker”;实现 worker 必须在独立 worktree 产出候选 patchCodex 复核后再选择性合入。
- 2026-05-25:下一批只派发 Worker Blocal upload / filetree 下一刀只读审计);Worker A/C/D 暂缓。
- 2026-05-25Reasonix local upload / filetree 只读审计尝试未产生 `result.json` / `process-handoff`,且运行期间出现额外 Batch A2 runner,主控已终止进程;该结果不作为正式 handoff 采纳。
- 可参考的 transcript 结论:`fetchWithTimeout` 是低风险纯工具函数,可先迁入 `local-upload-runtime.js``uploadFileToMediaAsset` / `uploadFilesWithResolvedTarget` / `insertUploadedAssetIntoEditor` 仍与 API、editor 插入和 snapshot refresh 耦合,暂不迁。
@@ -92,7 +92,7 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
- 修改:`rust/crates/mnote-web/browser/document-conflict-panel-runtime.js``rust/crates/mnote-web/src/routes/web_shell.rs`
- 已验证:`node --check rust/crates/mnote-web/browser/document-conflict-panel-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 document_conflict_panel_runtime_contains_dom_helpers -- --test-threads=1``cargo test --manifest-path rust/Cargo.toml -p mnote-web mnote_browser_runtime_assets_are_explicitly_mounted -- --test-threads=1`
- 未完成:conflict merge / accept / keep 业务逻辑、document session lifecycle、secondary pane conflict smoke 仍未迁出;本轮未声称真实冲突 UI 全链路完成。
- 2026-05-25:根据用户纠正,后续实现 worker 不能在主工作区直接修改;每批最多 4 个 worker,且必须采用独立 worktree 候选 patch 或明确只读任务。Codex 读取 Hindsight recall、`process-handoff.md/json``result.json`、diff 与验证证据后再选择性合入。
- 2026-05-25:根据用户纠正,后续实现 worker 不能在主工作区直接修改;每批最多 2 个 worker,且必须采用独立 worktree 候选 patch 或明确只读任务。Codex 读取 Hindsight recall、`process-handoff.md/json``result.json`、diff 与验证证据后再选择性合入。
- 2026-05-25Codex 主控完成非本地 media upload API 小切片:`local-upload-runtime.js` 新增并导出 `uploadMediaAsset(file, plan, context)`,承接 `/api/media/upload` 的 FormData 构造、fetch 和响应解析;`layout.rs``uploadFileToMediaAsset` 仍负责 appendUploadedAssetRow、editor 插入和 `wolai:assets-changed` 事件分发,并保留完整 inline fallback。
- 修改:`rust/crates/mnote-web/browser/local-upload-runtime.js``rust/crates/mnote-web/src/ssr/pages/layout.rs`
- 已验证:`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`
@@ -124,8 +124,12 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
- 2026-05-25Batch E 派发异常并终止:Worker B 任务被重复启动为两个 runner / ACP 进程(`reasonix-2026-05-24T18-25-26-844Z-33ea4d58``reasonix-2026-05-24T18-26-04-453Z-5ff62e40`),同一 worktree `/mnt/Data1T/mnote-worktrees/0525-e-worker-b-3-20-conflict-diff-dom` 出现并发写入风险;Codex 已终止相关 Reasonix 进程,未读取到 `final.md``result.json``process-handoff.md/json`。原始未验证 diff 不直接采纳;后续采纳必须经过 Codex 独立复核、修正和验证。
- 2026-05-25Batch F 计划继续采用独立 worktree 候选 patchWorker B 负责把 file tree 上传目标解析的纯 fallback / plan 归一化 helper 外置到 `filetree-runtime.js``layout.rs` 仍保留 async preflight 和完整 inline fallback,避免和当前 conflict panel 写集冲突。
- 2026-05-25Batch F Worker B 异常终止:run `reasonix-2026-05-24T18-39-34-442Z-d9e7ada1` 只产出 `prompt.md` / `memory-recall.json` / `reasonix-transcript.jsonl`,未产出 `final.md``result.json``process-handoff.md/json`worktree 无 difftranscript 停在 `ask_choice`,原因是 worker 误判任务书拼接了 Worker A / Worker B 两个任务并要求人工选择。Codex 已终止 runner / ACP,不采纳该 run。
- 2026-05-25Batch G 超限派发并终止:Worker B/C/D 三个 Reasonix runner 同时启动,超过当前 goal 的“每批最多 2 个 worker”;run `reasonix-2026-05-24T18-51-00-477Z-1307a1b4``reasonix-2026-05-24T18-51-00-504Z-2304f570``reasonix-2026-05-24T18-51-00-541Z-17d61f43` 均只有 `prompt.md` / `memory-recall.json` / `reasonix-transcript.jsonl`,无 handoffworktree diffCodex 已终止 runner / ACP,不采纳该批
- 2026-05-25Batch G 按用户纠正把 Worker B/C/D 分别派到独立 worktree,但三个 worker 同时启动,超过当前 goal 的“每批最多 2 个 worker”;三个 Reasonix run `reasonix-2026-05-24T18-51-00-477Z-1307a1b4``reasonix-2026-05-24T18-51-00-504Z-2304f570``reasonix-2026-05-24T18-51-00-541Z-17d61f43` 均只有 `prompt.md` / `memory-recall.json` / `reasonix-transcript.jsonl`,无 handoff/result/finalworktree 初始 diff 为空Codex 不采纳这些 Reasonix run,只把独立 worktree 保留为 Codex 候选 patch 沙盒
- 2026-05-25Codex 主控完成 filetree upload target fallback 小切片:`filetree-runtime.js` 新增并导出 `fileTreeUploadTargetFallback(detail, deps)`,承接同步 fallback / plan 归一化;`layout.rs``fallbackFileTreeUploadTarget` 优先委托 runtime,仍保留完整 inline fallbackasync preflight、后端归属判定、`uploadFileToMediaAsset``uploadFilesWithResolvedTarget` 不迁。
- 修改:`rust/crates/mnote-web/browser/filetree-runtime.js``rust/crates/mnote-web/src/ssr/pages/layout.rs`
- 已验证:`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 filetree -- --test-threads=1``cargo test --manifest-path rust/Cargo.toml -p mnote-web local_upload_runtime_contains_editor_upload_context_helpers -- --test-threads=1``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js`
- 未完成:async preflight、`refreshLocalFolderSidebarSnapshot` / `appendUploadedAssetRow`、conflict action helpers、secondary pane conflict smoke 仍未迁出或覆盖。
- 2026-05-25Batch G Worker C 使用独立 worktree `/mnt/Data1T/mnote-worktrees/0525-g-worker-c-3-20-conflict-actions`Reasonix run `reasonix-2026-05-24T18-51-00-504Z-2304f570` 无 handoff/result/final,且 transcript 停在 `ask_choice`,不采纳。Codex 随后在该 worktree 产出候选 patch,经复核后选择性移植到主工作区。
- 修改:`document-conflict-panel-runtime.js` 新增并导出 `runSessionConflictAction(action, deps)`,只负责 promise/catch 动作包装;`web_shell.rs` 仍持有 `acceptDiskVersion``keepCurrentEditorVersion``writeMergedConflictResult`、status 和重新渲染业务逻辑。
- 已验证:`node --check rust/crates/mnote-web/browser/document-conflict-panel-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 document_conflict_panel_runtime_contains_dom_helpers -- --test-threads=1``cargo test --manifest-path rust/Cargo.toml -p mnote-web mnote_browser_runtime_assets_are_explicitly_mounted -- --test-threads=1``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task451-local-markdown-conflict-resolution-ui-smoke.js``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js`
- 未完成:`acceptDiskVersion` / `keepCurrentEditorVersion` / `writeMergedConflictResult` 业务逻辑、document session lifecycle、secondary pane conflict smoke 仍未迁出或覆盖。
@@ -67,7 +67,7 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
- 已迁函数:`node_is_within_root``active_editor_text_selection``has_active_text_selection``selection_summary``selection_has_rich_marks`
- 未迁:`SelectionPayload``selection_payload``send_selection_state*``selection_event_payload`,原因是仍依赖 bridge event、`HoveredBlockState` 和 runtime block id 边界。
- 已验证:`cargo fmt --manifest-path rust/Cargo.toml --all --check``cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`、wasm release build、`wasm-bindgen``task488``task489`、CodeGraph pending 0。
- 2026-05-25:执行口径修正:继续遵循当前 goal 的“每批最多 4 个 worker”;Reasonix 后续必须使用独立 worktree 或明确只读任务,完成后由 Codex 读取 handoff 并复核。
- 2026-05-25:执行口径修正:继续遵循当前 goal 的“每批最多 2 个 worker”;Reasonix 后续必须使用独立 worktree 或明确只读任务,完成后由 Codex 读取 handoff 并复核。
- 2026-05-25Batch D 额外 runner 曾自动启动 Worker A / Worker B,未经过本轮主控计划确认;主控已终止相关 runner / ACP 进程,不采纳这些未受控 run。遗留 task 草稿暂不删除,后续如继续使用必须重新生成受控任务书。
- 2026-05-25Reasonix runner 异常:后续实现 run 未写 `result.json``process-handoff.md/json`,部分 transcript 停在工具调用阶段;Codex 不采纳其文字结论,只复核实际 diff。
- 2026-05-25Reasonix overlay / block menu 只读审计尝试未产生 `result.json` / `process-handoff`,且运行期间出现额外 Batch A2 runner,主控已终止进程;该结果不作为正式 handoff 采纳。
@@ -120,3 +120,12 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
- 修改:`rust/spikes/leptos-tiptap-spike/src/editor_runtime/block_menu_overlay.rs``rust/spikes/leptos-tiptap-spike/src/editor_runtime/mod.rs``rust/spikes/leptos-tiptap-spike/src/lib.rs`、generated island wasm/js/d.ts。
- 已验证:`cargo fmt --manifest-path rust/Cargo.toml --all --check``cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`、wasm release build、`wasm-bindgen``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task489-block-menu-delete-undo-smoke.js``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task488-local-attachment-link-delete-undo-smoke.js`
- 未完成:`pointer_in_handle_corridor``drop_indicator_from_target` / `drop_indicator_from_point``sync_editor_overlay_state` / `try_sync_editor_overlay_state` 仍在 `lib.rs`
- 2026-05-25Batch G Worker D 先按用户纠正使用独立 worktree `/mnt/Data1T/mnote-worktrees/0525-g-worker-d-5-29-block-dnd-helpers`Reasonix run `reasonix-2026-05-24T18-51-00-541Z-17d61f43` 仅产出 `prompt.md` / `memory-recall.json` / `reasonix-transcript.jsonl`,无 handoff/result/finalworktree 初始 diff 为空,拒绝作为 Reasonix handoff 采纳。Codex 随后在该独立 worktree 产出候选 patch,经复核后选择性移植到主工作区。
- 修改:新增 `rust/spikes/leptos-tiptap-spike/src/editor_runtime/block_dnd.rs`,迁出 `pointer_in_handle_corridor` / `drop_indicator_from_target` 使用的纯几何 helper`lib.rs` 仍保留 DOM 查询、signal 编排、拖拽事件和 HTML reorder 行为。
- 已验证:`cargo fmt --manifest-path rust/Cargo.toml --all --check``cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`、wasm release build、`wasm-bindgen``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task489-block-menu-delete-undo-smoke.js``NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task488-local-attachment-link-delete-undo-smoke.js`
- 未覆盖:`cargo test --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml block_dnd -- --test-threads=1` 仍被既有 `STYLE` 测试编译错误阻断,未进入本次新增 helper 测试。
- 未完成:`drop_indicator_from_point` 的 DOM target lookup、拖拽 listener 编排、`sync_editor_overlay_state` / `try_sync_editor_overlay_state` 仍在 `lib.rs`
- 2026-05-25Batch H 只派发 1 个只读 Reasonix worker 复核 block DnD helper 边界,使用独立 worktree `/mnt/Data1T/mnote-worktrees/0525-h-5-29-block-dnd-readonly`run id `reasonix-2026-05-24T18-59-12-393Z-b5d95a7b`,并显式使用 `--no-memory-recall` 降低任务串线风险。
- Codex 已读取 Hindsight recall、`process-handoff.md/json``result.json`,并核对 worktree `git status --short` / `git diff --stat` 为空。
- 审计结论:只迁纯几何 helper 是合理边界;DOM 查询、`document.element_from_point`、event listener、Leptos signal 和拖拽重排行为继续留在 `lib.rs`
- 主控裁决:采纳审计方向,但保留当前 `editor_runtime/block_dnd.rs``HandleCorridorGeometry` 参数结构,避免 Reasonix 建议的长参数列表降低可读性。