Skip to content
Open
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
29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Run tests
run: npm run test:ci
23 changes: 18 additions & 5 deletions app/api/cua/agent/browserbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,21 @@ export class BrowserbaseBrowser extends BasePlaywrightComputer {
const browser = await chromium.connectOverCDP(this.session.connectUrl, {
timeout: 1000 * 60,
});
const context = browser.contexts()[0];
const [width, height] = this.dimensions;
const context =
browser.contexts()[0] ??
(await browser.newContext({
viewport: {
width,
height,
},
}));
// Inject inline cursor-rendering script globally for every page
const pages = context.pages();
const page = pages[pages.length - 1];
const page =
pages.find((existingPage) => existingPage.url() !== "about:blank") ??
pages[pages.length - 1] ??
(await context.newPage());
page
.evaluate(() => {
const CURSOR_ID = "__cursor__";
Expand Down Expand Up @@ -166,9 +177,11 @@ export class BrowserbaseBrowser extends BasePlaywrightComputer {
console.error("Error injecting cursor-rendering script:", error);
});

// Only navigate to Google if it's a new session
if (!this.sessionId) {
await page.goto("https://www.google.com");
// Bootstrap to a real page to avoid stalling on about:blank.
if (!this.sessionId || page.url() === "about:blank") {
await page.goto("https://www.google.com", {
waitUntil: "domcontentloaded",
});
}

return [browser, page];
Expand Down
Loading
Loading