Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-9737): browser profile management page (#5990)
Celal Zamanoğlue334d4258d9a
diff --git a/skyvern-frontend/src/router.tsx b/skyvern-frontend/src/router.tsxindex 95d6d6015..d0a2f6357 100644--- a/skyvern-frontend/src/router.tsx+++ b/skyvern-frontend/src/router.tsx@@ -30,6 +30,8 @@ import { WorkflowRunOverview } from "./routes/workflows/workflowRun/WorkflowRunOimport { WorkflowRunRecording } from "./routes/workflows/workflowRun/WorkflowRunRecording";import { WorkflowRunCode } from "@/routes/workflows/workflowRun/WorkflowRunCode";import { DebugStoreProvider } from "@/store/DebugStoreContext";+import { BrowserProfileDetailPage } from "@/routes/browserProfiles/BrowserProfileDetailPage.tsx";+import { BrowserProfilesPage } from "@/routes/browserProfiles/BrowserProfilesPage.tsx";import { CredentialsPage } from "@/routes/credentials/CredentialsPage.tsx";import { IntegrationsUnavailable } from "@/routes/integrations/IntegrationsUnavailable";import { RunRouter } from "@/routes/runs/RunRouter";@@ -281,6 +283,20 @@ const router = createBrowserRouter([},],},+ {+ path: "browser-profiles",+ element: <PageLayout />,+ children: [+ {+ index: true,+ element: <BrowserProfilesPage />,+ },+ {+ path: ":profileId",+ element: <BrowserProfileDetailPage />,+ },+ ],+ },{path: "integrations",element: <PageLayout />,diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsxnew file mode 100644index 000000000..aecfc11e4--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileDetailPage.tsx@@ -0,0 +1,130 @@+import { useState } from "react";+import { ChevronLeftIcon, Pencil1Icon } from "@radix-ui/react-icons";+import { useNavigate, useParams } from "react-router-dom";++import { Button } from "@/components/ui/button";+import { Skeleton } from "@/components/ui/skeleton";+import { CopyText } from "@/routes/workflows/editor/Workspace";+import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat";++import { DeleteBrowserProfileButton } from "./DeleteBrowserProfileButton";+import { RenameBrowserProfileDialog } from "./RenameBrowserProfileDialog";+import { useBrowserProfileQuery } from "./hooks/useBrowserProfileQuery";++function BrowserProfileDetailPage() {+ const navigate = useNavigate();+ const { profileId } = useParams<{ profileId: string }>();+ const [renameOpen, setRenameOpen] = useState(false);++ const {+ data: profile,+ isLoading,+ isError,+ } = useBrowserProfileQuery(profileId);++ return (+ <div className="space-y-5">+ <div>+ <Button+ variant="tertiary"+ size="sm"+ onClick={() => navigate("/browser-profiles")}+ >+ <ChevronLeftIcon className="mr-1 size-4" />+ Browser Profiles+ </Button>+ </div>++ {isLoading && (+ <div className="space-y-4">+ <Skeleton className="h-8 w-64" />+ <Skeleton className="h-32 w-full" />+ </div>+ )}++ {!isLoading && (isError || !profile) && (+ <div className="rounded-md border border-slate-700 bg-slate-elevation1 p-6 text-sm text-slate-300">+ Browser profile not found.+ </div>+ )}++ {!isLoading && profile && (+ <>+ <div className="flex items-start justify-between gap-4">+ <div className="space-y-2">+ <h1 className="text-2xl">{profile.name}</h1>+ {profile.description && (+ <p className="text-sm text-slate-300">{profile.description}</p>+ )}+ {profile.deleted_at && (+ <p className="text-sm text-amber-400">+ Deleted {basicLocalTimeFormat(profile.deleted_at)}+ </p>+ )}+ </div>+ <div className="flex gap-2">+ <Button+ variant="secondary"+ onClick={() => setRenameOpen(true)}+ disabled={Boolean(profile.deleted_at)}+ >+ <Pencil1Icon className="mr-2 size-4" />+ Rename+ </Button>+ {!profile.deleted_at && (+ <DeleteBrowserProfileButton+ profile={profile}+ onDeleted={() => navigate("/browser-profiles")}+ />+ )}+ </div>+ </div>++ <div className="rounded-lg border border-slate-700 bg-slate-elevation1 p-6">+ <dl className="grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-[180px_1fr]">+ <dt className="text-sm text-slate-400">ID</dt>+ <dd className="flex items-center font-mono text-sm">+ <span className="break-all">{profile.browser_profile_id}</span>+ <CopyText+ className="ml-1 opacity-75 hover:opacity-100"+ text={profile.browser_profile_id}+ />+ </dd>++ <dt className="text-sm text-slate-400">Source Browser</dt>+ <dd className="text-sm">+ {profile.source_browser_type ?? (+ <span className="opacity-50">—</span>+ )}+ </dd>++ <dt className="text-sm text-slate-400">Created</dt>+ <dd+ className="text-sm"+ title={basicTimeFormat(profile.created_at)}+ >+ {basicLocalTimeFormat(profile.created_at)}+ </dd>++ <dt className="text-sm text-slate-400">Last Modified</dt>+ <dd+ className="text-sm"+ title={basicTimeFormat(profile.modified_at)}+ >+ {basicLocalTimeFormat(profile.modified_at)}+ </dd>+ </dl>+ </div>++ <RenameBrowserProfileDialog+ profile={profile}+ open={renameOpen}+ onOpenChange={setRenameOpen}+ />+ </>+ )}+ </div>+ );+}++export { BrowserProfileDetailPage };diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsxnew file mode 100644index 000000000..e724e9898--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfileItem.tsx@@ -0,0 +1,96 @@+import { useState } from "react";+import { Pencil1Icon } from "@radix-ui/react-icons";+import { useNavigate } from "react-router-dom";++import { BrowserProfileApiResponse } from "@/api/types";+import { Button } from "@/components/ui/button";+import { TableCell, TableRow } from "@/components/ui/table";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";+import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat";++import { DeleteBrowserProfileButton } from "./DeleteBrowserProfileButton";+import { RenameBrowserProfileDialog } from "./RenameBrowserProfileDialog";++type Props = {+ profile: BrowserProfileApiResponse;+};++function BrowserProfileItem({ profile }: Props) {+ const navigate = useNavigate();+ const [renameOpen, setRenameOpen] = useState(false);++ const handleRowClick = (event: React.MouseEvent<HTMLTableRowElement>) => {+ if (event.ctrlKey || event.metaKey) {+ window.open(+ `${window.location.origin}/browser-profiles/${profile.browser_profile_id}`,+ "_blank",+ "noopener,noreferrer",+ );+ return;+ }+ navigate(`/browser-profiles/${profile.browser_profile_id}`);+ };++ const stopRowClick = (event: React.MouseEvent<HTMLElement>) => {+ event.stopPropagation();+ };++ return (+ <TableRow+ className="cursor-pointer hover:bg-slate-elevation2"+ onClick={handleRowClick}+ >+ <TableCell className="truncate">+ <span title={profile.name}>{profile.name}</span>+ </TableCell>+ <TableCell className="truncate text-slate-400">+ {profile.description ? (+ <span title={profile.description}>{profile.description}</span>+ ) : (+ <span className="opacity-50">—</span>+ )}+ </TableCell>+ <TableCell className="truncate text-slate-400">+ {profile.source_browser_type ?? <span className="opacity-50">—</span>}+ </TableCell>+ <TableCell+ className="text-slate-400"+ title={basicTimeFormat(profile.created_at)}+ >+ {basicLocalTimeFormat(profile.created_at)}+ </TableCell>+ <TableCell onClick={stopRowClick}>+ <div className="flex justify-end gap-2">+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ size="icon"+ variant="outline"+ onClick={() => setRenameOpen(true)}+ aria-label="Rename browser profile"+ >+ <Pencil1Icon className="h-4 w-4" />+ </Button>+ </TooltipTrigger>+ <TooltipContent>Rename Browser Profile</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <DeleteBrowserProfileButton profile={profile} />+ </div>+ <RenameBrowserProfileDialog+ profile={profile}+ open={renameOpen}+ onOpenChange={setRenameOpen}+ />+ </TableCell>+ </TableRow>+ );+}++export { BrowserProfileItem };diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsxnew file mode 100644index 000000000..b4ffb98f2--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesList.tsx@@ -0,0 +1,187 @@+import { ReloadIcon } from "@radix-ui/react-icons";+import { useSearchParams } from "react-router-dom";++import { Button } from "@/components/ui/button";+import {+ Pagination,+ PaginationContent,+ PaginationItem,+ PaginationLink,+ PaginationNext,+ PaginationPrevious,+} from "@/components/ui/pagination";+import { Skeleton } from "@/components/ui/skeleton";+import {+ Table,+ TableBody,+ TableHead,+ TableHeader,+ TableRow,+} from "@/components/ui/table";+import { useBrowserProfilesQuery } from "@/routes/workflows/hooks/useBrowserProfilesQuery";+import { cn } from "@/util/utils";++import { BrowserProfileItem } from "./BrowserProfileItem";++function BrowserProfilesList() {+ const [searchParams, setSearchParams] = useSearchParams();+ const page = searchParams.get("page") ? Number(searchParams.get("page")) : 1;+ const itemsPerPage = searchParams.get("page_size")+ ? Number(searchParams.get("page_size"))+ : 10;++ function setParamPatch(patch: Record<string, string>) {+ const params = new URLSearchParams(searchParams);+ Object.entries(patch).forEach(([k, v]) => params.set(k, v));+ setSearchParams(params, { replace: true });+ }++ function handlePreviousPage() {+ if (page === 1) return;+ setParamPatch({ page: String(page - 1) });+ }++ function handleNextPage() {+ if (isNextDisabled) return;+ setParamPatch({ page: String(page + 1) });+ }++ const {+ data: profiles,+ isLoading,+ isError,+ refetch,+ isFetching,+ } = useBrowserProfilesQuery({+ page,+ page_size: itemsPerPage,+ });++ const { data: nextPageProfiles } = useBrowserProfilesQuery({+ page: page + 1,+ page_size: itemsPerPage,+ enabled: (profiles?.length ?? 0) === itemsPerPage,+ });++ const isNextDisabled =+ isFetching || !nextPageProfiles || nextPageProfiles.length === 0;++ if (isLoading) {+ return (+ <div className="space-y-3">+ <Skeleton className="h-12 w-full" />+ <Skeleton className="h-12 w-full" />+ <Skeleton className="h-12 w-full" />+ </div>+ );+ }++ if (isError) {+ return (+ <div className="rounded-md border border-slate-700 bg-slate-elevation1 p-6 text-sm text-slate-300">+ <div className="mb-3">Failed to load browser profiles.</div>+ <Button+ variant="secondary"+ onClick={() => refetch()}+ disabled={isFetching}+ >+ {isFetching && <ReloadIcon className="mr-2 size-4 animate-spin" />}+ Retry+ </Button>+ </div>+ );+ }++ const pageItems = profiles ?? [];++ if (pageItems.length === 0 && page === 1) {+ return (+ <div className="rounded-md border border-slate-700 bg-slate-elevation1 p-6 text-sm text-slate-300">+ No browser profiles yet. Profiles are created via the API/SDK, or when a+ credential test or workflow run saves its persistent browser session.+ </div>+ );+ }++ return (+ <div className="space-y-4">+ <div className="rounded-lg border">+ <Table className="w-full table-fixed">+ <TableHeader className="rounded-t-lg bg-slate-elevation2">+ <TableRow>+ <TableHead className="w-1/4 truncate rounded-tl-lg text-slate-400">+ Name+ </TableHead>+ <TableHead className="w-1/3 truncate text-slate-400">+ Description+ </TableHead>+ <TableHead className="w-1/6 truncate text-slate-400">+ Source Browser+ </TableHead>+ <TableHead className="w-1/6 truncate text-slate-400">+ Created+ </TableHead>+ <TableHead className="w-32 truncate rounded-tr-lg text-right text-slate-400">+ Actions+ </TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {pageItems.map((profile) => (+ <BrowserProfileItem+ key={profile.browser_profile_id}+ profile={profile}+ />+ ))}+ </TableBody>+ </Table>+ <div className="relative px-3 py-3">+ <div className="absolute left-3 top-1/2 flex -translate-y-1/2 items-center gap-2 text-sm">+ <span className="text-slate-400">Items per page</span>+ <select+ className="h-9 rounded-md border border-slate-300 bg-background px-3"+ value={itemsPerPage}+ onChange={(e) => {+ const next = Number(e.target.value);+ const params = new URLSearchParams(searchParams);+ params.set("page_size", String(next));+ params.set("page", "1");+ setSearchParams(params, { replace: true });+ }}+ >+ <option value={5}>5</option>+ <option value={10}>10</option>+ <option value={20}>20</option>+ <option value={50}>50</option>+ </select>+ </div>+ <Pagination className="pt-0">+ <PaginationContent>+ <PaginationItem>+ <PaginationPrevious+ className={cn({+ "cursor-not-allowed opacity-50": page === 1,+ })}+ onClick={handlePreviousPage}+ />+ </PaginationItem>+ <PaginationItem>+ <PaginationLink>{page}</PaginationLink>+ </PaginationItem>+ <PaginationItem>+ <PaginationNext+ className={cn({+ "cursor-not-allowed opacity-50": isNextDisabled,+ })}+ onClick={handleNextPage}+ />+ </PaginationItem>+ </PaginationContent>+ </Pagination>+ </div>+ </div>+ </div>+ );+}++export { BrowserProfilesList };diff --git a/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesPage.tsx b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesPage.tsxnew file mode 100644index 000000000..1ba9890ac--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/BrowserProfilesPage.tsx@@ -0,0 +1,16 @@+import { BrowserProfilesList } from "./BrowserProfilesList";++const subHeaderText =+ "Manage saved browser profiles used by your workflow runs.";++function BrowserProfilesPage() {+ return (+ <div className="space-y-5">+ <h1 className="text-2xl">Browser Profiles</h1>+ <div className="w-96 text-sm text-slate-300">{subHeaderText}</div>+ <BrowserProfilesList />+ </div>+ );+}++export { BrowserProfilesPage };diff --git a/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsx b/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsxnew file mode 100644index 000000000..39c4a119d--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/DeleteBrowserProfileButton.tsx@@ -0,0 +1,81 @@+import { ReloadIcon, TrashIcon } from "@radix-ui/react-icons";++import { BrowserProfileApiResponse } from "@/api/types";+import { Button } from "@/components/ui/button";+import {+ Dialog,+ DialogClose,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from "@/components/ui/dialog";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/ui/tooltip";++import { useDeleteBrowserProfileMutation } from "./hooks/useBrowserProfileMutations";++type Props = {+ profile: BrowserProfileApiResponse;+ onDeleted?: () => void;+};++function DeleteBrowserProfileButton({ profile, onDeleted }: Props) {+ const deleteMutation = useDeleteBrowserProfileMutation();++ return (+ <Dialog>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <DialogTrigger asChild>+ <Button+ size="icon"+ variant="outline"+ aria-label="Delete browser profile"+ >+ <TrashIcon className="h-4 w-4" />+ </Button>+ </DialogTrigger>+ </TooltipTrigger>+ <TooltipContent>Delete Browser Profile</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ <DialogContent onCloseAutoFocus={(e) => e.preventDefault()}>+ <DialogHeader>+ <DialogTitle>Are you sure?</DialogTitle>+ </DialogHeader>+ <div className="text-sm text-slate-400">+ The browser profile{" "}+ <span className="font-bold text-primary">{profile.name}</span> will be+ deleted. Workflows referencing this profile will no longer find it.+ </div>+ <DialogFooter>+ <DialogClose asChild>+ <Button variant="secondary">Cancel</Button>+ </DialogClose>+ <Button+ variant="destructive"+ onClick={async () => {+ await deleteMutation.mutateAsync(profile.browser_profile_id);+ onDeleted?.();+ }}+ disabled={deleteMutation.isPending}+ >+ {deleteMutation.isPending && (+ <ReloadIcon className="mr-2 size-4 animate-spin" />+ )}+ Delete+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}++export { DeleteBrowserProfileButton };diff --git a/skyvern-frontend/src/routes/browserProfiles/RenameBrowserProfileDialog.tsx b/skyvern-frontend/src/routes/browserProfiles/RenameBrowserProfileDialog.tsxnew file mode 100644index 000000000..e8166faba--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/RenameBrowserProfileDialog.tsx@@ -0,0 +1,95 @@+import { useEffect, useState } from "react";+import { ReloadIcon } from "@radix-ui/react-icons";++import { BrowserProfileApiResponse } from "@/api/types";+import { Button } from "@/components/ui/button";+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from "@/components/ui/dialog";+import { Input } from "@/components/ui/input";+import { Label } from "@/components/ui/label";++import { useUpdateBrowserProfileMutation } from "./hooks/useBrowserProfileMutations";++type Props = {+ profile: BrowserProfileApiResponse;+ open: boolean;+ onOpenChange: (open: boolean) => void;+};++function RenameBrowserProfileDialog({ profile, open, onOpenChange }: Props) {+ const [name, setName] = useState(profile.name);+ const updateProfileMutation = useUpdateBrowserProfileMutation();++ useEffect(() => {+ if (open) {+ setName(profile.name);+ }+ }, [open, profile.name]);++ const trimmedName = name.trim();+ const canSubmit =+ trimmedName.length > 0 &&+ trimmedName !== profile.name &&+ !updateProfileMutation.isPending;++ const handleSubmit = async (event: React.FormEvent) => {+ event.preventDefault();+ if (!canSubmit) {+ return;+ }+ await updateProfileMutation.mutateAsync({+ profileId: profile.browser_profile_id,+ name: trimmedName,+ });+ onOpenChange(false);+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent onCloseAutoFocus={(e) => e.preventDefault()}>+ <DialogHeader>+ <DialogTitle>Rename browser profile</DialogTitle>+ <DialogDescription>+ Give this browser profile a new name.+ </DialogDescription>+ </DialogHeader>+ <form onSubmit={handleSubmit}>+ <div className="grid gap-4 py-4">+ <div className="grid gap-2">+ <Label htmlFor="browser-profile-name">Name</Label>+ <Input+ id="browser-profile-name"+ value={name}+ onChange={(event) => setName(event.target.value)}+ autoFocus+ />+ </div>+ </div>+ <DialogFooter>+ <Button+ type="button"+ variant="secondary"+ onClick={() => onOpenChange(false)}+ >+ Cancel+ </Button>+ <Button type="submit" disabled={!canSubmit}>+ {updateProfileMutation.isPending && (+ <ReloadIcon className="mr-2 size-4 animate-spin" />+ )}+ Save+ </Button>+ </DialogFooter>+ </form>+ </DialogContent>+ </Dialog>+ );+}++export { RenameBrowserProfileDialog };diff --git a/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileMutations.ts b/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileMutations.tsnew file mode 100644index 000000000..f92758480--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileMutations.ts@@ -0,0 +1,97 @@+import { useMutation, useQueryClient } from "@tanstack/react-query";+import { AxiosError } from "axios";++import { getClient } from "@/api/AxiosClient";+import { BrowserProfileApiResponse } from "@/api/types";+import { toast } from "@/components/ui/use-toast";+import { useCredentialGetter } from "@/hooks/useCredentialGetter";++type UpdateBrowserProfileInput = {+ profileId: string;+ name?: string;+ description?: string | null;+};++function useUpdateBrowserProfileMutation() {+ const credentialGetter = useCredentialGetter();+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async ({+ profileId,+ name,+ description,+ }: UpdateBrowserProfileInput) => {+ const client = await getClient(credentialGetter, "sans-api-v1");+ const payload: Record<string, string | null> = {};+ if (name !== undefined) {+ payload.name = name;+ }+ if (description !== undefined) {+ payload.description = description;+ }+ return client+ .patch<BrowserProfileApiResponse>(+ `/browser_profiles/${profileId}`,+ payload,+ )+ .then((response) => response.data);+ },+ onSuccess: (_data, variables) => {+ queryClient.invalidateQueries({ queryKey: ["browserProfiles"] });+ queryClient.invalidateQueries({+ queryKey: ["browserProfile", variables.profileId],+ });+ toast({+ title: "Browser profile updated",+ variant: "success",+ description: "The browser profile has been updated.",+ });+ },+ onError: (error: AxiosError) => {+ const detail =+ (error.response?.data as { detail?: string } | undefined)?.detail ??+ error.message;+ toast({+ variant: "destructive",+ title: "Failed to update browser profile",+ description: detail,+ });+ },+ });+}++function useDeleteBrowserProfileMutation() {+ const credentialGetter = useCredentialGetter();+ const queryClient = useQueryClient();++ return useMutation({+ mutationFn: async (profileId: string) => {+ const client = await getClient(credentialGetter, "sans-api-v1");+ return client.delete(`/browser_profiles/${profileId}`);+ },+ onSuccess: (_data, profileId) => {+ queryClient.invalidateQueries({ queryKey: ["browserProfiles"] });+ queryClient.invalidateQueries({+ queryKey: ["browserProfile", profileId],+ });+ toast({+ title: "Browser profile deleted",+ variant: "success",+ description: "The browser profile has been deleted.",+ });+ },+ onError: (error: AxiosError) => {+ const detail =+ (error.response?.data as { detail?: string } | undefined)?.detail ??+ error.message;+ toast({+ variant: "destructive",+ title: "Failed to delete browser profile",+ description: detail,+ });+ },+ });+}++export { useUpdateBrowserProfileMutation, useDeleteBrowserProfileMutation };diff --git a/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileQuery.ts b/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileQuery.tsnew file mode 100644index 000000000..db5cab4e9--- /dev/null+++ b/skyvern-frontend/src/routes/browserProfiles/hooks/useBrowserProfileQuery.ts@@ -0,0 +1,32 @@+import { useQuery } from "@tanstack/react-query";++import { getClient } from "@/api/AxiosClient";+import { BrowserProfileApiResponse } from "@/api/types";+import { useCredentialGetter } from "@/hooks/useCredentialGetter";++type UseQueryOptions = Omit<+ Parameters<typeof useQuery<BrowserProfileApiResponse>>[0],+ "queryKey" | "queryFn"+>;++function useBrowserProfileQuery(+ profileId: string | undefined,+ options: UseQueryOptions = {},+) {+ const credentialGetter = useCredentialGetter();++ return useQuery<BrowserProfileApiResponse>({+ queryKey: ["browserProfile", profileId],+ queryFn: async () => {+ const client = await getClient(credentialGetter, "sans-api-v1");+ return client+ .get<BrowserProfileApiResponse>(`/browser_profiles/${profileId}`)+ .then((response) => response.data);+ },+ enabled: Boolean(profileId),+ staleTime: 5 * 60 * 1000,+ ...options,+ });+}++export { useBrowserProfileQuery };diff --git a/skyvern-frontend/src/routes/root/SideNav.tsx b/skyvern-frontend/src/routes/root/SideNav.tsxindex 9db2da318..ac2106037 100644--- a/skyvern-frontend/src/routes/root/SideNav.tsx+++ b/skyvern-frontend/src/routes/root/SideNav.tsx@@ -9,6 +9,7 @@ import {GlobeIcon,LightningBoltIcon,} from "@radix-ui/react-icons";+import { BrowserIcon } from "@/components/icons/BrowserIcon.tsx";import { KeyIcon } from "@/components/icons/KeyIcon.tsx";function SideNav() {@@ -63,6 +64,11 @@ function SideNav() {to: "/credentials",icon: <KeyIcon className="size-6" />,},+ {+ label: "Browser Profiles",+ to: "/browser-profiles",+ icon: <BrowserIcon className="size-6" />,+ },]}/></nav>diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsxindex 8414e9746..d07840269 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx@@ -398,9 +398,12 @@ function WorkflowRun() {</Link>)}{workflowRun?.browser_profile_id && (- <span className="font-mono text-sm text-slate-400">+ <Link+ className="font-mono text-sm text-slate-400 hover:text-slate-200 hover:underline hover:underline-offset-2"+ to={`/browser-profiles/${workflowRun.browser_profile_id}`}+ >Browser Profile: {workflowRun.browser_profile_id}- </span>+ </Link>)}</div>diff --git a/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.tsindex 6f5ee583a..59ffb91cd 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useBrowserProfilesQuery.ts@@ -11,20 +11,28 @@ type UseQueryOptions = Omit<type Props = UseQueryOptions & {includeDeleted?: boolean;+ page?: number;+ page_size?: number;};function useBrowserProfilesQuery(props: Props = {}) {- const { includeDeleted = false, ...queryOptions } = props;+ const { includeDeleted = false, page, page_size, ...queryOptions } = props;const credentialGetter = useCredentialGetter();return useQuery<QueryReturnType>({- queryKey: ["browserProfiles", includeDeleted],+ queryKey: ["browserProfiles", includeDeleted, page, page_size],queryFn: async () => {const client = await getClient(credentialGetter, "sans-api-v1");const params = new URLSearchParams();if (includeDeleted) {params.set("include_deleted", "true");}+ if (page !== undefined) {+ params.set("page", String(page));+ }+ if (page_size !== undefined) {+ params.set("page_size", String(page_size));+ }return client.get("/browser_profiles", { params }).then((res) => res.data);