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
fix(community): carry serverId/railChannelId/isMention on the unread bump
Claudettea23a845f38ec
diff --git a/src/shared/src/community-ws-events.ts b/src/shared/src/community-ws-events.tsindex dac470b08..38aca7730 100644--- a/src/shared/src/community-ws-events.ts+++ b/src/shared/src/community-ws-events.ts@@ -405,7 +405,29 @@ export type CommunityMentionCreate = {export type CommunityUnreadBump = {type: "community:unread.bump"userId: string+ /** The channel the message actually landed in (a thread bump = the thread's+ * id). Use `railChannelId` to locate the sidebar row; this is the true scope. */channelId: string+ /**+ * The server whose tree/rail badge to patch (inbox-dot-ws-driven plan). Lets+ * the client patch the RIGHT server — without it the client only patched the+ * currently-open server, so an other-server message's dot never lit. Absent+ * on a DM bump or an older server frame → client falls back to the+ * current-server behavior (backward-compatible).+ */+ serverId?: string+ /**+ * The sidebar-locatable channel row = `parentChannelId ?? channelId`, computed+ * server-side. A thread/forum-post message has no independent sidebar row, so+ * its dot must light the PARENT channel's row; a plain channel is its own row.+ * Absent → client falls back to `channelId`.+ */+ railChannelId?: string+ /**+ * Whether this recipient was mentioned by the message — decides +mention vs+ * +unread on the rail badge and which inbox feed the count lands in.+ * Per-recipient; known at emit time from the mention set. */+ isMention?: boolean}// ── Presence events ───────────────────────────────────────────────────────────diff --git a/src/web/src/lib/community/message-handler.ts b/src/web/src/lib/community/message-handler.tsindex 460cc4f63..450a6e169 100644--- a/src/web/src/lib/community/message-handler.ts+++ b/src/web/src/lib/community/message-handler.ts@@ -722,7 +722,21 @@ export async function createCommunityMessage(params: {{ authorName: row.authorName },{ id: row.id, channelId: row.channelId },recipients.filter((id) => id !== authorId),- { mentionedUserIds: [...liveMentions, ...liveReplies] },+ {+ mentionedUserIds: [...liveMentions, ...liveReplies],+ // serverId + railChannelId ride the UNREAD_BUMP so the client patches+ // the right server tree + (parent, for threads) sidebar row without a+ // query — straight off the resolved `target` (DM has neither). See+ // inbox-dot-ws-driven plan.+ ...(isDmTarget(target)+ ? {}+ : {+ serverId: target.serverId,+ railChannelId: hasParentChannel(target)+ ? target.parentChannelId+ : target.channelId,+ }),+ },).catch(() => { })if (!isDmTarget(target)) {diff --git a/src/web/src/lib/community/notify.test.ts b/src/web/src/lib/community/notify.test.tsindex 88deaacbe..63a06e894 100644--- a/src/web/src/lib/community/notify.test.ts+++ b/src/web/src/lib/community/notify.test.ts@@ -107,4 +107,32 @@ describe("dispatchMessageNotify", () => {).resolves.toBeUndefined()expect(bumpEvents()).toEqual([])})++ it("bump carries serverId + railChannelId when passed, and per-recipient isMention (inbox-dot)", async () => {+ mockResolveEffectiveLevelForUsers.mockResolvedValue(+ new Map([["u_plain", "all"], ["u_mentioned", "all"]]),+ )+ await dispatchMessageNotify(db, ctx, msg, ["u_plain", "u_mentioned"], {+ mentionedUserIds: ["u_mentioned"],+ serverId: "srv_1",+ railChannelId: "parent_c1", // thread → parent row+ })+ const bumps = bumpEvents()+ for (const b of bumps) {+ expect(b.serverId).toBe("srv_1")+ expect(b.railChannelId).toBe("parent_c1")+ expect(b.channelId).toBe("c1") // true message channel unchanged+ }+ expect(bumps.find((b: any) => b.userId === "u_mentioned").isMention).toBe(true)+ expect(bumps.find((b: any) => b.userId === "u_plain").isMention).toBe(false)+ })++ it("bump omits serverId/railChannelId when not passed (DM / backward-compatible frame)", async () => {+ mockResolveEffectiveLevelForUsers.mockResolvedValue(new Map([["u_dm", "all"]]))+ await dispatchMessageNotify(db, ctx, msg, ["u_dm"], { mentionedUserIds: [] })+ const [b] = bumpEvents()+ expect(b.serverId).toBeUndefined()+ expect(b.railChannelId).toBeUndefined()+ expect(b.isMention).toBe(false)+ })})diff --git a/src/web/src/lib/community/notify.ts b/src/web/src/lib/community/notify.tsindex 7d6a608b0..5fa2dfd46 100644--- a/src/web/src/lib/community/notify.ts+++ b/src/web/src/lib/community/notify.ts@@ -81,7 +81,16 @@ export async function dispatchMessageNotify(ctx: MessageNotifyContext,message: { id: string; channelId: string },recipients: string[],- opts: { mentionedUserIds: string[] },+ opts: {+ mentionedUserIds: string[]+ /** Server the message belongs to — rides the UNREAD_BUMP so the client+ * patches the right server tree/rail (inbox-dot-ws-driven). Undefined for+ * a DM (no server). From the caller's `target.serverId`, no extra query. */+ serverId?: string+ /** Sidebar-locatable row = `parentChannelId ?? channelId` (thread/forum-post+ * light the parent row). From the caller's target, no extra query. */+ railChannelId?: string+ },): Promise<void> {try {const { channelId } = message@@ -112,11 +121,19 @@ export async function dispatchMessageNotify(// Per-user UNREAD_BUMP badge — per-recipient (A muted, B not), so it rides a// per-user event, not a flag on the shared MESSAGE_CREATE payload.for (const userId of recipients) {- if (!shouldDeliver(levelOf(userId), mentioned.has(userId))) continue+ const isMention = mentioned.has(userId)+ if (!shouldDeliver(levelOf(userId), isMention)) continuebroadcastToUser(userId, {type: WS_EVENTS.UNREAD_BUMP,userId,channelId,+ // serverId + railChannelId let the client patch the RIGHT server tree+ // and the right (parent, for threads) sidebar row; isMention splits+ // +mention vs +unread. All optional — a client on an older frame falls+ // back to channelId + current-server behavior.+ ...(opts.serverId !== undefined ? { serverId: opts.serverId } : {}),+ ...(opts.railChannelId !== undefined ? { railChannelId: opts.railChannelId } : {}),+ isMention,}).catch(() => {})}} catch (err) {