refactor: reuse filetree selection runtime path

This commit is contained in:
lix-2026
2026-05-25 07:58:32 +08:00
parent 2c3077cb24
commit 6b39454caf
2 changed files with 13 additions and 4 deletions
@@ -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-25Batch 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`
@@ -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]