Skip to content

The agent that grows with you

fix(bot-mode): a gateway Group Chat row's right-click menu has Delete

Tekniumc4b5266ba4f5
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-locales.ts b/apps/desktop/src/plugins/hermes-bots/canonical-group-locales.ts
index 1d653d1c597..82b723388f6 100644
--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-locales.ts
+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-locales.ts
@@ -9,6 +9,7 @@ export interface CanonicalGroupMessages {
turnDeferred: string
memberUnavailable: string
refreshGroups: string
+ openGroup: string
loadingGroup: string
loadingGroups: string
emptyGroups: string
@@ -42,6 +43,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'Member unavailable',
members: 'Members',
refreshGroups: 'Refresh gateway groups',
+ openGroup: 'Open Group Chat',
loadingGroup: 'Loading group…',
loadingGroups: 'Loading gateway groups…',
emptyGroups: 'No gateway groups found.',
@@ -73,6 +75,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'メンバーは利用できません',
members: 'メンバー',
refreshGroups: 'ゲートウェイのグループを更新',
+ openGroup: 'グループチャットを開く',
loadingGroup: 'グループを読み込み中…',
loadingGroups: 'ゲートウェイのグループを読み込み中…',
emptyGroups: 'ゲートウェイのグループが見つかりません。',
@@ -104,6 +107,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: '成员不可用',
members: '成员',
refreshGroups: '刷新网关群组',
+ openGroup: '打开群聊',
loadingGroup: '正在加载群组…',
loadingGroups: '正在加载网关群组…',
emptyGroups: '未找到网关群组。',
@@ -135,6 +139,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: '成員無法使用',
members: '成員',
refreshGroups: '重新整理閘道群組',
+ openGroup: '開啟群組聊天',
loadingGroup: '正在載入群組…',
loadingGroups: '正在載入閘道群組…',
emptyGroups: '找不到閘道群組。',
@@ -166,6 +171,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'العضو غير متاح',
members: 'الأعضاء',
refreshGroups: 'تحديث مجموعات البوابة',
+ openGroup: 'فتح الدردشة الجماعية',
loadingGroup: 'جارٍ تحميل المجموعة…',
loadingGroups: 'جارٍ تحميل مجموعات البوابة…',
emptyGroups: 'لم يتم العثور على مجموعات في البوابة.',
@@ -197,6 +203,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'Участник недоступен',
members: 'Участники',
refreshGroups: 'Обновить группы шлюза',
+ openGroup: 'Открыть групповой чат',
loadingGroup: 'Загрузка группы…',
loadingGroups: 'Загрузка групп шлюза…',
emptyGroups: 'Группы шлюза не найдены.',
@@ -231,6 +238,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'Membre indisponible',
members: 'Membres',
refreshGroups: 'Actualiser les groupes de la passerelle',
+ openGroup: 'Ouvrir la discussion de groupe',
loadingGroup: 'Chargement du groupe…',
loadingGroups: 'Chargement des groupes de la passerelle…',
emptyGroups: 'Aucun groupe de passerelle trouvé.',
@@ -264,6 +272,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'Mitglied nicht verfügbar',
members: 'Mitglieder',
refreshGroups: 'Gateway-Gruppen aktualisieren',
+ openGroup: 'Gruppenchat öffnen',
loadingGroup: 'Gruppe wird geladen…',
loadingGroups: 'Gateway-Gruppen werden geladen…',
emptyGroups: 'Keine Gateway-Gruppen gefunden.',
@@ -298,6 +307,7 @@ export const CANONICAL_GROUP_LOCALES = {
memberUnavailable: 'Miembro no disponible',
members: 'Miembros',
refreshGroups: 'Actualizar grupos de la pasarela',
+ openGroup: 'Abrir chat de grupo',
loadingGroup: 'Cargando grupo…',
loadingGroups: 'Cargando grupos de la pasarela…',
emptyGroups: 'No se encontraron grupos de la pasarela.',
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx
index e9007699133..62c8a4d09a3 100644
--- a/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-registry.tsx
@@ -1,9 +1,11 @@
-import { atom, Button, host, useValue } from '@hermes/plugin-sdk'
+import { atom, Button, host, randomUuid, useValue } from '@hermes/plugin-sdk'
import { useEffect, useState } from 'react'
import { useCanonicalGroupLabels } from './canonical-group-labels'
-import { captureCanonicalGroupRoute, discoverCanonicalGroups } from './canonical-groups'
+import { CanonicalGroupRow } from './canonical-group-row'
+import { canonicalGroupRequest, captureCanonicalGroupRoute, discoverCanonicalGroups } from './canonical-groups'
import type { CanonicalGroupBinding, CanonicalGroupRoute, CanonicalRoom } from './canonical-groups'
+import { closeGroupChatMainTab } from './group-panes'
export const $canonicalGroupBindings = atom<Record<string, CanonicalGroupBinding>>({})
// Bumped when a room leaves outside the list's own Refresh, so the sidebar re-reads `groups.list`.
@@ -106,11 +108,22 @@ export function publishCanonicalGroup(
$canonicalGroupBindings.set({ ...$canonicalGroupBindings.get(), [alias]: binding })
}
+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)
+ forgetCanonicalGroup(room.binding)
+ host.notify({ kind: 'success', message: doneMessage })
+}
+
export function CanonicalGroupList({ onOpen }: { onOpen: (key: string, origin: CanonicalGroupOrigin) => void }) {
const labels = useCanonicalGroupLabels()
const connectionId = useValue(host.state.connectionId)
const profile = useValue(host.state.profile)
- const [rooms, setRooms] = useState<Array<{ key: string; name: string }>>([])
+ const [rooms, setRooms] = useState<ListedRoom[]>([])
const [error, setError] = useState('')
const [refresh, setRefresh] = useState(0)
const revision = useValue($canonicalGroupListRevision)
@@ -122,7 +135,14 @@ export function CanonicalGroupList({ onOpen }: { onOpen: (key: string, origin: C
const route = captureCanonicalGroupRoute()
const result = await discoverCanonicalGroups(route)
- if (!cancelled) {setRooms(result.rooms.map(room => ({ key: registerCanonicalGroup(route, room), name: room.name })))}
+ if (!cancelled) {
+ setRooms(result.rooms.map(room => ({
+ binding: { ...route, roomId: room.room_id, roomName: room.name },
+ key: registerCanonicalGroup(route, room),
+ memberCount: room.members?.length ?? 0,
+ name: room.name
+ })))
+ }
})().catch(e => { if (!cancelled) {setError(e instanceof Error ? e.message : String(e))} })
return () => { cancelled = true }
@@ -131,6 +151,7 @@ export function CanonicalGroupList({ onOpen }: { onOpen: (key: string, origin: C
return <div className="grid gap-1 px-2">
<Button onClick={() => setRefresh(value => value + 1)} variant="ghost">{labels.refreshGroups}</Button>
{error && <p role="alert">{error}</p>}
- {rooms.map(room => <Button key={room.key} onClick={() => onOpen(room.key, 'key')} variant="ghost">{room.name}</Button>)}
+ {rooms.map(room => <CanonicalGroupRow key={room.key} memberCount={room.memberCount} name={room.name}
+ onDelete={() => disbandListedRoom(room, labels.disbanded(room.name))} onOpen={() => onOpen(room.key, 'key')} />)}
</div>
}
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.tsx
new file mode 100644
index 00000000000..6b6e914fb4a
--- /dev/null
+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-row-delete.test.tsx
@@ -0,0 +1,111 @@
+/**
+ * #143571: a gateway Group Chat row in the Bots roster offers Delete from its
+ * right-click menu. Delete confirms, disbands the room on its own gateway
+ * (`groups.disband`), drops it from the list, forgets its bindings and closes
+ * a pane still showing it. A refused disband keeps the row and says why.
+ *
+ * Real SDK components and stores; only the gateway transport is mocked.
+ */
+
+import type * as HermesSdk from '@hermes/plugin-sdk'
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import { atom } from 'nanostores'
+import { afterEach, beforeEach, expect, it, vi } from 'vitest'
+
+import { translateBotsIn } from './i18n-test-helper'
+
+const { notify, requestProfile } = vi.hoisted(() => ({ notify: vi.fn(), requestProfile: vi.fn() }))
+
+vi.mock('@hermes/plugin-sdk', async importOriginal => {
+ const sdk = await importOriginal<typeof HermesSdk>()
+
+ return {
+ ...sdk,
+ host: {
+ ...sdk.host,
+ notify,
+ requestProfile,
+ state: { ...sdk.host.state, connectionId: atom<null | string>('local'), profile: atom('default') }
+ },
+ usePluginI18n: () => translateBotsIn('en')
+ }
+})
+
+import { $canonicalGroupBindings, CanonicalGroupList } from './canonical-group-registry'
+import { $groupChatWorkspace } from './group-chat'
+
+const room = { room_id: 'room-1', name: 'Launch crew', members: [{ member_id: 'm1', profile: 'work', handle: 'work' }] }
+let rooms: (typeof room)[] = []
+let refuse = ''
+
+beforeEach(() => {
+ rooms = [room]
+ refuse = ''
+ requestProfile.mockImplementation(async (_route: unknown, method: string, params: { room_id?: string }) => {
+ if (method === 'groups.capabilities') {
+ return { driver: true }
+ }
+
+ if (method === 'groups.list') {
+ return { rooms, next_offset: null }
+ }
+
+ if (method === 'groups.disband') {
+ if (refuse) {
+ throw new Error(refuse)
+ }
+
+ rooms = rooms.filter(r => r.room_id !== params.room_id)
+
+ return { tombstone: { room_id: params.room_id } }
+ }
+
+ return {}
+ })
+})
+
+afterEach(() => {
+ cleanup()
+ vi.clearAllMocks()
+ $canonicalGroupBindings.set({})
+ $groupChatWorkspace.set(null)
+})
+
+async function openDeleteConfirm() {
+ fireEvent.contextMenu(await screen.findByRole('button', { name: 'Launch crew' }))
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
+
+ return within(await screen.findByRole('dialog'))
+}
+
+it('deletes a gateway group from its row menu: confirm, disband on its gateway, gone from the list', async () => {
+ const onOpen = vi.fn()
+ render(<CanonicalGroupList onOpen={onOpen} />)
+ const dialog = await openDeleteConfirm()
+ const key = Object.keys($canonicalGroupBindings.get()).find(k => k.startsWith('canonical:'))!
+ $groupChatWorkspace.set(key)
+
+ expect(dialog.getByText('Launch crew')).toBeTruthy()
+ fireEvent.click(dialog.getByRole('button', { name: 'Disband' }))
+
+ await waitFor(() => expect(screen.queryByRole('button', { name: 'Launch crew' })).toBeNull())
+ const disband = requestProfile.mock.calls.filter(([, method]) => method === 'groups.disband')
+ expect(disband).toHaveLength(1)
+ expect(disband[0][0]).toMatchObject({ connectionId: 'local', profile: 'default' })
+ expect(disband[0][2]).toMatchObject({ room_id: 'room-1' })
+ expect($canonicalGroupBindings.get()[key]).toBeUndefined()
+ expect($groupChatWorkspace.get()).toBeNull()
+ expect(notify).toHaveBeenCalledWith({ kind: 'success', message: 'Disbanded “Launch crew”' })
+ expect(onOpen).not.toHaveBeenCalled()
+})
+
+it('keeps the row and shows the gateway refusal when the disband fails', async () => {
+ refuse = 'room is busy'
+ render(<CanonicalGroupList onOpen={vi.fn()} />)
+ const dialog = await openDeleteConfirm()
+ fireEvent.click(dialog.getByRole('button', { name: 'Disband' }))
+
+ expect(await dialog.findByText(/room is busy/)).toBeTruthy()
+ expect(screen.getByRole('button', { hidden: true, name: 'Launch crew' })).toBeTruthy()
+ expect(notify).not.toHaveBeenCalledWith(expect.objectContaining({ kind: 'success' }))
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/canonical-group-row.tsx b/apps/desktop/src/plugins/hermes-bots/canonical-group-row.tsx
new file mode 100644
index 00000000000..39409cc91ce
--- /dev/null
+++ b/apps/desktop/src/plugins/hermes-bots/canonical-group-row.tsx
@@ -0,0 +1,67 @@
+import {
+ Button,
+ ConfirmDialog,
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuSeparator,
+ ContextMenuTrigger
+} from '@hermes/plugin-sdk'
+import { useState } from 'react'
+
+import { useCanonicalGroupLabels } from './canonical-group-labels'
+import { useBots } from './i18n'
+
+interface CanonicalGroupRowProps {
+ memberCount: number
+ name: string
+ /** Rejects with the gateway's refusal so the confirm stays open and shows it. */
+ onDelete: () => Promise<void>
+ onOpen: () => void
+}
+
+/** One gateway Group Chat in the roster list, with the same right-click Open /
+ * Delete a Desktop-local group row has (#143571). */
+export function CanonicalGroupRow({ memberCount, name, onDelete, onOpen }: CanonicalGroupRowProps) {
+ const labels = useCanonicalGroupLabels()
+ const { group } = useBots()
+ const [confirming, setConfirming] = useState(false)
+
+ return (
+ <>
+ <ContextMenu>
+ <ContextMenuTrigger asChild>
+ <Button onClick={onOpen} variant="ghost">
+ {name}
+ </Button>
+ </ContextMenuTrigger>
+ <ContextMenuContent>
+ <ContextMenuItem onSelect={onOpen}>{labels.openGroup}</ContextMenuItem>
+ <ContextMenuSeparator />
+ <ContextMenuItem onSelect={() => setConfirming(true)} variant="destructive">
+ {group.deleteAction}
+ </ContextMenuItem>
+ </ContextMenuContent>
+ </ContextMenu>
+ {confirming && (
+ <ConfirmDialog
+ busyLabel={labels.disbanding}
+ confirmLabel={labels.disband}
+ description={
+ <span>
+ {labels.disbandDescPrefix}
+ <span className="font-medium text-foreground">{name}</span>
+ {labels.disbandDescSuffix(memberCount)}
+ </span>
+ }
+ destructive
+ doneLabel={labels.disbandDone}
+ onClose={() => setConfirming(false)}
+ onConfirm={onDelete}
+ open
+ title={labels.disbandTitle}
+ />
+ )}
+ </>
+ )
+}
diff --git a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts
index 8d681dd0f78..3106bd723f4 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-test-utils.ts
@@ -459,8 +459,17 @@ export async function pluginSdkMock(host: Record<string, unknown>) {
const { cn } = await import('@/lib/utils')
const { randomUuid } = await import('@hermes/shared')
+ // The gateway Group Chat row's right-click menu (#143571) renders the real one.
+ const { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger } =
+ await import('@/components/ui/context-menu')
+
return {
Textarea,
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuSeparator,
+ ContextMenuTrigger,
cn,
// Real value: approval.respond forwards it as its client deadline (#60654).
APPROVAL_RESPOND_TIMEOUT_MS: 300_000,