From 6b39454cafdc61935714ebc230a6d1b8d3171e67 Mon Sep 17 00:00:00 2001 From: lix-2026 Date: Mon, 25 May 2026 07:55:37 +0800 Subject: [PATCH] refactor: reuse filetree selection runtime path --- .../3-20-browser-runtime-followup-checklist-v1.md | 5 +++++ rust/crates/mnote-web/src/ssr/pages/layout.rs | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/design/03-rust-web/process/3-20-browser-runtime-followup-checklist-v1.md b/design/03-rust-web/process/3-20-browser-runtime-followup-checklist-v1.md index 6f4d2c05..f9d9c4b5 100644 --- a/design/03-rust-web/process/3-20-browser-runtime-followup-checklist-v1.md +++ b/design/03-rust-web/process/3-20-browser-runtime-followup-checklist-v1.md @@ -202,3 +202,8 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据 - 2026-05-25:发现未授权 Reasonix runner / ACP 进程指向 `/mnt/Data1T/mnote-worktrees/0525-af-worker-b-3-20-filetree-selection-helper`。 - 处置:该 worker 未由主控按当前 goal 派发,已终止相关 `reasonix-coding-runner` / `reasonix acp` 进程;主控复查后未发现残留 Reasonix worker。 - 采纳:不读取、不采纳该 worktree 的任何输出;后续若要审计 `syncSidebarFileTreeSelection`,必须重新按最多 2 worker 的短批次显式派发。 +- 2026-05-25:Batch AH 只派发 1 个只读 Reasonix worker 审计 filetree selection runtime 边界,使用独立 worktree `/mnt/Data1T/mnote-worktrees/0525-ah-worker-b-3-20-filetree-selection-readonly`,run id `reasonix-2026-05-24T23-50-15-233Z-0cee779d`。 + - Codex 已读取 Hindsight recall、`process-handoff.md/json`,并核对 worktree `git status --short` / `git diff --stat` 为空;runner 完成后未发现残留 Reasonix worker。 + - 审计结论经 Codex 复核后采纳:`syncSidebarFileTreeSelection` 已通过 `filetree-selection-runtime.js` 完成 runtime 外置,不应合并进 `filetree-runtime.js`;selection runtime、filetree DOM/data runtime、context menu runtime 继续保持分离。 + - Codex 主控完成后续小切片:`selectSidebarFileTreeDocument` 继续负责按 documentId 找行、active 标记和滚动,但选中状态改为复用 `selectSidebarFileTreeRow(row, { ctrlKey:false, metaKey:false, shiftKey:false })`,避免继续手写第二份 filetree selection 状态同步路径。 + - 已验证:`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_filetree_selection_runtime_helpers_are_externalized_with_inline_fallback -- --test-threads=1`、`cargo test --manifest-path rust/Cargo.toml -p mnote-web filetree_selection_runtime_contains_selection_helpers -- --test-threads=1`、临时当前源码服务 `MNOTE_WEB_BIND=127.0.0.1:3014 MNOTE_WEB_PUBLIC_BIND=127.0.0.1:3014 cargo run --manifest-path rust/Cargo.toml -p mnote-web`、`MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3014 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js`。 diff --git a/rust/crates/mnote-web/src/ssr/pages/layout.rs b/rust/crates/mnote-web/src/ssr/pages/layout.rs index 03a13831..65530ad4 100644 --- a/rust/crates/mnote-web/src/ssr/pages/layout.rs +++ b/rust/crates/mnote-web/src/ssr/pages/layout.rs @@ -5170,13 +5170,10 @@ const SIDEBAR_TREE_JS: &str = r##" if (!(row instanceof HTMLElement)) return false; var rowId = row.getAttribute('data-row-id') || ''; if (!rowId) return false; - sidebarFileTreeSelection.selectedRowIds = new Set([rowId]); - sidebarFileTreeSelection.anchorRowId = rowId; - sidebarFileTreeSelection.focusedRowId = rowId; + selectSidebarFileTreeRow(row, { ctrlKey: false, metaKey: false, shiftKey: false }); document.querySelectorAll('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"][data-active="true"]').forEach(function(activeRow) { if (activeRow instanceof HTMLElement) activeRow.setAttribute('data-active', 'false'); }); - syncSidebarFileTreeSelection(); row.setAttribute('data-active', 'true'); if (options && options.scrollIntoView !== false) { try { @@ -11210,6 +11207,13 @@ mod tests { && select_body.contains("ctrlKey"), "inline fallback 必须保留 shift range 与 ctrl/meta toggle" ); + let select_document_body = + js_function_body(SIDEBAR_TREE_JS, "selectSidebarFileTreeDocument"); + assert!( + select_document_body + .contains("selectSidebarFileTreeRow(row, { ctrlKey: false, metaKey: false, shiftKey: false })"), + "document selection 应复用 filetree row selection runtime/fallback" + ); } #[test]