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: Update av
Daniel683e9a04edb7
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 7c303695b7..bf6f758fe3 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -475,16 +475,14 @@ func addAttributeViewBlock(blockID string, operation *Operation, tree *parse.Tre}func (tx *Transaction) doRemoveAttrViewBlock(operation *Operation) (ret *TxErr) {- for _, id := range operation.SrcIDs {- var avErr error- if avErr = removeAttributeViewBlock(id, operation); nil != avErr {- return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID}- }+ err := removeAttributeViewBlock(operation)+ if nil != err {+ return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID}}return}-func removeAttributeViewBlock(blockID string, operation *Operation) (err error) {+func removeAttributeViewBlock(operation *Operation) (err error) {attrView, err := av.ParseAttributeView(operation.AvID)if nil != err {return@@ -496,15 +494,18 @@ func removeAttributeViewBlock(blockID string, operation *Operation) (err error)}for _, keyValues := range attrView.KeyValues {+ tmp := keyValues.Values[:0]for i, values := range keyValues.Values {- if values.BlockID == blockID {- keyValues.Values = append(keyValues.Values[:i], keyValues.Values[i+1:]...)- break+ if !gulu.Str.Contains(values.BlockID, operation.SrcIDs) {+ tmp = append(tmp, keyValues.Values[i])}}+ keyValues.Values = tmp}- view.Table.RowIDs = gulu.Str.RemoveElem(view.Table.RowIDs, blockID)+ for _, blockID := range operation.SrcIDs {+ view.Table.RowIDs = gulu.Str.RemoveElem(view.Table.RowIDs, blockID)+ }err = av.SaveAttributeView(attrView)returndiff --git a/kernel/util/misc.go b/kernel/util/misc.goindex 549cbaae0b..389dfc5e70 100644--- a/kernel/util/misc.go+++ b/kernel/util/misc.go@@ -24,16 +24,21 @@ import ("github.com/88250/lute/html")-// InsertElem inserts a new element value at the specified index position.-// 0 <= index <= len(a)-func InsertElem[T any](ret []T, index int, value T) []T {- if len(ret) == index { // nil or empty slice or after last element- return append(ret, value)+// InsertElem inserts value at index into a.+// 0 <= index <= len(s)+func InsertElem[T any](s []T, index int, value T) []T {+ if len(s) == index { // nil or empty slice or after last element+ return append(s, value)}- ret = append(ret[:index+1], ret[index:]...) // index < len(a)- ret[index] = value- return ret+ s = append(s[:index+1], s[index:]...) // index < len(s)+ s[index] = value+ return s+}++// RemoveElem removes the element at index i from s.+func RemoveElem[T any](s []T, index int) []T {+ return append(s[:index], s[index+1:]...)}func EscapeHTML(s string) string {