Skip to content

Automate browser based workflows with AI

feat(SKY-12649): Browser Profiles Refresh-in-place, role badges, used-by delete guards (#7548)

Celal Zamanoğlu677cdc9a7ed4
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index b7e6ed3ce..782720309 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -925,11 +925,30 @@ export type BrowserProfileApiResponse = {
proxy_session_id?: string | null;
is_managed?: boolean;
workflow_permanent_id?: string | null;
+ // Batched by the list endpoint so rows show the credential-login role without a per-row usage fetch.
+ linked_credential_name?: string | null;
created_at: string;
modified_at: string;
deleted_at: string | null;
};
+export type BrowserProfileUsageWorkflow = {
+ workflow_permanent_id: string;
+ title: string;
+ via: "browser_profile_id" | "seed_browser_profile_id";
+};
+
+export type BrowserProfileUsageCredential = {
+ credential_id: string;
+ name: string;
+};
+
+export type BrowserProfileUsage = {
+ workflows: Array<BrowserProfileUsageWorkflow>;
+ credentials: Array<BrowserProfileUsageCredential>;
+ recent_seeded_run_count: number;
+};
+
export type PasswordCredentialApiResponse = {
username: string;
totp_type: "authenticator" | "email" | "text" | "none";
diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsx
index 067b44641..953974fb4 100644
--- a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsx
+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsx
@@ -16,6 +16,7 @@ import { CopyText } from "@/routes/workflows/editor/Workspace";
import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat";
import { DeleteBrowserProfileButton } from "./DeleteBrowserProfileButton";
+import { RefreshBrowserProfileButton } from "./RefreshBrowserProfileButton";
import { RenameBrowserProfileDialog } from "./RenameBrowserProfileDialog";
import { useBrowserProfileQuery } from "./hooks/useBrowserProfileQuery";
import { useUpdateBrowserProfileMutation } from "./hooks/useBrowserProfileMutations";
@@ -115,6 +116,12 @@ function BrowserProfileDetailPage() {
)}
</div>
<div className="flex gap-2">
+ {!profile.deleted_at && (
+ <RefreshBrowserProfileButton
+ profile={profile}
+ label="Refresh"
+ />
+ )}
<Button
variant="secondary"
onClick={() => setRenameOpen(true)}
diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsx
index 05d7b1948..a3488f296 100644
--- a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsx
+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsx
@@ -16,7 +16,13 @@ import {
} from "@/components/ui/tooltip";
import { basicTimeFormat, compactLocalDateTime } from "@/util/timeFormat";
+import {
+ BROWSER_PROFILE_ROLE_BADGE,
+ BROWSER_PROFILE_ROLE_FRESHNESS,
+ getBrowserProfileRole,
+} from "./browserProfileRole";
import { DeleteBrowserProfileButton } from "./DeleteBrowserProfileButton";
+import { RefreshBrowserProfileButton } from "./RefreshBrowserProfileButton";
import { RenameBrowserProfileDialog } from "./RenameBrowserProfileDialog";
type Props = {
@@ -36,6 +42,13 @@ function BrowserProfileItem({
}: Props) {
const navigate = useNavigate();
const [renameOpen, setRenameOpen] = useState(false);
+ const role = getBrowserProfileRole(profile);
+ const badgeTitle =
+ role === "credential" && profile.linked_credential_name
+ ? `${BROWSER_PROFILE_ROLE_FRESHNESS.credential} Linked to ${profile.linked_credential_name}.`
+ : role === "plain"
+ ? `${BROWSER_PROFILE_ROLE_FRESHNESS.plain} Updated ${compactLocalDateTime(profile.modified_at)}.`
+ : BROWSER_PROFILE_ROLE_FRESHNESS.workflow_memory;
const handleRowClick = (event: React.MouseEvent<HTMLTableRowElement>) => {
if (event.ctrlKey || event.metaKey) {
@@ -74,15 +87,9 @@ function BrowserProfileItem({
<span className="truncate" title={profile.name}>
{profile.name}
</span>
- {profile.is_managed ? (
- <Badge
- variant="secondary"
- className="shrink-0"
- title="Auto-saved from a Save & Reuse Session workflow. Recreated automatically on the next run."
- >
- Auto-managed
- </Badge>
- ) : null}
+ <Badge variant="secondary" className="shrink-0" title={badgeTitle}>
+ {BROWSER_PROFILE_ROLE_BADGE[role]}
+ </Badge>
</div>
<div
className="flex min-w-0 items-center gap-1 text-xs text-muted-foreground"
@@ -119,6 +126,7 @@ function BrowserProfileItem({
</TableCell>
<TableCell onClick={stopRowClick}>
<div className="flex justify-end gap-2">
+ <RefreshBrowserProfileButton profile={profile} />
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileUsageList.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileUsageList.tsx
new file mode 100644
index 000000000..32d8585b7
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileUsageList.tsx
@@ -0,0 +1,80 @@
+import { BrowserProfileUsage } from "@/api/types";
+import { Skeleton } from "@/components/ui/skeleton";
+
+type Props = {
+ usage: BrowserProfileUsage | undefined;
+ isLoading: boolean;
+};
+
+function plural(count: number, noun: string) {
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
+}
+
+function BrowserProfileUsageList({ usage, isLoading }: Props) {
+ if (isLoading) {
+ return (
+ <div className="space-y-2">
+ <Skeleton className="h-4 w-40" />
+ <Skeleton className="h-4 w-56" />
+ </div>
+ );
+ }
+
+ if (!usage) {
+ return null;
+ }
+
+ const { workflows, credentials, recent_seeded_run_count } = usage;
+ const nothingUsesIt =
+ workflows.length === 0 &&
+ credentials.length === 0 &&
+ recent_seeded_run_count === 0;
+
+ if (nothingUsesIt) {
+ return (
+ <p className="text-sm text-muted-foreground">
+ Nothing else uses this browser profile yet.
+ </p>
+ );
+ }
+
+ return (
+ <div className="space-y-3 text-sm">
+ {credentials.length > 0 && (
+ <div className="space-y-1">
+ <p className="font-medium">
+ Linked to {plural(credentials.length, "credential")}
+ </p>
+ <ul className="list-disc space-y-0.5 pl-5 text-muted-foreground">
+ {credentials.map((credential) => (
+ <li key={credential.credential_id} className="truncate">
+ {credential.name}
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+ {workflows.length > 0 && (
+ <div className="space-y-1">
+ <p className="font-medium">
+ Used by {plural(workflows.length, "workflow")}
+ </p>
+ <ul className="list-disc space-y-0.5 pl-5 text-muted-foreground">
+ {workflows.map((workflow) => (
+ <li key={workflow.workflow_permanent_id} className="truncate">
+ {workflow.title}
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+ {recent_seeded_run_count > 0 && (
+ <p className="text-muted-foreground">
+ {plural(recent_seeded_run_count, "recent run")} used this profile.
+ </p>
+ )}
+ </div>
+ );
+}
+
+export { BrowserProfileUsageList };
diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.test.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.test.tsx
index 5c4b33356..9e5b5cb4b 100644
--- a/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.test.tsx
+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.test.tsx
@@ -115,4 +115,15 @@ describe("BrowserProfilesList paginated row selection", () => {
// table renders, so the highlighted rows are exactly the rendered range.
expect(selectionState()).toEqual(["true", "true", "true", "true"]);
});
+
+ it("bulk-delete dialog warns credentials unlink and pinned workflows need repointing", () => {
+ renderList(makeProfiles(2));
+
+ fireEvent.click(screen.getByLabelText("select-Profile 0"));
+ fireEvent.click(screen.getByRole("button", { name: "Delete" }));
+
+ expect(
+ screen.getByText(/Linked credentials are unlinked automatically/),
+ ).toBeTruthy();
+ });
});
diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsx
index c4a358a52..02a3ed1a5 100644
--- a/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsx
+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsx
@@ -395,7 +395,9 @@ function BrowserProfilesList({ searchKey, managed }: Props = {}) {
{deleteDialog.targets.length === 1
? "browser profile"
: "browser profiles"}
- ? This action cannot be undone.
+ ? Linked credentials are unlinked automatically; any workflows
+ pinned to these profiles will need repointing. This action cannot
+ be undone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
diff --git a/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.test.tsx b/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.test.tsx
new file mode 100644
index 000000000..154492336
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.test.tsx
@@ -0,0 +1,119 @@
+// @vitest-environment jsdom
+
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import type {
+ BrowserProfileApiResponse,
+ BrowserProfileUsage,
+} from "@/api/types";
+
+import { DeleteBrowserProfileButton } from "./DeleteBrowserProfileButton";
+import { deleteWarning } from "./browserProfileRole";
+import { useBrowserProfileUsageQuery } from "./hooks/useBrowserProfileUsageQuery";
+
+vi.mock("./hooks/useBrowserProfileUsageQuery", () => ({
+ useBrowserProfileUsageQuery: vi.fn(),
+}));
+vi.mock("./hooks/useBrowserProfileMutations", () => ({
+ useDeleteBrowserProfileMutation: () => ({
+ mutateAsync: vi.fn(),
+ isPending: false,
+ }),
+}));
+
+function makeProfile(
+ overrides: Partial<BrowserProfileApiResponse> = {},
+): BrowserProfileApiResponse {
+ return {
+ browser_profile_id: "bp_x",
+ organization_id: "org_1",
+ name: "My Profile",
+ description: null,
+ source_browser_type: null,
+ is_managed: false,
+ created_at: "2026-06-01T00:00:00.000Z",
+ modified_at: "2026-06-01T00:00:00.000Z",
+ deleted_at: null,
+ ...overrides,
+ };
+}
+
+function usage(over: Partial<BrowserProfileUsage> = {}): BrowserProfileUsage {
+ return {
+ workflows: [],
+ credentials: [],
+ recent_seeded_run_count: 0,
+ ...over,
+ };
+}
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe("deleteWarning copy selection", () => {
+ it("warns that a managed profile is the workflow's memory", () => {
+ expect(deleteWarning(makeProfile({ is_managed: true }), usage())).toContain(
+ "clears the workflow's remembered browser",
+ );
+ });
+
+ it("warns a credential-linked delete unlinks the saved login, by name", () => {
+ const warning = deleteWarning(
+ makeProfile(),
+ usage({ credentials: [{ credential_id: "c", name: "Bank portal" }] }),
+ );
+ expect(warning).toContain("unlinks the saved login from Bank portal");
+ });
+
+ it("warns pinned workflows will need repointing for a plain profile", () => {
+ const warning = deleteWarning(
+ makeProfile(),
+ usage({
+ workflows: [
+ { workflow_permanent_id: "w", title: "T", via: "browser_profile_id" },
+ ],
+ }),
+ );
+ expect(warning).toContain("Workflows pinned to this profile");
+ });
+
+ it("falls back to a plain unrecoverable-delete warning", () => {
+ expect(deleteWarning(makeProfile(), usage())).toContain(
+ "can't be recovered",
+ );
+ });
+});
+
+describe("DeleteBrowserProfileButton usage gating", () => {
+ function open() {
+ render(<DeleteBrowserProfileButton profile={makeProfile()} />);
+ fireEvent.click(screen.getByLabelText("Delete browser profile"));
+ }
+
+ it("disables Delete while the used-by list is still loading", () => {
+ vi.mocked(useBrowserProfileUsageQuery).mockReturnValue({
+ data: undefined,
+ isLoading: true,
+ } as unknown as ReturnType<typeof useBrowserProfileUsageQuery>);
+ open();
+ const button = screen.getByRole("button", {
+ name: "Delete",
+ }) as HTMLButtonElement;
+ expect(button.disabled).toBe(true);
+ });
+
+ it("enables Delete once usage has loaded", () => {
+ vi.mocked(useBrowserProfileUsageQuery).mockReturnValue({
+ data: usage(),
+ isLoading: false,
+ } as unknown as ReturnType<typeof useBrowserProfileUsageQuery>);
+ open();
+ const button = screen.getByRole("button", {
+ name: "Delete",
+ }) as HTMLButtonElement;
+ expect(button.disabled).toBe(false);
+ });
+});
diff --git a/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsx b/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsx
index 2c7f93a34..063d4e468 100644
--- a/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsx
+++ b/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsx
@@ -1,4 +1,5 @@
import { ReloadIcon, TrashIcon } from "@radix-ui/react-icons";
+import { useState } from "react";
import { BrowserProfileApiResponse } from "@/api/types";
import { Button } from "@/components/ui/button";
@@ -18,6 +19,9 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
+import { BrowserProfileUsageList } from "./BrowserProfileUsageList";
+import { deleteWarning } from "./browserProfileRole";
+import { useBrowserProfileUsageQuery } from "./hooks/useBrowserProfileUsageQuery";
import { useDeleteBrowserProfileMutation } from "./hooks/useBrowserProfileMutations";
type Props = {
@@ -26,10 +30,15 @@ type Props = {
};
function DeleteBrowserProfileButton({ profile, onDeleted }: Props) {
+ const [open, setOpen] = useState(false);
const deleteMutation = useDeleteBrowserProfileMutation();
+ const { data: usage, isLoading } = useBrowserProfileUsageQuery(
+ profile.browser_profile_id,
+ { enabled: open },
+ );
return (
- <Dialog>
+ <Dialog open={open} onOpenChange={setOpen}>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
@@ -49,12 +58,17 @@ function DeleteBrowserProfileButton({ profile, onDeleted }: Props) {
</TooltipProvider>
<DialogContent onCloseAutoFocus={(e) => e.preventDefault()}>
<DialogHeader>
- <DialogTitle>Are you sure?</DialogTitle>
+ <DialogTitle>
+ Delete{" "}
+ <span className="font-bold text-primary">{profile.name}</span>?
+ </DialogTitle>
</DialogHeader>
- <div className="text-sm text-neutral-600 dark:text-slate-400">
- The browser profile{" "}
- <span className="font-bold text-primary">{profile.name}</span> will be
- deleted. Agents referencing this profile will no longer find it.
+ <div className="space-y-4 text-sm text-neutral-600 dark:text-slate-400">
+ <p>{deleteWarning(profile, usage)}</p>
+ <BrowserProfileUsageList
+ usage={usage}
+ isLoading={open && isLoading}
+ />
</div>
<DialogFooter>
<DialogClose asChild>
@@ -64,9 +78,12 @@ function DeleteBrowserProfileButton({ profile, onDeleted }: Props) {
variant="destructive"
onClick={async () => {
await deleteMutation.mutateAsync(profile.browser_profile_id);
+ setOpen(false);
onDeleted?.();
}}
- disabled={deleteMutation.isPending}
+ // Hold the destructive action until the used-by list has loaded so a user can't confirm
+ // before seeing what depends on the profile. A usage error re-enables it (warn, never block).
+ disabled={deleteMutation.isPending || isLoading}
>
{deleteMutation.isPending && (
<ReloadIcon className="mr-2 size-4 animate-spin" />
diff --git a/skyvern-frontend/src/routes/browserProfiles/RefreshBrowserProfileButton.test.tsx b/skyvern-frontend/src/routes/browserProfiles/RefreshBrowserProfileButton.test.tsx
new file mode 100644
index 000000000..ac4b2f824
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/RefreshBrowserProfileButton.test.tsx
@@ -0,0 +1,56 @@
+// @vitest-environment jsdom
+
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import type { BrowserProfileApiResponse } from "@/api/types";
+
+import { RefreshBrowserProfileButton } from "./RefreshBrowserProfileButton";
+
+const mutate = vi.fn();
+
+vi.mock(
+ "@/routes/browserSessions/hooks/useCreateBrowserSessionMutation",
+ () => ({
+ useCreateBrowserSessionMutation: () => ({ mutate, isPending: false }),
+ }),
+);
+
+vi.mock("./hooks/useBrowserProfileUsageQuery", () => ({
+ useBrowserProfileUsageQuery: () => ({ data: undefined, isLoading: false }),
+}));
+
+function makeProfile(): BrowserProfileApiResponse {
+ return {
+ browser_profile_id: "bp_x",
+ organization_id: "org_1",
+ name: "My Profile",
+ description: null,
+ source_browser_type: null,
+ is_managed: false,
+ created_at: "2026-06-01T00:00:00.000Z",
+ modified_at: "2026-06-01T00:00:00.000Z",
+ deleted_at: null,
+ };
+}
+
+afterEach(() => {
+ cleanup();
+ vi.clearAllMocks();
+});
+
+describe("RefreshBrowserProfileButton", () => {
+ it("seeds a browser session with the profile id on confirm", () => {
+ render(<RefreshBrowserProfileButton profile={makeProfile()} />);
+
+ fireEvent.click(screen.getByLabelText("Refresh browser profile"));
+ fireEvent.click(screen.getByText("Open browser session"));
+
+ expect(mutate).toHaveBeenCalledWith({
+ browserProfileId: "bp_x",
+ proxyLocation: null,
+ proxySessionId: null,
+ timeout: null,
+ });
+ });
+});
diff --git a/skyvern-frontend/src/routes/browserProfiles/RefreshBrowserProfileButton.tsx b/skyvern-frontend/src/routes/browserProfiles/RefreshBrowserProfileButton.tsx
new file mode 100644
index 000000000..c2fcd4f78
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/RefreshBrowserProfileButton.tsx
@@ -0,0 +1,109 @@
+import { ReloadIcon, UpdateIcon } from "@radix-ui/react-icons";
+import { useState } from "react";
+
+import { BrowserProfileApiResponse } from "@/api/types";
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import { useCreateBrowserSessionMutation } from "@/routes/browserSessions/hooks/useCreateBrowserSessionMutation";
+
+import { BrowserProfileUsageList } from "./BrowserProfileUsageList";
+import { useBrowserProfileUsageQuery } from "./hooks/useBrowserProfileUsageQuery";
+
+type Props = {
+ profile: BrowserProfileApiResponse;
+ // When set, render a labeled button (detail page); otherwise an icon button (list row).
+ label?: string;
+};
+
+function RefreshBrowserProfileButton({ profile, label }: Props) {
+ const [open, setOpen] = useState(false);
+ const createSession = useCreateBrowserSessionMutation();
+ const { data: usage, isLoading } = useBrowserProfileUsageQuery(
+ profile.browser_profile_id,
+ { enabled: open },
+ );
+
+ const disabled = Boolean(profile.deleted_at);
+
+ const handleConfirm = () => {
+ // Navigation to the live session view happens in the mutation's onSuccess. Launch from the profile's
+ // own proxy identity so Refresh doesn't change the egress IP and re-trigger the very login challenge
+ // the user is repairing.
+ createSession.mutate({
+ browserProfileId: profile.browser_profile_id,
+ proxyLocation: profile.proxy_location ?? null,
+ proxySessionId: profile.proxy_session_id ?? null,
+ timeout: null,
+ });
+ };
+
+ const trigger = label ? (
+ <Button variant="secondary" disabled={disabled}>
+ <UpdateIcon className="mr-2 size-4" />
+ {label}
+ </Button>
+ ) : (
+ <Button
+ size="icon"
+ variant="ghost"
+ aria-label="Refresh browser profile"
+ disabled={disabled}
+ className="text-muted-foreground hover:text-foreground"
+ >
+ <UpdateIcon className="h-4 w-4" />
+ </Button>
+ );
+
+ return (
+ <Dialog open={open} onOpenChange={setOpen}>
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DialogTrigger asChild>{trigger}</DialogTrigger>
+ </TooltipTrigger>
+ <TooltipContent>Refresh browser profile</TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ <DialogContent onCloseAutoFocus={(e) => e.preventDefault()}>
+ <DialogHeader>
+ <DialogTitle>Open a live browser with this profile</DialogTitle>
+ <DialogDescription>
+ Skyvern opens a browser signed in with{" "}
+ <span className="font-medium text-primary">{profile.name}</span>.
+ Sign in again or clear the challenge, then close the session — the
+ browser you leave behind is saved back to this same profile.
+ </DialogDescription>
+ </DialogHeader>
+ <BrowserProfileUsageList usage={usage} isLoading={open && isLoading} />
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="secondary">Cancel</Button>
+ </DialogClose>
+ <Button onClick={handleConfirm} disabled={createSession.isPending}>
+ {createSession.isPending && (
+ <ReloadIcon className="mr-2 size-4 animate-spin" />
+ )}
+ Open browser session
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+export { RefreshBrowserProfileButton };
diff --git a/skyvern-frontend/src/routes/browserProfiles/browserProfileRole.test.ts b/skyvern-frontend/src/routes/browserProfiles/browserProfileRole.test.ts
new file mode 100644
index 000000000..e6221dd54
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/browserProfileRole.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, it } from "vitest";
+
+import type {
+ BrowserProfileApiResponse,
+ BrowserProfileUsage,
+} from "@/api/types";
+
+import { getBrowserProfileRole } from "./browserProfileRole";
+
+const managed = { is_managed: true } as Pick<
+ BrowserProfileApiResponse,
+ "is_managed"
+>;
+const plain = { is_managed: false } as Pick<
+ BrowserProfileApiResponse,
+ "is_managed"
+>;
+
+function usage(
+ overrides: Partial<BrowserProfileUsage> = {},
+): BrowserProfileUsage {
+ return {
+ workflows: [],
+ credentials: [],
+ recent_seeded_run_count: 0,
+ ...overrides,
+ };
+}
+
+describe("getBrowserProfileRole", () => {
+ it("is workflow_memory for a managed profile regardless of usage", () => {
+ expect(getBrowserProfileRole(managed, undefined)).toBe("workflow_memory");
+ expect(
+ getBrowserProfileRole(
+ managed,
+ usage({ credentials: [{ credential_id: "c", name: "n" }] }),
+ ),
+ ).toBe("workflow_memory");
+ });
+
+ it("is credential when a non-managed profile is linked by a credential", () => {
+ expect(
+ getBrowserProfileRole(
+ plain,
+ usage({ credentials: [{ credential_id: "c", name: "Bank" }] }),
+ ),
+ ).toBe("credential");
+ });
+
+ it("is credential from the list's linked_credential_name without a usage fetch", () => {
+ expect(
+ getBrowserProfileRole({
+ is_managed: false,
+ linked_credential_name: "Bank portal",
+ }),
+ ).toBe("credential");
+ });
+
+ it("is plain for a non-managed profile with no credential link", () => {
+ expect(getBrowserProfileRole(plain, usage())).toBe("plain");
+ expect(getBrowserProfileRole(plain, undefined)).toBe("plain");
+ });
+});
diff --git a/skyvern-frontend/src/routes/browserProfiles/browserProfileRole.ts b/skyvern-frontend/src/routes/browserProfiles/browserProfileRole.ts
new file mode 100644
index 000000000..fe8d5be7c
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/browserProfileRole.ts
@@ -0,0 +1,66 @@
+import { BrowserProfileApiResponse, BrowserProfileUsage } from "@/api/types";
+
+// Two state nouns only, per the Browser Memory copy rules: a "remembered browser"
+// (workflow memory / credential login, kept current automatically) vs a read-only
+// "saved profile".
+export type BrowserProfileRole = "workflow_memory" | "credential" | "plain";
+
+// Derive from whichever credential signal the caller has: list rows pass the batched
+// `linked_credential_name` (no per-row usage fetch); the delete/refresh dialogs pass the
+// full `usage` they fetch on open.
+export function getBrowserProfileRole(
+ profile: Pick<
+ BrowserProfileApiResponse,
+ "is_managed" | "linked_credential_name"
+ >,
+ usage?: BrowserProfileUsage,
+): BrowserProfileRole {
+ if (profile.is_managed) {
+ return "workflow_memory";
+ }
+ if (
+ profile.linked_credential_name ||
+ (usage && usage.credentials.length > 0)
+ ) {
+ return "credential";
+ }
+ return "plain";
+}
+
+export const BROWSER_PROFILE_ROLE_BADGE: Record<BrowserProfileRole, string> = {
+ workflow_memory: "Workflow memory",
+ credential: "Credential login",
+ plain: "Saved profile",
+};
+
+export const BROWSER_PROFILE_ROLE_FRESHNESS: Record<
+ BrowserProfileRole,
+ string
+> = {
+ workflow_memory: "Updated after every successful run.",
+ credential: "Kept fresh automatically.",
+ plain: "Read-only saved profile.",
+};
+
+// Per-role delete warning. The dialog fetches full usage on open, so the credential name and any
+// pinning workflows come from there; block nothing, warn everything.
+export function deleteWarning(
+ profile: Pick<
+ BrowserProfileApiResponse,
+ "is_managed" | "linked_credential_name"
+ >,
+ usage: BrowserProfileUsage | undefined,
+): string {
+ const role = getBrowserProfileRole(profile, usage);
+ if (role === "workflow_memory") {
+ return "This clears the workflow's remembered browser. Its next run starts fresh and saves a new one.";
+ }
+ if (role === "credential") {
+ const names = usage?.credentials.map((c) => c.name).join(", ");
+ return `This unlinks the saved login from ${names}. That credential will sign in fresh next time.`;
+ }
+ if ((usage?.workflows.length ?? 0) > 0) {
+ return "Workflows pinned to this profile won't find it until they're repointed.";
+ }
+ return "This saved browser profile will be deleted and can't be recovered.";
+}
diff --git a/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileUsageQuery.ts b/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileUsageQuery.ts
new file mode 100644
index 000000000..051cf416b
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileUsageQuery.ts
@@ -0,0 +1,32 @@
+import { useQuery } from "@tanstack/react-query";
+
+import { getClient } from "@/api/AxiosClient";
+import { BrowserProfileUsage } from "@/api/types";
+import { useCredentialGetter } from "@/hooks/useCredentialGetter";
+
+type UseQueryOptions = Omit<
+ Parameters<typeof useQuery<BrowserProfileUsage>>[0],
+ "queryKey" | "queryFn"
+>;
+
+function useBrowserProfileUsageQuery(
+ profileId: string | undefined,
+ options: UseQueryOptions = {},
+) {
+ const credentialGetter = useCredentialGetter();
+
+ return useQuery<BrowserProfileUsage>({
+ queryKey: ["browserProfileUsage", profileId],
+ queryFn: async () => {
+ const client = await getClient(credentialGetter, "sans-api-v1");
+ return client
+ .get<BrowserProfileUsage>(`/browser_profiles/${profileId}/usage`)
+ .then((response) => response.data);
+ },
+ enabled: Boolean(profileId),
+ staleTime: 60 * 1000,
+ ...options,
+ });
+}
+
+export { useBrowserProfileUsageQuery };
diff --git a/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.test.tsx b/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.test.tsx
index 8c37ebc09..138ef5db6 100644
--- a/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.test.tsx
+++ b/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.test.tsx
@@ -81,6 +81,7 @@ describe("useCreateBrowserSessionMutation proxy pin payloads", () => {
extensions: [],
browser_type: null,
generate_browser_profile: true,
+ browser_profile_id: null,
});
expect(mockNavigate).toHaveBeenCalledWith("/browser-session/pbs_123");
});
diff --git a/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.ts b/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.ts
index 5027dd985..22c0db6c4 100644
--- a/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.ts
+++ b/skyvern-frontend/src/routes/browserSessions/hooks/useCreateBrowserSessionMutation.ts
@@ -24,6 +24,7 @@ function useCreateBrowserSessionMutation() {
extensions = [],
browserType = null,
generateBrowserProfile = false,
+ browserProfileId = null,
}: {
proxyLocation: ProxyLocation | null;
proxySessionId?: string | null;
@@ -31,6 +32,7 @@ function useCreateBrowserSessionMutation() {
extensions?: BrowserSessionExtension[];
browserType?: BrowserSessionType | null;
generateBrowserProfile?: boolean;
+ browserProfileId?: string | null;
}) => {
const client = await getClient(credentialGetter, "sans-api-v1");
return client.post<string, { data: BrowserSession }>(
@@ -42,6 +44,7 @@ function useCreateBrowserSessionMutation() {
extensions,
browser_type: browserType,
generate_browser_profile: generateBrowserProfile,
+ browser_profile_id: browserProfileId,
},
);
},
diff --git a/skyvern-frontend/src/routes/credentials/CredentialItem.tsx b/skyvern-frontend/src/routes/credentials/CredentialItem.tsx
index c599350b8..9d84f5449 100644
--- a/skyvern-frontend/src/routes/credentials/CredentialItem.tsx
+++ b/skyvern-frontend/src/routes/credentials/CredentialItem.tsx
@@ -8,6 +8,7 @@ import {
import { getClient } from "@/api/AxiosClient";
import { SelectionCheckbox } from "@/components/SelectionCheckbox";
import { useEffect, useRef, useState } from "react";
+import { Link } from "react-router-dom";
import {
CopyIcon,
EyeNoneIcon,
@@ -435,6 +436,13 @@ function CredentialItem({
{getHostname(credential.tested_url) ?? credential.tested_url}
</span>
)}
+ <span className="text-muted-foreground">·</span>
+ <Link
+ to={`/browser-profiles/${credential.browser_profile_id}`}
+ className="text-blue-400 hover:text-blue-300"
+ >
+ Fix the saved login by hand
+ </Link>
</div>
)}
{canResaveSession && !credential.browser_profile_id && !activeTest && (