Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797

Daniel8ae4af4e43ec
diff --git a/app/src/layout/dock/AgentChat.ts b/app/src/layout/dock/AgentChat.ts
index 995ac2bd7f..373d5981f5 100644
--- a/app/src/layout/dock/AgentChat.ts
+++ b/app/src/layout/dock/AgentChat.ts
@@ -219,6 +219,7 @@ export class AgentChat extends Model {
this.sessionPromptTokens = session.promptTokens || 0;
this.sessionCompletionTokens = session.completionTokens || 0;
this.sessionTotalDuration = session.totalDuration || 0;
+ if (session.model) { this.modelSelect.value = session.model; }
if (this.composer) {
this.composer.restoreHistory(session.messageHistory || []);
}
@@ -372,6 +373,7 @@ export class AgentChat extends Model {
updatedAt: Date.now(),
messageHistory: this.composer?.getHistory() || [],
thinkingSteps: this.thinkingSteps,
+ model: this.getSelectedModel(),
};
await SessionStore.save(session);
}
@@ -398,6 +400,7 @@ export class AgentChat extends Model {
this.sessionPromptTokens = session.promptTokens || 0;
this.sessionCompletionTokens = session.completionTokens || 0;
this.sessionTotalDuration = session.totalDuration || 0;
+ if (session.model) { this.modelSelect.value = session.model; }
if (this.tokenDisplayEl) {
this.updateTokenDisplay();
}
diff --git a/app/src/layout/dock/SessionStore.ts b/app/src/layout/dock/SessionStore.ts
index 29f6dea0d8..cb5f4db3ce 100644
--- a/app/src/layout/dock/SessionStore.ts
+++ b/app/src/layout/dock/SessionStore.ts
@@ -6,6 +6,7 @@ const SESSIONS_INDEX = SESSIONS_DIR + "index.json";
interface SessionIndexItem {
id: string;
title: string;
+ model?: string;
createdAt: number;
updatedAt: number;
}
@@ -13,6 +14,7 @@ interface SessionIndexItem {
export interface AgentSession {
id: string;
title: string;
+ model?: string;
messages: Array<{
role: string;
content: string;
@@ -97,6 +99,7 @@ async function rebuildIndex(): Promise<void> {
list.push({
id: id,
title: session.title || "AI Agent",
+ model: session.model || "",
createdAt: session.createdAt || entries[i].updated || Date.now(),
updatedAt: session.updatedAt || entries[i].updated || Date.now(),
});
@@ -136,17 +139,18 @@ export const SessionStore = {
await writeJsonFile(SESSIONS_DIR + session.id + ".json", session);
const list = await this.list();
- let found = false;
+ let foundIdx = -1;
for (let i = 0; i < list.length; i++) {
if (list[i].id === session.id) {
list[i].title = session.title;
list[i].updatedAt = session.updatedAt;
- found = true;
+ list[i].model = session.model;
+ foundIdx = i;
break;
}
}
- if (!found) {
- list.unshift({id: session.id, title: session.title, createdAt: session.createdAt, updatedAt: session.updatedAt});
+ if (foundIdx < 0) {
+ list.unshift({id: session.id, title: session.title, model: session.model, createdAt: session.createdAt, updatedAt: session.updatedAt});
}
await writeIndex(list);
},