Skip to content

Automate browser based workflows with AI

SKY-15214: replace the Studio run failure card with a strip line (#8353)

Aaron Perez52491e7ef6c2
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunFailurePresentation.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunFailurePresentation.tsx
new file mode 100644
index 000000000..430b0f7ee
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunFailurePresentation.tsx
@@ -0,0 +1,104 @@
+import { type ReactNode } from "react";
+import {
+ CrossCircledIcon,
+ MagicWandIcon,
+ ReloadIcon,
+} from "@radix-ui/react-icons";
+
+import { Button } from "@/components/ui/button";
+// Fix leads when it is offered; Retry is the primary only when it stands alone.
+export function FailureRecoveryActions({
+ onFix,
+ onRetry,
+}: {
+ onFix?: () => void;
+ onRetry?: () => void;
+}) {
+ if (!onFix && !onRetry) {
+ return null;
+ }
+ return (
+ <>
+ {onFix ? (
+ <Button size="sm" onClick={onFix}>
+ <MagicWandIcon className="mr-1.5 h-3.5 w-3.5" aria-hidden="true" />
+ Fix with Copilot
+ </Button>
+ ) : null}
+ {onRetry ? (
+ <Button
+ size="sm"
+ variant={onFix ? "secondary" : "default"}
+ onClick={onRetry}
+ >
+ <ReloadIcon className="mr-1.5 h-3.5 w-3.5" aria-hidden="true" />
+ Retry
+ </Button>
+ ) : null}
+ </>
+ );
+}
+
+export function FailureTips({ tips }: { tips: Array<string> }) {
+ return (
+ <>
+ {tips.map((tip) => (
+ <span
+ key={tip}
+ className="basis-full text-[11px] italic text-muted-foreground"
+ >
+ {tip}
+ </span>
+ ))}
+ </>
+ );
+}
+
+// The strip's second line. The block name is the jump; the full
+// reason rides the headline's title so nothing else is said at run level.
+export function RunFailureLine({
+ blockLabel,
+ headline,
+ detail,
+ onJump,
+ tips,
+ children,
+}: {
+ blockLabel: string | null;
+ headline: string;
+ detail: string | null;
+ onJump?: () => void;
+ tips: Array<string>;
+ children: ReactNode;
+}) {
+ return (
+ <div
+ data-testid="run-failure-line"
+ className="flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1.5 text-xs"
+ >
+ <CrossCircledIcon
+ className="size-3.5 shrink-0 text-destructive"
+ aria-hidden="true"
+ />
+ {blockLabel ? (
+ <button
+ type="button"
+ onClick={onJump}
+ className="shrink-0 font-medium text-foreground underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ >
+ {blockLabel}
+ </button>
+ ) : null}
+ <span
+ className="min-w-0 flex-auto truncate text-foreground"
+ title={detail ?? undefined}
+ >
+ {blockLabel ? `— ${headline}` : headline}
+ </span>
+ <div className="ml-auto flex shrink-0 items-center gap-1.5">
+ {children}
+ </div>
+ <FailureTips tips={tips} />
+ </div>
+ );
+}
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 130ec787a..5e3f00bd4 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
@@ -957,29 +957,58 @@ describe("RunView live-watch terminal transition", () => {
});
});
-describe("RunView failure banner", () => {
- test("shows the failure reason with working Fix and Retry CTAs", () => {
+describe("RunView failure presentation", () => {
+ // A code block that killed the run, preceded in the (newest-first) timeline
+ // by a block that still ran after it — so the last frame is NOT the failure.
+ function seedFailedCodeRun(
+ blockFailureReason = "CodeBlock failed with NameError at line 6: name 'min' is not defined.",
+ errorCode = "user_code_error",
+ ) {
+ seedCompletedRun({
+ status: Status.Failed,
+ failure_reason: `code block failed. failure reason: ${blockFailureReason}`,
+ });
+ mocks.timeline = [
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_cleanup",
+ label: "cleanup",
+ status: Status.Completed,
+ actions: [buildAction({ action_id: "act_cleanup", action_order: 0 })],
+ }),
+ ),
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_code",
+ label: "scrape-prices",
+ block_type: "code",
+ status: Status.Failed,
+ error_codes: [errorCode],
+ failure_reason: blockFailureReason,
+ }),
+ ),
+ ];
+ }
+
+ test("leads with the failure headline and working Fix and Retry CTAs", () => {
seedCompletedRun({
status: Status.Failed,
failure_reason: "Login page rejected the credentials",
});
const onFix = vi.fn();
const onRetry = vi.fn();
- const { container } = renderRunView({ onFix, onRetry });
- const scope = within(container);
+ const { container, getByTestId } = renderRunView({ onFix, onRetry });
+ const line = within(getByTestId("run-failure-line"));
expect(
- scope.getByText("Login page rejected the credentials"),
+ line.getByText("Login page rejected the credentials"),
).not.toBeNull();
-
- fireEvent.click(scope.getByRole("button", { name: "Fix with Copilot" }));
+ fireEvent.click(line.getByRole("button", { name: "Fix with Copilot" }));
expect(onFix).toHaveBeenCalledTimes(1);
- expect(onFix.mock.calls[0]?.[0]).toContain(
- "Login page rejected the credentials",
- );
-
- fireEvent.click(scope.getByRole("button", { name: "Retry" }));
+ fireEvent.click(line.getByRole("button", { name: "Retry" }));
expect(onRetry).toHaveBeenCalledTimes(1);
+ // The card is gone: nothing on the page announces itself as an alert.
+ expect(within(container).queryByRole("alert")).toBeNull();
});
test("Fix passes the failing block's label alongside the seed message", () => {
@@ -1006,64 +1035,64 @@ describe("RunView failure banner", () => {
expect(onFix.mock.calls[0]?.[1]).toBe("checkout");
});
- test("splits the banner into a headline and de-emphasized detail", () => {
+ test("keeps the technical detail one hover away from the headline", () => {
seedCompletedRun({
status: Status.Failed,
failure_reason:
- "for_loop block failed. failure reason: Failed to execute code block. Reason: Exception: boom",
+ "for_loop block failed. failure reason: Failed to execute code block. Reason: Exception: boom\\n\\tstack trace",
});
- const { container } = renderRunView();
- const scope = within(container);
+ const { getByTestId } = renderRunView();
+ const line = within(getByTestId("run-failure-line"));
- const headline = scope.getByText("for_loop block failed");
- expect(headline.className).toContain("font-semibold");
- expect(
- scope.getByText(/Failed to execute code block\. Reason: Exception: boom/),
- ).not.toBeNull();
- // Short detail → no expand toggle.
- expect(scope.queryByRole("button", { name: "Show more" })).toBeNull();
+ const headline = line.getByText("for_loop block failed");
+ expect(headline.getAttribute("title")).toContain(
+ "Exception: boom\n stack trace",
+ );
+ expect(headline.getAttribute("title")).not.toContain("\\n");
+ expect(headline.getAttribute("title")).not.toContain("\\t");
+ expect(line.queryByText(/Exception: boom/)).toBeNull();
});
- test("long failure detail clamps behind a Show more toggle", () => {
+ test("shows no failure line for a user-canceled run", () => {
seedCompletedRun({
- status: Status.Failed,
- failure_reason: `for_loop block failed. failure reason: ${"x".repeat(300)}`,
+ status: Status.Canceled,
+ failure_reason: "canceled by user",
});
- const { container } = renderRunView();
+ const { container, queryByTestId } = renderRunView();
const scope = within(container);
- const detail = scope.getByText(/^x+$/);
- expect(detail.className).toContain("line-clamp-3");
- fireEvent.click(scope.getByRole("button", { name: "Show more" }));
- expect(scope.getByText(/^x+$/).className).not.toContain("line-clamp-3");
- fireEvent.click(scope.getByRole("button", { name: "Show less" }));
- expect(scope.getByText(/^x+$/).className).toContain("line-clamp-3");
+ expect(scope.queryByText("canceled by user")).toBeNull();
+ expect(queryByTestId("run-failure-line")).toBeNull();
});
- test("dismiss hides the failure banner", () => {
- seedCompletedRun({
- status: Status.Failed,
- failure_reason: "Something broke",
+ test("the block name jumps to the failing block, whose detail carries the expansion", () => {
+ seedFailedCodeRun();
+ const { container, getByTestId } = renderRunView({
+ onFix: vi.fn(),
+ onRetry: vi.fn(),
});
- const { container } = renderRunView();
- const scope = within(container);
+ const line = within(getByTestId("run-failure-line"));
- fireEvent.click(scope.getByRole("button", { name: "Dismiss" }));
- expect(scope.queryByText("Something broke")).toBeNull();
- });
+ expect(
+ line.getByText("— The block's code raised NameError"),
+ ).not.toBeNull();
+ // One line at run level: badges and the disclosure live on the block.
+ expect(line.queryByText("Line 6")).toBeNull();
+ expect(line.queryByText("Technical details")).toBeNull();
- test("no failure banner for a user-canceled run", () => {
- seedCompletedRun({
- status: Status.Canceled,
- failure_reason: "canceled by user",
- });
- const { container } = renderRunView();
- const scope = within(container);
+ fireEvent.click(line.getByRole("button", { name: "scrape-prices" }));
- expect(scope.queryByText("canceled by user")).toBeNull();
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code");
+ const scope = within(container);
+ expect(scope.getByText("Line 6")).not.toBeNull();
+ expect(scope.getByText("Error code user_code_error")).not.toBeNull();
+ expect(
+ scope.getByText(/Open the block and fix the line that raised/),
+ ).not.toBeNull();
+ expect(scope.getByText("Technical details")).not.toBeNull();
});
- test("a code block failure leads with its error state, line and guidance", () => {
+ test("the detail expands the line without restating it", () => {
seedCompletedRun({
status: Status.Failed,
failure_reason:
@@ -1073,33 +1102,94 @@ describe("RunView failure banner", () => {
buildBlockItem(
buildBlock({
workflow_run_block_id: "wrb_code",
+ label: "scrape-prices",
block_type: "code",
status: Status.Failed,
error_codes: ["user_code_error"],
failure_reason:
"CodeBlock failed with NameError at line 6: name 'min' is not defined.",
+ actions: [
+ buildAction({
+ action_id: "act_fail",
+ action_order: 1,
+ status: Status.Failed,
+ }),
+ buildAction({ action_id: "act_ok", action_order: 0 }),
+ ],
}),
),
];
- const { container } = renderRunView({ onFix: vi.fn(), onRetry: vi.fn() });
- const banner = within(within(container).getByRole("alert"));
+ const { container } = renderRunView(
+ { onFix: vi.fn(), onRetry: vi.fn() },
+ "/?wr=wr_1",
+ );
+ const scope = within(container);
+ // Pinned on the failing block: the title lives on the line only; the
+ // detail keeps guidance, badges and the disclosure.
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code");
expect(
- banner.getByText("The block's code raised NameError"),
- ).not.toBeNull();
- expect(banner.getByText("Line 6")).not.toBeNull();
- expect(banner.getByText("Error code user_code_error")).not.toBeNull();
- expect(
- banner.getByText(/Open the block and fix the line that raised/),
+ scope.getByText("— The block's code raised NameError"),
).not.toBeNull();
- expect(banner.getByText("Technical details")).not.toBeNull();
- // A code defect is still the author's to fix, so both CTAs stay.
+ expect(scope.queryByText("The block's code raised NameError")).toBeNull();
expect(
- banner.getByRole("button", { name: "Fix with Copilot" }),
+ scope.getByText(/Open the block and fix the line that raised/),
).not.toBeNull();
+ expect(scope.getByText("Line 6")).not.toBeNull();
+
+ // Reached through one of its action rows, the block's failure still expands
+ // (SKY-12240 keeps it on every action's Summary) and still skips the title.
+ for (const actionId of ["act_ok", "act_fail"]) {
+ act(() => useRunViewStore.getState().pinFrame(actionId));
+ expect(scope.getByText("Failure")).not.toBeNull();
+ expect(scope.getByText("Line 6")).not.toBeNull();
+ expect(scope.queryByText("The block's code raised NameError")).toBeNull();
+ }
+ });
+
+ test("a failed run's deep link lands on the failing block, not the last item", () => {
+ seedFailedCodeRun();
+ renderRunView({}, "/?wr=wr_1");
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code");
+ });
+
+ test("a failed latest-run Studio open lands on the failing block", () => {
+ seedFailedCodeRun();
+ const { getByTestId } = renderRunView();
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code");
+ expect(getByTestId("location-search").textContent).toContain(
+ "active=wrb_code",
+ );
+ });
+
+ test("a finally-only failure keeps its strip label and jump", () => {
+ seedCompletedRun({
+ status: Status.Failed,
+ failure_reason: "cleanup failed: Invalid master password",
+ workflow: {
+ workflow_definition: { blocks: [], finally_block_label: "cleanup" },
+ },
+ });
+ mocks.timeline = [
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_cleanup",
+ label: "cleanup",
+ status: Status.Failed,
+ failure_reason: "cleanup failed: Invalid master password",
+ }),
+ ),
+ ];
+
+ const { getByTestId } = renderRunView();
+ const line = within(getByTestId("run-failure-line"));
+ fireEvent.click(line.getByRole("button", { name: "cleanup" }));
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_cleanup");
});
- test("opens the Browser pane and pins the failed block when a capture exists", async () => {
+ test("the block detail's screenshot action opens the Browser pane and pins the block", async () => {
getSpy.mockResolvedValue({
data: [
{
@@ -1114,37 +1204,24 @@ describe("RunView failure banner", () => {
},
],
});
- seedCompletedRun({
- status: Status.Failed,
- failure_reason:
- "code block failed. failure reason: CodeBlock failed because a browser operation failed at line 4.",
- });
- mocks.timeline = [
- buildBlockItem(
- buildBlock({
- workflow_run_block_id: "wrb_failed",
- block_type: "code",
- status: Status.Failed,
- error_codes: ["browser_operation_failed"],
- failure_reason:
- "CodeBlock failed because a browser operation failed at line 4.",
- }),
- ),
- ];
+ seedFailedCodeRun(
+ "CodeBlock failed because a browser operation failed at line 4.",
+ "browser_operation_failed",
+ );
+ const { container, getByTestId } = renderRunView({}, "/?wr=wr_1");
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code");
- const { container, getByTestId } = renderRunView();
- const banner = within(within(container).getByRole("alert"));
fireEvent.click(
- await banner.findByRole("button", { name: "View block screenshot" }),
+ await within(container).findByRole("button", {
+ name: "View block screenshot",
+ }),
);
await waitFor(() =>
expect(getByTestId("location-search").textContent).toContain("browser"),
);
- // The pin drives ?active=, and the Browser pane's view machine lands a
- // scrubbed/failed run on Screenshots (see browserPaneView.test.ts).
await waitFor(() =>
- expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_failed"),
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code"),
);
});
@@ -1170,11 +1247,12 @@ describe("RunView failure banner", () => {
const { container, getByTestId } = renderRunView(
{ onFix: vi.fn(), onRetry: vi.fn() },
- "/",
+ "/?wr=wr_1",
false,
<ArtifactsQueryProbe workflowRunBlockId="wrb_failed" />,
);
- const banner = within(within(container).getByRole("alert"));
+ const line = within(getByTestId("run-failure-line"));
+ const scope = within(container);
// The link is also absent while the artifact query is in flight, so wait
// for the empty result to reach the DOM, not just for the request to start.
await waitFor(() =>
@@ -1184,49 +1262,34 @@ describe("RunView failure banner", () => {
// Absent from the a11y tree entirely, disabled included: a link into an
// empty Browser pane is worse than no link.
expect(
- banner.queryByRole("button", {
+ scope.queryByRole("button", {
name: "View block screenshot",
hidden: true,
}),
).toBeNull();
- expect(banner.getByRole("button", { name: "Retry" })).not.toBeNull();
+ expect(line.getByRole("button", { name: "Retry" })).not.toBeNull();
});
test("a sandbox fault offers a retry instead of a copilot fix", () => {
- seedCompletedRun({
- status: Status.Failed,
- failure_reason:
- "code block failed. failure reason: Secure CodeBlock runner is unavailable. Please retry.",
- });
- mocks.timeline = [
- buildBlockItem(
- buildBlock({
- workflow_run_block_id: "wrb_code",
- block_type: "code",
- status: Status.Failed,
- error_codes: ["runner_unavailable"],
- failure_reason:
- "Secure CodeBlock runner is unavailable. Please retry.",
- }),
- ),
- ];
+ seedFailedCodeRun(
+ "Secure CodeBlock runner is unavailable. Please retry.",
+ "runner_unavailable",
+ );
const onFix = vi.fn();
const onRetry = vi.fn();
- const { container } = renderRunView({ onFix, onRetry });
- const banner = within(within(container).getByRole("alert"));
+ const { getByTestId } = renderRunView({ onFix, onRetry });
+ const line = within(getByTestId("run-failure-line"));
- expect(banner.getByText("The code sandbox was unreachable")).not.toBeNull();
- expect(
- banner.queryByRole("button", { name: "Fix with Copilot" }),
- ).toBeNull();
+ expect(line.getByText("— The code sandbox was unreachable")).not.toBeNull();
+ expect(line.queryByRole("button", { name: "Fix with Copilot" })).toBeNull();
- const retry = banner.getByRole("button", { name: "Retry" });
+ const retry = line.getByRole("button", { name: "Retry" });
expect(retry.className).toContain("bg-cta");
fireEvent.click(retry);
expect(onRetry).toHaveBeenCalledTimes(1);
});
- test("a code block that continued on failure does not retitle the banner", () => {
+ test("a code block that continued on failure does not retitle the line", () => {
seedCompletedRun({
status: Status.Failed,
failure_reason: "task block failed. failure reason: Login rejected",
@@ -1244,30 +1307,137 @@ describe("RunView failure banner", () => {
}),
),
];
- const { container } = renderRunView();
- const banner = within(within(container).getByRole("alert"));
+ const { getByTestId } = renderRunView();
+ const line = within(getByTestId("run-failure-line"));
- expect(banner.getByText("task block failed")).not.toBeNull();
- expect(banner.queryByText("The code sandbox was unreachable")).toBeNull();
+ expect(line.getByText("task block failed")).not.toBeNull();
+ expect(line.queryByText(/code sandbox was unreachable/)).toBeNull();
});
- test("hides the run failure banner outside the Timeline view", () => {
+ test("hides the failure line outside the Timeline view", () => {
seedCompletedRun({
status: Status.Failed,
failure_reason: "Login page rejected the credentials",
});
- const { container } = renderRunView();
+ const { container, queryByTestId } = renderRunView();
const scope = within(container);
- // Visible on the default Timeline view.
expect(
scope.getByText("Login page rejected the credentials"),
).not.toBeNull();
- // Switching to another tab hides the run-level failure banner.
fireEvent.click(scope.getByRole("button", { name: "Outputs" }));
+ expect(queryByTestId("run-failure-line")).toBeNull();
expect(scope.queryByText("Login page rejected the credentials")).toBeNull();
});
+
+ test("an unlabeled failed block remains the deep-link and strip recovery target", () => {
+ seedCompletedRun({
+ status: Status.Failed,
+ failure_reason: "Login page rejected the credentials",
+ });
+ mocks.timeline = [
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_unlabeled",
+ label: null,
+ status: Status.Failed,
+ failure_reason: "Login page rejected the credentials",
+ }),
+ ),
+ ];
+ const { container, getByTestId } = renderRunView(
+ { onFix: vi.fn(), onRetry: vi.fn() },
+ "/?wr=wr_1",
+ );
+ const line = within(getByTestId("run-failure-line"));
+ const scope = within(container);
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_unlabeled");
+ expect(
+ line.getByRole("button", { name: "Fix with Copilot" }),
+ ).not.toBeNull();
+ expect(line.getByRole("button", { name: "Retry" })).not.toBeNull();
+ // The pinned block's own reason is identical to the run's, so it's fully
+ // stated on the strip already: the block detail must not repeat it.
+ expect(
+ scope.getAllByText("Login page rejected the credentials"),
+ ).toHaveLength(1);
+ expect(scope.queryByText("Failure")).toBeNull();
+ });
+
+ test("a block reason that diverges from the run's own headline is never dropped", () => {
+ seedCompletedRun({
+ status: Status.Failed,
+ failure_reason: "Task failed",
+ });
+ mocks.timeline = [
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_mismatch",
+ label: "submit-form",
+ status: Status.Failed,
+ failure_reason: "POST returned 401. The token expired.",
+ }),
+ ),
+ ];
+ const { container } = renderRunView(
+ { onFix: vi.fn(), onRetry: vi.fn() },
+ "/?wr=wr_1",
+ );
+ const scope = within(container);
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_mismatch");
+ // The strip states the run's own generic headline ("Task failed"); the
+ // pinned block's more specific reason was never actually shown there,
+ // so the detail panel must still say it in full.
+ expect(
+ scope.getByText("POST returned 401. The token expired."),
+ ).not.toBeNull();
+ });
+
+ test("a non-culprit failed block is never suppressed just because its headline text matches", () => {
+ seedCompletedRun({
+ status: Status.Failed,
+ failure_reason: "Network timeout",
+ });
+ mocks.timeline = [
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_early",
+ label: "flaky-request",
+ status: Status.Failed,
+ continue_on_failure: true,
+ failure_reason: "Network timeout",
+ }),
+ ),
+ buildBlockItem(
+ buildBlock({
+ workflow_run_block_id: "wrb_last",
+ label: "final-request",
+ status: Status.Failed,
+ failure_reason: "Network timeout",
+ }),
+ ),
+ ];
+ const { container } = renderRunView(
+ { onFix: vi.fn(), onRetry: vi.fn() },
+ "/?wr=wr_1",
+ );
+
+ // Auto-pin lands on the culprit — the strip's headline is about this
+ // block, so its own identical reason is correctly suppressed.
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_last");
+ expect(within(container).queryByText("Failure")).toBeNull();
+
+ // Navigating to the earlier continue_on_failure block, whose parsed
+ // headline happens to be the same text, must NOT suppress it: the
+ // strip never actually described this block.
+ act(() => useRunViewStore.getState().pinFrame("wrb_early"));
+ const scope = within(container);
+ expect(scope.getByText("Failure")).not.toBeNull();
+ expect(scope.getByText("Network timeout")).not.toBeNull();
+ });
});
describe("RunView live affordances", () => {
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
index 6902db539..fcf2a118d 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
@@ -1,17 +1,8 @@
import { useEffect, useMemo, useRef, useState } from "react";
-import {
- Cross2Icon,
- ExclamationTriangleIcon,
- ImageIcon,
- MagicWandIcon,
- MagnifyingGlassIcon,
- ReloadIcon,
-} from "@radix-ui/react-icons";
+import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
import { Status } from "@/api/types";
-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
-import { Button } from "@/components/ui/button";
import {
Command,
CommandEmpty,
@@ -38,7 +29,7 @@ import {
type WorkflowRunMilestoneCardProps,
usePageSlots,
} from "@/store/PageSlots";
-import { cn, isRecord } from "@/util/utils";
+import { isRecord } from "@/util/utils";
import { useWorkflowRunTimelineQuery } from "../../hooks/useWorkflowRunTimelineQuery";
import { useWorkflowRunWithWorkflowQuery } from "../../hooks/useWorkflowRunWithWorkflowQuery";
@@ -47,12 +38,7 @@ import { WorkflowRunBlockDetail } from "../../workflowRun/WorkflowRunBlockDetail
import { WorkflowRunCode } from "../../workflowRun/WorkflowRunCode";
import { WorkflowRunTimeline } from "../../workflowRun/WorkflowRunTimeline";
import { WorkflowRunVerificationCodeForm } from "../../workflowRun/WorkflowRunVerificationCodeForm";
-import { CodeBlockFailureDetails } from "../../workflowRun/CodeBlockFailureDetails";
-import {
- failureSupportsScreenshot,
- findRunCodeBlockFailure,
-} from "../../workflowRun/codeBlockFailure";
-import { useBlockScreenshot } from "../../workflowRun/useBlockScreenshot";
+import { findRunCodeBlockFailure } from "../../workflowRun/codeBlockFailure";
import { pickDownloadedFileFilename } from "../../workflowRun/blockDownloadedFiles";
import {
buildBlockOrderIndex,
@@ -72,10 +58,7 @@ import {
import { searchWithRunReference, toReadableSearch } from "../panes";
import { useStudioPanes } from "../useStudioPanes";
import { collectBlockPrompts } from "./blockPrompts";
-import {
- failureDetailIsLong,
- formatFailureReason,
-} from "./failureReasonFormat";
+import { formatFailureReason } from "../../workflowRun/failureReasonFormat";
import { matchFailureTips } from "./failureTips";
import { buildRunFixMessage } from "./runFixMessage";
import { RunInputsSection, type RunInputMeta } from "./RunInputsSection";
@@ -84,10 +67,14 @@ import {
type RunOutputError,
type RunOutputFile,
} from "./RunOutputsSection";
-import { failingBlockLabel } from "./failingBlock";
+import { failingBlock } from "./failingBlock";
import { RunPlaceholder } from "./RunPlaceholder";
import { RunSummaryStrip } from "./RunSummaryStrip";
import { type WorkflowRunBlock } from "../../types/workflowRunTypes";
+import {
+ FailureRecoveryActions,
+ RunFailureLine,
+} from "./RunFailurePresentation";
import { resolveEditorSelectionPin } from "./editorSelectionPin";
import { resolveTimelineBlockJumpNodeId } from "./timelineBlockJump";
@@ -236,8 +223,6 @@ export function RunView({
searchParamsRef.current = searchParams;
const view = useRunPaneViewStore((s) => s.view);
const resetPaneView = useRunPaneViewStore((s) => s.reset);
- const [failureDismissed, setFailureDismissed] = useState(false);
- const [failureDetailExpanded, setFailureDetailExpanded] = useState(false);
const [outputSummary, setOutputSummary] = useState<string | null>(null);
// Last editor selection the canvas→run sync below acted on.
@@ -249,8 +234,6 @@ export function RunView({
resetRunView();
setOutputSummary(null);
resetPaneView();
- setFailureDismissed(false);
- setFailureDetailExpanded(false);
const active = searchParamsRef.current.get("active");
if (active) {
pinFrame(active);
@@ -336,6 +319,33 @@ export function RunView({
);
const lastFrame = frames.length > 0 ? frames[frames.length - 1] : null;
+ const outcome = runOutcomeFromStatus(workflowRun?.status);
+ // A user-canceled run isn't a failure — don't show the "run failed" CTA.
+ const canceled = workflowRun?.status === Status.Canceled;
+ const failed = !statusUnavailable && outcome === "failed" && !canceled;
+ const finalized =
+ !statusUnavailable && workflowRun ? statusIsFinalized(workflowRun) : false;
+ useLiveClock(Boolean(workflowRun) && !finalized && !statusUnavailable);
+ const finallyBlockLabel =
+ workflowRun?.workflow?.workflow_definition?.finally_block_label ?? null;
+ const codeFailure = useMemo(
+ () =>
+ findRunCodeBlockFailure(
+ workflowRun?.failure_reason,
+ timeline,
+ finallyBlockLabel,
+ ),
+ [workflowRun?.failure_reason, timeline, finallyBlockLabel],
+ );
+ const failedBlock = useMemo(
+ () => failingBlock(timeline, finallyBlockLabel),
+ [timeline, finallyBlockLabel],
+ );
+ const failureBlockId =
+ codeFailure?.workflowRunBlockId ??
+ failedBlock?.workflow_run_block_id ??
+ null;
+
// Landing the selection on the LAST timeline item — so the Browser pane
// shows the final screenshot instead of an idle replay — happens on two
// paths sharing this one-shot: cold-opening a deep link to an already-
@@ -374,7 +384,13 @@ export function RunView({
// matching path id is the focused deep link too (parity with ?wr= cold open).
const isFocusedDeepLink =
params.get("wr") === workflowRunId || pathRunId === workflowRunId;
- if (!isFocusedDeepLink || params.get("active")) {
+ // The normal Studio route resolves the latest run without naming it in the
+ // URL. For failures, give its strip the same zero-click failed-block target.
+ const isLatestRunRoute = !params.get("wr") && !pathRunId;
+ if (
+ (!isFocusedDeepLink && !(failed && isLatestRunRoute)) ||
+ params.get("active")
+ ) {
return;
}
if (params.has("bl")) {
@@ -390,30 +406,28 @@ export function RunView({
if (watchedLive && useStudioBrowserStore.getState().view !== "auto") {
return;
}
+ // A failed run lands on the block that killed it, so its Failure section
+ // is on screen with zero clicks; anything else lands on the last item so
+ // the Browser pane shows the final screenshot.
const last = frames.length > 0 ? frames[frames.length - 1] : null;
- if (last) {
- pinFrame(last.id);
+ const target =
+ failed && failureBlockId ? failureBlockId : (last?.id ?? null);
+ if (target) {
+ pinFrame(target);
}
}, [
workflowRunId,
workflowRun,
timeline,
frames,
+ failed,
+ failureBlockId,
pinFrame,
pathRunId,
runIsPlaceholder,
timelineIsPlaceholder,
]);
- const outcome = runOutcomeFromStatus(workflowRun?.status);
- // A user-canceled run isn't a failure — don't show the "run failed" CTA.
- const canceled = workflowRun?.status === Status.Canceled;
- const failed = !statusUnavailable && outcome === "failed" && !canceled;
- const finalized =
- !statusUnavailable && workflowRun ? statusIsFinalized(workflowRun) : false;
- useLiveClock(Boolean(workflowRun) && !finalized && !statusUnavailable);
- const finallyBlockLabel =
- workflowRun?.workflow?.workflow_definition?.finally_block_label ?? null;
// This pane never hosts the live stream, so a "stream" pin (or no pin) follows
// the live edge — the same resolution the Browser pane applies in useRunVisuals.
const selectedId =
@@ -470,22 +484,6 @@ export function RunView({
[workflowRun?.failure_reason],
);
- const codeFailure = useMemo(
- () =>
- findRunCodeBlockFailure(
- workflowRun?.failure_reason,
- timeline,
- finallyBlockLabel,
- ),
- [workflowRun?.failure_reason, timeline, finallyBlockLabel],
- );
-
- const failureScreenshot = useBlockScreenshot(
- codeFailure?.workflowRunBlockId,
- "code",
- codeFailure !== null && failureSupportsScreenshot(codeFailure),
- );
-
const extractedInformation = useMemo<Record<string, unknown> | null>(() => {
const outputs = workflowRun?.outputs;
return isRecord(outputs) && "extracted_information" in outputs
@@ -633,138 +631,35 @@ export function RunView({
const failureReason = formatFailureReason(
workflowRun.failure_reason ?? "The run failed.",
);
- const failureDetailLong = failureReason.detail
- ? failureDetailIsLong(failureReason.detail)
- : false;
- const codeFailureDetail = codeFailure
- ? (failureReason.detail ?? workflowRun.failure_reason?.trim() ?? null)
- : null;
+ const failureHeadline = codeFailure
+ ? codeFailure.title
+ : failureReason.headline;
+ const failureDetail = failureReason.detail;
+ const failureTips = matchFailureTips(workflowRun.failure_reason ?? null);
// Editing code cannot reach a sandbox that was never available, so a fault the
// block did not cause offers a retry alone rather than a copilot session that
// would rewrite working code.
const showFix = codeFailure === null || codeFailure.recovery !== "retry";
const hasFixAction = Boolean(onFix && showFix);
+ const recovery = failed ? (
+ <FailureRecoveryActions
+ onFix={
+ onFix && hasFixAction
+ ? () => onFix(fixSeedMessage, failedBlock?.label ?? null)
+ : undefined
+ }
+ onRetry={onRetry}
+ />
+ ) : null;
+ const jumpToFailedBlock = failedBlock
+ ? () => selectTimelineBlock(failedBlock)
+ : undefined;
return (
<div className="flex h-full min-h-0 min-w-0 flex-col gap-2 overflow-hidden p-2">
<WorkflowRunVerificationCodeForm
workflowRunId={workflowRun.workflow_run_id}
/>
- {failed && !failureDismissed && view === "timeline" ? (
- <Alert className="shrink-0 border-destructive/40 bg-destructive/5 py-3.5 dark:bg-destructive/10 [&>svg]:text-destructive">
- <ExclamationTriangleIcon className="h-4 w-4" />
- <div className="min-w-0 pr-6">
- <AlertTitle className="mb-0 text-sm font-semibold leading-5 text-foreground">
- {codeFailure ? codeFailure.title : failureReason.headline}
- </AlertTitle>
- <AlertDescription className="mt-1 text-xs leading-relaxed text-muted-foreground">
- {codeFailure ? <p>{codeFailure.guidance}</p> : null}
- {codeFailure ? (
- <CodeBlockFailureDetails
- failure={codeFailure}
- reason={codeFailureDetail}
- />
- ) : failureReason.detail ? (
- <>
- <p
- className={cn(
- "mt-1 whitespace-pre-wrap break-words text-xs leading-relaxed text-muted-foreground",
- !failureDetailExpanded && "line-clamp-3",
- )}
- >
- {failureReason.detail}
- </p>
- {failureDetailLong ? (
- <button
- type="button"
- onClick={() => setFailureDetailExpanded((v) => !v)}
- className="mt-1 text-xs font-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
- >
- {failureDetailExpanded ? "Show less" : "Show more"}
- </button>
- ) : null}
- </>
- ) : null}
- {matchFailureTips(workflowRun.failure_reason ?? null).map(
- (tip) => (
- <span
- key={tip}
- className="mt-1.5 block text-xs italic text-muted-foreground"
- >
- {tip}
- </span>
- ),
- )}
- {hasFixAction || onRetry || failureScreenshot ? (
- <div className="mt-3 flex flex-wrap gap-2">
- {onFix && showFix ? (
- <Button
- size="sm"
- onClick={() =>
- onFix(
- fixSeedMessage,
- failingBlockLabel(timeline, finallyBlockLabel),
- )
- }
- >
- <MagicWandIcon
- className="mr-1.5 h-3.5 w-3.5"
- aria-hidden="true"
- />
- Fix with Copilot
- </Button>
- ) : null}
- {onRetry ? (
- <Button
- size="sm"
- variant={hasFixAction ? "secondary" : "default"}
- onClick={onRetry}
- >
- <ReloadIcon
- className="mr-1.5 h-3.5 w-3.5"
- aria-hidden="true"
- />
- Retry
- </Button>
- ) : null}
- {failureScreenshot && codeFailure ? (
- <Button
- size="sm"
- variant={
- hasFixAction || onRetry ? "secondary" : "default"
- }
- onClick={() => {
- openPane("browser");
- // Let the pane-open navigation commit before mirroring
- // the pin. Otherwise the pin's URL writer can drop
- // `browser`.
- requestAnimationFrame(() =>
- pinFrame(codeFailure.workflowRunBlockId),
- );
- }}
- >
- <ImageIcon
- className="mr-1.5 h-3.5 w-3.5"
- aria-hidden="true"
- />
- View block screenshot
- </Button>
- ) : null}
- </div>
- ) : null}
- </AlertDescription>
- <button
- type="button"
- onClick={() => setFailureDismissed(true)}
- className="absolute right-2 top-2 shrink-0 rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
- aria-label="Dismiss"
- title="Dismiss"
- >
- <Cross2Icon className="h-4 w-4" />
- </button>
- </div>
- </Alert>
- ) : null}
{WorkflowRunMilestoneCard &&
runPaneOpen &&
!runIsPlaceholder &&
@@ -790,6 +685,17 @@ export function RunView({
/>
}
/>
+ {failed ? (
+ <RunFailureLine
+ blockLabel={failedBlock?.label ?? null}
+ headline={failureHeadline}
+ detail={failureDetail}
+ onJump={jumpToFailedBlock}
+ tips={failureTips}
+ >
+ {recovery}
+ </RunFailureLine>
+ ) : null}
<ResizableTimelineSplit
className="flex-1"
top={
@@ -830,6 +736,14 @@ export function RunView({
showDownloadedFiles
workflowRunId={workflowRunId}
onThoughtSelect={(thought) => pinFrame(thought.thought_id)}
+ onViewScreenshot={(workflowRunBlockId) => {
+ openPane("browser");
+ // Let the pane-open navigation commit before mirroring the
+ // pin; otherwise the pin's URL writer can drop `browser`.
+ requestAnimationFrame(() => pinFrame(workflowRunBlockId));
+ }}
+ statedFailureBlockId={failed ? failureBlockId : null}
+ statedFailureHeadline={failed ? failureHeadline : null}
/>
</div>
}
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.test.ts b/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.test.ts
index 0e1f3c2f0..b19a1c5d8 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.test.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, test } from "vitest";
import { Status } from "@/api/types";
import { type WorkflowRunTimelineItem } from "@/routes/workflows/types/workflowRunTypes";
-import { failingBlockLabel } from "./failingBlock";
+import { failingBlock } from "./failingBlock";
function blockItem(
label: string | null,
@@ -27,51 +27,58 @@ function blockItem(
} as unknown as WorkflowRunTimelineItem;
}
-describe("failingBlockLabel", () => {
- test("names the failed block", () => {
- expect(
- failingBlockLabel([
- blockItem("login", Status.Completed),
- blockItem("checkout", Status.Failed),
- ]),
- ).toBe("checkout");
+describe("failingBlock", () => {
+ test("returns the failed block", () => {
+ const timeline = [
+ blockItem("login", Status.Completed),
+ blockItem("checkout", Status.Failed),
+ ];
+
+ expect(failingBlock(timeline)?.workflow_run_block_id).toBe("wrb_checkout");
});
- test("skips continue-on-failure blocks — they cannot end a run", () => {
+ test("skips continue-on-failure blocks", () => {
expect(
- failingBlockLabel([
+ failingBlock([
blockItem("checkout", Status.Failed),
blockItem("optional", Status.Failed, true),
- ]),
+ ])?.label,
).toBe("checkout");
});
- test("finds a failure nested in a container", () => {
+ test("finds a nested failure", () => {
expect(
- failingBlockLabel([
+ failingBlock([
blockItem("loop", Status.Failed, false, [
blockItem("search", Status.Failed),
]),
- ]),
+ ])?.label,
).toBe("search");
});
- test("skips the finally block, which runs after the real failure", () => {
+ test("prefers a pre-finally failure but keeps a finally-only target", () => {
expect(
- failingBlockLabel(
+ failingBlock(
[
blockItem("checkout", Status.Failed),
blockItem("cleanup", Status.Failed),
],
"cleanup",
- ),
+ )?.label,
).toBe("checkout");
+ expect(
+ failingBlock([blockItem("cleanup", Status.Failed)], "cleanup")?.label,
+ ).toBe("cleanup");
});
- test("null for a clean or absent timeline", () => {
+ test("keeps an unlabeled failed block as the recovery target", () => {
expect(
- failingBlockLabel([blockItem("login", Status.Completed)]),
- ).toBeNull();
- expect(failingBlockLabel(undefined)).toBeNull();
+ failingBlock([blockItem(null, Status.Failed)])?.workflow_run_block_id,
+ ).toBe("wrb_anon");
+ });
+
+ test("returns null for a clean or absent timeline", () => {
+ expect(failingBlock([blockItem("login", Status.Completed)])).toBeNull();
+ expect(failingBlock(undefined)).toBeNull();
});
});
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.ts b/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.ts
index 972ee79f4..736d403f4 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/failingBlock.ts
@@ -1,41 +1,45 @@
import { statusIsAFailureType } from "@/routes/tasks/types";
import {
isBlockItem,
+ type WorkflowRunBlock,
type WorkflowRunTimelineItem,
} from "@/routes/workflows/types/workflowRunTypes";
import { flattenTimelineChronologically } from "@/routes/workflows/workflowRun/workflowTimelineUtils";
/**
- * The labeled block the run died on: the last failed block in walk order that
+ * The block the run died on: the last failed block in walk order that
* was allowed to end the run (continue_on_failure blocks can't). The walk takes
* top-level items oldest-first and descends into each before moving on, so a
* failed container yields to its failing leaf. That ordering is what makes the
* last match the culprit — a run stops at the block that killed it, so there is
* normally only one.
*
- * The finally block is excluded because it runs AFTER the failure and can fail
- * on its own; the run's failure_reason (which seeds the copilot message) is the
- * pre-finally one, so counting it would name a block the message never mentions.
+ * Prefer the pre-finally failure: a finally block may run after it and fail on
+ * its own. If there is no earlier failure, though, the failed finally block is
+ * the only useful jump target.
*/
-export function failingBlockLabel(
+export function failingBlock(
timeline: ReadonlyArray<WorkflowRunTimelineItem> | undefined,
finallyBlockLabel: string | null = null,
-): string | null {
+): WorkflowRunBlock | null {
if (!timeline) {
return null;
}
- let found: string | null = null;
+ let found: WorkflowRunBlock | null = null;
+ let finallyFailure: WorkflowRunBlock | null = null;
const walk = (items: ReadonlyArray<WorkflowRunTimelineItem>): void => {
for (const item of items) {
if (
isBlockItem(item) &&
- item.block.label &&
- item.block.label !== finallyBlockLabel &&
item.block.status &&
statusIsAFailureType({ status: item.block.status }) &&
!item.block.continue_on_failure
) {
- found = item.block.label;
+ if (finallyBlockLabel && item.block.label === finallyBlockLabel) {
+ finallyFailure = item.block;
+ } else {
+ found = item.block;
+ }
}
if (item.children.length > 0) {
walk(item.children);
@@ -43,5 +47,5 @@ export function failingBlockLabel(
}
};
walk(flattenTimelineChronologically([...timeline]));
- return found;
+ return found ?? finallyFailure;
}
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx
index b7d0d86f6..3a79eb266 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/WorkflowRunBlockDetail.tsx
@@ -48,6 +48,14 @@ type Props = {
workflowRunId?: string;
onThoughtSelect?: (thought: ObserverThought) => void;
onViewScreenshot?: (workflowRunBlockId: string) => void;
+ // The block the run-level line's headline is actually about, and that
+ // headline's exact text. Both must match — the ID alone (a block can fail
+ // with different text than the run's own failure_reason) and the text
+ // alone (an unrelated block, e.g. an earlier continue_on_failure failure,
+ // can coincidentally parse to the same headline) are each insufficient on
+ // their own to say "the line already stated this."
+ statedFailureBlockId?: string | null;
+ statedFailureHeadline?: string | null;
};
function BlockDownloadedFiles({
@@ -154,6 +162,8 @@ function WorkflowRunBlockDetail({
workflowRunId,
onThoughtSelect,
onViewScreenshot,
+ statedFailureBlockId = null,
+ statedFailureHeadline = null,
}: Props) {
// activeIteration is a URL hint scoped to a specific selection. In
// fallback mode (null or "stream") the resolved block may not be the
@@ -263,6 +273,11 @@ function WorkflowRunBlockDetail({
? () => onViewScreenshot(resolvedBlock.workflow_run_block_id)
: undefined
}
+ statedFailureHeadline={
+ resolvedBlock.workflow_run_block_id === statedFailureBlockId
+ ? statedFailureHeadline
+ : null
+ }
/>
)}
{resolvedBlock && (
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx
index 607b2b23d..e5f3418b8 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/BlockInspector.tsx
@@ -566,10 +566,12 @@ function BlockInspector({
block,
action,
onViewScreenshot,
+ statedFailureHeadline = null,
}: {
block: WorkflowRunBlock;
action?: ActionsApiResponse | null;
onViewScreenshot?: () => void;
+ statedFailureHeadline?: string | null;
}) {
const inputFields = useMemo(
() => getInputFields(block, action),
@@ -661,6 +663,7 @@ function BlockInspector({
<BlockDetailFailure
block={block}
onViewScreenshot={onViewScreenshot}
+ statedFailureHeadline={statedFailureHeadline}
/>
<FieldList
fields={summaryFields}
diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/shared.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/shared.tsx
index cba7171d7..5d98c9a79 100644
--- a/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/shared.tsx
+++ b/skyvern-frontend/src/routes/workflows/workflowRun/blockDetail/shared.tsx
@@ -25,6 +25,7 @@ import {
failureSupportsScreenshot,
} from "../codeBlockFailure";
import { useBlockScreenshot } from "../useBlockScreenshot";
+import { formatFailureReason } from "../failureReasonFormat";
import { stringifyTimelineValue } from "./formatValue";
function TruncatedWithTooltip({
@@ -267,12 +268,36 @@ function BlockScreenshotAction({
function BlockDetailFailure({
block,
onViewScreenshot,
+ statedFailureHeadline = null,
}: {
block: WorkflowRunBlock;
onViewScreenshot?: () => void;
+ // The exact headline text the Studio strip already states (only set for
+ // the run's failing block). Compared by text, not just by block identity:
+ // the strip's headline comes from the RUN's failure_reason, which can
+ // differ from this block's own failure_reason even when this is the
+ // block the run failed on — suppressing on identity alone would drop an
+ // actionable reason the strip never actually showed.
+ statedFailureHeadline?: string | null;
}) {
const codeFailure = describeCodeBlockFailure(block);
- if (!block.failure_reason && !codeFailure) return null;
+ // Non-code failures have no curated title/guidance split like codeFailure
+ // does, so borrow the strip's own headline/detail parser to find this
+ // block's own headline and compare it against what the strip stated.
+ const nonCodeReason =
+ !codeFailure && block.failure_reason
+ ? formatFailureReason(block.failure_reason)
+ : null;
+ const headlineElsewhere =
+ codeFailure !== null
+ ? statedFailureHeadline === codeFailure.title
+ : statedFailureHeadline !== null &&
+ nonCodeReason !== null &&
+ statedFailureHeadline === nonCodeReason.headline;
+ const nonCodeContent = headlineElsewhere
+ ? nonCodeReason?.detail
+ : block.failure_reason;
+ if (!codeFailure && !nonCodeContent) return null;
return (
<div className="space-y-1.5 duration-200 animate-in fade-in slide-in-from-top-2">
<div className="text-[11px] font-medium uppercase tracking-wide text-destructive">
@@ -282,10 +307,17 @@ function BlockDetailFailure({
<ExclamationTriangleIcon className="mt-0.5 h-4 w-4 shrink-0 text-destructive" />
{codeFailure ? (
<div className="min-w-0 flex-1">
- <div className="text-sm font-semibold leading-5">
- {codeFailure.title}
- </div>
- <p className="mt-1 break-words text-muted-foreground">
+ {headlineElsewhere ? null : (
+ <div className="text-sm font-semibold leading-5">
+ {codeFailure.title}
+ </div>
+ )}
+ <p
+ className={cn(
+ "break-words text-muted-foreground",
+ !headlineElsewhere && "mt-1",
+ )}
+ >
{codeFailure.guidance}
</p>
<CodeBlockFailureDetails
@@ -301,9 +333,7 @@ function BlockDetailFailure({
) : null}
</div>
) : (
- <span className="min-w-0 flex-1 break-words">
- {block.failure_reason}
- </span>
+ <span className="min-w-0 flex-1 break-words">{nonCodeContent}</span>
)}
</div>
</div>
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/failureReasonFormat.test.ts b/skyvern-frontend/src/routes/workflows/workflowRun/failureReasonFormat.test.ts
similarity index 100%
rename from skyvern-frontend/src/routes/workflows/studio/runview/failureReasonFormat.test.ts
rename to skyvern-frontend/src/routes/workflows/workflowRun/failureReasonFormat.test.ts
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/failureReasonFormat.ts b/skyvern-frontend/src/routes/workflows/workflowRun/failureReasonFormat.ts
similarity index 100%
rename from skyvern-frontend/src/routes/workflows/studio/runview/failureReasonFormat.ts
rename to skyvern-frontend/src/routes/workflows/workflowRun/failureReasonFormat.ts