Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/rare-bikes-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Fix handling possible navigation on cua clicks
8 changes: 8 additions & 0 deletions lib/handlers/agentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@/types/agent";
import { Stagehand } from "../index";
import { StagehandFunctionName } from "@/types/stagehand";
import { handlePossiblePageNavigation } from "./handlerUtils/actHandlerUtils";

export class StagehandAgentHandler {
private stagehand: Stagehand;
Expand Down Expand Up @@ -215,6 +216,13 @@ export class StagehandAgentHandler {
await this.page.mouse.click(x as number, y as number, {
button: button as "left" | "right",
});
await handlePossiblePageNavigation(
"clicked",
`(coordinates) x:${x}, y:${y}`,
this.page.url(),
this.stagehandPage,
this.logger,
);
return { success: true };
}

Expand Down
2 changes: 1 addition & 1 deletion lib/handlers/handlerUtils/actHandlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export async function fallbackLocatorMethod(ctx: MethodHandlerContext) {
}
}

async function handlePossiblePageNavigation(
export async function handlePossiblePageNavigation(
actionDescription: string,
xpath: string,
initialUrl: string,
Expand Down