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: Keep agent notebook renames in sync https://github.com/siyuan-note/siyuan/issues/18315
Daniel2f4c3551c244
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex a8e135b382..6b9bedb36b 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -940,11 +940,19 @@ export class Files extends Model {this.selectItem(data.data.box.id, data.data.path);break;case "renamenotebook": {+ const name = data.data.name;+ if (typeof name !== "string") {+ break;+ }const notebook = window.siyuan.notebooks.find((item) => item.id === data.data.box);if (notebook) {- notebook.name = data.data.name;+ notebook.name = name;+ }+ const textElement = this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`) ||+ this.closeElement.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`);+ if (textElement) {+ textElement.textContent = name;}- this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = escapeHtml(data.data.name);break;}case "rename":diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.tsindex dee7f11b4b..066ef6ffdd 100644--- a/app/src/mobile/dock/MobileFiles.ts+++ b/app/src/mobile/dock/MobileFiles.ts@@ -564,11 +564,19 @@ export class MobileFiles extends Model {this.updateDocInfo(data);break;case "renamenotebook": {+ const name = data.data.name;+ if (typeof name !== "string") {+ break;+ }const notebook = window.siyuan.notebooks.find((item) => item.id === data.data.box);if (notebook) {- notebook.name = data.data.name;+ notebook.name = name;+ }+ const textElement = this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`) ||+ this.closeElement.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`);+ if (textElement) {+ textElement.textContent = name;}- this.element.querySelector(`[data-url="${data.data.box}"] .b3-list-item__text`).innerHTML = escapeHtml(data.data.name);break;}case "rename":diff --git a/kernel/mcp/tools/notebook.go b/kernel/mcp/tools/notebook.goindex c3e7c85f9f..a4bb4c0645 100644--- a/kernel/mcp/tools/notebook.go+++ b/kernel/mcp/tools/notebook.go@@ -117,9 +117,12 @@ func notebookRename(args map[string]any) (CallToolResult, error) {return CallToolResult{Content: []ContentItem{{Type: "text", Text: "rename notebook failed: " + err.Error()}}, IsError: true}, nil}- evt := util.NewCmdResult("renamenotebook", 0, util.PushModeBroadcast)- evt.Data = map[string]any{"box": id}- util.PushEvent(evt)+ if box := model.Conf.Box(id); nil != box {+ name = box.Name+ evt := util.NewCmdResult("renamenotebook", 0, util.PushModeBroadcast)+ evt.Data = map[string]any{"box": id, "name": name}+ util.PushEvent(evt)+ }return CallToolResult{Content: []ContentItem{{Type: "text", Text: "notebook renamed: " + id + " -> " + name}}}, nil}