feat: add evidence search and stabilize pdf previews
- add document evidence parsing/search/open routes, Hermes tool wiring, local index settings/status, and the document-evidence skill plus design notes - fix PDF resource tabs by rendering PDFs inline with pdf.js canvases instead of iframe preview pages, release PDF documents on close, and document the fourth-PDF stall bug - keep PDF preview at 2x rendering while removing the previous lazy-load/placeholder direction, and make dev:hot bind loopback defaults externally reachable Verification: - node --check rust/crates/mnote-web/browser/document-resource-tab-runtime.js - node scripts/task-dev-hot-plan-test.js - cargo test -p mnote-web --manifest-path rust/Cargo.toml pdf_preview_page_does_not_render_visible_toolbar - cargo test -p mnote-web --manifest-path rust/Cargo.toml document_shell_returns_page_aggregate_snapshot - cargo build -p mnote-web --manifest-path rust/Cargo.toml - browser smoke: sequentially opened the four tea_seed_oil_cosmetic PDFs; fourth PDF rendered 15/15 canvases, iframeCount=0, browser errors=0
This commit is contained in:
@@ -140,7 +140,7 @@ pub fn PageLayout(
|
||||
<nav class="mnote-sidebar-nav wolai-quick-actions" aria-label="快捷操作" data-testid="wolai-sidebar-quick-actions">
|
||||
<a href="/search" class:active={current_nav == "search"} title="搜索" aria-label="搜索" data-mnote-action="open-search-modal"><span class="material-symbols-outlined nav-icon" data-icon="search" aria-hidden="true"></span></a>
|
||||
<a href="/graph" title="关系图" aria-label="关系图"><span class="material-symbols-outlined nav-icon" data-icon="account_tree" aria-hidden="true"></span></a>
|
||||
<a href="/actions" title="快捷动作" aria-label="快捷动作"><span class="material-symbols-outlined nav-icon" data-icon="bolt" aria-hidden="true"></span></a>
|
||||
<button type="button" title="导航页" aria-label="导航页" data-mnote-action="open-navigation-page"><span class="material-symbols-outlined nav-icon" data-icon="home" aria-hidden="true"></span></button>
|
||||
<a href="/help" title="帮助" aria-label="帮助"><span class="material-symbols-outlined nav-icon" data-icon="help" aria-hidden="true"></span></a>
|
||||
<a href="/files" title="文件" aria-label="文件"><span class="material-symbols-outlined nav-icon" data-icon="inventory_2" aria-hidden="true"></span></a>
|
||||
<button type="button" title="打开本地文件夹" aria-label="打开本地文件夹" data-mnote-action="open-local-folder"><span class="material-symbols-outlined nav-icon" data-icon="folder_open" aria-hidden="true"></span></button>
|
||||
@@ -188,7 +188,8 @@ pub fn PageLayout(
|
||||
<span class="wolai-public-pill" data-testid="wolai-public-state" hidden></span>
|
||||
<button type="button" class="wolai-icon-button" title="星标置顶" aria-label="星标置顶" data-mnote-action="toggle-sidebar-shortcut" data-mnote-shortcut-kind="page"><span class="material-symbols-outlined" data-icon="star" aria-hidden="true"></span></button>
|
||||
<button type="button" class="wolai-icon-button" title="演示" aria-label="演示"><span class="material-symbols-outlined" data-icon="slideshow" aria-hidden="true"></span></button>
|
||||
<button type="button" class="wolai-icon-button mnote-local-ocr-task-toggle" title="OCR 任务" aria-label="OCR 任务" data-testid="mnote-local-ocr-task-toggle" data-mnote-action="toggle-ocr-tasks"><span class="material-symbols-outlined" data-icon="document_scanner" aria-hidden="true"></span><span class="mnote-local-ocr-task-badge" data-mnote-local-ocr-task-count hidden>0</span></button>
|
||||
<button type="button" class="wolai-icon-button mnote-local-ocr-task-toggle" title="OCR 设置" aria-label="OCR 设置" data-testid="mnote-local-ocr-task-toggle" data-mnote-action="open-ocr-settings"><span class="material-symbols-outlined" data-icon="document_scanner" aria-hidden="true"></span><span class="mnote-local-ocr-task-badge" data-mnote-local-ocr-task-count hidden>0</span></button>
|
||||
<button type="button" class="wolai-icon-button" title="索引设置" aria-label="索引设置" data-testid="mnote-local-index-settings-toggle" data-mnote-action="open-index-settings"><span class="material-symbols-outlined" data-icon="manage_search" aria-hidden="true"></span></button>
|
||||
<button type="button" class="wolai-icon-button" title="评论" aria-label="评论"><span class="material-symbols-outlined" data-icon="comment" aria-hidden="true"></span></button>
|
||||
<button type="button" class="wolai-icon-button" title="分享" aria-label="分享"><span class="material-symbols-outlined" data-icon="share" aria-hidden="true"></span></button>
|
||||
<button type="button" class="wolai-icon-button" title="成员" aria-label="成员"><span class="material-symbols-outlined" data-icon="person_add" aria-hidden="true"></span></button>
|
||||
@@ -436,7 +437,12 @@ mod tests {
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("toggle-sidebar-shortcut"));
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("openStarredFolderShortcut"));
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("function openNavigationPageForFolder"));
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("function openCurrentNavigationPage"));
|
||||
assert!(
|
||||
SIDEBAR_TREE_RUNTIME_JS.contains("openCurrentNavigationPage(navigationPageTrigger)")
|
||||
);
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("/api/navigation/recent"));
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("await renderPageProjection(sidebarProjection)"));
|
||||
assert!(!SIDEBAR_TREE_RUNTIME_JS.contains("authRedirectUrl"));
|
||||
assert!(!SIDEBAR_TREE_RUNTIME_JS.contains("window.location.assign(authRedirectUrl())"));
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("window.location.assign(url)"));
|
||||
@@ -467,6 +473,64 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_layout_quick_action_opens_current_navigation_page() {
|
||||
let html = crate::ssr::render_view(leptos::view! {
|
||||
<super::PageLayout current_nav="documents" topbar_title={"个人".to_string()}>
|
||||
<main>"正文"</main>
|
||||
</super::PageLayout>
|
||||
});
|
||||
|
||||
assert!(html.contains(r#"data-mnote-action="open-navigation-page""#));
|
||||
assert!(html.contains(r#"title="导航页""#));
|
||||
assert!(!html.contains(r#"href="/actions""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_layout_exposes_standalone_index_and_ocr_settings() {
|
||||
let html = crate::ssr::render_view(leptos::view! {
|
||||
<super::PageLayout current_nav="documents" topbar_title={"个人".to_string()}>
|
||||
<main>"正文"</main>
|
||||
</super::PageLayout>
|
||||
});
|
||||
|
||||
assert!(html.contains(r#"data-testid="mnote-local-index-settings-toggle""#));
|
||||
assert!(html.contains(r#"data-mnote-action="open-index-settings""#));
|
||||
assert!(html.contains(r#"data-icon="manage_search""#));
|
||||
assert!(html.contains(r#"data-testid="mnote-local-ocr-task-toggle""#));
|
||||
assert!(html.contains(r#"data-mnote-action="open-ocr-settings""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_settings_runtime_keeps_index_and_ocr_out_of_page_settings() {
|
||||
assert!(SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("mnote-local-index-settings-popover"));
|
||||
assert!(SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("mnote-local-ocr-settings-popover"));
|
||||
assert!(SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("data-local-index-range-input"));
|
||||
assert!(SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("data-index-status=\"' + kind"));
|
||||
assert!(SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("if (kind === 'indexed')"));
|
||||
assert!(
|
||||
SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains(
|
||||
"renderLocalIndexRangeRows(popover, currentLocalIndexRangeValues(popover).concat([''])"
|
||||
),
|
||||
"新增索引范围必须保留空白输入行,不能先过滤成默认 ."
|
||||
);
|
||||
assert!(
|
||||
SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("if (!values.length) values = [''];"),
|
||||
"删除最后一个索引范围时 UI 应显示空行,不能强制回填 ."
|
||||
);
|
||||
assert!(SIDEBAR_PAGE_SETTINGS_RUNTIME_JS
|
||||
.contains("data-local-ocr-settings-action=\"run-active\""));
|
||||
assert!(SIDEBAR_TREE_RUNTIME_JS.contains("mnote:local-ocr-settings-action"));
|
||||
assert!(!SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("data-page-settings-tab=\"index\""));
|
||||
assert!(!SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("本地索引仅在本地工作区页面可用"));
|
||||
assert!(
|
||||
!SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("wolai-page-settings-local-index-backlinks")
|
||||
);
|
||||
assert!(!SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("wolai-page-settings-local-index-tags"));
|
||||
assert!(!SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("backlinksUrl"));
|
||||
assert!(!SIDEBAR_PAGE_SETTINGS_RUNTIME_JS.contains("tagsUrl"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_filetree_folder_click_toggles_instead_of_navigation_page() {
|
||||
let folder_branch = SIDEBAR_TREE_RUNTIME_JS
|
||||
@@ -1258,7 +1322,7 @@ mod tests {
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("function markExistingFileTreeChildrenLoaded"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("if (markExistingFileTreeChildrenLoaded(row, button))"));
|
||||
.contains("if (!stale && markExistingFileTreeChildrenLoaded(row, button, options))"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("scheduleRestorePersistedFileTreeExpansionState();"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("function patchFileTreeParentChildren"));
|
||||
@@ -1288,10 +1352,10 @@ mod tests {
|
||||
"非 scope parent projection 必须先局部 patch,不能替换整棵 filetree"
|
||||
);
|
||||
let load_start = SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.find("async function loadFileTreeChildren(row, button)")
|
||||
.find("async function loadFileTreeChildren(row, button, options)")
|
||||
.expect("lazy children loader");
|
||||
let optimistic_expand = SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS[load_start..]
|
||||
.find("setTreeRowExpanded(row, button, true);")
|
||||
.find("setTreeRowExpanded(row, button, true, options);")
|
||||
.expect("lazy loading should mark the requested folder expanded before fetch")
|
||||
+ load_start;
|
||||
let fetch_start = SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS[load_start..]
|
||||
@@ -1394,6 +1458,11 @@ mod tests {
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("tree_error"));
|
||||
assert!(TREE_LIVE_CONTROLLER_JS.contains("tree:error"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("function applyLocalFolderWatchBatch"));
|
||||
assert!(
|
||||
SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("function watchBatchNeedsPageTreeRefresh")
|
||||
);
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("data-mnote-local-folder-watch-sidebar-refresh-skipped"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("data-mnote-local-folder-watch-batch-applied"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("data-mnote-tree-live-error-schema"));
|
||||
@@ -1416,6 +1485,41 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_filetree_runtime_hydrates_visible_expanded_rows_on_idle() {
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("function scheduleHydrateVisibleExpandedFileTreeRows"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("function hydrateVisibleExpandedFileTreeRows"));
|
||||
assert!(
|
||||
SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("FILETREE_VISIBLE_EXPANDED_HYDRATE_MAX")
|
||||
);
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("requestIdleCallback"));
|
||||
assert!(
|
||||
SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS.contains("data-mnote-filetree-idle-hydrate-applied")
|
||||
);
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("row.getAttribute('aria-expanded') === 'true'"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("row.getAttribute('data-filetree-children-loaded') !== 'true'"));
|
||||
assert!(SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.contains("loadFileTreeChildren(row, button, { persist: false, idleHydrate: true })"));
|
||||
|
||||
let restore_start = SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS
|
||||
.find("function restorePersistedFileTreeExpansionState")
|
||||
.expect("restorePersistedFileTreeExpansionState");
|
||||
let restore_end = SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS[restore_start..]
|
||||
.find("function installTreeLiveApplyEventListeners")
|
||||
.map(|offset| restore_start + offset)
|
||||
.expect("restore function end");
|
||||
let restore_body = &SIDEBAR_TREE_LIVE_APPLY_RUNTIME_JS[restore_start..restore_end];
|
||||
assert!(restore_body.contains("scheduleHydrateVisibleExpandedFileTreeRows('restore')"));
|
||||
assert!(
|
||||
!restore_body.contains("then(function(loaded)"),
|
||||
"恢复 view-state 不能递归拉取历史 expanded path"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_filetree_runtime_reprojects_selection_focus_after_patch() {
|
||||
assert!(
|
||||
@@ -1493,6 +1597,24 @@ mod tests {
|
||||
assert!(SIDEBAR_FILETREE_COMMAND_RUNTIME_JS.contains("确认删除选中的 "));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_filetree_bulk_delete_refreshes_local_folder_after_success() {
|
||||
let bulk_delete_start = SIDEBAR_FILETREE_COMMAND_RUNTIME_JS
|
||||
.find("async function deleteSelectedSidebarFileTreeRows")
|
||||
.expect("bulk delete function");
|
||||
let bulk_delete_end = SIDEBAR_FILETREE_COMMAND_RUNTIME_JS[bulk_delete_start..]
|
||||
.find("return {")
|
||||
.map(|offset| bulk_delete_start + offset)
|
||||
.expect("bulk delete function end");
|
||||
let bulk_delete = &SIDEBAR_FILETREE_COMMAND_RUNTIME_JS[bulk_delete_start..bulk_delete_end];
|
||||
assert!(bulk_delete.contains(
|
||||
"if (currentSourceKind() === 'local_folder') void refreshLocalFolderSidebarSnapshot();"
|
||||
));
|
||||
assert!(!bulk_delete.contains(
|
||||
"if (currentSourceKind() !== 'local_folder') void refreshLocalFolderSidebarSnapshot();"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sidebar_filetree_blocks_readonly_paste_and_drop_with_action_status() {
|
||||
assert!(SIDEBAR_FILETREE_UPLOAD_RUNTIME_JS.contains("function blockReadonlyFileTreeAction"));
|
||||
@@ -1587,6 +1709,10 @@ mod tests {
|
||||
fn sidebar_filetree_runtime_does_not_keep_retired_table_engine_branches() {
|
||||
let retired_table_engine = ["lucky", "sheet"].concat();
|
||||
assert!(!SIDEBAR_FILETREE_COMMAND_RUNTIME_JS.contains(&retired_table_engine));
|
||||
let retired_api = ["/api/", "lucky"].concat();
|
||||
let retired_constructor = ["create", "Luck"].concat();
|
||||
assert!(!SIDEBAR_FILETREE_COMMAND_RUNTIME_JS.contains(&retired_constructor));
|
||||
assert!(!SIDEBAR_FILETREE_COMMAND_RUNTIME_JS.contains(&retired_api));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user