The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): pin a group chat to the top of the Bots roster
teknium12679f4772708
diff --git a/apps/desktop/e2e/bot-roster-group-row-organisation.spec.ts b/apps/desktop/e2e/bot-roster-group-row-organisation.spec.tsnew file mode 100644index 00000000000..2c02bf92f69--- /dev/null+++ b/apps/desktop/e2e/bot-roster-group-row-organisation.spec.ts@@ -0,0 +1,184 @@+import fs from 'node:fs'+import path from 'node:path'++import { startMockServer } from '../../../tests-js/scripts/mock-server'++import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig+} from './fixtures'+import { RealSessionBuilder } from './real-session-builder'+import { expect, test } from './test'++// A group chat's roster row gets the same organisation affordances a bot row+// has: right-click → Pin to top floats the room above unpinned rows and+// persists on the room record; right-click → Move to section files the room+// into a user-made section, with membership riding the durable group-chats+// record rather than any bot's profile meta (hermes-agent#89813, #105544).++type Page = MockBackendFixture['page']++let fixture: MockBackendFixture | null = null++// BOT_GROUP_ROW_SCREENSHOT_DIR=<dir> saves full-window captures at the key+// states — PR evidence; never part of the assertions.+async function capture(page: Page, name: string): Promise<void> {+ const dir = process.env.BOT_GROUP_ROW_SCREENSHOT_DIR++ if (!dir) {+ return+ }++ fs.mkdirSync(dir, { recursive: true })+ await page.screenshot({ path: path.join(dir, `${name}.png`) })+}++async function seedBot(hermesHome: string, mockUrl: string, name: string): Promise<void> {+ const dir = path.join(hermesHome, 'profiles', name)+ fs.mkdirSync(dir, { recursive: true })+ writeMockProviderConfig(dir, mockUrl)+ writeEnvFile(dir)++ const builder = await RealSessionBuilder.start(dir)++ try {+ await builder.createSession({ title: 'Bot Chat', turns: [`Hello ${name}`] })+ } finally {+ await builder.close()+ }+}++const ROOM = 'Standup'++const roster = (page: Page) => page.locator('[data-slot="bots-roster"]')+const groupRow = (page: Page) => roster(page).getByRole('button', { name: new RegExp(`^${ROOM}, `) })+const sectionLabel = (page: Page, name: string) => page.locator('span.truncate', { hasText: new RegExp(`^${name}$`, 'i') })++const sectionBlock = (page: Page, name: string) =>+ roster(page).locator('[data-slot="bots-section"]').filter({ has: sectionLabel(page, name) })++/** Roster rows top to bottom: bot rows by roster key, the room by its label. */+async function rowOrder(page: Page): Promise<string[]> {+ return roster(page)+ .locator(`[data-roster-key], button[aria-label^="${ROOM},"]`)+ .evaluateAll(rows => rows.map(row => (row as HTMLElement).dataset.rosterKey || 'group'))+}++async function storedRoom(page: Page): Promise<{ pinned?: boolean; sectionId?: null | string }> {+ return page.evaluate(+ room => JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.group-chats') || '{}')[room] || {},+ ROOM+ )+}++test.beforeAll(async () => {+ const mock = await startMockServer()+ const sandbox = createSandbox('bots-group-row')+ writeMockProviderConfig(sandbox.hermesHome, mock.url)+ writeEnvFile(sandbox.hermesHome)++ for (const name of ['alpha', 'beta']) {+ await seedBot(sandbox.hermesHome, mock.url, name)+ }++ const { app, page } = await launchDesktop(buildAppEnv(sandbox))++ fixture = {+ app,+ page,+ mock,+ mockUrl: mock.url,+ sandbox,+ cleanup: async () => {+ await app.close().catch(() => undefined)+ await mock.close()+ sandbox.cleanup()+ }+ }+ await waitForAppReady(fixture, 120_000)+})++test.afterAll(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a group chat row pins to the top and files into a user section like a bot row', async () => {+ test.setTimeout(300_000)+ const page = fixture!.page++ 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()+ await expect(roster(page).locator('[data-roster-key="local::alpha"]')).toBeVisible({ timeout: 30_000 })+ await expect(roster(page).locator('[data-roster-key="local::beta"]')).toBeVisible({ timeout: 30_000 })++ // Make a room from the two bots.+ 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 name of ['Alpha @alpha', 'Beta @beta']) {+ await dialog.getByRole('checkbox', { name }).click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill(ROOM)+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()+ await expect(dialog).toBeHidden({ timeout: 30_000 })++ // Back to the roster: the fresh, quiet room sinks under the bots that have+ // history, so a pin has something to change.+ await tab.click()+ await expect(groupRow(page)).toBeVisible({ timeout: 30_000 })+ await expect.poll(() => rowOrder(page).then(rows => rows.at(-1))).toBe('group')+ await capture(page, '1-room-unpinned-last')++ await groupRow(page).click({ button: 'right' })+ await expect(page.getByRole('menuitem', { name: 'Pin to top' })).toBeVisible()+ await capture(page, '2-group-row-menu')+ await page.getByRole('menuitem', { name: 'Pin to top' }).click()++ await expect.poll(() => rowOrder(page).then(rows => rows[0])).toBe('group')+ await expect(groupRow(page).locator('.codicon-pinned')).toHaveCount(1)+ // Storage truth: the flag is on the room record, where a reload hydrates it.+ await expect.poll(async () => (await storedRoom(page)).pinned).toBe(true)+ await capture(page, '3-room-pinned-first')++ // Unpin through the same item — the room sinks again.+ await groupRow(page).click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Unpin' }).click()+ await expect.poll(() => rowOrder(page).then(rows => rows.at(-1))).toBe('group')+ await expect.poll(async () => (await storedRoom(page)).pinned).toBe(false)++ // File the room into a brand-new section from its own menu.+ await groupRow(page).click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Move to section' }).hover()+ await expect(page.getByRole('menuitem', { name: 'New section…' })).toBeVisible()+ await capture(page, '4-group-row-move-to-section')+ await page.getByRole('menuitem', { name: 'New section…' }).click()+ const nameField = page.getByRole('textbox', { name: 'Section name' })+ await nameField.fill('Rooms')+ await page.getByRole('button', { name: 'Create' }).click()++ await expect(sectionBlock(page, 'Rooms').getByRole('button', { name: new RegExp(`^${ROOM}, `) })).toBeVisible()+ await expect(sectionBlock(page, 'Unassigned').getByRole('button', { name: new RegExp(`^${ROOM}, `) })).toHaveCount(0)+ await expect.poll(async () => (await storedRoom(page)).sectionId).toMatch(/^sec-/)+ await capture(page, '5-room-filed-into-rooms')++ // Remove from section returns it to the unassigned bucket.+ await groupRow(page).click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Move to section' }).hover()+ await page.getByRole('menuitem', { name: 'Remove from section' }).click()+ await expect(sectionBlock(page, 'Unassigned').getByRole('button', { name: new RegExp(`^${ROOM}, `) })).toBeVisible()+ await expect.poll(async () => (await storedRoom(page)).sectionId).toBeNull()+ await capture(page, '6-room-unfiled')+})diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.tsxindex 2b4e671b9c2..77ab9adc5ce 100644--- a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.tsx@@ -56,6 +56,7 @@ import {} from './data'import { $groupChats, $groupChatWorkspace } from './group-chat'import { botGroups, groupLastActivity } from './group-membership'+import { toggleGroupChatPinned } from './group-pin'import { $activeGroupMemberKeys } from './group-presence'import { fallbackSelectionAfterHide, isBotHidden, isBotPinned } from './hidden-bots'import { useBots } from './i18n'@@ -558,6 +559,11 @@ export function GroupRow({ active, group, members, needsYou, onOpen, onDisband,<div className="min-w-0 flex-1"><div className="flex items-baseline justify-between gap-2"><span className="min-w-0 flex-1 truncate text-[0.8125rem] font-medium">{group}</span>+ {room.pinned ? (+ <Tip label={b.roster.pinned}>+ <Codicon className="shrink-0 text-[0.6875rem] text-(--ui-text-quaternary)" name="pinned" />+ </Tip>+ ) : null}{needsYou ? (<Tip label={b.group.needsYourInput}><Codicon aria-label={b.roster.needsInput} className="shrink-0 text-(--ui-accent)" name="question" />@@ -580,6 +586,19 @@ export function GroupRow({ active, group, members, needsYou, onOpen, onDisband,<ContextMenuContent><ContextMenuItem onSelect={() => onOpen(group)}>Open Group Chat</ContextMenuItem><ContextMenuSeparator />+ {/* Same affordance as a bot row's pin; pinned rooms lead the roster+ band, and the flag lives on the room record. */}+ <ContextMenuItem+ onSelect={() => {+ const pinned = toggleGroupChatPinned(group)++ if (pinned !== null) {+ host.notify({ kind: 'info', message: `${group} ${pinned ? 'pinned to top' : 'unpinned'}` })+ }+ }}+ >+ {room.pinned ? 'Unpin' : 'Pin to top'}+ </ContextMenuItem>{/* Filing — the same submenu a bot row gets, driving the room-recordassignment instead of profile meta. */}<ContextMenuSub>diff --git a/apps/desktop/src/plugins/hermes-bots/group-pin.test.ts b/apps/desktop/src/plugins/hermes-bots/group-pin.test.tsnew file mode 100644index 00000000000..55af0715d3d--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/group-pin.test.ts@@ -0,0 +1,63 @@+/**+ * "Pin to top" for group chats (hermes-agent#89813): the flag the roster sort+ * already honours gets a write site on the room record, and the pin survives+ * a reload through the same durable group-chats persistence the room uses —+ * never through any bot's profile meta.+ */++import { beforeEach, describe, expect, it, vi } from 'vitest'++const { storage } = vi.hoisted(() => ({ storage: new Map<string, unknown>() }))++vi.mock('@hermes/plugin-sdk', async () => {+ const { atom } = await import('nanostores')++ return { atom, host: {} }+})++vi.mock('./data', async () => {+ const { atom } = await import('nanostores')++ return { $botMeta: atom({}), $lastRoster: atom([]), botRosterKey: (bot: { name?: string }) => `legacy::${bot?.name}` }+})++vi.mock('./routing', () => ({ botRosterMeta: () => undefined }))++vi.mock('./shared', () => ({+ getPluginCtx: () => ({+ storage: {+ get: (key: string, fallback: unknown) => (storage.has(key) ? storage.get(key) : fallback),+ set: (key: string, value: unknown) => storage.set(key, value)+ }+ })+}))++import { $groupChats } from './group-chat'+import { sortGroupRosterRows } from './group-order'+import { toggleGroupChatPinned } from './group-pin'++beforeEach(() => {+ storage.clear()+ $groupChats.set({ Standup: { log: [], watermarks: {}, sessions: {}, stranded: {}, members: [] } as never })+})++describe('group chat pin', () => {+ it('pins the room record durably and floats the room above unpinned rows; a second toggle unpins', () => {+ expect(toggleGroupChatPinned('Standup')).toBe(true)+ expect($groupChats.get().Standup.pinned).toBe(true)+ expect((storage.get('group-chats') as Record<string, { pinned?: boolean }>).Standup.pinned).toBe(true)++ const rows = [+ { kind: 'bot' as const, name: 'busy-bot', pinned: false, activity: 900 },+ { kind: 'group' as const, name: 'Standup', pinned: Boolean($groupChats.get().Standup.pinned), activity: 100 }+ ]++ expect(sortGroupRosterRows(rows, $groupChats.get()).map(row => row.name)).toEqual(['Standup', 'busy-bot'])++ expect(toggleGroupChatPinned('Standup')).toBe(false)+ expect((storage.get('group-chats') as Record<string, { pinned?: boolean }>).Standup.pinned).toBe(false)+ // A room that no longer exists is not resurrected by a stale menu.+ expect(toggleGroupChatPinned('Gone')).toBeNull()+ expect($groupChats.get().Gone).toBeUndefined()+ })+})diff --git a/apps/desktop/src/plugins/hermes-bots/group-pin.ts b/apps/desktop/src/plugins/hermes-bots/group-pin.tsnew file mode 100644index 00000000000..da9c56d44c4--- /dev/null+++ b/apps/desktop/src/plugins/hermes-bots/group-pin.ts@@ -0,0 +1,21 @@+import { $groupChats, updateGroupChat } from './group-chat'++/** Flip a group chat's "Pin to top" flag (hermes-agent#89813). The roster+ * sort already treats `room.pinned` as the outer band for group rows, the+ * same way `bot-meta.pinned` leads bot rows; this is the write site that flag+ * never had. Presentation only: the room record is the group's sole durable+ * identity, so the pin rides the local group-chats persistence like+ * `rosterOrder` and stays out of the gateway conversation mirror.+ * Returns the new pinned state, or null when the room is gone. */+export function toggleGroupChatPinned(name: string): boolean | null {+ const room = $groupChats.get()[name]++ if (!room || room.tombstone) {+ return null+ }++ const pinned = !room.pinned+ updateGroupChat(name, current => ({ ...current, pinned }), { sync: false })++ return pinned+}diff --git a/apps/desktop/src/plugins/hermes-bots/types.ts b/apps/desktop/src/plugins/hermes-bots/types.tsindex 642b3865e21..823163d41ae 100644--- a/apps/desktop/src/plugins/hermes-bots/types.ts+++ b/apps/desktop/src/plugins/hermes-bots/types.ts@@ -178,7 +178,7 @@ export interface GroupChat {tombstone?: boolean/** Local display order, deliberately excluded from the gateway mirror. */rosterOrder?: number- /** Read when ordering rooms; no write site in the plugin today. */+ /** "Pin to top" on the room row (`group-pin.ts`); the outer band of the room order. */pinned?: boolean/** Which user-made sidebar section this group chat is filed under* (`user-sections.ts`). Like a bot's `sectionId` it is membership on thediff --git a/apps/desktop/src/plugins/hermes-bots/user-sections.ts b/apps/desktop/src/plugins/hermes-bots/user-sections.tsindex 9edb7d0b0fa..cb1a0609d63 100644--- a/apps/desktop/src/plugins/hermes-bots/user-sections.ts+++ b/apps/desktop/src/plugins/hermes-bots/user-sections.ts@@ -267,6 +267,7 @@ export function groupRowsBySection<TRow extends { bot?: RosterRow } | RosterRow>for (const row of rows || []) {const group = (row as { kind?: string; name?: string })?.kind === 'group' ? row : null+const id = group? groupChatSectionId(String((group as { name?: string }).name || ''), groupRooms): botSectionId((((row as { bot?: RosterRow })?.bot || row) as RosterRow), metaByName)diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..4f56db59d50--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+tobenwarriordiff --git a/website/docs/user-guide/bot-mode.md b/website/docs/user-guide/bot-mode.mdindex 8200f5b38a3..be41a8fee09 100644--- a/website/docs/user-guide/bot-mode.md+++ b/website/docs/user-guide/bot-mode.md@@ -114,6 +114,8 @@ A group's identity is editable, at creation and after:Groups are standalone rows in the same activity-ordered roster as Bot DMs. A Bot keeps one DM row even when it belongs to several groups, while every group gets its own room row with member count, latest-message preview, timestamp, and needs-you state.+A room row organizes like a Bot row. Right-click it → **Pin to top** to keep a daily-driver room above the unpinned Bots and rooms (**Unpin** puts it back into recency order); the pin is saved with the room on this Desktop. Right-click → **Move to section** files the room into one of your [sections](#organize-bots-into-sections) — or drag the row onto a section heading — and **Remove from section** returns it to the group-chat bucket. A room's section is stored on its room record (rooms have no profile), so it stays local to this Desktop like the section list itself.+Use the **Move up** and **Move down** arrows beside a room to choose its position among rooms. Until the first move, the existing pinned-first, recent-activity order is unchanged. After a move, room order is saved on this Desktop and survives reloads; new rooms follow the explicitly ordered rooms within their pinned or unpinned band. Moves cannot cross the pinned boundary, and filtering does not discard hidden rooms from the saved order. These controls reorder actual Group Chat rooms, not user-created Bot folders, and do not change membership or gateway ownership.**Open chat** on any group row (2–6 Bots) opens a shared room where the whole group coordinates: