🤯 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
✨ feat(channel): picture up to nine members in a group Channel's list avatar (#23039)
Arvin Xuf686071653a7
diff --git a/packages/database/src/repositories/channel/__tests__/listAvatars.test.ts b/packages/database/src/repositories/channel/__tests__/listAvatars.test.tsindex 92d5d0cb55d..5e741ade3ff 100644--- a/packages/database/src/repositories/channel/__tests__/listAvatars.test.ts+++ b/packages/database/src/repositories/channel/__tests__/listAvatars.test.ts@@ -4,6 +4,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { getTestDB } from '../../../core/getTestDB';import { channelMembers } from '../../../schemas';+import { CHANNEL_AVATAR_MEMBERS } from '../avatars';import { createChannelFixture } from './testUtils';const db = await getTestDB();@@ -12,29 +13,35 @@ beforeEach(fixture.setup);afterEach(fixture.cleanup);describe('Channel list avatars', () => {+ // Three faces left most of a large group out; the grid holds the caller plus eight more.it('pictures the earliest other active members, capped, for each caller', async () => {const { asMember, asOwner, channel } = await fixture.createTeamChannel();const first = await fixture.addAgent(channel.id, 'First');const removed = await fixture.addAgent(channel.id, 'Removed');- const second = await fixture.addAgent(channel.id, 'Second');- await fixture.addAgent(channel.id, 'Third');+ const later = [];+ for (let index = 0; index < 7; index++)+ later.push(await fixture.addAgent(channel.id, `Agent ${index}`));await db.update(channelMembers).set({ status: 'removed' }).where(eq(channelMembers.id, removed.id));+ const agents = [first, ...later.slice(0, 6)].map((agent) => ({+ actorType: 'agent',+ id: agent.agentId,+ }));const [ownerRow] = await asOwner.list();+ expect(ownerRow.memberAvatars).toHaveLength(CHANNEL_AVATAR_MEMBERS);expect(ownerRow.memberAvatars).toMatchObject([{ actorType: 'user', id: fixture.memberId },{ actorType: 'agent', id: first.agentId, name: 'First' },- { actorType: 'agent', id: second.agentId, name: 'Second' },+ ...agents.slice(1),]);const [memberRow] = await asMember.list();expect(memberRow.memberAvatars).toMatchObject([{ actorType: 'user', id: fixture.ownerId },- { actorType: 'agent', id: first.agentId },- { actorType: 'agent', id: second.agentId },+ ...agents,]);});diff --git a/packages/database/src/repositories/channel/avatars.ts b/packages/database/src/repositories/channel/avatars.tsindex dbb673d9a1d..06ee329236a 100644--- a/packages/database/src/repositories/channel/avatars.ts+++ b/packages/database/src/repositories/channel/avatars.ts@@ -4,8 +4,11 @@ import { and, asc, eq, inArray, isNull, lte, ne, or, sql } from 'drizzle-orm';import { agents, channelMembers, users } from '../../schemas';import type { LobeChatDatabase } from '../../type';-/** A list avatar pictures the caller plus this many other members. */-export const CHANNEL_AVATAR_MEMBERS = 3;+/**+ * A list avatar pictures the caller plus this many other members: a full 3×3 grid, the way a+ * WeChat group shows its people.+ */+export const CHANNEL_AVATAR_MEMBERS = 8;/*** The earliest active members of each Channel besides `userId`, for the list avatar. One