Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Render Workflow Studio run-view block prompts as prose, not code (SKY-12797) (#7643)
Celal Zamanoğlu2569a02e63b7
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunFieldValue.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunFieldValue.test.tsxnew file mode 100644index 000000000..63f9d0a81--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunFieldValue.test.tsx@@ -0,0 +1,61 @@+// @vitest-environment jsdom++import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, test, vi } from "vitest";++import { RunFieldValue } from "./RunFieldValue";++afterEach(() => {+ cleanup();+ vi.restoreAllMocks();+});++describe("RunFieldValue", () => {+ test("clamps a long primitive value, toggles it via Show more / Show less, and offers copy", () => {+ // jsdom has no layout engine, so mock the clamp overflow the component+ // measures (scrollHeight > clientHeight).+ vi.spyOn(HTMLElement.prototype, "scrollHeight", "get").mockReturnValue(200);+ vi.spyOn(HTMLElement.prototype, "clientHeight", "get").mockReturnValue(96);++ const value = "A synthetic field value long enough to overflow the clamp.";+ render(<RunFieldValue value={value} label="doc" />);++ // Collapsed: the value is clamped and a copy affordance is present.+ expect(screen.getByText(value).className).toContain("line-clamp-6");+ expect(+ screen.queryByRole("button", { name: "Copy to clipboard" }),+ ).not.toBeNull();++ fireEvent.click(screen.getByRole("button", { name: "Show more" }));+ expect(screen.queryByRole("button", { name: "Show less" })).not.toBeNull();+ expect(screen.queryByRole("button", { name: "Show more" })).toBeNull();+ // Expanded: the clamp is dropped so the full value is visible.+ expect(screen.getByText(value).className).not.toContain("line-clamp-6");+ });++ test("renders nested objects as the collapsible searchable tree, not clamped prose", () => {+ render(<RunFieldValue value={{ count: 3 }} label="line_items" />);+ expect(screen.queryByPlaceholderText("Search JSON")).not.toBeNull();+ expect(screen.queryByRole("button", { name: "Show more" })).toBeNull();+ });++ test("shows a muted placeholder for nullish/empty primitives but keeps the literal string 'null' as text", () => {+ for (const absent of [null, undefined, ""]) {+ render(<RunFieldValue value={absent} label="field" />);+ // The em-dash placeholder replaces the copyable prose box.+ expect(screen.getByText("—")).not.toBeNull();+ expect(+ screen.queryByRole("button", { name: "Copy to clipboard" }),+ ).toBeNull();+ cleanup();+ }++ // "null" is a real string value, not an absent one: prose + copy, no dash.+ render(<RunFieldValue value="null" label="field" />);+ expect(screen.getByText("null")).not.toBeNull();+ expect(screen.queryByText("—")).toBeNull();+ expect(+ screen.queryByRole("button", { name: "Copy to clipboard" }),+ ).not.toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunFieldValue.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunFieldValue.tsxnew file mode 100644index 000000000..39ed4b7e7--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunFieldValue.tsx@@ -0,0 +1,106 @@+import {+ useCallback,+ useEffect,+ useId,+ useLayoutEffect,+ useRef,+ useState,+} from "react";++import { CopyButton } from "@/components/CopyButton";+import { Button } from "@/components/ui/button";++import { JsonExplorer } from "../../workflowRun/blockDetail/BlockInspector";++// Clamped, copyable text box shared by primitive run field values and block+// prompts. line-clamp-6 caps the collapsed height so a long pasted document or+// serialized payload can't make the pane arbitrarily tall; Show more/Show less+// appears only when the text actually overflows the clamp.+export function ClampedProse({ text }: { text: string }) {+ const [expanded, setExpanded] = useState(false);+ const [overflows, setOverflows] = useState(false);+ const contentId = useId();+ const boxRef = useRef<HTMLDivElement>(null);+ const measureOverflow = useCallback(() => {+ const element = boxRef.current;+ if (element) {+ setOverflows(element.scrollHeight > element.clientHeight);+ }+ }, []);++ useLayoutEffect(() => {+ if (!expanded) {+ measureOverflow();+ }+ }, [expanded, measureOverflow, text]);++ useEffect(() => {+ if (expanded || typeof ResizeObserver === "undefined") {+ return;+ }+ const element = boxRef.current;+ if (!element) {+ return;+ }+ // Width changes (pane resize) re-wrap the text and can flip the overflow+ // verdict even though the collapsed clamp is pinned — so keep observing.+ const observer = new ResizeObserver(measureOverflow);+ observer.observe(element);+ return () => observer.disconnect();+ }, [expanded, measureOverflow]);++ return (+ <div className="flex flex-col items-start">+ <div className="group relative w-full">+ <CopyButton+ value={text}+ className="absolute right-1.5 top-1.5 z-10 h-6 w-6 text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100"+ />+ {/* elevation2 (the run-view pane is elevation1) so the field reads as+ raised. Padding sits on this wrapper, not the clamped child, because+ line-clamp clips at the padding box and would otherwise leak a sliver+ of the next line below the ellipsis. */}+ <div className="rounded bg-slate-elevation2 px-2.5 py-2 pr-9">+ <div+ id={contentId}+ ref={boxRef}+ className={`whitespace-pre-wrap break-words text-xs text-tertiary-foreground ${expanded ? "" : "line-clamp-6"}`}+ >+ {text}+ </div>+ </div>+ </div>+ {overflows ? (+ <Button+ type="button"+ variant="link"+ size="sm"+ className="mt-1.5 h-auto justify-start p-0 text-xs text-muted-foreground hover:text-foreground"+ aria-controls={contentId}+ aria-expanded={expanded}+ onClick={() => setExpanded((value) => !value)}+ >+ {expanded ? "Show less" : "Show more"}+ </Button>+ ) : null}+ </div>+ );+}++export function RunFieldValue({+ value,+ label,+}: {+ value: unknown;+ label: string;+}) {+ if (typeof value === "object" && value !== null) {+ return <JsonExplorer value={value} rootLabel={label} />;+ }+ // Nullish/empty stays distinguishable from the literal string "null" (which+ // String() would flatten into the same prose); 0 and false are real values.+ if (value === null || value === undefined || value === "") {+ return <span className="text-xs italic text-muted-foreground">—</span>;+ }+ return <ClampedProse text={String(value)} />;+}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsxindex a00ab89e3..a99e858b1 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.test.tsx@@ -3,12 +3,9 @@import { cleanup, fireEvent, render, screen } from "@testing-library/react";import { afterEach, describe, expect, test, vi } from "vitest";+import type { WorkflowParameter } from "../../types/workflowTypes";import { RunInputsSection } from "./RunInputsSection";-vi.mock("./OverviewCodeBlock", () => ({- OverviewCodeBlock: ({ value }: { value: string }) => <pre>{value}</pre>,-}));-const emptyProps = {parameters: [],blockPrompts: [],@@ -96,6 +93,34 @@ describe("RunInputsSection", () => {expect(empty.container.firstChild).toBeNull();});+ test("renders parameters as labeled fields: primitive prose, nested tree, description", () => {+ render(+ <RunInputsSection+ {...emptyProps}+ parameters={[+ [+ "invoice_url",+ "https://example.test/invoice.pdf",+ {+ description: "Where the invoice lives",+ } as unknown as WorkflowParameter,+ ],+ ["line_items", { count: 3 }],+ ]}+ />,+ );++ expect(screen.queryByText("Run inputs")).not.toBeNull();+ expect(screen.queryByText("invoice_url")).not.toBeNull();+ expect(screen.queryByText("Where the invoice lives")).not.toBeNull();+ // Primitive renders as prose text, not a single JSON dump.+ expect(+ screen.queryByText("https://example.test/invoice.pdf"),+ ).not.toBeNull();+ // Nested value renders the collapsible searchable tree (JsonExplorer).+ expect(screen.queryByPlaceholderText("Search JSON")).not.toBeNull();+ });+test("labels every prompt inset, including single-field blocks", () => {render(<RunInputsSection@@ -124,10 +149,11 @@ describe("RunInputsSection", () => {expect(screen.queryByText("Extraction goal")).not.toBeNull();});- test("renders the expansion toggle when measured content overflows", () => {- // jsdom has no layout engine, so it cannot measure line-clamp overflow itself.- vi.spyOn(HTMLElement.prototype, "scrollHeight", "get").mockReturnValue(80);- vi.spyOn(HTMLElement.prototype, "clientHeight", "get").mockReturnValue(48);+ test("toggles the clamped prose block via Show more / Show less", () => {+ // jsdom has no layout engine, so mock the clamp overflow the component+ // measures (scrollHeight > clientHeight).+ vi.spyOn(HTMLElement.prototype, "scrollHeight", "get").mockReturnValue(200);+ vi.spyOn(HTMLElement.prototype, "clientHeight", "get").mockReturnValue(96);render(<RunInputsSection@@ -139,8 +165,7 @@ describe("RunInputsSection", () => {fields: [{fieldLabel: "Prompt",- prompt:- "A synthetic prompt long enough to overflow three lines.",+ prompt: "A synthetic prompt long enough to overflow the clamp.",},],},@@ -148,16 +173,28 @@ describe("RunInputsSection", () => {/>,);- expect(screen.queryByRole("button", { name: "Show more" })).not.toBeNull();+ const toggle = screen.getByRole("button", { name: "Show more" });+ const promptText = "A synthetic prompt long enough to overflow the clamp.";+ // Collapsed: the prose block carries the line clamp.+ expect(screen.getByText(promptText).className).toContain("line-clamp-6");++ fireEvent.click(toggle);+ expect(screen.queryByRole("button", { name: "Show less" })).not.toBeNull();+ expect(screen.queryByRole("button", { name: "Show more" })).toBeNull();+ // Expanded: the clamp is dropped so the full prompt is visible.+ expect(screen.getByText(promptText).className).not.toContain(+ "line-clamp-6",+ );});- test("bounds the collapsed render and toggles many-line prompts without layout", () => {- // 20 short lines: jsdom can't measure height, so the line-count cap alone- // must drive the toggle and keep the hidden lines out of the DOM.+ test("renders the whole prompt as one wrapped block, not per-line rows", () => {+ // Prose keeps the entire prompt in the DOM and clamps height via CSS; the+ // old code inset sliced hidden lines out, so a collapsed multi-line prompt+ // must now expose every line (copy/accessibility) as a single text node.const prompt = Array.from({ length: 20 }, (_, i) => `line ${i + 1}`).join("\n",);- render(+ const { container } = render(<RunInputsSection{...emptyProps}blockPrompts={[@@ -170,11 +207,10 @@ describe("RunInputsSection", () => {/>,);- expect(screen.queryByText("line 6")).not.toBeNull();- expect(screen.queryByText("line 7")).toBeNull();- const toggle = screen.getByRole("button", { name: "Show more" });-- fireEvent.click(toggle);- expect(screen.queryByText("line 20")).not.toBeNull();+ expect(container.textContent).toContain("line 1");+ expect(container.textContent).toContain("line 20");+ // No per-line row elements: the prompt lives in one node, so no element's+ // text is exactly "line 6".+ expect(screen.queryByText("line 6")).toBeNull();});});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.tsxindex 49b85aa97..83c213486 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunInputsSection.tsx@@ -1,132 +1,21 @@-import {- useCallback,- useEffect,- useId,- useLayoutEffect,- useRef,- useState,-} from "react";-import { defaultSettingsTokyoNightStorm } from "@uiw/codemirror-theme-tokyo-night-storm";-import { CopyButton } from "@/components/CopyButton";-import { Button } from "@/components/ui/button";import { workflowBlockTitle } from "@/routes/workflows/editor/nodes/types";+import type { WorkflowParameter } from "../../types/workflowTypes";import type { BlockPrompt } from "./blockPrompts";-import { OverviewCodeBlock } from "./OverviewCodeBlock";+import { OverviewField } from "./OverviewField";+import { ClampedProse, RunFieldValue } from "./RunFieldValue";export type RunInputMeta = { label: string; value: string };type RunInputsSectionProps = {- // Ordered [key, value] entries for the agent (workflow) inputs this run used.- parameters: Array<[string, unknown]>;+ // Ordered [key, value, definition] entries for the agent (workflow) inputs this run used.+ parameters: Array<[string, unknown, WorkflowParameter?]>;blockPrompts: BlockPrompt[];// Run-level non-parameter inputs (webhook, proxy, headers, …).meta: RunInputMeta[];};-// The background/foreground CodeMirror paints for the JSON Agent-inputs block-// (tokyoNightStorm). Prompts are plain text, so this inset reproduces the-// OverviewCodeBlock chrome without mounting a CodeMirror per prompt.-const CODE_INSET_BG = defaultSettingsTokyoNightStorm.background ?? "#24283b";-const CODE_INSET_FG = defaultSettingsTokyoNightStorm.foreground ?? "#7982a9";-// Collapsed height shows ~4 lines; render a few past that so the clamp is filled,-// but not the whole prompt — an unbounded paste would otherwise build thousands-// of hidden line nodes.-const COLLAPSED_LINE_CAP = 6;--function PromptCodeInset({ prompt }: { prompt: string }) {- const [expanded, setExpanded] = useState(false);- const [overflows, setOverflows] = useState(false);- const contentId = useId();- const boxRef = useRef<HTMLDivElement>(null);- const measureOverflow = useCallback(() => {- const element = boxRef.current;- if (element) {- setOverflows(element.scrollHeight > element.clientHeight);- }- }, []);-- useLayoutEffect(() => {- if (!expanded) {- measureOverflow();- }- }, [expanded, measureOverflow, prompt]);-- useEffect(() => {- if (expanded || typeof ResizeObserver === "undefined") {- return;- }- const element = boxRef.current;- if (!element) {- return;- }- // Width changes (pane resize) re-wrap the prompt and can flip the overflow- // verdict even though the collapsed height is pinned — so keep observing.- const observer = new ResizeObserver(measureOverflow);- observer.observe(element);- return () => observer.disconnect();- }, [expanded, measureOverflow]);-- const lines = prompt.split("\n");- const visibleLines = expanded ? lines : lines.slice(0, COLLAPSED_LINE_CAP);- const showToggle = overflows || lines.length > COLLAPSED_LINE_CAP;-- return (- <div className="flex flex-col items-start">- <div className="relative w-full">- <CopyButton- value={prompt}- className="absolute right-2 top-2 z-10 h-7 w-7 bg-slate-elevation3/80 text-muted-foreground backdrop-blur hover:bg-slate-elevation4 hover:text-foreground"- />- <div- id={contentId}- ref={boxRef}- style={{ backgroundColor: CODE_INSET_BG, color: CODE_INSET_FG }}- // ~3 lines at the inset's 12px/1.4; a height clamp (not line-clamp-3)- // so the per-line number gutter rows stay intact.- className={`overflow-hidden rounded-md py-1 font-mono text-xs leading-[1.4] ${expanded ? "" : "max-h-[66px]"}`}- >- {visibleLines.map((line, index) => (- <div key={index} className="flex items-start">- <span className="min-w-[22px] shrink-0 select-none whitespace-nowrap pl-[5px] pr-2 text-right">- {index + 1}- </span>- {/* pr-10 clears the absolute copy button so a full-width wrapped- first line isn't occluded. */}- <span className="min-w-0 flex-1 whitespace-pre-wrap break-words pl-1.5 pr-10">- {line === "" ? " " : line}- </span>- </div>- ))}- </div>- {!expanded && showToggle ? (- <div- aria-hidden- className="pointer-events-none absolute inset-x-0 bottom-0 h-[26px] rounded-b-md"- style={{- background: `linear-gradient(to bottom, transparent, ${CODE_INSET_BG})`,- }}- />- ) : null}- </div>- {showToggle ? (- <Button- type="button"- variant="link"- size="sm"- className="mt-1.5 h-auto justify-start p-0 text-xs text-muted-foreground hover:text-foreground"- aria-controls={contentId}- aria-expanded={expanded}- onClick={() => setExpanded((value) => !value)}- >- {expanded ? "Show less" : "Show more"}- </Button>- ) : null}- </div>- );-}-export function RunInputsSection({parameters,blockPrompts,@@ -140,8 +29,6 @@ export function RunInputsSection({return null;}- const agentInputs = Object.fromEntries(parameters);-return (<div className="flex flex-col gap-6">{parameters.length > 0 ? (@@ -149,10 +36,20 @@ export function RunInputsSection({<span className="text-xs font-medium text-muted-foreground">Run inputs</span>- <OverviewCodeBlock- value={JSON.stringify(agentInputs, null, 2)}- maxHeight="320px"- />+ <div className="flex flex-col gap-4">+ {parameters.map(([key, value, definition]) => (+ <OverviewField key={key} label={key}>+ <div className="flex flex-col gap-1.5">+ {definition?.description ? (+ <span className="text-xs text-muted-foreground">+ {definition.description}+ </span>+ ) : null}+ <RunFieldValue value={value} label={key} />+ </div>+ </OverviewField>+ ))}+ </div></div>) : null}{blockPrompts.length > 0 ? (@@ -169,10 +66,10 @@ export function RunInputsSection({// pair with the flattened index to keep keys stable.key={`${block.blockLabel}-${index}`}>- <div className="mb-2.5 font-mono text-sm font-medium text-foreground">+ <div className="mb-2.5 text-sm font-medium text-foreground">{block.blockLabel}{typeLabel ? (- <span className="ml-2 font-sans font-normal text-muted-foreground">+ <span className="ml-2 font-normal text-muted-foreground">{typeLabel}</span>) : null}@@ -183,7 +80,7 @@ export function RunInputsSection({<span className="mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground">{field.fieldLabel}</span>- <PromptCodeInset prompt={field.prompt} />+ <ClampedProse text={field.prompt} /></div>))}</div>diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsxindex d79f24248..6c56c6342 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx@@ -101,6 +101,57 @@ describe("RunOutputsSection run outputs", () => {expect(screen.queryByText("Run outputs")).toBeNull();expect(screen.queryByTestId("summarize")).toBeNull();});++ test("hides the run outputs header when outputs holds only extracted_information", () => {+ render(+ <RunOutputsSection+ {...baseProps}+ outputs={{ extracted_information: { answer: 42 } }}+ extractedInformation={{ answer: 42 }}+ />,+ );+ // Extracted information keeps its own dedicated section.+ expect(screen.queryByText("Extracted information")).not.toBeNull();+ // No per-field run outputs remain, so no empty header or Summarize button.+ expect(screen.queryByText("Run outputs")).toBeNull();+ expect(screen.queryByTestId("summarize")).toBeNull();+ });++ test("keeps the run outputs block when only a persisted summary remains", () => {+ render(+ <RunOutputsSection+ {...baseProps}+ outputs={{ extracted_information: { answer: 42 } }}+ extractedInformation={{ answer: 42 }}+ summary="A persisted summary."+ />,+ );+ expect(screen.queryByText("Run outputs")).not.toBeNull();+ expect(screen.getByText("A persisted summary.")).not.toBeNull();+ });++ test("splits the outputs bag into per-block fields, excluding extracted_information", () => {+ render(+ <RunOutputsSection+ {...baseProps}+ outputs={{+ extracted_information: { answer: 42 },+ summary_block: "done",+ data_block: { rows: 2 },+ }}+ extractedInformation={{ answer: 42 }}+ />,+ );++ // Each non-extracted output key becomes its own labeled field.+ expect(screen.queryByText("summary_block")).not.toBeNull();+ expect(screen.queryByText("done")).not.toBeNull();+ // extracted_information keeps its dedicated section and is not repeated as a+ // per-block output field.+ expect(screen.queryByText("extracted_information")).toBeNull();+ // The nested block output renders the collapsible searchable tree.+ expect(screen.queryByPlaceholderText("Search JSON")).not.toBeNull();+ });});describe("RunOutputsSection task 2.0 and webhook surfaces", () => {diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsxindex 623e6b41f..c8a74b9b1 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx@@ -8,6 +8,8 @@ import { ArtifactDownloadLink } from "@/components/ArtifactDownloadLink";import { SummarizeOutput } from "@/components/SummarizeOutput";import { OverviewCodeBlock } from "./OverviewCodeBlock";+import { OverviewField } from "./OverviewField";+import { RunFieldValue } from "./RunFieldValue";export type RunOutputFile = { url: string; filename: string };export type RunOutputError = Record<string, unknown>;@@ -183,8 +185,16 @@ export function RunOutputsSection({return null;}- const hasAgentRunOutputs =- outputs !== null && Object.keys(outputs).length > 0;+ // extracted_information has its own dedicated section above, so drop it from the+ // per-block field list to avoid rendering it twice.+ const outputFields = outputs+ ? Object.entries(outputs).filter(([key]) => key !== "extracted_information")+ : [];+ // Gate the block on real per-field content or a persisted summary: an outputs+ // bag holding only extracted_information yields no fields, and that content+ // already renders in its dedicated section above — so an empty header ++ // Summarize button would otherwise render over nothing.+ const hasAgentRunOutputs = outputFields.length > 0 || summary !== null;return (<div className="flex flex-col gap-5">@@ -245,10 +255,15 @@ export function RunOutputsSection({{summary}</div>) : null}- <OverviewCodeBlock- value={JSON.stringify(outputs, null, 2)}- maxHeight="320px"- />+ {outputFields.length > 0 ? (+ <div className="flex flex-col gap-4">+ {outputFields.map(([key, value]) => (+ <OverviewField key={key} label={key}>+ <RunFieldValue value={value} label={key} />+ </OverviewField>+ ))}+ </div>+ ) : null}</div>) : null}{files.length > 0 ? (diff --git a/skyvern-frontend/src/routes/workflows/utils.test.ts b/skyvern-frontend/src/routes/workflows/utils.test.tsindex 6b11e6c06..cbb1d6b3e 100644--- a/skyvern-frontend/src/routes/workflows/utils.test.ts+++ b/skyvern-frontend/src/routes/workflows/utils.test.ts@@ -4,9 +4,10 @@ import {ProxyLocation,type WorkflowRunStatusApiResponseWithWorkflow,} from "@/api/types";-import type { WorkflowParameter } from "./types/workflowTypes";+import type { Parameter, WorkflowParameter } from "./types/workflowTypes";import {getInitialValues,+ getOrderedRunParameters,getRerunNavigationState,normalizeJsonParameterFormValue,parseJsonWorkflowParameterValue,@@ -164,3 +165,56 @@ describe("validateJsonWorkflowParameterValue", () => {);});});++describe("getOrderedRunParameters", () => {+ it("orders by the workflow definition, then appends definition-less extras", () => {+ const definitionParameters = [+ { parameter_type: "workflow", key: "first", description: "First field" },+ { parameter_type: "workflow", key: "second", description: null },+ ] as unknown as Parameter[];+ const runParameters = { second: "b", first: "a", extra: "c" };++ const result = getOrderedRunParameters(definitionParameters, runParameters);++ expect(result.map(([key]) => key)).toEqual(["first", "second", "extra"]);+ expect(result.map(([, value]) => value)).toEqual(["a", "b", "c"]);+ // The matched definition rides along per key.+ expect(result.map(([, , def]) => def?.description ?? null)).toEqual([+ "First field",+ null,+ null,+ ]);+ // Extras (absent from the definition) carry no definition object.+ expect(result[2]?.[2]).toBeUndefined();+ });++ it("never surfaces credential/secret parameter definitions", () => {+ const definitionParameters = [+ {+ parameter_type: "workflow",+ key: "invoice_url",+ description: "Invoice",+ },+ {+ parameter_type: "credential",+ key: "login",+ credential_id: "cred_secret_123",+ },+ ] as unknown as Parameter[];+ const runParameters = { invoice_url: "https://x.test" };++ const result = getOrderedRunParameters(definitionParameters, runParameters);++ // Only the workflow parameter is surfaced; the credential key is absent...+ expect(result.map(([key]) => key)).toEqual(["invoice_url"]);+ // ...and no credential-definition metadata leaks into any entry.+ expect(JSON.stringify(result)).not.toContain("cred_secret_123");+ });++ it("falls back to Object.entries ordering without a definition", () => {+ expect(getOrderedRunParameters(undefined, { b: 2, a: 1 })).toEqual([+ ["b", 2, undefined],+ ["a", 1, undefined],+ ]);+ });+});diff --git a/skyvern-frontend/src/routes/workflows/utils.ts b/skyvern-frontend/src/routes/workflows/utils.tsindex a57755f8a..e70233b25 100644--- a/skyvern-frontend/src/routes/workflows/utils.ts+++ b/skyvern-frontend/src/routes/workflows/utils.ts@@ -221,31 +221,40 @@ export const getOrderedBlockLabels = (workflow?: WorkflowApiResponse) => {};/**- * Returns run parameter entries ordered by the workflow definition's parameter array.- * Falls back to Object.entries() if no definition is available.+ * Returns run parameter entries ordered by the workflow definition's parameter array,+ * each paired with its matched workflow-parameter definition (undefined when absent).+ * Falls back to Object.entries() ordering if no definition is available.*/export function getOrderedRunParameters(definitionParameters: Array<Parameter> | undefined,runParameters: Record<string, unknown>,-): Array<[string, unknown]> {+): Array<[string, unknown, WorkflowParameter?]> {+ const workflowDefs = (definitionParameters ?? []).filter(+ (p): p is WorkflowParameter => p.parameter_type === "workflow",+ );+ const defByKey = new Map(workflowDefs.map((p) => [p.key, p] as const));+ const attach = (+ key: string,+ value: unknown,+ ): [string, unknown, WorkflowParameter?] => [key, value, defByKey.get(key)];+if (!definitionParameters) {- return Object.entries(runParameters);+ return Object.entries(runParameters).map(([key, value]) =>+ attach(key, value),+ );}- const orderedKeys = definitionParameters- .filter((p) => p.parameter_type === "workflow")- .map((p) => p.key);-+ const orderedKeys = workflowDefs.map((p) => p.key);const seenKeys = new Set(orderedKeys);- const ordered: Array<[string, unknown]> = orderedKeys+ const ordered: Array<[string, unknown, WorkflowParameter?]> = orderedKeys.filter((key) => key in runParameters)- .map((key) => [key, runParameters[key]]);+ .map((key) => attach(key, runParameters[key]));// Append any run parameters not in the definition (backward compat)for (const [key, value] of Object.entries(runParameters)) {if (!seenKeys.has(key)) {- ordered.push([key, value]);+ ordered.push(attach(key, value));}}