The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: restore Desktop bot/group Playwright specs dropped by #120071
teknium1d947b6f73c48
diff --git a/apps/desktop/e2e/bot-mode-tab-shows-bot-name.spec.ts b/apps/desktop/e2e/bot-mode-tab-shows-bot-name.spec.tsnew file mode 100644index 00000000000..8eac23c5a1f--- /dev/null+++ b/apps/desktop/e2e/bot-mode-tab-shows-bot-name.spec.ts@@ -0,0 +1,137 @@+import fs from 'node:fs'+import path from 'node:path'++import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig+} from './fixtures'+import { MOCK_REPLY, startMockServer } from '../../../tests-js/scripts/mock-server'+import { RealSessionBuilder } from './real-session-builder'+import { expect, test } from './test'++// Every bot's canonical chat is STORED under the same title ("Bot Chat" — the+// name the gateway resolves it by), so the main tab strip captioned every open+// bot chat identically and two bots' tabs were indistinguishable (#99152). The+// tab must read the bot's display name while the stored title stays canonical.++type Page = MockBackendFixture['page']++let fixture: MockBackendFixture | null = null++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 openUntil(action: () => Promise<void>, expected: () => Promise<void>, attempts = 3): Promise<void> {+ for (let attempt = 1; ; attempt += 1) {+ await action()++ try {+ await expected()++ return+ } catch (error) {+ if (attempt >= attempts) {+ throw error+ }+ }+ }+}++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()+ }+}++/** Every tab caption in the main strip (the main `workspace` tab + tiles). */+function mainStripTabTitles(page: Page): Promise<string[]> {+ return page.evaluate(() =>+ [...document.querySelectorAll<HTMLElement>('[data-zone-tabstrip="grp-main"] [data-tree-tab]')].map(element =>+ (element.textContent ?? '').trim()+ )+ )+}++test.beforeAll(async () => {+ const mock = await startMockServer()+ const sandbox = createSandbox('bots-tabname')+ writeMockProviderConfig(sandbox.hermesHome, mock.url)+ writeEnvFile(sandbox.hermesHome)+ await seedBot(sandbox.hermesHome, mock.url, 'alpha')+ await seedBot(sandbox.hermesHome, mock.url, 'beta')++ 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("an open Bot Chat's tab reads the bot's name, not the canonical 'Bot Chat' title", async () => {+ test.setTimeout(300_000)+ const page = fixture!.page++ await openBots(page)++ const alphaRow = page.getByRole('button', { name: /^alpha\b/i }).filter({ visible: true }).first()+ await expect(alphaRow).toBeVisible({ timeout: 30_000 })++ await openUntil(+ () => alphaRow.click(),+ () =>+ expect(page.getByText('Hello alpha', { exact: true }).filter({ visible: true }).first()).toBeVisible({+ timeout: 45_000+ })+ )++ // A `+` side thread beside the Bot Chat gives the main zone a tab strip —+ // the surface where every bot chat used to read "Bot Chat".+ await page.keyboard.press('Control+t')+ const composer = page.locator('[data-slot="composer-root"] [contenteditable="true"]').filter({ visible: true }).first()+ await expect(composer).toBeVisible({ timeout: 15_000 })+ await composer.click()+ await composer.fill('hello alpha thread')+ await page.keyboard.press('Enter')+ await expect(page.getByText(MOCK_REPLY).filter({ visible: true }).first()).toBeVisible({ timeout: 60_000 })++ await expect.poll(() => mainStripTabTitles(page), { timeout: 15_000 }).toHaveLength(2)+ const captions = await mainStripTabTitles(page)+ expect(captions.some(caption => /alpha/i.test(caption))).toBe(true)+ expect(captions.some(caption => /bot chat/i.test(caption))).toBe(false)+})diff --git a/apps/desktop/e2e/bot-tile-ignores-ambient-composer-model.spec.ts b/apps/desktop/e2e/bot-tile-ignores-ambient-composer-model.spec.tsnew file mode 100644index 00000000000..5f1a95fc896--- /dev/null+++ b/apps/desktop/e2e/bot-tile-ignores-ambient-composer-model.spec.ts@@ -0,0 +1,169 @@+import fs from 'node:fs'+import path from 'node:path'++import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig+} from './fixtures'+import { MOCK_REPLY, startMockServer } from '../../../tests-js/scripts/mock-server'+import { RealSessionBuilder } from './real-session-builder'+import { expect, test } from './test'++// A manual model pick in the composer is sticky for ordinary new chats. A `+`+// chat opened beside a bot in Bot Mode targets that bot's profile without+// switching the window's ambient composer, so a pick made for some other open+// session must NOT ride into the bot's session.create: the bot profile's+// configured default model is what the new chat's inference request carries+// (#95264).++type Page = MockBackendFixture['page']++const AMBIENT_PICK = 'ambient-pick-model'++let fixture: MockBackendFixture | null = null++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 settle(page: Page, timeout = 90_000): Promise<void> {+ await page+ .getByText(/Waking up/i)+ .first()+ .waitFor({ state: 'hidden', timeout })+ .catch(() => undefined)+ await page.waitForTimeout(500)+}++async function openUntil(action: () => Promise<void>, expected: () => Promise<void>, attempts = 3): Promise<void> {+ for (let attempt = 1; ; attempt += 1) {+ await action()++ try {+ await expected()++ return+ } catch (error) {+ if (attempt >= attempts) {+ throw error+ }+ }+ }+}++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()+ }+}++test.beforeAll(async () => {+ const mock = await startMockServer({ extraModels: [AMBIENT_PICK] })+ const sandbox = createSandbox('bot-tile-model')+ writeMockProviderConfig(sandbox.hermesHome, mock.url)+ writeEnvFile(sandbox.hermesHome)+ await seedBot(sandbox.hermesHome, mock.url, 'alpha')++ 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 bot's `+` chat runs on the bot profile's model, not the ambient composer pick", async ({}, testInfo) => {+ test.setTimeout(300_000)+ const page = fixture!.page+ const mock = fixture!.mock++ await openBots(page)++ const alphaRow = page+ .getByRole('button', { name: /^alpha\b/i })+ .filter({ visible: true })+ .first()+ await expect(alphaRow).toBeVisible({ timeout: 30_000 })+ await openUntil(+ () => alphaRow.click(),+ () =>+ expect(page.getByText('Hello alpha', { exact: true }).filter({ visible: true }).first()).toBeVisible({+ timeout: 45_000+ })+ )++ await settle(page, 15_000)++ // A manual pick while the bot's canonical chat is open: the window's ambient+ // composer now holds a model that is NOT the profile default. Rows are+ // hover-submenu triggers (reasoning/fast edit); Enter on the row commits.+ await page+ .getByRole('button', { name: /^Model ·/ })+ .first()+ .click()+ await page.getByRole('textbox', { name: 'Search models' }).fill('ambient pick')+ const row = page.getByRole('menuitem', { name: /^Ambient Pick Model/ }).first()+ await expect(row).toBeVisible()+ await row.focus()+ await page.keyboard.press('Enter')+ await expect(page.getByRole('button', { name: /^Model ·/ }).first()).toHaveAccessibleName(new RegExp(AMBIENT_PICK), {+ timeout: 15_000+ })+ await page.screenshot({ path: testInfo.outputPath('bot-chat-manual-pick.png') })++ // `+` beside the bot: a fresh bots-workspace tile for alpha.+ const before = mock.receivedModels.length+ await page.keyboard.press('Control+t')+ await settle(page)+ const composer = page+ .locator('[data-slot="composer-root"] [contenteditable="true"]')+ .filter({ visible: true })+ .first()+ await expect(composer).toBeVisible({ timeout: 15_000 })+ await composer.click()+ await composer.fill('hello alpha thread')+ await page.keyboard.press('Enter')+ await expect(page.getByText(MOCK_REPLY).filter({ visible: true }).first()).toBeVisible({ timeout: 60_000 })+ await page.screenshot({ path: testInfo.outputPath('bot-tile-after-turn.png') })++ await expect.poll(() => mock.receivedModels.length, { timeout: 15_000 }).toBeGreaterThan(before)+ const models = mock.receivedModels.slice(before)+ // The bot profile's configured default (config.yaml `model.default`), never+ // the window's manual composer pick.+ expect(models).not.toContain(AMBIENT_PICK)+ expect(models).toContain('mock-model')+})diff --git a/apps/desktop/e2e/group-chat-code-block-and-media.spec.ts b/apps/desktop/e2e/group-chat-code-block-and-media.spec.tsnew file mode 100644index 00000000000..945e52e913d--- /dev/null+++ b/apps/desktop/e2e/group-chat-code-block-and-media.spec.ts@@ -0,0 +1,172 @@+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// A bot's group-chat reply was rendered through raw Streamdown, whose stock+// code block lays its header and body out as inline siblings: the code body+// sat shifted right by the header's width and the wrapper's overflow-hidden+// clipped the tail with no scrollbar (#91878). The same raw path never ran the+// Desktop's `MEDIA:` transform, so a bot's `MEDIA:/path/file.png` showed as+// a plain path instead of an inline image/player (#93728). Group replies now+// go through the same message renderer as the 1:1 chat.++const SHOT_DIR = path.join(os.tmpdir(), 'batchbots/panes-layout-cron-tile/shots')+// One unbroken 600+ char token: it cannot wrap, so it MUST overflow the+// message column — the probe asserts that overflow exists before asserting+// nothing clips it (a line that fits proves nothing about #91878).+const LONG_LINE = `const veryLongIdentifierNameForTheGroupChatCodeBlockRepro_${'x'.repeat(600)} = 1`+// 1x1 PNG.+const PNG_BASE64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=='++let fixture: MockBackendFixture | null = null+let mediaPath = ''++function codeReply(): string {+ return ['Here is the draft:', '', '```ts', LONG_LINE, 'export {}', '```', '', `MEDIA:${mediaPath}`].join('\n')+}++async function openBots(page: MockBackendFixture['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: MockBackendFixture['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(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: MockBackendFixture['page']) {+ await openBots(page)+ await createAgent(page, 'writer', 'Writer')+ await createAgent(page, 'editor', 'Editor')++ 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 ['Writer', 'Editor']) {+ await dialog.getByText(title, { exact: true }).locator('xpath=ancestor::label').getByRole('checkbox').click()+ }++ await dialog.getByRole('textbox', { name: 'Group name' }).fill('Writer, Editor')+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()++ const composer = page.getByRole('textbox', { name: 'Message Writer, Editor' }).filter({ visible: true })+ await expect(composer).toBeVisible({ timeout: 20_000 })++ return composer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({+ mockServer: {+ replyForPrompt: prompt => (prompt.includes('CODE_BLOCK_REPRO') ? codeReply() : 'ok')+ }+ })+ mediaPath = path.join(fixture.sandbox.hermesHome, 'group-media.png')+ fs.writeFileSync(mediaPath, Buffer.from(PNG_BASE64, 'base64'))+ fs.mkdirSync(SHOT_DIR, { recursive: true })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a group reply renders its code block inside the message and its MEDIA: line as inline media', async () => {+ test.setTimeout(300_000)+ const page = fixture!.page+ const composer = await createRoom(page)++ await composer.fill('@writer CODE_BLOCK_REPRO')+ await composer.press('Enter')++ // A bot created moments ago runs its intro turn in the background; when it+ // lands, the roster fronts that bot's chat tab and yanks the center away+ // from the room. Re-select the room and read the reply from a room body.+ const roomTab = page.getByRole('tab', { name: /Writer, Editor Close/ })++ const code = page+ .locator('[data-selectable-text="true"]')+ .getByText(/veryLongIdentifierNameForTheGroupChatCodeBlockRepro/)+ .filter({ visible: true })+ .first()++ await expect(async () => {+ if ((await roomTab.getAttribute('aria-selected')) !== 'true') {+ await roomTab.click()+ }++ await expect(code).toBeVisible({ timeout: 5_000 })+ }).toPass({ timeout: 90_000 })+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0, { timeout: 60_000 })+ await page.screenshot({ path: path.join(SHOT_DIR, 'group-chat-code-media.png') })++ const geometry = await code.evaluate(el => {+ const body = el.closest<HTMLElement>('[data-selectable-text="true"]')!+ const bodyRect = body.getBoundingClientRect()+ const pre = el.closest('pre') ?? el+ const preRect = pre.getBoundingClientRect()+ // Every box between the code text and the message body: a box whose+ // content is wider than itself must scroll, never clip — that is the+ // "cut off with no horizontal scrollbar" the report describes.+ const chain: Array<{ tag: string; overflowX: string; scrollWidth: number; clientWidth: number }> = []+ let node: HTMLElement | null = el as HTMLElement++ while (node && node !== body.parentElement) {+ chain.push({+ tag: node.tagName.toLowerCase(),+ overflowX: getComputedStyle(node).overflowX,+ scrollWidth: node.scrollWidth,+ clientWidth: node.clientWidth+ })+ node = node.parentElement+ }++ const clippedWithoutScroll = chain.filter(+ box => box.scrollWidth > box.clientWidth + 1 && !['auto', 'scroll'].includes(box.overflowX)+ )++ const scrollingPre = chain.find(+ box => box.tag === 'pre' && box.scrollWidth > box.clientWidth + 1 && ['auto', 'scroll'].includes(box.overflowX)+ )++ return {+ body: { left: bodyRect.left, right: bodyRect.right },+ pre: { left: preRect.left, right: preRect.right, width: preRect.width },+ chain,+ clippedWithoutScroll,+ scrollingPre,+ rawMedia: body.textContent?.includes('MEDIA:') ?? false,+ inlineMedia: Boolean(body.querySelector('img, audio, video'))+ }+ })++ console.log('GROUP CODE BLOCK GEOMETRY', JSON.stringify(geometry))+ // The fixture really overflows and the code block scrolls to show it...+ expect.soft(geometry.scrollingPre).toBeDefined()+ // ...while staying inside the message column...+ expect.soft(geometry.pre.right).toBeLessThanOrEqual(geometry.body.right + 1)+ // ...and no box between the code and the message clips text it cannot scroll.+ expect.soft(geometry.clippedWithoutScroll).toEqual([])+ // MEDIA: renders as media, never as the raw directive.+ expect.soft(geometry.rawMedia).toBe(false)+ expect.soft(geometry.inlineMedia).toBe(true)+})diff --git a/apps/desktop/e2e/group-create-gate-remote-roster.spec.ts b/apps/desktop/e2e/group-create-gate-remote-roster.spec.tsnew file mode 100644index 00000000000..2c8776bb3b7--- /dev/null+++ b/apps/desktop/e2e/group-create-gate-remote-roster.spec.ts@@ -0,0 +1,219 @@+/**+ * 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 os from 'node:os'+import * as path from 'node:path'++import { startMockServer } from '../../../tests-js/scripts/mock-server'++import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ type Sandbox,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig,+} from './fixtures'+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 = path.join(os.tmpdir(), '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,+ // HOME is pinned to the sandbox too: profile roots are HOME-anchored, and a+ // HERMES_HOME that happens to sit under the developer's ~/.hermes (a TMPDIR+ // there) would otherwise serve their real profiles as the remote's bots.+ env: { ...process.env, HOME: root, 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/e2e/group-room-member-editing.spec.ts b/apps/desktop/e2e/group-room-member-editing.spec.tsnew file mode 100644index 00000000000..2dad2a4213f--- /dev/null+++ b/apps/desktop/e2e/group-room-member-editing.spec.ts@@ -0,0 +1,152 @@+import os from 'node:os'+import path from 'node:path'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// #91329 / #110736 — membership of an EXISTING room is editable from Group+// settings: the picker pre-checks the current seats, Save rewrites both+// membership sources the room reads (each local Bot's groups[] metadata and+// the room's durable member descriptors), and the next unaddressed send seats+// exactly the saved roster — the removed Bot never takes a turn again.++const ROOM = 'Programmer, Reviewer'+const SHOTS = path.join(os.tmpdir(), 'batchbots/features-groups-ui/shots')+let fixture: MockBackendFixture | null = null++type Page = MockBackendFixture['page']++async function durableMembers(page: Page) {+ return page.evaluate(room => {+ const rooms = JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.group-chats') || '{}')++ return ((rooms[room]?.members || []) as { name: string }[]).map(member => member.name).sort()+ }, ROOM)+}++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(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++async function createRoom(page: Page) {+ await openBots(page)+ await createAgent(page, 'programmer', 'Programmer')+ await createAgent(page, 'reviewer', 'Reviewer')+ await createAgent(page, 'planner', 'Planner')++ 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()++ return frontRoom(page)+}++/** A just-created Bot's canonical Bot Chat hydrates late and can front its+ * "Draft" tab over the room tab; bring the room back before typing into it. */+async function frontRoom(page: Page) {+ const tab = page.getByRole('tab', { name: ROOM }).first()+ await expect(tab).toBeVisible({ timeout: 20_000 })++ if ((await tab.getAttribute('aria-selected')) !== 'true') {+ await tab.click()+ }++ const composer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })+ await expect(composer).toBeVisible({ timeout: 20_000 })++ return composer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({ mockServer: {} })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('Group settings edits the room roster and the next round seats only the saved members', async () => {+ test.setTimeout(300_000)+ const page = fixture!.page+ await createRoom(page)++ expect(await durableMembers(page)).toEqual(['programmer', 'reviewer'])++ // Group settings → Manage members: the checklist opens pre-checked.+ await page.getByRole('button', { name: `Group settings for ${ROOM}` }).click()+ await page.getByRole('dialog', { name: 'Group settings' }).getByRole('button', { name: /^Manage members \(2\)/ }).click()++ const picker = page.getByRole('dialog', { name: 'Manage members' })+ await expect(picker).toBeVisible()+ const row = (title: string) => picker.getByRole('checkbox').filter({ hasText: title })+ await expect(row('Programmer')).toHaveAttribute('aria-checked', 'true')+ await expect(row('Reviewer')).toHaveAttribute('aria-checked', 'true')+ await expect(row('Planner')).toHaveAttribute('aria-checked', 'false')+ await page.screenshot({ path: `${SHOTS}/member-picker-open.png` })++ // Cancel changes nothing.+ await row('Planner').click()+ await picker.getByRole('button', { name: 'Cancel' }).click()+ await expect(picker).toBeHidden()+ expect(await durableMembers(page)).toEqual(['programmer', 'reviewer'])++ // Header door → swap Reviewer for Planner → Save.+ await page.getByRole('button', { name: 'Manage group members' }).click()+ await expect(row('Planner')).toHaveAttribute('aria-checked', 'false')+ await row('Planner').click()+ await row('Reviewer').click()+ await page.screenshot({ path: `${SHOTS}/member-picker-edited.png` })+ await picker.getByRole('button', { name: 'Save members' }).click()+ await expect(picker).toBeHidden()++ // Storage truth: the durable descriptors carry the new roster …+ await expect.poll(() => durableMembers(page)).toEqual(['planner', 'programmer'])+ // … and so does each local Bot's groups[] metadata (the plugin's meta snapshot).+ await expect.poll(() => page.evaluate(room => {+ const meta = JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.bot-meta-v2') || '{}')++ return Object.entries(meta as Record<string, any>)+ .filter(([, value]) => (value?.groups || []).includes(room))+ .map(([key]) => key.split('::').pop())+ .sort()+ }, ROOM), { timeout: 30_000 }).toEqual(['planner', 'programmer'])++ // An unaddressed send seats exactly the saved roster.+ const groupComposer = await frontRoom(page)+ await groupComposer.fill('ROOM_EDIT_ROUND who is here?')+ await groupComposer.press('Enter')+ await expect.poll(() => fixture!.mock.receivedPrompts.filter(p => p.includes('ROOM_EDIT_ROUND')).length, { timeout: 90_000 }).toBeGreaterThanOrEqual(2)+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0, { timeout: 90_000 })++ const speakers = fixture!.mock.receivedPrompts+ .filter(p => p.includes('ROOM_EDIT_ROUND'))+ .map(p => /You are @([a-z0-9_-]+)/.exec(p)?.[1])+ console.log('ROUND SPEAKERS after roster edit:', JSON.stringify(speakers))+ expect(new Set(speakers)).toEqual(new Set(['programmer', 'planner']))+ expect(speakers).not.toContain('reviewer')+ await page.screenshot({ path: `${SHOTS}/member-picker-after-round.png` })+})diff --git a/apps/desktop/e2e/group-to-local-bot-handoff.spec.ts b/apps/desktop/e2e/group-to-local-bot-handoff.spec.tsnew file mode 100644index 00000000000..2f863d144fe--- /dev/null+++ b/apps/desktop/e2e/group-to-local-bot-handoff.spec.ts@@ -0,0 +1,80 @@+import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++let fixture: MockBackendFixture | null = null++async function openBots(page: MockBackendFixture['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: MockBackendFixture['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(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).toBeVisible({ timeout: 30_000 })+}++test.beforeAll(async () => {+ fixture = await setupMockBackend()+ await waitForAppReady(fixture, 120_000)+})++test.afterAll(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('local bot replaces an open group main workspace', async () => {+ test.setTimeout(240_000)+ const page = fixture!.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('Programmer, Reviewer')+ await dialog.getByRole('button', { name: 'Create Group (2)' }).click()++ const groupTab = page.getByRole('tab', { name: /Programmer, Reviewer Close/ })+ const groupComposer = page.getByRole('textbox', { name: 'Message Programmer, Reviewer' }).filter({ visible: true })+ await expect(groupTab).toBeVisible({ timeout: 20_000 })+ await expect(groupTab).toHaveAttribute('aria-selected', 'true')+ await expect(groupComposer).toBeVisible()++ const programmer = page.getByRole('button', { name: /^Programmer\b/ }).filter({ visible: true }).first()+ await programmer.click()++ // The bot's canonical chat opens INTO the main workspace pane (post+ // design-system rework); as the lone pane in the zone it renders chromeless+ // — no "Bot Chat" tab exists until a second pane joins the strip. The+ // handoff is observed by the group surfaces leaving and the bot's chat+ // (here a fresh one: its empty-state splash asks for a first message)+ // taking the main workspace. The first open also spawns the bot's own+ // backend, so give the "Loading session" phase a real chance to clear.+ await expect(page.getByText('Say something to get started.').filter({ visible: true })).toBeVisible({+ timeout: 120_000+ })+ await expect(groupTab).toHaveCount(0)+ await expect(groupComposer).toHaveCount(0)+ // No "Waking up…" assertion: the mock backend can keep a bot's wake notice+ // around indefinitely (see bot-mode-row-click-mirrors-registry's settle()),+ // so its presence no longer distinguishes a stranded handoff. The splash+ // and composer above are the proof the bot's chat took the workspace.+ await expect(page.locator('[data-slot="composer-root"] [contenteditable="true"]').filter({ visible: true }).first()).toBeVisible()+})diff --git a/apps/desktop/e2e/group-transcript-mentions-reply-to.spec.ts b/apps/desktop/e2e/group-transcript-mentions-reply-to.spec.tsnew file mode 100644index 00000000000..54225fe50ff--- /dev/null+++ b/apps/desktop/e2e/group-transcript-mentions-reply-to.spec.ts@@ -0,0 +1,135 @@+import os from 'node:os'+import path from 'node:path'++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++// #91359 / #89883 — group-room transcript affordances:+// - a recognized @mention in a sent message renders as an inline reference+// (`.ref[data-ref=agent|human|broadcast]`); unknown @tokens stay prose;+// - a bot's message carries "Reply to <bot>", which seeds `@tag ` into the+// room composer so the next send routes to that member only.++const ROOM = 'Programmer, Reviewer'+const SHOTS = path.join(os.tmpdir(), 'batchbots/features-groups-ui/shots')+let fixture: MockBackendFixture | null = null++type Page = MockBackendFixture['page']++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(page.getByRole('button', { name: new RegExp(`^${title}\\b`) }).first()).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 groupComposer = page.getByRole('textbox', { name: `Message ${ROOM}` }).filter({ visible: true })+ await expect(groupComposer).toBeVisible({ timeout: 20_000 })++ return groupComposer+}++test.beforeEach(async () => {+ fixture = await setupMockBackend({ mockServer: {} })+ await waitForAppReady(fixture, 120_000)+})++test.afterEach(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('mentions render as inline references and Reply-to seeds the composer', async () => {+ test.setTimeout(300_000)+ const page = fixture!.page+ const groupComposer = await createRoom(page)++ await groupComposer.fill('@programmer MENTION_RENDER check this, then @user decides; not [email protected] and not @nobody')+ await groupComposer.press('Enter')++ // The sent user line: exactly the routed bot and the human token are refs.+ // A bot created moments ago runs its intro turn in the background; when it+ // lands, the roster fronts that bot's chat tab and yanks the center away+ // from the room. Re-select the room and read the line from a room body.+ const roomTab = page.getByRole('tab', { name: new RegExp(`${ROOM} Close`) })++ const sent = page+ .locator('[data-selectable-text="true"]')+ .getByText(/MENTION_RENDER check this/)+ .filter({ visible: true })+ .first()++ await expect(async () => {+ if ((await roomTab.getAttribute('aria-selected')) !== 'true') {+ await roomTab.click()+ }++ await expect(sent).toBeVisible({ timeout: 5_000 })+ }).toPass({ timeout: 60_000 })+ await expect(sent.locator('.ref[data-ref="agent"]')).toHaveText('@programmer')+ await expect(sent.locator('.ref[data-ref="human"]')).toHaveText('@user')+ // Only the two mention refs carry `data-ref`; the e-mail address renders+ // as the shell's ordinary (also `.ref`-styled) mailto link, not a mention.+ await expect(sent.locator('.ref[data-ref]')).toHaveCount(2)+ await expect(sent).toContainText('@nobody')++ // The mock reply from programmer arrives; its hover action targets that bot.+ await expect(page.getByRole('button', { name: 'Stop', exact: true })).toHaveCount(0, { timeout: 90_000 })+ const replyButton = page.getByRole('button', { name: 'Reply to Programmer' }).first()++ await expect(async () => {+ if ((await roomTab.getAttribute('aria-selected')) !== 'true') {+ await roomTab.click()+ }++ await expect(replyButton).toBeAttached({ timeout: 5_000 })+ }).toPass({ timeout: 60_000 })+ await sent.hover()+ await page.screenshot({ path: `${SHOTS}/mention-refs.png` })++ await groupComposer.fill('')+ await replyButton.click({ force: true })+ await expect(groupComposer).toHaveValue('@programmer ')+ await page.screenshot({ path: `${SHOTS}/reply-to-seeded.png` })++ // Idempotent: a second click never doubles the tag.+ await replyButton.click({ force: true })+ await expect(groupComposer).toHaveValue('@programmer ')++ // Storage truth: the stored text is untouched by rendering.+ const stored = await page.evaluate(room => {+ const rooms = JSON.parse(localStorage.getItem('hermes.plugin.hermes-bots.group-chats') || '{}')++ return (rooms[room]?.log || []).map((entry: any) => entry.text)[0]+ }, ROOM)++ expect(stored).toBe('@programmer MENTION_RENDER check this, then @user decides; not [email protected] and not @nobody')+})