Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(inbox): tighten delivery, add reaction preference, remove dead inbox code (MUL-9328) (#10665)
Jiayuan Zhangf64636d10311
diff --git a/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx b/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsxindex c2b2551bad..40db214618 100644--- a/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx+++ b/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx@@ -44,6 +44,11 @@ const INBOX_GROUPS: {labelKey: "groups.mentions",descriptionKey: "groups.mentions_description",},+ {+ key: "reactions",+ labelKey: "groups.reactions",+ descriptionKey: "groups.reactions_description",+ },{key: "updates",labelKey: "groups.updates",diff --git a/apps/mobile/locales/en/settings.json b/apps/mobile/locales/en/settings.jsonindex 950b7ea572..5d03736417 100644--- a/apps/mobile/locales/en/settings.json+++ b/apps/mobile/locales/en/settings.json@@ -73,12 +73,14 @@"comments_description": "New comments on issues you're subscribed to.","mentions": "Mentions","mentions_description": "When someone @mentions you, including @all and @squad.",+ "reactions": "Reactions",+ "reactions_description": "When someone reacts to an issue you created or a comment you wrote.","updates": "Issue updates","updates_description": "Edits to title, description, labels, priority, or due date.","new_issues": "New issues","new_issues_description": "When an issue is created in a project you subscribe to.","agent_activity": "Agent activity",- "agent_activity_description": "When an agent run fails.",+ "agent_activity_description": "When an agent run fails, or an app action an agent asked to run is blocked or expires.","inbox_notifications": "Inbox notifications","system": "System","system_notifications": "System notifications",diff --git a/apps/mobile/locales/zh-Hans/settings.json b/apps/mobile/locales/zh-Hans/settings.jsonindex 87fa484152..01d63d388a 100644--- a/apps/mobile/locales/zh-Hans/settings.json+++ b/apps/mobile/locales/zh-Hans/settings.json@@ -73,12 +73,14 @@"comments_description": "你订阅的任务有新评论时。","mentions": "提及","mentions_description": "有人用 @ 提到你时,包括 @all 和 @squad。",+ "reactions": "表情回应",+ "reactions_description": "有人对你创建的任务或你写的评论添加表情时。","updates": "任务更新","updates_description": "标题、描述、标签、优先级或截止日期变更时。","new_issues": "新任务","new_issues_description": "你订阅的项目中有新任务创建时。","agent_activity": "智能体动态",- "agent_activity_description": "智能体运行失败时。",+ "agent_activity_description": "智能体运行失败,或智能体请求的应用操作被拦截、过期时。","inbox_notifications": "收件箱通知","system": "系统","system_notifications": "系统通知",diff --git a/apps/mobile/locales/zh-Hant/settings.json b/apps/mobile/locales/zh-Hant/settings.jsonindex 300b6ab88f..9afb7d32b3 100644--- a/apps/mobile/locales/zh-Hant/settings.json+++ b/apps/mobile/locales/zh-Hant/settings.json@@ -73,12 +73,14 @@"comments_description": "你訂閱的任務有新評論時。","mentions": "提及","mentions_description": "有人用 @ 提到你時,包括 @all 和 @squad。",+ "reactions": "表情回應",+ "reactions_description": "有人對你建立的任務或你寫的評論加上表情時。","updates": "任務更新","updates_description": "標題、描述、標籤、優先順序或截止日期變更時。","new_issues": "新任務","new_issues_description": "你訂閱的專案中有新任務建立時。","agent_activity": "AI 代理動態",- "agent_activity_description": "AI 代理執行失敗時。",+ "agent_activity_description": "AI 代理執行失敗,或 AI 代理請求的應用操作被攔截、過期時。","inbox_notifications": "收件箱通知","system": "系統","system_notifications": "系統通知",diff --git a/packages/core/api/client.ts b/packages/core/api/client.tsindex f2e1c4a5f0..f7bf5f7812 100644--- a/packages/core/api/client.ts+++ b/packages/core/api/client.ts@@ -3187,16 +3187,6 @@ export class ApiClient {});}- // Archived notifications, backing the inbox's "Archived" sub-view. Capped- // server-side (no pagination in v1). Schema-guarded so a contract drift- // renders an empty archive instead of taking the inbox down with it.- async listArchivedInbox(): Promise<InboxItem[]> {- const raw = await this.fetch<unknown>("/api/inbox/archived");- return parseWithFallback(raw, InboxItemListSchema, EMPTY_INBOX_ITEMS, {- endpoint: "GET /api/inbox/archived",- });- }-private archivedInboxParams(filters: ArchivedInboxFilters): URLSearchParams {return new URLSearchParams(archivedInboxQuery(filters));}@@ -3229,16 +3219,6 @@ export class ApiClient {return this.fetch(`/api/inbox/${id}/unarchive`, { method: "POST" });}- // Raw unread ROW count — not the number any badge shows. The inbox renders- // one row per issue, so a single issue with three unread notifications- // counts once there and three times here. `getInboxUnreadSummary` is the- // deduplicated, per-workspace count the UI is built on (see- // `useInboxUnreadCount`); reach for this one only when raw rows are what- // you actually mean.- async getUnreadInboxCount(): Promise<{ count: number }> {- return this.fetch("/api/inbox/unread-count");- }-// Cross-workspace unread summary: one entry per workspace the user belongs// to that has unread inbox items. Backs the workspace-switcher dot for// OTHER workspaces. Schema-guarded so a contract drift hides the dot ratherdiff --git a/packages/core/inbox/filter-store.test.ts b/packages/core/inbox/filter-store.test.tsindex 2dec0acc7c..aaf349147b 100644--- a/packages/core/inbox/filter-store.test.ts+++ b/packages/core/inbox/filter-store.test.ts@@ -162,6 +162,8 @@ describe("notification dimensions", () => {expect(inboxTypeGroup("issue_subscribed")).toBe("assign");expect(inboxTypeGroup("children_done")).toBe("change");expect(inboxTypeGroup("agent_blocked")).toBe("run");+ expect(inboxTypeGroup("task_completed")).toBe("run");+ expect(inboxTypeGroup("review_requested")).toBe("review");expect(inboxTypeGroup("quick_create_failed")).toBe("system");expect(inboxTypeGroup("something_new")).toBe("system");});diff --git a/packages/core/inbox/filters.ts b/packages/core/inbox/filters.tsindex 12492348dd..55af93497c 100644--- a/packages/core/inbox/filters.ts+++ b/packages/core/inbox/filters.ts@@ -363,11 +363,6 @@ export function effectiveInboxFilters(return next;}-/** @deprecated Use `effectiveInboxFilters` with `archived: true`. */-export function inboxFiltersForArchive(filters: InboxFilters): InboxFilters {- return filters.agent ? withoutInboxFilter(filters, "agent") : filters;-}-/** Start of the received window, at a local midnight so it holds all day. */export function inboxReceivedAfter(received: InboxReceivedFilter, now: Date = new Date()): Date {const start = new Date(now.getFullYear(), now.getMonth(), now.getDate());diff --git a/packages/core/inbox/queries.ts b/packages/core/inbox/queries.tsindex d78138c06b..e1f8562f40 100644--- a/packages/core/inbox/queries.ts+++ b/packages/core/inbox/queries.ts@@ -26,18 +26,6 @@ export function inboxListOptions(wsId: string) {});}-/**- * @deprecated Legacy array endpoint, capped at 200 groups. New archive- * consumers must use archivedInboxPagesOptions for the complete archive.- * Retained for compatibility with legacy cache consumers.- */-export function archivedInboxListOptions(wsId: string) {- return queryOptions({- queryKey: inboxKeys.archived(wsId),- queryFn: () => api.listArchivedInbox(),- });-}-// Keyed by the request parameters themselves: an `agent` selection carried in// from the active inbox never changes the key, and the relative windows// (received, due date) re-key when the day turns.@@ -192,10 +180,9 @@ export function unreadCountForWorkspace(* its own; deriving it from `listInbox()` instead downloaded the entire* unbounded inbox on every app start just to render a number (MUL-6967).*- * `GET /api/inbox/unread-count` is deliberately not the source: it counts raw- * notification rows, while the inbox renders one row per issue. The summary- * endpoint applies the same newest-per-issue rule `deduplicateInboxItems`- * applies client-side, so this number matches the list the user sees.+ * The summary endpoint applies the same newest-per-issue rule+ * `deduplicateInboxItems` applies client-side, so this number matches the+ * list the user sees.*/export function useInboxUnreadCount(wsId: string | null | undefined,diff --git a/packages/core/notification-preferences/patch.ts b/packages/core/notification-preferences/patch.tsindex c3d753bf0c..437963205e 100644--- a/packages/core/notification-preferences/patch.ts+++ b/packages/core/notification-preferences/patch.ts@@ -10,6 +10,7 @@ const NOTIFICATION_GROUP_KEYS: readonly NotificationGroupKey[] = ["comments","chat_replies","mentions",+ "reactions","updates","new_issues","agent_activity",diff --git a/packages/core/realtime/use-realtime-sync.test.ts b/packages/core/realtime/use-realtime-sync.test.tsindex 965021a85d..ffc01b13a4 100644--- a/packages/core/realtime/use-realtime-sync.test.ts+++ b/packages/core/realtime/use-realtime-sync.test.ts@@ -854,6 +854,33 @@ describe("handleInboxNew", () => {expect(showNotification).not.toHaveBeenCalled();});+ it("skips the banner for a move to in_progress but still refreshes the inbox", async () => {+ const qc = createQueryClient();+ qc.setQueryData<Workspace[]>(workspaceKeys.list(), [workspace()]);+ qc.setQueryData(notificationPreferenceKeys.all("ws-a"), {+ preferences: { system_notifications: "all" },+ });+ const invalidate = vi.spyOn(qc, "invalidateQueries");+ const showNotification = stubDesktopAPI();++ await handleInboxNew(+ qc,+ inboxItem({ type: "status_changed", details: { from: "todo", to: "in_progress" } }),+ );+ expect(showNotification).not.toHaveBeenCalled();+ await vi.waitFor(() =>+ expect(invalidate).toHaveBeenCalledWith(+ expect.objectContaining({ queryKey: inboxKeys.all("ws-a") }),+ ),+ );++ await handleInboxNew(+ qc,+ inboxItem({ type: "status_changed", details: { from: "in_progress", to: "in_review" } }),+ );+ expect(showNotification).toHaveBeenCalledTimes(1);+ });+// The tests below exercise the COLD-cache mute path (source preference not// yet cached), where the request — not just the query key — must be scoped// to the source workspace (#3766 follow-up). They install a fake API so thediff --git a/packages/core/realtime/use-realtime-sync.ts b/packages/core/realtime/use-realtime-sync.tsindex 8ece84345e..57bc40a4f0 100644--- a/packages/core/realtime/use-realtime-sync.ts+++ b/packages/core/realtime/use-realtime-sync.ts@@ -589,6 +589,10 @@ export async function handleInboxNew(// A new item in ANY workspace can light the workspace-switcher dot, so// refresh the cross-workspace summary regardless of the active workspace.void onInboxSummaryInvalidate(qc);+ // Moving to in_progress is routine progress (an agent picking the issue+ // up), the same exception the server's delegated-handoff rule makes. The+ // row still lands in the inbox; it just doesn't interrupt with a banner.+ if (item.type === "status_changed" && item.details?.to === "in_progress") return;// Fire a native OS notification only when the app isn't focused. When// the user is already looking at Multica, the inbox sidebar's unread// styling is enough — no need to interrupt with a banner. `desktopAPI`diff --git a/packages/core/types/inbox.ts b/packages/core/types/inbox.tsindex c0ac238786..a4f472d55f 100644--- a/packages/core/types/inbox.ts+++ b/packages/core/types/inbox.ts@@ -15,12 +15,14 @@ export type InboxItemType =| "due_date_changed"| "new_comment"| "mentioned"+ | "task_failed"+ | "reaction_added"+ // No longer written, but older servers wrote them and those rows remain;+ // keep their labels and filter groups so history still reads and filters.| "review_requested"| "task_completed"- | "task_failed"| "agent_blocked"| "agent_completed"- | "reaction_added"| "quick_create_done"| "quick_create_failed"// Quick create whose outcome could not be verified. Distinct fromdiff --git a/packages/core/types/notification-preference.ts b/packages/core/types/notification-preference.tsindex 9365017198..6e12791a06 100644--- a/packages/core/types/notification-preference.ts+++ b/packages/core/types/notification-preference.ts@@ -4,6 +4,7 @@ export type NotificationGroupKey =| "comments"| "chat_replies"| "mentions"+ | "reactions"| "updates"| "new_issues"| "agent_activity"diff --git a/packages/views/layout/panels/sidebar-settings.tsx b/packages/views/layout/panels/sidebar-settings.tsxindex c2f23d3842..fc8e3555b0 100644--- a/packages/views/layout/panels/sidebar-settings.tsx+++ b/packages/views/layout/panels/sidebar-settings.tsx@@ -64,6 +64,7 @@ const INBOX_NOTIFICATION_GROUPS = ["status_changes","comments","mentions",+ "reactions","updates","new_issues","agent_activity",diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.jsonindex f86f83ad34..ddffb3822f 100644--- a/packages/views/locales/en/settings.json+++ b/packages/views/locales/en/settings.json@@ -870,6 +870,10 @@"label": "Mentions","description": "When someone @mentions you, including @all and @squad"},+ "reactions": {+ "label": "Reactions",+ "description": "When someone reacts to an issue you created or a comment you wrote"+ },"updates": {"label": "Priority & Due date","description": "When priority or due date changes on issues you follow"@@ -880,7 +884,7 @@},"agent_activity": {"label": "Agent activity",- "description": "When an agent run fails"+ "description": "When an agent run fails, or an app action an agent asked to run is blocked or expires"},"chat_replies": {"label": "Include chat replies"diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.jsonindex cb18ff4f77..4835efea6f 100644--- a/packages/views/locales/es/settings.json+++ b/packages/views/locales/es/settings.json@@ -870,6 +870,10 @@"label": "Menciones","description": "Cuando alguien te @menciona, incluidos @all y @squad"},+ "reactions": {+ "label": "Reacciones",+ "description": "Cuando alguien reacciona a una tarea que creaste o a un comentario que escribiste"+ },"updates": {"label": "Prioridad y fecha de entrega","description": "Cuando cambian la prioridad o la fecha de entrega de tareas que sigues"@@ -880,7 +884,7 @@},"agent_activity": {"label": "Actividad de agentes",- "description": "Cuando falla una ejecución de agente"+ "description": "Cuando falla una ejecución de agente, o una acción de app que pidió un agente se bloquea o caduca"},"chat_replies": {"label": "Incluir respuestas del chat"diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.jsonindex d0b3a9c68c..8c5a78abe6 100644--- a/packages/views/locales/fr/settings.json+++ b/packages/views/locales/fr/settings.json@@ -870,6 +870,10 @@"label": "Mentions","description": "Quand quelqu'un vous @mentionne, y compris via @all et @squad"},+ "reactions": {+ "label": "Réactions",+ "description": "Quand quelqu'un réagit à une tâche que vous avez créée ou à un commentaire que vous avez écrit"+ },"updates": {"label": "Priorité et date d'échéance","description": "Quand la priorité ou la date d'échéance change sur les tâches que vous suivez"@@ -880,7 +884,7 @@},"agent_activity": {"label": "Activité des agents",- "description": "Lorsqu'une exécution d'agent échoue"+ "description": "Lorsqu'une exécution d'agent échoue, ou qu'une action d'app demandée par un agent est bloquée ou expire"},"chat_replies": {"label": "Inclure les réponses du chat"diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.jsonindex 394e14014b..2e8d103e2d 100644--- a/packages/views/locales/ja/settings.json+++ b/packages/views/locales/ja/settings.json@@ -861,6 +861,10 @@"label": "メンション","description": "誰かがあなたを @メンションしたとき(@all と @squad を含む)"},+ "reactions": {+ "label": "リアクション",+ "description": "あなたが作成したタスクや書いたコメントに誰かがリアクションしたとき"+ },"updates": {"label": "優先度と期限","description": "フォロー中のタスクの優先度や期限が変わったとき"@@ -871,7 +875,7 @@},"agent_activity": {"label": "エージェントのアクティビティ",- "description": "エージェントの実行が失敗したとき"+ "description": "エージェントの実行が失敗したとき、またはエージェントが求めたアプリ操作がブロックされたか期限切れになったとき"},"chat_replies": {"label": "チャットの返信を含める"diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.jsonindex ce1379efe5..681336d623 100644--- a/packages/views/locales/ko/settings.json+++ b/packages/views/locales/ko/settings.json@@ -861,6 +861,10 @@"label": "멘션","description": "누군가 나를 @멘션할 때(@all, @squad 포함)"},+ "reactions": {+ "label": "반응",+ "description": "내가 만든 태스크나 내가 쓴 댓글에 누군가 반응할 때"+ },"updates": {"label": "우선순위 및 마감일","description": "팔로우 중인 태스크의 우선순위나 마감일이 바뀔 때"@@ -871,7 +875,7 @@},"agent_activity": {"label": "에이전트 활동",- "description": "에이전트 실행이 실패할 때"+ "description": "에이전트 실행이 실패하거나, 에이전트가 요청한 앱 작업이 차단되거나 만료될 때"},"chat_replies": {"label": "채팅 답변 포함"diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.jsonindex 00be4050b7..560ef7066a 100644--- a/packages/views/locales/ru/settings.json+++ b/packages/views/locales/ru/settings.json@@ -884,7 +884,7 @@},"groups": {"agent_activity": {- "description": "Когда запуск агента завершается с ошибкой",+ "description": "Когда запуск агента завершается с ошибкой или запрошенное агентом действие в приложении заблокировано либо истекло","label": "Активность агентов"},"assignments": {@@ -899,6 +899,10 @@"description": "Когда вас упоминают через @, в том числе через @all и @squad","label": "Упоминания"},+ "reactions": {+ "description": "Когда кто-то реагирует на созданную вами задачу или ваш комментарий",+ "label": "Реакции"+ },"status_changes": {"description": "Когда у задачи, на которую вы подписаны, меняется статус (например, «К выполнению», «В работе», «Готово»)","label": "Изменения статуса"diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.jsonindex 535e0d2aba..fbadaa400c 100644--- a/packages/views/locales/zh-Hans/settings.json+++ b/packages/views/locales/zh-Hans/settings.json@@ -861,6 +861,10 @@"label": "提及","description": "有人 @ 你时,包括 @all 和 @squad"},+ "reactions": {+ "label": "表情回应",+ "description": "有人对你创建的任务或你写的评论添加表情时"+ },"updates": {"label": "优先级与截止日期","description": "你订阅的任务优先级或截止日期变更时"@@ -871,7 +875,7 @@},"agent_activity": {"label": "智能体活动",- "description": "智能体运行失败时"+ "description": "智能体运行失败,或智能体请求的应用操作被拦截、过期时"},"chat_replies": {"label": "包含聊天回复"diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.jsonindex 548b43a423..2902eaab40 100644--- a/packages/views/locales/zh-Hant/settings.json+++ b/packages/views/locales/zh-Hant/settings.json@@ -861,6 +861,10 @@"label": "提及","description": "有人 @ 你時,包括 @all 和 @squad"},+ "reactions": {+ "label": "表情回應",+ "description": "有人對你建立的任務或你寫的評論加上表情時"+ },"updates": {"label": "優先順序與截止日期","description": "你訂閱的任務優先順序或截止日期變更時"@@ -871,7 +875,7 @@},"agent_activity": {"label": "AI 代理活動",- "description": "AI 代理執行失敗時"+ "description": "AI 代理執行失敗,或 AI 代理請求的應用操作被攔截、過期時"},"chat_replies": {"label": "包含聊天回覆"diff --git a/packages/views/settings/components/notifications-tab.test.tsx b/packages/views/settings/components/notifications-tab.test.tsxindex 14a27a9c3f..5d6d6d1c97 100644--- a/packages/views/settings/components/notifications-tab.test.tsx+++ b/packages/views/settings/components/notifications-tab.test.tsx@@ -51,6 +51,7 @@ describe("Inbox notification settings", () => {"About you","Assignments","Mentions",+ "Reactions","Issues you subscribe to","Status changes","Comments",diff --git a/packages/views/settings/components/notifications-tab.tsx b/packages/views/settings/components/notifications-tab.tsxindex 275184e653..b4d928c803 100644--- a/packages/views/settings/components/notifications-tab.tsx+++ b/packages/views/settings/components/notifications-tab.tsx@@ -25,7 +25,7 @@ import {// Inbox event groups, by how the event reaches you. `system_notifications`// is a sibling preference key but lives in its own section below.const INBOX_CATEGORIES = [- { key: "direct", groups: ["assignments", "mentions"] },+ { key: "direct", groups: ["assignments", "mentions", "reactions"] },{ key: "issues", groups: ["status_changes", "comments", "updates"] },{ key: "projects", groups: ["new_issues"] },{ key: "agents", groups: ["agent_activity"] },diff --git a/packages/views/settings/components/use-settings-search-index.ts b/packages/views/settings/components/use-settings-search-index.tsindex 28a1759fd6..4d7c9eed68 100644--- a/packages/views/settings/components/use-settings-search-index.ts+++ b/packages/views/settings/components/use-settings-search-index.ts@@ -11,6 +11,7 @@ const NOTIFICATION_GROUPS = ["status_changes","comments","mentions",+ "reactions","updates","new_issues","agent_activity",diff --git a/server/cmd/server/delegated_subscriber_test.go b/server/cmd/server/delegated_subscriber_test.goindex 2981417e4c..5e3d5b1fce 100644--- a/server/cmd/server/delegated_subscriber_test.go+++ b/server/cmd/server/delegated_subscriber_test.go@@ -479,7 +479,6 @@ func TestDeliverToSubscriber_DelegatedTier(t *testing.T) {{"delegated always gets direct mentions", "delegated", "mentioned", false, true},{"delegated always gets comments", "delegated", "new_comment", false, true},{"delegated always gets failures", "delegated", "task_failed", false, true},- {"delegated always gets agent_blocked", "delegated", "agent_blocked", false, true},}for _, tc := range cases {diff --git a/server/cmd/server/notification_listeners.go b/server/cmd/server/notification_listeners.goindex 4a7e9681d8..3f2a6b609e 100644--- a/server/cmd/server/notification_listeners.go+++ b/server/cmd/server/notification_listeners.go@@ -52,11 +52,13 @@ var parentBubbleNotifTypes = map[string]bool{// status changes must not leave the human with no signal that the work they// started was answered (MUL-9314). The inbox keeps one row per issue, so a// comment lands on the row a handoff would light anyway.+//+// An agent that cannot proceed reaches the human as a blocked status change,+// which the handoff rule in deliverToSubscriber already delivers.var delegatedAlwaysNotifTypes = map[string]bool{- "mentioned": true,- "new_comment": true,- "task_failed": true,- "agent_blocked": true,+ "mentioned": true,+ "new_comment": true,+ "task_failed": true,}// issueStatusIsHandoff reports whether ARRIVING on this status hands the issue@@ -142,8 +144,10 @@ func deliverToSubscriber(reason, notifType string, statusIsHandoff bool) bool {return statusIsHandoff}-// notifTypeToGroup maps each InboxItemType to a user-configurable preference-// group. Types not in this map are always delivered (not configurable).+// notifTypeToGroup maps each inbox type the issue listeners write to a+// user-configurable preference group. Types not in this map are always+// delivered (not configurable). app_action_result also belongs to+// agent_activity; connectedapps checks that group itself.var notifTypeToGroup = map[string]string{"issue_assigned": "assignments","unassigned": "assignments",@@ -151,13 +155,11 @@ var notifTypeToGroup = map[string]string{"status_changed": "status_changes","new_comment": "comments","mentioned": "mentions",+ "reaction_added": "reactions","priority_changed": "updates","start_date_changed": "updates","due_date_changed": "updates",- "task_completed": "agent_activity","task_failed": "agent_activity",- "agent_blocked": "agent_activity",- "agent_completed": "agent_activity","issue_created": "new_issues",}@@ -738,7 +740,8 @@ func notifyDelegatedIssueCreated(// notifyMentionedMembers creates inbox items for each @mentioned member,// excluding the actor and any IDs in the skip set. When an @all mention is-// present, all workspace members are notified (excluding agents).+// present, all workspace members are notified (excluding agents). Returns the+// members that received a row.func notifyMentionedMembers(bus *events.Bus,queries *db.Queries,@@ -748,9 +751,11 @@ func notifyMentionedMembers(issueTitle string,issueStatus string,title string,+ body string,skip map[string]bool,details []byte,-) {+) map[string]bool {+ notified := map[string]bool{}// Collect the set of member IDs to notify.recipientIDs := map[string]bool{}@@ -832,6 +837,7 @@ func notifyMentionedMembers(Severity: "info",IssueID: parseUUID(issueID),Title: title,+ Body: util.StrToText(body),ActorType: util.StrToText(e.ActorType),ActorID: optionalUUID(e.ActorID),Details: details,@@ -843,6 +849,7 @@ func notifyMentionedMembers(if !inserted {continue}+ notified[id] = trueresp := inboxItemToResponse(item)resp["issue_status"] = issueStatusbus.Publish(events.Event{@@ -853,11 +860,11 @@ func notifyMentionedMembers(Payload: map[string]any{"item": resp},})}+ return notified}// registerNotificationListeners wires up event bus listeners that create inbox-// notifications using the subscriber table. This replaces the old hardcoded-// notification logic from inbox_listeners.go.+// notifications using the subscriber table.//// NOTE: uses context.Background() because the event bus dispatches synchronously// within the HTTP request goroutine. Adding per-handler timeouts is a bus-level@@ -896,7 +903,7 @@ func registerNotificationListeners(bus *events.Bus, queries *db.Queries) {if issue.Description != nil && *issue.Description != "" {mentions := parseMentions(*issue.Description)notifyMentionedMembers(bus, queries, e, mentions, issue.ID, issue.Title, issue.Status,- issue.Title, skip, emptyDetails)+ issue.Title, "", skip, emptyDetails)}notifyDelegatedIssueCreated(ctx, queries, bus, issue, e, skip)@@ -1106,7 +1113,7 @@ func registerNotificationListeners(bus *events.Bus, queries *db.Queries) {}skip := map[string]bool{e.ActorID: true}notifyMentionedMembers(bus, queries, e, added, issue.ID, issue.Title, issue.Status,- issue.Title, skip, emptyDetails)+ issue.Title, "", skip, emptyDetails)}}})@@ -1159,18 +1166,20 @@ func registerNotificationListeners(bus *events.Bus, queries *db.Queries) {})}+ // Mentions first: a member who gets a `mentioned` row for this comment+ // does not also get its `new_comment`, so one comment is one+ // notification. A member who muted mentions still gets the comment.+ mentioned := map[string]bool{}+ if mentions := parseMentions(commentContent); len(mentions) > 0 {+ skip := map[string]bool{e.ActorID: true}+ mentioned = notifyMentionedMembers(bus, queries, e, mentions, issueID, issueTitle, issueStatus,+ issueTitle, commentContent, skip, commentDetails)+ }+notifySubscribers(ctx, queries, bus, issueID, issueStatus, e.WorkspaceID, e,- nil, "new_comment", "info",+ mentioned, "new_comment", "info",issueTitle, commentContent,commentDetails)-- // Notify @mentions in comment content.- mentions := parseMentions(commentContent)- if len(mentions) > 0 {- skip := map[string]bool{e.ActorID: true}- notifyMentionedMembers(bus, queries, e, mentions, issueID, issueTitle, issueStatus,- issueTitle, skip, commentDetails)- }})// issue_reaction:added — notify the issue creatordiff --git a/server/cmd/server/notification_listeners_test.go b/server/cmd/server/notification_listeners_test.goindex a5d789635b..fd471025a1 100644--- a/server/cmd/server/notification_listeners_test.go+++ b/server/cmd/server/notification_listeners_test.go@@ -2,6 +2,7 @@ package mainimport ("context"+ "strings""testing""github.com/multica-ai/multica/server/internal/events"@@ -384,6 +385,139 @@ func TestNotification_StatusChanged_Muted(t *testing.T) {}}+// TestNotification_ReactionAdded_Muted verifies that reactions="muted" stops+// the reaction_added row an issue creator would otherwise get.+func TestNotification_ReactionAdded_Muted(t *testing.T) {+ queries := db.New(testPool)+ bus := newNotificationBus(t, queries)++ for _, tc := range []struct {+ name string+ prefs string+ want int+ }{+ {"reactions muted", `{"reactions":"muted"}`, 0},+ {"comments muted", `{"comments":"muted"}`, 1},+ } {+ t.Run(tc.name, func(t *testing.T) {+ email := "notif-reaction-" + strings.ReplaceAll(tc.name, " ", "-") + "@multica.ai"+ creatorID := createNotificationMember(t, email)+ t.Cleanup(func() { cleanupTestUser(t, email) })++ issueID := createTestIssue(t, testWorkspaceID, creatorID)+ t.Cleanup(func() {+ cleanupInboxForIssue(t, issueID)+ cleanupTestIssue(t, issueID)+ })++ if _, err := testPool.Exec(context.Background(), `+ INSERT INTO notification_preference (workspace_id, user_id, preferences)+ VALUES ($1, $2, $3::jsonb)+ `, testWorkspaceID, creatorID, tc.prefs); err != nil {+ t.Fatalf("seed notification preference: %v", err)+ }++ bus.Publish(events.Event{+ Type: protocol.EventIssueReactionAdded,+ WorkspaceID: testWorkspaceID,+ ActorType: "member",+ ActorID: testUserID,+ Payload: map[string]any{+ "reaction": handler.IssueReactionResponse{Emoji: "👍"},+ "creator_type": "member",+ "creator_id": creatorID,+ "issue_id": issueID,+ "issue_title": "reaction mute test issue",+ "issue_status": "todo",+ },+ })++ if items := inboxItemsForRecipient(t, queries, creatorID); len(items) != tc.want {+ t.Fatalf("expected %d inbox items for creator, got %d", tc.want, len(items))+ }+ })+ }+}++// TestNotification_CommentMentionIsOneNotification verifies that a subscriber+// @mentioned in a comment gets one `mentioned` row carrying the comment, not a+// `new_comment` row as well, while a subscriber who muted mentions still gets+// the comment.+func TestNotification_CommentMentionIsOneNotification(t *testing.T) {+ queries := db.New(testPool)+ bus := newNotificationBus(t, queries)++ mentionedEmail := "[email protected]"+ mentionedID := createNotificationMember(t, mentionedEmail)+ t.Cleanup(func() { cleanupTestUser(t, mentionedEmail) })++ mutedEmail := "[email protected]"+ mutedID := createNotificationMember(t, mutedEmail)+ t.Cleanup(func() { cleanupTestUser(t, mutedEmail) })++ otherEmail := "[email protected]"+ otherID := createNotificationMember(t, otherEmail)+ t.Cleanup(func() { cleanupTestUser(t, otherEmail) })++ issueID := createTestIssue(t, testWorkspaceID, testUserID)+ t.Cleanup(func() {+ cleanupInboxForIssue(t, issueID)+ cleanupTestIssue(t, issueID)+ })++ if _, err := testPool.Exec(context.Background(), `+ INSERT INTO notification_preference (workspace_id, user_id, preferences)+ VALUES ($1, $2, '{"mentions":"muted"}'::jsonb)+ `, testWorkspaceID, mutedID); err != nil {+ t.Fatalf("seed muted notification preference: %v", err)+ }++ addTestSubscriber(t, issueID, "member", mentionedID, "commenter")+ addTestSubscriber(t, issueID, "member", mutedID, "commenter")+ addTestSubscriber(t, issueID, "member", otherID, "commenter")++ content := "[@A](mention://member/" + mentionedID + ") [@B](mention://member/" + mutedID + ") please look"+ bus.Publish(events.Event{+ Type: protocol.EventCommentCreated,+ WorkspaceID: testWorkspaceID,+ ActorType: "member",+ ActorID: testUserID,+ Payload: map[string]any{+ "comment": handler.CommentResponse{+ ID: "00000000-0000-0000-0000-000000000000",+ IssueID: issueID,+ AuthorType: "member",+ AuthorID: testUserID,+ Content: content,+ Type: "comment",+ },+ "issue_title": "comment mention test issue",+ "issue_status": "todo",+ },+ })++ for _, tc := range []struct {+ name string+ recipientID string+ wantType string+ }{+ {"mentioned subscriber", mentionedID, "mentioned"},+ {"subscriber who muted mentions", mutedID, "new_comment"},+ {"subscriber not mentioned", otherID, "new_comment"},+ } {+ items := inboxItemsForRecipient(t, queries, tc.recipientID)+ if len(items) != 1 {+ t.Fatalf("%s: expected 1 inbox item, got %d", tc.name, len(items))+ }+ if items[0].Type != tc.wantType {+ t.Fatalf("%s: expected type %q, got %q", tc.name, tc.wantType, items[0].Type)+ }+ if items[0].Body.String != content {+ t.Fatalf("%s: expected the comment as body, got %q", tc.name, items[0].Body.String)+ }+ }+}+// TestNotification_CommentCreated verifies that all subscribers except the// commenter receive a "new_comment" notification.func TestNotification_CommentCreated(t *testing.T) {diff --git a/server/cmd/server/notification_mentions_test.go b/server/cmd/server/notification_mentions_test.goindex d20961f6a2..5bcd159a83 100644--- a/server/cmd/server/notification_mentions_test.go+++ b/server/cmd/server/notification_mentions_test.go@@ -105,5 +105,5 @@ func TestNotifyMentionedMembersOnlyMalformedIDs(t *testing.T) {// no valid recipients, neither the database nor the bus is needed.notifyMentionedMembers(nil, nil, events.Event{},parseMentions("[@Bad](mention://member/deadbeef) [@Bad all](mention://member/all)"),- "", "", "", "", nil, nil)+ "", "", "", "", "", nil, nil)}diff --git a/server/cmd/server/notification_mute_group_test.go b/server/cmd/server/notification_mute_group_test.goindex d50a6673fb..cfe7493436 100644--- a/server/cmd/server/notification_mute_group_test.go+++ b/server/cmd/server/notification_mute_group_test.go@@ -32,8 +32,12 @@ func TestIsNotifMutedGroupSplit(t *testing.T) {{"status group intact", map[string]string{"status_changes": "muted"}, "status_changed", true},{"muting comments leaves assignments alone", map[string]string{"comments": "muted"}, "issue_assigned", false},+ // Reactions have their own group, apart from comments.+ {"muted reactions drops reaction_added", map[string]string{"reactions": "muted"}, "reaction_added", true},+ {"muted comments still delivers reactions", map[string]string{"comments": "muted"}, "reaction_added", false},+// Types outside the map are always delivered.- {"unconfigurable type always delivered", map[string]string{"comments": "muted"}, "reaction_added", false},+ {"unconfigurable type always delivered", map[string]string{"comments": "muted"}, "children_done", false},}for _, tc := range cases {diff --git a/server/internal/handler/inbox_archive_legacy_types_test.go b/server/internal/handler/inbox_archive_legacy_types_test.gonew file mode 100644index 0000000000..904bd55499--- /dev/null+++ b/server/internal/handler/inbox_archive_legacy_types_test.go@@ -0,0 +1,34 @@+package handler++import (+ "net/http"+ "testing"++ "github.com/google/uuid"+ "github.com/multica-ai/multica/server/internal/testutil"+)++func TestArchivedInboxFilterKeepsLegacyTypes(t *testing.T) {+ for _, tc := range []struct{ kind, group string }{+ {"task_completed", "run"},+ {"review_requested", "review"},+ {"agent_blocked", "run"},+ } {+ t.Run(tc.kind, func(t *testing.T) {+ ws := dbfx.Workspace(t, "Legacy archive", "legacy-archive-"+uuid.NewString())+ dbfx.Member(t, ws, testUserID, "owner")+ issue := dbfx.Issue(t, "Historical notification", testutil.Cols{"workspace_id": ws})+ id := dbfx.Insert(t, "inbox_item", testutil.Cols{+ "workspace_id": ws, "recipient_type": "member", "recipient_id": testUserID,+ "type": tc.kind, "severity": "info", "title": "Historical notification",+ "issue_id": issue, "archived": true,+ })+ var page archivedInboxPageResponse+ testutil.Call(t, inboxWorkspaceHandler(testHandler.ListArchivedInboxPage),+ inboxRequest(http.MethodGet, "/api/inbox/archived/page?types="+tc.group, ws)).Want(http.StatusOK).JSON(&page)+ if len(page.Items) != 1 || page.Items[0].ID != id {+ t.Fatalf("historical %s notification missing from %s filter: %+v", tc.kind, tc.group, page.Items)+ }+ })+ }+}diff --git a/server/internal/handler/notification_preference.go b/server/internal/handler/notification_preference.goindex d309522e01..7750fedc1b 100644--- a/server/internal/handler/notification_preference.go+++ b/server/internal/handler/notification_preference.go@@ -23,6 +23,7 @@ var validNotifGroups = map[string]bool{"comments": true,"chat_replies": true,"mentions": true,+ "reactions": true,"updates": true,"agent_activity": true,"new_issues": true,diff --git a/server/internal/handler/notification_preference_test.go b/server/internal/handler/notification_preference_test.goindex af8e913768..9e80ffc014 100644--- a/server/internal/handler/notification_preference_test.go+++ b/server/internal/handler/notification_preference_test.go@@ -127,40 +127,45 @@ func TestPatchNotificationPreferencesMergesWithoutReplacing(t *testing.T) {}}-// TestPatchNotificationPreferencesAcceptsMentions covers the group added by-// #6468. The whitelist rejects unknown keys, so a client shipped ahead of the-// server would 400 on this key — the reason the server must deploy first.-func TestPatchNotificationPreferencesAcceptsMentions(t *testing.T) {+// TestPatchNotificationPreferencesAcceptsAddedGroups covers groups added after+// the original set: mentions (#6468) and reactions (MUL-9328). The whitelist+// rejects unknown keys, so a client shipped ahead of the server would 400 on+// these keys — the reason the server must deploy first.+func TestPatchNotificationPreferencesAcceptsAddedGroups(t *testing.T) {if testHandler == nil || testPool == nil {t.Skip("database not available")}- t.Cleanup(func() {- _, _ = testPool.Exec(context.Background(), `- DELETE FROM notification_preference- WHERE workspace_id = $1 AND user_id = $2- `, testWorkspaceID, testUserID)- })-- recorder := httptest.NewRecorder()- testHandler.PatchNotificationPreferences(- recorder,- notificationPreferenceRequest(t, http.MethodPatch, map[string]string{- "mentions": "muted",- }),- )- if recorder.Code != http.StatusOK {- t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String())- }-- var response struct {- Preferences map[string]string `json:"preferences"`- }- if err := json.NewDecoder(recorder.Body).Decode(&response); err != nil {- t.Fatalf("decode response: %v", err)- }- if response.Preferences["mentions"] != "muted" {- t.Fatalf("mentions not persisted: %#v", response.Preferences)+ for _, group := range []string{"mentions", "reactions"} {+ t.Run(group, func(t *testing.T) {+ t.Cleanup(func() {+ _, _ = testPool.Exec(context.Background(), `+ DELETE FROM notification_preference+ WHERE workspace_id = $1 AND user_id = $2+ `, testWorkspaceID, testUserID)+ })++ recorder := httptest.NewRecorder()+ testHandler.PatchNotificationPreferences(+ recorder,+ notificationPreferenceRequest(t, http.MethodPatch, map[string]string{+ group: "muted",+ }),+ )+ if recorder.Code != http.StatusOK {+ t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String())+ }++ var response struct {+ Preferences map[string]string `json:"preferences"`+ }+ if err := json.NewDecoder(recorder.Body).Decode(&response); err != nil {+ t.Fatalf("decode response: %v", err)+ }+ if response.Preferences[group] != "muted" {+ t.Fatalf("%s not persisted: %#v", group, response.Preferences)+ }+ })}}diff --git a/server/pkg/db/generated/inbox.sql.go b/server/pkg/db/generated/inbox.sql.goindex 6696a3451f..593809f171 100644--- a/server/pkg/db/generated/inbox.sql.go+++ b/server/pkg/db/generated/inbox.sql.go@@ -437,36 +437,6 @@ func (q *Queries) DeleteInboxGroup(ctx context.Context, arg DeleteInboxGroupParareturn result.RowsAffected(), nil}-const getInboxItem = `-- name: GetInboxItem :one-SELECT id, workspace_id, recipient_type, recipient_id, type, severity, issue_id, title, body, read, archived, created_at, actor_type, actor_id, details, section, snoozed_until FROM inbox_item-WHERE id = $1-`--func (q *Queries) GetInboxItem(ctx context.Context, id pgtype.UUID) (InboxItem, error) {- row := q.db.QueryRow(ctx, getInboxItem, id)- var i InboxItem- err := row.Scan(- &i.ID,- &i.WorkspaceID,- &i.RecipientType,- &i.RecipientID,- &i.Type,- &i.Severity,- &i.IssueID,- &i.Title,- &i.Body,- &i.Read,- &i.Archived,- &i.CreatedAt,- &i.ActorType,- &i.ActorID,- &i.Details,- &i.Section,- &i.SnoozedUntil,- )- return i, err-}-const getInboxItemInWorkspace = `-- name: GetInboxItemInWorkspace :oneSELECT id, workspace_id, recipient_type, recipient_id, type, severity, issue_id, title, body, read, archived, created_at, actor_type, actor_id, details, section, snoozed_until FROM inbox_itemWHERE id = $1 AND workspace_id = $2diff --git a/server/pkg/db/generated/inbox_archive.sql.go b/server/pkg/db/generated/inbox_archive.sql.goindex e4f3b30f86..39526f44dd 100644--- a/server/pkg/db/generated/inbox_archive.sql.go+++ b/server/pkg/db/generated/inbox_archive.sql.go@@ -356,6 +356,8 @@ type ListArchivedInboxPageRow struct {// MATCHING notification, which is the row the list renders; issue filters and// "unread" then test that group. Issue filters never match a notification// without an issue, "is not" included. Type groups mirror INBOX_TYPE_GROUPS.+// review_requested, task_completed, agent_blocked and agent_completed are no+// longer written, but archived rows from older servers still carry them.// Select narrow group representatives before loading bodies or comment anchors.func (q *Queries) ListArchivedInboxPage(ctx context.Context, arg ListArchivedInboxPageParams) ([]ListArchivedInboxPageRow, error) {rows, err := q.db.Query(ctx, listArchivedInboxPage,diff --git a/server/pkg/db/queries/inbox.sql b/server/pkg/db/queries/inbox.sqlindex 21e1cbd242..03cdf47635 100644--- a/server/pkg/db/queries/inbox.sql+++ b/server/pkg/db/queries/inbox.sql@@ -105,10 +105,6 @@ JOIN selected_ids selected ON selected.id = i.idLEFT JOIN issue iss ON iss.id = i.issue_idORDER BY i.created_at DESC, i.id DESC;--- name: GetInboxItem :one-SELECT * FROM inbox_item-WHERE id = $1;--- name: GetInboxItemInWorkspace :oneSELECT * FROM inbox_itemWHERE id = $1 AND workspace_id = $2;diff --git a/server/pkg/db/queries/inbox_archive.sql b/server/pkg/db/queries/inbox_archive.sqlindex e1f65ad715..c15882471e 100644--- a/server/pkg/db/queries/inbox_archive.sql+++ b/server/pkg/db/queries/inbox_archive.sql@@ -3,6 +3,8 @@-- MATCHING notification, which is the row the list renders; issue filters and-- "unread" then test that group. Issue filters never match a notification-- without an issue, "is not" included. Type groups mirror INBOX_TYPE_GROUPS.+-- review_requested, task_completed, agent_blocked and agent_completed are no+-- longer written, but archived rows from older servers still carry them.-- name: ListArchivedInboxPage :many-- Select narrow group representatives before loading bodies or comment anchors.