Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

community(api): serialize seq in pins route (client jump-to-pinned-message)

Gus601eb6450b08
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.ts
index ab2314adf..e9351912d 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
@@ -184,7 +184,7 @@ describe("GET /api/community/channels/[id]/pins", () => {
mockListPins.mockResolvedValue([
{
pin: { channelId: "c1", messageId: "m1" },
- message: { id: "m1", content: "hi", createdAt: "2026-08-04T00:00:00Z" },
+ message: { id: "m1", seq: 42, content: "hi", createdAt: "2026-08-04T00:00:00Z" },
author: { id: "u42", name: "Ada", image: null },
},
]);
@@ -192,11 +192,14 @@ describe("GET /api/community/channels/[id]/pins", () => {
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 }> };
+ const body = (await res.json()) as { pins: Array<{ id: string; seq: number; 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");
+ // seq lets the client jumpToSeq to the pinned message (scroll+highlight, or
+ // open the context sheet if it's outside the loaded window).
+ expect(body.pins[0].seq).toBe(42);
});
it("returns 403 when the caller can't see the channel", async () => {
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.ts
index fa6270dd6..735b98604 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,12 @@ 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,
+ // seq is the per-channel sequence the client needs to JUMP to a pinned
+ // message (jumpToSeq: scroll+highlight if in the loaded window, else open
+ // the context sheet). A pin is usually an OLD message outside the window,
+ // so a scroll-only path silently no-ops without seq. listPins selects the
+ // whole message row, so seq is already here.
+ seq: r.message.seq,
// 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