From 36fdb344989b4e3df0258537c6087a421f5b2c84 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 19 Nov 2026 22:17:48 -0800 Subject: [PATCH] fix(desktop): fix the races behind retried e2e checks and stop retrying in CI --- apps/desktop/e2e/browser-page-dialogs.spec.ts | 9 +++++++-- apps/desktop/e2e/chat-panel.spec.ts | 2 ++ apps/desktop/playwright.config.ts | 1 - apps/desktop/src/main/browser-agent/session.ts | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/desktop/e2e/browser-page-dialogs.spec.ts b/apps/desktop/e2e/browser-page-dialogs.spec.ts index 667a7ae74f8..7a79887abb7 100644 --- a/apps/desktop/e2e/browser-page-dialogs.spec.ts +++ b/apps/desktop/e2e/browser-page-dialogs.spec.ts @@ -215,9 +215,15 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`, expect(result.ok, result.error).toBe(true) return result.ok ? result.result : undefined } + const pageDialog = () => shell.evaluate(() => (globalThis as Bridge).pageDialog ?? null) /** Browser-chrome actions are user gestures, so each follows a real click in Sim. */ const panelAction = async (action: Record) => { - if (action.action === 'respond-dialog' && (await shell.getByRole('dialog').count())) { + // The store holds a dialog before its modal finishes the native-surface handshake and + // renders, so a live dialog is answered through the modal once it appears. + if ( + action.action === 'respond-dialog' && + (await pageDialog())?.requestId === action.requestId + ) { await shell .getByRole('button', { name: action.allowed ? 'Leave' : 'Stay', @@ -236,7 +242,6 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`, { action, scope: SCOPE } ) } - const pageDialog = () => shell.evaluate(() => (globalThis as Bridge).pageDialog ?? null) const inPage = (script: string) => shellApp.evaluate( async ({ webContents }, { script, url }) => diff --git a/apps/desktop/e2e/chat-panel.spec.ts b/apps/desktop/e2e/chat-panel.spec.ts index bb41187fa1d..9731e6011d2 100644 --- a/apps/desktop/e2e/chat-panel.spec.ts +++ b/apps/desktop/e2e/chat-panel.spec.ts @@ -379,6 +379,7 @@ test('chat panel sizes survive navigation, chat switches, collapse, and layout c }) await check('assigning a permanent chat ID lets an active drag finish', async () => { await page.getByRole('button', { name: 'pending:chat', exact: true }).click() + await expectWidth(720) await dragTo(620) const rect = await beginDrag() await page.mouse.move(rect.x + 100, rect.y + 100, { steps: 12 }) @@ -402,6 +403,7 @@ test('chat panel sizes survive navigation, chat switches, collapse, and layout c 'cancelling before the first animation frame restores native browser bounds', async () => { await page.getByRole('button', { name: 'pending:native', exact: true }).click() + await expectWidth(720) await dragTo(698) await shell.evaluate(({ app, BrowserWindow }) => { app.focus({ steal: true }) diff --git a/apps/desktop/playwright.config.ts b/apps/desktop/playwright.config.ts index 142b184e05d..00181f3924d 100644 --- a/apps/desktop/playwright.config.ts +++ b/apps/desktop/playwright.config.ts @@ -4,6 +4,5 @@ export default defineConfig({ testDir: './e2e', timeout: 90_000, workers: 1, - retries: process.env.CI ? 1 : 0, reporter: process.env.CI ? [['github'], ['list']] : [['list']], }) diff --git a/apps/desktop/src/main/browser-agent/session.ts b/apps/desktop/src/main/browser-agent/session.ts index e912baa5722..ad0cf9dcc28 100644 --- a/apps/desktop/src/main/browser-agent/session.ts +++ b/apps/desktop/src/main/browser-agent/session.ts @@ -2058,6 +2058,11 @@ function userOwnsPageDialogs(tab: AgentTab): boolean { function holdPageDialogForUser(tab: AgentTab, respond: (accept: boolean) => void): void { if (tab.pageDialog) answerPageDialog(tab, false) tab.pageDialog = { request: { requestId: generateId(), kind: 'beforeunload' }, respond } + // The renderer's modal now holds the decision. A reload pressed from the page keeps keyboard + // focus in the native view the modal hides, where Escape and Enter would never reach it; + // answering returns focus to the page (focusAfterPageDialog). + const win = panelWindow() + if (win && !win.isDestroyed()) win.webContents.focus() events?.onPageStateChanged(tab.view.webContents) }