An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prioritize recently used search history keywords https://github.com/siyuan-note/siyuan/issues/19367
Daniel40907fa17839
diff --git a/app/src/search/toggleHistory.ts b/app/src/search/toggleHistory.tsindex 70f9eaa3c1..d442cbe7fc 100644--- a/app/src/search/toggleHistory.ts+++ b/app/src/search/toggleHistory.ts@@ -83,7 +83,7 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILarequestElement = searchElement) => {const searchInputElement = searchElement.querySelector("#searchInput, #toolbarSearch") as HTMLInputElement;const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];- if (!list.keys || list.keys.length === 0 || (list.length === 1 && list[0] === searchInputElement.value)) {+ if (!list.keys || list.keys.length === 0) {return;}const menu = new Menu(Constants.MENU_SEARCH_HISTORY);@@ -102,7 +102,7 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILaconst separatorElement = menu.addSeparator(1);let current = true;list.keys.forEach((s: string) => {- if (s !== searchInputElement.value && s) {+ if (s) {const menuItem = menu.addItem({iconHTML: "",label: escapeHtml(s),@@ -124,7 +124,8 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILaelement.remove();}} else {- searchInputElement.value = element.textContent;+ searchInputElement.value = s;+ saveKeyList("keys", s, config);config.page = 1;/// #if MOBILEupdateSearchResult(config, requestElement, true);diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex 6ebb7304f0..7169ad2416 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -389,9 +389,22 @@ export const movePathTo = (options: {});};+ const saveMovePathHistory = () => {+ if (inputElement.value) {+ let list: string[] = window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys;+ list.splice(0, 0, inputElement.value);+ list = Array.from(new Set(list));+ if (list.length > window.siyuan.config.search.limit) {+ list.splice(window.siyuan.config.search.limit, list.length - window.siyuan.config.search.limit);+ }+ window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys = list;+ }+ window.siyuan.storage[Constants.LOCAL_MOVE_PATH].k = inputElement.value;+ setStorageVal(Constants.LOCAL_MOVE_PATH, window.siyuan.storage[Constants.LOCAL_MOVE_PATH]);+ };const toggleMovePathHistory = () => {const keys = window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys;- if (!keys || keys.length === 0 || (keys.length === 1 && keys[0] === inputElement.value)) {+ if (!keys || keys.length === 0) {return;}const menu = new Menu(Constants.MENU_MOVE_PATH_HISTORY);@@ -410,7 +423,7 @@ export const movePathTo = (options: {const separatorElement = menu.addSeparator(1);let current = true;keys.forEach((s: string) => {- if (s !== inputElement.value && s) {+ if (s) {const menuItem = menu.addItem({iconHTML: "",label: escapeHtml(s),@@ -432,7 +445,8 @@ export const movePathTo = (options: {element.remove();}} else {- inputElement.value = element.textContent;+ inputElement.value = s;+ saveMovePathHistory();inputEvent();window.siyuan.menus.menu.remove();}@@ -464,19 +478,7 @@ export const movePathTo = (options: {inputElement.addEventListener("input", (event: InputEvent) => {inputEvent(event);});- inputElement.addEventListener("blur", () => {- if (inputElement.value) {- let list: string[] = window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys;- list.splice(0, 0, inputElement.value);- list = Array.from(new Set(list));- if (list.length > window.siyuan.config.search.limit) {- list.splice(window.siyuan.config.search.limit, list.length - window.siyuan.config.search.limit);- }- window.siyuan.storage[Constants.LOCAL_MOVE_PATH].keys = list;- }- window.siyuan.storage[Constants.LOCAL_MOVE_PATH].k = inputElement.value;- setStorageVal(Constants.LOCAL_MOVE_PATH, window.siyuan.storage[Constants.LOCAL_MOVE_PATH]);- });+ inputElement.addEventListener("blur", saveMovePathHistory);const lineHeight = 28;inputElement.addEventListener("keydown", (event: KeyboardEvent) => {if (event.isComposing) {