Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11514): show real run status on studio Run tab (#6891)
Celal Zamanoğlud1acaabcb009
diff --git a/skyvern-frontend/src/components/StatusBadge.test.tsx b/skyvern-frontend/src/components/StatusBadge.test.tsxindex 2a2870987..1497409fa 100644--- a/skyvern-frontend/src/components/StatusBadge.test.tsx+++ b/skyvern-frontend/src/components/StatusBadge.test.tsx@@ -16,6 +16,14 @@ describe("StatusBadge", () => {expect(label.classList.contains("md:not-sr-only")).toBe(true);});+ test("keeps the label visible at every width when alwaysShowLabel is set", () => {+ render(<StatusBadge status={Status.Terminated} alwaysShowLabel />);++ const label = screen.getByText("terminated");+ expect(label.classList.contains("sr-only")).toBe(false);+ expect(label.classList.contains("md:not-sr-only")).toBe(false);+ });+test("collapses to a compact pill below md via responsive classes", () => {const { container } = render(<StatusBadge status={Status.Completed} />);diff --git a/skyvern-frontend/src/components/StatusBadge.tsx b/skyvern-frontend/src/components/StatusBadge.tsxindex 1cf0c474f..3aa829b20 100644--- a/skyvern-frontend/src/components/StatusBadge.tsx+++ b/skyvern-frontend/src/components/StatusBadge.tsx@@ -59,6 +59,9 @@ function Pill({ tone, className, children }: PillProps) {type Props = {className?: string;status: Status | "pending";+ // By default the label is sr-only below md (compact pill in dense tables);+ // set this where the label must stay visible at every width, e.g. a tab chip.+ alwaysShowLabel?: boolean;};function variantForStatus(status: Status | "pending"): StatusVariant {@@ -109,7 +112,7 @@ function iconForStatus(status: Status | "pending") {}}-function StatusBadge({ className, status }: Props) {+function StatusBadge({ className, status, alwaysShowLabel = false }: Props) {const statusText = status === "timed_out" ? "timed out" : status;return (@@ -122,7 +125,9 @@ function StatusBadge({ className, status }: Props) {title={statusText}>{iconForStatus(status)}- <span className="sr-only md:not-sr-only">{statusText}</span>+ <span className={alwaysShowLabel ? undefined : "sr-only md:not-sr-only"}>+ {statusText}+ </span></Badge>);}diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsxindex 053031bc0..e1632d116 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx@@ -11,6 +11,7 @@ import { useNavigate, useParams } from "react-router-dom";import { getClient } from "@/api/AxiosClient";import { SaveIcon } from "@/components/icons/SaveIcon";+import { StatusBadge } from "@/components/StatusBadge";import { Button } from "@/components/ui/button";import {Dialog,@@ -42,7 +43,7 @@ import { useWorkflowQuery } from "../hooks/useWorkflowQuery";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";import { studioPanelId, studioTabId } from "./constants";-import { runOutcomeFromStatus } from "./runProjections";+import { finalizedRunStatus, runOutcomeFromStatus } from "./runProjections";import { useStudioRunId } from "./useStudioRunId";function useIsGlobalWorkflow(): boolean {@@ -103,19 +104,10 @@ function StudioTabs() {});const latestRun = runs?.[0];const hasRun = Boolean(urlRunId) || (runs?.length ?? 0) > 0;- const outcome = runOutcomeFromStatus(+ const runStatus = finalizedRunStatus(urlRunId ? urlRun?.status : latestRun?.status,);- // Live status lives in the Run view header (one source of truth); the tab keeps- // only the terminal outcome.- const runBadge =- outcome === "failed"- ? { label: "failed", cls: "bg-destructive/20 text-destructive" }- : outcome === "success"- ? { label: "passed", cls: "bg-success/20 text-success" }- : null;-const tabs: Array<{ id: StudioTab; label: string; disabled: boolean }> = [{ id: "editor", label: "Editor", disabled: false },{ id: "browser", label: "Browser", disabled: false },@@ -178,15 +170,13 @@ function StudioTabs() {)}>{t.label}- {t.id === "run" && runBadge ? (- <span- className={cn(- "rounded px-1.5 py-0.5 text-[10px] font-semibold",- runBadge.cls,- )}- >- {runBadge.label}- </span>+ {t.id === "run" && runStatus ? (+ <StatusBadge+ status={runStatus}+ alwaysShowLabel+ // overrides StatusBadge's md:px-2.5 to keep the chip compact in the tab bar+ className="h-5 gap-1 px-1.5 py-0 text-[10px] md:w-auto md:px-1.5"+ />) : null}</button>);diff --git a/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts b/skyvern-frontend/src/routes/workflows/studio/runProjections.test.tsindex f8986030f..67c503073 100644--- a/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts+++ b/skyvern-frontend/src/routes/workflows/studio/runProjections.test.ts@@ -10,6 +10,7 @@ import {buildActionIndex,buildBlockStatusMap,buildFilmstrip,+ finalizedRunStatus,runOutcomeFromStatus,} from "./runProjections";@@ -108,6 +109,25 @@ describe("runOutcomeFromStatus", () => {});});+describe("finalizedRunStatus", () => {+ test("null while there is no status or the run is in-flight", () => {+ expect(finalizedRunStatus(null)).toBeNull();+ expect(finalizedRunStatus(undefined)).toBeNull();+ expect(finalizedRunStatus(Status.Created)).toBeNull();+ expect(finalizedRunStatus(Status.Queued)).toBeNull();+ expect(finalizedRunStatus(Status.Running)).toBeNull();+ expect(finalizedRunStatus(Status.Paused)).toBeNull();+ });++ test("preserves the real terminal status instead of collapsing it", () => {+ expect(finalizedRunStatus(Status.Completed)).toBe(Status.Completed);+ expect(finalizedRunStatus(Status.Failed)).toBe(Status.Failed);+ expect(finalizedRunStatus(Status.Terminated)).toBe(Status.Terminated);+ expect(finalizedRunStatus(Status.TimedOut)).toBe(Status.TimedOut);+ expect(finalizedRunStatus(Status.Canceled)).toBe(Status.Canceled);+ });+});+describe("buildFilmstrip", () => {test("empty or undefined timeline yields no frames", () => {expect(buildFilmstrip(undefined)).toEqual([]);diff --git a/skyvern-frontend/src/routes/workflows/studio/runProjections.ts b/skyvern-frontend/src/routes/workflows/studio/runProjections.tsindex 5650a7fc4..e56fded13 100644--- a/skyvern-frontend/src/routes/workflows/studio/runProjections.ts+++ b/skyvern-frontend/src/routes/workflows/studio/runProjections.ts@@ -4,7 +4,7 @@ import {ReadableActionTypes,Status,} from "@/api/types";-import { statusIsAFailureType } from "@/routes/tasks/types";+import { statusIsAFailureType, statusIsFinalized } from "@/routes/tasks/types";import {isBlockItem,WorkflowRunTimelineItem,@@ -53,6 +53,16 @@ export function runOutcomeFromStatus(return "running";}+// Null while the run is in-flight; the tab shows only the terminal status.+export function finalizedRunStatus(+ status: Status | null | undefined,+): Status | null {+ if (status == null) {+ return null;+ }+ return statusIsFinalized({ status }) ? status : null;+}+export type FilmstripFrame = {id: string;index: number;