Skip to content

The agent that grows with you

fix(desktop): enable New Group Chat with one local bot plus remote-connection bots

teknium19f077100cc3f
diff --git a/apps/desktop/e2e/group-create-gate-remote-roster.spec.ts b/apps/desktop/e2e/group-create-gate-remote-roster.spec.ts
new file mode 100644
index 00000000000..521f7ee0d20
--- /dev/null
+++ b/apps/desktop/e2e/group-create-gate-remote-roster.spec.ts
@@ -0,0 +1,214 @@
+/**
+ * E2E: the New Group Chat menu gate with one local bot plus remote-connection
+ * bots (#101543). "This device" is the Electron-managed local backend with
+ * only its `default` profile; "Homelab" is a REAL second `hermes serve`
+ * registered as a remote URL connection. The gate must count the same
+ * selectable set the dialog seats — bots from every registered connection —
+ * so 1 local + 1 remote enables New Group Chat and the room can be created.
+ */
+
+import { type ChildProcess, spawn, spawnSync } from 'node:child_process'
+import * as fs from 'node:fs'
+import * as net from 'node:net'
+import * as path from 'node:path'
+
+import {
+ buildAppEnv,
+ createSandbox,
+ launchDesktop,
+ type MockBackendFixture,
+ type Sandbox,
+ waitForAppReady,
+ writeEnvFile,
+ writeMockProviderConfig,
+} from './fixtures'
+import { startMockServer } from '../../../tests-js/scripts/mock-server'
+import { type ElectronApplication, expect, type Page, test } from './test'
+
+const DESKTOP_ROOT = path.resolve(import.meta.dirname, '..')
+const REPO_ROOT = path.resolve(DESKTOP_ROOT, '..', '..')
+const REMOTE_LABEL = 'Homelab'
+const REMOTE_ID = 'homelab'
+const REMOTE_TOKEN = 'e2e-group-gate-homelab-token'
+const SHOTS = '/tmp/batchbots/group-identity-members/shots'
+
+interface RemoteGateway {
+ url: string
+ close: () => Promise<void>
+}
+
+/** The worktree's own backend: `python -m hermes_cli.main` from the repo root
+ * (the venv's `hermes` console script resolves the package it was installed
+ * from, which need not be this checkout). */
+function hermesCommand(): { bin: string; args: string[] } {
+ const venvPython = path.join(REPO_ROOT, '.venv', 'bin', 'python')
+
+ if (fs.existsSync(venvPython)) {
+ return { bin: venvPython, args: ['-m', 'hermes_cli.main'] }
+ }
+
+ const result = spawnSync('which', ['hermes'], { encoding: 'utf8' })
+
+ if (result.status === 0 && result.stdout.trim()) {
+ return { bin: result.stdout.trim(), args: [] }
+ }
+
+ throw new Error('hermes backend not found: create the repo venv (uv sync) or put hermes on PATH')
+}
+
+async function freePort(): Promise<number> {
+ return new Promise((resolve, reject) => {
+ const server = net.createServer()
+ server.unref()
+ server.on('error', reject)
+ server.listen(0, '127.0.0.1', () => {
+ const { port } = server.address() as net.AddressInfo
+ server.close(() => resolve(port))
+ })
+ })
+}
+
+function seedProfiles(home: string, names: string[]): void {
+ for (const name of names) {
+ const dir = path.join(home, 'profiles', name)
+ fs.mkdirSync(dir, { recursive: true })
+ fs.writeFileSync(path.join(dir, 'config.yaml'), '', 'utf8')
+ }
+}
+
+async function startRemoteGateway(root: string, mockUrl: string, profiles: string[]): Promise<RemoteGateway> {
+ const home = path.join(root, 'homelab-home')
+ fs.mkdirSync(home, { recursive: true })
+ writeMockProviderConfig(home, mockUrl)
+ writeEnvFile(home)
+ seedProfiles(home, profiles)
+ const port = await freePort()
+ const url = `http://127.0.0.1:${port}`
+
+ const hermes = hermesCommand()
+
+ const child: ChildProcess = spawn(hermes.bin, [...hermes.args, 'serve', '--host', '127.0.0.1', '--port', String(port), '--skip-build'], {
+ cwd: REPO_ROOT,
+ detached: true,
+ env: { ...process.env, HERMES_HOME: home, HERMES_DASHBOARD_SESSION_TOKEN: REMOTE_TOKEN, PYTHONPATH: REPO_ROOT },
+ stdio: ['ignore', 'pipe', 'pipe'],
+ })
+
+ let log = ''
+ child.stdout?.on('data', (chunk: Buffer) => { log += chunk.toString() })
+ child.stderr?.on('data', (chunk: Buffer) => { log += chunk.toString() })
+ const deadline = Date.now() + 90_000
+
+ while (Date.now() < deadline) {
+ if (child.exitCode !== null) {
+ throw new Error(`remote hermes serve exited early (${child.exitCode}):\n${log}`)
+ }
+
+ try {
+ const response = await fetch(`${url}/api/status`, { headers: { 'X-Hermes-Session-Token': REMOTE_TOKEN } })
+
+ if (response.ok) {
+ break
+ }
+ } catch {
+ // not up yet
+ }
+
+ await new Promise(resolve => setTimeout(resolve, 500))
+ }
+
+ if (Date.now() >= deadline) {
+ throw new Error(`remote hermes serve never became ready:\n${log}`)
+ }
+
+ return {
+ url,
+ close: async () => {
+ if (child.pid && child.exitCode === null) {
+ try {
+ process.kill(-child.pid, 'SIGTERM')
+ } catch {
+ child.kill('SIGTERM')
+ }
+ }
+
+ await new Promise(resolve => setTimeout(resolve, 500))
+ },
+ }
+}
+
+function writeConnectionsRegistry(sandbox: Sandbox, remoteUrl: string): void {
+ fs.writeFileSync(
+ path.join(sandbox.userDataDir, 'connections.json'),
+ JSON.stringify(
+ {
+ version: 2,
+ primary: 'local',
+ launchMode: 'primary',
+ lastUsed: 'local',
+ connections: [
+ { id: 'local', kind: 'local', label: 'This device' },
+ { id: REMOTE_ID, kind: 'remote', label: REMOTE_LABEL, url: remoteUrl, authMode: 'token', token: { encoding: 'plain', value: REMOTE_TOKEN } },
+ ],
+ },
+ null,
+ 2,
+ ),
+ { encoding: 'utf8', mode: 0o600 },
+ )
+}
+
+const roster = (page: Page) => page.locator('[data-slot="bots-roster"]')
+
+test.describe('New Group Chat gate — one local bot plus remote-connection bots', () => {
+ let mock: Awaited<ReturnType<typeof startMockServer>>
+ let sandbox: Sandbox
+ let remote: RemoteGateway
+ let app: ElectronApplication
+ let page: Page
+
+ test.beforeAll(async () => {
+ test.setTimeout(240_000)
+ mock = await startMockServer()
+ sandbox = createSandbox('group-gate')
+ writeMockProviderConfig(sandbox.hermesHome, mock.url)
+ writeEnvFile(sandbox.hermesHome)
+ // This device: ONLY its primary `default` profile. Homelab: default + inbox (rendered title-cased, "Inbox").
+ remote = await startRemoteGateway(sandbox.root, mock.url, ['inbox'])
+ writeConnectionsRegistry(sandbox, remote.url)
+ ;({ app, page } = await launchDesktop(buildAppEnv(sandbox)))
+ await waitForAppReady({ app, page } as MockBackendFixture, 120_000)
+ await expect(page.locator('[data-slot="statusbar"]').getByText('ready', { exact: true })).toBeVisible({ timeout: 120_000 })
+ })
+
+ test.afterAll(async () => {
+ await app?.close().catch(() => undefined)
+ await remote?.close()
+ await mock?.close()
+ sandbox?.cleanup()
+ })
+
+ test('the menu entry enables and the dialog seats the remote bot', async () => {
+ test.setTimeout(240_000)
+ const tab = page.getByRole('button', { name: 'Bots', exact: true }).or(page.getByRole('tab', { name: 'Bots', exact: true })).first()
+ await tab.click()
+ await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()
+ // Precondition: exactly one local bot, and the remote bots have arrived.
+ await expect(roster(page).locator(`[data-roster-key="${REMOTE_ID}::inbox"]`)).toBeVisible({ timeout: 90_000 })
+ await expect(roster(page).locator('[data-roster-key^="local::"]')).toHaveCount(1)
+
+ await page.getByRole('button', { name: 'New bot or group chat' }).click()
+ const entry = page.getByRole('menuitem', { name: 'New Group Chat' })
+ await expect(entry).toBeVisible()
+ await page.screenshot({ path: `${SHOTS}/group-create-gate-menu.png` })
+ await expect(entry).toBeEnabled()
+ await entry.click()
+
+ const dialog = page.getByRole('dialog', { name: 'New Group Chat' })
+ await expect(dialog).toBeVisible()
+ await dialog.getByText('Hermes', { exact: true }).first().locator('xpath=ancestor::label').getByRole('checkbox').click()
+ await dialog.getByText('Inbox', { exact: true }).first().locator('xpath=ancestor::label').getByRole('checkbox').click()
+ await expect(dialog.getByRole('button', { name: 'Create Group (2)' })).toBeEnabled()
+ await page.screenshot({ path: `${SHOTS}/group-create-gate-dialog.png` })
+ })
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/roster-pane-toolbar.tsx b/apps/desktop/src/plugins/hermes-bots/roster-pane-toolbar.tsx
index ca366664868..66f31de5edd 100644
--- a/apps/desktop/src/plugins/hermes-bots/roster-pane-toolbar.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/roster-pane-toolbar.tsx
@@ -22,6 +22,9 @@ interface renderRosterToolbarProps {
b: ReturnType<typeof useBots>
activityToasts: boolean
activeSourceRoster: RosterRow[]
+ /** Full multi-source roster — the New Group Chat gate counts the same
+ * selectable set the dialog seats (bots from every registered connection). */
+ roster: RosterRow[]
setCreateOpen: (value: boolean) => void
setGroupCreateOpen: (value: boolean) => void
setSectionDialog: (
@@ -46,6 +49,7 @@ export function renderRosterToolbar({
b,
activityToasts,
activeSourceRoster,
+ roster,
setCreateOpen,
setGroupCreateOpen,
setSectionDialog,
@@ -100,7 +104,9 @@ export function renderRosterToolbar({
<Codicon className="mr-1.5" name="hubot" />
{b.bot.newTitle}
</DropdownMenuItem>
- <DropdownMenuItem disabled={activeSourceRoster.length < 2} onSelect={() => setGroupCreateOpen(true)}>
+ {/* Same selectable set as CreateGroupChatDialog: one local bot plus a
+ remote-connection bot is a valid room (#101543). */}
+ <DropdownMenuItem disabled={roster.filter(bot => !bot?.ghost).length < 2} onSelect={() => setGroupCreateOpen(true)}>
<Codicon className="mr-1.5" name="organization" />
{b.group.newTitle}
</DropdownMenuItem>
diff --git a/apps/desktop/src/plugins/hermes-bots/roster-pane.tsx b/apps/desktop/src/plugins/hermes-bots/roster-pane.tsx
index 39303657fa4..8e69c57b08b 100644
--- a/apps/desktop/src/plugins/hermes-bots/roster-pane.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/roster-pane.tsx
@@ -457,6 +457,7 @@ export function BotsPane() {
b,
activityToasts,
activeSourceRoster,
+ roster,
setCreateOpen,
setGroupCreateOpen,
setSectionDialog,
diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.md
index dc520d71fbb..add334f953a 100644
--- a/website/docs/user-guide/bot-mode.md
+++ b/website/docs/user-guide/bot-mode.md
@@ -142,7 +142,7 @@ Use the **Move up** and **Move down** arrows beside a room to choose its positio
- **Rooms keep running when you close the Desktop.** When every member of a room lives on the same gateway, that gateway owns turn scheduling through a durable driver: closing Hermes Desktop (or losing its connection) does not stop a room mid-discussion, and the Desktop simply catches up from the room's log when it reconnects. `groups.capabilities` on the gateway reports `driver: true` when this applies. More than one room worker may share a home — the messaging gateway (`hermes gateway run`) and the Desktop's own backend (`hermes serve`) both run one — and whichever holds the room's driver lease runs the next turn; a member's room session is held only for the duration of its turn, so the lease can move between workers without a turn being refused. Room state lives in the install's root `shared-state.db`; installs that created rooms before that file existed (when rooms were still kept in the root `state.db`) get those rooms copied across once, on the first open after updating, so pre-existing Group Chats stay reachable. Rooms whose members span several machines are different: each member's turns run on its own gateway, and the cross-connection courier described under *Bot-to-bot messaging* still applies to them.
- **Mentions read as identities.** In the transcript a routed `@bot` mention, the human handoff `@user`, and the broadcasts `@everyone` / `@all` render as inline references (accent text, not pills); unknown `@words` and e-mail addresses stay plain. Hover a Bot's message and use **Reply to @handle** to seed `@handle ` into the composer, so your next send goes to that Bot only (when a same-named Bot from a Connection shares the room, the tag is device-qualified, e.g. `@reviewer-mini` / `@reviewer-local`) — **Reply in thread** still continues the whole thread. If a reply box for a *different* thread is open, **Reply to** seeds the main composer instead and so starts a fresh thread; use **Reply in thread** to continue that thread.
-- **Rooms can span machines.** The New Group Chat picker seats Bots from any registered connection; each member's turns run on its own machine, in its own room session there. Cross-machine members carry a device badge (`dixie · Mac Mini`) in the room and in other members' transcripts, and the disambiguated `@name-device` handle works in room mentions — so same-named agents on two machines never blur together.
+- **Rooms can span machines.** **New Group Chat** is available as soon as two Bots are selectable across all your registered connections — one Bot on this device plus one on another gateway is enough. The picker seats Bots from any registered connection; each member's turns run on its own machine, in its own room session there. Cross-machine members carry a device badge (`dixie · Mac Mini`) in the room and in other members' transcripts, and the disambiguated `@name-device` handle works in room mentions — so same-named agents on two machines never blur together.
- **Rooms show the same identity as the roster.** Transcript rows, the “X is thinking…” line and Activity rows resolve each member's title and avatar by its owning connection and profile — re-titling a Bot or changing its picture updates every room it sits in, remote members keep their own titles, and two same-named Bots on different connections never borrow each other's avatar. When two members would still read identically, Activity appends the connection label (`Reviewer · Mac Mini`).
- **Plugins can watch members work.** The durable room log records `turn.started` and `turn.settled`; what a member does in between (tools, approvals, streamed text) is projected to plugins through the [`on_room_member_activity`](/user-guide/features/hooks#on_room_member_activity) hook with room, member and turn coordinates, so community clients can build tool cards and live member status on top of Group Chat without reading Hermes internals.