From c2c62fa893f339fc5234de7db24c3a40f40a399c Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Wed, 20 May 2026 23:36:13 -0700 Subject: [PATCH] fix: deselect team toggle when individual agents are unchecked --- .../channels/ui/QuickAddAgentPopover.tsx | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx b/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx index f8aae1b053..ed4cd3650c 100644 --- a/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx +++ b/desktop/src/features/channels/ui/QuickAddAgentPopover.tsx @@ -311,6 +311,34 @@ export function QuickAddAgentPopover({ } else { next.add(key); } + + // Deselect any team whose members are no longer all selected + setSelectedTeamIds((prevTeams) => { + const nextTeams = new Set(prevTeams); + for (const team of usableTeams) { + if (!nextTeams.has(team.id)) continue; + const resolution = resolveTeamPersonas(team, personas); + const allSelected = resolution.resolvedPersonas.every((persona) => { + const runningItem = items.find( + (i) => i.kind === "running-available" && i.agent.personaId === persona.id, + ); + const itemKey = runningItem + ? getItemKey(runningItem) + : (() => { + const personaItem = items.find( + (i) => i.kind === "persona" && i.persona.id === persona.id, + ); + return personaItem ? getItemKey(personaItem) : null; + })(); + return itemKey ? next.has(itemKey) : true; + }); + if (!allSelected) { + nextTeams.delete(team.id); + } + } + return nextTeams; + }); + return next; }); }