The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge upstream main (afc3d9d34c): refresh before review
yoniebans558d76c401cc
diff --cc apps/desktop/e2e/bot-mode-row-click-mirrors-registry.spec.tsindex 00000000000,23354e7b774..1ea609318b6mode 000000,100644..100644--- a/apps/desktop/e2e/bot-mode-row-click-mirrors-registry.spec.ts+++ b/apps/desktop/e2e/bot-mode-row-click-mirrors-registry.spec.ts@@@ -1,0 -1,158 +1,158 @@@+ 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 './mock-server'++import { MOCK_REPLY, startMockServer } from '../../../tests-js/scripts/mock-server'+ import { RealSessionBuilder } from './real-session-builder'+ import { expect, test } from './test'++ // A bot row previews the bot's canonical Bot Chat (the gateway resolves it by+ // name on every roster poll). Clicking the row must land on THAT conversation.+ // Before this fix a plain click fronted whatever bots-workspace tile the user+ // last had open for that bot — a `+` side thread outlived every restart in+ // Local Storage and won every click forever, while the row kept previewing the+ // Bot Chat. The user saw the sidebar and the center describe two different+ // conversations ("sessions not in sync"; support thread 1544460286084391043).++ 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 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()+ const sandbox = createSandbox('bots-sync')+ 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('a bot row click lands on the Bot Chat the row previews, not a side thread', 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()+ const betaRow = page.getByRole('button', { name: /^beta\b/i }).filter({ visible: true }).first()+ await expect(alphaRow).toBeVisible({ timeout: 30_000 })+ await expect(betaRow).toBeVisible({ timeout: 30_000 })+ const seededTurn = page.getByText('Hello alpha', { exact: true }).filter({ visible: true })++ await openUntil(+ () => alphaRow.click(),+ () => expect(seededTurn.first()).toBeVisible({ timeout: 45_000 })+ )+ await settle(page, 15_000)++ // A `+` side thread for alpha, with a real turn so it is a persisted tile.+ 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 })++ // Leave alpha on the side thread, go to beta, come back via the row.+ await betaRow.click()+ await expect(page.getByText('Hello beta', { exact: true }).filter({ visible: true }).first()).toBeVisible({+ timeout: 60_000+ })+ await settle(page)++ await alphaRow.click()+ // The row previews the Bot Chat; the click must front it.+ await expect(seededTurn.first()).toBeVisible({ timeout: 45_000 })+ // The side thread is still open beside it (scoped to alpha), not closed.+ await expect+ .poll(+ () =>+ page.evaluate(() =>+ [...document.querySelectorAll<HTMLElement>('[data-zone-tabstrip="grp-main"] [data-tree-tab]')]+ .map(element => element.getAttribute('data-tree-tab') ?? '')+ .filter(id => id.startsWith('session-tile:')).length+ ),+ { timeout: 15_000 }+ )+ .toBe(1)+ })diff --cc apps/desktop/e2e/bot-mode-tab-shows-bot-name.spec.tsindex 00000000000,c26cd180432..8eac23c5a1fmode 000000,100644..100644--- a/apps/desktop/e2e/bot-mode-tab-shows-bot-name.spec.ts+++ b/apps/desktop/e2e/bot-mode-tab-shows-bot-name.spec.ts@@@ -1,0 -1,137 +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 './mock-server'++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 --cc apps/desktop/e2e/bot-roster-user-sections.spec.tsindex 00000000000,1b2e6753ab4..7439777cce2mode 000000,100644..100644--- a/apps/desktop/e2e/bot-roster-user-sections.spec.ts+++ b/apps/desktop/e2e/bot-roster-user-sections.spec.ts@@@ -1,0 -1,254 +1,254 @@@+ import fs from 'node:fs'+ import path from 'node:path'++ import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig+ } from './fixtures'-import { startMockServer } from './mock-server'++import { startMockServer } from '../../../tests-js/scripts/mock-server'+ import { RealSessionBuilder } from './real-session-builder'+ import { expect, test } from './test'++ // User-made sections in the Bots roster: a bot is filed by dragging it onto a+ // section or through its row menu, the section is renamed through the same+ // dialog shape sessions use, and deleting a section returns its bots to+ // Unassigned (with an Undo toast, no confirmation). With no sections created+ // the roster is the plain list it always was.++ type Page = MockBackendFixture['page']++ let fixture: MockBackendFixture | null = null++ // BOT_SECTIONS_SCREENSHOT_DIR=<dir> saves full-window captures at the key+ // states — handy for design review; never part of the assertions.+ async function capture(page: Page, name: string): Promise<void> {+ const dir = process.env.BOT_SECTIONS_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 roster = (page: Page) => page.locator('[data-slot="bots-roster"]')+ const botRow = (page: Page, name: string) => roster(page).locator(`[data-roster-key="local::${name}"]`)++ /** A section's label span — the one node whose text is exactly the name. */+ const sectionLabel = (page: Page, name: string) =>+ page.locator('span.truncate', { hasText: new RegExp(`^${name}$`, 'i') })++ /** The heading's fold button (label + count) — the ⋯ menu trigger is a sibling with no text. */+ const sectionHeading = (page: Page, name: string) =>+ roster(page).locator('[data-slot="bots-section"] button[aria-expanded]').filter({ has: sectionLabel(page, name) })++ const sectionBlock = (page: Page, name: string) =>+ roster(page).locator('[data-slot="bots-section"]').filter({ has: sectionLabel(page, name) })++ /** Section name → roster keys of the rows under it (the plain list has no sections). */+ async function layout(page: Page): Promise<Array<[string, string[]]>> {+ return roster(page).locator('[data-slot="bots-section"]').evaluateAll(blocks =>+ blocks.map(block => [+ block.querySelector('button[aria-expanded] span.truncate')?.textContent?.trim() ?? '',+ [...block.querySelectorAll<HTMLElement>('[data-roster-key]')].map(row => row.dataset.rosterKey ?? '')+ ])+ )+ }++ test.beforeAll(async () => {+ const mock = await startMockServer()+ const sandbox = createSandbox('bots-sections')+ writeMockProviderConfig(sandbox.hermesHome, mock.url)+ writeEnvFile(sandbox.hermesHome)++ for (const name of ['alpha', 'beta', 'gamma']) {+ 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('file bots into user sections by menu and drag; rename; delete returns them to Unassigned', 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(botRow(page, 'alpha')).toBeVisible({ timeout: 30_000 })+ await expect(botRow(page, 'beta')).toBeVisible({ timeout: 30_000 })++ // No sections yet: the plain list, no section chrome at all.+ await expect(roster(page).locator('[data-slot="bots-section"]')).toHaveCount(0)+ await capture(page, '1-plain-roster')++ // Right-click alpha → Move to section → New section… → name it → alpha is filed.+ await botRow(page, 'alpha').click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Move to section' }).hover()+ await expect(page.getByRole('menuitem', { name: 'New section…' })).toBeVisible()+ await capture(page, '2-row-menu-move-to-section')+ await page.getByRole('menuitem', { name: 'New section…' }).click()+ const nameField = page.getByRole('textbox', { name: 'Section name' })+ await expect(nameField).toBeVisible()+ await nameField.fill('Clients')+ await capture(page, '3-new-section-dialog')+ await page.getByRole('button', { name: 'Create' }).click()++ await expect(sectionHeading(page, 'Clients')).toBeVisible()+ await expect(sectionBlock(page, 'Clients').locator('[data-roster-key="local::alpha"]')).toBeVisible()+ // The remainder is Unassigned, drawn last.+ await expect+ .poll(async () => (await layout(page)).map(([name, keys]) => [name, keys.length]))+ .toEqual([+ ['Clients', 1],+ ['Unassigned', 3]+ ])+ await capture(page, '4-alpha-filed')++ // Drag beta over the Clients block: the target highlights while over it.+ // Escape cancels — nothing moves, nothing stays highlighted or faded.+ const target = sectionBlock(page, 'Clients')+ const from = (await botRow(page, 'beta').boundingBox())!+ const to = (await sectionHeading(page, 'Clients').boundingBox())!++ const dragBetaOverClients = async () => {+ await page.mouse.move(from.x + from.width / 2, from.y + from.height / 2)+ await page.mouse.down()+ await page.mouse.move(from.x + from.width / 2, from.y + from.height / 2 - 10, { steps: 4 })+ await page.mouse.move(to.x + to.width / 2, to.y + to.height / 2, { steps: 12 })+ await expect(target).toHaveAttribute('data-drop-over', 'true')+ }++ await dragBetaOverClients()+ await page.keyboard.press('Escape')+ await page.mouse.up()+ await expect(target).not.toHaveAttribute('data-drop-over', 'true')+ await expect(botRow(page, 'beta')).toHaveCSS('opacity', '1')+ expect((await layout(page)).map(([name, keys]) => [name, keys.length])).toEqual([+ ['Clients', 1],+ ['Unassigned', 3]+ ])++ // Drop it for real: the bot is filed.+ await dragBetaOverClients()+ await capture(page, '5-drag-over-clients')+ await page.mouse.up()++ await expect(target.locator('[data-roster-key="local::beta"]')).toBeVisible()+ await expect(target).not.toHaveAttribute('data-drop-over', 'true')+ // The moved row remounts under its new section; it must not stay faded.+ await expect(botRow(page, 'beta')).toHaveCSS('opacity', '1')+ await expect+ .poll(async () => (await layout(page)).map(([name, keys]) => [name, keys.length]))+ .toEqual([+ ['Clients', 2],+ ['Unassigned', 2]+ ])+ await capture(page, '6-beta-dropped')++ // Rename through the heading's context menu — the same Dialog + Input+ // + Save shape as a session rename.+ await sectionHeading(page, 'Clients').click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Rename…' }).click()+ await expect(nameField).toHaveValue('Clients')+ await nameField.fill('Customers')+ await page.getByRole('button', { name: 'Save' }).click()+ await expect(sectionHeading(page, 'Customers')).toBeVisible()+ await expect(sectionHeading(page, 'Clients')).toHaveCount(0)+ await capture(page, '7-renamed')++ // A second, empty section from the + menu shows its drop hint; collapsing+ // a section folds its rows like the gateway headings do.+ await page.getByRole('button', { name: 'New bot or group chat' }).click()+ await page.getByRole('menuitem', { name: 'New section' }).click()+ await nameField.fill('Team')+ await page.getByRole('button', { name: 'Create' }).click()+ await expect(sectionBlock(page, 'Team').getByText('Drag bots here')).toBeVisible()+ await sectionHeading(page, 'Customers').click()+ await expect(sectionBlock(page, 'Customers').locator('[data-roster-key]')).toHaveCount(0)+ await capture(page, '8-empty-section-and-collapsed')+ await sectionHeading(page, 'Customers').click()+ await expect(sectionBlock(page, 'Customers').locator('[data-roster-key]')).toHaveCount(2)++ // Delete Customers: no confirmation, its two bots return to Unassigned,+ // and the toast offers Undo.+ await sectionHeading(page, 'Customers').click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Delete' }).click()+ await expect(sectionHeading(page, 'Customers')).toHaveCount(0)+ const toast = page.getByRole('status').filter({ hasText: 'Deleted “Customers”' })+ await expect(toast).toBeVisible()+ await expect+ .poll(async () => (await layout(page)).map(([name, keys]) => [name, keys.length]))+ .toEqual([+ ['Team', 0],+ ['Unassigned', 4]+ ])+ await capture(page, '9-deleted-with-undo-toast')++ await toast.getByRole('button', { name: 'Undo' }).click()+ await expect(sectionHeading(page, 'Customers')).toBeVisible()+ await expect+ .poll(async () => (await layout(page)).map(([name, keys]) => [name, keys.length]))+ .toEqual([+ ['Customers', 2],+ ['Team', 0],+ ['Unassigned', 2]+ ])++ // Membership rides the bot's profile ui_meta, so it follows profile sync.+ const alphaProfile = path.join(fixture!.sandbox.hermesHome, 'profiles', 'alpha', 'profile.yaml')+ await expect.poll(() => (fs.existsSync(alphaProfile) ? fs.readFileSync(alphaProfile, 'utf8') : '')).toMatch(/sectionId:\s*sec-/)++ // Delete both sections: the roster is the plain list again.+ for (const name of ['Customers', 'Team']) {+ await sectionHeading(page, name).click({ button: 'right' })+ await page.getByRole('menuitem', { name: 'Delete' }).click()+ }++ await expect(roster(page).locator('[data-slot="bots-section"]')).toHaveCount(0)+ await expect(botRow(page, 'alpha')).toBeVisible()+ })diff --cc apps/desktop/e2e/hidden-history-messages.spec.tsindex 77241d33675,7756a07076c..efaa0092530--- a/apps/desktop/e2e/hidden-history-messages.spec.ts+++ b/apps/desktop/e2e/hidden-history-messages.spec.ts@@@ -25,8 -23,9 +23,9 @@@ importstartMockServer,VERIFICATION_STOP_TEXT,VERIFICATION_STOP_TRIGGER,-} from './mock-server'+} from '../../../tests-js/scripts/mock-server'import { RealSessionBuilder } from './real-session-builder'+ import { expect, test } from './test'const SESSION_TITLE = 'E2E Hidden History Messages'const VISIBLE_USER_TEXT = 'E2E_VISIBLE_USER_HISTORY'