Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Stop the agents-list Edit action from inverting against the theme (SKY-16087) (#8524)
Aaron Perezb340c6a82b94
diff --git a/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx b/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsxindex 81d69ba1b..e5e0013b8 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowsFlat.tsx@@ -938,7 +938,7 @@ function WorkflowsFlat() {</TableCell><TableCell><div className="flex justify-end gap-0.5">- <Button size="icon" variant="default" disabled>+ <Button size="icon" variant="secondary" disabled><Pencil2Icon className="h-4 w-4" /></Button><Button size="icon" variant="ghost" disabled>@@ -1112,7 +1112,7 @@ function WorkflowsFlat() {<TooltipTrigger asChild><Buttonsize="icon"- variant="default"+ variant="secondary"onClick={(event) => {handleIconClick(event,diff --git a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsxindex 191fac508..2b67ad787 100644--- a/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx+++ b/skyvern-frontend/src/routes/workflows/components/tree/WorkflowRow.tsx@@ -118,7 +118,7 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {</TableCell><TableCell><div className="flex justify-end gap-0.5">- <Button size="icon" variant="default" disabled>+ <Button size="icon" variant="secondary" disabled><Pencil2Icon className="h-4 w-4" /></Button><Button size="icon" variant="ghost" disabled>@@ -267,7 +267,7 @@ function WorkflowRow({ workflow, depth = 0 }: WorkflowRowProps) {<TooltipTrigger asChild><Buttonsize="icon"- variant="default"+ variant="secondary"onClick={(event) => {handleIconClick(event,diff --git a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsxindex ffc4e4e76..c8e19e81d 100644--- a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx@@ -1787,6 +1787,12 @@ function Workspace({});yamlEntryHadChangesRef.current =useWorkflowHasChangesStore.getState().hasChanges;+ // Freeze the pre-edit canvas as the clean baseline before the draft can+ // diverge: a baseline captured once the draft is dirty is taken from the+ // draft itself (effectiveDraft prefers it), baking the uncommitted edit in.+ if (useWorkflowSnapshotStore.getState().snapshot === null) {+ useWorkflowSnapshotStore.getState().captureSnapshot();+ }useWorkflowYamlEditorStore.getState().open(yaml);};@@ -1953,7 +1959,15 @@ function Workspace({return false;}}- applyWorkflowUpdate(version, { persisted: persist });+ // A non-persisting commit is a user edit that lands async (the convert+ // round-trip outruns the canvas gesture window), so mark it — otherwise+ // the baseline absorbs it as post-load materialization and the save+ // confirmation sees nothing to confirm. A persisting commit already moved+ // the baseline the only other way it may move: a successful save.+ applyWorkflowUpdate(version, {+ persisted: persist,+ userDriven: !persist,+ });yamlStore.close();return true;} catch (error) {diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.test.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.test.tsxindex b9271c959..856e2923b 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.test.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.test.tsx@@ -34,7 +34,6 @@ const node = {};const updateNodeData = vi.fn();-let codeBlockAccess = true;let workflowErrorCodeMapping: Record<string, string> | null = null;vi.mock("@xyflow/react", () => ({@@ -52,11 +51,6 @@ vi.mock("@xyflow/react", () => ({}),}));-vi.mock("@/hooks/useFeatureFlag", () => ({- useFeatureFlag: (flag: string) =>- flag === "CODE_BLOCK_ACCESS" ? codeBlockAccess : undefined,-}));-vi.mock("..", () => ({errorMappingExampleValue: {sample_invalid_credentials: "if the credentials are incorrect, terminate",@@ -128,7 +122,6 @@ vi.mock("@/routes/workflows/components/CodeEditor", () => ({beforeEach(() => {node.data = { ...baseData };updateNodeData.mockClear();- codeBlockAccess = true;workflowErrorCodeMapping = null;});@@ -316,16 +309,7 @@ describe("CodeBlockEditor error messages", () => {).toBeTruthy();};- test("renders error messages below the code in the legacy layout", () => {- renderEditor();-- expectToRenderBefore(- screen.getByText("Code Input"),- screen.getByText("Error Messages"),- );- });-- test("renders error messages below the code in the code-first code view", () => {+ test("renders error messages below the code in the code view", () => {node.data = { ...baseData, ...codeFirstData };renderEditor();switchToCode();@@ -336,7 +320,7 @@ describe("CodeBlockEditor error messages", () => {);});- test("renders error messages below the steps card in the code-first plain view", () => {+ test("renders error messages below the steps card in the plain view", () => {node.data = { ...baseData, ...codeFirstData };renderEditor();@@ -346,7 +330,7 @@ describe("CodeBlockEditor error messages", () => {);});- test("toggles the Navigation-compatible editor in the legacy layout", () => {+ test("toggles the Navigation-compatible editor", () => {renderEditor();expect(screen.getByText("Error Messages")).toBeTruthy();expect(screen.queryByTestId("error-code-mapping-editor")).toBeNull();@@ -366,7 +350,7 @@ describe("CodeBlockEditor error messages", () => {});});- test("renders the editor in both code-first layouts", () => {+ test("renders the editor in both views", () => {node.data = {...baseData,...codeFirstData,@@ -593,18 +577,34 @@ describe("CodeBlockEditor step-to-code highlighting", () => {});});-describe("CodeBlockEditor for a legacy block", () => {- test("renders the inputs and code sections when goal is null", () => {+describe("CodeBlockEditor for a block without a goal", () => {+ test("still gets the code-first layout, opened on its code", () => {renderEditor();+ // The view toggle is the code-first layout; a goal-less block reaches it.+ expect(screen.getByText("View")).toBeTruthy();expect(screen.getByText("Inputs")).toBeTruthy();expect(screen.getByText("Code Input")).toBeTruthy();expect(screen.queryByText("Goal")).toBeNull();- expect(screen.queryByText("View")).toBeNull();- expect(screen.queryAllByTestId("block-input-textarea")).toHaveLength(0);});- test("treats a block missing the goal field entirely as legacy", () => {+ test("reaches the goal and steps by switching to the plain view", () => {+ renderEditor();+ fireEvent.click(screen.getByRole("button", { name: "Plain" }));++ expect(screen.getByText("Goal")).toBeTruthy();+ expect(screen.getByText(/No steps yet/)).toBeTruthy();+ });++ test("opens on the steps when a goal-less block carries an outline", () => {+ node.data = { ...baseData, steps: codeFirstData.steps! };+ renderEditor();++ expect(screen.getByText("Open the page")).toBeTruthy();+ expect(screen.queryByTestId("code-editor")).toBeNull();+ });++ test("treats a block missing the goal field entirely the same as null", () => {// Simulates pre-migration node data where the field is absent, not null.node.data = {...baseData,@@ -658,18 +658,6 @@ describe("CodeBlockEditor view toggle", () => {});});-describe("CodeBlockEditor without code-first access", () => {- test("renders the legacy code layout even when the block carries a goal", () => {- codeBlockAccess = false;- node.data = { ...baseData, ...codeFirstData };- renderEditor();-- expect(screen.getByText("Code Input")).toBeTruthy();- expect(screen.queryByText("Goal")).toBeNull();- expect(screen.queryByText("View")).toBeNull();- });-});-describe("CodeBlockEditor generate gating", () => {test("enables regenerate in the editable live scope", () => {node.data = { ...baseData, ...codeFirstData };diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsxindex 4a0925341..6cbccb1a7 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsx@@ -7,7 +7,6 @@ import { Label } from "@/components/ui/label";import { Switch } from "@/components/ui/switch";import { WorkflowBlockInputSet } from "@/components/WorkflowBlockInputSet";import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";-import { useFeatureFlag } from "@/hooks/useFeatureFlag";import { CodeEditor } from "@/routes/workflows/components/CodeEditor";import { jinjaHighlight } from "@/routes/workflows/components/jinjaHighlight";import { lineHighlight } from "@/routes/workflows/components/lineHighlight";@@ -69,11 +68,12 @@ function CodeBlockEditorBody({const { editable } = data;const update = useUpdate<CodeBlockNodeData>({ id: blockId, editable });const scopeReadOnly = useWorkflowScopeReadOnly();- const codeFirstAccess = useFeatureFlag("CODE_BLOCK_ACCESS") === true;- // Code-first layout needs the access flag plus a prompt; otherwise keep the legacy manual layout.- const isCodeFirst = data.prompt != null && codeFirstAccess;const steps = data.steps ?? [];- const [view, setView] = useState<CodeBlockView>("plain");+ // A block with neither a goal nor a generated outline is hand-written, so open+ // it on its code rather than on an empty Steps card.+ const [view, setView] = useState<CodeBlockView>(+ data.prompt == null && steps.length === 0 ? "code" : "plain",+ );const [stepsOpen, setStepsOpen] = useState(true);const [activeStepIndex, setActiveStepIndex] = useState<number | null>(null);const activeStep =@@ -371,19 +371,6 @@ function CodeBlockEditorBody({</div>) : null;- if (!isCodeFirst) {- return (- <div data-testid="code-block-block-form" className="space-y-4">- {inputsField}- <div className="space-y-2">- <Label className="text-xs text-tertiary-foreground">Code Input</Label>- {codeEditorElement}- </div>- {errorCodeMappingField}- </div>- );- }-return (<div data-testid="code-block-block-form" className="space-y-4"><div className="flex items-center justify-between gap-2">diff --git a/skyvern-frontend/src/store/WorkflowSnapshotStore.test.ts b/skyvern-frontend/src/store/WorkflowSnapshotStore.test.tsindex 054ee2bb4..c1838c01d 100644--- a/skyvern-frontend/src/store/WorkflowSnapshotStore.test.ts+++ b/skyvern-frontend/src/store/WorkflowSnapshotStore.test.ts@@ -19,11 +19,14 @@ import { useWorkflowSnapshotStore } from "./WorkflowSnapshotStore";const block = (label: string, extra: Record<string, unknown> = {}): BlockYAML =>({ label, block_type: "task", ...extra }) as unknown as BlockYAML;-const saveData = (blocks: Array<BlockYAML>): WorkflowSaveData =>+const saveData = (+ blocks: Array<BlockYAML>,+ parameters: Array<unknown> = [],+): WorkflowSaveData =>({title: "T",blocks,- parameters: [],+ parameters,settings: { proxyLocation: "RESIDENTIAL" },workflow: {title: "T",@@ -32,8 +35,10 @@ const saveData = (blocks: Array<BlockYAML>): WorkflowSaveData =>}) as unknown as WorkflowSaveData;/** Point getSaveData at a fresh draft — the store reads it live on each call. */-function setDraft(blocks: Array<BlockYAML>) {- useWorkflowHasChangesStore.setState({ getSaveData: () => saveData(blocks) });+function setDraft(blocks: Array<BlockYAML>, parameters: Array<unknown> = []) {+ useWorkflowHasChangesStore.setState({+ getSaveData: () => saveData(blocks, parameters),+ });}beforeEach(() => {@@ -176,6 +181,47 @@ describe("WorkflowSnapshotStore YAML-draft trigger", () => {});});+describe("WorkflowSnapshotStore across a YAML commit", () => {+ const param = {+ parameter_type: "workflow",+ key: "p",+ workflow_parameter_type: "string",+ };++ // The commit's convert round-trip outruns the canvas gesture window, so+ // FlowRenderer refreshes the rebuilt canvas as non-user materialization —+ // and an edit the draft diff can't see (effectiveDraft only takes+ // `parameters` when the draft parses it as an array) has marked nothing+ // user-edited, so the baseline absorbs the commit and Save has nothing left+ // to confirm. Workspace.commitYaml marks the non-persisting commit+ // user-driven to pin the baseline; this is that path.+ it("pins the baseline when the commit lands an edit the draft diff missed", () => {+ const blocks = [block("a", { url: "x" })];+ setDraft(blocks, [param]);+ useWorkflowSnapshotStore.getState().captureSnapshot(); // frozen at YAML entry+ useWorkflowYamlEditorStore+ .getState()+ .open(toYaml({ parameters: [param], blocks }));++ // Dropping the whole `parameters:` key reads as unchanged against the canvas.+ const unsub = subscribeToYamlDraftChanges(() =>+ useWorkflowSnapshotStore.getState().noteDraftChange(true),+ );+ useWorkflowYamlEditorStore.getState().setDraft(toYaml({ blocks }));+ unsub();+ expect(useWorkflowSnapshotStore.getState().userHasEdited).toBe(false);++ setDraft(blocks, []); // the commit rebuilds the canvas without the parameter+ useWorkflowSnapshotStore.getState().markUserEdit();+ useWorkflowYamlEditorStore.getState().close();+ useWorkflowSnapshotStore.getState().noteDraftChange(false);++ const { snapshot } = useWorkflowSnapshotStore.getState();+ expect(snapshot?.parameters).toEqual([param]);+ expect(isDraftDirty(saveData(blocks, []), snapshot)).toBe(true);+ });+});+describe("WorkflowSnapshotStore cross-workflow reset (A→B same instance)", () => {// Workspace can be reused across workflows without remounting (A/build →// B/build), so its per-workflow reset effect must clear the baseline — a