Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(copilot): code-first demo-readiness PoC — labels, action-row fix, extraction render, Build-vs-code (#6771)
Aaron Perez5294745c2ccd
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.tsindex 0013f30e6..41070aff9 100644--- a/skyvern-frontend/src/api/types.ts+++ b/skyvern-frontend/src/api/types.ts@@ -504,10 +504,20 @@ export const ReadableActionTypes: {execute_js: "Execute JS",};+type GetReadableActionTypeOptions = {+ nullActionLabel?: string;+};+// Recorded code-block actions can carry an action_type the readable map doesn't// list yet (the runtime recorder maps more Playwright calls than the UI enumerates).// Humanize unknown types instead of rendering a blank badge.-export function getReadableActionType(actionType: string): string {+export function getReadableActionType(+ actionType: string,+ options: GetReadableActionTypeOptions = {},+): string {+ if (actionType === ActionTypes.NullAction && options.nullActionLabel) {+ return options.nullActionLabel;+ }const known = ReadableActionTypes[actionType as ActionType];if (known) {return known;diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerMode.test.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerMode.test.tsxindex ac302a4c0..b1622ed04 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerMode.test.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.composerMode.test.tsx@@ -159,7 +159,7 @@ async function submit(value: string) {});}-async function selectMode(label: "Ask" | "Build" | "Build with code") {+async function selectMode(label: "Ask" | "Build" | "Build workflow as code") {await act(async () => {fireEvent.pointerDown(screen.getByRole("button", { name: "Switch mode" }), {button: 0,@@ -252,13 +252,13 @@ describe("WorkflowCopilotChat — composer default mode variant", () => {expect(streamCalls[0]?.body.code_block).toBe(null);});- it("lands on code ON when selecting Build with code", async () => {+ it("lands on code ON when selecting Build workflow as code", async () => {await renderChat({copilotV2: true,codeBlockMode: true,defaultMode: "ask_code",});- await selectMode("Build with code");+ await selectMode("Build workflow as code");await submit("build me a workflow");await waitFor(() => expect(postStreaming).toHaveBeenCalledTimes(1));diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsxindex 1dc1940c9..43f4bf41a 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx@@ -2321,7 +2321,10 @@ export function WorkflowCopilotChat({setCodeWorkflow(false);setCodeBlockRequestOverride(null);}}- className="flex items-start gap-2.5"+ className={cn(+ "flex items-start gap-2.5",+ !isBuild && "bg-accent",+ )}><ModeGlyph mode="ask" /><span className="flex flex-1 flex-col">@@ -2341,7 +2344,10 @@ export function WorkflowCopilotChat({setCodeWorkflow(false);setCodeBlockRequestOverride(false);}}- className="flex items-start gap-2.5"+ className={cn(+ "flex items-start gap-2.5",+ isBuild && !codeWorkflow && "bg-accent",+ )}><ModeGlyph mode="build" /><span className="flex flex-1 flex-col">@@ -2357,18 +2363,21 @@ export function WorkflowCopilotChat({</DropdownMenuItem>{codeOptionAvailable ? (<DropdownMenuItem- aria-label="Build with code"+ aria-label="Build workflow as code"onSelect={() => {setComposerMode("build");setCodeWorkflow(true);setCodeBlockRequestOverride(true);}}- className="flex items-start gap-2.5"+ className={cn(+ "flex items-start gap-2.5",+ isBuild && codeWorkflow && "bg-accent",+ )}><ModeGlyph mode="build" glow /><span className="flex flex-1 flex-col"><span className="text-sm font-medium">- Build with code+ Build workflow as code</span><span className="text-xs leading-snug text-muted-foreground">Build the workflow as code. Faster and more flexible,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 2ff0cb1a7..752f87fa3 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@@ -96,14 +96,18 @@ beforeEach(() => {afterEach(cleanup);-function renderEditor(readOnly: boolean = false, view?: "plain" | "code") {+function renderEditor(readOnly: boolean = false) {return render(<WorkflowScopeContext.Provider value={{ workflowId: "w", readOnly }}>- <CodeBlockEditor blockId="cb1" view={view} />+ <CodeBlockEditor blockId="cb1" /></WorkflowScopeContext.Provider>,);}+function switchToCode() {+ fireEvent.click(screen.getByRole("button", { name: /Code/ }));+}+const codeFirstData: Partial<CodeBlockNodeData> = {prompt: "Open {{ url }}",steps: [{ description: "Open the page", action_type: "goto_url" }],@@ -138,29 +142,29 @@ test("wires the jinja highlight into the code editor", () => {});describe("CodeBlockEditor for a code-first block", () => {- test("renders goal, steps, and code panel in order", () => {+ test("defaults to the plain view: goal and steps, no inputs or code editor", () => {node.data = { ...baseData, ...codeFirstData };- const { container } = renderEditor();+ renderEditor();expect(screen.getByText("Goal")).toBeTruthy();- expect(screen.getByText("Steps (1)")).toBeTruthy();expect(screen.getByText("Open the page")).toBeTruthy();- expect(screen.getByText("goto_url")).toBeTruthy();-- const text = container.textContent ?? "";- const order = ["Goal", "Steps (1)", "Code Input"].map((label) =>- text.indexOf(label),- );- expect(order).toEqual([...order].sort((a, b) => a - b));- expect(order.every((index) => index >= 0)).toBe(true);+ // The readable action label is the per-step subtitle.+ expect(screen.getByText("Goto URL")).toBeTruthy();+ // Inputs and the code editor live in the code view, not the plain view.+ expect(screen.queryByText("Inputs")).toBeNull();+ expect(screen.queryByTestId("code-editor")).toBeNull();});- test("renders the inputs selector alongside the code panel", () => {+ test("exposes the inputs selector and code panel in the code view", () => {node.data = { ...baseData, ...codeFirstData };renderEditor();+ switchToCode();expect(screen.getByText("Inputs")).toBeTruthy();expect(screen.getByText("Code Input")).toBeTruthy();+ expect(screen.getByTestId("code-editor")).toBeTruthy();+ // The goal lives in the plain view only.+ expect(screen.queryByText("Goal")).toBeNull();});test("uses the parameter-autocomplete textarea for the goal", () => {@@ -187,9 +191,10 @@ describe("CodeBlockEditor for a code-first block", () => {});});- test("collapses and expands the step list", () => {+ test("collapses and expands the step list in the code view", () => {node.data = { ...baseData, ...codeFirstData };renderEditor();+ switchToCode();const toggle = () => screen.getByRole("button", { name: /Steps \(1\)/ });expect(screen.getByText("Open the page")).toBeTruthy();@@ -204,11 +209,12 @@ describe("CodeBlockEditor for a code-first block", () => {expect(toggle().getAttribute("aria-expanded")).toBe("true");});- test("omits the step list when the block has no steps", () => {+ test("omits the code-view step list when the block has no steps", () => {node.data = { ...baseData, ...codeFirstData, steps: [] };renderEditor();+ switchToCode();- expect(screen.getByText("Goal")).toBeTruthy();+ expect(screen.getByText("Code Input")).toBeTruthy();expect(screen.queryByText(/Steps \(/)).toBeNull();});});@@ -232,9 +238,10 @@ describe("CodeBlockEditor step-to-code highlighting", () => {],};- test("shows each step's line range", () => {+ test("shows each step's line range in the code view", () => {node.data = { ...baseData, ...steppedData };renderEditor();+ switchToCode();expect(screen.getByText("L2-3")).toBeTruthy();expect(screen.getByText("L5")).toBeTruthy();@@ -243,6 +250,7 @@ describe("CodeBlockEditor step-to-code highlighting", () => {test("highlights the clicked step's lines and toggles off", () => {node.data = { ...baseData, ...steppedData };renderEditor();+ switchToCode();const editor = () => screen.getByTestId("code-editor");// Baseline: jinja only (2 extensions), no active step.@@ -267,7 +275,7 @@ describe("CodeBlockEditor for a legacy block", () => {expect(screen.getByText("Inputs")).toBeTruthy();expect(screen.getByText("Code Input")).toBeTruthy();expect(screen.queryByText("Goal")).toBeNull();- expect(screen.queryByText(/Steps \(/)).toBeNull();+ expect(screen.queryByText("View")).toBeNull();expect(screen.queryAllByTestId("block-input-textarea")).toHaveLength(0);});@@ -286,55 +294,42 @@ describe("CodeBlockEditor for a legacy block", () => {});describe("CodeBlockEditor for a newly-added block from the node adder", () => {- test("renders the code-first layout because the default goal is non-null", () => {+ test("renders the code-first plain view because the default goal is non-null", () => {node.data = { ...codeBlockNodeDefaultData, label: "code_block" };renderEditor();expect(screen.getByText("Goal")).toBeTruthy();+ expect(screen.getByText("View")).toBeTruthy();// Steps are copilot-authored annotations, so a hand-added block has none yet.- expect(screen.queryByText(/Steps \(/)).toBeNull();+ expect(screen.getByText(/No steps yet/)).toBeTruthy();});});-describe("CodeBlockEditor plain view", () => {- test("shows goal and steps but not inputs or the code editor", () => {+describe("CodeBlockEditor view toggle", () => {+ test("switches between the plain and code views", () => {node.data = { ...baseData, ...codeFirstData };- renderEditor(false, "plain");-- expect(screen.getByText("Goal")).toBeTruthy();- expect(screen.getByText("What Skyvern will do")).toBeTruthy();- expect(screen.getByText("Open the page")).toBeTruthy();- // The readable action label is the per-step subtitle.- expect(screen.getByText("Goto URL")).toBeTruthy();- // Inputs and the code editor live outside the plain view now.- expect(screen.queryByText("Inputs")).toBeNull();- expect(screen.queryByTestId("code-editor")).toBeNull();- });-- test("shows an empty hint when a code-first block has no steps", () => {- node.data = { ...baseData, ...codeFirstData, steps: [] };- renderEditor(false, "plain");+ renderEditor(false);- expect(screen.getByText("What Skyvern will do")).toBeTruthy();- expect(screen.getByText(/No steps yet/)).toBeTruthy();+ // Plain by default.+ expect(screen.getByTitle("Open the page")).toBeTruthy();expect(screen.queryByTestId("code-editor")).toBeNull();- });-- test("renders inputs and the code editor when the view is code", () => {- node.data = { ...baseData, ...codeFirstData };- renderEditor(false, "code");+ switchToCode();expect(screen.getByTestId("code-editor")).toBeTruthy();expect(screen.getByText("Inputs")).toBeTruthy();- expect(screen.queryByText("Goal")).toBeNull();- expect(screen.queryByText("What Skyvern will do")).toBeNull();++ fireEvent.click(screen.getByRole("button", { name: "Plain" }));+ expect(screen.queryByTestId("code-editor")).toBeNull();+ expect(screen.getByText("Goal")).toBeTruthy();});- test("ignores the split view for a legacy block without a goal", () => {- renderEditor(false, "plain");+ test("shows an empty hint in the plain view when there are no steps", () => {+ node.data = { ...baseData, ...codeFirstData, steps: [] };+ renderEditor(false);- expect(screen.queryByText("What Skyvern will do")).toBeNull();- expect(screen.getByText("Code Input")).toBeTruthy();+ expect(screen.getByText("Goal")).toBeTruthy();+ expect(screen.getByText(/No steps yet/)).toBeTruthy();+ expect(screen.queryByTestId("code-editor")).toBeNull();});});@@ -346,7 +341,7 @@ describe("CodeBlockEditor without code-first access", () => {expect(screen.getByText("Code Input")).toBeTruthy();expect(screen.queryByText("Goal")).toBeNull();- expect(screen.queryByText(/Steps \(/)).toBeNull();+ expect(screen.queryByText("View")).toBeNull();});});diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsxindex 5fe141d99..4153e043d 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockEditor.tsx@@ -13,6 +13,7 @@ import { jinjaHighlight } from "@/routes/workflows/components/jinjaHighlight";import { lineHighlight } from "@/routes/workflows/components/lineHighlight";import { useWorkflowScopeReadOnly } from "@/routes/workflows/editor/WorkflowScopeContext";import type { CodeBlockStep } from "@/routes/workflows/types/workflowTypes";+import { getCodeStepPlainText } from "@/routes/workflows/workflowBlockUtils";import { useCopilotActionStore } from "@/store/useCopilotActionStore";import { deepEqualStringArrays } from "@/util/equality";import { cn } from "@/util/utils";@@ -20,7 +21,8 @@ import { cn } from "@/util/utils";import { type AppNode, isWorkflowBlockNode } from "..";import { dataSchemaExampleValue } from "../types";import { CodeBlockPlainCard } from "./CodeBlockPlainCard";-import type { CodeBlockView } from "./CodeBlockViewToggle";+import { getStepLabel } from "./stepPresentation";+import { CodeBlockViewToggle, type CodeBlockView } from "./CodeBlockViewToggle";import type { CodeBlockNode, CodeBlockNodeData } from "./types";import { useUpdate } from "../../useUpdate";@@ -34,35 +36,21 @@ function formatStepLines(step: CodeBlockStep): string {return `L${step.line_start}-${step.line_end}`;}-function CodeBlockEditor({- blockId,- view,-}: {- blockId: string;- view?: CodeBlockView;-}) {+function CodeBlockEditor({ blockId }: { blockId: string }) {const rf = useReactFlow<AppNode>();const node = rf.getNode(blockId);if (!node || !isWorkflowBlockNode(node) || node.type !== "codeBlock") {return null;}- return (- <CodeBlockEditorBody- blockId={blockId}- node={node as CodeBlockNode}- view={view}- />- );+ return <CodeBlockEditorBody blockId={blockId} node={node as CodeBlockNode} />;}function CodeBlockEditorBody({blockId,node,- view,}: {blockId: string;node: CodeBlockNode;- view?: CodeBlockView;}) {const data = node.data;const { editable } = data;@@ -72,6 +60,7 @@ function CodeBlockEditorBody({// 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");const [stepsOpen, setStepsOpen] = useState(true);const [activeStepIndex, setActiveStepIndex] = useState<number | null>(null);const activeStep =@@ -153,7 +142,8 @@ function CodeBlockEditorBody({update({ code: value });}}className="nopan"- fontSize={8}+ fontSize={10}+ lineWrap={false}extraExtensions={codeExtensions}/>);@@ -186,99 +176,109 @@ function CodeBlockEditorBody({/>);- if (isCodeFirst && view === "plain") {- return (- <div data-testid="code-block-block-form" className="space-y-4">- {goalField}- <CodeBlockPlainCard- steps={steps}- generating={isGenerating}- onStop={requestCancel}- />+ // Technical step list shown alongside the code: clicking a step highlights+ // the lines it maps to in the editor.+ const stepLineList =+ steps.length > 0 ? (+ <div className="space-y-2">+ <button+ type="button"+ aria-expanded={stepsOpen}+ className="flex w-full items-center justify-between text-xs text-slate-300"+ onClick={() => setStepsOpen((open) => !open)}+ >+ <span>Steps ({steps.length})</span>+ <ChevronDownIcon+ className={cn(+ "size-4 transition-transform",+ stepsOpen && "rotate-180",+ )}+ />+ </button>+ {stepsOpen && (+ <ol className="space-y-1">+ {steps.map((step, index) => {+ const hasLines = step.line_start != null;+ const isActive = activeStepIndex === index;+ return (+ <li key={index}>+ <button+ type="button"+ disabled={!hasLines}+ aria-pressed={isActive}+ onClick={() =>+ setActiveStepIndex((current) =>+ current === index ? null : index,+ )+ }+ className={cn(+ "flex w-full items-center gap-2 rounded bg-slate-elevation1 px-2 py-1 text-left text-xs",+ hasLines && "hover:bg-slate-elevation2",+ isActive && "ring-1 ring-sky-400/60",+ !hasLines && "cursor-default",+ )}+ >+ <span className="w-5 shrink-0 tabular-nums text-slate-500">+ {index + 1}.+ </span>+ <span className="shrink-0 rounded border border-slate-700 px-1.5 py-0.5 text-[10px] text-slate-400">+ {getStepLabel(step.action_type)}+ </span>+ <span className="min-w-0 flex-1 truncate text-slate-300">+ {getCodeStepPlainText(step)}+ </span>+ {hasLines && (+ <span className="shrink-0 text-[10px] tabular-nums text-slate-500">+ {formatStepLines(step)}+ </span>+ )}+ </button>+ </li>+ );+ })}+ </ol>+ )}</div>- );- }+ ) : null;- if (isCodeFirst && view === "code") {+ if (!isCodeFirst) {return (<div data-testid="code-block-block-form" className="space-y-4">{inputsField}- {dataSchemaField}- {codeEditorElement}+ <div className="space-y-2">+ <Label className="text-xs text-slate-300">Code Input</Label>+ {codeEditorElement}+ </div></div>);}return (<div data-testid="code-block-block-form" className="space-y-4">- {isCodeFirst && goalField}- {isCodeFirst && steps.length > 0 && (- <div className="space-y-2">- <button- type="button"- aria-expanded={stepsOpen}- className="flex w-full items-center justify-between text-xs text-slate-300"- onClick={() => setStepsOpen((open) => !open)}- >- <span>Steps ({steps.length})</span>- <ChevronDownIcon- className={cn(- "size-4 transition-transform",- stepsOpen && "rotate-180",- )}- />- </button>- {stepsOpen && (- <ol className="space-y-1">- {steps.map((step, index) => {- const hasLines = step.line_start != null;- const isActive = activeStepIndex === index;- return (- <li key={index}>- <button- type="button"- disabled={!hasLines}- aria-pressed={isActive}- onClick={() =>- setActiveStepIndex((current) =>- current === index ? null : index,- )- }- className={cn(- "flex w-full items-center gap-2 rounded bg-slate-elevation1 px-2 py-1 text-left text-xs",- hasLines && "hover:bg-slate-elevation2",- isActive && "ring-1 ring-sky-400/60",- !hasLines && "cursor-default",- )}- >- <span className="w-5 shrink-0 tabular-nums text-slate-500">- {index + 1}.- </span>- <span className="shrink-0 rounded border border-slate-700 px-1.5 py-0.5 text-[10px] text-slate-400">- {step.action_type}- </span>- <span className="min-w-0 flex-1 truncate text-slate-300">- {step.title ?? step.description ?? ""}- </span>- {hasLines && (- <span className="shrink-0 text-[10px] tabular-nums text-slate-500">- {formatStepLines(step)}- </span>- )}- </button>- </li>- );- })}- </ol>- )}- </div>- )}- {inputsField}- {isCodeFirst && dataSchemaField}- <div className="space-y-2">- <Label className="text-xs text-slate-300">Code Input</Label>- {codeEditorElement}+ <div className="flex items-center justify-between gap-2">+ <Label className="text-xs text-slate-300">View</Label>+ <CodeBlockViewToggle value={view} onChange={setView} /></div>+ {view === "plain" ? (+ <>+ {goalField}+ <CodeBlockPlainCard+ steps={steps}+ generating={isGenerating}+ onStop={requestCancel}+ />+ </>+ ) : (+ <>+ {stepLineList}+ {inputsField}+ {dataSchemaField}+ <div className="space-y-2">+ <Label className="text-xs text-slate-300">Code Input</Label>+ {codeEditorElement}+ </div>+ </>+ )}</div>);}diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockNode.tsxindex 6f784a69e..1bcf59e32 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockNode.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockNode.tsx@@ -1,8 +1,6 @@import { Handle, NodeProps, Position } from "@xyflow/react";-import { useState } from "react";import { useParams } from "react-router-dom";-import { useFeatureFlag } from "@/hooks/useFeatureFlag";import { statusIsRunningOrQueued } from "@/routes/tasks/types";import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";import { useRecordingStore } from "@/store/useRecordingStore";@@ -12,8 +10,8 @@ import { useCollapseContext } from "../../collapse/CollapseContext";import { NodeBody } from "../../collapse/NodeBody";import { BuildModeOnly } from "../BuildModeOnly";import { CodeBlockEditor } from "./CodeBlockEditor";-import { CodeBlockViewToggle, type CodeBlockView } from "./CodeBlockViewToggle";import { NodeHeader } from "../components/NodeHeader";+import { getCodeBlockTitle } from "../types";import type { CodeBlockNode } from "./types";function CodeBlockNode({ id, data }: NodeProps<CodeBlockNode>) {@@ -22,10 +20,10 @@ function CodeBlockNode({ id, data }: NodeProps<CodeBlockNode>) {const { data: workflowRun } = useWorkflowRunQuery();const recordingStore = useRecordingStore();const { open } = useCollapseContext();- const isCodeFirst = data.prompt != null;- const codeFirstAccess = useFeatureFlag("CODE_BLOCK_ACCESS") === true;- const showViewToggle = isCodeFirst && codeFirstAccess;- const [view, setView] = useState<CodeBlockView>("plain");+ const blockTitle = getCodeBlockTitle({+ prompt: data.prompt,+ steps: data.steps,+ });const workflowRunIsRunningOrQueued =workflowRun && statusIsRunningOrQueued(workflowRun);const thisBlockIsTargetted =@@ -70,18 +68,11 @@ function CodeBlockNode({ id, data }: NodeProps<CodeBlockNode>) {totpIdentifier={null}totpUrl={null}type="code"- viewToggle={- showViewToggle ? (- <CodeBlockViewToggle value={view} onChange={setView} />- ) : undefined- }+ blockTitle={blockTitle}/><NodeBody><BuildModeOnly>- <CodeBlockEditor- blockId={id}- view={showViewToggle ? view : undefined}- />+ <CodeBlockEditor blockId={id} /></BuildModeOnly></NodeBody></div>diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.test.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.test.tsxindex 544a049ac..b3f061d37 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.test.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.test.tsx@@ -12,6 +12,31 @@ afterEach(() => {});describe("CodeBlockPlainCard", () => {+ it("renders a Steps section with a count", () => {+ render(+ <CodeBlockPlainCard+ steps={[+ { action_type: "goto_url", description: "Open the portal" },+ { action_type: "extract", description: "Read the totals" },+ ]}+ />,+ );++ expect(screen.getByText("Steps")).toBeDefined();+ expect(screen.getByText("2 steps")).toBeDefined();+ });++ it("uses a singular label for a single step", () => {+ render(+ <CodeBlockPlainCard+ steps={[{ action_type: "extract", title: "Summarize the page" }]}+ />,+ );++ expect(screen.getByText("1 step")).toBeDefined();+ expect(screen.getByText("Summarize the page")).toBeDefined();+ });+it("renders a page.evaluate step with the Execute JS label, not a dropped or blank step", () => {const steps: Array<CodeBlockStep> = [{@@ -30,11 +55,13 @@ describe("CodeBlockPlainCard", () => {render(<CodeBlockPlainCard steps={steps} />);+ // Per-step action labels.expect(screen.getByText("Goto URL")).toBeDefined();expect(screen.getByText("Execute JS")).toBeDefined();+ // Plain text for the second step is preserved, not dropped.expect(screen.getByText("Run a script")).toBeDefined();- // The evaluate step is the 2nd of 2 — the count must match the script, not drop it.- expect(screen.getByText("2")).toBeDefined();+ // The evaluate step is the 2nd of 2 — the count must match the script.+ expect(screen.getByText("2 steps")).toBeDefined();});it("humanizes an unmapped step action type instead of rendering a blank label", () => {@@ -51,4 +78,29 @@ describe("CodeBlockPlainCard", () => {expect(screen.getByText("Go Forward")).toBeDefined();});++ it("falls back to the readable action type for the step text when title and description are absent", () => {+ const steps: Array<CodeBlockStep> = [+ { action_type: "extract", line_start: 1, line_end: 1 },+ ];++ render(<CodeBlockPlainCard steps={steps} />);++ // The primary step text falls back to the readable type instead of a blank+ // label; the type subtitle reads it too, so it appears twice.+ expect(screen.getAllByText("Extract Data").length).toBe(2);+ });++ it("shows an empty hint when there are no steps", () => {+ render(<CodeBlockPlainCard steps={[]} />);++ expect(screen.getByText(/No steps yet/)).toBeDefined();+ });++ it("shows a generating indicator and stop control while generating", () => {+ render(<CodeBlockPlainCard steps={[]} generating onStop={() => {}} />);++ expect(screen.getByText("Generating…")).toBeDefined();+ expect(screen.getByRole("button", { name: /Stop/ })).toBeDefined();+ });});diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.tsxindex 8da1d5a51..1d4568ea3 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/CodeBlockNode/CodeBlockPlainCard.tsx@@ -1,6 +1,8 @@import { Cross2Icon, ReloadIcon } from "@radix-ui/react-icons";+import { Label } from "@/components/ui/label";import type { CodeBlockStep } from "@/routes/workflows/types/workflowTypes";+import { getCodeStepPlainText } from "@/routes/workflows/workflowBlockUtils";import { cn } from "@/util/utils";import {@@ -17,12 +19,10 @@ type Props = {function CodeBlockPlainCard({ steps, generating = false, onStop }: Props) {return (- <div data-testid="code-block-plain-card" className="space-y-3">+ <div data-testid="code-block-plain-card" className="space-y-2"><div className="flex items-center justify-between gap-2">- <div className="text-sm font-semibold text-slate-200">- What Skyvern will do- </div>- {generating && (+ <Label className="text-xs text-slate-300">Steps</Label>+ {generating ? (<div className="flex items-center gap-2 text-xs text-slate-400"><span className="flex items-center gap-1"><ReloadIcon className="size-3 animate-spin" />@@ -39,57 +39,64 @@ function CodeBlockPlainCard({ steps, generating = false, onStop }: Props) {</button>)}</div>+ ) : (+ steps.length > 0 && (+ <span className="shrink-0 text-xs tabular-nums text-slate-400">+ {steps.length} {steps.length === 1 ? "step" : "steps"}+ </span>+ ))}</div>{generating ? (- <ol className="space-y-0" aria-busy="true">+ <ol className="space-y-1.5" aria-busy="true">{[0, 1, 2].map((index) => (- <li key={index} className="flex gap-3">- <div className="flex flex-col items-center">- <div className="size-8 shrink-0 animate-pulse rounded-lg bg-slate-elevation2" />- {index < 2 && <div className="w-px flex-1 bg-slate-700/60" />}- </div>- <div className="min-w-0 flex-1 pb-4">- <div className="h-3.5 w-2/3 animate-pulse rounded bg-slate-elevation2" />- <div className="mt-1.5 h-2.5 w-1/3 animate-pulse rounded bg-slate-elevation2" />+ <li+ key={index}+ className="flex items-center gap-2.5 rounded-md border border-slate-700/60 bg-slate-elevation1 px-2.5 py-2"+ >+ <div className="size-7 shrink-0 animate-pulse rounded-md bg-slate-elevation2" />+ <div className="min-w-0 flex-1 space-y-1.5">+ <div className="h-3 w-2/3 animate-pulse rounded bg-slate-elevation2" />+ <div className="h-2.5 w-1/3 animate-pulse rounded bg-slate-elevation2" /></div></li>))}</ol>) : steps.length === 0 ? (- <p className="rounded-lg border border-dashed border-slate-700/70 px-3 py-4 text-xs text-slate-400">+ <p className="rounded-md border border-dashed border-slate-700/70 px-3 py-4 text-xs text-slate-400">No steps yet. Steps appear once Skyvern generates them.</p>) : (- <ol>+ <ol className="space-y-1.5">{steps.map((step, index) => {- const isLast = index === steps.length - 1;+ const plainText = getCodeStepPlainText(step);return (- <li key={index} className="flex gap-3">- <div className="flex flex-col items-center">+ <li+ key={index}+ className="flex items-start gap-2.5 rounded-md border border-slate-700/60 bg-slate-elevation1 px-2.5 py-2"+ >+ <div+ className={cn(+ "flex size-7 shrink-0 items-center justify-center rounded-md",+ getStepChipClassName(step.action_type),+ )}+ >+ {getStepIcon(step.action_type)}+ </div>+ <div className="min-w-0 flex-1"><div- className={cn(- "flex size-8 shrink-0 items-center justify-center rounded-lg",- getStepChipClassName(step.action_type),- )}+ className="truncate text-xs font-medium text-slate-100"+ title={plainText}>- {getStepIcon(step.action_type)}+ {plainText}</div>- {!isLast && <div className="w-px flex-1 bg-slate-700/60" />}- </div>- <div className={cn("min-w-0 flex-1", !isLast && "pb-4")}>- <div className="flex items-baseline gap-2">- <span className="shrink-0 text-xs tabular-nums text-slate-500">- {index + 1}- </span>- <span className="text-sm font-medium text-slate-100">- {step.title ?? step.description ?? ""}- </span>- </div>- <p className="mt-0.5 text-xs text-slate-400">+ <div className="mt-0.5 text-[11px] text-slate-400">{getStepLabel(step.action_type)}- </p>+ </div></div>+ <span className="shrink-0 text-[11px] tabular-nums text-slate-500">+ {index + 1}+ </span></li>);})}diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsxindex 268454857..1c69e31bf 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx@@ -129,6 +129,7 @@ interface Transmutations {interface Props {blockLabel: string; // today, this + wpid act as the identity of a block+ blockTitle?: string;disabled?: boolean;editable: boolean;extraActions?: React.ReactNode;@@ -140,7 +141,6 @@ interface Props {totpUrl: string | null;transmutations?: Transmutations;type: WorkflowBlockType;- viewToggle?: React.ReactNode;}type Payload = Record<string, unknown> & {@@ -226,6 +226,7 @@ const getPayload = (opts: {function NodeHeader({blockLabel,+ blockTitle: blockTitleOverride,disabled = false,editable,extraActions,@@ -235,7 +236,6 @@ function NodeHeader({totpUrl,transmutations,type,- viewToggle,}: Props) {const log = useLogging();const mode = useWorkflowEditorMode();@@ -256,7 +256,7 @@ function NodeHeader({id: nodeId,initialValue: blockLabel,});- const blockTitle = workflowBlockTitle[type];+ const blockTitle = blockTitleOverride ?? workflowBlockTitle[type];const requestDeleteNodeCallback = useRequestDeleteNodeCallback();const transmuteNodeCallback = useTransmuteNodeCallback();const toggleScriptForNodeCallback = useToggleScriptForNodeCallback();@@ -966,7 +966,12 @@ function NodeHeader({</NoticeMe></div>) : (- <span className="text-xs text-slate-400">{blockTitle}</span>+ <span+ className="min-w-0 flex-1 truncate text-xs text-slate-400"+ title={blockTitle}+ >+ {blockTitle}+ </span>)}{workflowSettingsStore.finallyBlockLabel === blockLabel && (<span className="rounded bg-amber-600/20 px-1.5 py-0.5 text-[10px] font-medium text-amber-400">@@ -977,7 +982,6 @@ function NodeHeader({</div></div><div className="pointer-events-auto ml-auto flex items-center gap-2">- {viewToggle}{extraActions}{thisBlockIsPlaying && (<div className="ml-auto">diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/types.test.ts b/skyvern-frontend/src/routes/workflows/editor/nodes/types.test.tsnew file mode 100644index 000000000..bdd4bf6cd--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/types.test.ts@@ -0,0 +1,40 @@+import { describe, expect, it } from "vitest";++import { CODE_BLOCK_TITLE_MAX_LENGTH, getCodeBlockTitle } from "./types";++describe("getCodeBlockTitle", () => {+ it("prefers a normalized prompt over the first step title", () => {+ expect(+ getCodeBlockTitle({+ prompt: " Collect\ninvoice details ",+ steps: [{ title: "Run a script" }],+ }),+ ).toBe("Collect invoice details");+ });++ it("falls back to the first step title and then Code", () => {+ expect(+ getCodeBlockTitle({+ prompt: null,+ steps: [{ title: "Summarize the page" }],+ }),+ ).toBe("Summarize the page");++ expect(+ getCodeBlockTitle({+ prompt: " ",+ steps: [{ title: null }],+ }),+ ).toBe("Code");+ });++ it("truncates long titles", () => {+ const title = getCodeBlockTitle({+ prompt: "a".repeat(CODE_BLOCK_TITLE_MAX_LENGTH + 20),+ steps: null,+ });++ expect(title).toHaveLength(CODE_BLOCK_TITLE_MAX_LENGTH);+ expect(title.endsWith("…")).toBe(true);+ });+});diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/types.ts b/skyvern-frontend/src/routes/workflows/editor/nodes/types.tsindex 531088c90..f3b599495 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/types.ts+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/types.ts@@ -2,6 +2,7 @@ import {WorkflowBlockType,type WorkflowModel,} from "../../types/workflowTypes";+import type { CodeBlockTitleSource } from "../../types/scriptTypes";export type NodeBaseData = {debuggable: boolean;@@ -44,11 +45,34 @@ export const dataSchemaExampleForFileExtraction = {},};+export const CODE_BLOCK_FALLBACK_TITLE = "Code";+export const CODE_BLOCK_TITLE_MAX_LENGTH = 80;++function normalizeTitle(value: string | null | undefined): string | null {+ const normalized = value?.replace(/\s+/g, " ").trim();+ return normalized ? normalized : null;+}++function truncateTitle(value: string): string {+ if (value.length <= CODE_BLOCK_TITLE_MAX_LENGTH) {+ return value;+ }+ return `${value.slice(0, CODE_BLOCK_TITLE_MAX_LENGTH - 1).trimEnd()}…`;+}++export function getCodeBlockTitle(source: CodeBlockTitleSource): string {+ return truncateTitle(+ normalizeTitle(source.prompt) ??+ normalizeTitle(source.steps?.[0]?.title) ??+ CODE_BLOCK_FALLBACK_TITLE,+ );+}+export const workflowBlockTitle: {[blockType in WorkflowBlockType]: string;} = {action: "Browser Action",- code: "Code",+ code: CODE_BLOCK_FALLBACK_TITLE,conditional: "Conditional",download_to_s3: "Download",extraction: "Extraction",diff --git a/skyvern-frontend/src/routes/workflows/types/scriptTypes.ts b/skyvern-frontend/src/routes/workflows/types/scriptTypes.tsindex a22cab526..0b99630a4 100644--- a/skyvern-frontend/src/routes/workflows/types/scriptTypes.ts+++ b/skyvern-frontend/src/routes/workflows/types/scriptTypes.ts@@ -1,3 +1,10 @@+import type { CodeBlockStep } from "./workflowTypes";++export type CodeBlockTitleSource = {+ prompt?: string | null;+ steps?: Array<Pick<CodeBlockStep, "title">> | null;+};+export type ScriptBlocksResponse = {blocks: { [blockName: string]: string };main_script: string | null;diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.test.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.test.tsnew file mode 100644index 000000000..8a53a320e--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.test.ts@@ -0,0 +1,34 @@+import { describe, expect, it } from "vitest";++import { Status } from "@/api/types";+import {+ getBlockOutputDisplayValue,+ getExtractedInformationDisplayValue,+ shouldShowExtractedInformation,+} from "./workflowRunTypes";++describe("workflow run output display helpers", () => {+ it("only labels task-variant output as extracted information when the wrapper field is present", () => {+ const block = {+ block_type: "task_v2",+ status: Status.Completed,+ output: { result: "plain task output" },+ } as const;++ expect(shouldShowExtractedInformation(block)).toBe(false);+ expect(getBlockOutputDisplayValue(block)).toEqual({+ result: "plain task output",+ });+ });++ it("preserves empty extracted information payloads as extracted information", () => {+ const block = {+ block_type: "code",+ status: Status.Completed,+ output: { extracted_information: null },+ } as const;++ expect(shouldShowExtractedInformation(block)).toBe(true);+ expect(getExtractedInformationDisplayValue(block)).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.tsindex 93d0ce945..a51d0aaf7 100644--- a/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts+++ b/skyvern-frontend/src/routes/workflows/types/workflowRunTypes.ts@@ -1,5 +1,10 @@import { ActionsApiResponse, RunEngine, Status } from "@/api/types";-import { WorkflowBlock, WorkflowBlockType } from "./workflowTypes";+import {+ isTaskVariantBlock,+ WorkflowBlock,+ WorkflowBlockType,+ WorkflowBlockTypes,+} from "./workflowTypes";import { ActionItem } from "../workflowRun/WorkflowRunOverview";export const WorkflowRunTimelineItemTypes = {@@ -227,6 +232,47 @@ export function hasNavigationGoal(return item !== null && typeof item === "object" && "navigation_goal" in item;}+type BlockExtractionDisplayFields = {+ block_type: WorkflowBlockType;+ status: Status | null;+ output: unknown;+};++export function shouldShowExtractedInformation(+ block: BlockExtractionDisplayFields,+): boolean {+ if (block.status !== Status.Completed) {+ return false;+ }+ if (!hasExtractedInformation(block.output)) {+ return false;+ }+ return (+ isTaskVariantBlock(block) || block.block_type === WorkflowBlockTypes.Code+ );+}++export function getExtractedInformationDisplayValue(+ block: BlockExtractionDisplayFields,+): unknown {+ if (!hasExtractedInformation(block.output)) {+ return null;+ }+ return block.output.extracted_information ?? null;+}++export function getBlockOutputDisplayValue(+ block: BlockExtractionDisplayFields,+): unknown {+ if (+ shouldShowExtractedInformation(block) &&+ hasExtractedInformation(block.output)+ ) {+ return block.output.extracted_information;+ }+ return block.output;+}+// Branch evaluation types for conditional blocksexport type BranchEvaluation = {branch_id: string;diff --git a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.tsindex 8f5860a8c..8e92fb716 100644--- a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts+++ b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.test.ts@@ -1,6 +1,10 @@import { describe, expect, it } from "vitest";-import { buildCodeStepsByLabel } from "./workflowBlockUtils";+import {+ buildCodeStepsByLabel,+ findCodeStepForLine,+ getCodeStepPlainText,+} from "./workflowBlockUtils";import type {CodeBlock,CodeBlockStep,@@ -68,3 +72,75 @@ describe("buildCodeStepsByLabel", () => {expect(map.size).toBe(0);});});++describe("getCodeStepPlainText", () => {+ it("prefers the step title", () => {+ expect(+ getCodeStepPlainText({+ action_type: "extract",+ title: "Extract the product details",+ description: "page.extract",+ }),+ ).toBe("Extract the product details");+ });++ it("falls back to the description when there is no title", () => {+ expect(+ getCodeStepPlainText({+ action_type: "click",+ description: "Click submit",+ }),+ ).toBe("Click submit");+ });++ it("humanizes the action type when title and description are absent", () => {+ expect(getCodeStepPlainText({ action_type: "extract" })).toBe(+ "Extract Data",+ );+ expect(getCodeStepPlainText({ action_type: "go_forward" })).toBe(+ "Go Forward",+ );+ });++ it("ignores blank title and description", () => {+ expect(+ getCodeStepPlainText({+ action_type: "extract",+ title: " ",+ description: "",+ }),+ ).toBe("Extract Data");+ });+});++describe("findCodeStepForLine", () => {+ const steps: Array<CodeBlockStep> = [+ { action_type: "goto", title: "Open page", line_start: 1, line_end: 1 },+ { action_type: "click", title: "Submit", line_start: 3, line_end: 6 },+ { action_type: "extract", title: "No line position" },+ ];++ it("returns null when the action carries no code line", () => {+ expect(findCodeStepForLine(steps, null)).toBeNull();+ });++ it("matches a step by exact line_start", () => {+ expect(findCodeStepForLine(steps, 1)?.title).toBe("Open page");+ });++ it("matches a step by range containment when no exact line_start matches", () => {+ expect(findCodeStepForLine(steps, 4)?.title).toBe("Submit");+ });++ it("prefers an exact line_start over a containing range", () => {+ const overlapping: Array<CodeBlockStep> = [+ { action_type: "click", title: "Range", line_start: 1, line_end: 5 },+ { action_type: "extract", title: "Exact", line_start: 3, line_end: 3 },+ ];+ expect(findCodeStepForLine(overlapping, 3)?.title).toBe("Exact");+ });++ it("returns null when no step covers the line", () => {+ expect(findCodeStepForLine(steps, 99)).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.tsindex 37062c5da..aa9599ef8 100644--- a/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts+++ b/skyvern-frontend/src/routes/workflows/workflowBlockUtils.ts@@ -1,3 +1,5 @@+import { getReadableActionType } from "@/api/types";+import {isNestedLoopWorkflowBlock,type CodeBlockStep,@@ -56,3 +58,47 @@ export function buildCodeStepsByLabel(visit(blocks);return stepsByLabel;}++/**+ * Plain-English text for a code-block step: prefer the generated title, then+ * the description, and only humanize the raw action type when neither is+ * present.+ */+export function getCodeStepPlainText(step: CodeBlockStep): string {+ const title = step.title?.trim();+ if (title) {+ return title;+ }+ const description = step.description?.trim();+ if (description) {+ return description;+ }+ return getReadableActionType(step.action_type);+}++/**+ * Resolve the definition step a recorded action belongs to by its source line.+ * A fired action carries its `code_line`; match it to the step whose+ * `line_start` equals that line, falling back to the step whose+ * `[line_start, line_end]` range contains it.+ */+export function findCodeStepForLine(+ steps: Array<CodeBlockStep>,+ codeLine: number | null,+): CodeBlockStep | null {+ if (codeLine == null) {+ return null;+ }+ const exact = steps.find((step) => step.line_start === codeLine);+ if (exact) {+ return exact;+ }+ return (+ steps.find(+ (step) =>+ step.line_start != null &&+ codeLine >= step.line_start &&+ codeLine <= (step.line_end ?? step.line_start),+ ) ?? null+ );+}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.test.tsxindex 961af57b0..4c0bd2bf8 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.test.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.test.tsx@@ -102,6 +102,65 @@ describe("WorkflowRunBlockDetail router", () => {).toBeGreaterThanOrEqual(1);});+ it("renders code block extracted information without the raw output wrapper", () => {+ const block = buildBlock({+ block_type: "code",+ label: "collect_data",+ output: {+ extracted_information: {+ account_status: "active",+ reference_id: "ref_123",+ },+ raw_code_output: "debug payload",+ },+ });++ render(<WorkflowRunBlockDetail activeItem={block} timeline={[]} />);++ expect(+ screen.getByRole("tab", { name: "Extracted Information" }),+ ).toBeDefined();+ expect(screen.getByText("account_status")).toBeDefined();+ expect(screen.getByText('"active"')).toBeDefined();+ expect(screen.queryByText("raw_code_output")).toBeNull();+ expect(screen.queryByText('"debug payload"')).toBeNull();+ });++ it("renders a string code block extraction without dropping it", () => {+ const block = buildBlock({+ block_type: "code",+ label: "collect_summary",+ output: {+ extracted_information: "Order #1024 shipped on Tuesday",+ },+ });++ render(<WorkflowRunBlockDetail activeItem={block} timeline={[]} />);++ expect(+ screen.getByRole("tab", { name: "Extracted Information" }),+ ).toBeDefined();+ expect(screen.getByText('"Order #1024 shipped on Tuesday"')).toBeDefined();+ });++ it("keeps a null code block extraction visible in the detail panel", () => {+ const block = buildBlock({+ block_type: "code",+ label: "collect_empty",+ output: {+ extracted_information: null,+ },+ });++ render(<WorkflowRunBlockDetail activeItem={block} timeline={[]} />);++ const tab = screen.getByRole("tab", { name: "Extracted Information" });+ expect(tab.hasAttribute("disabled")).toBe(false);+ expect(tab.getAttribute("data-state")).toBe("active");+ expect(screen.getByText("null")).toBeDefined();+ expect(screen.queryByText("No block output.")).toBeNull();+ });+it("renders block inputs and searchable outputs inside the detail panel inspector", () => {const block = buildBlock({block_type: "http_request",diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.test.tsxnew file mode 100644index 000000000..b0d83b5ea--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.test.tsx@@ -0,0 +1,176 @@+// @vitest-environment jsdom++vi.mock("@/api/AxiosClient", () => ({ getClient: vi.fn() }));+vi.mock("@/hooks/useCredentialGetter", () => ({+ useCredentialGetter: () => null,+}));++import { cleanup, render, screen } from "@testing-library/react";+import { type ReactNode } from "react";+import { MemoryRouter } from "react-router-dom";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";++import { Status } from "@/api/types";+import type {+ WorkflowRunBlock,+ WorkflowRunTimelineBlockItem,+} from "../types/workflowRunTypes";+import { WorkflowRunOutput } from "./WorkflowRunOutput";++const mocks = vi.hoisted(() => ({+ activeItem: null as unknown,+ workflowRun: null as unknown,+ timeline: [] as unknown,+}));++vi.mock("../hooks/useWorkflowRunWithWorkflowQuery", () => ({+ useWorkflowRunWithWorkflowQuery: () => ({+ data: mocks.workflowRun,+ isLoading: false,+ }),+}));++vi.mock("../hooks/useWorkflowRunTimelineQuery", () => ({+ useWorkflowRunTimelineQuery: () => ({+ data: mocks.timeline,+ isLoading: false,+ }),+}));++vi.mock("./useActiveWorkflowRunItem", () => ({+ useActiveWorkflowRunItem: () => [mocks.activeItem, vi.fn()],+}));++vi.mock("../components/CodeEditor", () => ({+ CodeEditor: ({ value }: { value: string }) => (+ <pre data-testid="code-editor">{value}</pre>+ ),+}));++vi.mock("@/components/SummarizeOutput", () => ({+ SummarizeOutput: () => null,+}));++vi.mock("@/components/ui/scroll-area", () => ({+ ScrollArea: ({ children }: { children?: ReactNode }) => <div>{children}</div>,+ ScrollAreaViewport: ({ children }: { children?: ReactNode }) => (+ <div>{children}</div>+ ),+}));++function buildBlock(+ overrides: Partial<WorkflowRunBlock> = {},+): WorkflowRunBlock {+ return {+ workflow_run_block_id: "wrb_default",+ workflow_run_id: "wr_default",+ parent_workflow_run_block_id: null,+ block_type: "http_request",+ label: null,+ description: null,+ title: null,+ status: Status.Completed,+ failure_reason: null,+ output: null,+ continue_on_failure: false,+ task_id: null,+ url: null,+ navigation_goal: null,+ navigation_payload: null,+ data_extraction_goal: null,+ data_schema: null,+ terminate_criterion: null,+ complete_criterion: null,+ include_action_history_in_verification: null,+ engine: null,+ actions: null,+ created_at: "2026-01-01T00:00:00Z",+ modified_at: "2026-01-01T00:00:00Z",+ duration: null,+ loop_values: null,+ current_value: null,+ current_index: null,+ ...overrides,+ };+}++function buildBlockItem(block: WorkflowRunBlock): WorkflowRunTimelineBlockItem {+ return {+ type: "block",+ block,+ children: [],+ thought: null,+ created_at: block.created_at,+ modified_at: block.modified_at,+ };+}++function renderWorkflowRunOutput(activeBlock: WorkflowRunBlock) {+ mocks.activeItem = activeBlock;+ mocks.timeline = [buildBlockItem(activeBlock)];+ mocks.workflowRun = {+ workflow_run_id: activeBlock.workflow_run_id,+ workflow_title: "Demo workflow",+ outputs: {},+ downloaded_file_urls: [],+ downloaded_files: [],+ };++ return render(+ <MemoryRouter initialEntries={["/runs/demo?active=wrb_code"]}>+ <WorkflowRunOutput />+ </MemoryRouter>,+ );+}++beforeEach(() => {+ mocks.activeItem = null;+ mocks.workflowRun = null;+ mocks.timeline = [];+});++afterEach(() => {+ cleanup();+});++describe("WorkflowRunOutput", () => {+ it("renders code block extracted information without the raw output wrapper", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code",+ block_type: "code",+ output: {+ extracted_information: {+ order_id: "ord_123",+ status: "shipped",+ },+ raw_code_output: "debug payload",+ },+ });++ renderWorkflowRunOutput(block);++ expect(screen.getByText("Extracted Information")).toBeDefined();+ expect(screen.getByText("order_id")).toBeDefined();+ expect(screen.getByText('"ord_123"')).toBeDefined();+ expect(screen.queryByText("raw_code_output")).toBeNull();+ expect(screen.queryByText('"debug payload"')).toBeNull();+ });++ it("keeps null code block extracted information in the extraction section", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_null_extraction",+ block_type: "code",+ output: {+ extracted_information: null,+ raw_code_output: "debug payload",+ },+ });++ renderWorkflowRunOutput(block);++ expect(screen.getByText("Extracted Information")).toBeDefined();+ expect(screen.getByText("null")).toBeDefined();+ expect(screen.queryByText("raw_code_output")).toBeNull();+ expect(screen.queryByText('"debug payload"')).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsxindex aaecc086a..7f5259cc9 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunOutput.tsx@@ -6,16 +6,18 @@ import { CodeEditor } from "../components/CodeEditor";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";import { useActiveWorkflowRunItem } from "./useActiveWorkflowRunItem";import {- hasExtractedInformation,+ getBlockOutputDisplayValue,+ getExtractedInformationDisplayValue,isAction,isWorkflowRunBlock,+ shouldShowExtractedInformation,} from "../types/workflowRunTypes";+import { JsonExplorer } from "./blockDetail/BlockInspector";import { findBlockSurroundingAction } from "./workflowTimelineUtils";import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery";import { Status } from "@/api/types";import { AutoResizingTextarea } from "@/components/AutoResizingTextarea/AutoResizingTextarea";import { SummarizeOutput } from "@/components/SummarizeOutput";-import { isTaskVariantBlock } from "../types/workflowTypes";import { statusIsAFailureType } from "@/routes/tasks/types";import {pickDownloadedFileFilename,@@ -116,23 +118,16 @@ function WorkflowRunOutput() {[outputs],);- const activeBlockOutput = activeBlock?.output;- const activeBlockStatus = activeBlock?.status;- const activeBlockType = activeBlock?.block_type;const blockOutputJsonCompact = useMemo(() => {- if (activeBlockOutput === undefined || activeBlockOutput === null) {+ if (+ !activeBlock ||+ activeBlock.output === undefined ||+ activeBlock.output === null+ ) {return "";}- const isCompletedTaskBlock =- activeBlockType !== undefined &&- isTaskVariantBlock({ block_type: activeBlockType }) &&- activeBlockStatus === Status.Completed;- const value =- isCompletedTaskBlock && hasExtractedInformation(activeBlockOutput)- ? activeBlockOutput.extracted_information- : activeBlockOutput;- return JSON.stringify(value);- }, [activeBlockOutput, activeBlockStatus, activeBlockType]);+ return JSON.stringify(getBlockOutputDisplayValue(activeBlock));+ }, [activeBlock]);if (workflowRunTimelineIsLoading) {return <div>Loading...</div>;@@ -143,9 +138,16 @@ function WorkflowRunOutput() {}const showExtractedInformation =- activeBlock &&- isTaskVariantBlock(activeBlock) &&- activeBlock.status === Status.Completed;+ activeBlock && shouldShowExtractedInformation(activeBlock);+ const extractedInformationValue = activeBlock+ ? getExtractedInformationDisplayValue(activeBlock)+ : null;+ // Only flat/nested objects benefit from the structured tree; scalars, arrays,+ // and null read better as formatted JSON, so keep the CodeEditor for those.+ const extractedInformationIsRecord =+ typeof extractedInformationValue === "object" &&+ extractedInformationValue !== null &&+ !Array.isArray(extractedInformationValue);const showFailureReason =activeBlock &&@@ -252,19 +254,20 @@ function WorkflowRunOutput() {) : showExtractedInformation ? (<div className="space-y-2"><h2>Extracted Information</h2>- <CodeEditor- language="json"- value={JSON.stringify(- (hasExtractedInformation(activeBlock.output) &&- activeBlock.output.extracted_information) ??- null,- null,- 2,- )}- minHeight="96px"- maxHeight="200px"- readOnly- />+ {extractedInformationIsRecord ? (+ <JsonExplorer+ value={extractedInformationValue}+ rootLabel="extracted_information"+ />+ ) : (+ <CodeEditor+ language="json"+ value={JSON.stringify(extractedInformationValue, null, 2)}+ minHeight="96px"+ maxHeight="200px"+ readOnly+ />+ )}</div>) : activeBlock.output !== null ? (<div className="space-y-2">diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsxindex 1f9c0c5ef..58d8bea3c 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.test.tsx@@ -507,6 +507,43 @@ describe("WorkflowRunTimelineBlockItem", () => {expect(screen.getByText(/ValueError: boom · line 7/)).toBeDefined();});+ it("labels non-failed synthetic code rows as steps instead of screenshots", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_synthetic",+ block_type: "code",+ label: "run_script",+ actions: [+ {+ action_id: "wrb_code_synthetic_action_0",+ action_type: ActionTypes.NullAction,+ status: Status.Completed,+ reasoning: null,+ description: "recorded code step",+ output: { code_line: 4, duration_ms: 250 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.getByText("Step")).toBeDefined();+ expect(screen.queryByText("Screenshot")).toBeNull();+ expect(screen.queryByText("Error")).toBeNull();+ expect(+ screen.getByText(/recorded code step · line 4 · 0.3s/),+ ).toBeDefined();+ });+it("renders non-code action rows without code line metadata", () => {const block = buildBlock({workflow_run_block_id: "wrb_task_null_action",@@ -601,6 +638,7 @@ describe("WorkflowRunTimelineBlockItem", () => {workflow_run_block_id: "wrb_code_outline",block_type: "code",label: "run_script",+ prompt: "Run homepage flow",actions: [],});const steps: Array<CodeBlockStep> = [@@ -631,18 +669,148 @@ describe("WorkflowRunTimelineBlockItem", () => {expect(screen.getByText(/Open the homepage/)).toBeDefined();expect(screen.getByText(/Click the top post/)).toBeDefined();- expect(screen.getByText("goto")).toBeDefined();- expect(screen.getByText("click")).toBeDefined();+ expect(screen.getByText("Goto")).toBeDefined();+ expect(screen.getByText("Click")).toBeDefined();expect(screen.getByText("L1")).toBeDefined();expect(screen.getByText("L3-5")).toBeDefined();});+ it("uses the code block prompt as the row name", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_prompt_title",+ block_type: "code",+ label: "run_script",+ prompt: "Collect invoice details",+ actions: [],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "execute_js", title: "Run a script" },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.getByText("Collect invoice details")).toBeDefined();+ });++ it("falls back to the first code step title for the row name", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_step_title",+ block_type: "code",+ label: "run_script",+ prompt: null,+ actions: [],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "execute_js", title: "Summarize the page" },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.getByText("Summarize the page")).toBeDefined();+ });++ it("falls back to the block reasoning before bare 'Code' for prompt-less code blocks", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_reasoning",+ block_type: "code",+ label: "block_1",+ prompt: null,+ description: "Planning to extract current top post details.",+ actions: [],+ });++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ // The reasoning is surfaced as the row name (it would otherwise be lost to+ // the bare "Code" fallback); the label remains the descriptor subtitle.+ expect(+ screen.getByText("Planning to extract current top post details."),+ ).toBeDefined();+ });++ it("prefers the code block prompt over the reasoning for the row name", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_prompt_over_reasoning",+ block_type: "code",+ label: "block_1",+ prompt: "Run the homepage flow",+ description: "Planning to extract current top post details.",+ actions: [],+ });++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.getByText("Run the homepage flow")).toBeDefined();+ expect(+ screen.queryByText("Planning to extract current top post details."),+ ).toBeNull();+ });++ it("shows the bare 'Code' name for a prompt-less code block with no reasoning", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_bare",+ block_type: "code",+ label: "block_2",+ prompt: null,+ description: null,+ actions: [],+ });++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ // Both the type badge and the row name read "Code" when nothing else exists.+ expect(screen.getAllByText("Code").length).toBe(2);+ });+it("selects the block when a code step row is clicked", () => {const onBlockItemClick = vi.fn();const block = buildBlock({workflow_run_block_id: "wrb_code_outline_click",block_type: "code",label: "run_script",+ prompt: "Run homepage flow",actions: [],});const steps: Array<CodeBlockStep> = [@@ -664,11 +832,241 @@ describe("WorkflowRunTimelineBlockItem", () => {expect(onBlockItemClick).toHaveBeenCalledWith(block);});+ it("marks definition steps after the failure line as 'didn't run' in a failed code block", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_partial_fail",+ block_type: "code",+ label: "run_script",+ prompt: "Run the saved script",+ status: Status.Failed,+ actions: [+ // DESC payload: the synthetic error row is newest.+ {+ action_id: "wrb_code_err",+ action_type: ActionTypes.NullAction,+ status: Status.Failed,+ reasoning: null,+ description: "code error at line 3",+ response: "ValueError: boom",+ output: { code_line: 3 },+ created_by: null,+ confidence_float: null,+ },+ {+ action_id: "wrb_code_goto",+ action_type: ActionTypes.GotoUrl,+ status: Status.Completed,+ reasoning: null,+ description: "page.goto https://example.com",+ output: { code_line: 1, duration_ms: 500 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "goto", title: "Open the homepage", line_start: 1 },+ { action_type: "click", title: "Submit the form", line_start: 3 },+ { action_type: "extract", title: "Read the result", line_start: 5 },+ {+ action_type: "execute_js",+ title: "Summarize the page",+ line_start: 7,+ line_end: 8,+ },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ // Only the steps strictly after the failure line (3) are "didn't run".+ const didntRun = screen.getAllByText(/didn't run/i);+ expect(didntRun.length).toBe(2);+ expect(screen.getByText(/Read the result/)).toBeDefined();+ expect(screen.getByText(/Summarize the page/)).toBeDefined();+ // The executed goto step (line 1) reads its plain-English step copy in its+ // fired action row, not as a didn't-run row.+ expect(screen.getByText(/Open the homepage · line 1/)).toBeDefined();+ // The step at the failure line (3) executed no fired action and is not after+ // the failure, so it surfaces nowhere.+ expect(screen.queryByText(/Submit the form/)).toBeNull();+ // Neutral slate tone — never the rose error tone.+ expect(didntRun[0]!.className).toMatch(/text-slate-400/);+ expect(didntRun[0]!.className).not.toMatch(/rose/);+ });++ it("renders no 'didn't run' rows when the code block fails at or after its last step", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_fail_last",+ block_type: "code",+ label: "run_script",+ status: Status.Failed,+ actions: [+ {+ action_id: "wrb_code_err_last",+ action_type: ActionTypes.NullAction,+ status: Status.Failed,+ reasoning: null,+ description: "code error at line 9",+ response: "Boom",+ output: { code_line: 9 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "goto", title: "Open the homepage", line_start: 1 },+ { action_type: "click", title: "Submit the form", line_start: 3 },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.queryByText(/didn't run/i)).toBeNull();+ });++ it("skips definition steps without a line position when marking 'didn't run'", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_null_line",+ block_type: "code",+ label: "run_script",+ prompt: "Run the saved script",+ status: Status.Failed,+ actions: [+ {+ action_id: "wrb_code_err_null",+ action_type: ActionTypes.NullAction,+ status: Status.Failed,+ reasoning: null,+ description: "code error at line 2",+ response: "Boom",+ output: { code_line: 2 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "extract", title: "Has a line position", line_start: 5 },+ { action_type: "execute_js", title: "No line position" },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.getAllByText(/didn't run/i).length).toBe(1);+ expect(screen.getByText(/Has a line position/)).toBeDefined();+ expect(screen.queryByText(/No line position/)).toBeNull();+ });++ it("does not mark steps as 'didn't run' for a successful code block", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_success",+ block_type: "code",+ label: "run_script",+ status: Status.Completed,+ actions: [+ {+ action_id: "wrb_code_ok",+ action_type: ActionTypes.GotoUrl,+ status: Status.Completed,+ reasoning: null,+ description: "page.goto https://example.com",+ output: { code_line: 1, duration_ms: 500 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "extract", title: "A later step", line_start: 5 },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.queryByText(/didn't run/i)).toBeNull();+ });++ it("does not infer skipped steps when a failed code block has no synthetic error row", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_failed_without_error_row",+ block_type: "code",+ label: "run_script",+ prompt: "Run cached code",+ status: Status.Failed,+ actions: [+ {+ action_id: "wrb_code_goto_only",+ action_type: ActionTypes.GotoUrl,+ status: Status.Completed,+ reasoning: null,+ description: "page.goto https://example.com",+ output: { code_line: 1, duration_ms: 500 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ { action_type: "goto", title: "Open the homepage", line_start: 1 },+ { action_type: "extract", title: "Read the result", line_start: 5 },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.queryByText(/didn't run/i)).toBeNull();+ expect(screen.queryByText(/Read the result/)).toBeNull();+ });+it("prefers recorded actions over the step outline for code blocks", () => {const block = buildBlock({workflow_run_block_id: "wrb_code_actions_win",block_type: "code",label: "run_script",+ prompt: "Run cached code",actions: [{action_id: "wrb_code_action_0",@@ -702,4 +1100,137 @@ describe("WorkflowRunTimelineBlockItem", () => {).toBeDefined();expect(screen.queryByText("Outline step that should be hidden")).toBeNull();});++ it("leads a fired code action row with the matched definition step's plain English", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_plain_english",+ block_type: "code",+ label: "run_script",+ prompt: "Run cached code",+ actions: [+ {+ action_id: "wrb_code_extract",+ action_type: ActionTypes.extract,+ status: Status.Completed,+ reasoning: null,+ description: "page.extract",+ output: { code_line: 12, duration_ms: 500 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ {+ action_type: "extract",+ title: "Extract the product details",+ line_start: 12,+ line_end: 12,+ },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ // The same plain-English copy as the editor, not the raw page.extract call.+ expect(+ screen.getByText(/Extract the product details · line 12/),+ ).toBeDefined();+ expect(screen.queryByText(/page\.extract/)).toBeNull();+ // The readable action type stays as the chip.+ expect(screen.getByText("Extract Data")).toBeDefined();+ });++ it("matches a fired code action to a multi-line step by range containment", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_range",+ block_type: "code",+ label: "run_script",+ prompt: "Run cached code",+ actions: [+ {+ action_id: "wrb_code_range_action",+ action_type: ActionTypes.Click,+ status: Status.Completed,+ reasoning: null,+ description: "page.click",+ output: { code_line: 4, duration_ms: 200 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ {+ action_type: "click",+ title: "Submit the application",+ line_start: 3,+ line_end: 6,+ },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ expect(screen.getByText(/Submit the application · line 4/)).toBeDefined();+ });++ it("falls back to the readable action type when no definition step matches a fired code action", () => {+ const block = buildBlock({+ workflow_run_block_id: "wrb_code_no_match",+ block_type: "code",+ label: "run_script",+ prompt: "Run cached code",+ actions: [+ {+ action_id: "wrb_code_no_match_action",+ action_type: ActionTypes.extract,+ status: Status.Completed,+ reasoning: null,+ description: null,+ output: { code_line: 99 },+ created_by: null,+ confidence_float: null,+ },+ ] as unknown as WorkflowRunBlock["actions"],+ });+ const steps: Array<CodeBlockStep> = [+ {+ action_type: "extract",+ title: "A step on another line",+ line_start: 1,+ },+ ];++ render(+ <WorkflowRunTimelineBlockItem+ activeItem={block}+ block={block}+ subItems={[]}+ codeStepsByLabel={new Map([["run_script", steps]])}+ onActionClick={noop}+ onBlockItemClick={noop}+ />,+ );++ // No matching step and no reasoning — the readable action type carries the row.+ expect(screen.getByText("Extract Data")).toBeDefined();+ expect(screen.queryByText(/A step on another line/)).toBeNull();+ });});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsxindex 47ca7b526..7508626c0 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunTimelineBlockItem.tsx@@ -5,7 +5,7 @@ import {CrossCircledIcon,ReloadIcon,} from "@radix-ui/react-icons";-import { useEffect, useMemo, useRef, useState } from "react";+import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";import {type ActionsApiResponse,@@ -16,7 +16,11 @@ import {import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible";import { formatDuration, toDuration } from "@/routes/workflows/utils";import { cn } from "@/util/utils";-import { workflowBlockTitle } from "../editor/nodes/types";+import {+ CODE_BLOCK_FALLBACK_TITLE,+ getCodeBlockTitle,+ workflowBlockTitle,+} from "../editor/nodes/types";import { WorkflowBlockIcon } from "../editor/nodes/WorkflowBlockIcon";import { actionTypeIcons as timelineActionIcons } from "../components/actionTypeIcons";import { getActionDisplayStatus } from "../components/actionStatus";@@ -32,6 +36,7 @@ import {WorkflowRunTimelineItem,} from "../types/workflowRunTypes";import { type CodeBlockStep, WorkflowBlockTypes } from "../types/workflowTypes";+import { findCodeStepForLine } from "../workflowBlockUtils";import {ActionItem,WorkflowRunOverviewActiveElement,@@ -163,29 +168,54 @@ function formatActionDurationMs(durationMs: number): string {}type ActionRowPresentation = {+ icon: ReactNode;label: string;summary: string | null;+ tone: "default" | "error";};-// Design C rows for code blocks: recorded actions summarize as-// "<description> · line N · <duration>s"; the synthetic failure row-// (failed null_action) is labeled Error instead of Screenshot.+// Rows for code blocks summarize recorded actions as+// "<plain-English step> · line N · <duration>s"; the synthetic failure row+// (failed null_action) is labeled Error instead of Screenshot. The leading+// text reuses the matched definition step's plain-English copy so a fired+// action reads the same as the editor, falling back to the action's own+// reasoning and finally to the readable action type chip.function getCodeActionRowPresentation(action: ActionsApiResponse,+ matchedStep: CodeBlockStep | null,): ActionRowPresentation {const isCodeError =action.status === Status.Failed &&action.action_type === ActionTypes.NullAction;const label = isCodeError? "Error"- : getReadableActionType(action.action_type);+ : getReadableActionType(action.action_type, { nullActionLabel: "Step" });+ const icon = isCodeError ? (+ <CrossCircledIcon className="size-3.5" />+ ) : action.action_type === ActionTypes.NullAction ? (+ <WorkflowBlockIcon workflowBlockType="code" className="size-3.5" />+ ) : (+ timelineActionIcons[action.action_type]+ );const { codeLine, durationMs } = getRecordedActionMeta(action);+ const stepText =+ !isCodeError && matchedStep+ ? (normalizeInlineText(matchedStep.title) ??+ normalizeInlineText(matchedStep.description))+ : null;const parts = [- getActionSummary(action) ?? normalizeInlineText(action.description),+ stepText ??+ getActionSummary(action) ??+ normalizeInlineText(action.description),codeLine !== null ? `line ${codeLine}` : null,durationMs !== null ? formatActionDurationMs(durationMs) : null,].filter((part): part is string => part !== null);- return { label, summary: parts.length > 0 ? parts.join(" · ") : null };+ return {+ icon,+ label,+ summary: parts.length > 0 ? parts.join(" · ") : null,+ tone: isCodeError ? "error" : "default",+ };}function countSchemaFields(value: WorkflowRunBlock["data_schema"]): number {@@ -258,6 +288,23 @@ function getTimelineTypeLabel(block: WorkflowRunBlock): string {}}+// getCodeBlockTitle ends at the bare "Code" label for prompt-less runs, which+// dropped the reasoning subtitle the timeline used to show. Fall back to the+// block reasoning (description) before bare "Code", normalized like a prompt.+function getCodeBlockTimelineName(+ block: WorkflowRunBlock,+ steps: Array<CodeBlockStep>,+): string {+ const title = getCodeBlockTitle({ prompt: block.prompt, steps });+ if (title !== CODE_BLOCK_FALLBACK_TITLE) {+ return title;+ }+ const reasoning = normalizeInlineText(block.description);+ return reasoning+ ? getCodeBlockTitle({ prompt: reasoning, steps: [] })+ : title;+}+function getLoopIterationGroups(items: Array<WorkflowRunTimelineItem>,): Array<LoopIterationGroup> {@@ -439,6 +486,7 @@ type TimelineActionRowsProps = {block: WorkflowRunBlock;activeItem: WorkflowRunOverviewActiveElement;depth: number;+ codeSteps: Array<CodeBlockStep>;onActionClick: (action: ActionItem) => void;workflowRunIsFinalized?: boolean;};@@ -447,6 +495,7 @@ function TimelineActionRows({block,activeItem,depth,+ codeSteps,onActionClick,workflowRunIsFinalized,}: TimelineActionRowsProps) {@@ -462,12 +511,19 @@ function TimelineActionRows({const isActive =isAction(activeItem) && activeItem.action_id === action.action_id;const displayIndex = index + 1;- const icon = timelineActionIcons[action.action_type];- const { label, summary } = isCodeBlock- ? getCodeActionRowPresentation(action)+ const { icon, label, summary, tone } = isCodeBlock+ ? getCodeActionRowPresentation(+ action,+ findCodeStepForLine(+ codeSteps,+ getRecordedActionMeta(action).codeLine,+ ),+ ): {+ icon: timelineActionIcons[action.action_type],label: getReadableActionType(action.action_type),summary: getActionSummary(action),+ tone: "default" as const,};return (@@ -504,7 +560,14 @@ function TimelineActionRows({<span className="w-7 shrink-0 text-[10px] tabular-nums text-slate-500">#{displayIndex}</span>- <span className="shrink-0 rounded border border-slate-700 px-1.5 py-0.5 text-[10px] font-medium text-slate-400">+ <span+ className={cn(+ "shrink-0 rounded border px-1.5 py-0.5 text-[10px] font-medium",+ tone === "error"+ ? "border-rose-500/30 bg-rose-500/10 text-rose-300"+ : "border-slate-700 text-slate-400",+ )}+ >{label}</span>{summary && (@@ -531,6 +594,40 @@ function formatCodeStepLines(step: CodeBlockStep): string | null {return `L${step.line_start}-${step.line_end}`;}+// The line where a code block stopped: use the synthetic error row's code line+// (failed null_action) when present, and avoid inferring skipped definition+// steps without that explicit failure marker.+function getCodeBlockFailureLine(+ actions: Array<ActionsApiResponse>,+): number | null {+ let errorLine: number | null = null;+ for (const action of actions) {+ const { codeLine } = getRecordedActionMeta(action);+ if (codeLine === null) continue;+ if (+ action.action_type === ActionTypes.NullAction &&+ action.status === Status.Failed+ ) {+ errorLine = errorLine === null ? codeLine : Math.max(errorLine, codeLine);+ }+ }+ return errorLine;+}++// Definition steps whose code position is strictly after the failure line never+// executed. Steps without a line position, or whose range starts at/before the+// failure, are excluded — they either ran or were in progress when it stopped.+function getUnfiredCodeSteps(+ steps: Array<CodeBlockStep>,+ actions: Array<ActionsApiResponse>,+): Array<CodeBlockStep> {+ const failureLine = getCodeBlockFailureLine(actions);+ if (failureLine === null) return [];+ return steps.filter(+ (step) => step.line_start != null && step.line_start > failureLine,+ );+}+type TimelineCodeStepRowsProps = {block: WorkflowRunBlock;steps: Array<CodeBlockStep>;@@ -579,7 +676,7 @@ function TimelineCodeStepRows({#{index + 1}</span><span className="shrink-0 rounded border border-slate-700 px-1.5 py-0.5 text-[10px] font-medium text-slate-400">- {step.action_type}+ {getReadableActionType(step.action_type)}</span>{summary && (<span className="min-w-0 flex-1 truncate text-slate-500">@@ -600,6 +697,87 @@ function TimelineCodeStepRows({);}+type TimelineSkippedStepRowsProps = {+ block: WorkflowRunBlock;+ steps: Array<CodeBlockStep>;+ depth: number;+ onBlockItemClick: (block: WorkflowRunBlock) => void;+};++// Negative-space sibling of TimelineActionRows: when a code block fails partway,+// its definition steps after the failure point never ran. Mirror the block-level+// "didn't run" treatment (WorkflowRunTimelineUnexecutedBlockItem) one level down+// — dimmed, hollow dashed marker, neutral slate (never the rose error tone).+function TimelineSkippedStepRows({+ block,+ steps,+ depth,+ onBlockItemClick,+}: TimelineSkippedStepRowsProps) {+ if (steps.length === 0) return null;++ return (+ <div className="space-y-1 pb-1">+ {steps.map((step, index) => {+ const lines = formatCodeStepLines(step);+ const summary =+ normalizeInlineText(step.title) ??+ normalizeInlineText(step.description);++ return (+ <div+ key={`skipped-${index}`}+ className="flex min-h-[24px] items-stretch text-xs opacity-60"+ >+ <IndentRails depth={depth} />+ <div+ className={cn(+ "flex min-w-0 flex-1 items-center gap-1.5 rounded-r py-0.5 pr-1.5",+ "hover:bg-slate-800/60",+ )}+ style={railHighlightStyle}+ >+ <div className="size-4 shrink-0" />+ <button+ type="button"+ onClick={(event) => {+ event.stopPropagation();+ onBlockItemClick(block);+ }}+ className="flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 rounded text-left outline-none focus-visible:ring-1 focus-visible:ring-white/40"+ >+ <span+ className="size-2 shrink-0 rounded-full border border-dashed border-slate-500"+ aria-hidden="true"+ />+ <span className="shrink-0 rounded border border-slate-700 px-1.5 py-0.5 text-[10px] font-medium text-slate-400">+ {getReadableActionType(step.action_type)}+ </span>+ {summary && (+ <span className="min-w-0 flex-1 truncate text-slate-500">+ · {summary}+ </span>+ )}+ {lines && (+ <span className="shrink-0 text-[10px] tabular-nums text-slate-500">+ {lines}+ </span>+ )}+ <span+ className="ml-auto shrink-0 rounded bg-slate-800 px-1 text-[10px] uppercase tracking-wide text-slate-400"+ title="This step did not execute because the code block stopped before reaching it."+ >+ didn't run+ </span>+ </button>+ </div>+ </div>+ );+ })}+ </div>+ );+}+function WorkflowRunTimelineBlockItem({activeItem,activeIteration = null,@@ -622,22 +800,39 @@ function WorkflowRunTimelineBlockItem({block.duration !== null ? formatDuration(toDuration(block.duration)) : null;const blockTypeTitle = workflowBlockTitle[block.block_type];const blockTypeLabel = getTimelineTypeLabel(block);- const blockName = block.label ?? block.title ?? blockTypeTitle;const blockIndex = blockOrder?.get(block.workflow_run_block_id);- const descriptor = getTimelineDescriptor(block);const actions = block.actions ?? [];const actionCount = actions.length;const hasActions = actionCount > 0;const isCodeBlock = block.block_type === WorkflowBlockTypes.Code;+ const definitionCodeSteps = isCodeBlock+ ? (codeStepsByLabel?.get(block.label ?? "") ?? [])+ : [];+ const blockName = isCodeBlock+ ? getCodeBlockTimelineName(block, definitionCodeSteps)+ : (block.label ?? block.title ?? blockTypeTitle);+ const descriptor = isCodeBlock+ ? (block.label ?? "Code block")+ : getTimelineDescriptor(block);const showsActionRows = hasActions;// Code blocks without recorded actions fall back to their definition step// outline so the timeline still reflects what the block was meant to do.- const codeSteps =- isCodeBlock && !hasActions- ? (codeStepsByLabel?.get(block.label ?? "") ?? [])- : [];+ const codeSteps = isCodeBlock && !hasActions ? definitionCodeSteps : [];const hasCodeSteps = codeSteps.length > 0;+ // When a code block fails partway, the definition steps after the failure+ // point left no action record — surface them as dimmed "didn't run" rows so+ // the timeline shows what never executed, not just what did.+ const blockFailed =+ block.status === Status.Failed ||+ block.status === Status.Terminated ||+ block.status === Status.TimedOut ||+ block.status === Status.Canceled;+ const skippedCodeSteps =+ isCodeBlock && blockFailed && hasActions+ ? getUnfiredCodeSteps(definitionCodeSteps, actions)+ : [];+ const hasSkippedCodeSteps = skippedCodeSteps.length > 0;const isForLoopBlock = block.block_type === "for_loop";const isWhileLoopBlock = block.block_type === "while_loop";const isLoopBlock = isForLoopBlock || isWhileLoopBlock;@@ -832,6 +1027,7 @@ function WorkflowRunTimelineBlockItem({block={block}activeItem={activeItem}depth={depth + 1}+ codeSteps={definitionCodeSteps}onActionClick={onActionClick}workflowRunIsFinalized={workflowRunIsFinalized}/>@@ -844,6 +1040,14 @@ function WorkflowRunTimelineBlockItem({onBlockItemClick={onBlockItemClick}/>)}+ {hasSkippedCodeSteps && (+ <TimelineSkippedStepRows+ block={block}+ steps={skippedCodeSteps}+ depth={depth + 1}+ onBlockItemClick={onBlockItemClick}+ />+ )}{isLoopBlock && loopIterationGroups.length > 0 ? (<LoopIterationRowsloopBlock={block}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsxindex 866ddb8b4..e4d084d7f 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx@@ -8,13 +8,12 @@ import { Link } from "react-router-dom";import { Input } from "@/components/ui/input";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";-import { Status } from "@/api/types";import { cn } from "@/util/utils";import {- hasExtractedInformation,+ getBlockOutputDisplayValue,+ shouldShowExtractedInformation,type WorkflowRunBlock,} from "../../types/workflowRunTypes";-import { isTaskVariantBlock } from "../../types/workflowTypes";type InspectorField = {label: string;@@ -356,14 +355,7 @@ function getInputFields(block: WorkflowRunBlock): Array<InspectorField> {}function getOutputValue(block: WorkflowRunBlock): unknown {- if (- isTaskVariantBlock(block) &&- block.status === Status.Completed &&- hasExtractedInformation(block.output)- ) {- return block.output.extracted_information;- }- return block.output;+ return getBlockOutputDisplayValue(block);}function getSummaryFields(block: WorkflowRunBlock): Array<InspectorField> {@@ -381,7 +373,14 @@ function BlockInspector({ block }: { block: WorkflowRunBlock }) {const inputFields = useMemo(() => getInputFields(block), [block]);const summaryFields = useMemo(() => getSummaryFields(block), [block]);const outputValue = getOutputValue(block);- const hasOutput = !isEmptyValue(outputValue);+ const showsExtractedInformation = shouldShowExtractedInformation(block);+ const hasOutput = showsExtractedInformation || !isEmptyValue(outputValue);+ const outputRootLabel = showsExtractedInformation+ ? "extracted_information"+ : "output";+ const outputTabLabel = showsExtractedInformation+ ? "Extracted Information"+ : "Outputs";const defaultTab = hasOutput ? "outputs" : "summary";const [activeTab, setActiveTab] = useState(defaultTab);const triggerClassName =@@ -413,7 +412,7 @@ function BlockInspector({ block }: { block: WorkflowRunBlock }) {disabled={!hasOutput}value="outputs">- Outputs+ {outputTabLabel}</TabsTrigger>{block.task_id && (<Link@@ -441,7 +440,7 @@ function BlockInspector({ block }: { block: WorkflowRunBlock }) {</TabsContent><TabsContent value="outputs" className="m-0">{hasOutput ? (- <JsonExplorer value={outputValue} rootLabel="output" />+ <JsonExplorer value={outputValue} rootLabel={outputRootLabel} />) : (<div className="text-xs text-slate-500">No block output.</div>)}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockInfo/CodeBlockParameters.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockInfo/CodeBlockParameters.tsxindex e5e7c30fd..930bc7de7 100644--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockInfo/CodeBlockParameters.tsx+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockInfo/CodeBlockParameters.tsx@@ -95,6 +95,7 @@ function CodeBlockParameters({language="python"value={code}readOnly+ lineWrap={false}minHeight="160px"maxHeight="400px"extraExtensions={codeExtensions}