Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
community(api): serialize authorId in pins + mentions routes (beam-avatar seed)
Guse4f4788e61ef
diff --git a/src/web/src/app/api/community/channels/[id]/pins/route.test.ts b/src/web/src/app/api/community/channels/[id]/pins/route.test.tsindex 8a05b8314..ab2314adf 100644--- a/src/web/src/app/api/community/channels/[id]/pins/route.test.ts+++ b/src/web/src/app/api/community/channels/[id]/pins/route.test.ts@@ -6,9 +6,11 @@ vi.mock("@opennextjs/cloudflare", () => ({}));const mockGetChannel = vi.fn();+const mockGetChannelForMember = vi.fn();const mockGetMember = vi.fn();const mockGetMessage = vi.fn();const mockPinMessage = vi.fn();+const mockListPins = vi.fn();const mockLogAction = vi.fn();const mockFanOut = vi.fn();@@ -20,10 +22,16 @@ vi.mock("@alook/shared", async () => {return {...actual,queries: {- communityChannel: { getChannel: (...a: unknown[]) => mockGetChannel(...a) },+ communityChannel: {+ getChannel: (...a: unknown[]) => mockGetChannel(...a),+ getChannelForMember: (...a: unknown[]) => mockGetChannelForMember(...a),+ },communityMember: { getMember: (...a: unknown[]) => mockGetMember(...a) },communityMessage: { getMessage: (...a: unknown[]) => mockGetMessage(...a) },- communityPin: { pinMessage: (...a: unknown[]) => mockPinMessage(...a) },+ communityPin: {+ pinMessage: (...a: unknown[]) => mockPinMessage(...a),+ listPins: (...a: unknown[]) => mockListPins(...a),+ },communityAuditLog: { logAction: (...a: unknown[]) => mockLogAction(...a) },},};@@ -54,7 +62,11 @@ vi.mock("@/lib/middleware/helpers", async () => {};});-import { POST } from "./route";+import { GET, POST } from "./route";++function getReq() {+ return new NextRequest("http://localhost/api/community/channels/c1/pins", { method: "GET" });+}function postReq(messageId?: unknown) {return new NextRequest("http://localhost/api/community/channels/c1/pins", {@@ -158,3 +170,39 @@ describe("POST /api/community/channels/[id]/pins", () => {expect(mockPinMessage).not.toHaveBeenCalled();});});++describe("GET /api/community/channels/[id]/pins", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ mockGetChannelForMember.mockResolvedValue({ id: "c1", serverId: "s1", type: "text" });+ });++ it("returns each pin's authorId so the client can derive a beam avatar", async () => {+ // A pinned message whose author has no uploaded image — the client needs+ // authorId as the beam seed; without it the pinned panel drew a blank+ // avatar (the bug this field fixes).+ mockListPins.mockResolvedValue([+ {+ pin: { channelId: "c1", messageId: "m1" },+ message: { id: "m1", content: "hi", createdAt: "2026-08-04T00:00:00Z" },+ author: { id: "u42", name: "Ada", image: null },+ },+ ]);++ const res = await GET(getReq(), ctx);++ expect(res.status).toBe(200);+ const body = (await res.json()) as { pins: Array<{ id: string; authorId: string; authorName: string }> };+ expect(body.pins).toHaveLength(1);+ expect(body.pins[0].authorId).toBe("u42");+ expect(body.pins[0].id).toBe("m1");+ expect(body.pins[0].authorName).toBe("Ada");+ });++ it("returns 403 when the caller can't see the channel", async () => {+ mockGetChannelForMember.mockResolvedValue(null);+ const res = await GET(getReq(), ctx);+ expect(res.status).toBe(403);+ expect(mockListPins).not.toHaveBeenCalled();+ });+});diff --git a/src/web/src/app/api/community/channels/[id]/pins/route.ts b/src/web/src/app/api/community/channels/[id]/pins/route.tsindex 83da25b53..fa6270dd6 100644--- a/src/web/src/app/api/community/channels/[id]/pins/route.ts+++ b/src/web/src/app/api/community/channels/[id]/pins/route.ts@@ -20,6 +20,11 @@ export const GET = withAuth(async (_req: NextRequest, ctx) => {const rows = await queries.communityPin.listPins(db, channelId)const pins = rows.map((r) => ({id: r.message.id,+ // authorId lets the client derive a stable beam avatar when the author+ // has no uploaded image — same shape mapMessageForApi feeds the message+ // list. Omitting it (and pre-flattening authorAvatar to an initial) is+ // why the pinned panel showed no avatar for image-less authors.+ authorId: r.author.id,authorName: r.author.name,authorAvatar: r.author.image ?? avatarInitial(r.author.name),content: r.message.content,diff --git a/src/web/src/app/api/community/inbox/mentions/route.test.ts b/src/web/src/app/api/community/inbox/mentions/route.test.tsindex fa45c9399..c205ce8d5 100644--- a/src/web/src/app/api/community/inbox/mentions/route.test.ts+++ b/src/web/src/app/api/community/inbox/mentions/route.test.ts@@ -70,7 +70,7 @@ describe("GET /api/community/inbox/mentions", () => {{mention: { id: "mn1", kind: "mention" },message: { id: "m1", channelId: "c1", content: "@u1 hi", createdAt: "2026-06-25T10:00:00Z" },- author: { name: "Alice", email: "[email protected]", image: null },+ author: { id: "u-alice", name: "Alice", email: "[email protected]", image: null },},])mockGetChannelsByIds.mockResolvedValue([{ id: "c1", name: "general", serverId: "s1" }])@@ -86,7 +86,10 @@ describe("GET /api/community/inbox/mentions", () => {serverId: "s1",channel: "general",channelId: "c1",- m: { id: "m1", authorName: "Alice", content: "@u1 hi" },+ // authorId is the beam-avatar seed the inbox popover renders from+ // (<Avatar seed={mn.m.authorId}>) — omitting it blanked image-less+ // authors' avatars, same bug the pins route had.+ m: { id: "m1", authorId: "u-alice", authorName: "Alice", content: "@u1 hi" },})})diff --git a/src/web/src/app/api/community/inbox/mentions/route.ts b/src/web/src/app/api/community/inbox/mentions/route.tsindex 9eb0f44f1..28915d509 100644--- a/src/web/src/app/api/community/inbox/mentions/route.ts+++ b/src/web/src/app/api/community/inbox/mentions/route.ts@@ -70,6 +70,10 @@ export const GET = withAuth(async (req, ctx) => {channelId: row.message.channelId,m: {id: row.message.id,+ // authorId is the beam-avatar seed the popover renders from+ // (<Avatar seed={authorId}>); omitting it left image-less authors with+ // a blank avatar — same fix as the pins route.+ authorId: row.author.id,authorName: row.author.name,authorAvatar: row.author.image ?? avatarInitial(row.author.name),content: row.message.content,