An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/17407
Daniel77d30f5fa73d
diff --git a/kernel/model/bookmark.go b/kernel/model/bookmark.goindex 66c61ee8e6..f8dcf17ec0 100644--- a/kernel/model/bookmark.go+++ b/kernel/model/bookmark.go@@ -19,8 +19,10 @@ package modelimport ("errors""fmt"+ "path/filepath""sort""strings"+ "time""github.com/88250/gulu""github.com/88250/lute/parse"@@ -37,14 +39,16 @@ func RemoveBookmark(bookmark string) (err error) {bookmarks := sql.QueryBookmarkBlocks()treeBlocks := map[string][]string{}- for _, tag := range bookmarks {- if blocks, ok := treeBlocks[tag.RootID]; !ok {- treeBlocks[tag.RootID] = []string{tag.ID}+ for _, bm := range bookmarks {+ if blocks, ok := treeBlocks[bm.RootID]; !ok {+ treeBlocks[bm.RootID] = []string{bm.ID}} else {- treeBlocks[tag.RootID] = append(blocks, tag.ID)+ treeBlocks[bm.RootID] = append(blocks, bm.ID)}}+ historyDir, err := getHistoryDir(HistoryOpReplace, time.Now())+for treeID, blocks := range treeBlocks {util.PushEndlessProgress("[" + treeID + "]")tree, e := LoadTreeByBlockID(treeID)@@ -53,6 +57,7 @@ func RemoveBookmark(bookmark string) (err error) {return e}+ changed := falsefor _, blockID := range blocks {node := treenode.GetNodeInTree(tree, blockID)if nil == node {@@ -62,17 +67,25 @@ func RemoveBookmark(bookmark string) (err error) {if bookmarkAttrVal := node.IALAttr("bookmark"); bookmarkAttrVal == bookmark {node.RemoveIALAttr("bookmark")cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))+ changed = true}}- util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), util.EscapeHTML(tree.Root.IALAttr("title"))))- if err = writeTreeUpsertQueue(tree); err != nil {- util.ClearPushProgress(100)- return+ if changed {+ generateTreeHistory(historyDir, tree)+ util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), util.EscapeHTML(tree.Root.IALAttr("title"))))+ if err = writeTreeUpsertQueue(tree); err != nil {+ util.ClearPushProgress(100)+ return+ }}+util.RandomSleep(50, 150)}+ indexHistoryDir(filepath.Base(historyDir), util.NewLute())+ sql.FlushQueue()+util.ReloadUI()return}@@ -95,14 +108,15 @@ func RenameBookmark(oldBookmark, newBookmark string) (err error) {bookmarks := sql.QueryBookmarkBlocks()treeBlocks := map[string][]string{}- for _, tag := range bookmarks {- if blocks, ok := treeBlocks[tag.RootID]; !ok {- treeBlocks[tag.RootID] = []string{tag.ID}+ for _, bm := range bookmarks {+ if blocks, ok := treeBlocks[bm.RootID]; !ok {+ treeBlocks[bm.RootID] = []string{bm.ID}} else {- treeBlocks[tag.RootID] = append(blocks, tag.ID)+ treeBlocks[bm.RootID] = append(blocks, bm.ID)}}+ historyDir, err := getHistoryDir(HistoryOpReplace, time.Now())for treeID, blocks := range treeBlocks {util.PushEndlessProgress("[" + treeID + "]")tree, e := LoadTreeByBlockID(treeID)@@ -111,6 +125,7 @@ func RenameBookmark(oldBookmark, newBookmark string) (err error) {return e}+ changed := falsefor _, blockID := range blocks {node := treenode.GetNodeInTree(tree, blockID)if nil == node {@@ -120,17 +135,25 @@ func RenameBookmark(oldBookmark, newBookmark string) (err error) {if bookmarkAttrVal := node.IALAttr("bookmark"); bookmarkAttrVal == oldBookmark {node.SetIALAttr("bookmark", newBookmark)cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))+ changed = true}}- util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), util.EscapeHTML(tree.Root.IALAttr("title"))))- if err = writeTreeUpsertQueue(tree); err != nil {- util.ClearPushProgress(100)- return+ if changed {+ generateTreeHistory(historyDir, tree)+ util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), util.EscapeHTML(tree.Root.IALAttr("title"))))+ if err = writeTreeUpsertQueue(tree); err != nil {+ util.ClearPushProgress(100)+ return+ }}+util.RandomSleep(50, 150)}+ indexHistoryDir(filepath.Base(historyDir), util.NewLute())+ sql.FlushQueue()+util.ReloadUI()return}diff --git a/kernel/model/tag.go b/kernel/model/tag.goindex edac491336..2c1d5ffe21 100644--- a/kernel/model/tag.go+++ b/kernel/model/tag.go@@ -53,6 +53,8 @@ func RemoveTag(label string) (err error) {var reloadTreeIDs []stringupdateNodes := map[string]*ast.Node{}+ historyDir, err := getHistoryDir(HistoryOpReplace, time.Now())+for treeID, blocks := range treeBlocks {util.PushEndlessProgress("[" + treeID + "]")tree, e := LoadTreeByBlockIDWithReindex(treeID)@@ -61,6 +63,8 @@ func RemoveTag(label string) (err error) {return e}+ generateTreeHistory(historyDir, tree)+var unlinks []*ast.Nodefor _, blockID := range blocks {node := treenode.GetNodeInTree(tree, blockID)@@ -106,6 +110,7 @@ func RemoveTag(label string) (err error) {reloadTreeIDs = append(reloadTreeIDs, tree.ID)}+ indexHistoryDir(filepath.Base(historyDir), util.NewLute())sql.FlushQueue()reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)