Skip to content

Automate browser based workflows with AI

feat(SKY-9737): wire browser profile selector into workflow run form (#5962)

Celal Zamanoğludeafee4ab20c
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index 7ec9d38e9..a0c77c61f 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -594,6 +594,7 @@ export type WorkflowRunStatusApiResponse = {
task_v2: TaskV2 | null;
workflow_title: string | null;
browser_session_id: string | null;
+ browser_profile_id: string | null;
max_screenshot_scrolls: number | null;
run_with: string | null;
waiting_for_verification_code?: boolean;
@@ -626,6 +627,7 @@ export type WorkflowRunStatusApiResponseWithWorkflow = {
task_v2: TaskV2 | null;
workflow_title: string | null;
browser_session_id: string | null;
+ browser_profile_id: string | null;
max_screenshot_scrolls: number | null;
run_with: string | null;
workflow: WorkflowApiResponse;
@@ -688,6 +690,17 @@ export type Createv2TaskRequest = {
browser_session_id?: string | null;
};
+export type BrowserProfileApiResponse = {
+ browser_profile_id: string;
+ organization_id: string;
+ name: string;
+ description: string | null;
+ source_browser_type: string | null;
+ created_at: string;
+ modified_at: string;
+ deleted_at: string | null;
+};
+
export type PasswordCredentialApiResponse = {
username: string;
totp_type: "authenticator" | "email" | "text" | "none";
diff --git a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx
index b25c1247d..66dd678e9 100644
--- a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx
+++ b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx
@@ -57,6 +57,7 @@ import {
isNestedLoopWorkflowBlock,
} from "./types/workflowTypes";
import { WorkflowParameterInput } from "./WorkflowParameterInput";
+import { BrowserProfileSelector } from "./components/BrowserProfileSelector";
import { TestWebhookDialog } from "@/components/TestWebhookDialog";
import * as env from "@/util/env";
@@ -186,6 +187,7 @@ type RunWorkflowRequestBody = {
proxy_location: ProxyLocation | null;
webhook_callback_url?: string | null;
browser_session_id: string | null;
+ browser_profile_id?: string | null;
max_screenshot_scrolls?: number | null;
extra_http_headers?: Record<string, string> | null;
browser_address?: string | null;
@@ -201,6 +203,7 @@ function getRunWorkflowRequestBody(
webhookCallbackUrl,
proxyLocation,
browserSessionId,
+ browserProfileId,
cdpAddress,
maxScreenshotScrolls,
extraHttpHeaders,
@@ -215,11 +218,13 @@ function getRunWorkflowRequestBody(
);
const bsi = browserSessionId?.trim() === "" ? null : browserSessionId;
+ const bpi = browserProfileId?.trim() === "" ? null : browserProfileId;
const body: RunWorkflowRequestBody = {
data: parsedParameters,
proxy_location: proxyLocation,
browser_session_id: bsi,
+ browser_profile_id: bpi,
browser_address: cdpAddress,
run_with: runWith,
ai_fallback: aiFallback ?? true,
@@ -281,6 +286,7 @@ type RunWorkflowFormType = Record<string, unknown> & {
webhookCallbackUrl: string;
proxyLocation: ProxyLocation;
browserSessionId: string | null;
+ browserProfileId: string | null;
cdpAddress: string | null;
maxScreenshotScrolls: number | null;
extraHttpHeaders: string | null;
@@ -323,6 +329,7 @@ function RunWorkflowForm({
webhookCallbackUrl: initialSettings.webhookCallbackUrl,
proxyLocation: initialSettings.proxyLocation ?? ProxyLocation.Residential,
browserSessionId: null,
+ browserProfileId: null,
cdpAddress: initialSettings.cdpAddress,
maxScreenshotScrolls: initialSettings.maxScreenshotScrolls,
extraHttpHeaders: initialSettings.extraHttpHeaders
@@ -465,6 +472,7 @@ function RunWorkflowForm({
webhookCallbackUrl,
proxyLocation,
browserSessionId,
+ browserProfileId,
maxScreenshotScrolls,
extraHttpHeaders,
cdpAddress,
@@ -482,6 +490,7 @@ function RunWorkflowForm({
webhookCallbackUrl,
proxyLocation,
browserSessionId,
+ browserProfileId,
maxScreenshotScrolls,
extraHttpHeaders,
cdpAddress,
@@ -495,6 +504,7 @@ function RunWorkflowForm({
"webhookCallbackUrl",
"proxyLocation",
"browserSessionId",
+ "browserProfileId",
"maxScreenshotScrolls",
"extraHttpHeaders",
"cdpAddress",
@@ -1013,6 +1023,38 @@ function RunWorkflowForm({
);
}}
/>
+ <FormField
+ control={form.control}
+ name="browserProfileId"
+ render={({ field }) => {
+ return (
+ <FormItem>
+ <div className="flex gap-16">
+ <FormLabel>
+ <div className="w-72">
+ <div className="flex items-center gap-2 text-lg">
+ Browser Profile
+ </div>
+ <h2 className="text-sm text-slate-400">
+ Load a saved browser profile to reuse cookies,
+ storage, and signed-in state for this run.
+ </h2>
+ </div>
+ </FormLabel>
+ <div className="w-full space-y-2">
+ <FormControl>
+ <BrowserProfileSelector
+ value={field.value}
+ onChange={field.onChange}
+ />
+ </FormControl>
+ <FormMessage />
+ </div>
+ </div>
+ </FormItem>
+ );
+ }}
+ />
<FormField
key="cdpAddress"
control={form.control}
diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx
index 095b0df79..dbfb7d895 100644
--- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx
+++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx
@@ -397,6 +397,11 @@ function WorkflowRun() {
Browser Session: {workflowRun.browser_session_id}
</Link>
)}
+ {workflowRun?.browser_profile_id && (
+ <span className="font-mono text-sm text-slate-400">
+ Browser Profile: {workflowRun.browser_profile_id}
+ </span>
+ )}
</div>
<div className="flex gap-2">
diff --git a/skyvern-frontend/src/routes/workflows/components/BrowserProfileSelector.tsx b/skyvern-frontend/src/routes/workflows/components/BrowserProfileSelector.tsx
new file mode 100644
index 000000000..2f3920d14
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/components/BrowserProfileSelector.tsx
@@ -0,0 +1,74 @@
+import {
+ CustomSelectItem,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectItemText,
+ SelectSeparator,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Skeleton } from "@/components/ui/skeleton";
+import { useBrowserProfilesQuery } from "../hooks/useBrowserProfilesQuery";
+
+const NONE_VALUE = "__none__";
+
+type Props = {
+ value: string | null;
+ onChange: (value: string | null) => void;
+ placeholder?: string;
+};
+
+function BrowserProfileSelector({ value, onChange, placeholder }: Props) {
+ const { data: profiles, isLoading, isError } = useBrowserProfilesQuery();
+
+ if (isLoading) {
+ return <Skeleton className="h-10 w-full" />;
+ }
+
+ if (isError) {
+ return (
+ <Select disabled>
+ <SelectTrigger>
+ <SelectValue placeholder="Failed to load browser profiles" />
+ </SelectTrigger>
+ </Select>
+ );
+ }
+
+ const selectValue = value === null || value === "" ? NONE_VALUE : value;
+
+ return (
+ <Select
+ value={selectValue}
+ onValueChange={(next) => {
+ onChange(next === NONE_VALUE ? null : next);
+ }}
+ >
+ <SelectTrigger>
+ <SelectValue placeholder={placeholder ?? "Select a browser profile"} />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value={NONE_VALUE}>None</SelectItem>
+ {profiles && profiles.length > 0 && <SelectSeparator />}
+ {profiles?.map((profile) => (
+ <CustomSelectItem
+ key={profile.browser_profile_id}
+ value={profile.browser_profile_id}
+ >
+ <div className="space-y-1">
+ <p className="text-sm font-medium">
+ <SelectItemText>{profile.name}</SelectItemText>
+ </p>
+ {profile.description && (
+ <p className="text-xs text-slate-400">{profile.description}</p>
+ )}
+ </div>
+ </CustomSelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ );
+}
+
+export { BrowserProfileSelector };
diff --git a/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.ts
new file mode 100644
index 000000000..6f5ee583a
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.ts
@@ -0,0 +1,37 @@
+import { getClient } from "@/api/AxiosClient";
+import { BrowserProfileApiResponse } from "@/api/types";
+import { useCredentialGetter } from "@/hooks/useCredentialGetter";
+import { useQuery } from "@tanstack/react-query";
+
+type QueryReturnType = Array<BrowserProfileApiResponse>;
+type UseQueryOptions = Omit<
+ Parameters<typeof useQuery<QueryReturnType>>[0],
+ "queryKey" | "queryFn"
+>;
+
+type Props = UseQueryOptions & {
+ includeDeleted?: boolean;
+};
+
+function useBrowserProfilesQuery(props: Props = {}) {
+ const { includeDeleted = false, ...queryOptions } = props;
+ const credentialGetter = useCredentialGetter();
+
+ return useQuery<QueryReturnType>({
+ queryKey: ["browserProfiles", includeDeleted],
+ queryFn: async () => {
+ const client = await getClient(credentialGetter, "sans-api-v1");
+ const params = new URLSearchParams();
+ if (includeDeleted) {
+ params.set("include_deleted", "true");
+ }
+ return client
+ .get("/browser_profiles", { params })
+ .then((res) => res.data);
+ },
+ staleTime: 5 * 60 * 1000,
+ ...queryOptions,
+ });
+}
+
+export { useBrowserProfilesQuery };