diff --git a/mobile/src/bots/use-mobile-bot-group-transcript.ts b/mobile/src/bots/use-mobile-bot-group-transcript.ts index 8e45d007d1b8..6e8acb1daaca 100644 --- a/mobile/src/bots/use-mobile-bot-group-transcript.ts +++ b/mobile/src/bots/use-mobile-bot-group-transcript.ts @@ -13,6 +13,7 @@ import { startHostBotRefresh } from './host-bot-refresh' import { botChangeBotIds, botChangeConcerns, + botGroupRoomConcerned, type BotChangeKind, type BotChangeScope } from '../../../src/shared/bots/bot-change-scope' @@ -139,7 +140,12 @@ export function useMobileBotGroupTranscript( if (counts) { setNeedsYou((last) => (sameCounts(last, counts) ? last : counts)) } - if (!botChangeConcerns(changed, { kinds: ROOM_KINDS })) { + // A groups change naming other rooms leaves this one as it is. + const room = + botChangeConcerns(changed, { kinds: ['bot'] }) || + (botChangeConcerns(changed, { kinds: ['groups'] }) && + botGroupRoomConcerned(changed, groupId)) + if (!room) { return } const current = ++request diff --git a/src/main/bots/bot-change-notices.ts b/src/main/bots/bot-change-notices.ts index b8adb9ae8137..5ed84135699b 100644 --- a/src/main/bots/bot-change-notices.ts +++ b/src/main/bots/bot-change-notices.ts @@ -100,8 +100,8 @@ export type BotPaneFacts = { botOfWorkspace: (worktreeId: string) => string | null /** The bot whose chat, worker or run a pane is. */ botOfPane: (paneKey: string) => string | null - /** Whether the pane is a member's in a bot group room. */ - inGroupRoom: (sessionId: string) => boolean + /** The bot group room whose member the pane is, by group id; null when it is none's. */ + groupRoomOf: (sessionId: string) => string | null /** A Dispatch's worker pane. */ workerPane: (paneKey: string) => boolean /** Reads the chats of bots never read yet; false when one can't be read, so a worker pane may be an @@ -137,8 +137,9 @@ export function botPhaseChangeScopes( } const tabId = parsePaneKey(change.paneKey)?.tabId const sessionId = tabId ? structuredAgentSessionIdOfTab(tabId) : null - if (sessionId && facts.inGroupRoom(sessionId)) { - scopes.push({ kinds: ['groups'] }) + const groupId = sessionId ? facts.groupRoomOf(sessionId) : null + if (groupId) { + scopes.push({ kinds: ['groups'], groupIds: [groupId] }) } return scopes } diff --git a/src/main/bots/bot-group-automation-run.ts b/src/main/bots/bot-group-automation-run.ts index 3141a789f96f..df9628927fe4 100644 --- a/src/main/bots/bot-group-automation-run.ts +++ b/src/main/bots/bot-group-automation-run.ts @@ -84,7 +84,7 @@ export async function sendBotGroupAutomationRun( return stored } ) - groups.changed() + groups.changed(message.groupId) const [turn] = message.turns const fingerprint = turn ? await deliverTurn(groups, message, turn, run) : undefined if (!turn || fingerprint === undefined) { diff --git a/src/main/bots/bot-group-dead-mail-turns.ts b/src/main/bots/bot-group-dead-mail-turns.ts index 72281c8bb3f7..9dcc5b7ce2b9 100644 --- a/src/main/bots/bot-group-dead-mail-turns.ts +++ b/src/main/bots/bot-group-dead-mail-turns.ts @@ -107,7 +107,7 @@ async function settle( : item ) }) - groups.changed() + groups.changed(current.groupId) return false } diff --git a/src/main/bots/bot-group-delivery.ts b/src/main/bots/bot-group-delivery.ts index 73e0d05a64e1..12416eb300c5 100644 --- a/src/main/bots/bot-group-delivery.ts +++ b/src/main/bots/bot-group-delivery.ts @@ -125,7 +125,7 @@ export async function sendBotGroupMessage( }) // Marks its asks in flight before any reader can see the post. void deliverRemoteAsks(groups, message, remoteBodies) - groups.changed() + groups.changed(message.groupId) for (const turn of message.turns) { void deliverTurn(groups, message, turn) } @@ -166,7 +166,7 @@ export function assertGroupQueuedMessageAllowed( assertTurnActive(groups, message, turn) } catch (error) { recordTurnError(groups, message.id, operationId, error) - groups.changed() + groups.changed(message.groupId) throw error } } @@ -273,7 +273,7 @@ export async function deliverTurn( } finally { groups.store.delivered([turn.operationId]) groups.deliveries.delete(turn.operationId) - groups.changed() + groups.changed(message.groupId) } } diff --git a/src/main/bots/bot-group-latest.ts b/src/main/bots/bot-group-latest.ts index 855bfaf47767..9219381dae77 100644 --- a/src/main/bots/bot-group-latest.ts +++ b/src/main/bots/bot-group-latest.ts @@ -65,7 +65,7 @@ export async function noteBotGroupMemberReply( { after, reply } ) if (kept) { - groups.changed() + groups.changed(owner.group.id) } await handOffGroupMentions(groups, message, turn, { full: finished.full, saved: finished.text }) } diff --git a/src/main/bots/bot-group-mention-handoffs.ts b/src/main/bots/bot-group-mention-handoffs.ts index 573af59610cc..ac0859628de1 100644 --- a/src/main/bots/bot-group-mention-handoffs.ts +++ b/src/main/bots/bot-group-mention-handoffs.ts @@ -142,7 +142,7 @@ export async function handOffGroupMentions( ) } }) - groups.changed() + groups.changed(groupId) return stored }) for (const line of woken) { diff --git a/src/main/bots/bot-group-peer-answer.ts b/src/main/bots/bot-group-peer-answer.ts index 9f72c78e3856..6277d2ce5dd7 100644 --- a/src/main/bots/bot-group-peer-answer.ts +++ b/src/main/bots/bot-group-peer-answer.ts @@ -31,5 +31,5 @@ export function saveGroupPeerAnswer( : turn ) }) - groups.changed() + groups.changed(message.groupId) } diff --git a/src/main/bots/bot-group-peer-requests.ts b/src/main/bots/bot-group-peer-requests.ts index fef41462be3b..0d29016bb852 100644 --- a/src/main/bots/bot-group-peer-requests.ts +++ b/src/main/bots/bot-group-peer-requests.ts @@ -176,7 +176,7 @@ export function reserveGroupMailTurn( } if (line) { groups.store.retarget(id, input.operationId) - groups.changed() + groups.changed(group.id) return } const bot = groups.runtime.bots.list().find((bot) => bot.id === member.botId) @@ -232,7 +232,7 @@ export function reserveGroupMailTurn( } ] }) - groups.changed() + groups.changed(group.id) } /** The group operation a member is running now (as it starts a worker or answers a peer), read diff --git a/src/main/bots/bot-group-remote-answers.ts b/src/main/bots/bot-group-remote-answers.ts index 14679a65cd58..744f5a215c5a 100644 --- a/src/main/bots/bot-group-remote-answers.ts +++ b/src/main/bots/bot-group-remote-answers.ts @@ -194,7 +194,7 @@ export function remoteRoomMailArrived(groups: BotGroupRuntime, groupId: string): .prepare('SELECT id, thread_id FROM messages WHERE to_handle = ? AND read = 0') .all(botGroupRoomMailAddress(groupId)) if (rows.length === 0) { - groups.changed() + groups.changed(groupId) return } if (!db.db.prepare('SELECT 1 FROM bot_groups WHERE id = ?').get(groupId)) { @@ -231,7 +231,7 @@ export function remoteRoomMailArrived(groups: BotGroupRuntime, groupId: string): } catch (error) { console.warn('[bot-groups] could not read a remote member answer', error) } - groups.changed() + groups.changed(groupId) } /** At startup: settle room mail that arrived while this build wasn't running, as if it had just diff --git a/src/main/bots/bot-group-remote.ts b/src/main/bots/bot-group-remote.ts index 4837560be204..eb690b8ffee1 100644 --- a/src/main/bots/bot-group-remote.ts +++ b/src/main/bots/bot-group-remote.ts @@ -252,7 +252,7 @@ export async function deliverRemoteAsks( for (const ask of asks) { sending.delete(ask.requestId) } - groups.changed() + groups.changed(message.groupId) } } diff --git a/src/main/bots/bot-group-runtime.ts b/src/main/bots/bot-group-runtime.ts index e661ad02fc21..c6c8b40926d8 100644 --- a/src/main/bots/bot-group-runtime.ts +++ b/src/main/bots/bot-group-runtime.ts @@ -146,8 +146,9 @@ export class BotGroupRuntime { this.store = new BotGroupStore(runtime.getOrchestrationDb().db) } - changed(): void { - this.runtime.notifyBotGroupsChanged() + /** Readers re-read; open rooms of `groupId` only, when it is given (a change inside one room). */ + changed(groupId?: string): void { + this.runtime.notifyBotGroupsChanged(groupId === undefined ? undefined : [groupId]) } create = (input: z.infer) => createBotGroup(this, input) diff --git a/src/main/bots/bot-group-stop.ts b/src/main/bots/bot-group-stop.ts index 21c27716f016..e271558ae16d 100644 --- a/src/main/bots/bot-group-stop.ts +++ b/src/main/bots/bot-group-stop.ts @@ -45,7 +45,7 @@ export function stopBotGroup( } : { members }) }) - groups.changed() + groups.changed(group.id) const host = await requireStructuredHost(groups.runtime) return Promise.all( previous.members.filter(stopping).map(({ sessionId }) => diff --git a/src/main/runtime/construction/orca-runtime-agent-transitions.ts b/src/main/runtime/construction/orca-runtime-agent-transitions.ts index 1a3d4ea8008c..12a2042f0861 100644 --- a/src/main/runtime/construction/orca-runtime-agent-transitions.ts +++ b/src/main/runtime/construction/orca-runtime-agent-transitions.ts @@ -225,7 +225,7 @@ export abstract class OrcaRuntimeWithAgentTransitions extends OrcaRuntimeWithTer const dispatchId = this.getAgentStatusOrchestrationContextForPaneKey(paneKey)?.dispatchId return dispatchId ? (index?.botOfDispatch(dispatchId) ?? null) : null }, - inGroupRoom: (sessionId) => this.botSessions.groupRoomOf(sessionId) !== null, + groupRoomOf: (sessionId) => this.botSessions.groupRoomOf(sessionId)?.group.id ?? null, workerPane: (paneKey) => this.getAgentStatusOrchestrationContextForPaneKey(paneKey) !== undefined, readEveryBot: () => this.botChatTreeIndex?.readEveryBot() !== false diff --git a/src/main/runtime/orca-runtime-bots.ts b/src/main/runtime/orca-runtime-bots.ts index b0426c68deee..fda6da5e0e11 100644 --- a/src/main/runtime/orca-runtime-bots.ts +++ b/src/main/runtime/orca-runtime-bots.ts @@ -353,9 +353,10 @@ export abstract class OrcaRuntimeWithBots extends OrcaRuntimeWithLinearCommands this.botChangeNotices.changed({ kinds: ['access'] }) } - /** A group's room, members or latest message changed; windows and phones re-read the groups. */ - notifyBotGroupsChanged(): void { - this.botChangeNotices.changed({ kinds: ['groups'] }) + /** A group's room, members or latest message changed; windows and phones re-read the groups, and + * open rooms of `groupIds` (every room when absent) re-read their page. */ + notifyBotGroupsChanged(groupIds?: readonly string[]): void { + this.botChangeNotices.changed({ kinds: ['groups'], ...(groupIds ? { groupIds } : {}) }) } /** A paired server's worker verdicts changed: their bots re-read (all, if a bot can't be read). */ diff --git a/src/renderer/src/components/bots/use-bot-group-transcript.ts b/src/renderer/src/components/bots/use-bot-group-transcript.ts index f02b1e8010e7..58fab21f51ca 100644 --- a/src/renderer/src/components/bots/use-bot-group-transcript.ts +++ b/src/renderer/src/components/bots/use-bot-group-transcript.ts @@ -2,6 +2,7 @@ import { useEffect, useReducer } from 'react' import { onBotsChanged } from '@/lib/bots-changed-window-event' import type { BotRef } from '@/lib/bot-hosts' import { callBotGroupRpc } from '@/lib/bot-group-rpc' +import { botGroupRoomConcerned } from '../../../../shared/bots/bot-change-scope' import { reduceBotGroupTranscript, type BotGroupTranscript @@ -19,7 +20,8 @@ function readPage( }) } -/** The room's transcript while visible: re-read on every host bots change, older pages on request. +/** The room's transcript while visible: re-read on each host groups change that names this room (or + * names none), older pages on request. * A thread's room is read when `threadId` is set. */ export function useBotGroupTranscript( group: BotRef | undefined, @@ -49,7 +51,15 @@ export function useBotGroupTranscript( .catch((error: unknown) => !closed && setError(String(error))) } read() - const stopListening = onBotsChanged(read, hostId, { kinds: ['groups'] }) + const stopListening = onBotsChanged( + (_host, scope) => { + if (botGroupRoomConcerned(scope, groupId)) { + read() + } + }, + hostId, + { kinds: ['groups'] } + ) return () => { closed = true stopListening() diff --git a/src/renderer/src/lib/bots-changed-window-event.performance.test.ts b/src/renderer/src/lib/bots-changed-window-event.performance.test.ts new file mode 100644 index 000000000000..500817646b4d --- /dev/null +++ b/src/renderer/src/lib/bots-changed-window-event.performance.test.ts @@ -0,0 +1,48 @@ +// @vitest-environment happy-dom +import { afterEach, expect, it } from 'vitest' +import { emitBotsChangedWindowEvent, onBotsChanged } from './bots-changed-window-event' +import { + botGroupRoomConcerned, + readBotChangeScope, + type BotChangeScope +} from '../../../shared/bots/bot-change-scope' + +// A room-scoped groups notice (#47523) reaches every bot view in the window. Guards that the notice is +// read once and shared, not copied per listener, and that only the named rooms' views re-read. + +const stops: (() => void)[] = [] +afterEach(() => stops.splice(0).forEach((stop) => stop())) + +function dispatch(listeners: number, named: number) { + const scopes: (BotChangeScope | undefined)[] = [] + let reads = 0 + for (let index = 0; index < listeners; index += 1) { + stops.push( + onBotsChanged( + (_host, scope) => { + scopes.push(scope) + if (botGroupRoomConcerned(scope, `room-${index}`)) { + reads += 1 + } + }, + 'local', + { kinds: ['groups'] } + ) + ) + } + const groupIds = Array.from({ length: named }, (_, index) => `room-${index}`) + emitBotsChangedWindowEvent('local', { kinds: ['groups'], groupIds }) + return { scopes: new Set(scopes).size, heard: scopes.length, reads } +} + +it('reads a notice once for every listener and re-reads only the rooms it names', () => { + expect(dispatch(100, 1)).toEqual({ scopes: 1, heard: 100, reads: 1 }) + stops.splice(0).forEach((stop) => stop()) + expect(dispatch(1_000, 10)).toEqual({ scopes: 1, heard: 1_000, reads: 10 }) +}) + +it('reads a notice without copying its room list, so a reader that wants no room never walks it', () => { + const groupIds = Array.from({ length: 1_000 }, (_, index) => `room-${index}`) + const scope = readBotChangeScope({ kinds: ['groups'], groupIds }) + expect(scope?.receivedGroupIds).toBe(groupIds) +}) diff --git a/src/renderer/src/lib/bots-changed-window-event.ts b/src/renderer/src/lib/bots-changed-window-event.ts index 6625f77526e0..28e460d23877 100644 --- a/src/renderer/src/lib/bots-changed-window-event.ts +++ b/src/renderer/src/lib/bots-changed-window-event.ts @@ -23,6 +23,20 @@ export function emitBotsChangedWindowEvent(hostId: ExecutionHostId, scope?: BotC ) } +// One read per notice, shared by every listener the window event reaches. +type ReceivedDetail = { readonly scope?: unknown } +const readScopes = new WeakMap() + +function readDetailScope(detail: ReceivedDetail): BotChangeScope | undefined { + if (!readScopes.has(detail)) { + readScopes.set( + detail, + 'scope' in detail ? readBotChangeScopeWithItems(detail.scope) : undefined + ) + } + return readScopes.get(detail) +} + /** * Hears each host's bots change. With `hostId`, only that host's changes call `listener`, so a * view of one bot or one host never re-reads on another host's change; with `interest`, only a @@ -46,10 +60,7 @@ export function onBotsChanged( if (!changed || (hostId !== undefined && changed !== hostId)) { return } - const scope = - detail && typeof detail === 'object' && 'scope' in detail - ? readBotChangeScopeWithItems(detail.scope) - : undefined + const scope = detail && typeof detail === 'object' ? readDetailScope(detail) : undefined if (!interest || botChangeConcerns(scope, interest)) { listener(changed, scope) } diff --git a/src/shared/bots/bot-change-scope.test.ts b/src/shared/bots/bot-change-scope.test.ts new file mode 100644 index 000000000000..0555773f2778 --- /dev/null +++ b/src/shared/bots/bot-change-scope.test.ts @@ -0,0 +1,51 @@ +import { expect, it } from 'vitest' +import { + addBotChange, + botChangeNotice, + botGroupRoomConcerned, + pendingBotChanges, + readBotChangeScope, + type BotChangeScope +} from './bot-change-scope' + +// One quiet window's notice, as it leaves the host and as a reader reads it back. +function notice(...changes: BotChangeScope[]): BotChangeScope | undefined { + const pending = pendingBotChanges() + changes.forEach((change) => addBotChange(pending, change)) + return readBotChangeScope(JSON.parse(JSON.stringify(botChangeNotice(pending)))) +} + +const rooms = (scope: BotChangeScope | undefined) => + ['room-a', 'room-b', 'room-c'].filter((id) => botGroupRoomConcerned(scope, id)) + +it('re-reads only the rooms a window named, and every room once a change names none', () => { + const named = notice( + { kinds: ['groups'], groupIds: ['room-a'] }, + { kinds: ['groups'], groupIds: ['room-b'] }, + { botIds: ['bot-1'], kinds: ['status'] } + ) + expect(rooms(named)).toEqual(['room-a', 'room-b']) + // A groups change that names no room (a roster edit, an older caller) reaches every room. + expect(rooms(notice({ kinds: ['groups'], groupIds: ['room-a'] }, { kinds: ['groups'] }))).toEqual( + ['room-a', 'room-b', 'room-c'] + ) + expect(rooms(notice({ kinds: ['groups'] }, { kinds: ['groups'], groupIds: ['room-a'] }))).toEqual( + ['room-a', 'room-b', 'room-c'] + ) + expect( + rooms(notice({ kinds: ['groups'], groupIds: [] }, { kinds: ['groups'], groupIds: ['room-a'] })) + ).toHaveLength(3) + // A change of every kind, an older host's bare notice, and a kind this build doesn't know all reach + // every room; another kind alone reaches none. + expect(rooms(notice({ kinds: ['groups'], groupIds: ['room-a'] }, {}))).toHaveLength(3) + expect(rooms(undefined)).toHaveLength(3) + expect(rooms(readBotChangeScope({ kinds: ['future-kind'], groupIds: ['room-a'] }))).toHaveLength( + 3 + ) + expect(rooms(notice({ botIds: ['bot-1'], kinds: ['status'] }))).toEqual([]) +}) + +it('keeps the rooms a notice names when a window reads a notice the bridge already read', () => { + const bridged = structuredClone(readBotChangeScope({ kinds: ['groups'], groupIds: ['room-a'] })) + expect(rooms(readBotChangeScope(bridged))).toEqual(['room-a']) +}) diff --git a/src/shared/bots/bot-change-scope.ts b/src/shared/bots/bot-change-scope.ts index ae03f5295b7f..95a14210bb22 100644 --- a/src/shared/bots/bot-change-scope.ts +++ b/src/shared/bots/bot-change-scope.ts @@ -45,6 +45,12 @@ export type BotChangeScope = { /** The host reads a list's items by uid, so a `workers` change can read just the loaded items that * link a worker. Absent: an older host, whose lists read whole. */ namesItems?: true + /** A `groups` change's rooms, by group id: an open room re-reads only when its group is named. Absent + * (and an older host's notice): every room re-reads. */ + groupIds?: readonly string[] + /** `groupIds` as a peer's notice carried it, unread: only an open room reads it (botGroupRoomConcerned), + * so a reader that wants no room never walks the list. */ + receivedGroupIds?: readonly unknown[] } /** The notice of these changed items, by bot; null for none. */ @@ -139,6 +145,8 @@ const ANY_KIND = '*' export type PendingBotChanges = { kinds: Map | null> itemUids: Map | null> + /** The rooms a `groups` change named; null once one named none (every room), absent before any. */ + groupIds?: Set | null } export function pendingBotChanges(): PendingBotChanges { @@ -151,6 +159,15 @@ export const BOT_CHANGE_ITEM_UIDS_MAX = 100 export function addBotChange(pending: PendingBotChanges, scope: BotChangeScope): void { const kinds: readonly (BotChangeKind | typeof ANY_KIND)[] = scope.kinds && scope.kinds.length > 0 ? scope.kinds : [ANY_KIND] + if (kinds.includes('groups') || kinds.includes(ANY_KIND)) { + // A change naming no room (no list, or an empty one) reaches every room. + if (!scope.groupIds?.length || pending.groupIds === null) { + pending.groupIds = null + } else { + pending.groupIds ??= new Set() + scope.groupIds.forEach((id) => pending.groupIds?.add(id)) + } + } for (const kind of kinds) { const bots = pending.kinds.get(kind) if (!scope.botIds) { @@ -187,6 +204,7 @@ export function botChangeNotice(pending: PendingBotChanges): BotChangeScope { if (pending.kinds.has(ANY_KIND)) { return botIds ? { botIds } : {} } + const groupIds = pending.kinds.has('groups') && pending.groupIds ? [...pending.groupIds] : null const kinds = entries.map(([kind]) => kind).filter((kind) => kind !== ANY_KIND) const scoped = entries.flatMap(([kind, bots]) => kind !== ANY_KIND && bots ? [[kind, [...bots]] as const] : [] @@ -204,8 +222,39 @@ export function botChangeNotice(pending: PendingBotChanges): BotChangeScope { kinds, ...(sameBots || scoped.length === 0 ? {} : { kindBots: Object.fromEntries(scoped) }), ...(named.length > 0 ? { itemUids: Object.fromEntries(named) } : {}), - ...(pending.kinds.has('workers') ? { namesItems: true as const } : {}) + ...(pending.kinds.has('workers') ? { namesItems: true as const } : {}), + ...(groupIds ? { groupIds } : {}) + } +} + +/** Whether an open room of `groupId` re-reads for this notice: a `groups` change (or one of any or an + * unknown kind) that names its group or names none. */ +export function botGroupRoomConcerned(scope: BotChangeScope | undefined, groupId: string): boolean { + const known = new Set(BOT_CHANGE_KINDS) + const kinds = scope?.kinds ?? [] + // A kind this build does not know counts, as in botChangeConcerns. + if (kinds.some((kind) => !known.has(kind))) { + return true + } + if (kinds.length > 0 && !kinds.includes('groups')) { + return false + } + const listed = scope?.groupIds ?? scope?.receivedGroupIds + // A list with no room in it names none, so every room re-reads. + const rooms = listed ? namedRooms(listed) : null + return rooms && rooms.size > 0 ? rooms.has(groupId) : true +} + +// Each notice's rooms as a set, built once however many open rooms ask. +const roomSets = new WeakMap>() + +function namedRooms(groupIds: readonly unknown[]): ReadonlySet { + let rooms = roomSets.get(groupIds) + if (!rooms) { + rooms = new Set(groupIds.filter((id): id is string => typeof id === 'string')) + roomSets.set(groupIds, rooms) } + return rooms } /** The scope a runtime event carries, read loosely (a peer of another version may send anything). */ @@ -223,12 +272,21 @@ export function readBotChangeScope(event: unknown): BotChangeScope | undefined { : undefined const kindBots = 'kindBots' in event ? readStringLists(event.kindBots) : undefined const needsYou = 'needsYou' in event ? readBotNeedsYouCounts(event.needsYou) : undefined + // Kept as sent: only an open room walks it, once per notice. + // A notice read once already (the preload's, a paired host's) carries it as `receivedGroupIds`. + const receivedGroupIds: readonly unknown[] | undefined = + 'groupIds' in event && Array.isArray(event.groupIds) + ? event.groupIds + : 'receivedGroupIds' in event && Array.isArray(event.receivedGroupIds) + ? event.receivedGroupIds + : undefined return botIds || kinds ? { ...(botIds ? { botIds } : {}), ...(kinds ? { kinds } : {}), ...(kindBots ? { kindBots } : {}), - ...(needsYou ? { needsYou } : {}) + ...(needsYou ? { needsYou } : {}), + ...(receivedGroupIds ? { receivedGroupIds } : {}) } : undefined }