Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-11508): auto-navigate to Run tab when a block run starts (#6888)
Celal Zamanoğlu746644c8494c
diff --git a/skyvern-frontend/src/routes/workflows/LegacyBuildRedirect.tsx b/skyvern-frontend/src/routes/workflows/LegacyBuildRedirect.tsxindex 8a1274372..5fdf8eb3d 100644--- a/skyvern-frontend/src/routes/workflows/LegacyBuildRedirect.tsx+++ b/skyvern-frontend/src/routes/workflows/LegacyBuildRedirect.tsx@@ -1,14 +1,14 @@import { Navigate, useLocation, useParams } from "react-router-dom";/**- * Legacy /build and /debug URLs land on /studio; block-run URLs carry the run- * as ?wr=&bl= so the Run tab opens in block mode.+ * Legacy /build and /debug URLs land on /studio; block-run URLs carry the run as+ * ?wr=&bl= so the Run tab opens on it in block-scoped mode.*/function LegacyBuildRedirect() {const { workflowPermanentId, workflowRunId, blockLabel } = useParams();const location = useLocation();- // Block-run URLs carry the run as ?wr=&bl=; plain /build keeps its own search- // (e.g. ?via= onboarding telemetry) rather than dropping it.+ // Block-run URLs carry the run as ?wr=&bl= (bl marks block scope); plain /build+ // keeps its own search (e.g. ?via= onboarding telemetry) rather than dropping it.const query =workflowRunId && blockLabel? `?wr=${workflowRunId}&bl=${encodeURIComponent(blockLabel)}`diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsxindex 643c59457..36928acbb 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx@@ -555,7 +555,7 @@ function NodeHeader({});if (studioEnabled) {- useStudioShellStore.getState().setTab("browser");+ useStudioShellStore.getState().setTab("run");navigate(`/workflows/${workflowPermanentId}/studio?wr=${response.data.run_id}&bl=${encodeURIComponent(label)}`,);diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsxnew file mode 100644index 000000000..3ea87a616--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.test.tsx@@ -0,0 +1,45 @@+// @vitest-environment jsdom++import { cleanup, render, screen } from "@testing-library/react";+import { MemoryRouter } from "react-router-dom";+import { afterEach, describe, expect, test, vi } from "vitest";++import { RunTab } from "./RunTab";++vi.mock("../hooks/useWorkflowRunsQuery", () => ({+ useWorkflowRunsQuery: () => ({ data: [] }),+}));++vi.mock("./runview/RunView", () => ({+ RunView: (props: { onRetry?: () => void }) => (+ <div data-testid="runview" data-has-retry={props.onRetry ? "yes" : "no"} />+ ),+}));++afterEach(cleanup);++// useStudioRunId reads ?wr= from the router, so the MemoryRouter URL drives it+// (and ?bl=, which RunTab reads directly) — no hook mock needed.+function renderAt(path: string) {+ return render(+ <MemoryRouter initialEntries={[path]}>+ <RunTab />+ </MemoryRouter>,+ );+}++describe("RunTab block-scoped retry", () => {+ test("suppresses the retry CTA for a block run (?bl= present)", () => {+ renderAt("/workflows/wpid_abc/studio?wr=run_1&bl=Block%201");+ expect(screen.getByTestId("runview").getAttribute("data-has-retry")).toBe(+ "no",+ );+ });++ test("wires the retry CTA for a full run (no ?bl=)", () => {+ renderAt("/workflows/wpid_abc/studio?wr=run_1");+ expect(screen.getByTestId("runview").getAttribute("data-has-retry")).toBe(+ "yes",+ );+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsxindex 6b1148f4e..e2bb8a653 100644--- a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx@@ -1,4 +1,4 @@-import { useNavigate, useParams } from "react-router-dom";+import { useNavigate, useParams, useSearchParams } from "react-router-dom";import { useStudioShellStore } from "@/store/StudioShellStore";@@ -13,6 +13,7 @@ import { useStudioRunId } from "./useStudioRunId";export function RunTab() {const navigate = useNavigate();const urlRunId = useStudioRunId();+ const [searchParams] = useSearchParams();const { workflowPermanentId } = useParams();const setCopilotCollapsed = useStudioShellStore((s) => s.setCopilotCollapsed);const { data: runs } = useWorkflowRunsQuery({@@ -21,12 +22,19 @@ export function RunTab() {pageSize: 1,});const runId = urlRunId ?? runs?.[0]?.workflow_run_id;+ // ?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");return (<RunViewworkflowRunId={runId}onFix={() => setCopilotCollapsed(false)}- onRetry={() => navigate(`/workflows/${workflowPermanentId}/run`)}+ onRetry={+ isBlockRun+ ? undefined+ : () => navigate(`/workflows/${workflowPermanentId}/run`)+ }/>);}diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsxindex 60a7efaa9..4d02bd29a 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx@@ -16,6 +16,7 @@ import {STUDIO_COPILOT_TRANSITION_EASE,STUDIO_COPILOT_TRANSITION_MS,STUDIO_COPILOT_WIDTH,+ initialStudioTab,studioPanelId,studioTabId,} from "./constants";@@ -49,19 +50,24 @@ export function StudioShell(props: StudioWorkspaceProps) {);const [browserStreamSlot, setBrowserStreamSlot] =useState<HTMLElement | null>(null);+ const [runStreamSlot, setRunStreamSlot] = useState<HTMLElement | null>(null);const [streamHolderEl, setStreamHolderEl] = useState<HTMLElement | null>(null,);- // Move the persistent stream node into the showing surface (PiP / Browser tab),- // parking it in the offscreen holder otherwise so the socket stays warm.+ // Move the persistent stream node into the showing surface (PiP / Browser tab /+ // Run tab for a block run), parking it in the offscreen holder otherwise so the+ // socket stays warm. runStreamSlot is registered only for a block run, so a full+ // run on the Run tab falls through to the holder and keeps its own RunLiveStream.useLayoutEffect(() => {const activeSlot =tab === "browser"? browserStreamSlot: tab === "editor" && !pipMinimized? editorStreamSlot- : null;+ : tab === "run"+ ? runStreamSlot+ : null;const dest = activeSlot ?? streamHolderEl;if (dest && streamHostEl.parentElement !== dest) {// BrowserStream re-asserts scaleViewport on its own resize, so it rescales@@ -73,12 +79,18 @@ export function StudioShell(props: StudioWorkspaceProps) {pipMinimized,editorStreamSlot,browserStreamSlot,+ runStreamSlot,streamHolderEl,streamHostEl,]);const shellContextValue = useMemo(- () => ({ copilotPortalEl, setEditorStreamSlot, setBrowserStreamSlot }),+ () => ({+ copilotPortalEl,+ setEditorStreamSlot,+ setBrowserStreamSlot,+ setRunStreamSlot,+ }),[copilotPortalEl],);@@ -86,7 +98,6 @@ export function StudioShell(props: StudioWorkspaceProps) {// later URL writes (the Run tab writes ?wr=/?active=) or it fights manual switches.const [searchParams] = useSearchParams();const deepLinkRunId = searchParams.get("wr");- const deepLinkBlockLabel = searchParams.get("bl");const deepLinkActive = searchParams.get("active");const initialTabAppliedRef = useRef(false);useEffect(() => {@@ -94,16 +105,8 @@ export function StudioShell(props: StudioWorkspaceProps) {return;}initialTabAppliedRef.current = true;- if (deepLinkRunId && deepLinkBlockLabel) {- setTab("browser");- return;- }- if (deepLinkRunId || deepLinkActive) {- setTab("run");- return;- }- setTab("editor");- }, [deepLinkRunId, deepLinkBlockLabel, deepLinkActive, setTab]);+ setTab(initialStudioTab({ runId: deepLinkRunId, active: deepLinkActive }));+ }, [deepLinkRunId, deepLinkActive, setTab]);const copilotWidth = copilotCollapsed? STUDIO_COPILOT_RAIL_WIDTHdiff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShellContext.ts b/skyvern-frontend/src/routes/workflows/studio/StudioShellContext.tsindex a05bd02ce..d77fbd4f4 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioShellContext.ts+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShellContext.ts@@ -8,12 +8,16 @@ type StudioShellContextValue = {// persistent stream node into the active surface without remounting it.setEditorStreamSlot: (el: HTMLElement | null) => void;setBrowserStreamSlot: (el: HTMLElement | null) => void;+ // The Run tab registers this for a block run, so the debug-session stream shows+ // there too (same node, view-only); null for a full run keeps it parked.+ setRunStreamSlot: (el: HTMLElement | null) => void;};export const StudioShellContext = createContext<StudioShellContextValue>({copilotPortalEl: null,setEditorStreamSlot: () => {},setBrowserStreamSlot: () => {},+ setRunStreamSlot: () => {},});export function useStudioShellContext(): StudioShellContextValue {diff --git a/skyvern-frontend/src/routes/workflows/studio/constants.ts b/skyvern-frontend/src/routes/workflows/studio/constants.tsindex 956c6dbb5..332d03fa5 100644--- a/skyvern-frontend/src/routes/workflows/studio/constants.ts+++ b/skyvern-frontend/src/routes/workflows/studio/constants.ts@@ -1,3 +1,5 @@+import { type StudioTab } from "@/store/StudioShellStore";+// Width of the docked Copilot spine (px), and its collapsed-rail width.export const STUDIO_COPILOT_WIDTH = 450;export const STUDIO_COPILOT_RAIL_WIDTH = 60;@@ -13,3 +15,11 @@ export const STUDIO_COPILOT_COLLAPSE_EASE = "cubic-bezier(0.65, 0, 0.35, 1)";// Stable element ids linking each tab to its panel (WAI-ARIA tabs pattern).export const studioTabId = (tab: string) => `studio-tab-${tab}`;export const studioPanelId = (tab: string) => `studio-panel-${tab}`;++// Deep-link landing tab: any run reference (?wr=) or pinned item (?active=) → Run; else Editor.+export function initialStudioTab(params: {+ runId: string | null;+ active: string | null;+}): StudioTab {+ return params.runId || params.active ? "run" : "editor";+}diff --git a/skyvern-frontend/src/routes/workflows/studio/initialStudioTab.test.ts b/skyvern-frontend/src/routes/workflows/studio/initialStudioTab.test.tsnew file mode 100644index 000000000..6753f9cdf--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/initialStudioTab.test.ts@@ -0,0 +1,21 @@+import { describe, expect, test } from "vitest";++import { initialStudioTab } from "./constants";++describe("initialStudioTab", () => {+ test("opens the Run tab for a run deep link (block or full run)", () => {+ expect(initialStudioTab({ runId: "wr_123", active: null })).toBe("run");+ });++ test("opens the Run tab when only a pinned item is deep linked", () => {+ expect(initialStudioTab({ runId: null, active: "act_1" })).toBe("run");+ });++ test("opens the Run tab when both a run and a pinned item are present", () => {+ expect(initialStudioTab({ runId: "wr_123", active: "act_1" })).toBe("run");+ });++ test("opens the Editor with no run reference", () => {+ expect(initialStudioTab({ runId: null, active: null })).toBe("editor");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.test.tsxnew file mode 100644index 000000000..78020b0d2--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.test.tsx@@ -0,0 +1,58 @@+// @vitest-environment jsdom++import { cleanup, render, screen } 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",+ shownFrame: null,+ 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();+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsxindex 264683e5e..29608fb18 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx@@ -14,6 +14,7 @@ import { cn } from "@/util/utils";import { WorkflowRunCode } from "../../workflowRun/WorkflowRunCode";import { FilmstripFrame } from "../runProjections";+import { useStudioShellContext } from "../StudioShellContext";import { HeroRecording } from "./HeroRecording";import { HeroScreenshot } from "./HeroScreenshot";import { RunLiveStream } from "./RunLiveStream";@@ -22,6 +23,9 @@ type RunHeroProps = {workflowRunId: string;shownFrame: FilmstripFrame | null;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;provisioning: boolean;isPaused: boolean;failed: boolean;@@ -73,6 +77,7 @@ export function RunHero({workflowRunId,shownFrame,running,+ showDebugStream,provisioning,isPaused,failed,@@ -93,27 +98,37 @@ export function RunHero({const jumpToLive = useRunViewStore((s) => s.jumpToLive);const codeOpen = useRunViewStore((s) => s.codeOpen);const setCodeOpen = useRunViewStore((s) => s.setCodeOpen);+ 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);useEffect(() => {setStreamUrl(null);+ setRecordingOpen(false);}, [workflowRunId]);const scrubbing = pinnedFrameId != null && pinnedFrameId !== "stream";const hasRecording = recordingUrls.length > 0;- // A failed run defaults to its last screenshot so the fix/retry CTA is- // visible; otherwise a finished run defaults to the recording.+ // A block run keeps the live debug stream as its default view (while running and+ // once parked on the final page), unless the user scrubs, opens code, or the+ // recording. A full run shows its live stream only while running, then the+ // recording or its last screenshot.const center: CenterView = codeOpen? "code"- : running && !scrubbing- ? "stream"- : scrubbing- ? "screenshot"- : hasRecording && !failed+ : scrubbing+ ? "screenshot"+ : showDebugStream+ ? recordingOpen && hasRecording? "recording"- : "screenshot";+ : "stream"+ : running+ ? "stream"+ : hasRecording && !failed+ ? "recording"+ : "screenshot";const headerLabel =center === "stream"@@ -145,7 +160,34 @@ export function RunHero({</span></div><div className="flex shrink-0 items-center gap-1">- {running ? (+ {showDebugStream ? (+ <>+ <ViewToggle+ active={center === "stream"}+ onClick={() => {+ setRecordingOpen(false);+ pinFrame("stream");+ }}+ icon={+ <span className="h-1.5 w-1.5 animate-pulse rounded-full bg-success" />+ }+ >+ Live+ </ViewToggle>+ {hasRecording ? (+ <ViewToggle+ active={center === "recording"}+ onClick={() => {+ setRecordingOpen(true);+ jumpToLive();+ }}+ icon={<PlayIcon className="h-3 w-3" />}+ >+ Recording+ </ViewToggle>+ ) : null}+ </>+ ) : running ? (<ViewToggleactive={center === "stream"}onClick={() => pinFrame("stream")}@@ -213,7 +255,17 @@ export function RunHero({/></div>) : center === "stream" ? (- provisioning ? (+ showDebugStream ? (+ // The shell re-parents the persistent debug-session stream into this+ // slot (the same node as the Browser tab), 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">@@ -256,10 +308,13 @@ export function RunHero({<span className="truncate">Inspecting step · <b>{shownFrame.label}</b></span>- {running ? (+ {running || showDebugStream ? (<buttontype="button"- onClick={() => pinFrame("stream")}+ onClick={() => {+ 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" />@@ -278,7 +333,10 @@ export function RunHero({</div>) : null}- {center === "screenshot" && failed && !scrubbing ? (+ {failed &&+ !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-center gap-2 text-sm font-semibold text-foreground"><ExclamationTriangleIcon className="h-4 w-4 text-destructive" />diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex ccd187f5e..8fa052731 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -1,7 +1,7 @@import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { Share1Icon } from "@radix-ui/react-icons";import { usePostHog } from "posthog-js/react";-import { useSearchParams } from "react-router-dom";+import { useParams, useSearchParams } from "react-router-dom";import { Status } from "@/api/types";import { ApiWebhookActionsMenu } from "@/components/ApiWebhookActionsMenu";@@ -14,6 +14,7 @@ import { type ApiCommandOptions } from "@/util/apiCommands";import { runsApiBaseUrl } from "@/util/env";import { cn } from "@/util/utils";+import { useDebugSessionQuery } from "../../hooks/useDebugSessionQuery";import { useWorkflowRunTimelineQuery } from "../../hooks/useWorkflowRunTimelineQuery";import { useWorkflowRunWithWorkflowQuery } from "../../hooks/useWorkflowRunWithWorkflowQuery";import { WorkflowRunBlockDetail } from "../../workflowRun/WorkflowRunBlockDetail";@@ -47,6 +48,11 @@ export function RunView({ workflowRunId, onFix, onRetry }: RunViewProps) {const queryOptions = workflowRunId ? { workflowRunId } : undefined;const { data: workflowRun } = useWorkflowRunWithWorkflowQuery(queryOptions);const { data: timeline } = useWorkflowRunTimelineQuery(queryOptions);+ const { workflowPermanentId } = useParams();+ const { data: debugSession } = useDebugSessionQuery({+ workflowPermanentId,+ enabled: false,+ });const pinnedFrameId = useRunViewStore((s) => s.pinnedFrameId);const pinFrame = useRunViewStore((s) => s.pinFrame);const resetRunView = useRunViewStore((s) => s.reset);@@ -115,31 +121,36 @@ export function RunView({ workflowRunId, onFix, onRetry }: RunViewProps) {);}, [pinnedFrameId, workflowRunId, setSearchParams]);- // Pin the resolved run into ?wr= while the Run tab shows it (an ?active=-only link- // becomes stable). Gated on the tab: RunView also mounts under Editor, no ?wr= there.+ // Stabilize an ?active=-only deep link by ADDING ?wr= when it's absent. Gated on+ // the tab: RunView also mounts under Editor, no ?wr= there.+ //+ // The guard reads the LIVE URL, not this render's searchParams: a block-run launch+ // navigates to ?wr=&bl= via a separate router update, and the editor→run transition+ // can fire this effect from a render whose searchParams closure predates it. Reading+ // the live URL avoids writing the stale latest-run id back over the new run (which+ // reverted ?wr= and dropped ?bl=, disabling the debug stream).useEffect(() => {if (studioTab !== "run") {return;}- const resolvedRunId = workflowRun?.workflow_run_id;- if (!resolvedRunId) {+ if (!workflowRunId) {+ return;+ }+ if (new URLSearchParams(window.location.search).get("wr")) {return;}setSearchParams((prev) => {- if (prev.get("wr") === resolvedRunId && !prev.has("bl")) {+ if (prev.get("wr")) {return prev;}const next = new URLSearchParams(prev);- next.set("wr", resolvedRunId);- // Viewing the run, not the block-run browser — drop stale ?bl= so a reload- // doesn't snap back to the Browser tab.- next.delete("bl");+ next.set("wr", workflowRunId);return next;},{ replace: true },);- }, [studioTab, workflowRun, setSearchParams]);+ }, [studioTab, workflowRunId, setSearchParams]);const frames = useMemo(() => buildFilmstrip(timeline), [timeline]);@@ -148,6 +159,15 @@ export function RunView({ workflowRunId, onFix, onRetry }: RunViewProps) {// 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; on the Run tab 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 =+ studioTab === "run" &&+ searchParams.has("bl") &&+ workflowRun?.browser_session_id != null &&+ workflowRun.browser_session_id === debugSession?.browser_session_id;const lastFrame = frames.length > 0 ? frames[frames.length - 1] : null;const shownFrame =@@ -246,6 +266,7 @@ export function RunView({ workflowRunId, onFix, onRetry }: RunViewProps) {workflowRunId={workflowRun.workflow_run_id}shownFrame={shownFrame}running={running}+ showDebugStream={showDebugStream}provisioning={workflowRun.status === Status.Created ||workflowRun.status === Status.Queued