Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
SKY-11505: distinguish loading vs empty state in studio run view (#6926)
Celal Zamanoğlub9c8300a7220
diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsxindex 3ea87a616..46dd61433 100644--- a/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsx@@ -2,21 +2,28 @@import { cleanup, render, screen } from "@testing-library/react";import { MemoryRouter } from "react-router-dom";-import { afterEach, describe, expect, test, vi } from "vitest";+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import { RunTab } from "./RunTab";+const { runsQueryMock } = vi.hoisted(() => ({ runsQueryMock: vi.fn() }));+vi.mock("../hooks/useWorkflowRunsQuery", () => ({- useWorkflowRunsQuery: () => ({ data: [] }),+ useWorkflowRunsQuery: () => runsQueryMock(),}));vi.mock("./runview/RunView", () => ({- RunView: (props: { onRetry?: () => void }) => (- <div data-testid="runview" data-has-retry={props.onRetry ? "yes" : "no"} />+ RunView: (props: { onRetry?: () => void; runIdPending?: boolean }) => (+ <div+ data-testid="runview"+ data-has-retry={props.onRetry ? "yes" : "no"}+ data-run-id-pending={props.runIdPending ? "yes" : "no"}+ />),}));afterEach(cleanup);+beforeEach(() => runsQueryMock.mockReturnValue({ data: [], isPending: false }));// useStudioRunId reads ?wr= from the router, so the MemoryRouter URL drives it// (and ?bl=, which RunTab reads directly) — no hook mock needed.@@ -43,3 +50,40 @@ describe("RunTab block-scoped retry", () => {);});});++describe("RunTab run-id resolution", () => {+ test("marks the run id pending while the recent-runs query is loading", () => {+ runsQueryMock.mockReturnValue({ data: undefined, isPending: true });+ renderAt("/workflows/wpid_abc/studio");+ expect(+ screen.getByTestId("runview").getAttribute("data-run-id-pending"),+ ).toBe("yes");+ });++ test("does not mark pending once the recent-runs query settles empty", () => {+ renderAt("/workflows/wpid_abc/studio");+ expect(+ screen.getByTestId("runview").getAttribute("data-run-id-pending"),+ ).toBe("no");+ });++ test("does not mark pending when the run id comes from the URL", () => {+ runsQueryMock.mockReturnValue({ data: undefined, isPending: true });+ renderAt("/workflows/wpid_abc/studio?wr=run_1");+ expect(+ screen.getByTestId("runview").getAttribute("data-run-id-pending"),+ ).toBe("no");+ });++ test("marks the run id pending while the globalWorkflows prerequisite is still loading (query disabled)", () => {+ runsQueryMock.mockReturnValue({+ data: undefined,+ isPending: true,+ isLoading: false,+ });+ renderAt("/workflows/wpid_abc/studio");+ expect(+ screen.getByTestId("runview").getAttribute("data-run-id-pending"),+ ).toBe("yes");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsxindex 7d423ab94..3031fff7f 100644--- a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx@@ -22,7 +22,9 @@ export function RunTab() {const [searchParams] = useSearchParams();const { workflowPermanentId } = useParams();const setCopilotCollapsed = useStudioShellStore((s) => s.setCopilotCollapsed);- const { data: runs } = useWorkflowRunsQuery({+ // isPending (not isLoading) stays true while the query is disabled waiting for+ // globalWorkflows, so the empty state can't flash before the run lookup settles.+ const { data: runs, isPending: runsPending } = useWorkflowRunsQuery({workflowPermanentId,page: 1,pageSize: 1,@@ -35,6 +37,7 @@ export function RunTab() {return (<RunViewworkflowRunId={runId}+ runIdPending={!urlRunId && runsPending}onFix={(seedMessage) => {// Seed via location.state (Workspace reads it as the copilot's initialMessage);// replace so Fix adds no Back-able entry and the message can't re-fire on Back.diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunPlaceholder.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunPlaceholder.test.tsxnew file mode 100644index 000000000..4b4e6536c--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunPlaceholder.test.tsx@@ -0,0 +1,26 @@+// @vitest-environment jsdom++import { cleanup, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, test } from "vitest";++import { RunPlaceholder } from "./RunPlaceholder";++afterEach(cleanup);++describe("RunPlaceholder", () => {+ test("shows the loading copy while a run is loading", () => {+ render(<RunPlaceholder loading />);+ expect(screen.queryByText("Workflow run is loading…")).not.toBeNull();+ expect(+ screen.queryByText("Run the workflow to watch it live here."),+ ).toBeNull();+ });++ test("shows the empty-state copy when no run is loading", () => {+ render(<RunPlaceholder loading={false} />);+ expect(+ screen.queryByText("Run the workflow to watch it live here."),+ ).not.toBeNull();+ expect(screen.queryByText("Workflow run is loading…")).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunPlaceholder.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunPlaceholder.tsxnew file mode 100644index 000000000..26998d9b6--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunPlaceholder.tsx@@ -0,0 +1,16 @@+import { ReloadIcon } from "@radix-ui/react-icons";++export function RunPlaceholder({ loading }: { loading: boolean }) {+ return (+ <div className="flex h-full w-full items-center justify-center gap-2 p-8 text-center text-sm text-muted-foreground">+ {loading ? (+ <>+ <ReloadIcon className="h-5 w-5 animate-spin" />+ Workflow run is loading…+ </>+ ) : (+ "Run the workflow to watch it live here."+ )}+ </div>+ );+}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex fe470939b..0d16da525 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -34,9 +34,13 @@ import { RunHero } from "./RunHero";import { buildRunFixMessage } from "./runFixMessage";import { RunInputsButton, type RunInputMeta } from "./RunInputsButton";import { RunOutputsButton, type RunOutputFile } from "./RunOutputsButton";+import { RunPlaceholder } from "./RunPlaceholder";type RunViewProps = {workflowRunId?: string;+ // The caller is still resolving which run to show; keep the placeholder in its+ // loading state rather than flashing the "no run yet" empty state.+ runIdPending?: boolean;onFix?: (seedMessage?: string) => void;onRetry?: () => void;};@@ -45,9 +49,17 @@ type RunViewProps = {* Fused run view: browser hero on the left, run timeline tree + block detail on* the right, sharing one pinned item via RunViewStore.*/-export function RunView({ workflowRunId, onFix, onRetry }: RunViewProps) {+export function RunView({+ workflowRunId,+ runIdPending = false,+ onFix,+ onRetry,+}: RunViewProps) {const queryOptions = workflowRunId ? { workflowRunId } : undefined;- const { data: workflowRun } = useWorkflowRunWithWorkflowQuery(queryOptions);+ // isLoading here, not isPending like RunTab: this query is enabled only once a run+ // id exists, so a disabled query means "no run" → fall through to the empty CTA.+ const { data: workflowRun, isLoading } =+ useWorkflowRunWithWorkflowQuery(queryOptions);const { data: timeline } = useWorkflowRunTimelineQuery(queryOptions);const { workflowPermanentId } = useParams();const { data: debugSession } = useDebugSessionQuery({@@ -248,11 +260,7 @@ export function RunView({ workflowRunId, onFix, onRetry }: RunViewProps) {}, [workflowRun]);if (!workflowRun) {- return (- <div className="flex h-full w-full items-center justify-center p-8 text-center text-sm text-muted-foreground">- Run the workflow to watch it live here.- </div>- );+ return <RunPlaceholder loading={isLoading || runIdPending} />;}const elapsed = formatElapsed(