Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve recent documents handling 2 (#16908)

Jeffrey Chen09da39a676ca
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index c95c18e5b1..06f8df030b 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -66,11 +66,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
}
if len(deduplicated) <= maxCount {
- // 清空 Title 和 Icon
- for _, doc := range deduplicated {
- doc.Title = ""
- doc.Icon = ""
- }
return deduplicated
}
@@ -129,9 +124,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
result := make([]*RecentDoc, 0, len(docMap))
for _, doc := range docMap {
- // 清空 Title 和 Icon
- doc.Title = ""
- doc.Icon = ""
result = append(result, doc)
}
@@ -386,6 +378,11 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
bts := treenode.GetBlockTrees(rootIDs)
for _, sqlBlock := range sqlBlocks {
+ bt := bts[sqlBlock.ID]
+ if nil == bt {
+ continue
+ }
+
// 解析 IAL 获取 icon
icon := ""
if sqlBlock.IAL != "" {
@@ -400,19 +397,7 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
}
}
// 获取文档标题
- title := ""
- if bt := bts[sqlBlock.ID]; nil != bt {
- title = path.Base(bt.HPath)
- }
- if title == "" {
- title = sqlBlock.Content
- if title == "" {
- title = sqlBlock.HPath
- if title == "" {
- title = sqlBlock.ID
- }
- }
- }
+ title := path.Base(bt.HPath)
doc := &RecentDoc{
RootID: sqlBlock.ID,
Icon: icon,