🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(resource): keep images and media out of the Docs home list (#21511)
Arvin Xu5d1b6747561f
diff --git a/packages/database/src/repositories/knowledge/__tests__/homeItems.test.ts b/packages/database/src/repositories/knowledge/__tests__/homeItems.test.tsindex 65af13c9c3d..f31cb338e3e 100644--- a/packages/database/src/repositories/knowledge/__tests__/homeItems.test.ts+++ b/packages/database/src/repositories/knowledge/__tests__/homeItems.test.ts@@ -49,9 +49,9 @@ beforeEach(async () => {workspaceId,},{- fileType: 'image/png',+ fileType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',id: 'home-file-mate',- name: 'mate.png',+ name: 'mate.docx',size: 1,updatedAt: minutesAgo(4),url: 'u2',@@ -68,6 +68,21 @@ beforeEach(async () => {userId: mate,workspaceId,},+ // Newest rows, yet not documents: media and raw data never reach the list.+ ...[+ ['home-file-image', 'image/png'],+ ['home-file-video', 'video/mp4'],+ ['home-file-zip', 'application/zip'],+ ].map(([id, fileType]) => ({+ fileType,+ id,+ name: id,+ size: 1,+ updatedAt: new Date(),+ url: id,+ userId: me,+ workspaceId,+ })),]);await serverDB.insert(knowledgeBaseFiles).values([{ fileId: 'home-file-mine', knowledgeBaseId: 'home-kb', userId: me, workspaceId },@@ -130,6 +145,14 @@ describe('KnowledgeRepo.queryHomeItems', () => {]);});+ it('keeps only document files, not images, videos or raw data', async () => {+ const result = await ids({});+ expect(result).not.toContain('home-file-image');+ expect(result).not.toContain('home-file-video');+ expect(result).not.toContain('home-file-zip');+ expect(result).toEqual(expect.arrayContaining(['home-file-mine', 'home-file-mate']));+ });+it("narrows to the caller's own rows", async () => {expect(await ids({ creator: 'self' })).toEqual(['home-file-mine',diff --git a/packages/database/src/repositories/knowledge/index.ts b/packages/database/src/repositories/knowledge/index.tsindex 5a69114cbd8..0474dd626c2 100644--- a/packages/database/src/repositories/knowledge/index.ts+++ b/packages/database/src/repositories/knowledge/index.ts@@ -603,13 +603,13 @@ export class KnowledgeRepo {}/**- * The Docs home list: pages and uploaded files together, newest update first,+ * The Docs home list: pages and uploaded documents (pdf / office / text; no+ * media, raw data or page-backing rows) together, newest update first,* wherever they live (a knowledge base or not; rows carry `knowledgeBaseIds`* for the location column). `creator` narrows to the caller's own rows* (`self`) or to what other workspace members shared (`others`); private rows- * of other members never pass the ownership scope in the first place.- * Folders, page-backing file rows and rows of restricted knowledge bases are- * excluded in SQL, so `limit` is never eaten by rows filtered out later.+ * of other members never pass the ownership scope in the first place. All+ * exclusions run in SQL, so `limit` is never eaten by rows filtered later.*/async queryHomeItems({creator,@@ -630,7 +630,7 @@ export class KnowledgeRepo {const fileArm = this.fileArm([creatorFilter(f.userId),- ne(f.fileType, CUSTOM_DOCUMENT_FILE_TYPE),+ this.fileCategoryFilter(FilesTabs.Documents),excludeKnowledgeBaseIds?.length? this.notInKnowledgeBases(excludeKnowledgeBaseIds): undefined,