Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-11758): slim the studio Run pane into a timeline + run-data pane (#7045)
Celal Zamanoğlu34d3196c6473
diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsxindex 12abbe4f3..3d26b8257 100644--- a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx@@ -1,28 +1,20 @@import { useNavigate, useParams, useSearchParams } from "react-router-dom";-import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";import { RunView } from "./runview/RunView";+import { useStudioInspectedRun } from "./useStudioInspectedRun";import { useStudioPanes } from "./useStudioPanes";-import { useStudioRunId } from "./useStudioRunId";/**- * Run pane of the studio shell — the fused hero + filmstrip RunView. Shows the- * run in the URL when present, otherwise the workflow's most recent run.+ * Run pane of the studio shell — the run timeline + run-data view (the Browser+ * pane owns the visuals). Shows the run in the URL when present, otherwise the+ * workflow's most recent run.*/export function RunTab() {const navigate = useNavigate();- const urlRunId = useStudioRunId();const [searchParams] = useSearchParams();const { workflowPermanentId } = useParams();const { openPane } = useStudioPanes();- // 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,- });- const runId = urlRunId ?? runs?.[0]?.workflow_run_id;+ const { runId, pending } = useStudioInspectedRun();// ?bl= marks a block-scoped run; "Retry as-is" would rerun the whole workflow,// so suppress that CTA for block runs (the block is rerun from the editor).const isBlockRun = searchParams.has("bl");@@ -30,7 +22,7 @@ export function RunTab() {return (<RunViewworkflowRunId={runId}- runIdPending={!urlRunId && runsPending}+ runIdPending={pending}onFix={(seedMessage) => {// One replace-navigation opens the Copilot pane and seeds the message via// location.state (Workspace reads it as the copilot's initialMessage), sodiff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsxindex 169716878..0b7412c81 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx@@ -22,6 +22,7 @@ import { BrowserPaneActions, BrowserPaneViewPills } from "./BrowserPaneHeader";import { BrowserTab } from "./BrowserTab";import { EditorTab, type StudioWorkspaceProps } from "./EditorTab";import { RunTab } from "./RunTab";+import { RunPaneActions, RunPaneStatusBadge } from "./runview/RunPaneHeader";import { StudioBrowserStream } from "./StudioBrowserStream";import { StudioCoachMark } from "./StudioCoachMark";import { studioPanelId, studioTabId } from "./constants";@@ -315,7 +316,11 @@ function StudioStage(props: StudioWorkspaceProps) {><BrowserTab /></StudioPane>- <StudioPane {...paneProps("run")}>+ <StudioPane+ {...paneProps("run")}+ headerExtras={<RunPaneStatusBadge />}+ headerActions={<RunPaneActions />}+ ><RunTab /></StudioPane>{panes.length === 0 ? <StudioStageLauncher /> : null}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.test.tsxdeleted file mode 100644index 9b467bb3a..000000000--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.test.tsx+++ /dev/null@@ -1,458 +0,0 @@-// @vitest-environment jsdom--import {- cleanup,- fireEvent,- render,- screen,- within,-} from "@testing-library/react";-import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";--import { useRunViewStore } from "@/store/RunViewStore";--vi.mock("./RunLiveStream", () => ({- RunLiveStream: () => <div data-testid="run-live-stream" />,-}));-vi.mock("../../workflowRun/WorkflowRunCode", () => ({- WorkflowRunCode: () => <div data-testid="workflow-run-code" />,-}));-vi.mock("./HeroRecording", () => ({- HeroRecording: () => <div data-testid="hero-recording" />,-}));-vi.mock("./HeroScreenshot", () => ({- HeroScreenshot: () => <div data-testid="hero-screenshot" />,-}));--import { RunHero } from "./RunHero";--const baseProps = {- workflowRunId: "wr_1",- heroSelection: null,- heroLabel: "",- running: true,- provisioning: false,- isPaused: false,- failed: false,- failureReason: null,- browserSessionId: "bp_1",- recordingUrls: [],- elapsed: "0:01",-};--afterEach(cleanup);-beforeEach(() => useRunViewStore.getState().reset());--describe("RunHero block-run stream", () => {- test("block run shows the shared debug-stream slot, not its own RunLiveStream", () => {- render(<RunHero {...baseProps} showDebugStream />);- expect(screen.queryByTestId("run-stream-slot")).not.toBeNull();- expect(screen.queryByTestId("run-live-stream")).toBeNull();- });-- test("full run shows its own RunLiveStream, not the debug-stream slot", () => {- render(<RunHero {...baseProps} showDebugStream={false} />);- expect(screen.queryByTestId("run-live-stream")).not.toBeNull();- expect(screen.queryByTestId("run-stream-slot")).toBeNull();- });-- test("block run skips the provisioning panel (debug stream is already alive)", () => {- render(- <RunHero {...baseProps} showDebugStream running={false} provisioning />,- );- expect(screen.queryByTestId("run-stream-slot")).not.toBeNull();- });-});--describe("RunHero when the Browser pane hosts the debug stream", () => {- const blockRunProps = {- ...baseProps,- showDebugStream: true,- debugStreamInBrowserPane: true,- };-- test("renders live-edge screenshots, not a dead stream slot", () => {- render(- <RunHero- {...blockRunProps}- heroSelection={{- kind: "action",- artifactId: "art_1",- stepId: "step_1",- actionOrder: 0,- }}- />,- );- expect(screen.queryByTestId("run-stream-slot")).toBeNull();- expect(screen.queryByTestId("run-live-stream")).toBeNull();- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- });-- test("the Live chip focuses the Browser pane and unpins to the live edge", () => {- const onFocusBrowserPane = vi.fn();- useRunViewStore.getState().pinFrame("act_1");- render(- <RunHero {...blockRunProps} onFocusBrowserPane={onFocusBrowserPane} />,- );-- fireEvent.click(screen.getByRole("button", { name: "Live" }));-- expect(onFocusBrowserPane).toHaveBeenCalledTimes(1);- expect(useRunViewStore.getState().pinnedFrameId).toBeNull();- expect(screen.queryByTestId("run-stream-slot")).toBeNull();- });-- test("a queued block run surfaces its queued state", () => {- render(<RunHero {...blockRunProps} provisioning />);- expect(screen.queryByText(/Run queued/)).not.toBeNull();- });-- test("a queued block run also shows the queued chip over the hosted slot", () => {- render(- <RunHero- {...baseProps}- showDebugStream- debugStreamInBrowserPane={false}- provisioning- />,- );- expect(screen.queryByTestId("run-stream-slot")).not.toBeNull();- expect(screen.queryByText(/Run queued/)).not.toBeNull();- });-});--describe("RunHero closed pane", () => {- test("mounts no full-run stream while the pane is hidden", () => {- render(<RunHero {...baseProps} showDebugStream={false} paneOpen={false} />);- expect(screen.queryByTestId("run-live-stream")).toBeNull();- expect(screen.queryByTestId("run-stream-slot")).toBeNull();- });-});--describe("RunHero archived recording", () => {- test("explains an archived recording instead of hiding it silently", () => {- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- recordingArchived- heroSelection={{ kind: "thought", thoughtId: "t1" }}- />,- );- const chip = screen.getByRole("button", { name: /Recording archived/ });- expect((chip as HTMLButtonElement).disabled).toBe(true);- });-});--describe("RunHero Code surface (single source of truth)", () => {- test("the Code toggle opens the generated-code view", () => {- render(<RunHero {...baseProps} showDebugStream={false} />);- expect(screen.queryByTestId("workflow-run-code")).toBeNull();- fireEvent.click(screen.getByRole("button", { name: "Code" }));- expect(screen.queryByTestId("workflow-run-code")).not.toBeNull();- });-- test("the Code toggle owns code-generation state, showing a spinner while generating", () => {- const { rerender } = render(- <RunHero {...baseProps} showDebugStream={false} codeGenerating={false} />,- );- expect(screen.queryByTestId("code-generating-spinner")).toBeNull();-- rerender(<RunHero {...baseProps} showDebugStream={false} codeGenerating />);- expect(screen.queryByTestId("code-generating-spinner")).not.toBeNull();- });-});--describe("RunHero screenshot discoverability", () => {- const propsWithScreenshots = {- ...baseProps,- showDebugStream: false,- running: false,- heroSelection: {- kind: "action" as const,- artifactId: "art_1",- stepId: "step_1",- actionOrder: 0,- },- heroLabel: "Clicked submit",- hasScreenshots: true,- };-- test("completed runs with recordings expose a Screenshots return path", () => {- render(- <RunHero- {...propsWithScreenshots}- recordingUrls={["https://example.com/rec.mp4"]}- />,- );-- expect(screen.queryByTestId("hero-recording")).not.toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Screenshots" }));- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Code" }));- expect(screen.queryByTestId("workflow-run-code")).not.toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Screenshots" }));- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("workflow-run-code")).toBeNull();- });-- test("running runs can return from live view to available screenshots", () => {- render(<RunHero {...propsWithScreenshots} running />);-- expect(screen.queryByTestId("run-live-stream")).not.toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Screenshots" }));- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("run-live-stream")).toBeNull();- });-- test("does not infer the Screenshots toggle from a screenshot-less selection", () => {- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- heroSelection={{- kind: "action",- artifactId: null,- stepId: null,- actionOrder: 0,- }}- heroLabel="Clicked submit"- />,- );-- expect(screen.queryByRole("button", { name: "Screenshots" })).toBeNull();- });-});--describe("RunHero header dedupe", () => {- test("recording view does not echo the active toggle label in the header", () => {- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- recordingUrls={["https://example.com/rec.mp4"]}- />,- );- // Only the toggle should say "Recording" — not the header label too.- expect(screen.getAllByText("Recording")).toHaveLength(1);- });-- test("code view does not echo the active toggle as a header label", () => {- useRunViewStore.getState().setCenterView("code");- render(<RunHero {...baseProps} showDebugStream={false} />);- // The Code toggle communicates the view; the "Generated code" header is redundant.- expect(screen.queryByText("Generated code")).toBeNull();- });-- test("scrubbed action description appears once, not in the header too", () => {- useRunViewStore.getState().pinFrame("f1");- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- heroSelection={{ kind: "thought", thoughtId: "t1" }}- heroLabel="Click the login button"- />,- );- // The in-card "Inspecting step" bar owns the action description.- expect(screen.getAllByText("Click the login button")).toHaveLength(1);- });-- test("view toggles live in the labeled segmented control, on the leading edge", () => {- render(<RunHero {...baseProps} showDebugStream={false} />);- const group = screen.getByRole("group", { name: "Center view" });- expect(group.contains(screen.getByText("Live"))).toBe(true);- expect(group.contains(screen.getByText("Code"))).toBe(true);- });-});--describe("RunHero recording navigation", () => {- test("live-pinned running runs can switch from recording back to the final run frame after finalizing", () => {- useRunViewStore.getState().pinFrame("stream");- const finalFrameSelection = { kind: "thought" as const, thoughtId: "t1" };- const { rerender } = render(- <RunHero {...baseProps} showDebugStream={false} />,- );-- expect(screen.queryByRole("button", { name: "Run" })).toBeNull();-- rerender(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- recordingUrls={["https://example.com/rec.mp4"]}- heroSelection={finalFrameSelection}- heroLabel="Final frame"- />,- );-- expect(screen.queryByTestId("hero-recording")).not.toBeNull();- expect(screen.queryByRole("button", { name: "Run" })).not.toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Run" }));- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();- });-- test("finalized runs can switch from the default recording back to the run frame", () => {- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- recordingUrls={["https://example.com/rec.mp4"]}- heroSelection={{ kind: "thought", thoughtId: "t1" }}- heroLabel="Final frame"- />,- );-- expect(screen.queryByTestId("hero-recording")).not.toBeNull();- expect(screen.queryByTestId("hero-screenshot")).toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Run" }));- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Recording" }));- expect(screen.queryByTestId("hero-recording")).not.toBeNull();- expect(screen.queryByTestId("hero-screenshot")).toBeNull();- });-- test("explicit run view stays selected while the frame selection reloads", () => {- const { rerender } = render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- recordingUrls={["https://example.com/rec.mp4"]}- heroSelection={{ kind: "thought", thoughtId: "t1" }}- heroLabel="Final frame"- />,- );-- fireEvent.click(screen.getByRole("button", { name: "Run" }));- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();-- rerender(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- recordingUrls={["https://example.com/rec.mp4"]}- heroSelection={null}- heroLabel="Final frame"- />,- );-- expect(screen.queryByText("Waiting for the first action…")).not.toBeNull();- expect(screen.queryByRole("button", { name: "Run" })).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();- });-- test("failed runs with a recording can open it from the run frame", () => {- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- failed- recordingUrls={["https://example.com/rec.mp4"]}- heroSelection={{ kind: "thought", thoughtId: "t1" }}- heroLabel="Failure frame"- />,- );-- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Recording" }));- expect(screen.queryByTestId("hero-recording")).not.toBeNull();- expect(screen.queryByTestId("hero-screenshot")).toBeNull();- });-- test("failed runs without a frame can return from recording to the run view", () => {- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- failed- recordingUrls={["https://example.com/rec.mp4"]}- />,- );-- expect(screen.queryByRole("button", { name: "Run" })).not.toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Recording" }));- expect(screen.queryByTestId("hero-recording")).not.toBeNull();-- fireEvent.click(screen.getByRole("button", { name: "Run" }));- expect(screen.queryByText("Waiting for the first action…")).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();- });-- test("scrubbed failed runs can open the recording from the inspection overlay", () => {- useRunViewStore.getState().pinFrame("f1");- render(- <RunHero- {...baseProps}- showDebugStream={false}- running={false}- failed- recordingUrls={["https://example.com/rec.mp4"]}- heroSelection={{ kind: "thought", thoughtId: "t1" }}- heroLabel="Failure frame"- />,- );-- expect(screen.queryByTestId("hero-screenshot")).not.toBeNull();- expect(screen.queryByTestId("hero-recording")).toBeNull();-- const overlay = screen.getByText("Failure frame").closest("div");- if (!overlay) {- throw new Error("Expected the inspection overlay to be visible");- }-- fireEvent.click(within(overlay).getByRole("button", { name: "Recording" }));- expect(screen.queryByTestId("hero-recording")).not.toBeNull();- expect(screen.queryByTestId("hero-screenshot")).toBeNull();- });-});--describe("RunHero failure banner", () => {- const failedProps = {- ...baseProps,- showDebugStream: true,- running: false,- failed: true,- failureReason: "for_loop block failed.",- };-- test("shows the failure reason with a dismiss button when the run failed", () => {- render(<RunHero {...failedProps} />);- expect(screen.queryByText("for_loop block failed.")).not.toBeNull();- expect(screen.queryByRole("button", { name: "Dismiss" })).not.toBeNull();- });-- test("dismiss hides the failure banner", () => {- render(<RunHero {...failedProps} />);- fireEvent.click(screen.getByRole("button", { name: "Dismiss" }));- expect(screen.queryByText("for_loop block failed.")).toBeNull();- expect(screen.queryByRole("button", { name: "Dismiss" })).toBeNull();- });-- test("no failure banner when the run has not failed", () => {- render(<RunHero {...failedProps} failed={false} />);- expect(screen.queryByRole("button", { name: "Dismiss" })).toBeNull();- });-});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsxdeleted file mode 100644index b375238b7..000000000--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx+++ /dev/null@@ -1,497 +0,0 @@-import { type ReactNode, useEffect, useRef, useState } from "react";-import {- ClockIcon,- CodeIcon,- CounterClockwiseClockIcon,- Cross2Icon,- ExclamationTriangleIcon,- FileTextIcon,- GlobeIcon,- ImageIcon,- ListBulletIcon,- PlayIcon,- ReloadIcon,-} from "@radix-ui/react-icons";--import { Button } from "@/components/ui/button";-import { StreamStatusPanel } from "@/routes/streaming/StreamDiagnostics";-import { useRunViewStore } from "@/store/RunViewStore";--import { WorkflowRunCode } from "../../workflowRun/WorkflowRunCode";-import { useStudioShellContext } from "../StudioShellContext";-import { ViewToggle } from "../ViewToggle";-import { matchFailureTips } from "./failureTips";-import { HeroRecording } from "./HeroRecording";-import { HeroScreenshot, type HeroSelection } from "./HeroScreenshot";-import { resolveRunHeroCenterView } from "./runHeroCenter";-import { RunLiveStream } from "./RunLiveStream";--type RunHeroProps = {- workflowRunId: string;- heroSelection: HeroSelection | null;- heroLabel: string;- running: boolean;- // A block run shows the shared debug-session stream (re-parented in by the- // shell), view-only, instead of mounting a separate run stream.- showDebugStream: boolean;- // The open Browser pane outranks this hero for the single stream node; the- // Live affordance points there instead of registering a slot that stays black.- debugStreamInBrowserPane?: boolean;- onFocusBrowserPane?: () => void;- // The pane keeps rendering while closed (display:none); never mount a stream- // socket into a hidden pane.- paneOpen?: boolean;- provisioning: boolean;- isPaused: boolean;- failed: boolean;- failureReason: string | null;- codeGenerating?: boolean;- browserSessionId: string | null;- recordingUrls: string[];- recordingArchived?: boolean;- hasScreenshots?: boolean;- elapsed: string;- inputs?: ReactNode;- outputs?: ReactNode;- overview?: ReactNode;- actions?: ReactNode;- onRecordingPlay?: (index: number) => void;- onFix?: () => void;- onRetry?: () => void;-};--// Below this header width the toggle/dropdown labels collapse to icons.-const HEADER_COMPACT_BELOW_PX = 640;--const RECORDING_ARCHIVED_LABEL =- "Recording archived — contact [email protected] to request restoration";--export function RunHero({- workflowRunId,- heroSelection,- heroLabel,- running,- showDebugStream,- debugStreamInBrowserPane = false,- onFocusBrowserPane,- paneOpen = true,- provisioning,- isPaused,- failed,- failureReason,- codeGenerating = false,- browserSessionId,- recordingUrls,- recordingArchived = false,- hasScreenshots = false,- elapsed,- inputs,- outputs,- overview,- actions,- onRecordingPlay,- onFix,- onRetry,-}: RunHeroProps) {- const pinnedFrameId = useRunViewStore((s) => s.pinnedFrameId);- const pinFrame = useRunViewStore((s) => s.pinFrame);- const jumpToLive = useRunViewStore((s) => s.jumpToLive);- const centerView = useRunViewStore((s) => s.centerView);- const setCenterView = useRunViewStore((s) => s.setCenterView);- const compact = useRunViewStore((s) => s.headerCompact);- const setHeaderCompact = useRunViewStore((s) => s.setHeaderCompact);- const { setRunStreamSlot } = useStudioShellContext();-- // The live page URL comes from the stream frames (CDP); reset per run.- const [streamUrl, setStreamUrl] = useState<string | null>(null);- // Block runs default to the live debug stream; this opts into the recording.- const [recordingOpen, setRecordingOpen] = useState(false);- // The failure banner is dismissable; the route reuses this instance across- // runs, so clear the dismissal whenever the run changes.- const [failureDismissed, setFailureDismissed] = useState(false);- useEffect(() => {- setStreamUrl(null);- setRecordingOpen(false);- setFailureDismissed(false);- }, [workflowRunId]);-- // Collapse labels to icons by the header's own width — the studio side panels- // make viewport width the wrong signal.- const headerRef = useRef<HTMLDivElement>(null);- useEffect(() => {- const el = headerRef.current;- if (!el || typeof ResizeObserver === "undefined") {- return;- }- const observer = new ResizeObserver((entries) => {- const width = entries[0]?.contentRect.width ?? 0;- setHeaderCompact(width < HEADER_COMPACT_BELOW_PX);- });- observer.observe(el);- return () => observer.disconnect();- }, [setHeaderCompact]);-- const scrubbing = pinnedFrameId != null && pinnedFrameId !== "stream";- const hasRecording = recordingUrls.length > 0;-- const center = resolveRunHeroCenterView({- centerView,- hasScreenshots,- hasInputs: Boolean(inputs),- hasOutputs: Boolean(outputs),- hasRecording,- scrubbing,- showDebugStream,- debugStreamInBrowserPane,- recordingOpen,- running,- failed,- });-- const focusBrowserPane = () => {- setRecordingOpen(false);- // Unpin instead of pinning "stream": the hero can't host the debug node,- // so its screenshot surface follows the live edge while the pane streams.- jumpToLive();- onFocusBrowserPane?.();- };-- // The right-side toggles own the view identity (Live/Recording/Code) and the- // in-card "Inspecting step" bar owns a scrubbed action's description; the- // header only adds context they don't surface — the live page URL, or the- // final frame's label when nothing else names it.- const headerLabel =- center === "stream"- ? streamUrl- : center === "screenshot" && !scrubbing- ? heroLabel- : null;-- const toggleCenter = (view: "code" | "inputs" | "outputs") =>- setCenterView(centerView === view ? "default" : view);- const showRunToggle =- Boolean(heroSelection) || centerView === "screenshot" || failed;-- return (- <div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1">- <div- ref={headerRef}- className="flex items-center gap-2 border-b border-border px-3 py-2"- >- <div- role="group"- aria-label="Center view"- className="flex shrink-0 items-center gap-0.5 rounded-md border border-slate-700 bg-slate-elevation2 p-0.5"- >- {showDebugStream ? (- <>- <ViewToggle- active={!debugStreamInBrowserPane && center === "stream"}- onClick={- debugStreamInBrowserPane- ? focusBrowserPane- : () => {- setRecordingOpen(false);- pinFrame("stream");- }- }- compact={compact}- label="Live"- title={- debugStreamInBrowserPane- ? "Watch live in the Browser pane"- : undefined- }- icon={- <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-success" />- }- />- {hasRecording ? (- <ViewToggle- active={center === "recording"}- onClick={() => {- setRecordingOpen(true);- jumpToLive();- }}- compact={compact}- label="Recording"- icon={<PlayIcon className="h-3 w-3" />}- />- ) : null}- </>- ) : running ? (- <ViewToggle- active={center === "stream"}- onClick={() => pinFrame("stream")}- compact={compact}- label="Live"- icon={- <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-success" />- }- />- ) : hasRecording ? (- <>- {showRunToggle ? (- <ViewToggle- active={center === "screenshot"}- onClick={() => setCenterView("screenshot")}- compact={compact}- label="Run"- icon={<CounterClockwiseClockIcon className="h-3 w-3" />}- />- ) : null}- <ViewToggle- active={center === "recording"}- onClick={() => setCenterView("recording")}- compact={compact}- label="Recording"- icon={<PlayIcon className="h-3 w-3" />}- />- </>- ) : recordingArchived ? (- <button- type="button"- disabled- title={RECORDING_ARCHIVED_LABEL}- aria-label={RECORDING_ARCHIVED_LABEL}- className="inline-flex cursor-not-allowed items-center gap-1.5 rounded px-2 py-1 text-[11px] font-medium text-muted-foreground opacity-60"- >- <PlayIcon className="h-3 w-3" />- {compact ? null : "Recording archived"}- </button>- ) : null}- {hasScreenshots ? (- <ViewToggle- active={center === "screenshot"}- onClick={() => setCenterView("screenshots")}- compact={compact}- label="Screenshots"- icon={<ImageIcon className="h-3 w-3" />}- />- ) : null}- <ViewToggle- active={center === "code"}- onClick={() => toggleCenter("code")}- compact={compact}- label="Code"- title={- codeGenerating ? "Generating cached code for this run" : undefined- }- icon={- codeGenerating ? (- <ReloadIcon- data-testid="code-generating-spinner"- className="h-3 w-3 animate-spin"- />- ) : (- <CodeIcon className="h-3 w-3" />- )- }- />- {inputs ? (- <ViewToggle- active={center === "inputs"}- onClick={() => toggleCenter("inputs")}- compact={compact}- label="Inputs"- icon={<ListBulletIcon className="h-3 w-3" />}- />- ) : null}- {outputs ? (- <ViewToggle- active={center === "outputs"}- onClick={() => toggleCenter("outputs")}- compact={compact}- label="Outputs"- icon={<FileTextIcon className="h-3 w-3" />}- />- ) : null}- </div>- <div className="flex min-w-0 flex-1 items-center gap-1.5">- {headerLabel ? (- <>- <GlobeIcon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />- <span className="min-w-0 flex-1 truncate text-sm font-medium text-foreground">- {headerLabel}- </span>- </>- ) : null}- </div>- <div className="flex shrink-0 items-center gap-1">- {overview || actions ? (- <div className="mx-0.5 h-4 w-px bg-border" />- ) : null}- {overview}- {actions}- {compact ? null : (- <span- className="ml-1 whitespace-nowrap font-mono text-[11px] tabular-nums text-muted-foreground"- title="Elapsed"- >- {elapsed}- </span>- )}- </div>- </div>-- <div className="relative min-h-0 flex-1 overflow-hidden bg-slate-950">- {center === "code" ? (- <div className="absolute inset-0 flex flex-col overflow-hidden bg-slate-elevation1 p-2">- <WorkflowRunCode- workflowRunId={workflowRunId}- showCacheKeyValueSelector- />- </div>- ) : center === "inputs" ? (- <div className="absolute inset-0 overflow-y-auto bg-slate-elevation1 p-4">- {inputs}- </div>- ) : center === "outputs" ? (- <div className="absolute inset-0 overflow-y-auto bg-slate-elevation1 p-4">- {outputs}- </div>- ) : center === "stream" ? (- !paneOpen ? null : showDebugStream ? (- // The shell re-parents the persistent debug-session stream into this- // slot (the same node as the Browser pane), so a block run shows its- // live browser here, view-only. The slot unmounts when the user scrubs- // or opens code/recording, which parks the node back offscreen.- <div- ref={setRunStreamSlot}- data-testid="run-stream-slot"- className="absolute inset-0"- />- ) : provisioning ? (- // Mounting the stream while the run is still queued opens a socket- // the backend never feeds; wait until the run is actually running.- <div className="absolute inset-0">- <StreamStatusPanel- diagnostic={{- title: "Starting the browser",- detail: "Getting your run's browser ready…",- pending: true,- }}- />- </div>- ) : (- <RunLiveStream- workflowRunId={workflowRunId}- browserSessionId={browserSessionId}- interactive={isPaused}- onUrlChange={setStreamUrl}- />- )- ) : center === "recording" ? (- <HeroRecording- recordingUrls={recordingUrls}- onPlay={onRecordingPlay}- />- ) : heroSelection ? (- <HeroScreenshot selection={heroSelection} running={running} />- ) : (- <div className="absolute inset-0 grid place-items-center text-sm text-muted-foreground">- Waiting for the first action…- </div>- )}-- {provisioning &&- showDebugStream &&- !scrubbing &&- (center === "stream" || center === "screenshot") ? (- // A block run can queue behind a running full run (run_sequentially);- // the debug browser is already live, so say why nothing moves yet.- <div className="absolute left-3 top-3 flex items-center gap-2 rounded-md bg-black/70 px-3 py-1.5 text-xs text-white backdrop-blur">- <ClockIcon className="h-3.5 w-3.5 shrink-0" />- <span>Run queued — waiting to start</span>- </div>- ) : null}-- {center === "screenshot" && scrubbing && heroSelection ? (- <div className="absolute left-3 top-3 flex max-w-[26rem] items-center gap-2 rounded-md bg-black/70 px-3 py-1.5 text-xs text-white backdrop-blur">- <CounterClockwiseClockIcon className="h-3.5 w-3.5 shrink-0" />- <span className="truncate">- Inspecting · <b>{heroLabel}</b>- </span>- {running || showDebugStream ? (- <button- type="button"- onClick={- showDebugStream && debugStreamInBrowserPane- ? focusBrowserPane- : () => {- setRecordingOpen(false);- pinFrame("stream");- }- }- className="ml-1 inline-flex items-center gap-1.5 rounded-full bg-white/15 px-2 py-0.5 text-[11px] hover:bg-white/25 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white"- >- <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-success" />- Jump to live- </button>- ) : hasRecording ? (- <button- type="button"- onClick={() => {- // Preserve the inspected frame so "Run" returns to this step.- setCenterView("recording");- }}- className="ml-1 inline-flex items-center gap-1.5 rounded-full bg-white/15 px-2 py-0.5 text-[11px] hover:bg-white/25 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white"- >- <PlayIcon className="h-3 w-3" />- Recording- </button>- ) : null}- </div>- ) : null}-- {failed &&- !failureDismissed &&- !scrubbing &&- (center === "screenshot" ||- (showDebugStream && center === "stream")) ? (- <div className="absolute inset-x-0 bottom-0 m-4 rounded-lg border border-destructive/40 bg-slate-elevation1/95 p-4 shadow-lg backdrop-blur">- <div className="flex items-start gap-2 text-sm font-semibold text-foreground">- <ExclamationTriangleIcon className="mt-0.5 h-4 w-4 shrink-0 text-destructive" />- <span className="min-w-0 flex-1">- {failureReason ?? "The run failed."}- {matchFailureTips(failureReason).map((tip) => (- <span- key={tip}- className="mt-1.5 block text-xs font-normal italic text-muted-foreground"- >- {tip}- </span>- ))}- </span>- <button- type="button"- onClick={() => setFailureDismissed(true)}- className="-mr-1 -mt-1 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>- <div className="mt-3 flex flex-wrap gap-2">- {onFix ? (- <Button- size="sm"- className="bg-studio-accent text-foreground hover:bg-studio-accent/90"- onClick={onFix}- >- Fix with Copilot- </Button>- ) : null}- {onRetry ? (- <Button size="sm" variant="secondary" onClick={onRetry}>- Retry as-is- </Button>- ) : null}- </div>- </div>- ) : null}- </div>- </div>- );-}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunOverviewButton.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunOverviewButton.tsxdeleted file mode 100644index ff9f31ddd..000000000--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunOverviewButton.tsx+++ /dev/null@@ -1,166 +0,0 @@-import { type ReactNode } from "react";-import {- ClockIcon,- ExclamationTriangleIcon,- ReaderIcon,-} from "@radix-ui/react-icons";-import { Link } from "react-router-dom";--import { type FailureCategory, type Status } from "@/api/types";-import { CopyButton } from "@/components/CopyButton";-import { FailureCategoryBadge } from "@/components/FailureCategoryBadge";-import { StatusBadge } from "@/components/StatusBadge";-import {- Popover,- PopoverContent,- PopoverTrigger,-} from "@/components/ui/popover";-import { useRunViewStore } from "@/store/RunViewStore";-import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat";-import { cn } from "@/util/utils";--import { OverviewField } from "./OverviewField";--type RunOverviewButtonProps = {- status: Status;- elapsed: string;- startedAt: string | null;- finishedAt: string | null;- failureReason: string | null;- failureCategory: Array<FailureCategory> | null;- workflowRunId: string;- browserSessionId: string | null;- browserProfileId: string | null;-};--function Stat({- label,- value,- title,- icon,-}: {- label: string;- value: string;- title?: string;- icon?: ReactNode;-}) {- return (- <div className="flex flex-col gap-0.5">- <span className="text-[10px] font-medium uppercase tracking-wide text-muted-foreground">- {label}- </span>- <span- title={title}- className="flex items-center gap-1.5 text-sm font-medium text-foreground"- >- {icon ? <span className="text-muted-foreground">{icon}</span> : null}- {value}- </span>- </div>- );-}--export function RunOverviewButton({- status,- elapsed,- startedAt,- finishedAt,- failureReason,- failureCategory,- workflowRunId,- browserSessionId,- browserProfileId,-}: RunOverviewButtonProps) {- const compact = useRunViewStore((s) => s.headerCompact);- return (- <Popover>- <PopoverTrigger asChild>- <button- type="button"- title={compact ? "Overview" : undefined}- aria-label="Overview"- className={cn(- "inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium",- "text-muted-foreground hover:bg-slate-elevation3 hover:text-foreground",- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",- )}- >- <ReaderIcon className="h-4 w-4" />- {compact ? null : "Overview"}- </button>- </PopoverTrigger>- <PopoverContent- align="end"- className="flex w-[26rem] max-w-[90vw] flex-col gap-4"- >- <div className="flex flex-wrap items-center gap-x-5 gap-y-3">- <div className="flex items-center gap-2">- <StatusBadge status={status} />- {failureCategory?.length ? (- <FailureCategoryBadge failureCategory={failureCategory} />- ) : null}- </div>- <Stat- label="Duration"- value={elapsed}- icon={<ClockIcon className="h-3.5 w-3.5" />}- />- {startedAt ? (- <Stat- label="Started"- value={basicLocalTimeFormat(startedAt)}- title={basicTimeFormat(startedAt)}- />- ) : null}- {finishedAt ? (- <Stat- label="Finished"- value={basicLocalTimeFormat(finishedAt)}- title={basicTimeFormat(finishedAt)}- />- ) : null}- </div>-- {failureReason ? (- <div className="flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm">- <ExclamationTriangleIcon className="mt-0.5 h-4 w-4 shrink-0 text-destructive" />- <span className="whitespace-pre-wrap break-words text-foreground">- {failureReason}- </span>- </div>- ) : null}-- <div className="flex flex-col gap-3">- <OverviewField label="Run ID">- <div className="flex items-center gap-1.5">- <span className="truncate font-mono text-xs">- {workflowRunId}- </span>- <CopyButton value={workflowRunId} />- </div>- </OverviewField>- {browserSessionId ? (- <OverviewField label="Browser session">- <Link- to={`/browser-session/${browserSessionId}/stream`}- className="font-mono text-xs text-studio-accent-2 underline-offset-4 hover:underline"- >- {browserSessionId}- </Link>- </OverviewField>- ) : null}- {browserProfileId ? (- <OverviewField label="Browser profile">- <Link- to={`/browser-profiles/${browserProfileId}`}- className="font-mono text-xs text-studio-accent-2 underline-offset-4 hover:underline"- >- {browserProfileId}- </Link>- </OverviewField>- ) : null}- </div>- </PopoverContent>- </Popover>- );-}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunOverviewSection.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunOverviewSection.tsxnew file mode 100644index 000000000..776f32874--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunOverviewSection.tsx@@ -0,0 +1,150 @@+import { ClockIcon, ExclamationTriangleIcon } from "@radix-ui/react-icons";+import { Link } from "react-router-dom";++import { type WorkflowRunStatusApiResponseWithWorkflow } from "@/api/types";+import { CopyButton } from "@/components/CopyButton";+import { FailureCategoryBadge } from "@/components/FailureCategoryBadge";+import { StatusBadge } from "@/components/StatusBadge";+import { statusIsFinalized } from "@/routes/tasks/types";+import { basicLocalTimeFormat, basicTimeFormat } from "@/util/timeFormat";++import { OverviewField } from "./OverviewField";++function StatBlock({ label, value }: { label: string; value: string }) {+ return (+ <div className="min-w-0 flex-1 rounded-lg border border-border bg-slate-elevation2 px-2 py-3 text-center">+ <div className="truncate text-base font-semibold text-foreground">+ {value}+ </div>+ <div className="text-[10px] font-medium uppercase tracking-wide text-muted-foreground">+ {label}+ </div>+ </div>+ );+}++type RunOverviewSectionProps = {+ workflowRun: WorkflowRunStatusApiResponseWithWorkflow;+ actionCount: number;+ elapsed: string;+};++/**+ * Overview body view of the Run pane: step / action / credit stat blocks plus+ * the run metadata that used to live in the header's Overview popover.+ */+export function RunOverviewSection({+ workflowRun,+ actionCount,+ elapsed,+}: RunOverviewSectionProps) {+ const finalized = statusIsFinalized(workflowRun);+ const webhookFailureReason =+ workflowRun.task_v2?.webhook_failure_reason ??+ workflowRun.webhook_failure_reason ??+ null;+ const webhookState = !workflowRun.webhook_callback_url+ ? null+ : webhookFailureReason+ ? "failed"+ : finalized+ ? "delivered"+ : "pending";+ const credits =+ (workflowRun.credits_used ?? 0) + (workflowRun.cached_credits_used ?? 0);++ return (+ <div className="flex flex-col gap-4">+ <div className="flex gap-2">+ <StatBlock label="Steps" value={String(workflowRun.total_steps ?? 0)} />+ <StatBlock label="Actions" value={String(actionCount)} />+ <StatBlock label="Credits" value={credits.toLocaleString()} />+ </div>++ <div className="flex flex-wrap items-center gap-2">+ <StatusBadge status={workflowRun.status} />+ {workflowRun.failure_category?.length ? (+ <FailureCategoryBadge+ failureCategory={workflowRun.failure_category}+ />+ ) : null}+ </div>++ {workflowRun.failure_reason ? (+ <div className="flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm">+ <ExclamationTriangleIcon className="mt-0.5 h-4 w-4 shrink-0 text-destructive" />+ <span className="whitespace-pre-wrap break-words text-foreground">+ {workflowRun.failure_reason}+ </span>+ </div>+ ) : null}++ <div className="flex flex-col gap-3">+ {workflowRun.started_at ? (+ <OverviewField label="Started">+ <span+ title={basicTimeFormat(workflowRun.started_at)}+ className="text-xs"+ >+ {basicLocalTimeFormat(workflowRun.started_at)}+ </span>+ </OverviewField>+ ) : null}+ {finalized && workflowRun.finished_at ? (+ <OverviewField label="Finished">+ <span+ title={basicTimeFormat(workflowRun.finished_at)}+ className="text-xs"+ >+ {basicLocalTimeFormat(workflowRun.finished_at)}+ </span>+ </OverviewField>+ ) : null}+ <OverviewField label="Duration">+ <span className="flex items-center gap-1.5 text-xs">+ <ClockIcon className="h-3.5 w-3.5 text-muted-foreground" />+ {elapsed}+ </span>+ </OverviewField>+ <OverviewField label="Run ID">+ <div className="flex items-center gap-1.5">+ <span className="truncate font-mono text-xs">+ {workflowRun.workflow_run_id}+ </span>+ <CopyButton value={workflowRun.workflow_run_id} />+ </div>+ </OverviewField>+ {webhookState ? (+ <OverviewField label="Webhook">+ <span+ className="font-mono text-xs"+ title={webhookFailureReason ?? undefined}+ >+ {webhookState}+ </span>+ </OverviewField>+ ) : null}+ {workflowRun.browser_session_id ? (+ <OverviewField label="Browser session">+ <Link+ to={`/browser-session/${workflowRun.browser_session_id}/stream`}+ className="font-mono text-xs text-studio-accent-2 underline-offset-4 hover:underline"+ >+ {workflowRun.browser_session_id}+ </Link>+ </OverviewField>+ ) : null}+ {workflowRun.browser_profile_id ? (+ <OverviewField label="Browser profile">+ <Link+ to={`/browser-profiles/${workflowRun.browser_profile_id}`}+ className="font-mono text-xs text-studio-accent-2 underline-offset-4 hover:underline"+ >+ {workflowRun.browser_profile_id}+ </Link>+ </OverviewField>+ ) : null}+ </div>+ </div>+ );+}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsxnew file mode 100644index 000000000..81d74fadd--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx@@ -0,0 +1,101 @@+import { useState } from "react";+import { Share1Icon } from "@radix-ui/react-icons";++import { ApiWebhookActionsMenu } from "@/components/ApiWebhookActionsMenu";+import { StatusBadge } from "@/components/StatusBadge";+import { WebhookReplayDialog } from "@/components/WebhookReplayDialog";+import { useApiCredential } from "@/hooks/useApiCredential";+import { statusIsFinalized } from "@/routes/tasks/types";+import { type ApiCommandOptions } from "@/util/apiCommands";+import { runsApiBaseUrl } from "@/util/env";+import { cn } from "@/util/utils";++import { useWorkflowRunWithWorkflowQuery } from "../../hooks/useWorkflowRunWithWorkflowQuery";+import { useStudioPaneCompact } from "../StudioShellContext";+import { useStudioInspectedRun } from "../useStudioInspectedRun";++/**+ * Left header cluster of the Run pane: the inspected run's status pill.+ * Queries dedupe with the pane body via react-query.+ */+export function RunPaneStatusBadge() {+ const { runId } = useStudioInspectedRun();+ const { data: workflowRun } = useWorkflowRunWithWorkflowQuery(+ runId ? { workflowRunId: runId } : undefined,+ );+ if (!workflowRun) {+ return null;+ }+ return <StatusBadge status={workflowRun.status} />;+}++/**+ * Right header cluster of the Run pane: the API & Webhooks menu for the+ * inspected run, relocated from the retired run-hero header.+ */+export function RunPaneActions() {+ const compact = useStudioPaneCompact();+ const apiCredential = useApiCredential();+ const { runId } = useStudioInspectedRun();+ const { data: workflowRun } = useWorkflowRunWithWorkflowQuery(+ runId ? { workflowRunId: runId } : undefined,+ );+ const [replayOpen, setReplayOpen] = useState(false);+ if (!workflowRun) {+ return null;+ }+ const finalized = statusIsFinalized(workflowRun);+ return (+ <>+ <ApiWebhookActionsMenu+ trigger={+ <button+ type="button"+ title={compact ? "API & Webhooks" : undefined}+ aria-label="API & Webhooks"+ className={cn(+ "inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium",+ "text-muted-foreground hover:bg-slate-elevation3 hover:text-foreground",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ )}+ >+ <Share1Icon className="h-4 w-4" />+ {compact ? null : "API & Webhooks"}+ </button>+ }+ getOptions={() => {+ const headers: Record<string, string> = {+ "Content-Type": "application/json",+ "x-api-key": apiCredential ?? "<your-api-key>",+ };+ const body: Record<string, unknown> = {+ workflow_id: workflowRun.workflow?.workflow_permanent_id,+ parameters: workflowRun.parameters,+ proxy_location: workflowRun.proxy_location,+ };+ if (workflowRun.max_screenshot_scrolls != null) {+ body.max_screenshot_scrolls = workflowRun.max_screenshot_scrolls;+ }+ if (workflowRun.webhook_callback_url) {+ body.webhook_url = workflowRun.webhook_callback_url;+ }+ return {+ method: "POST",+ url: `${runsApiBaseUrl}/run/workflows`,+ body,+ headers,+ } satisfies ApiCommandOptions;+ }}+ webhookDisabled={!finalized}+ onTestWebhook={() => setReplayOpen(true)}+ />+ <WebhookReplayDialog+ runId={workflowRun.workflow_run_id}+ disabled={!finalized}+ open={replayOpen}+ onOpenChange={setReplayOpen}+ hideTrigger+ />+ </>+ );+}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsxindex cf4074fff..a8c3266c9 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx@@ -1,13 +1,8 @@// @vitest-environment jsdom-import {- act,- cleanup,- fireEvent,- render,- within,-} from "@testing-library/react";-import { MemoryRouter } from "react-router-dom";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { cleanup, fireEvent, render, within } from "@testing-library/react";+import { MemoryRouter, useLocation } from "react-router-dom";import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import { type ReactNode } from "react";@@ -19,13 +14,11 @@ import type {WorkflowRunTimelineItem,} from "../../types/workflowRunTypes";import { RunView } from "./RunView";-import { getSelectedRunFrameId } from "./runFrameSelection";const mocks = vi.hoisted(() => ({workflowRun: undefined as unknown,timeline: undefined as unknown,- debugSession: undefined as unknown,- runHeroProps: [] as Array<Record<string, unknown>>,+ codeGenerating: false,}));vi.mock("../../hooks/useWorkflowRunWithWorkflowQuery", () => ({@@ -40,23 +33,11 @@ vi.mock("../../hooks/useWorkflowRunTimelineQuery", () => ({isLoading: false,}),}));-vi.mock("../../hooks/useDebugSessionQuery", () => ({- useDebugSessionQuery: () => ({ data: mocks.debugSession }),-}));vi.mock("../../editor/hooks/useIsGeneratingCode", () => ({- useIsGeneratingCode: () => false,+ useIsGeneratingCode: () => mocks.codeGenerating,}));-vi.mock("./RunHero", () => ({- RunHero: (props: Record<string, unknown> & { outputs?: ReactNode }) => {- mocks.runHeroProps.push(props);- return (- <div data-testid="run-hero">- {props.outputs ? (- <div data-testid="run-outputs">{props.outputs}</div>- ) : null}- </div>- );- },+vi.mock("../../workflowRun/WorkflowRunCode", () => ({+ WorkflowRunCode: () => <div data-testid="workflow-run-code" />,}));vi.mock("../../workflowRun/WorkflowRunVerificationCodeForm", () => ({WorkflowRunVerificationCodeForm: () => null,@@ -71,7 +52,6 @@ vi.mock("@/components/ui/scroll-area", () => ({vi.mock("posthog-js/react", () => ({usePostHog: () => ({ capture: vi.fn() }),}));-vi.mock("@/hooks/useApiCredential", () => ({ useApiCredential: () => null }));function buildBlock(overrides: Partial<WorkflowRunBlock> = {},@@ -197,175 +177,232 @@ function seedCompletedRun(overrides: Record<string, unknown> = {}) {};}+function seedRunningRun() {+ mocks.timeline = [+ buildBlockItem(+ buildBlock({+ workflow_run_block_id: "wrb_1",+ label: "goto-block",+ actions: [+ buildAction({+ action_id: "act_1",+ action_order: 0,+ screenshot_artifact_id: "art_1",+ }),+ ],+ }),+ ),+ ];+ mocks.workflowRun = {+ workflow_run_id: "wr_1",+ status: Status.Running,+ browser_session_id: "pbs_1",+ workflow: {+ workflow_definition: { blocks: [], finally_block_label: null },+ },+ };+}++function LocationSpy() {+ const location = useLocation();+ return <div data-testid="location-search">{location.search}</div>;+}++function renderRunView(+ props: Partial<Parameters<typeof RunView>[0]> = {},+ initialEntry = "/",+) {+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ return render(+ <QueryClientProvider client={queryClient}>+ <MemoryRouter initialEntries={[initialEntry]}>+ <RunView workflowRunId="wr_1" {...props} />+ <LocationSpy />+ </MemoryRouter>+ </QueryClientProvider>,+ );+}+afterEach(() => {cleanup();mocks.workflowRun = undefined;mocks.timeline = undefined;- mocks.debugSession = undefined;- mocks.runHeroProps = [];+ mocks.codeGenerating = false;});-const initialStudioBrowserState = useStudioBrowserStore.getState();--// jsdom doesn't implement scrollIntoView; focusBrowserPane calls it via rAF.-Element.prototype.scrollIntoView = vi.fn();-beforeEach(() => {useRunViewStore.getState().reset();- useStudioBrowserStore.setState(initialStudioBrowserState, true);+ useStudioBrowserStore.setState({ view: "auto" });});-describe("getSelectedRunFrameId", () => {- test("defaults to live stream while a run is running", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: null,- running: true,- lastFrameId: "action_1",- }),- ).toBe("stream");+describe("RunView view toggles", () => {+ test("defaults to the Timeline view with the timeline and step detail", () => {+ seedForLoopRun();+ const { container } = renderRunView();+ const scope = within(container);++ expect(scope.getByRole("group", { name: "Run view" })).not.toBeNull();+ // The timeline tree is visible by default (loop row present).+ expect(scope.queryAllByText("checkout-loop").length).toBeGreaterThan(0);});- test("preserves an explicit pinned frame while a run is running", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: "action_1",- running: true,- lastFrameId: "action_2",- }),- ).toBe("action_1");+ test("Overview view shows the run stat blocks and metadata", () => {+ seedCompletedRun({+ total_steps: 12,+ credits_used: 3,+ cached_credits_used: 2,+ webhook_callback_url: "https://example.test/hook",+ });+ mocks.timeline = [+ buildBlockItem(+ buildBlock({+ workflow_run_block_id: "wrb_1",+ actions: [buildAction({ action_id: "act_1" })],+ }),+ ),+ ];+ const { container } = renderRunView();+ const scope = within(container);++ fireEvent.click(scope.getByRole("button", { name: "Overview" }));++ expect(scope.getByText("Steps")).not.toBeNull();+ expect(scope.getByText("12")).not.toBeNull();+ expect(scope.getByText("Actions")).not.toBeNull();+ // total credits = credits_used + cached_credits_used+ expect(scope.getByText("5")).not.toBeNull();+ expect(scope.getByText("wr_1")).not.toBeNull();+ expect(scope.getByText("delivered")).not.toBeNull();});- test("uses the latest frame while a running run shows screenshots", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: null,- running: true,- showingScreenshots: true,- lastFrameId: "action_2",- }),- ).toBe("action_2");+ test("Overview reports a failed webhook delivery", () => {+ seedCompletedRun({+ webhook_callback_url: "https://example.test/hook",+ webhook_failure_reason: "410 gone",+ });+ const { container } = renderRunView();+ const scope = within(container);++ fireEvent.click(scope.getByRole("button", { name: "Overview" }));+ expect(scope.getByText("failed")).not.toBeNull();});- test("uses the final frame after a live stream pin outlives a completed run", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: "stream",- running: false,- lastFrameId: "action_2",- }),- ).toBe("action_2");+ test("Inputs view shows the run's input metadata", () => {+ seedCompletedRun({+ webhook_callback_url: "https://example.test/hook",+ });+ const { container } = renderRunView();+ const scope = within(container);++ fireEvent.click(scope.getByRole("button", { name: "Inputs" }));+ expect(scope.getByText("Webhook URL")).not.toBeNull();+ expect(scope.getByText("https://example.test/hook")).not.toBeNull();});- test("preserves an explicit pinned frame after a run finalizes", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: "action_1",- running: false,- lastFrameId: "action_2",- }),- ).toBe("action_1");+ test("Code view renders the shared WorkflowRunCode surface", () => {+ seedCompletedRun();+ const { container } = renderRunView();+ const scope = within(container);++ expect(scope.queryByTestId("workflow-run-code")).toBeNull();+ fireEvent.click(scope.getByRole("button", { name: "Code" }));+ expect(scope.queryByTestId("workflow-run-code")).not.toBeNull();});- test("defaults to the final frame after a run finalizes without a pin", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: null,- running: false,- lastFrameId: "action_2",- }),- ).toBe("action_2");+ test("the Code toggle shows a spinner while cached code is generating", () => {+ seedCompletedRun();+ mocks.codeGenerating = true;+ const { container } = renderRunView();+ const scope = within(container);++ expect(scope.queryByTestId("code-generating-spinner")).not.toBeNull();});- test("uses the latest frame while the Browser pane owns a live debug stream", () => {- expect(- getSelectedRunFrameId({- pinnedFrameId: null,- running: true,- debugStreamInBrowserPane: true,- lastFrameId: "action_2",- }),- ).toBe("action_2");+ test("hides the Inputs and Outputs toggles when the run has neither", () => {+ seedCompletedRun();+ const { container } = renderRunView();+ const scope = within(container);++ expect(scope.queryByRole("button", { name: "Inputs" })).toBeNull();+ expect(scope.queryByRole("button", { name: "Outputs" })).toBeNull();});});-function seedLiveBlockRun() {- mocks.debugSession = { browser_session_id: "pbs_1" };- mocks.timeline = [- buildBlockItem(- buildBlock({- workflow_run_block_id: "wrb_1",- actions: [- buildAction({- action_id: "act_1",- action_order: 0,- screenshot_artifact_id: "art_1",- }),- ],- }),- ),- ];- mocks.workflowRun = {- workflow_run_id: "wr_1",- status: Status.Running,- browser_session_id: "pbs_1",- workflow: {- workflow_definition: { blocks: [], finally_block_label: null },- },- };-}+describe("RunView failure banner", () => {+ test("shows the failure reason with 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);-describe("RunView block run and the Browser pane", () => {- test("Browser pane open: the hero gets live-edge screenshots, not the stream selection", () => {- seedLiveBlockRun();- render(- <MemoryRouter- initialEntries={["/?wr=wr_1&bl=Block%201&panes=run,browser"]}- >- <RunView workflowRunId="wr_1" />- </MemoryRouter>,+ expect(+ scope.getByText("Login page rejected the credentials"),+ ).not.toBeNull();++ fireEvent.click(scope.getByRole("button", { name: "Fix with Copilot" }));+ expect(onFix).toHaveBeenCalledTimes(1);+ expect(onFix.mock.calls[0]?.[0]).toContain(+ "Login page rejected the credentials",);- const props = mocks.runHeroProps[mocks.runHeroProps.length - 1];- expect(props?.showDebugStream).toBe(true);- expect(props?.debugStreamInBrowserPane).toBe(true);- // Without the remap the "stream" selection would leave heroSelection null.- expect(props?.heroSelection).toMatchObject({- kind: "action",- artifactId: "art_1",+ fireEvent.click(scope.getByRole("button", { name: "Retry as-is" }));+ expect(onRetry).toHaveBeenCalledTimes(1);+ });++ test("dismiss hides the failure banner", () => {+ seedCompletedRun({+ status: Status.Failed,+ failure_reason: "Something broke",+ });+ const { container } = renderRunView();+ const scope = within(container);++ fireEvent.click(scope.getByRole("button", { name: "Dismiss" }));+ expect(scope.queryByText("Something broke")).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);++ expect(scope.queryByText("canceled by user")).toBeNull();});+});- test("focusBrowserPane pins the Browser pane's Live view", () => {- seedLiveBlockRun();+describe("RunView live affordances", () => {+ test("a running run shows the Live chip; clicking hands off to the Browser pane", () => {+ seedRunningRun();+ useRunViewStore.getState().pinFrame("act_1");+ // Park the Browser pane on a pinned replay view: the Live CTA promises+ // live, so the pinned pill must not swallow the handoff.useStudioBrowserStore.setState({ view: "screenshots" });- render(- <MemoryRouter- initialEntries={["/?wr=wr_1&bl=Block%201&panes=run,browser"]}- >- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );+ const { container, getByTestId } = renderRunView();+ const scope = within(container);- const props = mocks.runHeroProps[mocks.runHeroProps.length - 1];- act(() => {- (props?.onFocusBrowserPane as () => void)();- });- // The CTA promises live; a pinned replay pill must not swallow it.+ fireEvent.click(scope.getByRole("button", { name: "Live" }));++ // Unpins to the live edge and pins the Browser pane's view intent to live.+ expect(useRunViewStore.getState().pinnedFrameId).toBeNull();expect(useStudioBrowserStore.getState().view).toBe("live");+ expect(getByTestId("location-search").textContent).toContain("browser");});- test("Browser pane closed, Run pane open: the hero stays self-sufficient", () => {- seedLiveBlockRun();- render(- <MemoryRouter initialEntries={["/?wr=wr_1&bl=Block%201&panes=run"]}>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );+ test("a queued run shows the queued chip instead of the Live chip", () => {+ seedCompletedRun({ status: Status.Queued });+ const { container } = renderRunView();+ const scope = within(container);- const props = mocks.runHeroProps[mocks.runHeroProps.length - 1];- expect(props?.showDebugStream).toBe(true);- expect(props?.debugStreamInBrowserPane).toBe(false);- expect(props?.paneOpen).toBe(true);+ expect(scope.queryByText(/Run queued/)).not.toBeNull();+ expect(scope.queryByRole("button", { name: "Live" })).toBeNull();});});@@ -374,11 +411,7 @@ describe("RunView iteration selection", () => {seedForLoopRun();// Seed ?active= so the loop is the selected (and expanded) item on mount,// making its iteration rows visible.- const { container } = render(- <MemoryRouter initialEntries={["/?active=wrb_loop"]}>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );+ const { container } = renderRunView({}, "/?active=wrb_loop");const scope = within(container);// Baseline: loop overview (all iterable values), not a single iteration.@@ -388,141 +421,18 @@ describe("RunView iteration selection", () => {fireEvent.click(scope.getByText("Iteration 2"));expect(scope.queryByText("Iteration 2 value")).not.toBeNull();expect(scope.queryByText(/Iterable values/)).toBeNull();+ // The iteration scope is shared with the Browser pane via the store.+ expect(useRunViewStore.getState().activeIteration).toBe(1);// Click the loop block row (descriptor text is timeline-only). The detail// must fall back to the loop overview instead of staying on iteration 2.fireEvent.click(scope.getByText(/Loop over 2 values/));expect(scope.queryByText(/Iterable values/)).not.toBeNull();expect(scope.queryByText("Iteration 2 value")).toBeNull();+ expect(useRunViewStore.getState().activeIteration).toBeNull();}, 20_000);});-describe("RunView screenshot center view", () => {- test("selects the latest action frame when a running run opens Screenshots", () => {- mocks.timeline = [- buildBlockItem(- buildBlock({- workflow_run_block_id: "wrb_1",- actions: [- buildAction({- action_id: "act_1",- action_order: 0,- screenshot_artifact_id: "art_1",- }),- ],- }),- ),- ];- mocks.workflowRun = {- workflow_run_id: "wr_1",- status: Status.Running,- workflow: {- workflow_definition: { blocks: [], finally_block_label: null },- },- };-- render(- <MemoryRouter>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );-- const props = mocks.runHeroProps[mocks.runHeroProps.length - 1];- expect(props?.heroSelection).toBeNull();-- act(() => {- useRunViewStore.getState().pinFrame("stream");- useRunViewStore.getState().setCenterView("screenshots");- });-- const screenshotProps = mocks.runHeroProps[mocks.runHeroProps.length - 1];- expect(screenshotProps?.hasScreenshots).toBe(true);- expect(screenshotProps?.heroSelection).toMatchObject({- kind: "action",- artifactId: "art_1",- stepId: "step_default",- actionOrder: 0,- });- });-- test("does not advertise screenshots for actions without screenshot candidates", () => {- mocks.timeline = [- buildBlockItem(- buildBlock({- workflow_run_block_id: "wrb_1",- actions: [- buildAction({- action_id: "act_1",- step_id: null,- screenshot_artifact_id: null,- }),- ],- }),- ),- ];- mocks.workflowRun = {- workflow_run_id: "wr_1",- status: Status.Completed,- workflow: {- workflow_definition: { blocks: [], finally_block_label: null },- },- };-- render(- <MemoryRouter>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );-- const props = mocks.runHeroProps[mocks.runHeroProps.length - 1];- expect(props?.hasScreenshots).toBe(false);- expect(props?.heroSelection).toMatchObject({- kind: "action",- artifactId: null,- stepId: null,- });- });-- test("does not advertise step screenshots without an action order", () => {- mocks.timeline = [- buildBlockItem(- buildBlock({- workflow_run_block_id: "wrb_1",- actions: [- buildAction({- action_id: "act_1",- action_order: null,- screenshot_artifact_id: null,- }),- ],- }),- ),- ];- mocks.workflowRun = {- workflow_run_id: "wr_1",- status: Status.Completed,- workflow: {- workflow_definition: { blocks: [], finally_block_label: null },- },- };-- render(- <MemoryRouter>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );-- const props = mocks.runHeroProps[mocks.runHeroProps.length - 1];- expect(props?.hasScreenshots).toBe(false);- expect(props?.heroSelection).toMatchObject({- kind: "action",- artifactId: null,- stepId: "step_default",- actionOrder: null,- });- });-});-describe("RunView output signals", () => {test("surfaces run errors, error codes, and rich downloaded files", () => {seedCompletedRun({@@ -549,13 +459,11 @@ describe("RunView output signals", () => {downloaded_file_urls: null,});- const { container } = render(- <MemoryRouter>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );+ const { container } = renderRunView();const scope = within(container);+ fireEvent.click(scope.getByRole("button", { name: "Outputs" }));+expect(scope.getByText("Run errors")).not.toBeNull();expect(scope.getAllByText("E_INVOICE_MISSING").length).toBeGreaterThan(0);expect(scope.getByText("E_PAYMENT_BLOCKED")).not.toBeNull();@@ -574,27 +482,20 @@ describe("RunView output signals", () => {},});- const { container } = render(- <MemoryRouter>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );+ const { container } = renderRunView();const scope = within(container);+ expect(scope.queryByRole("button", { name: "Outputs" })).toBeNull();expect(scope.queryByText("Run errors")).toBeNull();});- test("does not add an output slot when run signals are absent", () => {+ test("does not offer an Outputs view when run signals are absent", () => {seedCompletedRun();- const { container } = render(- <MemoryRouter>- <RunView workflowRunId="wr_1" />- </MemoryRouter>,- );+ const { container } = renderRunView();const scope = within(container);- expect(scope.queryByTestId("run-outputs")).toBeNull();+ expect(scope.queryByRole("button", { name: "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.tsxindex b63dd81ae..cdf1a7641 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -1,50 +1,44 @@import { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { Share1Icon } from "@radix-ui/react-icons";-import { usePostHog } from "posthog-js/react";+import {+ ActivityLogIcon,+ ClockIcon,+ CodeIcon,+ Cross2Icon,+ ExclamationTriangleIcon,+ FileTextIcon,+ ListBulletIcon,+ ReaderIcon,+ ReloadIcon,+} from "@radix-ui/react-icons";import { useParams, useSearchParams } from "react-router-dom";import { Status } from "@/api/types";-import { ApiWebhookActionsMenu } from "@/components/ApiWebhookActionsMenu";-import { WebhookReplayDialog } from "@/components/WebhookReplayDialog";-import { useApiCredential } from "@/hooks/useApiCredential";+import { Button } from "@/components/ui/button";import { statusIsFinalized } from "@/routes/tasks/types";-import {- isAction,- isObserverThought,- isWorkflowRunBlock,-} from "@/routes/workflows/types/workflowRunTypes";import { useRunViewStore } from "@/store/RunViewStore";import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";-import { type ApiCommandOptions } from "@/util/apiCommands";-import { runsApiBaseUrl } from "@/util/env";-import { cn, isRecord } from "@/util/utils";+import { isRecord } from "@/util/utils";import { useIsGeneratingCode } from "../../editor/hooks/useIsGeneratingCode";import { constructCacheKeyValue } from "../../editor/utils";-import { useDebugSessionQuery } from "../../hooks/useDebugSessionQuery";import { useWorkflowRunTimelineQuery } from "../../hooks/useWorkflowRunTimelineQuery";import { useWorkflowRunWithWorkflowQuery } from "../../hooks/useWorkflowRunWithWorkflowQuery";import { WorkflowRunBlockDetail } from "../../workflowRun/WorkflowRunBlockDetail";+import { WorkflowRunCode } from "../../workflowRun/WorkflowRunCode";import { WorkflowRunTimeline } from "../../workflowRun/WorkflowRunTimeline";import { WorkflowRunVerificationCodeForm } from "../../workflowRun/WorkflowRunVerificationCodeForm";import { pickDownloadedFileFilename } from "../../workflowRun/blockDownloadedFiles";-import { getRecordingUrls } from "../../workflowRun/recordingUrls";-import {- findActiveItem,- findTimelineBlock,- resolveScreenshotBlockId,-} from "../../workflowRun/workflowTimelineUtils";+import { findActiveItem } from "../../workflowRun/workflowTimelineUtils";import { getOrderedRunParameters } from "../../utils";import {- actionLabel,buildFilmstrip,formatElapsed,runOutcomeFromStatus,} from "../runProjections";import { studioPanelId } from "../constants";import { useStudioPanes } from "../useStudioPanes";-import { RunHero } from "./RunHero";-import { type HeroSelection } from "./HeroScreenshot";+import { ViewToggle } from "../ViewToggle";+import { matchFailureTips } from "./failureTips";import { buildRunFixMessage } from "./runFixMessage";import { RunInputsSection, type RunInputMeta } from "./RunInputsSection";import {@@ -52,9 +46,8 @@ import {type RunOutputError,type RunOutputFile,} from "./RunOutputsSection";-import { RunOverviewButton } from "./RunOverviewButton";+import { RunOverviewSection } from "./RunOverviewSection";import { RunPlaceholder } from "./RunPlaceholder";-import { getSelectedRunFrameId } from "./runFrameSelection";type RunViewProps = {workflowRunId?: string;@@ -65,18 +58,11 @@ type RunViewProps = {onRetry?: () => void;};-function hasScreenshotCandidate(selection: HeroSelection | null): boolean {- if (!selection) {- return false;- }- if (selection.kind === "action") {- return Boolean(- selection.artifactId ||- (selection.stepId && selection.actionOrder != null),- );- }- return true;-}+type RunPaneView = "timeline" | "overview" | "inputs" | "outputs" | "code";++// Below this row width the view-toggle labels collapse to icons — the pane,+// not the viewport, decides (studio panes share the stage side by side).+const TOGGLE_ROW_COMPACT_BELOW_PX = 440;function isRunOutputError(value: unknown): value is RunOutputError {return isRecord(value);@@ -90,8 +76,10 @@ function normalizeRunOutputErrors(value: unknown): RunOutputError[] {}/**- * Fused run view: browser hero on the left, run timeline tree + block detail on- * the right, sharing one pinned item via RunViewStore.+ * Run pane body: the run timeline + step detail, with Overview / Inputs /+ * Outputs / Code as sibling views. Visuals (live stream, screenshots,+ * recordings) live in the Browser pane, which follows this pane's selection+ * via RunViewStore and ?active=.*/export function RunView({workflowRunId,@@ -117,51 +105,28 @@ export function RunView({workflowPermanentId,workflowRunId,});- const { data: debugSession } = useDebugSessionQuery({- workflowPermanentId,- enabled: false,- });const pinnedFrameId = useRunViewStore((s) => s.pinnedFrameId);- const centerView = useRunViewStore((s) => s.centerView);+ const activeIteration = useRunViewStore((s) => s.activeIteration);const pinFrame = useRunViewStore((s) => s.pinFrame);+ const jumpToLive = useRunViewStore((s) => s.jumpToLive);const resetRunView = useRunViewStore((s) => s.reset);- const headerCompact = useRunViewStore((s) => s.headerCompact);+ const setBrowserPaneView = useStudioBrowserStore((s) => s.setView);const { panes: studioPanes, openPane } = useStudioPanes();const runPaneOpen = studioPanes.includes("run");- const browserPaneOpen = studioPanes.includes("browser");const [searchParams, setSearchParams] = useSearchParams();const searchParamsRef = useRef(searchParams);searchParamsRef.current = searchParams;- const postHog = usePostHog();- const apiCredential = useApiCredential();- const [activeIteration, setActiveIteration] = useState<number | null>(null);- const [replayOpen, setReplayOpen] = useState(false);+ const [view, setView] = useState<RunPaneView>("timeline");+ const [failureDismissed, setFailureDismissed] = useState(false);const [outputSummary, setOutputSummary] = useState<string | null>(null);- const recordingUrls = useMemo(- () => getRecordingUrls(workflowRun),- [workflowRun],- );- const onRecordingPlay = useCallback(- (index: number) => {- if (!workflowRun) {- return;- }- postHog.capture("run.recording.viewed", {- org_id: workflowRun.workflow?.organization_id,- run_id: workflowRun.workflow_run_id,- recording_index: index,- recording_count: recordingUrls.length,- });- },- [postHog, workflowRun, recordingUrls.length],- );-// A pinned frame belongs to one run; drop it when the run changes, then re-seed// from ?active= to restore a deep-linked selection.useEffect(() => {resetRunView();setOutputSummary(null);+ setView("timeline");+ setFailureDismissed(false);const active = searchParamsRef.current.get("active");if (active) {pinFrame(active);@@ -231,27 +196,37 @@ export function RunView({}, [runPaneOpen, workflowRunId, setSearchParams]);const frames = useMemo(() => buildFilmstrip(timeline), [timeline]);+ const lastFrame = frames.length > 0 ? frames[frames.length - 1] : null;const outcome = runOutcomeFromStatus(workflowRun?.status);const running = outcome === "running";// A user-canceled run isn't a failure — don't show the "run failed" CTA.const canceled = workflowRun?.status === Status.Canceled;const failed = outcome === "failed" && !canceled;- // A block run executes in the debug session; in the Run pane show that same live- // debug stream (the shared node) instead of a separate run stream — but only when- // the run's browser session IS the current debug session. A historical block-run- // link whose debug session is gone/different falls back to the normal run view.- const showDebugStream =- runPaneOpen &&- searchParams.has("bl") &&- workflowRun?.browser_session_id != null &&- workflowRun.browser_session_id === debugSession?.browser_session_id;- // The open Browser pane outranks the hero for the singleton debug-stream- // node (StudioShell priority); the hero then points at it instead.- const debugStreamInBrowserPane = showDebugStream && browserPaneOpen;+ const provisioning =+ workflowRun?.status === Status.Created ||+ workflowRun?.status === Status.Queued;++ const finalized = workflowRun ? statusIsFinalized(workflowRun) : false;+ 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 =+ pinnedFrameId && pinnedFrameId !== "stream"+ ? pinnedFrameId+ : (lastFrame?.id ?? null);+ const activeItem = useMemo(+ () =>+ findActiveItem(timeline ?? [], selectedId, finalized, finallyBlockLabel),+ [timeline, selectedId, finalized, finallyBlockLabel],+ );+const focusBrowserPane = useCallback(() => {- // The pane may sit on a pinned replay view; this CTA promises live.- useStudioBrowserStore.getState().setView("live");+ // An explicit "watch live": unpin back to the live edge and hand the+ // Browser pane a live intent (it may be sitting on a replay view).+ jumpToLive();+ setBrowserPaneView("live");openPane("browser");// Defer past the pane-open commit so the scroll sees the visible panel.requestAnimationFrame(() => {@@ -264,91 +239,12 @@ export function RunView({inline: "nearest",});});- }, [openPane]);+ }, [jumpToLive, setBrowserPaneView, openPane]);const fixSeedMessage = useMemo(() => buildRunFixMessage(workflowRun?.failure_reason ?? null),[workflowRun?.failure_reason],);- const lastFrame = frames.length > 0 ? frames[frames.length - 1] : null;- const showingScreenshots = centerView === "screenshots";-- const finalized = workflowRun ? statusIsFinalized(workflowRun) : false;- const finallyBlockLabel =- workflowRun?.workflow?.workflow_definition?.finally_block_label ?? null;- const selectedId = getSelectedRunFrameId({- pinnedFrameId,- running,- showingScreenshots,- debugStreamInBrowserPane,- lastFrameId: lastFrame?.id ?? null,- });- const activeItem = useMemo(- () =>- findActiveItem(timeline ?? [], selectedId, finalized, finallyBlockLabel),- [timeline, selectedId, finalized, finallyBlockLabel],- );-- // Mirror the legacy run page: an action shows its own screenshot, a block shows- // its representative screenshot (a loop/conditional container resolves to its leaf).- const heroSelection = useMemo<HeroSelection | null>(() => {- if (isAction(activeItem)) {- return {- kind: "action",- artifactId: activeItem.screenshot_artifact_id ?? null,- stepId: activeItem.step_id ?? null,- actionOrder: activeItem.action_order ?? null,- };- }- if (isWorkflowRunBlock(activeItem)) {- const screenshotBlockId = resolveScreenshotBlockId(- timeline ?? [],- activeItem,- activeIteration,- );- const blockType =- findTimelineBlock(timeline ?? [], screenshotBlockId)?.block_type ??- activeItem.block_type ??- null;- return {- kind: "block",- workflowRunBlockId: screenshotBlockId,- blockType,- };- }- if (isObserverThought(activeItem)) {- return { kind: "thought", thoughtId: activeItem.thought_id };- }- return null;- }, [activeItem, timeline, activeIteration]);- const hasScreenshotFrame = useMemo(- () =>- frames.some(- (frame) =>- frame.screenshotArtifactId != null ||- (frame.stepId != null && frame.actionOrder != null),- ),- [frames],- );- const activeSelectionHasScreenshot = useMemo(- () => hasScreenshotCandidate(heroSelection),- [heroSelection],- );- // Frames are the usual source; the selection keeps the toggle visible while- // filmstrip data is still catching up.- const hasScreenshots = useMemo(- () => hasScreenshotFrame || activeSelectionHasScreenshot,- [hasScreenshotFrame, activeSelectionHasScreenshot],- );-- const heroLabel = isAction(activeItem)- ? actionLabel(activeItem)- : isWorkflowRunBlock(activeItem)- ? (activeItem.label ?? "Screenshot")- : isObserverThought(activeItem)- ? (activeItem.thought ?? "Thought")- : "Screenshot";-const extractedInformation = useMemo<Record<string, unknown> | null>(() => {const outputs = workflowRun?.outputs;return isRecord(outputs) && "extracted_information" in outputs@@ -433,6 +329,26 @@ export function RunView({observerOutput != null ||webhookFailureReason != null;+ // Collapse toggle labels to icons by the row's own width.+ const hasRun = workflowRun != null;+ const toggleRowRef = useRef<HTMLDivElement>(null);+ const [toggleCompact, setToggleCompact] = useState(false);+ useEffect(() => {+ const el = toggleRowRef.current;+ if (!hasRun || !el || typeof ResizeObserver === "undefined") {+ return;+ }+ const observer = new ResizeObserver((entries) => {+ const width = entries[0]?.contentRect.width ?? 0;+ // A closed pane measures 0 (display:none); keep its last real state.+ if (width > 0) {+ setToggleCompact(width < TOGGLE_ROW_COMPACT_BELOW_PX);+ }+ });+ observer.observe(el);+ return () => observer.disconnect();+ }, [hasRun]);+if (!workflowRun) {return <RunPlaceholder loading={isLoading || runIdPending} />;}@@ -442,132 +358,152 @@ export function RunView({finalized ? (workflowRun.finished_at ?? null) : null,);+ // A selected view whose data vanished (run change settles late) falls back+ // to the timeline instead of rendering an empty body.+ const resolvedView =+ (view === "inputs" && !hasInputs) || (view === "outputs" && !hasOutputs)+ ? "timeline"+ : view;+return (- <div className="flex h-full min-h-0 w-full flex-col p-3">- <div className="flex min-h-0 flex-1 items-stretch gap-3 overflow-hidden">- <div className="flex min-w-0 flex-1 flex-col gap-3 overflow-hidden">- <WorkflowRunVerificationCodeForm- workflowRunId={workflowRun.workflow_run_id}+ <div className="flex h-full min-h-0 w-full flex-col">+ <div+ ref={toggleRowRef}+ className="flex shrink-0 items-center gap-2 border-b border-border px-3 py-2"+ >+ <div+ role="group"+ aria-label="Run view"+ className="flex min-w-0 shrink items-center gap-0.5 overflow-hidden rounded-md border border-slate-700 bg-slate-elevation2 p-0.5"+ >+ <ViewToggle+ active={resolvedView === "timeline"}+ onClick={() => setView("timeline")}+ compact={toggleCompact}+ label="Timeline"+ icon={<ActivityLogIcon className="h-3 w-3" />}/>- <RunHero- workflowRunId={workflowRun.workflow_run_id}- heroSelection={heroSelection}- heroLabel={heroLabel}- running={running}- showDebugStream={showDebugStream}- debugStreamInBrowserPane={debugStreamInBrowserPane}- onFocusBrowserPane={focusBrowserPane}- paneOpen={runPaneOpen}- provisioning={- workflowRun.status === Status.Created ||- workflowRun.status === Status.Queued- }- isPaused={workflowRun.status === Status.Paused}- failed={failed}- failureReason={workflowRun.failure_reason ?? null}- codeGenerating={codeGenerating}- browserSessionId={workflowRun.browser_session_id ?? null}- recordingUrls={recordingUrls}- recordingArchived={workflowRun.recording_archived ?? false}- hasScreenshots={hasScreenshots}- elapsed={elapsed}- overview={- <RunOverviewButton- status={workflowRun.status}- elapsed={elapsed}- startedAt={workflowRun.started_at ?? null}- finishedAt={workflowRun.finished_at ?? null}- failureReason={workflowRun.failure_reason ?? null}- failureCategory={workflowRun.failure_category ?? null}- workflowRunId={workflowRun.workflow_run_id}- browserSessionId={workflowRun.browser_session_id ?? null}- browserProfileId={workflowRun.browser_profile_id ?? null}- />- }- inputs={- hasInputs ? (- <RunInputsSection- parameters={runInputs.parameters}- meta={runInputs.meta}- />- ) : undefined- }- outputs={- hasOutputs ? (- <RunOutputsSection- workflowRunId={workflowRun.workflow_run_id}- workflowTitle={workflowRun.workflow?.title}- extractedInformation={extractedInformation}- files={downloadedFiles}- errors={runErrors}- observerOutput={observerOutput}- webhookFailureReason={webhookFailureReason}- summary={outputSummary}- onSummary={setOutputSummary}- />- ) : undefined+ <ViewToggle+ active={resolvedView === "overview"}+ onClick={() => setView("overview")}+ compact={toggleCompact}+ label="Overview"+ icon={<ReaderIcon className="h-3 w-3" />}+ />+ {hasInputs ? (+ <ViewToggle+ active={resolvedView === "inputs"}+ onClick={() => setView("inputs")}+ compact={toggleCompact}+ label="Inputs"+ icon={<ListBulletIcon className="h-3 w-3" />}+ />+ ) : null}+ {hasOutputs ? (+ <ViewToggle+ active={resolvedView === "outputs"}+ onClick={() => setView("outputs")}+ compact={toggleCompact}+ label="Outputs"+ icon={<FileTextIcon className="h-3 w-3" />}+ />+ ) : null}+ <ViewToggle+ active={resolvedView === "code"}+ onClick={() => setView("code")}+ compact={toggleCompact}+ label="Code"+ title={+ codeGenerating ? "Generating cached code for this run" : undefined}- actions={- <>- <ApiWebhookActionsMenu- trigger={- <button- type="button"- title={headerCompact ? "API & Webhooks" : undefined}- aria-label="API & Webhooks"- className={cn(- "inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium",- "text-muted-foreground hover:bg-slate-elevation3 hover:text-foreground",- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",- )}- >- <Share1Icon className="h-4 w-4" />- {headerCompact ? null : "API & Webhooks"}- </button>- }- getOptions={() => {- const headers: Record<string, string> = {- "Content-Type": "application/json",- "x-api-key": apiCredential ?? "<your-api-key>",- };- const body: Record<string, unknown> = {- workflow_id: workflowRun.workflow?.workflow_permanent_id,- parameters: workflowRun.parameters,- proxy_location: workflowRun.proxy_location,- };- if (workflowRun.max_screenshot_scrolls != null) {- body.max_screenshot_scrolls =- workflowRun.max_screenshot_scrolls;- }- if (workflowRun.webhook_callback_url) {- body.webhook_url = workflowRun.webhook_callback_url;- }- return {- method: "POST",- url: `${runsApiBaseUrl}/run/workflows`,- body,- headers,- } satisfies ApiCommandOptions;- }}- webhookDisabled={!finalized}- onTestWebhook={() => setReplayOpen(true)}- />- <WebhookReplayDialog- runId={workflowRun.workflow_run_id}- disabled={!finalized}- open={replayOpen}- onOpenChange={setReplayOpen}- hideTrigger+ icon={+ codeGenerating ? (+ <ReloadIcon+ data-testid="code-generating-spinner"+ className="h-3 w-3 animate-spin"/>- </>+ ) : (+ <CodeIcon className="h-3 w-3" />+ )}- onRecordingPlay={onRecordingPlay}- onFix={onFix ? () => onFix(fixSeedMessage) : undefined}- onRetry={onRetry}/></div>- <div className="relative w-[26rem] shrink-0">- <div className="absolute inset-0 grid grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-3">+ <span className="min-w-0 flex-1" />+ {running && !provisioning ? (+ <button+ type="button"+ onClick={focusBrowserPane}+ title="Watch live in the Browser pane"+ className="inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-slate-elevation2 px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-slate-elevation3 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ >+ <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-success" />+ Live+ </button>+ ) : null}+ </div>++ <div className="flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-hidden p-3">+ <WorkflowRunVerificationCodeForm+ workflowRunId={workflowRun.workflow_run_id}+ />++ {provisioning ? (+ <div className="flex shrink-0 items-center gap-2 rounded-md border border-border bg-slate-elevation2 px-3 py-1.5 text-xs text-muted-foreground">+ <ClockIcon className="h-3.5 w-3.5 shrink-0" />+ <span>Run queued — waiting to start</span>+ </div>+ ) : null}++ {failed && !failureDismissed ? (+ <div className="shrink-0 rounded-lg border border-destructive/40 bg-slate-elevation1 p-4">+ <div className="flex items-start gap-2 text-sm font-semibold text-foreground">+ <ExclamationTriangleIcon className="mt-0.5 h-4 w-4 shrink-0 text-destructive" />+ <span className="min-w-0 flex-1">+ {workflowRun.failure_reason ?? "The run failed."}+ {matchFailureTips(workflowRun.failure_reason ?? null).map(+ (tip) => (+ <span+ key={tip}+ className="mt-1.5 block text-xs font-normal italic text-muted-foreground"+ >+ {tip}+ </span>+ ),+ )}+ </span>+ <button+ type="button"+ onClick={() => setFailureDismissed(true)}+ className="-mr-1 -mt-1 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>+ {onFix || onRetry ? (+ <div className="mt-3 flex flex-wrap gap-2">+ {onFix ? (+ <Button+ size="sm"+ className="bg-studio-accent text-foreground hover:bg-studio-accent/90"+ onClick={() => onFix(fixSeedMessage)}+ >+ Fix with Copilot+ </Button>+ ) : null}+ {onRetry ? (+ <Button size="sm" variant="secondary" onClick={onRetry}>+ Retry as-is+ </Button>+ ) : null}+ </div>+ ) : null}+ </div>+ ) : null}++ {resolvedView === "timeline" ? (+ <div className="grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-3"><div className="min-h-0 overflow-hidden"><WorkflowRunTimelineworkflowRunId={workflowRunId}@@ -575,24 +511,19 @@ export function RunView({activeItem={activeItem}activeIteration={activeIteration}onActionItemSelected={(item) => {- setActiveIteration(null);pinFrame(item.action.action_id);}}onBlockItemSelected={(block) => {- setActiveIteration(null);pinFrame(block.workflow_run_block_id);}}onThoughtItemSelected={(thought) => {- setActiveIteration(null);pinFrame(thought.thought_id);}}onLiveStreamSelected={() => {- setActiveIteration(null);pinFrame("stream");}}onIterationSelected={(loopBlock, iterationIndex) => {- setActiveIteration(iterationIndex);- pinFrame(loopBlock.workflow_run_block_id);+ pinFrame(loopBlock.workflow_run_block_id, iterationIndex);}}/></div>@@ -608,7 +539,43 @@ export function RunView({/></div></div>- </div>+ ) : resolvedView === "overview" ? (+ <div className="min-h-0 flex-1 overflow-y-auto rounded-lg border border-border bg-slate-elevation1 p-4">+ <RunOverviewSection+ workflowRun={workflowRun}+ actionCount={frames.length}+ elapsed={elapsed}+ />+ </div>+ ) : resolvedView === "inputs" ? (+ <div className="min-h-0 flex-1 overflow-y-auto rounded-lg border border-border bg-slate-elevation1 p-4">+ <RunInputsSection+ parameters={runInputs.parameters}+ meta={runInputs.meta}+ />+ </div>+ ) : resolvedView === "outputs" ? (+ <div className="min-h-0 flex-1 overflow-y-auto rounded-lg border border-border bg-slate-elevation1 p-4">+ <RunOutputsSection+ workflowRunId={workflowRun.workflow_run_id}+ workflowTitle={workflowRun.workflow?.title}+ extractedInformation={extractedInformation}+ files={downloadedFiles}+ errors={runErrors}+ observerOutput={observerOutput}+ webhookFailureReason={webhookFailureReason}+ summary={outputSummary}+ onSummary={setOutputSummary}+ />+ </div>+ ) : (+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1 p-2">+ <WorkflowRunCode+ workflowRunId={workflowRun.workflow_run_id}+ showCacheKeyValueSelector+ />+ </div>+ )}</div></div>);diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/runFrameSelection.ts b/skyvern-frontend/src/routes/workflows/studio/runview/runFrameSelection.tsdeleted file mode 100644index 7dd4c179d..000000000--- a/skyvern-frontend/src/routes/workflows/studio/runview/runFrameSelection.ts+++ /dev/null@@ -1,25 +0,0 @@-export function getSelectedRunFrameId({- pinnedFrameId,- running,- showingScreenshots = false,- debugStreamInBrowserPane = false,- lastFrameId,-}: {- pinnedFrameId: string | null;- running: boolean;- showingScreenshots?: boolean;- debugStreamInBrowserPane?: boolean;- lastFrameId: string | null;-}): string | null {- const selectedId =- running && !showingScreenshots- ? (pinnedFrameId ?? "stream")- : pinnedFrameId === "stream"- ? lastFrameId- : (pinnedFrameId ?? lastFrameId);-- if (selectedId === "stream" && debugStreamInBrowserPane) {- return lastFrameId;- }- return selectedId;-}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/runHeroCenter.test.ts b/skyvern-frontend/src/routes/workflows/studio/runview/runHeroCenter.test.tsdeleted file mode 100644index 436e9bceb..000000000--- a/skyvern-frontend/src/routes/workflows/studio/runview/runHeroCenter.test.ts+++ /dev/null@@ -1,149 +0,0 @@-import { describe, expect, test } from "vitest";--import { resolveRunHeroCenterView } from "./runHeroCenter";--const defaultArgs = {- centerView: "default" as const,- hasScreenshots: false,- hasInputs: false,- hasOutputs: false,- hasRecording: false,- scrubbing: false,- showDebugStream: false,- debugStreamInBrowserPane: false,- recordingOpen: false,- running: false,- failed: false,-};--describe("resolveRunHeroCenterView", () => {- test("uses the screenshots tab when screenshots are available", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "screenshots",- hasScreenshots: true,- }),- ).toBe("screenshot");- });-- test("uses explicit content tabs when their content exists", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "code",- }),- ).toBe("code");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "inputs",- hasInputs: true,- }),- ).toBe("inputs");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "outputs",- hasOutputs: true,- }),- ).toBe("outputs");- });-- test("falls back when an explicit content tab has no content", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "inputs",- hasRecording: true,- }),- ).toBe("recording");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "outputs",- }),- ).toBe("screenshot");- });-- test("keeps explicit recording and run-frame overrides in finalized runs", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "recording",- hasRecording: true,- }),- ).toBe("recording");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- centerView: "screenshot",- hasRecording: true,- }),- ).toBe("screenshot");- });-- test("prioritizes scrubbed run frames before live or recording defaults", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- scrubbing: true,- showDebugStream: true,- recordingOpen: true,- hasRecording: true,- }),- ).toBe("screenshot");- });-- test("defaults block runs to the live debug stream unless recording is open", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- showDebugStream: true,- hasRecording: true,- }),- ).toBe("stream");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- showDebugStream: true,- recordingOpen: true,- hasRecording: true,- }),- ).toBe("recording");- });-- test("uses screenshots while the Browser pane owns a block run debug stream", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- showDebugStream: true,- debugStreamInBrowserPane: true,- hasRecording: true,- }),- ).toBe("screenshot");- });-- test("defaults full runs by lifecycle and failure state", () => {- expect(- resolveRunHeroCenterView({- ...defaultArgs,- running: true,- hasRecording: true,- }),- ).toBe("stream");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- hasRecording: true,- }),- ).toBe("recording");- expect(- resolveRunHeroCenterView({- ...defaultArgs,- failed: true,- hasRecording: true,- }),- ).toBe("screenshot");- });-});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/runHeroCenter.ts b/skyvern-frontend/src/routes/workflows/studio/runview/runHeroCenter.tsdeleted file mode 100644index e2bb4dd08..000000000--- a/skyvern-frontend/src/routes/workflows/studio/runview/runHeroCenter.ts+++ /dev/null@@ -1,73 +0,0 @@-import type { RunCenterView } from "@/store/RunViewStore";--// Rendered center panels are narrower than store intents: "default" is resolved-// away here, while "stream" is renderer-only and never stored as a center tab.-export type RunHeroCenterView =- | "code"- | "inputs"- | "outputs"- | "stream"- | "recording"- | "screenshot";--type ResolveRunHeroCenterViewArgs = {- centerView: RunCenterView;- hasScreenshots: boolean;- hasInputs: boolean;- hasOutputs: boolean;- hasRecording: boolean;- scrubbing: boolean;- showDebugStream: boolean;- debugStreamInBrowserPane: boolean;- recordingOpen: boolean;- running: boolean;- failed: boolean;-};--export function resolveRunHeroCenterView({- centerView,- hasScreenshots,- hasInputs,- hasOutputs,- hasRecording,- scrubbing,- showDebugStream,- debugStreamInBrowserPane,- recordingOpen,- running,- failed,-}: ResolveRunHeroCenterViewArgs): RunHeroCenterView {- if (centerView === "screenshots" && hasScreenshots) {- return "screenshot";- }- if (centerView === "code") {- return "code";- }- if (centerView === "inputs" && hasInputs) {- return "inputs";- }- if (centerView === "outputs" && hasOutputs) {- return "outputs";- }- if (centerView === "recording" && hasRecording) {- return "recording";- }- // A recording override can outlive the URLs during a reload; use the normal- // fallback order until there is a recording to render.- if (centerView === "screenshot") {- return "screenshot";- }- if (scrubbing) {- return "screenshot";- }- if (showDebugStream) {- if (recordingOpen && hasRecording) {- return "recording";- }- return debugStreamInBrowserPane ? "screenshot" : "stream";- }- if (running) {- return "stream";- }- return hasRecording && !failed ? "recording" : "screenshot";-}diff --git a/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.test.tsx b/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.test.tsxnew file mode 100644index 000000000..f0f42fcb5--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.test.tsx@@ -0,0 +1,152 @@+// @vitest-environment jsdom++import { renderHook } from "@testing-library/react";+import { MemoryRouter } from "react-router-dom";+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";+import { type ReactNode } from "react";++import { Status } from "@/api/types";+import { useRunViewStore } from "@/store/RunViewStore";+import type {+ WorkflowRunBlock,+ WorkflowRunTimelineItem,+} from "../types/workflowRunTypes";+import { useRunVisuals } from "./useRunVisuals";++const mocks = vi.hoisted(() => ({+ workflowRun: undefined as unknown,+ timeline: undefined as unknown,+}));++vi.mock("../hooks/useWorkflowRunWithWorkflowQuery", () => ({+ useWorkflowRunWithWorkflowQuery: () => ({+ data: mocks.workflowRun,+ isLoading: false,+ }),+}));+vi.mock("../hooks/useWorkflowRunTimelineQuery", () => ({+ useWorkflowRunTimelineQuery: () => ({+ data: mocks.timeline,+ isLoading: false,+ }),+}));++function buildBlock(+ overrides: Partial<WorkflowRunBlock> = {},+): WorkflowRunBlock {+ return {+ workflow_run_block_id: "wrb_default",+ workflow_run_id: "wr_default",+ parent_workflow_run_block_id: null,+ block_type: "task",+ label: null,+ description: null,+ title: null,+ status: Status.Completed,+ failure_reason: null,+ output: null,+ continue_on_failure: false,+ task_id: null,+ url: null,+ navigation_goal: null,+ navigation_payload: null,+ data_extraction_goal: null,+ data_schema: null,+ terminate_criterion: null,+ complete_criterion: null,+ include_action_history_in_verification: null,+ engine: null,+ actions: null,+ created_at: "2026-01-01T00:00:00Z",+ modified_at: "2026-01-01T00:00:00Z",+ duration: null,+ loop_values: null,+ current_value: null,+ current_index: null,+ ...overrides,+ };+}++function buildBlockItem(+ block: WorkflowRunBlock,+ children: Array<WorkflowRunTimelineItem> = [],+): WorkflowRunTimelineItem {+ return {+ type: "block",+ block,+ children,+ thought: null,+ created_at: block.created_at,+ modified_at: block.modified_at,+ };+}++function seedLoopRun() {+ const loop = buildBlock({+ workflow_run_block_id: "wrb_loop",+ block_type: "for_loop",+ label: "checkout-loop",+ loop_values: ["alpha", "beta"],+ current_index: 0,+ created_at: "2026-06-10T00:00:00Z",+ });+ const iter0 = buildBlock({+ workflow_run_block_id: "wrb_iter0",+ parent_workflow_run_block_id: "wrb_loop",+ current_index: 0,+ created_at: "2026-06-10T00:00:10Z",+ });+ const iter1 = buildBlock({+ workflow_run_block_id: "wrb_iter1",+ parent_workflow_run_block_id: "wrb_loop",+ current_index: 1,+ created_at: "2026-06-10T00:00:20Z",+ });+ mocks.timeline = [+ buildBlockItem(loop, [buildBlockItem(iter0), buildBlockItem(iter1)]),+ ];+ mocks.workflowRun = {+ workflow_run_id: "wr_1",+ status: Status.Completed,+ workflow: {+ workflow_definition: { blocks: [], finally_block_label: null },+ },+ };+}++function wrapper({ children }: { children: ReactNode }) {+ return (+ <MemoryRouter initialEntries={["/?active=wrb_loop"]}>+ {children}+ </MemoryRouter>+ );+}++afterEach(() => {+ mocks.workflowRun = undefined;+ mocks.timeline = undefined;+});+beforeEach(() => useRunViewStore.getState().reset());++describe("useRunVisuals loop-iteration threading", () => {+ test("resolves a selected container without an iteration to its first leaf", () => {+ seedLoopRun();+ const { result } = renderHook(() => useRunVisuals("wr_1"), { wrapper });++ expect(result.current.heroSelection).toMatchObject({+ kind: "block",+ workflowRunBlockId: "wrb_iter0",+ });+ });++ test("resolves the Run pane's selected iteration from the shared store", () => {+ seedLoopRun();+ useRunViewStore.getState().pinFrame("wrb_loop", 1);+ const { result } = renderHook(() => useRunVisuals("wr_1"), { wrapper });++ expect(result.current.heroSelection).toMatchObject({+ kind: "block",+ workflowRunBlockId: "wrb_iter1",+ });+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.ts b/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.tsindex 24ba28e95..d00304c03 100644--- a/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.ts+++ b/skyvern-frontend/src/routes/workflows/studio/useRunVisuals.ts@@ -9,6 +9,7 @@ import {isWorkflowRunBlock,WorkflowRunTimelineItem,} from "@/routes/workflows/types/workflowRunTypes";+import { useRunViewStore } from "@/store/RunViewStore";import { useWorkflowRunTimelineQuery } from "../hooks/useWorkflowRunTimelineQuery";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";@@ -67,6 +68,9 @@ export function useRunVisuals(workflowRunId: string | undefined): RunVisuals {const { data: timeline } = useWorkflowRunTimelineQuery(queryOptions);const [searchParams] = useSearchParams();const activeParam = searchParams.get("active");+ // The Run pane's loop-iteration selection isn't in the URL; read it from the+ // shared store so a selected iteration's screenshot resolves here too.+ const activeIteration = useRunViewStore((s) => s.activeIteration);const outcome = runOutcomeFromStatus(workflowRun?.status);const running = outcome === "running";@@ -114,7 +118,7 @@ export function useRunVisuals(workflowRunId: string | undefined): RunVisuals {const screenshotBlockId = resolveScreenshotBlockId(timeline ?? [],activeItem,- null,+ activeIteration,);const blockType =findTimelineBlock(timeline ?? [], screenshotBlockId)?.block_type ??@@ -130,7 +134,7 @@ export function useRunVisuals(workflowRunId: string | undefined): RunVisuals {return { kind: "thought", thoughtId: activeItem.thought_id };}return null;- }, [activeItem, timeline]);+ }, [activeItem, timeline, activeIteration]);const hasScreenshotFrame = useMemo(() =>diff --git a/skyvern-frontend/src/store/RunViewStore.ts b/skyvern-frontend/src/store/RunViewStore.tsindex f6fbc135c..f4478a815 100644--- a/skyvern-frontend/src/store/RunViewStore.ts+++ b/skyvern-frontend/src/store/RunViewStore.ts@@ -1,55 +1,30 @@import { create } from "zustand";-// Which tab takes over the hero center. "default" leaves the live stream /-// recording / screenshot logic in charge; the rest are explicit center tabs.-export type RunCenterView =- | "default"- | "screenshots"- | "recording"- | "screenshot"- | "code"- | "inputs"- | "outputs";-type RunViewState = {// The frame the user is inspecting. null means "follow the live edge" while- // running, or the recording once finalized.+ // running, or the final frame once finalized.pinnedFrameId: string | null;// Bumped on every pinFrame so the Browser pane can react to a re-pin of the// already-selected frame (the id alone wouldn't change).pinNonce: number;- centerView: RunCenterView;- // True when the run-tab header is too narrow for labels (set by RunHero); the- // toggles and externally-rendered dropdown triggers then collapse to icons.- headerCompact: boolean;- pinFrame: (id: string) => void;+ // Loop-iteration scope of a pinned container block. Not carried in ?active=,+ // so the Browser pane reads it here to resolve the iteration's screenshot.+ activeIteration: number | null;+ pinFrame: (id: string, iteration?: number | null) => void;jumpToLive: () => void;- setCenterView: (view: RunCenterView) => void;- setHeaderCompact: (compact: boolean) => void;reset: () => void;};export const useRunViewStore = create<RunViewState>((set) => ({pinnedFrameId: null,pinNonce: 0,- centerView: "default",- headerCompact: false,- // Inspecting a frame or jumping to live/recording always drops any override.- pinFrame: (id) =>+ activeIteration: null,+ pinFrame: (id, iteration = null) =>set((state) => ({pinnedFrameId: id,- centerView: "default",+ activeIteration: iteration,pinNonce: state.pinNonce + 1,})),- jumpToLive: () => set({ pinnedFrameId: null, centerView: "default" }),- setCenterView: (view) =>- set((state) => ({- centerView: view,- pinnedFrameId:- view === "screenshots" && state.pinnedFrameId === "stream"- ? null- : state.pinnedFrameId,- })),- setHeaderCompact: (compact) => set({ headerCompact: compact }),- reset: () => set({ pinnedFrameId: null, centerView: "default" }),+ jumpToLive: () => set({ pinnedFrameId: null, activeIteration: null }),+ reset: () => set({ pinnedFrameId: null, activeIteration: null }),}));