An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797
Danield79e42432d1d
diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.tsindex 17855775c9..203df04e8c 100644--- a/app/src/layout/dock/AgentChat.ts+++ b/app/src/layout/dock/AgentChat.ts@@ -508,6 +508,7 @@ export class AgentChat extends Model {this.messages.push({role: "user", content: text});this.appendUserMessage(text);+ if (this.composer) { this.composer.pushHistory(text); }this.requestStartTime = Date.now();diff --git a/app/src/layout/dock/AgentComposer.ts b/app/src/layout/dock/AgentComposer.tsindex ddd9f92993..8d1dfab57a 100644--- a/app/src/layout/dock/AgentComposer.ts+++ b/app/src/layout/dock/AgentComposer.ts@@ -20,6 +20,7 @@ interface ComposerHandle {destroy: () => void;getSendData: () => {text: string; references: {id: string; title: string}[]};clear: () => void;+ pushHistory: (text: string) => void;}export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHandle {@@ -46,6 +47,9 @@ export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHasuggestionItems = [];};+ const history: string[] = [];+ let historyIdx = -1;+const updateHighlight = () => {if (!suggestionMenu) { return; }const items = suggestionMenu.querySelectorAll(".agent-mention-menu__item");@@ -204,6 +208,29 @@ export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHaonSend();return true;}+ if (event.key === "ArrowUp" && !suggestionMenu) {+ const isEmpty = _view.state.doc.textContent.trim() === "";+ if (isEmpty && history.length > 0) {+ event.preventDefault();+ if (historyIdx === -1) { historyIdx = history.length - 1; }+ else if (historyIdx > 0) { historyIdx--; }+ if (historyIdx >= 0) {+ editor.commands.setContent(history[historyIdx]);+ }+ return true;+ }+ }+ if (event.key === "ArrowDown" && !suggestionMenu && historyIdx >= 0) {+ event.preventDefault();+ historyIdx++;+ if (historyIdx >= history.length) {+ historyIdx = -1;+ editor.commands.clearContent();+ } else {+ editor.commands.setContent(history[historyIdx]);+ }+ return true;+ }return false;},},@@ -226,5 +253,11 @@ export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHareturn {text: textParts.join("").trim(), references: refs};},clear: function () { editor.commands.clearContent(); },+ pushHistory: function (text: string) {+ if (!text || history[history.length - 1] === text) { return; }+ history.push(text);+ if (history.length > 50) { history.shift(); }+ historyIdx = -1;+ },};}