An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/14823
Vanessad97d20bd45d3
diff --git a/app/src/block/popover.ts b/app/src/block/popover.tsindex abe0a67b9a..1cc0608b55 100644--- a/app/src/block/popover.ts+++ b/app/src/block/popover.ts@@ -11,6 +11,8 @@ import {escapeAriaLabel, escapeHtml} from "../util/escape";let popoverTargetElement: HTMLElement;let notebookItemElement: HTMLElement | false;+// 异步获取信息后再显示 tooltip,鼠标已移走时需中断请求 https://github.com/siyuan-note/siyuan/issues/14823+let tooltipAbortController: AbortController | null = null;export const initBlockPopover = (app: App) => {let timeout: number;let timeoutHide: number;@@ -22,6 +24,11 @@ export const initBlockPopover = (app: App) => {hideTooltip();return;}+ // 鼠标进入新元素时中断上一轮尚未完成的 tooltip 信息请求+ if (tooltipAbortController) {+ tooltipAbortController.abort();+ tooltipAbortController = null;+ }const aElement = hasClosestByAttribute(event.target, "data-type", "a", true) ||hasClosestByClassName(event.target, "ariaLabel") ||hasClosestByAttribute(event.target, "data-type", "tab-header") ||@@ -101,7 +108,13 @@ export const initBlockPopover = (app: App) => {const title = aElement.getAttribute("data-title");if (tip && isLocalPath(href) && !aElement.classList.contains("b3-tooltips")) {let assetTip = tip;+ tooltipAbortController = new AbortController();+ const signal = tooltipAbortController.signal;+ const capturedController = tooltipAbortController;fetchPost("/api/asset/statAsset", {path: href}, (response) => {+ if (signal.aborted) {+ return;+ }if (response.code === 1) {if (title) {assetTip += '<div class="fn__hr"></div><span>' + title + "</span>";@@ -114,7 +127,10 @@ export const initBlockPopover = (app: App) => {} catch (e) {showTooltip(assetTip, aElement, tooltipClass, event, tooltipSpace);}- });+ if (tooltipAbortController === capturedController) {+ tooltipAbortController = null;+ }+ }, undefined, undefined, signal);tip = "";} else if (title) {tip = (tip ? (tip + '<div class="fn__hr"></div>') : "") + "<span>" + title + "</span>";@@ -123,19 +139,22 @@ export const initBlockPopover = (app: App) => {notebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");if (notebookItemElement && notebookItemElement.parentElement.getAttribute("data-type") === "navigation-root") {- fetchPost("/api/notebook/getNotebookInfo", {notebook: notebookItemElement.parentElement.parentElement.getAttribute("data-url")}, (response) => {+ const scopedNotebookItemElement = notebookItemElement;+ tooltipAbortController = new AbortController();+ const signal = tooltipAbortController.signal;+ const capturedController = tooltipAbortController;+ fetchPost("/api/notebook/getNotebookInfo", {notebook: scopedNotebookItemElement.parentElement.parentElement.getAttribute("data-url")}, (response) => {+ if (signal.aborted) {+ return;+ }const boxData = response.data.boxInfo;const tip = `${boxData.name} <small class='ft__on-surface'>${boxData.hSize}</small>${boxData.docCount !== 0 ? window.siyuan.languages.includeSubFile.replace("x", boxData.docCount) : ""}<br>${window.siyuan.languages.modifiedAt} ${boxData.hMtime}<br>${window.siyuan.languages.createdAt} ${boxData.hCtime}`;- const scopeNotebookItemElement = hasClosestByClassName(event.target, "b3-list-item__text");- if (notebookItemElement && scopeNotebookItemElement && (notebookItemElement === scopeNotebookItemElement)) {- showTooltip(tip, notebookItemElement);- }- if (scopeNotebookItemElement &&- scopeNotebookItemElement.parentElement.getAttribute("data-type") === "navigation-root" &&- scopeNotebookItemElement.parentElement.parentElement.getAttribute("data-url") === boxData.id) {- scopeNotebookItemElement.setAttribute("aria-label", tip);+ showTooltip(tip, scopedNotebookItemElement);+ scopedNotebookItemElement.setAttribute("aria-label", tip);+ if (tooltipAbortController === capturedController) {+ tooltipAbortController = null;}- });+ }, undefined, undefined, signal);}if (tip && !aElement.classList.contains("b3-tooltips")) {diff --git a/app/src/layout/Tab.ts b/app/src/layout/Tab.tsindex 6789ea0f5a..69f97cd0f7 100644--- a/app/src/layout/Tab.ts+++ b/app/src/layout/Tab.ts@@ -25,6 +25,8 @@ export class Tab {public title: string;public icon: string;public docIcon: string;+ // 鼠标已移走时中断尚未完成的完整路径请求 https://github.com/siyuan-note/siyuan/issues/14823+ public hPathAbortController: AbortController | null = null;constructor(options: ITab) {this.id = genUUID();@@ -69,18 +71,36 @@ export class Tab {}}if (id) {+ if (this.hPathAbortController) {+ this.hPathAbortController.abort();+ }+ this.hPathAbortController = new AbortController();+ const signal = this.hPathAbortController.signal;+ const capturedController = this.hPathAbortController;fetchPost("/api/filetree/getFullHPathByID", {id}, (response) => {+ if (signal.aborted) {+ return;+ }if (!this.headElement.getAttribute("aria-label")) {showTooltip(escapeLessThans(response.data), this.headElement);}this.headElement.setAttribute("aria-label", escapeLessThans(response.data));- });+ if (this.hPathAbortController === capturedController) {+ this.hPathAbortController = null;+ }+ }, undefined, undefined, signal);} else {this.headElement.setAttribute("aria-label", escapeLessThans(this.title));}});+ this.headElement.addEventListener("mouseleave", () => {+ if (this.hPathAbortController) {+ this.hPathAbortController.abort();+ this.hPathAbortController = null;+ }+ });this.headElement.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {window.getSelection().removeAllRanges();hideTooltip();