Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-12798): render the studio run view at /runs/{wr} (#7644)
Celal Zamanoğlu1f51942c6693
diff --git a/skyvern-frontend/src/routes/browserSessions/hooks/useProcessRecordingMutation.ts b/skyvern-frontend/src/routes/browserSessions/hooks/useProcessRecordingMutation.tsindex d18dc35e2..7bae496aa 100644--- a/skyvern-frontend/src/routes/browserSessions/hooks/useProcessRecordingMutation.ts+++ b/skyvern-frontend/src/routes/browserSessions/hooks/useProcessRecordingMutation.ts@@ -1,4 +1,3 @@-import { useParams } from "react-router-dom";import { useMutation } from "@tanstack/react-query";import { useRef } from "react";import { useFeatureFlagEnabled } from "posthog-js/react";@@ -6,6 +5,7 @@ import { useFeatureFlagEnabled } from "posthog-js/react";import { getClient } from "@/api/AxiosClient";import { toast } from "@/components/ui/use-toast";import { useCredentialGetter } from "@/hooks/useCredentialGetter";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { RECORD_BROWSER_CODE_FIRST_FLAG } from "@/util/featureFlags";import {useRecordingStore,@@ -34,7 +34,7 @@ const useProcessRecordingMutation = ({}) => {const credentialGetter = useCredentialGetter();const recordingStore = useRecordingStore();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const mutationStartedAtRef = useRef<number | null>(null);// Per-user opt-in preview; not enrolled reads as false (agent blocks).const codeFirst =diff --git a/skyvern-frontend/src/routes/history/RunHistory.tsx b/skyvern-frontend/src/routes/history/RunHistory.tsxindex 616a24e50..22474542f 100644--- a/skyvern-frontend/src/routes/history/RunHistory.tsx+++ b/skyvern-frontend/src/routes/history/RunHistory.tsx@@ -48,7 +48,6 @@ import {TableRow,} from "@/components/ui/table";import { useRunsQuery } from "@/hooks/useRunsQuery";-import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import {basicLocalTimeFormat,basicTimeFormat,@@ -170,17 +169,12 @@ function inferTriggerType(run: TaskRunListItem): TriggerType | null {return null;}-function getRunNavigationPath(- run: TaskRunListItem,- studioEnabled: boolean,-): string {+function getRunNavigationPath(run: TaskRunListItem): string {switch (run.task_run_type) {case TaskRunType.WorkflowRun:- // With the studio on, workflow runs open in its Run tab; otherwise they- // use the standalone run page (also the fallback when there is no wpid).- return studioEnabled && run.workflow_permanent_id- ? `/agents/${run.workflow_permanent_id}/studio?wr=${run.run_id}`- : `/runs/${run.run_id}`;+ // /runs/{wr} renders the studio run view when the preview is on and the+ // legacy run page when it is off, so one short path serves both.+ return `/runs/${run.run_id}`;case TaskRunType.TaskV2:return `/runs/${run.run_id}`;case TaskRunType.TaskV1:@@ -254,7 +248,6 @@ function RunHistory() {workflowPermanentIds,});const navigate = useNavigate();- const studioEnabled = useWorkflowStudioEnabled();const { data: nextPageRuns } = useRunsQuery({page: page + 1,@@ -418,7 +411,7 @@ function RunHistory() {);const isWorkflowRun = run.task_run_type === TaskRunType.WorkflowRun;const isExpanded = isWorkflowRun && expandedRows.has(run.run_id);- const navPath = getRunNavigationPath(run, studioEnabled);+ const navPath = getRunNavigationPath(run);const triggerType = inferTriggerType(run);const runTags = runTagsMap[run.run_id];const selectableIndex = selectableIndexById.get(run.run_id) ?? -1;diff --git a/skyvern-frontend/src/routes/root/useSidebarHidden.ts b/skyvern-frontend/src/routes/root/useSidebarHidden.tsindex 61209246c..ef2191d77 100644--- a/skyvern-frontend/src/routes/root/useSidebarHidden.ts+++ b/skyvern-frontend/src/routes/root/useSidebarHidden.ts@@ -1,6 +1,8 @@import { useMatch, useSearchParams } from "react-router-dom";+import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import { useAgentsPathMatch } from "@/routes/workflows/useAgentsPathMatch";+import { useStudioRunRouteMatch } from "@/routes/workflows/useStudioRunRouteMatch";type Options = {hideBrowserSessions?: boolean;@@ -9,6 +11,8 @@ type Options = {function useSidebarHidden({ hideBrowserSessions = false }: Options = {}) {const [searchParams] = useSearchParams();const embed = searchParams.get("embed");+ const studioEnabled = useWorkflowStudioEnabled();+ const runStudioMatch = useStudioRunRouteMatch();const workflowEditMatch = useAgentsPathMatch("/:workflowPermanentId/edit");const workflowStudioMatch = useAgentsPathMatch("/:workflowPermanentId/studio",@@ -27,6 +31,7 @@ function useSidebarHidden({ hideBrowserSessions = false }: Options = {}) {);return Boolean(+ (studioEnabled && runStudioMatch) ||workflowEditMatch ||workflowStudioMatch ||workflowBuildMatch ||diff --git a/skyvern-frontend/src/routes/runs/RunRouter.test.tsx b/skyvern-frontend/src/routes/runs/RunRouter.test.tsxnew file mode 100644index 000000000..a8ef4489e--- /dev/null+++ b/skyvern-frontend/src/routes/runs/RunRouter.test.tsx@@ -0,0 +1,161 @@+// @vitest-environment jsdom++import { render, screen } from "@testing-library/react";+import { MemoryRouter, Route, Routes } from "react-router-dom";+import { beforeEach, describe, expect, test, vi } from "vitest";++import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";++import { RunRouter } from "./RunRouter";++type RunQueryResult = {+ data:+ | { workflow_run_id: string; workflow: { workflow_permanent_id: string } }+ | undefined;+ isLoading: boolean;+ isError?: boolean;+};++const resolvedRun = {+ workflow_run_id: "wr_1",+ workflow: { workflow_permanent_id: "wpid_123" },+};++const mocks = vi.hoisted(() => ({+ studioEnabled: vi.fn(() => true),+ taskV2: vi.fn(() => ({ data: undefined, isLoading: false })),+ runQuery: vi.fn<+ (options?: { workflowRunId?: string; enabled?: boolean }) => RunQueryResult+ >(() => ({+ data: {+ workflow_run_id: "wr_1",+ workflow: { workflow_permanent_id: "wpid_123" },+ },+ isLoading: false,+ })),+}));++vi.mock("@/hooks/useWorkflowStudioEnabled", () => ({+ useWorkflowStudioEnabled: () => mocks.studioEnabled(),+}));+vi.mock("@/routes/runs/useTaskV2Query", () => ({+ useTaskV2Query: () => mocks.taskV2(),+}));+vi.mock("@/routes/workflows/hooks/useWorkflowRunWithWorkflowQuery", () => ({+ useWorkflowRunWithWorkflowQuery: (options?: {+ workflowRunId?: string;+ enabled?: boolean;+ }) => mocks.runQuery(options),+}));+// The studio shell is stubbed to a marker that echoes the resolved wpid, so we+// verify both the branch choice and that the provider fed the id through.+vi.mock("@/routes/workflows/editor/WorkflowEditor", () => ({+ WorkflowEditor: () => (+ <div data-testid="studio">studio:{useWorkflowPermanentId()}</div>+ ),+}));+vi.mock("@/routes/workflows/WorkflowRun", () => ({+ WorkflowRun: () => <div data-testid="legacy">legacy</div>,+}));++function renderAt(entry: string) {+ return render(+ <MemoryRouter initialEntries={[entry]}>+ <Routes>+ <Route path="/runs/:runId/*" element={<RunRouter />} />+ <Route path="/agents/*" element={<div data-testid="redirected" />} />+ </Routes>+ </MemoryRouter>,+ );+}++describe("RunRouter workflow-run branch", () => {+ beforeEach(() => {+ mocks.studioEnabled.mockReturnValue(true);+ mocks.taskV2.mockReturnValue({ data: undefined, isLoading: false });+ mocks.runQuery.mockReturnValue({ data: resolvedRun, isLoading: false });+ });++ test("studio on: renders the studio in place under /runs/{wr} (no redirect to /agents)", () => {+ renderAt("/runs/wr_1");+ expect(screen.getByTestId("studio").textContent).toBe("studio:wpid_123");+ expect(screen.queryByTestId("redirected")).toBeNull();+ expect(screen.queryByTestId("legacy")).toBeNull();+ });++ test("studio on: shows the fetching treatment while the run resolves", () => {+ mocks.runQuery.mockReturnValue({ data: undefined, isLoading: true });+ renderAt("/runs/wr_1");+ expect(screen.getByText("Fetching run details...")).toBeTruthy();+ expect(screen.queryByTestId("studio")).toBeNull();+ });++ test("studio on: waits out a stale (keepPreviousData) run from a prior URL", () => {+ // The query still holds the previous run while navigating to wr_1; its+ // workflow id must not be handed to the studio until the fetch catches up.+ mocks.runQuery.mockReturnValue({+ data: {+ workflow_run_id: "wr_0",+ workflow: { workflow_permanent_id: "wpid_prev" },+ },+ isLoading: false,+ });+ renderAt("/runs/wr_1");+ expect(screen.getByText("Fetching run details...")).toBeTruthy();+ expect(screen.queryByTestId("studio")).toBeNull();+ });++ test("studio off: keeps the legacy run view", () => {+ mocks.studioEnabled.mockReturnValue(false);+ renderAt("/runs/wr_1");+ expect(screen.getByTestId("legacy")).toBeTruthy();+ expect(screen.queryByTestId("studio")).toBeNull();+ });++ test("studio on: enables the run-resolver query for the wr_ id", () => {+ renderAt("/runs/wr_1");+ expect(mocks.runQuery).toHaveBeenCalledWith(+ expect.objectContaining({ workflowRunId: "wr_1", enabled: true }),+ );+ });++ test("studio off: disables the run-resolver query so non-studio routes don't fetch a workflow run", () => {+ mocks.studioEnabled.mockReturnValue(false);+ renderAt("/runs/wr_1");+ expect(mocks.runQuery).toHaveBeenCalledWith(+ expect.objectContaining({ enabled: false }),+ );+ });++ test("embed=true keeps the chrome-free legacy view, not the studio shell", () => {+ renderAt("/runs/wr_1?embed=true");+ expect(screen.getByTestId("legacy")).toBeTruthy();+ expect(screen.queryByTestId("studio")).toBeNull();+ });++ test("a permanently failed run fetch lands on 404, not an endless spinner", () => {+ mocks.runQuery.mockReturnValue({+ data: undefined,+ isLoading: false,+ isError: true,+ });+ renderAt("/runs/wr_1");+ expect(screen.queryByTestId("studio")).toBeNull();+ expect(screen.queryByText("Fetching run details...")).toBeNull();+ expect(screen.queryByTestId("legacy")).toBeNull();+ });++ test("a failed background poll keeps the studio view while the live run stays retained", () => {+ // isError flips true when a 5s poll of a live run fails, but keepPreviousData+ // still holds the matching run; the resolved run must win over the error so a+ // single failed poll never flashes 404 over a working studio view.+ mocks.runQuery.mockReturnValue({+ data: resolvedRun,+ isLoading: false,+ isError: true,+ });+ renderAt("/runs/wr_1");+ expect(screen.getByTestId("studio").textContent).toBe("studio:wpid_123");+ expect(screen.queryByText("Fetching run details...")).toBeNull();+ });+});diff --git a/skyvern-frontend/src/routes/runs/RunRouter.tsx b/skyvern-frontend/src/routes/runs/RunRouter.tsxindex 061ca0956..94fc8918d 100644--- a/skyvern-frontend/src/routes/runs/RunRouter.tsx+++ b/skyvern-frontend/src/routes/runs/RunRouter.tsx@@ -3,7 +3,13 @@* under the /runs/:runId path, discriminating based on ID prefix.*/-import { Navigate, Route, Routes, useParams } from "react-router-dom";+import {+ Navigate,+ Route,+ Routes,+ useParams,+ useSearchParams,+} from "react-router-dom";import { useMemo } from "react";import { PageLayout } from "@/components/PageLayout";@@ -20,15 +26,36 @@ import { WorkflowRunOverview } from "@/routes/workflows/workflowRun/WorkflowRunOimport { WorkflowRunRecording } from "@/routes/workflows/workflowRun/WorkflowRunRecording";import { WorkflowRunCode } from "@/routes/workflows/workflowRun/WorkflowRunCode";import { WorkflowsPageLayout } from "@/routes/workflows/WorkflowsPageLayout";+import { WorkflowEditor } from "@/routes/workflows/editor/WorkflowEditor";+import { WorkflowPermanentIdContext } from "@/routes/workflows/WorkflowPermanentIdContext";+import { useWorkflowRunWithWorkflowQuery } from "@/routes/workflows/hooks/useWorkflowRunWithWorkflowQuery";+import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import { useTaskV2Query } from "@/routes/runs/useTaskV2Query";function RunRouter() {const { runId } = useParams();+ const studioEnabled = useWorkflowStudioEnabled();const { data: task_v2, isLoading } = useTaskV2Query({id: runId?.startsWith("tsk_v2") ? runId : undefined,});+ // With the studio on, a workflow-run short URL renders the studio run view in+ // place (short URL stays in the address bar) rather than redirecting to the+ // long /agents/{wpid}/studio?wr= form. The studio components read the workflow+ // id, which the path lacks, so resolve it from the run first — this query is+ // shared/cached with the shell that renders next. An embedded run (?embed=true)+ // keeps the legacy chrome-free view instead of the full studio shell.+ const [searchParams] = useSearchParams();+ const isEmbedded = searchParams.get("embed") === "true";+ const renderStudioRun =+ studioEnabled && Boolean(runId?.startsWith("wr_")) && !isEmbedded;+ const { data: studioRun, isError: studioRunFailed } =+ useWorkflowRunWithWorkflowQuery({+ workflowRunId: renderStudioRun ? runId : undefined,+ enabled: renderStudioRun,+ });+const runType = runId?.startsWith("tsk_v2")? "redirect": runId?.startsWith("wr_")@@ -104,6 +131,34 @@ function RunRouter() {return <Navigate to={`/runs/${workflowRunId}`} replace />;}+ if (renderStudioRun) {+ // keepPreviousData holds the prior run's response while navigating between+ // short URLs; wait for the fetch that matches this runId before handing its+ // workflow id to the studio, so the editor and run panes never mix two runs.+ const resolvedRun =+ studioRun?.workflow_run_id === runId ? studioRun : undefined;+ if (!resolvedRun) {+ // No matching run data yet. A permanently failed initial fetch (deleted,+ // foreign-org, or garbage run id) lands on 404 like the legacy run view; a+ // failed background poll of a live run retains its data, so resolvedRun+ // stays set above and never flashes 404 over a working view.+ if (studioRunFailed) {+ return <Status404 />;+ }+ return <div>Fetching run details...</div>;+ }+ const workflowPermanentId = resolvedRun.workflow?.workflow_permanent_id;+ if (!workflowPermanentId) {+ console.error("Workflow permanent ID for run %s not found", runId);+ return <Status404 />;+ }+ return (+ <WorkflowPermanentIdContext.Provider value={workflowPermanentId}>+ <WorkflowEditor />+ </WorkflowPermanentIdContext.Provider>+ );+ }+return routes;}diff --git a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsxindex 012cc414b..40d48f19d 100644--- a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx+++ b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx@@ -532,11 +532,10 @@ function RunWorkflowForm({queryKey: ["runs"],});if (studioEnabled) {- // A full-run start lands on the bare ?wr= deep link; the learned run- // layout (or factory copilot,browser,overview) restores via the fallback.- navigate(- `/agents/${workflowPermanentId}/studio?wr=${response.data.workflow_run_id}`,- );+ // A full-run start lands on the bare /runs/{wr} deep link; the learned+ // run layout (or factory copilot,browser,overview) restores via the+ // fallback.+ navigate(`/runs/${response.data.workflow_run_id}`);} else {navigate(env.useNewRunsUrldiff --git a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsxindex f4240796f..238a54562 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowPage.tsx@@ -444,7 +444,7 @@ function WorkflowPage() {workflowRun.workflow_run_id,);const runPath = studioEnabled- ? `/agents/${workflowPermanentId}/studio?wr=${workflowRun.workflow_run_id}`+ ? `/runs/${workflowRun.workflow_run_id}`: legacyRunDetailPath(workflowPermanentId,workflowRun.workflow_run_id,diff --git a/skyvern-frontend/src/routes/workflows/WorkflowPermanentIdContext.ts b/skyvern-frontend/src/routes/workflows/WorkflowPermanentIdContext.tsnew file mode 100644index 000000000..5ac6f4b72--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/WorkflowPermanentIdContext.ts@@ -0,0 +1,19 @@+import { createContext, useContext } from "react";+import { useParams } from "react-router-dom";++export const WorkflowPermanentIdContext = createContext<string | undefined>(+ undefined,+);++/**+ * The workflow permanent id for the current studio/editor surface. Routes that+ * carry it in the path (/agents/:workflowPermanentId/...) resolve it from the+ * URL; the short run route (/runs/:runId) has no wpid segment, so its resolver+ * supplies it through the context. The context wins; the path param is the+ * fallback, so path-routed surfaces keep behaving exactly as before.+ */+export function useWorkflowPermanentId(): string | undefined {+ const override = useContext(WorkflowPermanentIdContext);+ const { workflowPermanentId } = useParams();+ return override ?? workflowPermanentId;+}diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsxindex 78ba90efb..d1394e931 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx@@ -537,20 +537,21 @@ function WorkflowRun() {return <Status404 />;}- // With the preview on, route legacy run links into the studio Run tab- // (preserving the selected item); flag-off keeps this legacy run view.+ // With the preview on, route legacy run links into the studio run view under+ // the short /runs/{wr} URL (preserving the selected item); flag-off keeps this+ // legacy run view. The run id lives in the path, so it stays out of the query.if (studioEnabled && !isEmbedded && workflowRunId && workflowPermanentId) {const studioParams = new URLSearchParams();- studioParams.set("wr", workflowRunId);if (active) {studioParams.set("active", active);}if (iterationParam) {studioParams.set("iteration", iterationParam);}+ const search = studioParams.toString();return (<Navigate- to={`/agents/${workflowPermanentId}/studio?${studioParams.toString()}`}+ to={`/runs/${workflowRunId}${search ? `?${search}` : ""}`}replace/>);diff --git a/skyvern-frontend/src/routes/workflows/components/BlockOutputs.tsx b/skyvern-frontend/src/routes/workflows/components/BlockOutputs.tsxindex 8061a0fb2..639797b4e 100644--- a/skyvern-frontend/src/routes/workflows/components/BlockOutputs.tsx+++ b/skyvern-frontend/src/routes/workflows/components/BlockOutputs.tsx@@ -1,5 +1,5 @@import { useState } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import {Tooltip,@@ -25,7 +25,7 @@ function BlockOutputs({blockLabel: string;blockOutput: { [k: string]: unknown } | null;}) {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const blockOutputStore = useBlockOutputStore();const [pageName, setPageName] = useState<PageName>("output");const [overrideHasError, setOverrideHasError] = useState(false);diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsxindex 3e9823f78..0273574bb 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx@@ -18,6 +18,7 @@ import { CredentialsModal } from "@/routes/credentials/CredentialsModal";import { CredentialModalTypes } from "@/routes/credentials/useCredentialModalState";import { getHostname } from "@/util/getHostname";import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import {ReloadIcon,Cross2Icon,@@ -890,8 +891,8 @@ export function WorkflowCopilotChat({posY: 0,});const credentialGetter = useCredentialGetter();- const { workflowRunId: routeWorkflowRunId, workflowPermanentId } =- useParams();+ const { workflowRunId: routeWorkflowRunId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();// The studio focuses a run via ?wr= (not a path param), so the route param is// empty there; an explicit prop grounds the chat in that run and wins.const workflowRunId = workflowRunIdProp ?? routeWorkflowRunId;diff --git a/skyvern-frontend/src/routes/workflows/editor/MakeACopyButton.tsx b/skyvern-frontend/src/routes/workflows/editor/MakeACopyButton.tsxindex c7dec6d83..bb25c0105 100644--- a/skyvern-frontend/src/routes/workflows/editor/MakeACopyButton.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/MakeACopyButton.tsx@@ -1,5 +1,5 @@import { CopyIcon, ReloadIcon } from "@radix-ui/react-icons";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { Button } from "@/components/ui/button";@@ -8,7 +8,7 @@ import { useGlobalWorkflowsQuery } from "../hooks/useGlobalWorkflowsQuery";import { convert } from "./workflowEditorUtils";function MakeACopyButton() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: globalWorkflows } = useGlobalWorkflowsQuery();const createWorkflowMutation = useCreateWorkflowMutation();diff --git a/skyvern-frontend/src/routes/workflows/editor/WorkflowEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/WorkflowEditor.tsxindex 95189d2ee..830de7906 100644--- a/skyvern-frontend/src/routes/workflows/editor/WorkflowEditor.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/WorkflowEditor.tsx@@ -1,5 +1,6 @@import { ReactFlowProvider } from "@xyflow/react";-import { useParams, useSearchParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";+import { useStudioRunId } from "../studio/useStudioRunId";import { useEffect } from "react";import { useWorkflowQuery } from "../hooks/useWorkflowQuery";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";@@ -19,8 +20,7 @@ import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import { useViaEntryPointCapture } from "../hooks/useViaEntryPointCapture";function WorkflowEditor() {- const { workflowPermanentId } = useParams();- const [searchParams] = useSearchParams();+ const workflowPermanentId = useWorkflowPermanentId();const studioEnabled = useWorkflowStudioEnabled();const {data: fetchedWorkflow,@@ -31,9 +31,10 @@ function WorkflowEditor() {});// Runs outlive their agent: the workflow GET 404s once the agent is deleted,- // but a ?wr= deep link can still be served from the run's embedded workflow- // snapshot (the same query the run panes use), in a read-only degraded mode.- const deepLinkRunId = searchParams.get("wr");+ // but a run deep link (?wr= or the /runs/{wr} path) can still be served from+ // the run's embedded workflow snapshot (the same query the run panes use), in+ // a read-only degraded mode.+ const deepLinkRunId = useStudioRunId();const { data: fallbackRun, isLoading: fallbackRunIsLoading } =useWorkflowRunWithWorkflowQuery(studioEnabled && deepLinkRunIddiff --git a/skyvern-frontend/src/routes/workflows/editor/WorkflowHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/WorkflowHeader.tsxindex b370fcd08..24c766f73 100644--- a/skyvern-frontend/src/routes/workflows/editor/WorkflowHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/WorkflowHeader.tsx@@ -6,7 +6,8 @@ import {ReloadIcon,} from "@radix-ui/react-icons";import { type ReactNode } from "react";-import { useNavigate, useParams } from "react-router-dom";+import { useNavigate } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { BrowserIcon } from "@/components/icons/BrowserIcon";import { SaveIcon } from "@/components/icons/SaveIcon";@@ -56,7 +57,7 @@ function GeneratingCodeButton() {function BrowserModeButton() {const navigate = useNavigate();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const debugStore = useDebugStore();const recordingStore = useRecordingStore();const { data: workflowRun } = useWorkflowRunQuery();@@ -199,7 +200,7 @@ function PanelToggleButton({function RunButton() {const navigate = useNavigate();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const closeWorkflowPanel = useWorkflowPanelStore((s) => s.closeWorkflowPanel);const isRecording = useRecordingStore().isRecording;@@ -262,7 +263,7 @@ function TitleSection() {}function WorkflowHeader() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: globalWorkflows } = useGlobalWorkflowsQuery();const { data: workflow } = useWorkflowQuery({ workflowPermanentId });const cacheKey = workflow?.cache_key ?? "";diff --git a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsxindex 79e9712ee..23c8ecc12 100644--- a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx@@ -25,6 +25,7 @@ import {useParams,useSearchParams,} from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import {useEdgesState,useNodesState,@@ -358,7 +359,8 @@ function Workspace({embedded = false,workflow,}: Props) {- const { blockLabel, workflowPermanentId } = useParams();+ const { blockLabel } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { copilotPortalEl: studioCopilotPortalEl } = useStudioShellContext();const { panes: studioPanes, openPane: openStudioPane } = useStudioPanes();const studioPaneWidths = useStudioShellStore((s) => s.paneWidths);diff --git a/skyvern-frontend/src/routes/workflows/editor/edges/EdgeWithAddButton.tsx b/skyvern-frontend/src/routes/workflows/editor/edges/EdgeWithAddButton.tsxindex 0953a8574..d0112c19e 100644--- a/skyvern-frontend/src/routes/workflows/editor/edges/EdgeWithAddButton.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/edges/EdgeWithAddButton.tsx@@ -7,7 +7,7 @@ import {useNodes,} from "@xyflow/react";import { useRef } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import {BranchContext,@@ -45,7 +45,7 @@ function EdgeWithAddButton({markerEnd,}: EdgeProps) {const isReadOnly = useWorkflowScopeReadOnly();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const nodes = useNodes();const [edgePath, labelX, labelY] = getBezierPath({sourceX,diff --git a/skyvern-frontend/src/routes/workflows/editor/header/CodeSubmenu.tsx b/skyvern-frontend/src/routes/workflows/editor/header/CodeSubmenu.tsxindex f72477e32..7eae12665 100644--- a/skyvern-frontend/src/routes/workflows/editor/header/CodeSubmenu.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/header/CodeSubmenu.tsx@@ -1,5 +1,5 @@import { CodeIcon } from "@radix-ui/react-icons";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import {DropdownMenuCheckboxItem,@@ -29,7 +29,7 @@ import { useToggleCodeView } from "../hooks/useToggleCodeView";* Renders nothing until that's the case, mirroring the old inline controls.*/function CodeSubmenu() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: workflow } = useWorkflowQuery({ workflowPermanentId });const cacheKey = workflow?.cache_key ?? "";diff --git a/skyvern-frontend/src/routes/workflows/editor/header/EditorOverflowMenu.tsx b/skyvern-frontend/src/routes/workflows/editor/header/EditorOverflowMenu.tsxindex c6faea0a7..8aad089f4 100644--- a/skyvern-frontend/src/routes/workflows/editor/header/EditorOverflowMenu.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/header/EditorOverflowMenu.tsx@@ -4,7 +4,7 @@ import {} from "@radix-ui/react-icons";import { useMutation, useQueryClient } from "@tanstack/react-query";import { type AxiosError } from "axios";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { getClient } from "@/api/AxiosClient";import { Button } from "@/components/ui/button";@@ -47,7 +47,7 @@ export function EditorOverflowMenu({// fast timing; standalone (legacy header) brings a local one.embedded?: boolean;} = {}) {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: workflow } = useWorkflowQuery({ workflowPermanentId });const { data: workflowRun } = useWorkflowRunQuery();const isTemplate = workflow?.is_template ?? false;diff --git a/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.test.tsx b/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.test.tsxindex 746d89e33..5b495935c 100644--- a/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.test.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.test.tsx@@ -61,6 +61,30 @@ describe("useBlockRunTarget", () => {});});+ test("resolves the short /runs/{wr} run id from the runId path param", () => {+ // The short URL has no ?wr= and names the run `runId`, not `workflowRunId`;+ // the block controls must still see the live run (running-chip + play-disable).+ const { result } = renderHook(() => useBlockRunTarget(), {+ wrapper: wrapperAt("/runs/wr_9", "/runs/:runId/*"),+ });+ expect(result.current).toEqual({+ workflowRunId: "wr_9",+ blockLabel: undefined,+ });+ });++ test("a block run overlaid on the short URL (?wr= over the path run) targets the block run", () => {+ // Starting a block run on /runs/{wr} keeps the pathname and sets ?wr={block};+ // ?wr= wins over the path run id, same precedence as useStudioRunId.+ const { result } = renderHook(() => useBlockRunTarget(), {+ wrapper: wrapperAt("/runs/wr_1?wr=wr_2&bl=login-block", "/runs/:runId/*"),+ });+ expect(result.current).toEqual({+ workflowRunId: "wr_2",+ blockLabel: "login-block",+ });+ });+test("no run anywhere resolves to no target", () => {const { result } = renderHook(() => useBlockRunTarget(), {wrapper: wrapperAt(diff --git a/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.ts b/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.tsindex 7add1ec07..d61e74ac9 100644--- a/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.ts+++ b/skyvern-frontend/src/routes/workflows/editor/hooks/useBlockRunTarget.ts@@ -1,20 +1,25 @@import { useParams, useSearchParams } from "react-router-dom";+import { useFirstParam } from "@/hooks/useFirstParam";+/*** The block run the editor canvas is focused on. The legacy debugger carries- * the run and target block in the path (/:workflowRunId/:blockLabel/build);- * the studio carries them in ?wr= / ?bl= so the canvas never re-mounts on a- * run start. Block components must gate on whichever shape is present, or the- * running chip / stop button / play-disable go inert in the studio.+ * the run and target block in the path (/:workflowRunId/:blockLabel/build); the+ * short /runs/{wr} URL carries the run as the runId path param; the studio+ * carries them in ?wr= / ?bl= so the canvas never re-mounts on a run start.+ * Block components must gate on whichever shape is present (matching the run-id+ * resolution in useStudioRunId), or the running chip / stop button /+ * play-disable go inert.*/export function useBlockRunTarget(): {workflowRunId: string | undefined;blockLabel: string | undefined;} {- const { blockLabel, workflowRunId } = useParams();+ const { blockLabel } = useParams();const [searchParams] = useSearchParams();+ const urlRunId = useFirstParam("workflowRunId", "runId");return {- workflowRunId: workflowRunId ?? searchParams.get("wr") ?? undefined,+ workflowRunId: searchParams.get("wr") ?? urlRunId,blockLabel: blockLabel ?? searchParams.get("bl") ?? undefined,};}diff --git a/skyvern-frontend/src/routes/workflows/editor/hooks/useSaveWorkflow.tsx b/skyvern-frontend/src/routes/workflows/editor/hooks/useSaveWorkflow.tsxindex a63c1a687..e8d9a3ab6 100644--- a/skyvern-frontend/src/routes/workflows/editor/hooks/useSaveWorkflow.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/hooks/useSaveWorkflow.tsx@@ -1,6 +1,6 @@import { useReactFlow } from "@xyflow/react";import { useQueryClient } from "@tanstack/react-query";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useCallback } from "react";import { toast } from "@/components/ui/use-toast";@@ -15,7 +15,7 @@ import { getWorkflowErrors } from "../workflowEditorUtils";import type { AppNode } from "../nodes";export function useSaveWorkflow(): () => Promise<void> {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const reactFlow = useReactFlow<AppNode>();const saveWorkflow = useWorkflowSave({ status: "published" });const setFilter = useCacheKeyValueStore((s) => s.setFilter);diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsxindex 28028ebf5..ed3b405b5 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/ConditionalNode/ConditionalNode.tsx@@ -7,7 +7,7 @@ import {useReactFlow,type Node,} from "@xyflow/react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { cn } from "@/util/utils";import { NodeHeader } from "../components/NodeHeader";@@ -31,7 +31,7 @@ function ConditionalNodeComponent({ id, data }: NodeProps<ConditionalNode>) {const isCollapsed = useIsBlockCollapsed(data.label);const prevIsCollapsed = useRef<boolean | null>(null);const { open } = useCollapseContext();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const children = useMemo(() => {return nodes.filter((node) => node.parentId === id && !node.hidden);diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/LoopNode/LoopNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/LoopNode/LoopNode.tsxindex 9bd277602..dab7c049e 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/LoopNode/LoopNode.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/LoopNode/LoopNode.tsx@@ -8,6 +8,7 @@ import {type Node,} from "@xyflow/react";import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { statusIsRunningOrQueued } from "@/routes/tasks/types";import { useWorkflowRunQuery } from "@/routes/workflows/hooks/useWorkflowRunQuery";@@ -37,7 +38,8 @@ function LoopNode({ id, data }: NodeProps<LoopNode>) {throw new Error("Node not found"); // not possible}const { editable, label } = data;- const { blockLabel: urlBlockLabel, workflowPermanentId } = useParams();+ const { blockLabel: urlBlockLabel } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: workflowRun } = useWorkflowRunQuery();const workflowRunIsRunningOrQueued =workflowRun && statusIsRunningOrQueued(workflowRun);diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/NodeAdderNode/NodeAdderNode.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/NodeAdderNode/NodeAdderNode.tsxindex 8b6105cc8..c21d3c7f3 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/NodeAdderNode/NodeAdderNode.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/NodeAdderNode/NodeAdderNode.tsx@@ -1,7 +1,7 @@import { PlusIcon } from "@radix-ui/react-icons";import { Handle, NodeProps, Position, useEdges, useNodes } from "@xyflow/react";import { useRef, useState } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useProcessRecordingMutation } from "@/routes/browserSessions/hooks/useProcessRecordingMutation";import { useSopToBlocksMutation } from "@/routes/workflows/hooks/useSopToBlocksMutation";@@ -31,7 +31,7 @@ import { useWorkflowScopeReadOnly } from "../../WorkflowScopeContext";import { findBranchContextForInsertion } from "../../workflowInsertion";function NodeAdderNode({ id, parentId }: NodeProps<NodeAdderNode>) {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const edges = useEdges();const nodes = useNodes();const debugStore = useDebugStore();diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/WorkflowSettingsEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/WorkflowSettingsEditor.tsxindex 6b24e9e0a..5c04e4a25 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/WorkflowSettingsEditor.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/StartNode/WorkflowSettingsEditor.tsx@@ -1,7 +1,7 @@import { ReloadIcon } from "@radix-ui/react-icons";import { useEdges, useNodes, useNodesData } from "@xyflow/react";import { useEffect, useMemo, useRef, useState } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { BrowserProfileSelector } from "@/routes/workflows/components/BrowserProfileSelector";import { HelpTooltip } from "@/components/HelpTooltip";@@ -88,7 +88,7 @@ function WorkflowSettingsEditorBody({blockId: string;data: WorkflowStartNodeData;}) {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const nodes = useNodes<AppNode>();const edges = useEdges();const update = useUpdate<StartNode["data"]>({ id: blockId, editable: true });diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/WorkflowTriggerNode/WorkflowTriggerEditor.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/WorkflowTriggerNode/WorkflowTriggerEditor.tsxindex 47b346c84..b94b11a58 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/WorkflowTriggerNode/WorkflowTriggerEditor.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/WorkflowTriggerNode/WorkflowTriggerEditor.tsx@@ -1,6 +1,6 @@import { useEdges, useNodes, useNodesData } from "@xyflow/react";import { useCallback, useEffect, useState } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { HelpTooltip } from "@/components/HelpTooltip";import { WorkflowBlockInputTextarea } from "@/components/WorkflowBlockInputTextarea";@@ -80,7 +80,7 @@ function WorkflowTriggerEditorBody({nextLoopOnFailure,} = data;- const { workflowPermanentId: parentWorkflowPermanentId } = useParams();+ const parentWorkflowPermanentId = useWorkflowPermanentId();const nodes = useNodes<AppNode>();const edges = useEdges();const isInsideForLoop = isNodeInsideForLoop(nodes, blockId);diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsxindex 7af0f5f2f..c77bf95c3 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx@@ -7,7 +7,8 @@ import {StopIcon,} from "@radix-ui/react-icons";import { useEffect, useRef, useState } from "react";-import { useLocation, useNavigate, useParams } from "react-router-dom";+import { useLocation, useNavigate } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useMutation, useQueryClient } from "@tanstack/react-query";import { useReactFlow } from "@xyflow/react";@@ -253,7 +254,7 @@ function NodeHeader({}: Props) {const log = useLogging();const mode = useWorkflowEditorMode();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { workflowRunId: activeWorkflowRunId, blockLabel: targetBlockLabel } =useBlockRunTarget();const blockOutputsStore = useBlockOutputStore();@@ -590,7 +591,13 @@ function NodeHeader({bl: label,});search.set(STUDIO_PANES_PARAM, panes.join(","));- navigate(`/agents/${workflowPermanentId}/studio?${search}`);+ // Under the short /runs/{wr} URL the run id is the pathname, so keep it+ // and only swap the search; from the editor it is a full studio path.+ if (location.pathname.startsWith("/runs/")) {+ navigate({ search: `?${search.toString()}` });+ } else {+ navigate(`/agents/${workflowPermanentId}/studio?${search}`);+ }} else {navigate(`/agents/${workflowPermanentId}/${response.data.run_id}/${label}/build`,diff --git a/skyvern-frontend/src/routes/workflows/editor/panels/schedulePanel/WorkflowSchedulePanel.tsx b/skyvern-frontend/src/routes/workflows/editor/panels/schedulePanel/WorkflowSchedulePanel.tsxindex 714f3e811..9715b4a5a 100644--- a/skyvern-frontend/src/routes/workflows/editor/panels/schedulePanel/WorkflowSchedulePanel.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/panels/schedulePanel/WorkflowSchedulePanel.tsx@@ -19,7 +19,7 @@ import { ScheduleCard } from "./ScheduleCard";import { CreateScheduleDialog } from "./CreateScheduleDialog";import { Cross2Icon, ReloadIcon } from "@radix-ui/react-icons";import { useState } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";type Props = {onClose?: () => void;@@ -40,7 +40,7 @@ function WorkflowSchedulePanel({ onClose }: Props) {scheduleId: string | null;}>({ open: false, scheduleId: null });- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: workflow } = useWorkflowQuery({ workflowPermanentId });const workflowParameters = workflow?.workflow_definition.parameters ?? [];diff --git a/skyvern-frontend/src/routes/workflows/hooks/useIsGlobalWorkflow.ts b/skyvern-frontend/src/routes/workflows/hooks/useIsGlobalWorkflow.tsindex d542eeb69..188644665 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useIsGlobalWorkflow.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useIsGlobalWorkflow.ts@@ -1,11 +1,11 @@-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useGlobalWorkflowsQuery } from "./useGlobalWorkflowsQuery";// Global (read-only) workflows can't be edited in place — the header offers// "Make a Copy" instead. Editing surfaces gate on this.export function useIsGlobalWorkflow(): boolean {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: globalWorkflows } = useGlobalWorkflowsQuery();return Boolean(globalWorkflows?.some(diff --git a/skyvern-frontend/src/routes/workflows/hooks/useScheduleMutations.ts b/skyvern-frontend/src/routes/workflows/hooks/useScheduleMutations.tsindex e5173e053..68176491b 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useScheduleMutations.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useScheduleMutations.ts@@ -1,5 +1,5 @@import { useMutation, useQueryClient } from "@tanstack/react-query";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { AxiosError } from "axios";import { getClient } from "@/api/AxiosClient";import { useCredentialGetter } from "@/hooks/useCredentialGetter";@@ -10,7 +10,7 @@ import type {} from "@/routes/workflows/types/scheduleTypes";function useCreateScheduleMutation() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const credentialGetter = useCredentialGetter();const queryClient = useQueryClient();@@ -47,7 +47,7 @@ function useCreateScheduleMutation() {}function useToggleScheduleMutation() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const credentialGetter = useCredentialGetter();const queryClient = useQueryClient();@@ -90,7 +90,7 @@ function useToggleScheduleMutation() {}function useDeleteScheduleMutation() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const credentialGetter = useCredentialGetter();const queryClient = useQueryClient();diff --git a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunQuery.tsindex 53d14dd87..fa8fe49e4 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunQuery.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunQuery.ts@@ -7,7 +7,7 @@ import {statusIsRunningOrQueued,} from "@/routes/tasks/types";import { keepPreviousData, useQuery } from "@tanstack/react-query";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useGlobalWorkflowsQuery } from "./useGlobalWorkflowsQuery";import {getActiveOrgQueryKeyScope,@@ -21,7 +21,7 @@ function useWorkflowRunQuery(options?: {}) {const urlWorkflowRunId = useFirstParam("workflowRunId", "runId");const workflowRunId = options?.workflowRunId ?? urlWorkflowRunId;- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const credentialGetter = useCredentialGetter();const { data: globalWorkflows } = useGlobalWorkflowsQuery();const activeOrgId = useActiveOrgId();diff --git a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunWithWorkflowQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunWithWorkflowQuery.tsindex 0429269a5..b74365dd9 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunWithWorkflowQuery.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowRunWithWorkflowQuery.ts@@ -13,7 +13,10 @@ import {useActiveOrgId,} from "@/store/ActiveOrgContext";-function useWorkflowRunWithWorkflowQuery(options?: { workflowRunId?: string }) {+function useWorkflowRunWithWorkflowQuery(options?: {+ workflowRunId?: string;+ enabled?: boolean;+}) {const urlWorkflowRunId = useFirstParam("workflowRunId", "runId");const workflowRunId = options?.workflowRunId ?? urlWorkflowRunId;const credentialGetter = useCredentialGetter();@@ -55,7 +58,7 @@ function useWorkflowRunWithWorkflowQuery(options?: { workflowRunId?: string }) {}return statusIsRunningOrQueued(query.state.data);},- enabled: !!workflowRunId,+ enabled: (options?.enabled ?? true) && !!workflowRunId,});}diff --git a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowSchedulesQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowSchedulesQuery.tsindex 0ab6f208c..52e0e5bfc 100644--- a/skyvern-frontend/src/routes/workflows/hooks/useWorkflowSchedulesQuery.ts+++ b/skyvern-frontend/src/routes/workflows/hooks/useWorkflowSchedulesQuery.ts@@ -1,5 +1,5 @@import { useQuery } from "@tanstack/react-query";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { getClient } from "@/api/AxiosClient";import { useCredentialGetter } from "@/hooks/useCredentialGetter";import type {@@ -8,7 +8,7 @@ import type {} from "@/routes/workflows/types/scheduleTypes";function useWorkflowSchedulesQuery() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const credentialGetter = useCredentialGetter();return useQuery<Array<WorkflowSchedule>>({diff --git a/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx b/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsxindex c24dc2eb5..5a55a24f0 100644--- a/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/BrowserPaneHeader.tsx@@ -7,7 +7,7 @@ import {import { AxiosError } from "axios";import { useMutation, useQueryClient } from "@tanstack/react-query";import { useState } from "react";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { getClient } from "@/api/AxiosClient";import { DebugSessionApiResponse } from "@/api/types";@@ -103,7 +103,7 @@ export function BrowserPaneViewPills() {}export function BrowserPaneActions() {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const compact = useStudioPaneCompact();const credentialGetter = useCredentialGetter();const queryClient = useQueryClient();diff --git a/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsx b/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsxindex 0e22860f3..8ccff64cc 100644--- a/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsx@@ -3,7 +3,7 @@ import {EnterFullScreenIcon,GlobeIcon,} from "@radix-ui/react-icons";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useStudioShellStore } from "@/store/StudioShellStore";import { cn } from "@/util/utils";@@ -23,7 +23,7 @@ export function BrowserPiP() {const { openPane } = useStudioPanes();const { setEditorStreamSlot } = useStudioShellContext();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();// The session is owned (fetched) by the editor's Workspace; read it passively.const { data: debugSession } = useDebugSessionQuery({workflowPermanentId,diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsxindex 504de30c5..2e8160bd7 100644--- a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx@@ -1,4 +1,5 @@-import { useNavigate, useParams, useSearchParams } from "react-router-dom";+import { useNavigate, useSearchParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { statusIsFinalized } from "@/routes/tasks/types";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";@@ -16,7 +17,7 @@ import { useStudioWorkflowDeletedAt } from "./StudioShellContext";export function RunTab() {const navigate = useNavigate();const [searchParams] = useSearchParams();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { openPane } = useStudioPanes();const { runId, pending } = useStudioInspectedRun();const { data: workflowRun } = useWorkflowRunWithWorkflowQuery(diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.test.tsxindex 1bdae8688..85389ae5a 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.test.tsx@@ -63,4 +63,9 @@ describe("StudioCoachMark", () => {renderAt("/workflows/wpid_1/studio?wr=wr_1");expect(screen.queryByRole("note")).toBeNull();});++ test("stays out of the way under the short run URL path", () => {+ renderAt("/runs/wr_1");+ expect(screen.queryByRole("note")).toBeNull();+ });});diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.tsxindex 2d5e47f1e..de6c37797 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioCoachMark.tsx@@ -2,6 +2,7 @@ import { useState } from "react";import { useLocation } from "react-router-dom";import { Button } from "@/components/ui/button";+import { useStudioRunRouteMatch } from "@/routes/workflows/useStudioRunRouteMatch";import { useStudioFirstRunStore } from "@/store/StudioFirstRunStore";import { liveSearch } from "./liveSearch";@@ -15,10 +16,14 @@ export function StudioCoachMark() {const coachMarkSeen = useStudioFirstRunStore((s) => s.coachMarkSeen);const markCoachMarkSeen = useStudioFirstRunStore((s) => s.markCoachMarkSeen);const location = useLocation();+ const runRouteMatch = useStudioRunRouteMatch();const [deepLinked] = useState(() => {const params = new URLSearchParams(liveSearch(location.search));return Boolean(- params.get("wr") || params.get("active") || params.get("bl"),+ params.get("wr") ||+ params.get("active") ||+ params.get("bl") ||+ runRouteMatch,);});diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsxindex 18d8f8770..f8b062d4a 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioPaneDefaults.tsx@@ -11,6 +11,7 @@ import {fitPanesToWidth,panesFitWidth,resolveOpenPanes,+ searchWithRunReference,STUDIO_PANE_IDS,type StudioPaneId,} from "./panes";@@ -19,6 +20,7 @@ import {type PaneClamp,type PaneWrite,} from "./StudioPaneDefaultsContext";+import { useStudioRunId } from "./useStudioRunId";// Drop unknown ids and duplicates; return null when the result is empty/invalid.function sanitizeLearnedPanes(@@ -55,6 +57,7 @@ export function StudioPaneDefaultsProvider({children: ReactNode;}) {const location = useLocation();+ const studioRunId = useStudioRunId();// hasBlocks gates only the learned-layout lookup, not the factory default// itself — empty agents never restore a saved arrangement.@@ -74,7 +77,7 @@ export function StudioPaneDefaultsProvider({const [initialPanes] = useState<readonly StudioPaneId[]>(() =>resolveOpenPanes(- liveSearch(location.search),+ searchWithRunReference(liveSearch(location.search), studioRunId),defaultPanes,learnedRunPanes,),diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsxindex ebe6fb4af..437176c74 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx@@ -7,7 +7,7 @@ import {type ReactNode,} from "react";import { createPortal } from "react-dom";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { Cross2Icon } from "@radix-ui/react-icons";import {@@ -544,7 +544,7 @@ function WorkflowDeletedPaneNotice() {function StudioStage(props: StudioWorkspaceProps) {const { panes, closePane, openPane, setPanesOrder } = useStudioPanes();const { registerStageElement } = useStudioPaneDefaults();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const workflowDeleted = Boolean(props.workflow.deleted_at);const isRecording = useRecordingStore((s) => s.isRecording);// The title store is normally seeded by the embedded Workspace's canvas,diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsxindex 918e6536c..3f65d6b03 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx@@ -8,12 +8,8 @@ import {StopIcon,} from "@radix-ui/react-icons";import { useMutation, useQueryClient } from "@tanstack/react-query";-import {- Link,- useNavigate,- useParams,- useSearchParams,-} from "react-router-dom";+import { Link, useNavigate, useSearchParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { getClient } from "@/api/AxiosClient";import { SaveIcon } from "@/components/icons/SaveIcon";@@ -64,7 +60,7 @@ export function TitleSection({ editable = true }: { editable?: boolean }) {const { title, setTitle } = useWorkflowTitleStore();const setHasChanges = useWorkflowHasChangesStore((s) => s.setHasChanges);const isRecording = useRecordingStore((s) => s.isRecording);- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const canEdit = editable && !isRecording;return (<div className="flex min-w-0 max-w-[19rem] items-center gap-1">@@ -268,7 +264,7 @@ function PanelToggle({// land here and must be stoppable — render Stop when active, nothing otherwise.export function RunStopButton({ stopOnly = false }: { stopOnly?: boolean }) {const navigate = useNavigate();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const runId = useStudioRunId();const [searchParams] = useSearchParams();const queryClient = useQueryClient();diff --git a/skyvern-frontend/src/routes/workflows/studio/panes.test.ts b/skyvern-frontend/src/routes/workflows/studio/panes.test.tsindex 91b869a88..afe76bf06 100644--- a/skyvern-frontend/src/routes/workflows/studio/panes.test.ts+++ b/skyvern-frontend/src/routes/workflows/studio/panes.test.ts@@ -16,6 +16,7 @@ import {parsePanesParam,resolveOpenPanes,searchWithPanes,+ searchWithRunReference,toReadableSearch,togglePane,withPaneClosed,@@ -500,3 +501,30 @@ describe("layoutClassForSearch", () => {expect(layoutClassForSearch("?active=act_1&bl=block_1")).toBeNull();});});++describe("searchWithRunReference", () => {+ test("injects ?wr= from the path run so /runs/{wr} resolves run-class panes", () => {+ expect(searchWithRunReference("", "wr_123")).toBe("?wr=wr_123");+ expect(resolveOpenPanes(searchWithRunReference("", "wr_123"))).toEqual(+ RUN_APPEND_PANES,+ );+ expect(layoutClassForSearch(searchWithRunReference("", "wr_123"))).toBe(+ "run",+ );+ });++ test("keeps an explicit ?wr= and other params untouched", () => {+ expect(searchWithRunReference("?wr=wr_a&bl=b", "wr_b")).toBe(+ "?wr=wr_a&bl=b",+ );+ expect(searchWithRunReference("?panes=browser", "wr_1")).toBe(+ "?panes=browser&wr=wr_1",+ );+ });++ test("no run id is a no-op (edit surfaces keep their search)", () => {+ expect(searchWithRunReference("?panes=editor", undefined)).toBe(+ "?panes=editor",+ );+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/panes.ts b/skyvern-frontend/src/routes/workflows/studio/panes.tsindex ce6d45c25..e701dd390 100644--- a/skyvern-frontend/src/routes/workflows/studio/panes.ts+++ b/skyvern-frontend/src/routes/workflows/studio/panes.ts@@ -223,6 +223,24 @@ export function toReadableSearch(params: URLSearchParams): string {return raw ? `?${raw}` : "";}+// The pane layout keys the focused run off ?wr=; the short /runs/{wr} URL carries+// it in the path instead, so pane RESOLUTION runs against a search that reflects+// that run. This is never written back — the address bar stays paramless.+export function searchWithRunReference(+ search: string,+ runId: string | undefined,+): string {+ if (!runId) {+ return search;+ }+ const params = new URLSearchParams(search);+ if (params.has("wr")) {+ return search;+ }+ params.set("wr", runId);+ return toReadableSearch(params);+}+// Serialize the open list into a search string, preserving unrelated params.export function searchWithPanes(search: string,diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsxindex b831a8a25..1616d2855 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunPaneHeader.tsx@@ -7,7 +7,7 @@ import {ReloadIcon,Share1Icon,} from "@radix-ui/react-icons";-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { ApiWebhookActionsMenu } from "@/components/ApiWebhookActionsMenu";import { WebhookReplayDialog } from "@/components/WebhookReplayDialog";@@ -45,7 +45,7 @@ import { ViewToggle } from "../ViewToggle";export function RunPaneViewToggles() {const compact = useStudioPaneCompact();const { runId } = useStudioInspectedRun();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: workflowRun } = useWorkflowRunWithWorkflowQuery(runId ? { workflowRunId: runId } : undefined,);diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsxindex 017266e15..8f3508cef 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx@@ -2,7 +2,7 @@import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { cleanup, fireEvent, render, within } from "@testing-library/react";-import { MemoryRouter, useLocation } from "react-router-dom";+import { MemoryRouter, Route, Routes, useLocation } from "react-router-dom";import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import { type ReactNode } from "react";@@ -248,7 +248,16 @@ function renderRunView(<StudioPaneCompactContext.Provider value={compact}><RunPaneViewToggles /></StudioPaneCompactContext.Provider>- <RunView workflowRunId="wr_1" {...props} />+ {initialEntry.startsWith("/runs/") ? (+ <Routes>+ <Route+ path="/runs/:runId"+ element={<RunView workflowRunId="wr_1" {...props} />}+ />+ </Routes>+ ) : (+ <RunView workflowRunId="wr_1" {...props} />+ )}</TooltipProvider><LocationSpy /></MemoryRouter>@@ -420,6 +429,13 @@ describe("RunView cold-open selection", () => {expect(getByTestId("location-search").textContent).toContain("active=");});+ test("a terminal /runs/{wr} short link with no ?active= selects the last item", () => {+ seedTerminalRunWithActions();+ renderRunView({}, "/runs/wr_1");++ expect(useRunViewStore.getState().pinnedFrameId).toBe("act_2");+ });+test("an explicit ?active= deep link wins over the last-item default", () => {seedTerminalRunWithActions();renderRunView({}, "/?wr=wr_1&active=act_1");diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex 20c7ac2e0..6511a9152 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -4,7 +4,7 @@ import {Cross2Icon,ExclamationTriangleIcon,} from "@radix-ui/react-icons";-import { useNavigate, useSearchParams } from "react-router-dom";+import { useNavigate, useParams, useSearchParams } from "react-router-dom";import { Status } from "@/api/types";import { Button } from "@/components/ui/button";@@ -79,6 +79,7 @@ export function RunView({onFix,onRetry,}: RunViewProps) {+ const { runId: pathRunId } = useParams();const queryOptions = workflowRunId ? { workflowRunId } : undefined;// isLoading here, not isPending like RunTab: this query is enabled only once a run// id exists, so a disabled query means "no run" → fall through to the empty CTA.@@ -154,6 +155,11 @@ export function RunView({if (!workflowRunId) {return;}+ // Under the short /runs/{wr} URL the run is already named by the path, so+ // pinning ?wr= would only duplicate it; the pane reads the run from either.+ if (pathRunId === workflowRunId) {+ return;+ }if (new URLSearchParams(window.location.search).get("wr")) {return;}@@ -165,7 +171,7 @@ export function RunView({}next.set("wr", workflowRunId);navigate({ search: toReadableSearch(next) }, { replace: true });- }, [runPaneOpen, workflowRunId, navigate]);+ }, [runPaneOpen, workflowRunId, pathRunId, navigate]);const frames = useMemo(() => buildFilmstrip(timeline), [timeline]);const lastFrame = frames.length > 0 ? frames[frames.length - 1] : null;@@ -197,7 +203,11 @@ export function RunView({const params = new URLSearchParams(window.location.search || searchParamsRef.current.toString(),);- if (params.get("wr") !== workflowRunId || params.get("active")) {+ // The short /runs/{wr} URL names the run in the path rather than ?wr=, so a+ // matching path id is the focused deep link too (parity with ?wr= cold open).+ const isFocusedDeepLink =+ params.get("wr") === workflowRunId || pathRunId === workflowRunId;+ if (!isFocusedDeepLink || params.get("active")) {return;}if (params.has("bl")) {@@ -217,7 +227,7 @@ export function RunView({if (last) {pinFrame(last.id);}- }, [workflowRunId, workflowRun, timeline, frames, pinFrame]);+ }, [workflowRunId, workflowRun, timeline, frames, pinFrame, pathRunId]);const outcome = runOutcomeFromStatus(workflowRun?.status);// A user-canceled run isn't a failure — don't show the "run failed" CTA.diff --git a/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts b/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.tsindex afec091e7..6923855e5 100644--- a/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts+++ b/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts@@ -1,5 +1,6 @@import { useEffect, useRef } from "react";-import { useParams, useSearchParams } from "react-router-dom";+import { useSearchParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useRecordingStore } from "@/store/useRecordingStore";import { useRunViewStore } from "@/store/RunViewStore";@@ -36,7 +37,7 @@ type BrowserPaneViewState = {* the pane body and its header chrome (queries dedupe via react-query).*/export function useBrowserPaneView(): BrowserPaneViewState {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const [searchParams] = useSearchParams();const { runId, explicit } = useStudioInspectedRun();const visuals = useRunVisuals(runId);diff --git a/skyvern-frontend/src/routes/workflows/studio/useExecutingBlockRun.ts b/skyvern-frontend/src/routes/workflows/studio/useExecutingBlockRun.tsindex e765adb67..a334b8c2e 100644--- a/skyvern-frontend/src/routes/workflows/studio/useExecutingBlockRun.ts+++ b/skyvern-frontend/src/routes/workflows/studio/useExecutingBlockRun.ts@@ -1,4 +1,5 @@-import { useParams, useSearchParams } from "react-router-dom";+import { useSearchParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { Status } from "@/api/types";import { statusIsFinalized } from "@/routes/tasks/types";@@ -13,7 +14,7 @@ import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWork* waiting on human input (2FA, verification).*/export function useExecutingBlockRun(): boolean {- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const [searchParams] = useSearchParams();const isBlockRun = searchParams.has("bl");const urlRunId = searchParams.get("wr");diff --git a/skyvern-frontend/src/routes/workflows/studio/useStudioInspectedRun.ts b/skyvern-frontend/src/routes/workflows/studio/useStudioInspectedRun.tsindex a57f13359..ee66d7487 100644--- a/skyvern-frontend/src/routes/workflows/studio/useStudioInspectedRun.ts+++ b/skyvern-frontend/src/routes/workflows/studio/useStudioInspectedRun.ts@@ -1,4 +1,4 @@-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";import { useStudioRunId } from "./useStudioRunId";@@ -14,7 +14,7 @@ export function useStudioInspectedRun(): {pending: boolean;} {const urlRunId = useStudioRunId();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: runs, isPending } = useWorkflowRunsQuery({workflowPermanentId,page: 1,diff --git a/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts b/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.tsindex b96cc0e64..76e8105b4 100644--- a/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts+++ b/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts@@ -14,12 +14,14 @@ import {panesWithoutDeletedBlocked,resolveOpenPanes,searchWithPanes,+ searchWithRunReference,togglePane as togglePaneIn,withPaneClosed,withPaneOpen,type StudioPaneId,} from "./panes";import { useStudioPaneDefaults } from "./StudioPaneDefaultsContext";+import { useStudioRunId } from "./useStudioRunId";import { useStudioWorkflowDeletedAt } from "./StudioShellContext";type ApplyPanesOptions = Pick<NavigateOptions, "state"> & {@@ -38,6 +40,9 @@ type ApplyPanesOptions = Pick<NavigateOptions, "state"> & {export function useStudioPanes() {const location = useLocation();const navigate = useNavigate();+ // Under /runs/{wr} the focused run is the path, not ?wr=; fold it into the+ // search used for resolution so the run layout (not the edit default) opens.+ const studioRunId = useStudioRunId();const { defaultPanes, clamp, notePaneWrite, learnedRunPanes } =useStudioPaneDefaults();const workflowDeleted = useStudioWorkflowDeletedAt() !== null;@@ -63,8 +68,14 @@ export function useStudioPanes() {const panes = useMemo(() =>- present(resolveOpenPanes(location.search, defaultPanes, learnedRunPanes)),- [location.search, defaultPanes, present, learnedRunPanes],+ present(+ resolveOpenPanes(+ searchWithRunReference(location.search, studioRunId),+ defaultPanes,+ learnedRunPanes,+ ),+ ),+ [location.search, studioRunId, defaultPanes, present, learnedRunPanes],);// The open list as the live URL resolves it right now — what cross-route@@ -74,12 +85,12 @@ export function useStudioPanes() {(): StudioPaneId[] =>present(resolveOpenPanes(- liveSearch(location.search),+ searchWithRunReference(liveSearch(location.search), studioRunId),defaultPanes,learnedRunPanes,),),- [location.search, defaultPanes, present, learnedRunPanes],+ [location.search, studioRunId, defaultPanes, present, learnedRunPanes],);const applyPanes = useCallback(@@ -99,7 +110,9 @@ export function useStudioPanes() {{ replace: true, state: options?.state },);if (options?.learn && next.length > 0 && !workflowDeleted) {- const cls = layoutClassForSearch(search);+ const cls = layoutClassForSearch(+ searchWithRunReference(search, studioRunId),+ );if (cls !== null) {setPaneLayout(cls, next);}@@ -108,6 +121,7 @@ export function useStudioPanes() {[navigate,location.search,+ studioRunId,resolveLivePanes,notePaneWrite,workflowDeleted,diff --git a/skyvern-frontend/src/routes/workflows/studio/useStudioPanesOrder.test.tsx b/skyvern-frontend/src/routes/workflows/studio/useStudioPanesOrder.test.tsxindex 7738a8174..999b1a6be 100644--- a/skyvern-frontend/src/routes/workflows/studio/useStudioPanesOrder.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/useStudioPanesOrder.test.tsx@@ -1,7 +1,7 @@// @vitest-environment jsdomimport { fireEvent, render, screen } from "@testing-library/react";-import { MemoryRouter } from "react-router-dom";+import { MemoryRouter, Route, Routes } from "react-router-dom";import { describe, expect, test } from "vitest";import { type StudioPaneId } from "./panes";@@ -77,3 +77,30 @@ describe("useStudioPanes setPanesOrder", () => {expect(screen.getByTestId("panes").textContent).toBe("browser,copilot");});});++function RunRouteProbe() {+ const { panes } = useStudioPanes();+ return <output data-testid="panes">{panes.join(",")}</output>;+}++function renderAtRunRoute(entry: string) {+ return render(+ <MemoryRouter initialEntries={[entry]}>+ <Routes>+ <Route path="/runs/:runId/*" element={<RunRouteProbe />} />+ </Routes>+ </MemoryRouter>,+ );+}++describe("useStudioPanes under the short run URL", () => {+ test("/runs/{wr} opens the run layout from the path, not the edit default", () => {+ renderAtRunRoute("/runs/wr_1");+ expect(screen.getByTestId("panes").textContent).toBe("browser,overview");+ });++ test("an explicit ?panes= still wins under the short run URL", () => {+ renderAtRunRoute("/runs/wr_1?panes=copilot");+ expect(screen.getByTestId("panes").textContent).toBe("copilot");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/useStudioRunSignals.ts b/skyvern-frontend/src/routes/workflows/studio/useStudioRunSignals.tsindex 585cd6ce7..398bac48e 100644--- a/skyvern-frontend/src/routes/workflows/studio/useStudioRunSignals.ts+++ b/skyvern-frontend/src/routes/workflows/studio/useStudioRunSignals.ts@@ -1,4 +1,4 @@-import { useParams } from "react-router-dom";+import { useWorkflowPermanentId } from "@/routes/workflows/WorkflowPermanentIdContext";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";@@ -12,7 +12,7 @@ import { useStudioRunId } from "./useStudioRunId";*/export function useStudioRunSignals() {const urlRunId = useStudioRunId();- const { workflowPermanentId } = useParams();+ const workflowPermanentId = useWorkflowPermanentId();const { data: urlRun } = useWorkflowRunWithWorkflowQuery(urlRunId ? { workflowRunId: urlRunId } : undefined,);diff --git a/skyvern-frontend/src/routes/workflows/useStudioRunRouteMatch.ts b/skyvern-frontend/src/routes/workflows/useStudioRunRouteMatch.tsnew file mode 100644index 000000000..fc787d6f0--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/useStudioRunRouteMatch.ts@@ -0,0 +1,13 @@+import { type PathMatch, useMatch } from "react-router-dom";++/**+ * The short run URL (/runs/{wr}) renders the studio run view when the preview is+ * on, so route classifiers that recognize /agents/.../studio must also treat it+ * as a studio surface. Only workflow runs (wr_) route into the studio; task runs+ * keep their own detail view. Callers still gate on the studio flag themselves,+ * since flag-off /runs/{wr} renders the legacy run page.+ */+export function useStudioRunRouteMatch(): PathMatch<string> | null {+ const match = useMatch("/runs/:runId/*");+ return match?.params.runId?.startsWith("wr_") ? match : null;+}diff --git a/skyvern-frontend/src/store/DebugStoreContext.tsx b/skyvern-frontend/src/store/DebugStoreContext.tsxindex 4c95bf8a0..f2f361199 100644--- a/skyvern-frontend/src/store/DebugStoreContext.tsx+++ b/skyvern-frontend/src/store/DebugStoreContext.tsx@@ -2,6 +2,7 @@ import React, { createContext, useMemo } from "react";import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import { useAgentsPathMatch } from "@/routes/workflows/useAgentsPathMatch";+import { useStudioRunRouteMatch } from "@/routes/workflows/useStudioRunRouteMatch";function useIsDebugMode() {const workflowBuildMatch = useAgentsPathMatch("/:workflowPermanentId/build");@@ -19,10 +20,11 @@ function useIsDebugMode() {function useBlockRunsEnabled() {const editMatch = useAgentsPathMatch("/:workflowPermanentId/edit");const studioMatch = useAgentsPathMatch("/:workflowPermanentId/studio");+ const runStudioMatch = useStudioRunRouteMatch();const studioEnabled = useWorkflowStudioEnabled();return useMemo(- () => studioEnabled && Boolean(editMatch || studioMatch),- [studioEnabled, editMatch, studioMatch],+ () => studioEnabled && Boolean(editMatch || studioMatch || runStudioMatch),+ [studioEnabled, editMatch, studioMatch, runStudioMatch],);}