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
Danielfba56d2e739f
diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.tsindex b0b93b2344..2e3f9f643e 100644--- a/app/src/layout/dock/AgentChat.ts+++ b/app/src/layout/dock/AgentChat.ts@@ -188,6 +188,7 @@ export class AgentChat extends Model {this.sessionTotalDuration = session.totalDuration || 0;if (this.composer) {this.composer.restoreHistory(session.messageHistory || []);+ console.log("[AgentChat] loaded history:", (session.messageHistory || []).length, "items, composer has:", this.composer.getHistory().length);}this.titleElement.textContent = session.title;this.updateTokenDisplay();@@ -504,6 +505,7 @@ export class AgentChat extends Model {this.messages.push({role: "user", content: text});this.appendUserMessage(text);if (this.composer) { this.composer.pushHistory(text); }+ this.saveSession().catch(function (e) { console.error(e); });this.requestStartTime = Date.now();diff --git a/app/src/layout/dock/AgentComposer.ts b/app/src/layout/dock/AgentComposer.tsindex db15427090..4563d76904 100644--- a/app/src/layout/dock/AgentComposer.ts+++ b/app/src/layout/dock/AgentComposer.ts@@ -52,6 +52,7 @@ export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHaconst history: string[] = [];let historyIdx = -1;+ let savedDraft = "";const updateHighlight = () => {if (!suggestionMenu) { return; }@@ -212,12 +213,15 @@ export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHareturn true;}if (event.key === "ArrowUp" && !suggestionMenu) {+ const navigating = historyIdx >= 0;const isEmpty = _view.state.doc.childCount === 1 &&_view.state.doc.firstChild?.childCount === 0;- if (isEmpty && history.length > 0) {+ if ((navigating || isEmpty) && history.length > 0) {event.preventDefault();- if (historyIdx === -1) { historyIdx = history.length - 1; }- else if (historyIdx > 0) { historyIdx--; }+ if (historyIdx === -1) {+ savedDraft = editor.state.doc.textContent;+ historyIdx = history.length - 1;+ } else if (historyIdx > 0) { historyIdx--; }if (historyIdx >= 0) {editor.commands.setContent(history[historyIdx]);}@@ -229,12 +233,17 @@ export function mountComposer(host: HTMLElement, onSend: () => void): ComposerHahistoryIdx++;if (historyIdx >= history.length) {historyIdx = -1;- editor.commands.clearContent();+ editor.commands.setContent(savedDraft || "");+ savedDraft = "";} else {editor.commands.setContent(history[historyIdx]);}return true;}+ if (historyIdx >= 0 && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {+ historyIdx = -1;+ savedDraft = "";+ }return false;},},