refactor: externalize local folder watch marker
This commit is contained in:
@@ -181,3 +181,7 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
|
|||||||
- 边界:未改 `refreshLocalFolderSidebarSnapshot` 的 fetch URL、projection JSON 渲染主路径、watcher 标记、focus/selection/sidebar shell 副作用;不把 HTML snapshot 应用重新接入主刷新流程。
|
- 边界:未改 `refreshLocalFolderSidebarSnapshot` 的 fetch URL、projection JSON 渲染主路径、watcher 标记、focus/selection/sidebar shell 副作用;不把 HTML snapshot 应用重新接入主刷新流程。
|
||||||
- Worker C 验证:`git diff --check`、`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_runtime -- --test-threads=1` 通过。
|
- Worker C 验证:`git diff --check`、`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_runtime -- --test-threads=1` 通过。
|
||||||
- Worker D smoke:Reasonix run `reasonix-2026-05-24T22-26-26-122Z-62733e93` 有完整 handoff/result/截图且源码零 diff;`task487-local-folder-tree-live-consumer-smoke.js` 在 3001 通过,PageTree/FileTree 外部创建/删除均为 `treeLiveApplied=resync`,导航数为 0。
|
- Worker D smoke:Reasonix run `reasonix-2026-05-24T22-26-26-122Z-62733e93` 有完整 handoff/result/截图且源码零 diff;`task487-local-folder-tree-live-consumer-smoke.js` 在 3001 通过,PageTree/FileTree 外部创建/删除均为 `treeLiveApplied=resync`,导航数为 0。
|
||||||
|
- 2026-05-25:Batch AB 未派发 Reasonix worker;Codex 主控完成 `refreshLocalFolderSidebarSnapshot` 内部 watch projection 标记的小切片。
|
||||||
|
- 修改:`filetree-runtime.js` 新增并导出 `markLocalFolderWatchApplied(value)`;`layout.rs` 的同名 wrapper 优先委托 runtime,inline fallback 保留 `data-mnote-local-folder-watch-applied="projection"` 行为。
|
||||||
|
- 边界:未改 projection fetch URL、JSON 渲染、selection/focus/sidebar shell 副作用、附件存在性刷新、tree live SSE consumer;本批只外置刷新完成证据标记。
|
||||||
|
- 已验证:`node --check rust/crates/mnote-web/browser/filetree-runtime.js`、`git diff --check`、`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_runtime -- --test-threads=1`。
|
||||||
|
|||||||
@@ -239,6 +239,13 @@ function applyLocalFolderSidebarSnapshot(nextDocument, options) {
|
|||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function markLocalFolderWatchApplied(value) {
|
||||||
|
var appliedValue = String(value || 'projection');
|
||||||
|
if (!document || !document.documentElement) return false;
|
||||||
|
document.documentElement.setAttribute('data-mnote-local-folder-watch-applied', appliedValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function revealFileTreeRow(row) {
|
function revealFileTreeRow(row) {
|
||||||
if (!(row instanceof HTMLElement)) return;
|
if (!(row instanceof HTMLElement)) return;
|
||||||
var node = row.closest('.tree-node');
|
var node = row.closest('.tree-node');
|
||||||
@@ -378,6 +385,7 @@ window.__mnoteFileTreeRuntime = {
|
|||||||
groupRowsByParent: groupRowsByParent,
|
groupRowsByParent: groupRowsByParent,
|
||||||
replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument,
|
replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument,
|
||||||
applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot,
|
applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot,
|
||||||
|
markLocalFolderWatchApplied: markLocalFolderWatchApplied,
|
||||||
fileTreeRowKind: fileTreeRowKind,
|
fileTreeRowKind: fileTreeRowKind,
|
||||||
fileTreeRowDocumentId: fileTreeRowDocumentId,
|
fileTreeRowDocumentId: fileTreeRowDocumentId,
|
||||||
fileTreeRowAssetId: fileTreeRowAssetId,
|
fileTreeRowAssetId: fileTreeRowAssetId,
|
||||||
|
|||||||
@@ -2442,6 +2442,14 @@ const SIDEBAR_TREE_JS: &str = r##"
|
|||||||
return applied;
|
return applied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function markLocalFolderWatchApplied(value) {
|
||||||
|
var runtimeFn = fileTreeRuntimeFunction('markLocalFolderWatchApplied');
|
||||||
|
if (runtimeFn) return runtimeFn(value);
|
||||||
|
var appliedValue = String(value || 'projection');
|
||||||
|
document.documentElement.setAttribute('data-mnote-local-folder-watch-applied', appliedValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
async function refreshLocalFolderSidebarSnapshot() {
|
async function refreshLocalFolderSidebarSnapshot() {
|
||||||
var workspaceId = currentWorkspaceId();
|
var workspaceId = currentWorkspaceId();
|
||||||
var rootUri = currentRootUri();
|
var rootUri = currentRootUri();
|
||||||
@@ -2474,7 +2482,7 @@ const SIDEBAR_TREE_JS: &str = r##"
|
|||||||
schedulePendingLocalFolderRestoreFocus();
|
schedulePendingLocalFolderRestoreFocus();
|
||||||
restoreSidebarTreeTab();
|
restoreSidebarTreeTab();
|
||||||
refreshEditorLocalAttachmentExistence();
|
refreshEditorLocalAttachmentExistence();
|
||||||
document.documentElement.setAttribute('data-mnote-local-folder-watch-applied', 'projection');
|
markLocalFolderWatchApplied('projection');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11111,6 +11119,7 @@ mod tests {
|
|||||||
assert!(
|
assert!(
|
||||||
SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('applyLocalFolderSidebarSnapshot')")
|
SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('applyLocalFolderSidebarSnapshot')")
|
||||||
);
|
);
|
||||||
|
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('markLocalFolderWatchApplied')"));
|
||||||
let document_id_body = js_function_body(SIDEBAR_TREE_JS, "fileTreeRowDocumentId");
|
let document_id_body = js_function_body(SIDEBAR_TREE_JS, "fileTreeRowDocumentId");
|
||||||
assert!(
|
assert!(
|
||||||
document_id_body.contains("data-document-id")
|
document_id_body.contains("data-document-id")
|
||||||
@@ -11131,6 +11140,12 @@ mod tests {
|
|||||||
&& apply_body.contains("replaceSidebarTreeFromDocument(nextDocument, fileRootId)"),
|
&& apply_body.contains("replaceSidebarTreeFromDocument(nextDocument, fileRootId)"),
|
||||||
"inline fallback 必须保留 sidebar/page tree DOM 应用行为"
|
"inline fallback 必须保留 sidebar/page tree DOM 应用行为"
|
||||||
);
|
);
|
||||||
|
let watch_applied_body = js_function_body(SIDEBAR_TREE_JS, "markLocalFolderWatchApplied");
|
||||||
|
assert!(
|
||||||
|
watch_applied_body.contains("data-mnote-local-folder-watch-applied")
|
||||||
|
&& watch_applied_body.contains("String(value || 'projection')"),
|
||||||
|
"inline fallback 必须保留 local folder watch projection 标记"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -11161,12 +11176,15 @@ mod tests {
|
|||||||
assert!(FILETREE_RUNTIME_JS.contains("function groupRowsByParent"));
|
assert!(FILETREE_RUNTIME_JS.contains("function groupRowsByParent"));
|
||||||
assert!(FILETREE_RUNTIME_JS.contains("function replaceSidebarTreeFromDocument"));
|
assert!(FILETREE_RUNTIME_JS.contains("function replaceSidebarTreeFromDocument"));
|
||||||
assert!(FILETREE_RUNTIME_JS.contains("function applyLocalFolderSidebarSnapshot"));
|
assert!(FILETREE_RUNTIME_JS.contains("function applyLocalFolderSidebarSnapshot"));
|
||||||
|
assert!(FILETREE_RUNTIME_JS.contains("function markLocalFolderWatchApplied"));
|
||||||
assert!(FILETREE_RUNTIME_JS.contains("appendUploadedAssetRow: appendUploadedAssetRow"));
|
assert!(FILETREE_RUNTIME_JS.contains("appendUploadedAssetRow: appendUploadedAssetRow"));
|
||||||
assert!(FILETREE_RUNTIME_JS.contains("groupRowsByParent: groupRowsByParent"));
|
assert!(FILETREE_RUNTIME_JS.contains("groupRowsByParent: groupRowsByParent"));
|
||||||
assert!(FILETREE_RUNTIME_JS
|
assert!(FILETREE_RUNTIME_JS
|
||||||
.contains("replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument"));
|
.contains("replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument"));
|
||||||
assert!(FILETREE_RUNTIME_JS
|
assert!(FILETREE_RUNTIME_JS
|
||||||
.contains("applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot"));
|
.contains("applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot"));
|
||||||
|
assert!(FILETREE_RUNTIME_JS
|
||||||
|
.contains("markLocalFolderWatchApplied: markLocalFolderWatchApplied"));
|
||||||
assert!(FILETREE_RUNTIME_JS
|
assert!(FILETREE_RUNTIME_JS
|
||||||
.contains("uploadIntent: String(detail.uploadIntent || 'filetree.folder.drop')"));
|
.contains("uploadIntent: String(detail.uploadIntent || 'filetree.folder.drop')"));
|
||||||
assert!(FILETREE_RUNTIME_JS
|
assert!(FILETREE_RUNTIME_JS
|
||||||
|
|||||||
Reference in New Issue
Block a user