Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/desktop/e2e/browser-page-dialogs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>) => {
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',
Expand All @@ -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 = <T>(script: string) =>
shellApp.evaluate(
async ({ webContents }, { script, url }) =>
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/e2e/chat-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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 })
Expand Down
1 change: 0 additions & 1 deletion apps/desktop/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']],
})
5 changes: 5 additions & 0 deletions apps/desktop/src/main/browser-agent/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Loading