The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-mode): deleting a gateway Group Chat also closes views opened under its name
Tekniumcefb38724ef2
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsxindex 62c8a4d09a3..5fa8b090697 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx@@ -108,13 +108,29 @@ export function publishCanonicalGroup($canonicalGroupBindings.set({ ...$canonicalGroupBindings.get(), [alias]: binding })}+/** Every view string showing this room: its `canonical:` keys, and the name a+ * name-opened tab and selection are recorded under (from its route-scoped alias). */+function canonicalGroupViews({ connectionId, profile, roomId }: CanonicalGroupBinding): Set<string> {+ const aliasPrefix = canonicalGroupAliasKey({ connectionId, profile }, '')+ const views = new Set<string>()++ for (const [key, binding] of Object.entries($canonicalGroupBindings.get())) {+ if (binding.connectionId === connectionId && binding.profile === profile && binding.roomId === roomId) {+ views.add(key.startsWith(aliasPrefix) ? key.slice(aliasPrefix.length) : key)+ }+ }++ return views+}+interface ListedRoom { binding: CanonicalGroupBinding; key: string; memberCount: number; name: string }/** Disband on the room's own gateway, then retire it everywhere this window shows it.* A refusal rejects before anything is dropped, so the row stays and the confirm shows why. */async function disbandListedRoom(room: ListedRoom, doneMessage: string): Promise<void> {await canonicalGroupRequest(room.binding, 'groups.disband', { room_id: room.binding.roomId, cancel_id: randomUuid() })- closeGroupChatMainTab(room.key)+ // Collect before forgetting: the bindings are the only record of which views alias this room.+ canonicalGroupViews(room.binding).add(room.key).forEach(closeGroupChatMainTab)forgetCanonicalGroup(room.binding)host.notify({ kind: 'success', message: doneMessage })}diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-row-delete.test.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-row-delete.test.tsxindex 6b6e914fb4a..aff8922acf9 100644--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-row-delete.test.tsx+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-row-delete.test.tsx@@ -31,8 +31,9 @@ vi.mock('@hermes/plugin-sdk', async importOriginal => {}})-import { $canonicalGroupBindings, CanonicalGroupList } from './canonical-group-registry'+import { $canonicalGroupBindings, CanonicalGroupList, publishCanonicalGroup } from './canonical-group-registry'import { $groupChatWorkspace } from './group-chat'+import { dropGroupMainTab, recordGroupMainTab } from './group-panes'const room = { room_id: 'room-1', name: 'Launch crew', members: [{ member_id: 'm1', profile: 'work', handle: 'work' }] }let rooms: (typeof room)[] = []@@ -69,6 +70,8 @@ afterEach(() => {vi.clearAllMocks()$canonicalGroupBindings.set({})$groupChatWorkspace.set(null)+ dropGroupMainTab('Launch crew')+ dropGroupMainTab('Other crew')})async function openDeleteConfirm() {@@ -109,3 +112,26 @@ it('keeps the row and shows the gateway refusal when the disband fails', async (expect(screen.getByRole('button', { hidden: true, name: 'Launch crew' })).toBeTruthy()expect(notify).not.toHaveBeenCalledWith(expect.objectContaining({ kind: 'success' }))})++it('closes the tab and selection opened under the room name, and leaves another room open', async () => {+ const other = { room_id: 'room-2', name: 'Other crew', members: [] }+ rooms = [room, other]+ const route = { connectionId: 'local', profile: 'default' }+ publishCanonicalGroup(route, room.name, { authority: route, room }, 'name')+ publishCanonicalGroup(route, other.name, { authority: route, room: other }, 'name')+ const closeAlias = vi.fn()+ const closeOther = vi.fn()+ recordGroupMainTab(room.name, closeAlias)+ recordGroupMainTab(other.name, closeOther)+ $groupChatWorkspace.set(room.name)++ render(<CanonicalGroupList onOpen={vi.fn()} />)+ fireEvent.click((await openDeleteConfirm()).getByRole('button', { name: 'Disband' }))++ await waitFor(() => expect(screen.queryByRole('button', { name: 'Launch crew' })).toBeNull())+ expect(closeAlias).toHaveBeenCalledTimes(1)+ expect($groupChatWorkspace.get()).toBeNull()+ expect(closeOther).not.toHaveBeenCalled()+ expect(Object.values($canonicalGroupBindings.get()).map(b => b.roomId)).toEqual(expect.arrayContaining(['room-2']))+ expect(Object.values($canonicalGroupBindings.get()).some(b => b.roomId === 'room-1')).toBe(false)+})