Skip to content

Commit 36fdb34

Browse files
committed
fix(desktop): fix the races behind retried e2e checks and stop retrying in CI
1 parent 017ac49 commit 36fdb34

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎apps/desktop/e2e/browser-page-dialogs.spec.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,15 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
215215
expect(result.ok, result.error).toBe(true)
216216
return result.ok ? result.result : undefined
217217
}
218+
const pageDialog = () => shell.evaluate(() => (globalThis as Bridge).pageDialog ?? null)
218219
/** Browser-chrome actions are user gestures, so each follows a real click in Sim. */
219220
const panelAction = async (action: Record<string, unknown>) => {
220-
if (action.action === 'respond-dialog' && (await shell.getByRole('dialog').count())) {
221+
// The store holds a dialog before its modal finishes the native-surface handshake and
222+
// renders, so a live dialog is answered through the modal once it appears.
223+
if (
224+
action.action === 'respond-dialog' &&
225+
(await pageDialog())?.requestId === action.requestId
226+
) {
221227
await shell
222228
.getByRole('button', {
223229
name: action.allowed ? 'Leave' : 'Stay',
@@ -236,7 +242,6 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
236242
{ action, scope: SCOPE }
237243
)
238244
}
239-
const pageDialog = () => shell.evaluate(() => (globalThis as Bridge).pageDialog ?? null)
240245
const inPage = <T>(script: string) =>
241246
shellApp.evaluate(
242247
async ({ webContents }, { script, url }) =>

‎apps/desktop/e2e/chat-panel.spec.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ test('chat panel sizes survive navigation, chat switches, collapse, and layout c
379379
})
380380
await check('assigning a permanent chat ID lets an active drag finish', async () => {
381381
await page.getByRole('button', { name: 'pending:chat', exact: true }).click()
382+
await expectWidth(720)
382383
await dragTo(620)
383384
const rect = await beginDrag()
384385
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
402403
'cancelling before the first animation frame restores native browser bounds',
403404
async () => {
404405
await page.getByRole('button', { name: 'pending:native', exact: true }).click()
406+
await expectWidth(720)
405407
await dragTo(698)
406408
await shell.evaluate(({ app, BrowserWindow }) => {
407409
app.focus({ steal: true })

‎apps/desktop/playwright.config.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ export default defineConfig({
44
testDir: './e2e',
55
timeout: 90_000,
66
workers: 1,
7-
retries: process.env.CI ? 1 : 0,
87
reporter: process.env.CI ? [['github'], ['list']] : [['list']],
98
})

‎apps/desktop/src/main/browser-agent/session.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,6 +2058,11 @@ function userOwnsPageDialogs(tab: AgentTab): boolean {
20582058
function holdPageDialogForUser(tab: AgentTab, respond: (accept: boolean) => void): void {
20592059
if (tab.pageDialog) answerPageDialog(tab, false)
20602060
tab.pageDialog = { request: { requestId: generateId(), kind: 'beforeunload' }, respond }
2061+
// The renderer's modal now holds the decision. A reload pressed from the page keeps keyboard
2062+
// focus in the native view the modal hides, where Escape and Enter would never reach it;
2063+
// answering returns focus to the page (focusAfterPageDialog).
2064+
const win = panelWindow()
2065+
if (win && !win.isDestroyed()) win.webContents.focus()
20612066
events?.onPageStateChanged(tab.view.webContents)
20622067
}
20632068

0 commit comments

Comments
 (0)