Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(inbox): option to leave squad handoff comments out of the Inbox (MUL-10008) (#11339)

Jiayuan Zhangbeb522ee48dc
diff --git a/apps/docs/content/docs/inbox.fr.mdx b/apps/docs/content/docs/inbox.fr.mdx
index a752404652..f8e91e0293 100644
--- a/apps/docs/content/docs/inbox.fr.mdx
+++ b/apps/docs/content/docs/inbox.fr.mdx
@@ -168,6 +168,8 @@ En dessous, **Me notifier pour** active ou désactive chaque type de notificatio
**Changements de statut** est désactivé par défaut ; tous les autres types sont activés. Un type désactivé ne crée aucune notification, et le réactiver ne fait pas revenir ce que vous avez manqué ; les changements restent enregistrés sur la tâche. Quelques types, comme les résultats de création rapide et les mises en pause d'automatisation, ne relèvent pas de ces groupes et sont toujours envoyés. Les notifications système et du navigateur contrôlent les bannières sur le bureau et ne modifient pas la boîte de réception elle-même.
+Sous **Commentaires**, **Inclure les passations de squad** couvre les commentaires d'une tâche de squad par lesquels son chef et ses agents se transmettent le travail : le chef qui @-mentionne un agent ou une squad, et les agents qui lui rendent compte. Activé par défaut ; désactivez-le pour ne garder que les commentaires destinés à des personnes. Les commentaires qui vous @-mentionnent, vous ou quelqu'un d'autre, les réponses d'agent au commentaire d'une personne, les exécutions d'agent en échec et les statuts qui demandent votre attention arrivent toujours.
+
## Étapes suivantes
- [Commentaires](/comments) — réponses, mentions et fils de discussion.
diff --git a/apps/docs/content/docs/inbox.ja.mdx b/apps/docs/content/docs/inbox.ja.mdx
index 08af4c3bae..5b266e5268 100644
--- a/apps/docs/content/docs/inbox.ja.mdx
+++ b/apps/docs/content/docs/inbox.ja.mdx
@@ -168,6 +168,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
**ステータス変更** は既定でオフ、ほかの種類は既定でオンです。オフにした種類の通知は作られず、オンに戻しても見逃した分は戻りません。変更そのものはタスクに記録され続けます。エージェント経由の作成結果、オートパイロットの一時停止など一部のタイプはこれらのグループの対象外で、常に届きます。システム通知とブラウザ通知はデスクトップのバナーを制御するもので、インボックス自体は変わりません。
+**コメント** の下の **スクワッド内の引き継ぎを含める** は、スクワッドのタスクでリーダーとエージェントが作業を受け渡すコメントが対象です。リーダーがエージェントやスクワッドを @ メンションして依頼するコメントと、エージェントからの報告がこれに当たります。既定でオンで、オフにすると人に向けたコメントだけが届きます。あなたや他のメンバーを @ メンションしたコメント、人のコメントへのエージェントの返信、エージェント実行の失敗、対応が必要なステータスは引き続き届きます。
+
## 次のステップ
- [コメント](/comments) — 返信、メンション、スレッドを理解します。
diff --git a/apps/docs/content/docs/inbox.ko.mdx b/apps/docs/content/docs/inbox.ko.mdx
index abda03988d..aa6b30e587 100644
--- a/apps/docs/content/docs/inbox.ko.mdx
+++ b/apps/docs/content/docs/inbox.ko.mdx
@@ -168,6 +168,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339, 30m, 3h, 1d, 1w; uns
**상태 변경**은 기본적으로 꺼져 있고 나머지 종류는 켜져 있습니다. 끈 종류의 알림은 만들어지지 않으며, 다시 켜도 놓친 알림은 돌아오지 않습니다. 변경 사항 자체는 태스크에 계속 기록됩니다. 빠른 생성 결과, 자동화 일시 중지 같은 일부 유형은 이 그룹들과 관계없이 항상 전달됩니다. 시스템 알림과 브라우저 알림 설정은 데스크톱 배너를 제어할 뿐 인박스 자체를 바꾸지 않습니다.
+**댓글** 아래의 **스쿼드 내부 인계 포함**은 스쿼드 태스크에서 리더와 에이전트가 작업을 주고받는 댓글을 다룹니다. 리더가 에이전트나 스쿼드를 @멘션해 일을 맡기는 댓글과 에이전트의 보고가 여기에 해당합니다. 기본적으로 켜져 있으며, 끄면 사람에게 향한 댓글만 받습니다. 나나 다른 멤버를 @멘션한 댓글, 사람의 댓글에 대한 에이전트 답글, 실패한 에이전트 실행, 확인이 필요한 상태는 계속 전달됩니다.
+
## 다음 단계
- [댓글](/comments) — 답글, 멘션, 논의 스레드를 알아봅니다.
diff --git a/apps/docs/content/docs/inbox.mdx b/apps/docs/content/docs/inbox.mdx
index 1a89ae6741..0a26a47d10 100644
--- a/apps/docs/content/docs/inbox.mdx
+++ b/apps/docs/content/docs/inbox.mdx
@@ -168,6 +168,8 @@ Below them, **Notify me about** turns each kind of notification on or off. These
**Status changes** starts off; every other kind starts on. A kind that's turned off creates no notification, and turning it back on doesn't bring back what you missed; the changes are still recorded on the issue. A few types, such as quick-create results and autopilot pauses, sit outside these groups and are always delivered. System and browser notifications control desktop banners and don't change the inbox itself.
+Under **Comments**, **Include squad handoffs** covers the comments on a squad's issue that its leader and agents pass work to each other with: the leader @-mentioning an agent or squad, and the agents reporting back. It starts on; turn it off to keep only the comments meant for people. Comments that @-mention you or anyone else, agent replies to a person's comment, failed agent runs, and statuses that need attention still arrive.
+
## Next steps
- [Comments](/comments) — replies, mentions, and discussion threads.
diff --git a/apps/docs/content/docs/inbox.zh-Hant.mdx b/apps/docs/content/docs/inbox.zh-Hant.mdx
index 4d527c27a6..12412a289e 100644
--- a/apps/docs/content/docs/inbox.zh-Hant.mdx
+++ b/apps/docs/content/docs/inbox.zh-Hant.mdx
@@ -168,6 +168,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
**狀態變更**預設關閉,其餘類型預設開啟。關閉某一類後,不再建立這類通知,重新開啟也不會補回錯過的通知;相關變化仍然儲存在任務中。快速建立結果和自動化暫停等少數類型不受這些分組控制,始終投遞。系統通知和瀏覽器通知控制的是桌面橫幅,不會改變收件箱本身。
+**評論**下的**包含小隊內部交接**針對小隊任務裡隊長和 AI 代理之間傳遞工作的評論:隊長 @ AI 代理或小隊指派工作,以及 AI 代理向隊長回報。預設開啟;關閉後只保留寫給人的評論。@ 你或其他成員的評論、AI 代理對某人評論的回覆、AI 代理執行失敗和需要關注的狀態照常通知。
+
## 接下來
- [評論](/comments) — 瞭解回覆、提及和討論執行緒。
diff --git a/apps/docs/content/docs/inbox.zh.mdx b/apps/docs/content/docs/inbox.zh.mdx
index 0830275b1e..021a716559 100644
--- a/apps/docs/content/docs/inbox.zh.mdx
+++ b/apps/docs/content/docs/inbox.zh.mdx
@@ -168,6 +168,8 @@ multica inbox snooze <id>... --until tomorrow # RFC 3339、30m、3h、1d、1w
**状态变更**默认关闭,其余类型默认打开。关闭某一类后,不再创建这类通知,重新打开也不会补回错过的通知;相关变化仍然保存在任务中。快速创建结果和自动化暂停等少数类型不受这些分组控制,始终投递。系统通知和浏览器通知控制的是桌面横幅,不会改变收件箱本身。
+**评论**下的**包含小队内部交接**针对小队任务里队长和智能体之间传递工作的评论:队长 @ 智能体或小队派活,以及智能体向队长回报。默认打开;关闭后只保留写给人的评论。@ 你或其他成员的评论、智能体对某人评论的回复、智能体运行失败和需要关注的状态照常通知。
+
## 接下来
- [评论](/comments) — 了解回复、提及和讨论线程。
diff --git a/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx b/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx
index 081e49b4e5..2b7c9de7bc 100644
--- a/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx
+++ b/apps/mobile/app/(app)/[workspace]/more/settings/notifications.tsx
@@ -22,7 +22,7 @@ import { useUpdateNotificationPreferences } from "@/data/mutations/notification-
import { useT } from "@/lib/i18n";
const INBOX_GROUPS: {
- key: Exclude<NotificationGroupKey, "system_notifications" | "chat_replies">;
+ key: Exclude<NotificationGroupKey, "system_notifications" | "chat_replies" | "squad_handoffs">;
labelKey: string;
descriptionKey?: string;
}[] = [
@@ -135,6 +135,27 @@ export default function NotificationsSettingsScreen() {
onCheckedChange={(checked) => onToggle(group.key, checked)}
/>
</View>
+ {group.key === "comments" && enabled && (
+ <>
+ <Separator />
+ <View className="flex-row items-center pl-8 pr-4 py-3 gap-3">
+ <View className="flex-1">
+ <Text className="text-base font-medium text-foreground">
+ {t("groups.squad_handoffs")}
+ </Text>
+ <Text className="text-xs text-muted-foreground mt-0.5">
+ {t("groups.squad_handoffs_description")}
+ </Text>
+ </View>
+ <Switch
+ checked={
+ notificationPreferenceValue(preferences, "squad_handoffs") !== "muted"
+ }
+ onCheckedChange={(checked) => onToggle("squad_handoffs", checked)}
+ />
+ </View>
+ </>
+ )}
{!isLast ? <Separator /> : null}
</View>
);
diff --git a/apps/mobile/locales/en/settings.json b/apps/mobile/locales/en/settings.json
index 0cdc6f501e..45b619527a 100644
--- a/apps/mobile/locales/en/settings.json
+++ b/apps/mobile/locales/en/settings.json
@@ -71,6 +71,8 @@
"status_changes": "Status changes",
"comments": "Comments",
"comments_description": "New comments on issues you're subscribed to.",
+ "squad_handoffs": "Include squad handoffs",
+ "squad_handoffs_description": "Comments a squad's leader and agents pass work to each other with. @mentions of you, failed agent runs and statuses that need attention still arrive.",
"mentions": "Mentions",
"mentions_description": "When someone @mentions you, including @all and @squad.",
"reactions": "Reactions",
diff --git a/apps/mobile/locales/zh-Hans/settings.json b/apps/mobile/locales/zh-Hans/settings.json
index 0eee91b84f..ad36eb7d08 100644
--- a/apps/mobile/locales/zh-Hans/settings.json
+++ b/apps/mobile/locales/zh-Hans/settings.json
@@ -71,6 +71,8 @@
"status_changes": "状态变更",
"comments": "评论",
"comments_description": "你订阅的任务有新评论时。",
+ "squad_handoffs": "包含小队内部交接",
+ "squad_handoffs_description": "小队队长给成员派活、成员向队长回报的评论。@你、智能体运行失败和需要人工关注的状态照常通知。",
"mentions": "提及",
"mentions_description": "有人用 @ 提到你时,包括 @all 和 @squad。",
"reactions": "表情回应",
diff --git a/apps/mobile/locales/zh-Hant/settings.json b/apps/mobile/locales/zh-Hant/settings.json
index fb4ac3a1b8..0b636a9a76 100644
--- a/apps/mobile/locales/zh-Hant/settings.json
+++ b/apps/mobile/locales/zh-Hant/settings.json
@@ -71,6 +71,8 @@
"status_changes": "狀態變更",
"comments": "評論",
"comments_description": "你訂閱的任務有新評論時。",
+ "squad_handoffs": "包含小隊內部交接",
+ "squad_handoffs_description": "小隊隊長指派工作給成員、成員向隊長回報的評論。@ 提及、AI 代理執行失敗和需要關注的狀態照常通知。",
"mentions": "提及",
"mentions_description": "有人用 @ 提到你時,包括 @all 和 @squad。",
"reactions": "表情回應",
diff --git a/packages/core/notification-preferences/patch.ts b/packages/core/notification-preferences/patch.ts
index 09c3d4dd9f..332a4d1689 100644
--- a/packages/core/notification-preferences/patch.ts
+++ b/packages/core/notification-preferences/patch.ts
@@ -13,6 +13,7 @@ const PREFERENCE_DEFAULTS: { [K in PreferenceKey]-?: NonNullable<NotificationPre
assignments: "all",
status_changes: "muted",
comments: "all",
+ squad_handoffs: "all",
chat_replies: "all",
mentions: "all",
reactions: "all",
diff --git a/packages/core/types/notification-preference.ts b/packages/core/types/notification-preference.ts
index fbbc83574d..07a0b2010c 100644
--- a/packages/core/types/notification-preference.ts
+++ b/packages/core/types/notification-preference.ts
@@ -2,6 +2,7 @@ export type NotificationGroupKey =
| "assignments"
| "status_changes"
| "comments"
+ | "squad_handoffs"
| "chat_replies"
| "mentions"
| "reactions"
diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.json
index 88c5f6aa04..47f400303e 100644
--- a/packages/views/locales/en/settings.json
+++ b/packages/views/locales/en/settings.json
@@ -918,6 +918,10 @@
"label": "Comments",
"description": "New comments on issues you follow"
},
+ "squad_handoffs": {
+ "label": "Include squad handoffs",
+ "description": "Comments a squad's leader and agents pass work to each other with. @mentions of you, failed agent runs and statuses that need attention still arrive."
+ },
"mentions": {
"label": "Mentions",
"description": "When someone @mentions you, including @all and @squad"
diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.json
index c09278559e..fcf9a5a2a7 100644
--- a/packages/views/locales/es/settings.json
+++ b/packages/views/locales/es/settings.json
@@ -918,6 +918,10 @@
"label": "Comentarios",
"description": "Comentarios nuevos en tareas que sigues"
},
+ "squad_handoffs": {
+ "label": "Incluir traspasos del squad",
+ "description": "Comentarios con los que el líder y los agentes de un squad se pasan el trabajo. Las @menciones, las ejecuciones de agente fallidas y los estados que requieren atención te siguen llegando."
+ },
"mentions": {
"label": "Menciones",
"description": "Cuando alguien te @menciona, incluidos @all y @squad"
diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.json
index 5383a911a7..42f0559360 100644
--- a/packages/views/locales/fr/settings.json
+++ b/packages/views/locales/fr/settings.json
@@ -918,6 +918,10 @@
"label": "Commentaires",
"description": "Nouveaux commentaires sur les tâches que vous suivez"
},
+ "squad_handoffs": {
+ "label": "Inclure les passations de squad",
+ "description": "Commentaires par lesquels le chef et les agents d'un squad se transmettent le travail. Les @mentions, les exécutions d'agent échouées et les statuts qui nécessitent votre attention vous parviennent toujours."
+ },
"mentions": {
"label": "Mentions",
"description": "Quand quelqu'un vous @mentionne, y compris via @all et @squad"
diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.json
index 52b287740a..abf72ae19d 100644
--- a/packages/views/locales/ja/settings.json
+++ b/packages/views/locales/ja/settings.json
@@ -908,6 +908,10 @@
"label": "コメント",
"description": "フォロー中のタスクに新しいコメントが付いたとき"
},
+ "squad_handoffs": {
+ "label": "スクワッド内の引き継ぎを含める",
+ "description": "スクワッドのリーダーとエージェントが作業を受け渡すコメントです。@メンション、エージェントの実行失敗、確認が必要なステータスは引き続き通知されます。"
+ },
"mentions": {
"label": "メンション",
"description": "誰かがあなたを @メンションしたとき(@all と @squad を含む)"
diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.json
index 9617b3235a..5ce1158b1c 100644
--- a/packages/views/locales/ko/settings.json
+++ b/packages/views/locales/ko/settings.json
@@ -908,6 +908,10 @@
"label": "댓글",
"description": "팔로우 중인 태스크에 새 댓글이 달릴 때"
},
+ "squad_handoffs": {
+ "label": "스쿼드 내부 인계 포함",
+ "description": "스쿼드 리더와 에이전트가 서로 작업을 넘기는 댓글입니다. @멘션, 에이전트 실행 실패, 확인이 필요한 상태는 계속 알림이 옵니다."
+ },
"mentions": {
"label": "멘션",
"description": "누군가 나를 @멘션할 때(@all, @squad 포함)"
diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.json
index 32a7ed1d59..c6bc496ebd 100644
--- a/packages/views/locales/ru/settings.json
+++ b/packages/views/locales/ru/settings.json
@@ -950,6 +950,10 @@
"description": "Новые комментарии к задачам, на которые вы подписаны",
"label": "Комментарии"
},
+ "squad_handoffs": {
+ "label": "Включать передачи внутри команды",
+ "description": "Комментарии, которыми лидер и агенты команды передают друг другу работу. @упоминания, ошибки запусков агентов и статусы, требующие внимания, по-прежнему приходят."
+ },
"mentions": {
"description": "Когда вас упоминают через @, в том числе через @all и @squad",
"label": "Упоминания"
diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.json
index ad20bd0a6b..afa43ffa84 100644
--- a/packages/views/locales/zh-Hans/settings.json
+++ b/packages/views/locales/zh-Hans/settings.json
@@ -908,6 +908,10 @@
"label": "评论",
"description": "你订阅的任务有新评论时"
},
+ "squad_handoffs": {
+ "label": "包含小队内部交接",
+ "description": "小队队长给成员派活、成员向队长回报的评论。@你、智能体运行失败和需要人工关注的状态照常通知。"
+ },
"mentions": {
"label": "提及",
"description": "有人 @ 你时,包括 @all 和 @squad"
diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.json
index c55ae75927..04f2eb83d0 100644
--- a/packages/views/locales/zh-Hant/settings.json
+++ b/packages/views/locales/zh-Hant/settings.json
@@ -908,6 +908,10 @@
"label": "評論",
"description": "你訂閱的任務有新評論時"
},
+ "squad_handoffs": {
+ "label": "包含小隊內部交接",
+ "description": "小隊隊長指派工作給成員、成員向隊長回報的評論。@ 提及、AI 代理執行失敗和需要關注的狀態照常通知。"
+ },
"mentions": {
"label": "提及",
"description": "有人 @ 你時,包括 @all 和 @squad"
diff --git a/packages/views/settings/components/notifications-tab.test.tsx b/packages/views/settings/components/notifications-tab.test.tsx
index 446d79ab87..aa6dd0b5ba 100644
--- a/packages/views/settings/components/notifications-tab.test.tsx
+++ b/packages/views/settings/components/notifications-tab.test.tsx
@@ -67,6 +67,7 @@ describe("Inbox notification settings", () => {
"Other people's issues",
"Status changes",
"Comments",
+ "Include squad handoffs",
"Priority & due date",
"Projects you subscribe to",
"New issues",
@@ -89,6 +90,24 @@ describe("Inbox notification settings", () => {
expect(mutate).toHaveBeenCalledWith({ status_changes: "all" }, expect.anything());
});
+ it("keeps squad handoffs on under Comments until you turn them off", async () => {
+ const user = userEvent.setup();
+ renderTab();
+ const handoffs = within(screen.getByRole("region", { name: "Inbox" })).getByRole("switch", {
+ name: "Include squad handoffs",
+ });
+ expect(handoffs).toBeChecked();
+
+ await user.click(handoffs);
+ expect(mutate).toHaveBeenCalledWith({ squad_handoffs: "muted" }, expect.anything());
+ });
+
+ it("hides squad handoffs while comments are off", () => {
+ renderTab({ comments: "muted" });
+ const inbox = screen.getByRole("region", { name: "Inbox" });
+ expect(within(inbox).queryByRole("switch", { name: "Include squad handoffs" })).toBeNull();
+ });
+
it("shows status changes on once you turned them on", () => {
renderTab({ status_changes: "all" });
const inbox = screen.getByRole("region", { name: "Inbox" });
diff --git a/packages/views/settings/components/notifications-tab.tsx b/packages/views/settings/components/notifications-tab.tsx
index c13b0e0455..a3c515793e 100644
--- a/packages/views/settings/components/notifications-tab.tsx
+++ b/packages/views/settings/components/notifications-tab.tsx
@@ -198,20 +198,38 @@ export function NotificationsTab() {
</Select>
</SettingsRow>
)}
- {category.groups.map((key) => (
- <SettingsRow
- key={key}
- anchor={key}
- label={t(($) => $.notifications.groups[key].label)}
- description={t(($) => $.notifications.groups[key].description)}
- >
- <Switch
- checked={notificationPreferenceValue(preferences, key) !== "muted"}
- aria-label={t(($) => $.notifications.groups[key].label)}
- onCheckedChange={(checked) => handleToggle(key, checked)}
- />
- </SettingsRow>
- ))}
+ {category.groups.map((key) => {
+ const enabled = notificationPreferenceValue(preferences, key) !== "muted";
+ return (
+ <Fragment key={key}>
+ <SettingsRow
+ anchor={key}
+ label={t(($) => $.notifications.groups[key].label)}
+ description={t(($) => $.notifications.groups[key].description)}
+ >
+ <Switch
+ checked={enabled}
+ aria-label={t(($) => $.notifications.groups[key].label)}
+ onCheckedChange={(checked) => handleToggle(key, checked)}
+ />
+ </SettingsRow>
+ {key === "comments" && enabled && (
+ <SettingsRow
+ anchor="squad_handoffs"
+ className="pl-8"
+ label={t(($) => $.notifications.groups.squad_handoffs.label)}
+ description={t(($) => $.notifications.groups.squad_handoffs.description)}
+ >
+ <Switch
+ checked={notificationPreferenceValue(preferences, "squad_handoffs") !== "muted"}
+ aria-label={t(($) => $.notifications.groups.squad_handoffs.label)}
+ onCheckedChange={(checked) => handleToggle("squad_handoffs", checked)}
+ />
+ </SettingsRow>
+ )}
+ </Fragment>
+ );
+ })}
</Fragment>
))}
</SettingsCard>
diff --git a/packages/views/settings/components/settings-page.test.tsx b/packages/views/settings/components/settings-page.test.tsx
index 877897e92e..0e4210756f 100644
--- a/packages/views/settings/components/settings-page.test.tsx
+++ b/packages/views/settings/components/settings-page.test.tsx
@@ -61,6 +61,11 @@ vi.mock("./keyboard-shortcuts-tab", stub("KeyboardShortcutsTab"));
vi.mock("./plugins-tab", stub("PluginsTab"));
vi.mock("./mcp-tab", stub("McpTab"));
vi.mock("./billing-tab", stub("BillingTab"));
+// The search index reads cached notification preferences; the shell has none.
+vi.mock("@tanstack/react-query", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@tanstack/react-query")>()),
+ useQuery: () => ({ data: undefined }),
+}));
const shell = vi.hoisted(() => ({
appsAvailable: false,
diff --git a/packages/views/settings/components/use-settings-search-index.test.tsx b/packages/views/settings/components/use-settings-search-index.test.tsx
new file mode 100644
index 0000000000..6c461dee3d
--- /dev/null
+++ b/packages/views/settings/components/use-settings-search-index.test.tsx
@@ -0,0 +1,46 @@
+import type { ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import { renderHook } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { I18nProvider } from "@multica/core/i18n/react";
+import { notificationPreferenceKeys } from "@multica/core/notification-preferences/queries";
+import enSettings from "../../locales/en/settings.json";
+import { useSettingsSearchIndex } from "./use-settings-search-index";
+
+vi.mock("@multica/core/paths", () => ({
+ useCurrentWorkspace: () => ({ id: "ws-a", name: "Acme" }),
+}));
+
+function squadHandoffsAnchor(preferences?: Record<string, string>) {
+ const qc = new QueryClient();
+ if (preferences) {
+ qc.setQueryData(notificationPreferenceKeys.all("ws-a"), {
+ workspace_id: "ws-a",
+ preferences,
+ auto_archive_prompt: false,
+ });
+ }
+ const wrapper = ({ children }: { children: ReactNode }) => (
+ <QueryClientProvider client={qc}>
+ <I18nProvider locale="en" resources={{ en: { settings: enSettings } }}>
+ {children}
+ </I18nProvider>
+ </QueryClientProvider>
+ );
+ const { result } = renderHook(
+ () => useSettingsSearchIndex([{ value: "notifications", label: "Notifications" }]),
+ { wrapper },
+ );
+ return result.current.find((entry) => entry.title === "Include squad handoffs")?.anchor;
+}
+
+describe("squad handoffs in settings search", () => {
+ it("lands on its own row while comments are on", () => {
+ expect(squadHandoffsAnchor({})).toBe("squad_handoffs");
+ expect(squadHandoffsAnchor()).toBe("squad_handoffs");
+ });
+
+ it("lands on Comments while the row is hidden", () => {
+ expect(squadHandoffsAnchor({ comments: "muted" })).toBe("comments");
+ });
+});
diff --git a/packages/views/settings/components/use-settings-search-index.ts b/packages/views/settings/components/use-settings-search-index.ts
index d679715b92..c263bf8e4e 100644
--- a/packages/views/settings/components/use-settings-search-index.ts
+++ b/packages/views/settings/components/use-settings-search-index.ts
@@ -1,6 +1,10 @@
"use client";
import { useMemo } from "react";
+import { useQuery } from "@tanstack/react-query";
+import { useCurrentWorkspace } from "@multica/core/paths";
+import { notificationPreferenceOptions } from "@multica/core/notification-preferences/queries";
+import { notificationPreferenceValue } from "@multica/core/notification-preferences/patch";
import { useT } from "../../i18n";
import type { SettingsSearchEntry } from "./settings-search";
import { CHANNEL_INTEGRATIONS } from "./settings-navigation";
@@ -35,6 +39,14 @@ export function useSettingsSearchIndex(
pages: readonly SettingsSearchPage[],
): SettingsSearchIndexEntry[] {
const { t } = useT("settings");
+ const workspace = useCurrentWorkspace();
+ // Reads what the Notifications tab loaded; never fetches on its own.
+ const { data: notificationPreferences } = useQuery({
+ ...notificationPreferenceOptions(workspace?.id ?? ""),
+ enabled: false,
+ });
+ const commentsOn =
+ notificationPreferenceValue(notificationPreferences?.preferences ?? {}, "comments") !== "muted";
return useMemo(() => {
const visible = new Set(pages.map((page) => page.value));
const rows: SettingsSearchIndexEntry[] = [
@@ -182,6 +194,13 @@ export function useSettingsSearchIndex(
title: t(($) => $.notifications.groups[group].label),
description: t(($) => $.notifications.groups[group].description),
})),
+ // The row is hidden while comments are off; Comments is the closest spot.
+ {
+ tab: "notifications",
+ anchor: commentsOn ? "squad_handoffs" : "comments",
+ title: t(($) => $.notifications.groups.squad_handoffs.label),
+ description: t(($) => $.notifications.groups.squad_handoffs.description),
+ },
{
tab: "notifications",
anchor: "others_issues",
@@ -393,5 +412,5 @@ export function useSettingsSearchIndex(
...pageEntries,
...rows.filter((row) => row.anchor || row.integration),
].filter((entry) => visible.has(entry.tab));
- }, [pages, t]);
+ }, [pages, t, commentsOn]);
}
diff --git a/server/cmd/server/notification_listeners.go b/server/cmd/server/notification_listeners.go
index 7418f47993..465c65209a 100644
--- a/server/cmd/server/notification_listeners.go
+++ b/server/cmd/server/notification_listeners.go
@@ -1183,17 +1183,23 @@ 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.
+ mentions := parseMentions(commentContent)
mentioned := map[string]bool{}
- if mentions := parseMentions(commentContent); len(mentions) > 0 {
+ if len(mentions) > 0 {
skip := map[string]bool{e.ActorID: true}
mentioned = notifyMentionedMembers(bus, queries, e, mentions, issueID, issueTitle, issueStatus,
issueTitle, commentContent, skip, commentDetails)
}
+ newCommentDetails := commentDetails
+ if authorType == "agent" && isSquadHandoff(ctx, queries, e.WorkspaceID, commentID, mentions) {
+ newCommentDetails = withDetail(commentDetails, inbox.SquadHandoffDetail, "true")
+ }
+
notifySubscribers(ctx, queries, bus, issueID, issueStatus, e.WorkspaceID, e,
mentioned, "new_comment", "info",
issueTitle, commentContent,
- commentDetails)
+ newCommentDetails)
// A quick action posts its prompt as the member's own comment, so
// running one counts the same as replying.
diff --git a/server/cmd/server/notification_squad_handoff.go b/server/cmd/server/notification_squad_handoff.go
new file mode 100644
index 0000000000..5670d6deb4
--- /dev/null
+++ b/server/cmd/server/notification_squad_handoff.go
@@ -0,0 +1,93 @@
+package main
+
+import (
+ "context"
+
+ db "github.com/multica-ai/multica/server/pkg/db/generated"
+)
+
+// isSquadHandoff reports whether a comment is one agent of the squad its issue
+// is assigned to handing work to another (MUL-10008): the leader dispatching
+// with an @agent or @squad mention, or a worker reporting back. A member's
+// inbox drops these rows when they mute inbox.SquadHandoffsPref.
+//
+// A worker is a roster agent of the squad, or any agent whose run the squad's
+// leader dispatched (delegated_from_task_id points at a leader task of this
+// squad), since a leader can pull in agents from outside the roster. A run a
+// person started directly answers that person, so its comment is not a
+// handoff even when the agent is on the roster.
+//
+// A comment that mentions a member or @all is addressed to people and is never
+// a handoff, whatever else it mentions.
+//
+// FAIL OPEN: every read that fails answers false, so the comment is delivered.
+// A spare inbox row costs a dismissal; a dropped one can strand a reply.
+func isSquadHandoff(ctx context.Context, queries *db.Queries, workspaceID, commentID string, mentions []mention) bool {
+ if commentID == "" {
+ return false
+ }
+ addressesAgent := false
+ for _, m := range mentions {
+ switch m.Type {
+ case "member", "all":
+ return false
+ case "agent", "squad":
+ addressesAgent = true
+ }
+ }
+
+ wsID := parseUUID(workspaceID)
+ comment, err := queries.GetCommentInWorkspace(ctx, db.GetCommentInWorkspaceParams{
+ ID: parseUUID(commentID),
+ WorkspaceID: wsID,
+ })
+ if err != nil || comment.AuthorType != "agent" || !comment.AuthorID.Valid {
+ return false
+ }
+ issue, err := queries.GetIssue(ctx, comment.IssueID)
+ if err != nil || !issue.AssigneeID.Valid || issue.AssigneeType.String != "squad" {
+ return false
+ }
+ squad, err := queries.GetSquadInWorkspace(ctx, db.GetSquadInWorkspaceParams{
+ ID: issue.AssigneeID,
+ WorkspaceID: wsID,
+ })
+ if err != nil || squad.ArchivedAt.Valid {
+ return false
+ }
+
+ if comment.AuthorID == squad.LeaderID {
+ return addressesAgent
+ }
+
+ if comment.SourceTaskID.Valid {
+ task, err := queries.GetAgentTask(ctx, comment.SourceTaskID)
+ if err != nil {
+ return false
+ }
+ if task.AgentID == comment.AuthorID {
+ if task.DelegatedFromTaskID.Valid {
+ source, err := queries.GetAgentTask(ctx, task.DelegatedFromTaskID)
+ if err == nil && source.IsLeaderTask && source.SquadID == squad.ID {
+ return true
+ }
+ }
+ if task.TriggerCommentID.Valid {
+ trigger, err := queries.GetCommentInWorkspace(ctx, db.GetCommentInWorkspaceParams{
+ ID: task.TriggerCommentID,
+ WorkspaceID: wsID,
+ })
+ if err != nil || trigger.AuthorType == "member" {
+ return false
+ }
+ }
+ }
+ }
+
+ onRoster, err := queries.IsSquadMember(ctx, db.IsSquadMemberParams{
+ SquadID: squad.ID,
+ MemberType: "agent",
+ MemberID: comment.AuthorID,
+ })
+ return err == nil && onRoster
+}
diff --git a/server/cmd/server/notification_squad_handoff_test.go b/server/cmd/server/notification_squad_handoff_test.go
new file mode 100644
index 0000000000..da50472136
--- /dev/null
+++ b/server/cmd/server/notification_squad_handoff_test.go
@@ -0,0 +1,167 @@
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "testing"
+
+ "github.com/multica-ai/multica/server/internal/events"
+ "github.com/multica-ai/multica/server/internal/handler"
+ "github.com/multica-ai/multica/server/internal/inbox"
+ "github.com/multica-ai/multica/server/internal/testutil"
+ db "github.com/multica-ai/multica/server/pkg/db/generated"
+ "github.com/multica-ai/multica/server/pkg/protocol"
+)
+
+type squadHandoffFixture struct {
+ f *testutil.Fixture
+ runtimeID string
+ squadID string
+ leaderID string
+ workerID string // on the squad's roster
+ outsideID string // not on the roster
+}
+
+func newSquadHandoffFixture(t *testing.T) squadHandoffFixture {
+ t.Helper()
+ f := workspaceFixture(t)
+ runtimeID := f.Runtime(t, "squad-handoff-runtime")
+ leaderID := f.Agent(t, "squad-handoff-leader", runtimeID)
+ workerID := f.Agent(t, "squad-handoff-worker", runtimeID)
+ outsideID := f.Agent(t, "squad-handoff-outside", runtimeID)
+ squadID := f.Squad(t, "squad-handoff", leaderID)
+ f.SquadMember(t, squadID, "agent", leaderID)
+ f.SquadMember(t, squadID, "agent", workerID)
+ return squadHandoffFixture{f: f, runtimeID: runtimeID, squadID: squadID,
+ leaderID: leaderID, workerID: workerID, outsideID: outsideID}
+}
+
+func agentMention(id string) string { return fmt.Sprintf("[@A](mention://agent/%s)", id) }
+func memberMention(id string) string { return fmt.Sprintf("[@M](mention://member/%s)", id) }
+
+// TestNotification_SquadHandoffs drives the comment:created listener with one
+// comment per case, each on its own issue, and checks who gets the
+// new_comment row: a member who muted squad_handoffs and one on the default
+// (MUL-10008).
+func TestNotification_SquadHandoffs(t *testing.T) {
+ queries := db.New(testPool)
+ bus := newNotificationBus(t, queries)
+ fx := newSquadHandoffFixture(t)
+
+ mutedEmail := "[email protected]"
+ mutedID := createNotificationMember(t, mutedEmail)
+ t.Cleanup(func() { cleanupTestUser(t, mutedEmail) })
+ setNotificationPref(t, mutedID, inbox.SquadHandoffsPref, "muted")
+
+ defaultEmail := "[email protected]"
+ defaultID := createNotificationMember(t, defaultEmail)
+ t.Cleanup(func() { cleanupTestUser(t, defaultEmail) })
+
+ leaderTask := fx.f.Task(t, fx.leaderID, testutil.Cols{
+ "runtime_id": fx.runtimeID, "is_leader_task": true, "squad_id": fx.squadID,
+ })
+
+ cases := []struct {
+ name string
+ assignee string // "squad" or "agent"
+ author string
+ content string
+ // task returns the authoring task of the comment, or "" for none.
+ task func(t *testing.T, issueID string) string
+ handoff bool
+ }{
+ {name: "leader dispatching to a worker", author: fx.leaderID,
+ content: agentMention(fx.workerID) + " take phase 1", handoff: true},
+ {name: "leader without a mention", author: fx.leaderID,
+ content: "PR merged.", handoff: false},
+ {name: "leader asking a person while dispatching", author: fx.leaderID,
+ content: memberMention(testUserID) + " " + agentMention(fx.workerID) + " please decide", handoff: false},
+ {name: "roster worker reporting", author: fx.workerID,
+ content: "Done, PR is up.", handoff: true},
+ {name: "outside agent the leader dispatched", author: fx.outsideID,
+ content: "Deployed.", handoff: true,
+ task: func(t *testing.T, issueID string) string {
+ return fx.f.Task(t, fx.outsideID, testutil.Cols{
+ "runtime_id": fx.runtimeID, "issue_id": issueID, "delegated_from_task_id": leaderTask,
+ })
+ }},
+ {name: "outside agent nobody dispatched", author: fx.outsideID,
+ content: "Drive-by note.", handoff: false},
+ {name: "roster worker answering a person", author: fx.workerID,
+ content: "Here is the answer.", handoff: false,
+ task: func(t *testing.T, issueID string) string {
+ ask := fx.f.Comment(t, issueID, "can you check this?")
+ return fx.f.Task(t, fx.workerID, testutil.Cols{
+ "runtime_id": fx.runtimeID, "issue_id": issueID, "trigger_comment_id": ask,
+ })
+ }},
+ {name: "roster worker on an issue not assigned to the squad", assignee: "agent", author: fx.workerID,
+ content: "Done.", handoff: false},
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ assigneeType, assigneeID := "squad", fx.squadID
+ if tc.assignee == "agent" {
+ assigneeType, assigneeID = "agent", fx.leaderID
+ }
+ issueID := fx.f.Issue(t, "squad handoff: "+tc.name, testutil.Cols{
+ "assignee_type": assigneeType, "assignee_id": assigneeID,
+ })
+ t.Cleanup(func() { cleanupInboxForIssue(t, issueID) })
+ addTestSubscriber(t, issueID, "member", mutedID, "manual")
+ addTestSubscriber(t, issueID, "member", defaultID, "manual")
+
+ commentCols := testutil.Cols{"author_type": "agent", "author_id": tc.author}
+ if tc.task != nil {
+ commentCols["source_task_id"] = tc.task(t, issueID)
+ }
+ commentID := fx.f.Comment(t, issueID, tc.content, commentCols)
+
+ bus.Publish(events.Event{
+ Type: protocol.EventCommentCreated,
+ WorkspaceID: testWorkspaceID,
+ ActorType: "agent",
+ ActorID: tc.author,
+ Payload: map[string]any{
+ "comment": handler.CommentResponse{
+ ID: commentID, IssueID: issueID, AuthorType: "agent",
+ AuthorID: tc.author, Content: tc.content, Type: "comment",
+ },
+ "issue_title": "squad handoff",
+ "issue_status": "in_progress",
+ },
+ })
+
+ defaultRow := newCommentRow(t, defaultID, issueID)
+ if defaultRow == nil {
+ t.Fatalf("member on the default got no new_comment row")
+ }
+ var details map[string]string
+ if err := json.Unmarshal(defaultRow.Details, &details); err != nil {
+ t.Fatalf("details must stay a string map for clients: %v (%s)", err, defaultRow.Details)
+ }
+ if marked := details[inbox.SquadHandoffDetail] == "true"; marked != tc.handoff {
+ t.Fatalf("squad_handoff marked %v, want %v (details %s)", marked, tc.handoff, defaultRow.Details)
+ }
+ if got := newCommentRow(t, mutedID, issueID) != nil; got == tc.handoff {
+ t.Fatalf("member who muted squad handoffs got a row: %v, want %v", got, !tc.handoff)
+ }
+ })
+ }
+}
+
+// newCommentRow is the recipient's new_comment row on issueID, or nil.
+func newCommentRow(t *testing.T, recipientID, issueID string) *db.InboxItem {
+ t.Helper()
+ var item db.InboxItem
+ err := testPool.QueryRow(context.Background(), `
+ SELECT id, details FROM inbox_item
+ WHERE recipient_type = 'member' AND recipient_id = $1 AND issue_id = $2 AND type = 'new_comment'
+ `, recipientID, issueID).Scan(&item.ID, &item.Details)
+ if err != nil {
+ return nil
+ }
+ return &item
+}
diff --git a/server/internal/handler/notification_preference.go b/server/internal/handler/notification_preference.go
index 4b6f4289a5..c2d6b5a476 100644
--- a/server/internal/handler/notification_preference.go
+++ b/server/internal/handler/notification_preference.go
@@ -23,12 +23,15 @@ import (
// says whether one action you take on an issue archives your notifications on
// it. Completing and triggering an agent archive unless "muted"; commenting,
// status changes, reassigning, priority, project, date and label edits archive
-// only with "all". `after_auto_archive` is a legacy preference kept accepted
-// for older clients; current clients always stay on an auto-archived issue.
+// only with "all". `squad_handoffs` narrows `comments` to leave out the
+// comments a squad's agents hand work to each other with (MUL-10008).
+// `after_auto_archive` is a legacy preference kept accepted for older
+// clients; current clients always stay on an auto-archived issue.
var validNotifGroups = map[string]bool{
"assignments": true,
"status_changes": true,
"comments": true,
+ "squad_handoffs": true,
"chat_replies": true,
"mentions": true,
"reactions": true,
diff --git a/server/internal/handler/notification_preference_test.go b/server/internal/handler/notification_preference_test.go
index 1d2c35bfee..7b91902b19 100644
--- a/server/internal/handler/notification_preference_test.go
+++ b/server/internal/handler/notification_preference_test.go
@@ -74,8 +74,9 @@ func TestPatchNotificationPreferencesMergesWithoutReplacing(t *testing.T) {
testHandler.PatchNotificationPreferences(
patchRecorder,
notificationPreferenceRequest(t, http.MethodPatch, map[string]string{
- "comments": "muted",
- "chat_replies": "muted",
+ "comments": "muted",
+ "chat_replies": "muted",
+ "squad_handoffs": "muted",
}),
)
if patchRecorder.Code != http.StatusOK {
@@ -101,6 +102,9 @@ func TestPatchNotificationPreferencesMergesWithoutReplacing(t *testing.T) {
if response.Preferences["chat_replies"] != "muted" {
t.Fatalf("chat_replies patch missing: %#v", response.Preferences)
}
+ if response.Preferences["squad_handoffs"] != "muted" {
+ t.Fatalf("squad_handoffs patch missing: %#v", response.Preferences)
+ }
enableRecorder := httptest.NewRecorder()
testHandler.PatchNotificationPreferences(
diff --git a/server/internal/inbox/deliver.go b/server/internal/inbox/deliver.go
index 0dacf978c6..a9373cc34b 100644
--- a/server/internal/inbox/deliver.go
+++ b/server/internal/inbox/deliver.go
@@ -50,7 +50,9 @@ func Deliver(ctx context.Context, queries *db.Queries, pub Publisher, n Notifica
if prefs == nil {
prefs = LoadPreferences(ctx, queries, n.Params.WorkspaceID, []pgtype.UUID{n.Params.RecipientID})
}
- if Muted(prefs[util.UUIDToString(n.Params.RecipientID)], n.Params.Type) {
+ recipientPrefs := prefs[util.UUIDToString(n.Params.RecipientID)]
+ if Muted(recipientPrefs, n.Params.Type) ||
+ MutedSquadHandoff(recipientPrefs, n.Params.Type, n.Params.Details) {
return db.InboxItem{}, false, nil
}
}
diff --git a/server/internal/inbox/registry.go b/server/internal/inbox/registry.go
index bf9f1e3563..7536c17cb6 100644
--- a/server/internal/inbox/registry.go
+++ b/server/internal/inbox/registry.go
@@ -117,6 +117,29 @@ func WithLegacyDefaults(prefs map[string]string) map[string]string {
return result
}
+// SquadHandoffsPref narrows the comments group: "muted" drops the new_comment
+// rows the comment listener marked with SquadHandoffDetail, the agents of an
+// issue's squad handing work to each other (MUL-10008). Absent means "all".
+const SquadHandoffsPref = "squad_handoffs"
+
+// SquadHandoffDetail is the new_comment details key, set to "true", that
+// marks a squad handoff. Details values stay strings: clients parse them as
+// a string map and reject the whole Inbox list otherwise.
+const SquadHandoffDetail = "squad_handoff"
+
+// MutedSquadHandoff reports whether a member's parsed preferences drop this
+// new_comment row as a squad handoff.
+func MutedSquadHandoff(prefs map[string]string, notifType string, details []byte) bool {
+ if notifType != "new_comment" || prefs[SquadHandoffsPref] != "muted" || len(details) == 0 {
+ return false
+ }
+ var d map[string]any
+ if err := json.Unmarshal(details, &d); err != nil {
+ return false
+ }
+ return d[SquadHandoffDetail] == "true"
+}
+
// Muted reports whether a member's parsed preferences mute notifType. nil
// prefs, a member without a stored row, applies every group's default.
func Muted(prefs map[string]string, notifType string) bool {
diff --git a/server/internal/inbox/registry_test.go b/server/internal/inbox/registry_test.go
index a957565394..d192f9d9c8 100644
--- a/server/internal/inbox/registry_test.go
+++ b/server/internal/inbox/registry_test.go
@@ -287,3 +287,32 @@ func frontendTypeMismatches(frontend []string) []string {
}
return problems
}
+
+// TestMutedSquadHandoff pins that squad_handoffs only ever drops a marked
+// new_comment row, and only for a member who muted it (MUL-10008).
+func TestMutedSquadHandoff(t *testing.T) {
+ marked := []byte(`{"comment_id":"c","squad_handoff":"true"}`)
+ plain := []byte(`{"comment_id":"c"}`)
+ muted := map[string]string{SquadHandoffsPref: "muted"}
+ cases := []struct {
+ name string
+ prefs map[string]string
+ notifType string
+ details []byte
+ want bool
+ }{
+ {"muted drops a marked comment", muted, "new_comment", marked, true},
+ {"muted keeps an unmarked comment", muted, "new_comment", plain, false},
+ {"muted keeps a marked mention", muted, "mentioned", marked, false},
+ {"default keeps a marked comment", map[string]string{}, "new_comment", marked, false},
+ {"explicit all keeps a marked comment", map[string]string{SquadHandoffsPref: "all"}, "new_comment", marked, false},
+ {"unreadable details are delivered", muted, "new_comment", []byte(`not json`), false},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := MutedSquadHandoff(tc.prefs, tc.notifType, tc.details); got != tc.want {
+ t.Fatalf("MutedSquadHandoff = %v, want %v", got, tc.want)
+ }
+ })
+ }
+}