Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-12845): credential run-sequentially toggle in edit UI (#7995)
LawyZheng41a1f61d4c29
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.tsindex bd9698aa9..4e52f01e9 100644--- a/skyvern-frontend/src/api/types.ts+++ b/skyvern-frontend/src/api/types.ts@@ -1060,6 +1060,7 @@ export type CredentialApiResponse = {tested_url?: string | null;user_context?: string | null;save_browser_session_intent?: boolean | null;+ run_sequentially?: boolean | null;folder_id?: string | null;proxy_location?: ProxyLocation | null;proxy_session_id?: string | null;diff --git a/skyvern-frontend/src/routes/credentials/CredentialsModal.test.tsx b/skyvern-frontend/src/routes/credentials/CredentialsModal.test.tsxindex 676740b02..a5c2845eb 100644--- a/skyvern-frontend/src/routes/credentials/CredentialsModal.test.tsx+++ b/skyvern-frontend/src/routes/credentials/CredentialsModal.test.tsx@@ -708,10 +708,11 @@ describe("CredentialsModal edit-mode inline test", () => {expect(toastMock).toHaveBeenCalledWith(expect.objectContaining({title: "Partial save",- // Flag-off the PATCH omits browser profile / IP, so the copy must not- // name them — byte-identical to the legacy partial-save message.+ // Flag-off the PATCH omits browser profile / IP, so the copy names+ // login instructions and sequential settings only — byte-identical+ // to the flag-off partial-save message.description:- "Credential updated, but login instructions could not be saved. Please try editing again.",+ "Credential updated, but login instructions and sequential settings could not be saved. Please try editing again.",}),);});@@ -1000,3 +1001,95 @@ describe("CredentialsModal copilot-context tested_url default", () => {expect(patchMock).not.toHaveBeenCalled();}, 10_000);});++describe("CredentialsModal run-sequentially toggle", () => {+ const sequentialLabel = /Run workflows sequentially for this credential/i;++ function renderEditModalFor(cred: CredentialApiResponse) {+ const queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ mutations: { retry: false },+ },+ });+ return render(+ <QueryClientProvider client={queryClient}>+ <MemoryRouter>+ <CredentialsModal+ isOpen+ onOpenChange={vi.fn()}+ overrideType={CredentialModalTypes.PASSWORD}+ editingCredential={cred}+ onStartBackgroundTest={vi.fn()}+ />+ </MemoryRouter>+ </QueryClientProvider>,+ );+ }++ it("reflects run_sequentially=false as an unchecked toggle", async () => {+ renderEditModalFor(editingPasswordCredential);+ const toggle = await screen.findByLabelText(sequentialLabel);+ expect(toggle.getAttribute("aria-checked")).toBe("false");+ });++ it("helper copy says scheduled/sync runs fail closed and does not over-promise", async () => {+ renderEditModalFor(editingPasswordCredential);+ await screen.findByLabelText(sequentialLabel);+ expect(+ screen.getByText(+ /scheduled or sync-triggered runs are not yet supported and fail closed/i,+ ),+ ).toBeTruthy();+ expect(screen.queryByText(/run without serialization/i)).toBeNull();+ });++ it("reflects run_sequentially=true as a checked toggle (readback)", async () => {+ renderEditModalFor({+ ...editingPasswordCredential,+ run_sequentially: true,+ });+ const toggle = await screen.findByLabelText(sequentialLabel);+ expect(toggle.getAttribute("aria-checked")).toBe("true");+ });++ it("persists run_sequentially via PATCH and shows success on a toggle-only edit", async () => {+ patchMock.mockResolvedValueOnce({+ data: { credential_id: "real-cred-id", name: "Acme Login" },+ });+ renderEditModalFor(editingPasswordCredential);+ const toggle = await screen.findByLabelText(sequentialLabel);+ fireEvent.click(toggle);+ fireEvent.click(screen.getByRole("button", { name: "Update" }));++ await waitFor(() => {+ expect(patchMock).toHaveBeenCalledWith(+ "/credentials/real-cred-id",+ expect.objectContaining({ run_sequentially: true }),+ );+ });+ await waitFor(() => {+ expect(toastMock).toHaveBeenCalledWith(+ expect.objectContaining({ title: "Credential saved" }),+ );+ });+ }, 10_000);++ it("surfaces the save failure and shows no success toast when the PATCH rejects", async () => {+ patchMock.mockRejectedValueOnce(axiosErrorWithDetail("nope"));+ renderEditModalFor(editingPasswordCredential);+ const toggle = await screen.findByLabelText(sequentialLabel);+ fireEvent.click(toggle);+ fireEvent.click(screen.getByRole("button", { name: "Update" }));++ await waitFor(() => {+ expect(patchMock).toHaveBeenCalledWith(+ "/credentials/real-cred-id",+ expect.objectContaining({ run_sequentially: true }),+ );+ });+ expect(toastMock).not.toHaveBeenCalledWith(+ expect.objectContaining({ title: "Credential saved" }),+ );+ }, 10_000);+});diff --git a/skyvern-frontend/src/routes/credentials/CredentialsModal.tsx b/skyvern-frontend/src/routes/credentials/CredentialsModal.tsxindex ac7d348ab..a5af9b75e 100644--- a/skyvern-frontend/src/routes/credentials/CredentialsModal.tsx+++ b/skyvern-frontend/src/routes/credentials/CredentialsModal.tsx@@ -415,6 +415,7 @@ function CredentialsModal({// Quick-win: optional browser profile + per-credential IP pin (flag-on).const [browserProfileId, setBrowserProfileId] = useState<string | null>(null);const [pinIp, setPinIp] = useState(false);+ const [runSequentially, setRunSequentially] = useState(false);// The inline profile Select has no scroll pagination, so pull a large first// page (unowned profiles are a small subset).const { data: plainProfilesPages } = useInfiniteBrowserProfilesQuery({@@ -633,6 +634,7 @@ function CredentialsModal({}setBrowserProfileId(editingCredential.browser_profile_id ?? null);setPinIp(editingCredential.pin_saved_session_ip ?? false);+ setRunSequentially(editingCredential.run_sequentially ?? false);if (editingCredential.user_context) {setUserContext(editingCredential.user_context);}@@ -705,6 +707,7 @@ function CredentialsModal({removalConfirmedRef.current = false;setBrowserProfileId(null);setPinIp(false);+ setRunSequentially(false);setTestAndSave(false);setTestUrl("");setTestStatus("idle");@@ -1058,6 +1061,7 @@ function CredentialsModal({...(capturedTestUrl && { tested_url: capturedTestUrl }),user_context: capturedUserContext?.trim() || null,save_browser_session_intent: saveBrowserSessionIntent,+ run_sequentially: runSequentially,// The /update vault path drops these; persist them here so a// profile/IP change made alongside credential values isn't lost.// PASSWORD-only, matching the picker UI and the bmPatch guard.@@ -1074,8 +1078,8 @@ function CredentialsModal({toast({title: "Partial save",description: includesBrowserMemoryFields- ? "Credential updated, but the login instructions, browser profile, and IP settings could not be saved. Please try editing again."- : "Credential updated, but login instructions could not be saved. Please try editing again.",+ ? "Credential updated, but the login instructions, sequential settings, browser profile, and IP settings could not be saved. Please try editing again."+ : "Credential updated, but login instructions and sequential settings could not be saved. Please try editing again.",variant: "destructive",});}@@ -1145,6 +1149,7 @@ function CredentialsModal({rotate_proxy_session_id,browser_profile_id,pin_saved_session_ip,+ run_sequentially,}: {id: string;name: string;@@ -1156,6 +1161,7 @@ function CredentialsModal({rotate_proxy_session_id?: boolean;browser_profile_id?: string | null;pin_saved_session_ip?: boolean;+ run_sequentially?: boolean;}) => {const client = await getClient(credentialGetter, "sans-api-v1");const body: Record<string, string | boolean | ProxyLocation | null> = {@@ -1185,6 +1191,9 @@ function CredentialsModal({if (pin_saved_session_ip !== undefined) {body.pin_saved_session_ip = pin_saved_session_ip;}+ if (run_sequentially !== undefined) {+ body.run_sequentially = run_sequentially;+ }const response = await client.patch<CredentialApiResponse>(`/credentials/${id}`,body,@@ -1249,13 +1258,18 @@ function CredentialsModal({? { browser_profile_id: browserProfileId, pin_saved_session_ip: pinIp }: {};+ const runSequentiallyChanged =+ isEditMode &&+ runSequentially !== (editingCredential?.run_sequentially ?? false);+// In edit mode, use editingGroups to determine what changed (type-agnostic)if (isEditMode && editingCredential) {if (!editingGroups.name &&!editingGroups.values &&!proxyPinChanged &&- !bmChanged+ !bmChanged &&+ !runSequentiallyChanged) {// Nothing was edited — close silentlyreset();@@ -1268,6 +1282,9 @@ function CredentialsModal({name,...(proxyPinChanged ? proxyPinPayload : {}),...bmPatch,+ ...(runSequentiallyChanged+ ? { run_sequentially: runSequentially }+ : {}),});return;}@@ -2131,6 +2148,29 @@ function CredentialsModal({</Alert>)}{credentialContent}+ {isEditMode && (+ <div className="space-y-1">+ <label className="flex cursor-pointer items-center gap-2 text-sm">+ <Checkbox+ checked={runSequentially}+ onCheckedChange={(checked) =>+ setRunSequentially(checked === true)+ }+ disabled={+ activeMutation.isPending ||+ renameCredentialMutation.isPending+ }+ />+ <span>Run workflows sequentially for this credential</span>+ </label>+ <p className="ml-6 text-xs text-muted-foreground">+ Serializes new workflow runs that share this credential so at+ most one runs at a time. Runs created before this is enabled are+ not serialized, and scheduled or sync-triggered runs are not yet+ supported and fail closed.+ </p>+ </div>+ )}{/* The browser-memory IP checkbox only replaces this for PASSWORDcredentials; card/secret keep the proxy-pin UI under the flag. */}{(!browserMemoryEnabled || type !== CredentialModalTypes.PASSWORD) &&