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 av
Danielef5236e0b177
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 1fc5e17618..0232e222c5 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -532,7 +532,7 @@ func SetAttributeViewGroup(avID, blockID string, group *av.ViewGroup) (err errorgroupStates := getAttrViewGroupStates(view)view.Group = group- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)setAttrViewGroupStates(view, groupStates)if view.Group.HideEmpty != oldHideEmpty {@@ -715,7 +715,7 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error}}- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)if err = av.SaveAttributeView(attrView); nil != err {logging.LogErrorf("save attribute view [%s] failed: %s", avID, err)@@ -2292,13 +2292,13 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {}}- regenAttrViewGroups(srcAv, "force")+ regenAttrViewGroups(srcAv)err = av.SaveAttributeView(srcAv)if err != nil {return}if !isSameAv {- regenAttrViewGroups(destAv, "force")+ regenAttrViewGroups(destAv)err = av.SaveAttributeView(destAv)ReloadAttrView(destAv.ID)}@@ -2555,7 +2555,7 @@ func (tx *Transaction) doDuplicateAttrViewView(operation *Operation) (ret *TxErr}view.GroupItemIDs = masterView.GroupItemIDs- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)}if err = av.SaveAttributeView(attrView); err != nil {@@ -3140,7 +3140,7 @@ func addAttributeViewBlock(now int64, avID, dbBlockID, groupID, previousItemID,}}- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)err = av.SaveAttributeView(attrView)return}@@ -3277,7 +3277,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er}}- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)err = av.SaveAttributeView(attrView)if nil != err {@@ -3703,7 +3703,7 @@ func sortAttributeViewRow(operation *Operation) (err error) {if av.KeyTypeMSelect == groupKey.Type || av.KeyTypeRelation == groupKey.Type {// 跨多选分组时一个项目可能会同时存在于多个分组中,需要重新生成分组- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)}} else { // 同分组内排序for i, r := range groupView.GroupItemIDs {@@ -4006,7 +4006,7 @@ func updateAttributeViewColTemplate(operation *Operation) (err error) {}}- regenAttrViewGroups(attrView, operation.ID)+ regenAttrViewGroups(attrView)err = av.SaveAttributeView(attrView)return}@@ -4108,7 +4108,7 @@ func updateAttributeViewColumn(operation *Operation) (err error) {}}- regenAttrViewGroups(destAv, "force")+ regenAttrViewGroups(destAv)av.SaveAttributeView(destAv)ReloadAttrView(destAv.ID)}@@ -4260,7 +4260,7 @@ func RemoveAttributeViewKey(avID, keyID string, removeRelationDest bool) (err er}}- regenAttrViewGroups(destAv, "force")+ regenAttrViewGroups(destAv)av.SaveAttributeView(destAv)ReloadAttrView(destAv.ID)}@@ -4309,7 +4309,7 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newNodeIcontent = util.UnescapeHTML(content)blockVal.Block.Icon, blockVal.Block.Content = icon, contentblockVal.UpdatedAt = now- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)return}}@@ -4339,7 +4339,7 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newNodeI}}- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)return}@@ -4587,7 +4587,7 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyIDupdateTwoWayRelationDestAttrView(attrView, key, val, relationChangeMode, oldRelationBlockIDs)}- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)if err = av.SaveAttributeView(attrView); nil != err {return}@@ -4604,7 +4604,7 @@ func refreshRelatedSrcAvs(destAvID string) {continue}- regenAttrViewGroups(destAv, "force")+ regenAttrViewGroups(destAv)av.SaveAttributeView(destAv)ReloadAttrView(relatedAvID)}@@ -4674,27 +4674,19 @@ func updateTwoWayRelationDestAttrView(attrView *av.AttributeView, relKey *av.Key}if destAv != attrView {- regenAttrViewGroups(destAv, "force")+ regenAttrViewGroups(destAv)av.SaveAttributeView(destAv)}}// regenAttrViewGroups 重新生成分组视图。-// keyID: 如果是 "force" 则强制重新生成所有分组视图,否则只生成 keyID 指定的分组字段的分组视图-func regenAttrViewGroups(attrView *av.AttributeView, keyID string) {+func regenAttrViewGroups(attrView *av.AttributeView) {for _, view := range attrView.Views {groupKey := view.GetGroupKey(attrView)if nil == groupKey {continue}- if "force" != keyID {- if av.KeyTypeTemplate != groupKey.Type && av.KeyTypeRollup != groupKey.Type && av.KeyTypeCreated != groupKey.Type && av.KeyTypeUpdated != groupKey.Type &&- view.Group.Field != keyID {- continue- }- }-genAttrViewGroups(view, attrView)}}@@ -4884,7 +4876,7 @@ func updateAttributeViewColumnOptions(operation *Operation) (err error) {})}- regenAttrViewGroups(attrView, operation.ID)+ regenAttrViewGroups(attrView)err = av.SaveAttributeView(attrView)return}@@ -4968,7 +4960,7 @@ func removeAttributeViewColumnOption(operation *Operation) (err error) {}}- regenAttrViewGroups(attrView, operation.ID)+ regenAttrViewGroups(attrView)err = av.SaveAttributeView(attrView)return}@@ -5087,7 +5079,7 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {}}- regenAttrViewGroups(attrView, operation.ID)+ regenAttrViewGroups(attrView)err = av.SaveAttributeView(attrView)return}diff --git a/kernel/model/attribute_view_render.go b/kernel/model/attribute_view_render.goindex 51c19dd58e..033c0b9b79 100644--- a/kernel/model/attribute_view_render.go+++ b/kernel/model/attribute_view_render.go@@ -92,7 +92,7 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,if isGroupByDate(view) {createdDate := time.UnixMilli(view.GroupCreated).Format("2006-01-02")if time.Now().Format("2006-01-02") != createdDate {- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)av.SaveAttributeView(attrView)}}@@ -108,7 +108,7 @@ func renderAttributeViewGroups(viewable av.Viewable, attrView *av.AttributeView,for _, groupView := range view.Groups {if (nil == groupView.GroupVal || nil == groupView.GroupKey) && !fixDev {// TODO 分组上线后删除,预计 2025 年 9 月后可以删除- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)av.SaveAttributeView(attrView)fixDev = true}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex e0a3c8640a..23404b2b6e 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -1008,7 +1008,7 @@ func syncDelete2AttributeView(node *ast.Node) (changedAvIDs []string) {}if changedAv {- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)av.SaveAttributeView(attrView)changedAvIDs = append(changedAvIDs, avID)}@@ -1569,7 +1569,7 @@ func upsertAvBlockRel(node *ast.Node) {for _, avID := range affectedAvIDs {attrView, _ := av.ParseAttributeView(avID)if nil != attrView {- regenAttrViewGroups(attrView, "force")+ regenAttrViewGroups(attrView)av.SaveAttributeView(attrView)}