The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): resolve Group Chat member identity by owning connection and profile
teknium1f9cc4ce975c5
diff --git a/apps/desktop/e2e/group-transcript-owner-meta.spec.ts b/apps/desktop/e2e/group-transcript-owner-meta.spec.tsnew file mode 100644index 00000000000..fcbf4694e53--- /dev/null+++ b/apps/desktop/e2e/group-transcript-owner-meta.spec.ts@@ -0,0 +1,121 @@+import { MOCK_REPLY } from '../../../tests-js/scripts/mock-server'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// Group Chat identity follows the OWNER-qualified bot meta (#96432, #101382,+// #102294, #94869): bot meta is persisted under `connectionId::profile`+// (botMetaKey), while the transcript speaker row and the Activity feed used+// to probe the bare profile name — a stale v1 relic at best, nothing for a+// remote or renamed bot at worst. Re-titling a member after the room exists+// is the single-gateway form of the bug: the roster repaints, the room does+// not. The room log itself is untouched by this — only presentation moves.++const ROOM = 'Ops Room'+const NEW_TITLE = 'Infra Ops'+const SHOTS = '/tmp/batchbots/group-identity-members/shots'+let fixture: MockBackendFixture | null = null++type Page = MockBackendFixture['page']++const roster = (page: Page) => page.locator('[data-slot="bots-roster"]')+const botRow = (page: Page, name: string) => roster(page).locator(`[data-roster-key="local::${name}"]`)+const speakerLabels = (page: Page) => page.locator('button[title="Show full handle"]')++async function openBots(page: Page): Promise<void> {+ 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()+}++async function createAgent(page: Page, name: string, title: string): Promise<void> {+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Bot' }).click()+ const dialog = page.getByRole('dialog', { name: 'New Bot' })+ await dialog.getByPlaceholder('inbox-triage').fill(name)+ await dialog.getByPlaceholder('Inbox Triage').fill(title)+ await dialog.getByRole('button', { name: 'Create Bot' }).click()+ await expect(dialog).toBeHidden({ timeout: 30_000 })+ await expect(botRow(page, name)).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: Page) {+ await openBots(page)+ await createAgent(page, 'programmer', 'Programmer')+ await createAgent(page, 'reviewer', 'Reviewer')+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New Group Chat' }).click()+ const dialog = page.getByRole('dialog', { name: 'New Group Chat' })++ for (const title of ['Programmer', 'Reviewer']) {+ await dialog.getByText(title, { exact: true }).locator('xpath=ancestor::label').getByRole('checkbox').click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill(ROOM)+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()+ const composer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })+ await expect(composer).toBeVisible({ timeout: 20_000 })++ return composer+}++async function storedMeta(page: Page) {+ return page.evaluate(() => {+ const meta = JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.bot-meta-v2') || '{}')++ return { bare: meta.programmer?.title ?? null, routed: meta['local::programmer']?.title ?? null }+ })+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({ mockServer: { replyForPrompt: () => MOCK_REPLY } })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a re-titled member is re-labelled in the room transcript and Activity feed', async () => {+ test.setTimeout(300_000)+ const page = fixture!.page+ const composer = await createRoom(page)++ await composer.fill('@programmer hello')+ await composer.press('Enter')+ await expect(page.getByText(MOCK_REPLY, { exact: true }).first()).toBeVisible({ timeout: 90_000 })+ await expect(speakerLabels(page).first()).toHaveText('Programmer')+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0)++ // Re-title the member through the real Edit dialog. The write lands on the+ // route-qualified key (`local::programmer`); the bare-name relic keeps the+ // old title — exactly the two-slot store reporters found in leveldb.+ await botRow(page, 'programmer').click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Edit…' }).click()+ const edit = page.getByRole('dialog', { name: 'Edit profile' })+ await expect(edit).toBeVisible({ timeout: 30_000 })+ // The Title input's placeholder is the bot's current display name.+ await edit.getByPlaceholder('Programmer').fill(NEW_TITLE)+ await edit.getByRole('button', { name: 'Save' }).click()+ await expect(edit).toBeHidden({ timeout: 30_000 })+ await expect(botRow(page, 'programmer')).toContainText(NEW_TITLE, { timeout: 30_000 })+ await expect.poll(async () => (await storedMeta(page)).routed, { timeout: 15_000 }).toBe(NEW_TITLE)+ expect((await storedMeta(page)).bare).toBe('Programmer')++ // The room must show the same identity the roster does.+ await expect(speakerLabels(page).first()).toHaveText(NEW_TITLE, { timeout: 15_000 })+ await page.getByRole('button', { name: /^Activity/ }).click()+ await expect(page.getByText(`${NEW_TITLE} replied`, { exact: true })).toBeVisible({ timeout: 15_000 })+ await expect(page.getByText('Programmer replied', { exact: true })).toHaveCount(0)+ await page.screenshot({ path: `${SHOTS}/group-transcript-owner-meta-after.png` })++ // Control: the user's own lines never pick up bot meta, and the durable+ // room log still stores the profile id, not the title.+ await expect(page.getByText('You', { exact: true }).first()).toBeVisible()+ const logFrom = await page.evaluate(+ room => (JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.group-chats') || '{}')[room]?.log || []).map((entry: any) => entry.from.name),+ ROOM+ )+ expect(logFrom).toEqual(['You', 'programmer'])+})diff --git a/apps/desktop/src/plugins/hermes-bots/group-activity.test.ts b/apps/desktop/src/plugins/hermes-bots/group-activity.test.tsindex 18123653795..c3734144c6c 100644--- a/apps/desktop/src/plugins/hermes-bots/group-activity.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-activity.test.ts@@ -92,6 +92,35 @@ describe('turn arc', () => {expect(events.find(event => event.kind === 'replied')?.member).toBe('research')})+ it('records source-scoped members by member key and labels them through their owner meta', async () => {+ // #94869 / #102294: bot meta lives under `connectionId::profile`, so an+ // activity row recorded by bare name could neither find the title nor+ // tell two same-named connections apart.+ const room = await loadRoom({ turn: () => 'on it' })++ const scoped: GroupMember = {+ connectionId: 'local',+ connectionKind: 'local',+ connectionLabel: 'This device',+ name: 'research',+ route: { connectionId: 'local', mode: 'local', profile: 'research', targetProfile: 'research' },+ sourceScoped: true,+ title: ''+ }++ room.data.$botMeta.set({ 'local::research': { title: 'Radar' } })+ room.data.$lastRoster.set([scoped])++ room.rounds.sendToGroupChat('Scoped', [scoped], 'status?')+ await drain(() => Boolean(room.chat.$groupChats.get().Scoped?.running))++ const events = feed(room, 'Scoped').filter(event => event.member && event.member !== 'You')++ expect(events.length).toBeGreaterThan(0)+ expect(events.every(event => event.member === 'local::research')).toBe(true)+ expect(events.map(event => room.activity.groupActivityLabel(event))).toContain('Radar replied')+ })+it('a failed member turn records failed instead of a phantom reply', async () => {const room = await loadRoom({turn: ({ profile }) => {diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsxindex 382a9a2868a..ef7607a2124 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx@@ -745,7 +745,7 @@ export function GroupChatWorkspace({ group, members, onBack, visible = true }: Greturn (seated.length ? seated : members).map(b => ({...b,- title: (b.remoteSource ? '' : allMeta[b.name]?.title) || b.title || ''+ title: botRosterMeta(b, allMeta)?.title || b.title || ''}))}diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat.test.ts b/apps/desktop/src/plugins/hermes-bots/group-chat.test.tsindex 87333b90aa0..b0bf06152a5 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-chat.test.ts@@ -182,6 +182,35 @@ describe('speaker labels', () => {expect(chat.groupSpeakerLabel('builder')).toBe('builder')})+ it('resolve member keys through the owner meta and qualify same-named twins', async () => {+ const { chat } = await loadRoom()+ const data = await import('./data')++ const local = { connectionId: 'local', connectionLabel: 'This device', name: 'reviewer', sourceScoped: true }+ const spark = { connectionId: 'spark', connectionLabel: 'Spark', name: 'reviewer', remoteSource: true, sourceScoped: true }++ data.$lastRoster.set([local, spark])+ data.$botMeta.set({})++ // Two untitled `reviewer`s resolve to the same label — qualify both.+ expect(chat.groupSpeakerLabel('local::reviewer')).toBe('Reviewer · This device')+ expect(chat.groupSpeakerLabel('spark::reviewer')).toBe('Reviewer · Spark')++ // A route-keyed title (how botMetaKey persists it) resolves for its+ // owner only, and the twins stop colliding.+ data.$botMeta.set({ 'spark::reviewer': { title: 'Beta' } })++ expect(chat.groupSpeakerLabel('spark::reviewer')).toBe('Beta')+ expect(chat.groupSpeakerLabel('local::reviewer')).toBe('Reviewer')++ // A raw-name caller (legacy rooms, the round prompt) reaches the same+ // route-keyed title when exactly one roster row carries the name.+ data.$lastRoster.set([{ connectionId: 'local', name: 'research', sourceScoped: true }])+ data.$botMeta.set({ 'local::research': { title: 'Radar' } })++ expect(chat.groupSpeakerLabel('research')).toBe('Radar')+ })+it("never borrow a remote row's display_name for a local speaker", async () => {const { chat } = await loadRoom()const data = await import('./data')diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat.ts b/apps/desktop/src/plugins/hermes-bots/group-chat.tsindex f9b6e311ae2..7dec5f70f3e 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-chat.ts@@ -13,6 +13,8 @@ import { atom, host } from '@hermes/plugin-sdk'import { $botMeta, $lastRoster, botRosterKey } from './data'import { groupMemberReferencesConnection, markOrphanedGroupMemberDescriptor } from './hygiene'+import { displayName } from './labels'+import { botRosterMeta } from './routing'import { getPluginCtx } from './shared'import type {Attachment,@@ -1221,7 +1223,7 @@ export const GROUP_CHAT_MAX_CONTINUATIONS = 2export const GROUP_CHAT_HISTORY_LIMIT = 24export const GROUP_CHAT_MAX_MEMBERS = 6-/** Transcript form of a room speaker's profile name. Friendly identity wins:+/** Transcript form of a room speaker's identity. Friendly identity wins:* a Bot Mode title or a core profile display_name (e.g. default renamed to* "Lucy") labels the speaker everywhere this helper feeds — the "X is* thinking…" working line, the activity feed, and transcript lines — so a@@ -1229,7 +1231,16 @@ export const GROUP_CHAT_MAX_MEMBERS = 6* (community report, Aug 21 2026: renamed default still read "Hermes is* thinking…" in group rooms). The untitled primary profile is literally* named "default" — render it as Hermes (matching displayName and the- * @hermes handle) so the main agent never loses its name in rooms. */+ * @hermes handle) so the main agent never loses its name in rooms.+ *+ * Accepts either a member key (`connectionId::profile`, what the activity+ * feed records) or a raw profile name (legacy rooms, the round prompt).+ * Bot meta is persisted under the route-qualified key (botMetaKey), so a+ * keyed caller resolves through the exact roster row + botRosterMeta — the+ * same pipeline the Bots tab renders — and a raw name resolves the same+ * way when exactly one roster row carries it. Same-named members on two+ * connections that resolve to the same label get their connection label+ * appended, so two failing `default`s are never one anonymous "Hermes". */export function groupSpeakerLabel(name?: null | string) {const trimmed = (name || '').trim()@@ -1237,29 +1248,45 @@ export function groupSpeakerLabel(name?: null | string) {return trimmed}- // Bot Mode title (edit dialog) — same first rung as displayName().- const title = String($botMeta.get()?.[trimmed]?.title || '').trim()+ const roster = $lastRoster.get()+ const rows: RosterRow[] = Array.isArray(roster) ? roster.filter(Boolean) : []+ const meta = $botMeta.get()+ const friendly = (bot: RosterRow) => displayName(bot, botRosterMeta(bot, meta))- if (title) {- return title+ const exact = rows.find(bot => botRosterKey(bot) === trimmed)++ if (exact) {+ const label = friendly(exact)+ const twin = rows.some(bot => bot !== exact && bot.name === exact.name && friendly(bot) === label)++ return twin ? `${label} · ${exact.connectionLabel || exact.connectionId}` : label}- // Core profile display_name (`hermes profile rename …` / dashboard) from- // the ACTIVE gateway's roster row. Source-scoped remote speakers carry- // their device suffix separately and keep their raw name here.- const roster = $lastRoster.get()+ // A raw `default` names the ACTIVE gateway's primary profile — it must+ // never borrow a remote default's identity, so only a local row counts.+ const isDefault = trimmed.toLowerCase() === 'default'+ const named = rows.filter(bot => bot.name === trimmed && !(isDefault && (bot.remoteSource || bot.sourceScoped)))- const row = Array.isArray(roster)- ? roster.find(bot => bot?.name === trimmed && !bot?.remoteSource && !bot?.sourceScoped)- : null+ if (named.length === 1) {+ return friendly(named[0])+ }++ // Legacy rungs for names the roster cannot place: a bare-keyed Bot Mode+ // title, then the local row's display_name, then default → Hermes.+ const title = String(meta?.[trimmed]?.title || '').trim()++ if (title) {+ return title+ }+ const row = rows.find(bot => bot.name === trimmed && !bot.remoteSource && !bot.sourceScoped)const renamed = typeof row?.display_name === 'string' ? row.display_name.trim() : ''if (renamed) {return renamed}- return trimmed.toLowerCase() === 'default' ? 'Hermes' : trimmed+ return isDefault ? 'Hermes' : trimmed}/** Trim a room log + its watermarks to the retained window, keepingdiff --git a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts b/apps/desktop/src/plugins/hermes-bots/group-round-members.tsindex 08207617e3d..a9f548aba7a 100644--- a/apps/desktop/src/plugins/hermes-bots/group-round-members.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-round-members.ts@@ -82,7 +82,7 @@ function prepareGroupRoundMember(context: GroupRoundMemberContext, member: Groupif (!heldEntry.noted) {recordGroupActivity(context.group, {kind: 'held',- member: member.name,+ member: groupMemberKey(member),thread})}@@ -165,7 +165,7 @@ export async function runGroupRoundMember(const reason = String(error?.data?.reason || '').trim()recordGroupActivity(context.group, {kind: 'failed',- member: member.name,+ member: groupMemberKey(member),thread,...(reason? {@@ -213,7 +213,7 @@ export async function runGroupRoundMember() {recordGroupActivity(context.group, {kind: 'cancelled',- member: member.name,+ member: groupMemberKey(member),thread})diff --git a/apps/desktop/src/plugins/hermes-bots/group-turns.ts b/apps/desktop/src/plugins/hermes-bots/group-turns.tsindex 5e02d3e43c1..cd7f5f22992 100644--- a/apps/desktop/src/plugins/hermes-bots/group-turns.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-turns.ts@@ -884,7 +884,7 @@ async function pollGroupMemberTurn(context: GroupTurnPollContext): Promise<nullif (replyText !== null) {recordGroupActivity(context.group, {kind: isGroupPassText(replyText) ? 'passed' : 'replied',- member: member.name,+ member: groupMemberKey(member),thread})@@ -893,7 +893,7 @@ async function pollGroupMemberTurn(context: GroupTurnPollContext): Promise<nullrecordGroupActivity(context.group, {kind: 'passed',- member: member.name,+ member: groupMemberKey(member),thread})@@ -918,7 +918,7 @@ async function pollGroupMemberTurn(context: GroupTurnPollContext): Promise<null// thread instead of vanishing.recordGroupActivity(context.group, {kind: 'timed-out',- member: member.name,+ member: groupMemberKey(member),thread})syncGroupClarify(context.group, member, thread, null)@@ -989,7 +989,7 @@ async function runGroupChatMemberTurnLeased(const dispatchEpoch = ($groupChats.get()[group] || {}).epoch || 0recordGroupActivity(group, {kind: 'working',- member: member.name,+ member: groupMemberKey(member),thread})@@ -1103,7 +1103,7 @@ export async function harvestStrandedGroupReply(group: string, member: GroupMembif (reply && !isGroupPassText(reply)) {recordGroupActivity(group, {kind: 'delivered',- member: member.name,+ member: groupMemberKey(member),thread: strandedThread})appendGroupChatEntry(diff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.mdindex 707f9da352b..52523707346 100644--- a/website/docs/user-guide/bot-mode.md+++ b/website/docs/user-guide/bot-mode.md@@ -135,6 +135,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. 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 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.## Bot-to-bot messaging