Skip to content

Automate browser based workflows with AI

SKY-11602 Surface run output signals in new UI (#7024)

Aaron Perez35363339049d
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index 1492b3f30..49755e853 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -720,6 +720,7 @@ export type WorkflowRunStatusApiResponse = {
webhook_failure_reason: string | null;
downloaded_file_urls: Array<string> | null;
downloaded_files: Array<DownloadedFileInfo> | null;
+ errors: Array<Record<string, unknown>> | null;
total_steps: number | null;
total_cost: number | null;
credits_used: number;
@@ -757,6 +758,7 @@ export type WorkflowRunStatusApiResponseWithWorkflow = {
webhook_failure_reason: string | null;
downloaded_file_urls: Array<string> | null;
downloaded_files: Array<DownloadedFileInfo> | null;
+ errors: Array<Record<string, unknown>> | null;
total_steps: number | null;
total_cost: number | null;
credits_used: number;
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx
index 54bf273af..a4756ae42 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.test.tsx
@@ -16,6 +16,7 @@ const baseProps = {
workflowRunId: "wr_1",
extractedInformation: null,
files: [],
+ errors: [],
summary: null,
onSummary: () => {},
};
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx
index 09b3edecb..8350eb268 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunOutputsSection.tsx
@@ -1,16 +1,22 @@
-import { DownloadIcon, FileIcon } from "@radix-ui/react-icons";
+import {
+ DownloadIcon,
+ ExclamationTriangleIcon,
+ FileIcon,
+} from "@radix-ui/react-icons";
import { SummarizeOutput } from "@/components/SummarizeOutput";
import { OverviewCodeBlock } from "./OverviewCodeBlock";
export type RunOutputFile = { url: string; filename: string };
+export type RunOutputError = Record<string, unknown>;
type RunOutputsSectionProps = {
workflowRunId: string;
workflowTitle?: string | null;
extractedInformation: Record<string, unknown> | null;
files: RunOutputFile[];
+ errors: RunOutputError[];
// Task 2.0 runs report their output on task_v2, not the run-level outputs.
observerOutput?: Record<string, unknown> | null;
webhookFailureReason?: string | null;
@@ -20,11 +26,141 @@ type RunOutputsSectionProps = {
onSummary: (summary: string | null) => void;
};
+function readStringField(
+ record: Record<string, unknown>,
+ keys: Array<string>,
+): string | null {
+ for (const key of keys) {
+ const value = record[key];
+ if (typeof value !== "string") {
+ continue;
+ }
+ const trimmed = value.trim();
+ if (trimmed !== "") {
+ return trimmed;
+ }
+ }
+ return null;
+}
+
+function getErrorCode(error: RunOutputError): string | null {
+ return readStringField(error, ["error_code", "code"]);
+}
+
+function getErrorMessage(error: RunOutputError): string | null {
+ return readStringField(error, [
+ "reasoning",
+ "message",
+ "detail",
+ "error",
+ "error_message",
+ "description",
+ ]);
+}
+
+function uniqueNonEmpty(
+ values: Array<string | null | undefined>,
+): Array<string> {
+ const seen = new Set<string>();
+ const result: Array<string> = [];
+ for (const value of values) {
+ const trimmed = value?.trim();
+ if (!trimmed || seen.has(trimmed)) {
+ continue;
+ }
+ seen.add(trimmed);
+ result.push(trimmed);
+ }
+ return result;
+}
+
+function getVisibleErrorCodes(errors: RunOutputError[]): string[] {
+ return uniqueNonEmpty(errors.map(getErrorCode));
+}
+
+function getVisibleErrors(errors: RunOutputError[]): RunOutputError[] {
+ return errors.filter((error) => getErrorMessage(error) !== null);
+}
+
+function hasRenderableErrors(errors: RunOutputError[]): boolean {
+ return (
+ getVisibleErrorCodes(errors).length > 0 ||
+ getVisibleErrors(errors).length > 0
+ );
+}
+
+function RunErrorsPanel({ errors }: { errors: RunOutputError[] }) {
+ const visibleErrorCodes = getVisibleErrorCodes(errors);
+ const visibleErrors = getVisibleErrors(errors);
+
+ if (visibleErrorCodes.length === 0 && visibleErrors.length === 0) {
+ return null;
+ }
+
+ return (
+ <div className="rounded-md border border-destructive/35 bg-destructive/10 p-3">
+ <div className="flex items-start gap-2">
+ <ExclamationTriangleIcon className="mt-0.5 size-4 shrink-0 text-destructive" />
+ <div className="min-w-0 flex-1 space-y-3">
+ <div>
+ <div className="text-xs font-semibold text-foreground">
+ Run errors
+ </div>
+ <div className="mt-0.5 text-xs text-muted-foreground">
+ Errors and failure codes from this run
+ </div>
+ </div>
+ {visibleErrorCodes.length > 0 ? (
+ <div className="flex flex-wrap gap-1.5">
+ {visibleErrorCodes.map((code) => (
+ <span
+ key={code}
+ className="rounded border border-destructive/30 bg-destructive/15 px-1.5 py-0.5 font-mono text-[11px] font-medium text-destructive"
+ >
+ {code}
+ </span>
+ ))}
+ </div>
+ ) : null}
+ {visibleErrors.length > 0 ? (
+ <div className="space-y-2">
+ {visibleErrors.map((error, index) => {
+ const code = getErrorCode(error);
+ const message = getErrorMessage(error);
+ return (
+ <div
+ key={`${code ?? "error"}-${index}`}
+ className="rounded-md border border-destructive/20 bg-slate-elevation2 px-3 py-2 text-sm text-foreground"
+ >
+ <div className="flex min-w-0 items-start gap-2">
+ {code ? (
+ <span className="mt-0.5 shrink-0 rounded bg-destructive/15 px-1.5 py-0.5 font-mono text-[11px] text-destructive">
+ {code}
+ </span>
+ ) : null}
+ {message ? (
+ <span className="min-w-0 whitespace-pre-wrap break-words">
+ {message}
+ </span>
+ ) : null}
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ ) : null}
+ </div>
+ </div>
+ </div>
+ );
+}
+
export function RunOutputsSection({
workflowRunId,
workflowTitle,
extractedInformation,
files,
+ errors,
observerOutput = null,
webhookFailureReason = null,
summary,
@@ -33,9 +169,11 @@ export function RunOutputsSection({
const hasExtracted =
extractedInformation != null &&
Object.values(extractedInformation).some((value) => value !== null);
+ const hasErrors = hasRenderableErrors(errors);
if (
!hasExtracted &&
files.length === 0 &&
+ !hasErrors &&
observerOutput == null &&
!webhookFailureReason
) {
@@ -46,6 +184,7 @@ export function RunOutputsSection({
return (
<div className="flex flex-col gap-5">
+ <RunErrorsPanel errors={errors} />
{webhookFailureReason ? (
<div className="flex flex-col gap-2">
<span className="text-xs font-medium text-muted-foreground">
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
index a195eed1d..7258c1240 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
@@ -46,9 +46,15 @@ vi.mock("../../editor/hooks/useIsGeneratingCode", () => ({
useIsGeneratingCode: () => false,
}));
vi.mock("./RunHero", () => ({
- RunHero: (props: Record<string, unknown>) => {
+ RunHero: (props: Record<string, unknown> & { outputs?: ReactNode }) => {
mocks.runHeroProps.push(props);
- return <div data-testid="run-hero" />;
+ return (
+ <div data-testid="run-hero">
+ {props.outputs ? (
+ <div data-testid="run-outputs">{props.outputs}</div>
+ ) : null}
+ </div>
+ );
},
}));
vi.mock("../../workflowRun/WorkflowRunVerificationCodeForm", () => ({
@@ -174,6 +180,22 @@ function seedForLoopRun() {
};
}
+function seedCompletedRun(overrides: Record<string, unknown> = {}) {
+ mocks.timeline = [];
+ mocks.workflowRun = {
+ workflow_run_id: "wr_1",
+ status: Status.Completed,
+ downloaded_file_urls: [],
+ downloaded_files: [],
+ errors: null,
+ outputs: null,
+ workflow: {
+ workflow_definition: { blocks: [], finally_block_label: null },
+ },
+ ...overrides,
+ };
+}
+
afterEach(() => {
cleanup();
mocks.workflowRun = undefined;
@@ -344,7 +366,7 @@ describe("RunView iteration selection", () => {
fireEvent.click(scope.getByText(/Loop over 2 values/));
expect(scope.queryByText(/Iterable values/)).not.toBeNull();
expect(scope.queryByText("Iteration 2 value")).toBeNull();
- });
+ }, 20_000);
});
describe("RunView screenshot center view", () => {
@@ -472,3 +494,80 @@ describe("RunView screenshot center view", () => {
});
});
});
+
+describe("RunView output signals", () => {
+ test("surfaces run errors, error codes, and rich downloaded files", () => {
+ seedCompletedRun({
+ errors: [
+ {
+ error_code: "E_INVOICE_MISSING",
+ reasoning: "The expected invoice was not available.",
+ },
+ {
+ error_code: "E_PAYMENT_BLOCKED",
+ confidence_float: 0.91,
+ },
+ ],
+ downloaded_files: [
+ {
+ url: "https://example.test/downloads/report.pdf",
+ filename: "report.pdf",
+ checksum: null,
+ file_size: null,
+ modified_at: null,
+ artifact_id: null,
+ },
+ ],
+ downloaded_file_urls: null,
+ });
+
+ const { container } = render(
+ <MemoryRouter>
+ <RunView workflowRunId="wr_1" />
+ </MemoryRouter>,
+ );
+ const scope = within(container);
+
+ expect(scope.getByText("Run errors")).not.toBeNull();
+ expect(scope.getAllByText("E_INVOICE_MISSING").length).toBeGreaterThan(0);
+ expect(scope.getByText("E_PAYMENT_BLOCKED")).not.toBeNull();
+ expect(
+ scope.getByText("The expected invoice was not available."),
+ ).not.toBeNull();
+ expect(scope.queryByText("confidence_float")).toBeNull();
+ expect(scope.getByText("Downloaded files")).not.toBeNull();
+ expect(scope.getByText("report.pdf")).not.toBeNull();
+ });
+
+ test("does not treat a user output parameter named errors as run errors", () => {
+ seedCompletedRun({
+ outputs: {
+ errors: [{ message: "This is ordinary user output data." }],
+ },
+ });
+
+ const { container } = render(
+ <MemoryRouter>
+ <RunView workflowRunId="wr_1" />
+ </MemoryRouter>,
+ );
+ const scope = within(container);
+
+ expect(scope.queryByText("Run errors")).toBeNull();
+ });
+
+ test("does not add an output slot when run signals are absent", () => {
+ seedCompletedRun();
+
+ const { container } = render(
+ <MemoryRouter>
+ <RunView workflowRunId="wr_1" />
+ </MemoryRouter>,
+ );
+ const scope = within(container);
+
+ expect(scope.queryByTestId("run-outputs")).toBeNull();
+ expect(scope.queryByText("Run errors")).toBeNull();
+ expect(scope.queryByText("Downloaded files")).toBeNull();
+ });
+});
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
index d50a2b93d..302095bbe 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
@@ -16,7 +16,7 @@ import {
import { useRunViewStore } from "@/store/RunViewStore";
import { type ApiCommandOptions } from "@/util/apiCommands";
import { runsApiBaseUrl } from "@/util/env";
-import { cn } from "@/util/utils";
+import { cn, isRecord } from "@/util/utils";
import { useIsGeneratingCode } from "../../editor/hooks/useIsGeneratingCode";
import { constructCacheKeyValue } from "../../editor/utils";
@@ -46,7 +46,11 @@ import { RunHero } from "./RunHero";
import { type HeroSelection } from "./HeroScreenshot";
import { buildRunFixMessage } from "./runFixMessage";
import { RunInputsSection, type RunInputMeta } from "./RunInputsSection";
-import { RunOutputsSection, type RunOutputFile } from "./RunOutputsSection";
+import {
+ RunOutputsSection,
+ type RunOutputError,
+ type RunOutputFile,
+} from "./RunOutputsSection";
import { RunOverviewButton } from "./RunOverviewButton";
import { RunPlaceholder } from "./RunPlaceholder";
import { getSelectedRunFrameId } from "./runFrameSelection";
@@ -73,6 +77,17 @@ function hasScreenshotCandidate(selection: HeroSelection | null): boolean {
return true;
}
+function isRunOutputError(value: unknown): value is RunOutputError {
+ return isRecord(value);
+}
+
+function normalizeRunOutputErrors(value: unknown): RunOutputError[] {
+ if (Array.isArray(value)) {
+ return value.filter(isRunOutputError);
+ }
+ return [];
+}
+
/**
* Fused run view: browser hero on the left, run timeline tree + block detail on
* the right, sharing one pinned item via RunViewStore.
@@ -333,25 +348,40 @@ export function RunView({
const extractedInformation = useMemo<Record<string, unknown> | null>(() => {
const outputs = workflowRun?.outputs;
- return typeof outputs === "object" &&
- outputs !== null &&
- "extracted_information" in outputs
+ return isRecord(outputs) && "extracted_information" in outputs
? (outputs.extracted_information as Record<string, unknown>)
: null;
}, [workflowRun]);
const downloadedFiles = useMemo<RunOutputFile[]>(() => {
- const urls = workflowRun?.downloaded_file_urls ?? [];
const filenameByUrl = new Map<string, string>();
+ const files: RunOutputFile[] = [];
+ const seen = new Set<string>();
+ const pushFile = (url: string, filename?: string | null) => {
+ if (seen.has(url)) {
+ return;
+ }
+ seen.add(url);
+ files.push({
+ url,
+ filename: filename || pickDownloadedFileFilename(url, filenameByUrl),
+ });
+ };
for (const file of workflowRun?.downloaded_files ?? []) {
if (file.filename) {
filenameByUrl.set(file.url, file.filename);
}
+ pushFile(file.url, file.filename);
}
- return urls.map((url) => ({
- url,
- filename: pickDownloadedFileFilename(url, filenameByUrl),
- }));
+ // Prefer rich metadata first; URL fallback only fills gaps without duplicating.
+ for (const url of workflowRun?.downloaded_file_urls ?? []) {
+ pushFile(url);
+ }
+ return files;
+ }, [workflowRun]);
+
+ const runErrors = useMemo<RunOutputError[]>(() => {
+ return normalizeRunOutputErrors(workflowRun?.errors);
}, [workflowRun]);
const runInputs = useMemo(() => {
@@ -393,6 +423,7 @@ export function RunView({
const hasInputs =
runInputs.parameters.length > 0 || runInputs.meta.length > 0;
const hasOutputs =
+ runErrors.length > 0 ||
(extractedInformation != null &&
Object.values(extractedInformation).some((value) => value !== null)) ||
downloadedFiles.length > 0 ||
@@ -465,6 +496,7 @@ export function RunView({
workflowTitle={workflowRun.workflow?.title}
extractedInformation={extractedInformation}
files={downloadedFiles}
+ errors={runErrors}
observerOutput={observerOutput}
webhookFailureReason={webhookFailureReason}
summary={outputSummary}
diff --git a/skyvern-frontend/src/util/utils.ts b/skyvern-frontend/src/util/utils.ts
index 5ec8b82e9..14c59457d 100644
--- a/skyvern-frontend/src/util/utils.ts
+++ b/skyvern-frontend/src/util/utils.ts
@@ -5,6 +5,10 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
+export function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === "object" && value !== null && !Array.isArray(value);
+}
+
const clampToZero = (n: number) => Math.max(n, 0);
export const formatMs = (elapsed: number) => {