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: Improve `Add to Database` https://github.com/siyuan-note/siyuan/issues/10659
Danieldcefed26ebdd
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex c1c5c7e617..12bf969651 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1263,7 +1263,12 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearchlogging.LogErrorf("read directory [%s] failed: %s", avDir, err)return}+avBlockRels := av.GetBlockRels()+ if 1 > len(avBlockRels) {+ return+ }+for _, entry := range entries {if entry.IsDir() {continue@@ -1322,48 +1327,29 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearchif 12 <= len(avSearchTmpResults) {avSearchTmpResults = avSearchTmpResults[:12]}- var avIDs []string- for _, a := range avSearchTmpResults {- avIDs = append(avIDs, a.AvID)- }-- var blockIDs []string- for _, bIDs := range avBlockRels {- blockIDs = append(blockIDs, bIDs...)- }- blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs)-- trees := filesys.LoadTrees(blockIDs)- hitAttrViews := map[string]bool{}- for _, blockID := range blockIDs {- tree := trees[blockID]- if nil == tree {- continue- }- node := treenode.GetNodeInTree(tree, blockID)- if nil == node || "" == node.AttributeViewID {- continue- }+ for _, tmpResult := range avSearchTmpResults {+ bIDs := avBlockRels[tmpResult.AvID]+ var node *ast.Node+ for _, bID := range bIDs {+ tree, _ := LoadTreeByBlockID(bID)+ if nil == tree {+ continue+ }- avID := node.AttributeViewID- var existAv *AvSearchTempResult- for _, tmpResult := range avSearchTmpResults {- if tmpResult.AvID == avID {- existAv = tmpResult- break+ node = treenode.GetNodeInTree(tree, bID)+ if nil == node || "" == node.AttributeViewID {+ continue}- }- if nil == existAv || gulu.Str.Contains(avID, excludeAvIDs) {- continue++ break}- if hitAttrViews[avID] {+ if nil == node {continue}- hitAttrViews[avID] = true- attrView, _ := av.ParseAttributeView(avID)+ attrView, _ := av.ParseAttributeView(tmpResult.AvID)if nil == attrView {continue}@@ -1378,27 +1364,27 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearchhPath = box.Name + hPath}- name := existAv.AvName+ name := tmpResult.AvNameif "" == name {name = Conf.language(267)}parent := &AvSearchResult{- AvID: avID,- AvName: existAv.AvName,- BlockID: blockID,+ AvID: tmpResult.AvID,+ AvName: tmpResult.AvName,+ BlockID: node.ID,HPath: hPath,}ret = append(ret, parent)for _, view := range attrView.Views {child := &AvSearchResult{- AvID: avID,- AvName: existAv.AvName,+ AvID: tmpResult.AvID,+ AvName: tmpResult.AvName,ViewName: view.Name,ViewID: view.ID,ViewLayout: view.LayoutType,- BlockID: blockID,+ BlockID: node.ID,HPath: hPath,}parent.Children = append(parent.Children, child)