The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: restore Desktop layout/zoom Playwright specs dropped by #120071
teknium189a86ce188f1
diff --git a/apps/desktop/e2e/bot-routines-pane-narrow.spec.ts b/apps/desktop/e2e/bot-routines-pane-narrow.spec.tsnew file mode 100644index 00000000000..1e758d1ed7f--- /dev/null+++ b/apps/desktop/e2e/bot-routines-pane-narrow.spec.ts@@ -0,0 +1,254 @@+import { execFileSync } from 'node:child_process'+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'++// The Scheduled jobs (Routines) pane docks at 250px beside a bot chat. A job+// row is a grid item, and grid items default to `min-width: auto`, so a long+// nowrap title pinned the row wider than the pane: the enable/disable Switch+// and the delete control were clipped off the right edge and the next-run+// label was cut mid-word (#91623, #89534). Closing the pane with its ✕ also+// remembered the dismissal forever — re-entering Bot Mode never brought the+// pane back (#102224).++type Page = MockBackendFixture['page']++const LONG_TITLE = '[bot:alpha] Weekly research digest with a deliberately long routine title that overflows'++let fixture: MockBackendFixture | null = null+let alphaHome = ''++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 openSessions(page: Page): Promise<void> {+ const tab = page+ .getByRole('button', { name: /^sessions$/i })+ .or(page.getByRole('tab', { name: /^sessions$/i }))+ .first()++ await tab.click()+}++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<string> {+ 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()+ }++ return dir+}++/** A real cron job in the profile's own cron store, written by the real store code. */+function seedRoutine(profileHome: string, title: string): void {+ const python = path.resolve(process.cwd(), '../../venv/bin/python')+ const repoRoot = path.resolve(process.cwd(), '../..')++ const script = [+ 'from cron.jobs import create_job',+ `create_job(name=${JSON.stringify(title)}, schedule='every 4 days', prompt='say hello')`+ ].join('\n')++ execFileSync(python, ['-c', script], {+ cwd: repoRoot,+ env: { ...process.env, HERMES_HOME: profileHome },+ stdio: 'pipe'+ })+}++function readJobs(profileHome: string): Array<{ enabled?: boolean; name?: string; state?: string }> {+ const raw = JSON.parse(fs.readFileSync(path.join(profileHome, 'cron', 'jobs.json'), 'utf8'))++ return Array.isArray(raw) ? raw : (raw.jobs ?? [])+}++async function openAlphaChat(page: Page): Promise<void> {+ 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+ })+ )+}++function routinesTab(page: Page) {+ return page.locator('[data-tree-tab="hermes-bots:routines"]').filter({ visible: true }).first()+}++/** Expand the collapsed right-edge Scheduled jobs tab (a no-op when the pane is already open); resolve the row. */+async function expandRoutines(page: Page) {+ const row = page+ .getByRole('button', { name: /Weekly research digest/ })+ .filter({ visible: true })+ .first()++ if (!(await row.isVisible())) {+ const tab = routinesTab(page)+ await expect(tab).toBeVisible({ timeout: 30_000 })+ await tab.click()+ }++ await expect(row).toBeVisible({ timeout: 30_000 })+ await page.waitForTimeout(2_500)+ await expect(row).toBeVisible()++ return row+}++test.beforeAll(async () => {+ const mock = await startMockServer()+ const sandbox = createSandbox('bots-routines')+ writeMockProviderConfig(sandbox.hermesHome, mock.url)+ writeEnvFile(sandbox.hermesHome)+ alphaHome = await seedBot(sandbox.hermesHome, mock.url, 'alpha')+ seedRoutine(alphaHome, LONG_TITLE)++ 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 long routine title never pushes the Switch, delete control or next-run label out of the 250px pane', async ({}, testInfo) => {+ test.setTimeout(300_000)+ const page = fixture!.page++ await openAlphaChat(page)+ const row = await expandRoutines(page)+ await page.screenshot({ path: testInfo.outputPath('routines-pane.png') })++ // Geometry against the pane's own scroll container, not body text: the row+ // is a grid item, so its intrinsic width is what pins the controls off-edge.+ const geometry = await row.evaluate(button => {+ const card = button.parentElement!.parentElement as HTMLElement+ const scroller = card.closest<HTMLElement>('.overflow-y-auto')!+ const paneRect = scroller.getBoundingClientRect()++ const rect = (el: Element | null) => {+ const r = el!.getBoundingClientRect()++ return { left: r.left, right: r.right, width: r.width }+ }++ const nextRun = [...card.querySelectorAll<HTMLElement>('span')].find(s => /^next/i.test(s.textContent ?? ''))!+ const title = button.querySelector<HTMLElement>('span.truncate')!++ return {+ card: rect(card),+ pane: rect(scroller),+ switch: rect(card.querySelector('[role="switch"]')),+ trash: rect(card.querySelector('button[aria-label]')),+ nextRun: { ...rect(nextRun), clipped: nextRun.scrollWidth > nextRun.clientWidth + 1, text: nextRun.textContent },+ titleEllipsized: title.scrollWidth > title.clientWidth,+ paneRight: paneRect.right+ }+ })+++ expect.soft(geometry.card.right).toBeLessThanOrEqual(geometry.pane.right + 1)+ expect.soft(geometry.switch.right).toBeLessThanOrEqual(geometry.pane.right + 1)+ expect.soft(geometry.trash.right).toBeLessThanOrEqual(geometry.pane.right + 1)+ expect.soft(geometry.nextRun.right).toBeLessThanOrEqual(geometry.pane.right + 1)+ expect.soft(geometry.nextRun.clipped).toBe(false)+ expect.soft(geometry.nextRun.text).toMatch(/next: in \d+ days?/i)+ // The title is the one thing that MAY be cut, and it must be cut with an ellipsis.+ expect.soft(geometry.titleEllipsized).toBe(true)++ await test.step("clicking the row's Switch toggles the job in place — the pane stays, jobs.json flips (#95031)", async () => {+ const toggle = row.locator('xpath=..').getByRole('switch')+ await expect(toggle).toBeVisible()+ expect(readJobs(alphaHome)[0]?.enabled).not.toBe(false)++ await toggle.click()++ await expect.poll(() => readJobs(alphaHome)[0]?.enabled, { timeout: 30_000 }).toBe(false)+ await expect(row).toBeVisible()+ await expect(page.getByText(/Open this bot's continuous chat/i)).toHaveCount(0)+ await page.screenshot({ path: testInfo.outputPath('routines-pane-toggled.png') })+ })++ await test.step('closing Scheduled jobs with ✕ is recoverable — leaving and re-entering Bot Mode brings the pane back (#102224)', async () => {+ const tab = page.locator('[data-tree-tab="hermes-bots:routines"]').first()+ await expect(tab).toBeVisible({ timeout: 30_000 })+ await tab.hover()+ const closer = tab.getByRole('button', { name: /^close$/i }).first()+ await closer.click({ force: true })+ await expect(page.getByRole('button', { name: /Weekly research digest/ })).toHaveCount(0, { timeout: 15_000 })+ await page.screenshot({ path: testInfo.outputPath('routines-closed.png') })++ await openSessions(page)+ await openAlphaChat(page)+ await page.screenshot({ path: testInfo.outputPath('routines-restored.png') })++ await expect(page.locator('[data-tree-tab="hermes-bots:routines"]').first()).toBeVisible({ timeout: 30_000 })+ })+})diff --git a/apps/desktop/e2e/onboarding-settings.spec.ts b/apps/desktop/e2e/onboarding-settings.spec.tsnew file mode 100644index 00000000000..6fe1253cdb5--- /dev/null+++ b/apps/desktop/e2e/onboarding-settings.spec.ts@@ -0,0 +1,82 @@+import { readFileSync, unlinkSync, writeFileSync } from 'node:fs'+import { createRequire } from 'node:module'+import path from 'node:path'++import { buildAppEnv, createSandbox, launchDesktop, setupNoProvider } from './fixtures'+import { type ElectronApplication, expect, type Page, test } from './test'++const { prepareWindowForInput } = createRequire(import.meta.url)(+ '../../../tests/install/e2e-assets/window-input.cjs',+) as { prepareWindowForInput: (app: ElectronApplication, page: Page) => Promise<void> }++test('input setup survives a fresh-install zoom restore before onboarding', async () => {+ const sandbox = createSandbox('cold-input')+ unlinkSync(path.join(sandbox.userDataDir, 'zoom-state.json'))+ writeFileSync(path.join(sandbox.hermesHome, 'config.yaml'), '# no provider\n', 'utf8')+ let app: ElectronApplication | undefined++ try {+ const launched = await launchDesktop(buildAppEnv(sandbox))+ app = launched.app+ const page = launched.page+ await page.waitForSelector('button', { state: 'attached' })+ await prepareWindowForInput(app, page)+ const later = page.getByRole('button', { name: /choose a provider later/i })+ await expect(later).toBeVisible({ timeout: 60_000 })+ const appWindow = await app.browserWindow(page)+ await appWindow.evaluate(win => win.emit('focus'))+ await expect.poll(() => appWindow.evaluate(win => win.webContents.getZoomFactor())).toBeCloseTo(1)+ await later.click({ timeout: 5_000 })+ await expect(later).toBeHidden()+ } finally {+ await app?.close().catch(() => undefined)+ sandbox.cleanup()+ }+})++// Exercise the install driver's input setup against the real renderer/backend,+// with no installer, update, credentials, or live user data.+for (const lifecycleEvent of ['focus', 'navigation'] as const) {+ test(`onboarding input zoom survives ${lifecycleEvent} and opens Settings`, async () => {+ const fixture = await setupNoProvider()+ const { app, page, sandbox } = fixture++ try {+ await prepareWindowForInput(app, page)+ const later = page.getByRole('button', { name: /choose a provider later/i })+ await expect(later).toBeVisible({ timeout: 60_000 })+ const zoomFile = path.join(sandbox.userDataDir, 'zoom-state.json')+ const savedLevel = () => JSON.parse(readFileSync(zoomFile, 'utf8')).zoomLevel as number+ await page.evaluate(() => {+ const desktop = (window as unknown as { hermesDesktop: { zoom: { setPercent: (percent: number) => void } } }).hermesDesktop+ desktop.zoom.setPercent(90)+ })+ await expect.poll(savedLevel).toBeCloseTo(Math.log(0.9) / Math.log(1.2))++ await prepareWindowForInput(app, page)+ const appWindow = await app.browserWindow(page)++ // The same lifecycle callback that fires when another window takes focus+ // must restore our input scale, not the original 90% preference.+ if (lifecycleEvent === 'focus') {+ await appWindow.evaluate(win => win.emit('focus'))+ } else {+ await page.evaluate(() => { window.location.hash = '#/settings' })+ }++ await expect.poll(() => appWindow.evaluate(win => win.webContents.getZoomFactor())).toBeCloseTo(1)+ expect(savedLevel()).toBe(0)+ await later.click({ timeout: 5_000 })+ await expect(later).toBeHidden()++ if (lifecycleEvent === 'navigation') {+ await page.evaluate(() => { window.location.hash = '#/' })+ }++ await page.getByRole('button', { name: 'Open settings', exact: true }).click({ timeout: 5_000 })+ await expect(page).toHaveURL(/settings/)+ } finally {+ await fixture.cleanup()+ }+ })+}diff --git a/apps/desktop/e2e/right-pane.spec.ts b/apps/desktop/e2e/right-pane.spec.tsnew file mode 100644index 00000000000..5447955f452--- /dev/null+++ b/apps/desktop/e2e/right-pane.spec.ts@@ -0,0 +1,138 @@+import { test, expect } from './test'++import {+ type MockBackendFixture,+ setupMockBackend,+ waitForAppReady,+} from './fixtures'++let fixture: MockBackendFixture | null = null++test.beforeAll(async () => {+ fixture = await setupMockBackend()+ await waitForAppReady(fixture, 120_000)+})++test.afterAll(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('persistent terminal overlay follows the pane after split dragging', async () => {+ const page = fixture!.page++ await page.keyboard.press('Control+`')+ await page.locator('[data-terminal-slot]').waitFor({ state: 'visible', timeout: 30_000 })+ await page.locator('[data-persistent-terminal] .xterm').waitFor({ state: 'visible', timeout: 30_000 })++ const result = await page.evaluate(async () => {+ const slot = document.querySelector('[data-terminal-slot]')+ const overlay = document.querySelector('[data-persistent-terminal]')++ if (!slot || !overlay) {+ return { drift: -1, moved: 0, target: false }+ }++ const before = slot.getBoundingClientRect()+ const target = [...document.querySelectorAll<HTMLElement>('[role="separator"]')]+ .map(element => {+ const box = element.getBoundingClientRect()+ const horizontal = box.width > box.height+ const center = horizontal+ ? (box.top + box.bottom) / 2+ : (box.left + box.right) / 2+ const sides = horizontal+ ? [before.top, before.bottom]+ : [before.left, before.right]++ return {+ element,+ box,+ horizontal,+ score: Math.min(...sides.map(side => Math.abs(center - side))),+ }+ })+ .filter(item => item.box.width > 0 && item.box.height > 0)+ .sort((a, b) => a.score - b.score)[0]++ if (!target) {+ return { drift: -1, moved: 0, target: false }+ }++ const x = target.box.left + target.box.width / 2+ const y0 = target.box.top + target.box.height / 2+ const nearestSide = target.horizontal+ ? Math.abs(y0 - before.top) < Math.abs(y0 - before.bottom)+ ? 'top'+ : 'bottom'+ : Math.abs(x - before.left) < Math.abs(x - before.right)+ ? 'left'+ : 'right'+ const deltaX = nearestSide === 'left' ? -1 : nearestSide === 'right' ? 1 : 0+ const deltaY = nearestSide === 'top' ? -1 : nearestSide === 'bottom' ? 1 : 0+ let currentX = x+ let y = y0+ const pointer = {+ bubbles: true,+ cancelable: true,+ pointerId: 71,+ pointerType: 'mouse',+ isPrimary: true,+ button: 0,+ buttons: 1,+ }++ target.element.dispatchEvent(+ new PointerEvent('pointerdown', { ...pointer, clientX: x, clientY: y }),+ )++ for (let index = 0; index < 24; index += 1) {+ currentX += deltaX+ y += deltaY+ window.dispatchEvent(+ new PointerEvent('pointermove', {+ ...pointer,+ clientX: currentX,+ clientY: y,+ }),+ )+ await new Promise<void>(resolve => requestAnimationFrame(() => resolve()))+ }++ window.dispatchEvent(+ new PointerEvent('pointerup', {+ ...pointer,+ buttons: 0,+ clientX: currentX,+ clientY: y,+ }),+ )+ await new Promise<void>(resolve => setTimeout(resolve, 350))+ await new Promise<void>(resolve =>+ requestAnimationFrame(() => requestAnimationFrame(() => resolve())),+ )++ const next = slot.getBoundingClientRect()+ const fixed = overlay.getBoundingClientRect()++ return {+ drift: Math.max(+ Math.abs(next.top - fixed.top),+ Math.abs(next.left - fixed.left),+ Math.abs(next.width - fixed.width),+ Math.abs(next.height - fixed.height),+ ),+ moved: Math.max(+ Math.abs(next.top - before.top),+ Math.abs(next.left - before.left),+ Math.abs(next.width - before.width),+ Math.abs(next.height - before.height),+ ),+ target: true,+ }+ })++ expect(result.target).toBe(true)+ expect(result.moved).toBeGreaterThan(10)+ expect(result.drift).toBeLessThanOrEqual(1)+})diff --git a/apps/desktop/e2e/worktree-branch-status.spec.ts b/apps/desktop/e2e/worktree-branch-status.spec.tsnew file mode 100644index 00000000000..33e9946e725--- /dev/null+++ b/apps/desktop/e2e/worktree-branch-status.spec.ts@@ -0,0 +1,240 @@+import { execFileSync } from 'node:child_process'+import * as fs from 'node:fs'+import * as path from 'node:path'++import {+ buildAppEnv,+ createSandbox,+ launchDesktop,+ type MockBackendFixture,+ waitForAppReady,+ writeEnvFile,+ writeMockProviderConfig,+} from './fixtures'+import { startMockServer } from '../../../tests-js/scripts/mock-server'+import { expect, test } from './test'++const BRANCH_NAME = 'e2e-composer-branch'++/**+ * Enough branches to make both the base-branch popover and the convert-branch+ * list taller than their default height. That is the condition in which the+ * dialog's own scroll box clips the popover, and that regression is what the+ * visual snapshots here guard against.+ */+const EXTRA_BRANCHES = [+ 'feature/alpha-one',+ 'feature/beta-two',+ 'feature/gamma-three',+ 'fix/delta-four',+ 'fix/epsilon-five',+ 'chore/zeta-six',+ 'chore/eta-seven',+ 'spike/theta-eight',+ 'spike/iota-nine',+ 'release/kappa-ten',+]++function createGitRepo(root: string): string {+ const repo = path.join(root, 'repo')++ fs.mkdirSync(repo, { recursive: true })+ execFileSync('git', ['init', '--initial-branch=main'], { cwd: repo })+ execFileSync('git', ['config', 'user.email', '[email protected]'], { cwd: repo })+ execFileSync('git', ['config', 'user.name', 'Hermes E2E'], { cwd: repo })+ fs.writeFileSync(path.join(repo, 'README.md'), '# E2E repo\n', 'utf8')+ execFileSync('git', ['add', 'README.md'], { cwd: repo })+ execFileSync('git', ['commit', '-m', 'initial'], { cwd: repo })++ for (const branch of EXTRA_BRANCHES) {+ execFileSync('git', ['branch', branch], { cwd: repo })+ }++ return repo+}++function configureRepoCwd(hermesHome: string, mockUrl: string, repo: string): void {+ writeMockProviderConfig(hermesHome, mockUrl)+ fs.appendFileSync(path.join(hermesHome, 'config.yaml'), `\nterminal:\n cwd: ${repo}\n`, 'utf8')+ writeEnvFile(hermesHome)+}++let fixture: MockBackendFixture | null = null++/** A dialog renders as `[data-slot="dialog-content"]` (components/ui/dialog.tsx). */+const DIALOG = '[data-slot="dialog-content"]'++/** Open the worktree dialog with the global ⌘⇧B / ctrl+shift+B hotkey. */+async function openWorktreeDialog(): Promise<void> {+ const page = fixture!.page+ await page.keyboard.press('Control+Shift+B')+ await expect(page.locator(DIALOG)).toBeVisible()+}++/** Close the open dialog and wait until it leaves the DOM. */+async function closeDialog(): Promise<void> {+ const page = fixture!.page+ await page.keyboard.press('Escape')+ await expect(page.locator(DIALOG)).toHaveCount(0)+}++test.beforeAll(async () => {+ const sandbox = createSandbox('worktree-branch-status')+ const repo = createGitRepo(sandbox.root)+ const mock = await startMockServer()++ configureRepoCwd(sandbox.hermesHome, mock.url, repo)++ 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)++ // The coding rail, and thus the ⌘⇧B worktree dialog, mounts only after the+ // session resolves a cwd that holds a repo. This happens on the first turn.+ const composer = page.locator('[contenteditable="true"]').first()+ await composer.click()+ await composer.type('create a repo-backed e2e session', { delay: 2 })+ await page.keyboard.press('Enter')+ await page.waitForFunction(+ prompt => (document.querySelector('[data-slot="aui_thread-viewport"]')?.textContent ?? '').includes(prompt),+ 'create a repo-backed e2e session',+ { timeout: 15_000 },+ )+ await expect(page.locator('.coding-status-bar')).toContainText('main')+})++test.afterAll(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('worktree dialog renders the base-branch picker over the dialog, not clipped by it', async () => {+ const page = fixture!.page++ await openWorktreeDialog()++ // Open the base-branch combobox. With 11 branches, the list is taller than+ // the space below the trigger. A popover that portals into the dialog's+ // `overflow-y-auto` box is therefore cut off.+ await page.getByRole('button', { name: /branch off/i }).click()+ await expect(page.getByPlaceholder('Search branches…')).toBeVisible()+ await expect(page.getByRole('option', { name: 'feature/alpha-one' })).toBeVisible()+++ // This check does not depend on pixels: the dialog's scroll box must not crop+ // the painted box of the popover. Measure the geometry, so a headless run+ // fails on this regression before a person looks at a diff image.+ const clipped = await page.evaluate(() => {+ const popover = document.querySelector('[data-slot="popover-content"]')+ const dialog = document.querySelector('[data-slot="dialog-content"]')++ if (!popover || !dialog) {+ return { reason: 'missing', clipped: true }+ }++ const p = popover.getBoundingClientRect()+ const d = dialog.getBoundingClientRect()+ const scrolls = window.getComputedStyle(dialog).overflowY++ return {+ reason: 'measured',+ // Only a clipping ancestor can crop the popover. The popover is cut when+ // the dialog scrolls its overflow AND the popover goes past the box of+ // the dialog.+ clipped: (scrolls === 'auto' || scrolls === 'scroll' || scrolls === 'hidden') &&+ (p.bottom > d.bottom + 1 || p.top < d.top - 1 || p.right > d.right + 1 || p.left < d.left - 1),+ }+ })++ expect(clipped.clipped, `base-branch popover is clipped by the dialog (${clipped.reason})`).toBe(false)++ await page.keyboard.press('Escape')+ await closeDialog()+})++test('worktree dialog convert-an-existing-branch sub-view lists the repo branches', async () => {+ const page = fixture!.page++ await openWorktreeDialog()+ await page.getByRole('button', { name: 'Convert an existing branch' }).click()++ await expect(page.getByPlaceholder('Search branches…')).toBeVisible()+ await expect(page.getByRole('option', { name: /feature\/alpha-one/ })).toBeVisible()+++ await closeDialog()+})++test('creating a branch with ctrl-shift-b updates the composer git-status branch and leaves no dialog behind', async ({}, testInfo) => {+ const page = fixture!.page+ const codingRow = page.locator('.coding-status-bar')++ await openWorktreeDialog()+ // Exactly one dialog instance. A second dialog here, hidden or empty, is the+ // symptom of the double-open bug.+ await expect(page.locator(DIALOG)).toHaveCount(1)++ const branchInput = page.locator('input[placeholder="e.g. my-feature"]').first()+ await expect(branchInput).toBeVisible()+ await branchInput.fill(BRANCH_NAME)+ // Select a base branch, so this test uses the same path as the user: open the+ // picker, select a branch, then submit. It does not use the default value.+ // The keyboard drives this step. The dialog still clips the popover, so a+ // mouse click on an option is not reliable until that bug is corrected. The+ // double-open check below is therefore independent of the clipping bug.+ await page.getByRole('button', { name: /branch off/i }).click()+ await page.getByPlaceholder('Search branches…').fill('main')+ await expect(page.getByRole('option', { name: 'main' }).first()).toBeVisible()+ await page.keyboard.press('Enter')+ await expect(page.locator('[data-slot="popover-content"]')).toHaveCount(0)++ await page.getByRole('button', { name: 'New worktree' }).click()++ await expect(codingRow).toContainText(BRANCH_NAME, { timeout: 15_000 })++ // The dialog must close and stay closed. No empty second dialog can remain+ // after the new worktree session starts.+ await expect(page.locator(DIALOG)).toHaveCount(0)+ await page.waitForTimeout(2000)+ await expect(page.locator(DIALOG)).toHaveCount(0)++ await page.screenshot({ path: testInfo.outputPath('composer-branch-after-create.png') })+})++test('ctrl-shift-b opens exactly one worktree dialog when a second composer is on screen', async ({}, testInfo) => {+ const page = fixture!.page++ // ⌘T / ctrl+T stacks a second session tile. That gives a second live composer+ // and therefore a second coding rail. Each rail mounted its own+ // WorktreeDialog, and each rail subscribed to the same global token. One+ // keypress therefore opened two stacked dialogs, and the dialog the user+ // dismissed showed an identical empty one behind it. One mount in the sidebar+ // makes that impossible by structure.+ await page.keyboard.press('Control+T')+ await expect(page.locator('.coding-status-bar')).toHaveCount(2, { timeout: 20_000 })++ await page.keyboard.press('Control+Shift+B')+ await expect(page.locator(DIALOG).first()).toBeVisible()+ // Wait: let the effect of every subscriber flush before the count.+ await page.waitForTimeout(500)++ const count = await page.locator(DIALOG).count()+ await page.screenshot({ path: testInfo.outputPath('worktree-dialog-two-composers.png') })++ expect(count, 'one hotkey press must open exactly one worktree dialog').toBe(1)++ // A dismissal then leaves nothing behind.+ await closeDialog()+})diff --git a/apps/desktop/e2e/zoom-preservation.spec.ts b/apps/desktop/e2e/zoom-preservation.spec.tsnew file mode 100644index 00000000000..f852c04a8a4--- /dev/null+++ b/apps/desktop/e2e/zoom-preservation.spec.ts@@ -0,0 +1,92 @@+/**+ * E2E regression: in-page route navigation must preserve the chosen UI scale.+ *+ * Desktop is a HashRouter over one file:// document, so every route is a+ * distinct URL to Chromium's per-URL zoom store, and a route with no record of+ * its own resolves to the host default (100%). In-page navigation fires no load+ * or window event, so nothing re-asserted the persisted level: switching+ * sessions dropped the window to 100% while Appearance kept reading the chosen+ * scale (#48658, #38854, #79863).+ *+ * Prerequisite: `npm run build` must have been run so dist/ exists.+ */++import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'+import { expect, test } from './test'++const SCALE = 110++let fixture: MockBackendFixture | null = null++async function readZoomPercent(): Promise<number> {+ return fixture!.page.evaluate(async () => {+ const desktop = window as unknown as {+ hermesDesktop: { zoom: { get: () => Promise<{ percent: number }> } }+ }++ return (await desktop.hermesDesktop.zoom.get()).percent+ })+}++async function setZoomPercent(percent: number): Promise<void> {+ await fixture!.page.evaluate(target => {+ const desktop = window as unknown as {+ hermesDesktop: { zoom: { setPercent: (percent: number) => void } }+ }++ desktop.hermesDesktop.zoom.setPercent(target)+ }, percent)+ await expect.poll(readZoomPercent).toBe(percent)+}++async function gotoRoute(route: string): Promise<void> {+ const page = fixture!.page++ const before = await page.evaluate(() => window.location.hash)++ await page.evaluate(target => {+ window.location.hash = target+ }, route)+ // The router may normalise or redirect the hash (an unknown route, a settings+ // tab it rewrites), so wait for the navigation itself rather than an exact+ // hash — every in-page hop must keep the chosen scale either way.+ await page.waitForFunction(previous => window.location.hash !== previous, before)+}++test.beforeAll(async () => {+ fixture = await setupMockBackend()+ await waitForAppReady(fixture, 120_000)+})++test.afterAll(async () => {+ await fixture?.cleanup()+ fixture = null+})++test('a non-default UI scale survives navigation to never-zoomed routes', async () => {+ await setZoomPercent(SCALE)++ // Routes Chromium has no zoom record for — what opening a new session looks+ // like to the per-URL store. Pre-fix, the first hop reports 100%.+ const fresh = `/e2e-zoom-${Date.now()}`++ for (const route of [`${fresh}-one`, `${fresh}-two`, '/settings?tab=config%3Aappearance']) {+ await gotoRoute(route)+ await expect.poll(readZoomPercent, { message: `UI scale after navigating to ${route}` }).toBe(SCALE)+ }+})++test('Cmd/Ctrl+N preserves a non-default UI scale', async () => {+ const page = fixture!.page++ await gotoRoute('/settings')+ await setZoomPercent(SCALE)++ await page.evaluate(() => {+ ;(document.activeElement as HTMLElement | null)?.blur()+ })+ await page.keyboard.press(process.platform === 'darwin' ? 'Meta+N' : 'Control+N')+ await page.waitForFunction(() => window.location.hash === '#/')++ await expect.poll(readZoomPercent).toBe(SCALE)+})