Skip to content

Automate browser based workflows with AI

Show 'Browser session expired' with the fix, not 'Browser error', when a run's session had already ended (SKY-17600) (#8783)

Shuchang Zhengba92e3e4cc28
diff --git a/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.test.tsx b/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.test.tsx
index 853f034fc..4a7f93ecd 100644
--- a/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.test.tsx
+++ b/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.test.tsx
@@ -39,6 +39,7 @@ describe("getRecoveryPaths", () => {
"AUTH_FAILURE",
"ELEMENT_NOT_FOUND",
"PAGE_LOAD_TIMEOUT",
+ "BROWSER_SESSION_EXPIRED",
]) {
expect(getRecoveryPaths(category).length).toBeGreaterThanOrEqual(2);
}
@@ -158,6 +159,33 @@ describe("FirstRunRecoveryGuidance", () => {
expect(navigateMock).toHaveBeenCalledWith("/agents");
});
+ it("sends an expired browser session to create a new session instead of offering retry", () => {
+ const onRetry = vi.fn();
+ const { getByTestId, queryByTestId } = render(
+ <FirstRunRecoveryGuidance
+ telemetryContext={{
+ ...telemetryContext,
+ failureCategory: "BROWSER_SESSION_EXPIRED",
+ }}
+ onRetry={onRetry}
+ />,
+ );
+
+ expect(queryByTestId("recovery-path-retry")).toBeNull();
+
+ fireEvent.click(getByTestId("recovery-path-create_browser_session"));
+
+ expect(navigateMock).toHaveBeenCalledWith("/browser-sessions");
+ expect(onRetry).not.toHaveBeenCalled();
+ expect(posthog.capture).toHaveBeenCalledWith(
+ "recovery_guidance_clicked",
+ expect.objectContaining({
+ failure_category: "BROWSER_SESSION_EXPIRED",
+ path_id: "create_browser_session",
+ }),
+ );
+ });
+
it("opens external recovery links without an opener or referrer", () => {
const open = vi.spyOn(window, "open").mockImplementation(() => null);
const { getByTestId } = render(
diff --git a/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.tsx b/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.tsx
index 76944ba56..b19124ba1 100644
--- a/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.tsx
+++ b/skyvern-frontend/src/components/onboarding/FirstRunRecoveryGuidance.tsx
@@ -63,6 +63,9 @@ function FirstRunRecoveryGuidance({
? workflowEditorPath(workflowPermanentId, studioEnabled)
: "/agents";
}
+ if (id === "create_browser_session") {
+ return "/browser-sessions";
+ }
return "/credentials";
}
diff --git a/skyvern-frontend/src/components/onboarding/recoveryPaths.ts b/skyvern-frontend/src/components/onboarding/recoveryPaths.ts
index ce2baa5ff..2932af838 100644
--- a/skyvern-frontend/src/components/onboarding/recoveryPaths.ts
+++ b/skyvern-frontend/src/components/onboarding/recoveryPaths.ts
@@ -4,6 +4,7 @@ type RecoveryPathId =
| "retry"
| "edit_workflow"
| "update_credentials"
+ | "create_browser_session"
| "view_docs"
| "contact_support";
@@ -24,6 +25,11 @@ const UPDATE_CREDENTIALS: RecoveryPath = {
label: "Update credentials",
kind: "navigate",
};
+const CREATE_BROWSER_SESSION: RecoveryPath = {
+ id: "create_browser_session",
+ label: "Create browser session",
+ kind: "navigate",
+};
const VIEW_DOCS: RecoveryPath = {
id: "view_docs",
label: "View troubleshooting docs",
@@ -39,6 +45,10 @@ const CONTACT_SUPPORT: RecoveryPath = {
// Always returns at least two paths so the failure state offers real choices.
function getRecoveryPaths(failureCategory: string | null): RecoveryPath[] {
const category = failureCategory?.toLowerCase() ?? "";
+ // Retrying against the same timed-out session fails identically, so Retry is not offered.
+ if (category === "browser_session_expired") {
+ return [CREATE_BROWSER_SESSION, VIEW_DOCS];
+ }
if (/credential|auth|login|password|2fa|verification/.test(category)) {
return [UPDATE_CREDENTIALS, RETRY];
}
diff --git a/skyvern-frontend/src/util/failureCategoryDisplay.ts b/skyvern-frontend/src/util/failureCategoryDisplay.ts
index 8a3b20968..ffcb85e76 100644
--- a/skyvern-frontend/src/util/failureCategoryDisplay.ts
+++ b/skyvern-frontend/src/util/failureCategoryDisplay.ts
@@ -24,6 +24,11 @@ const FAILURE_CATEGORY_DISPLAY = {
description:
"The browser crashed or the page closed unexpectedly. Retrying usually helps.",
},
+ BROWSER_SESSION_EXPIRED: {
+ label: "Browser session expired",
+ description:
+ "The browser session this run was sent to had already reached its time limit, so the run never started. Running it again with the same browser session will fail the same way. Create a new browser session and run again, or leave the browser session empty to start a fresh browser.",
+ },
NAVIGATION_FAILURE: {
label: "Couldn't open the page",
description: