Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-11662, SKY-11663): studio spine + side-by-side panes (?panes= URL state), Copilot as a peer pane (#7007)
Celal Zamanoğlucd088a4ce0b3
diff --git a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsxindex 41c547c04..d70d63b32 100644--- a/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx+++ b/skyvern-frontend/src/routes/workflows/RunWorkflowForm.tsx@@ -46,7 +46,6 @@ import { useCredentialGetter } from "@/hooks/useCredentialGetter";import { useBlockScriptsQuery } from "@/routes/workflows/hooks/useBlockScriptsQuery";import { constructCacheKeyValueFromParameters } from "@/routes/workflows/editor/utils";import { useWorkflowQuery } from "@/routes/workflows/hooks/useWorkflowQuery";-import { useStudioShellStore } from "@/store/StudioShellStore";import { useWorkflowStudioEnabled } from "@/hooks/useWorkflowStudioEnabled";import { workflowEditorPath } from "./studioNavigation";import { CredentialSetupPrompt } from "@/components/onboarding/CredentialSetupPrompt";@@ -404,8 +403,7 @@ function RunWorkflowForm({queryKey: ["runs"],});if (studioEnabled) {- // Land in the studio shell with the Run tab live.- useStudioShellStore.getState().setTab("run");+ // Land in the studio shell; the ?wr= deep link opens the Run pane.navigate(`/workflows/${workflowPermanentId}/studio?wr=${response.data.workflow_run_id}`,);diff --git a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsxindex dab1e8360..8120192cd 100644--- a/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx+++ b/skyvern-frontend/src/routes/workflows/copilot/WorkflowCopilotChat.tsx@@ -14,7 +14,6 @@ import {ReloadIcon,Cross2Icon,ChevronDownIcon,- ChevronLeftIcon,CheckIcon,} from "@radix-ui/react-icons";import { createPortal } from "react-dom";@@ -358,8 +357,9 @@ interface WorkflowCopilotChatProps {onInitialMessageConsumed?: () => void;// Render as a docked panel (no float/drag/resize) instead of a floating window.docked?: boolean;- // Collapse the docked panel to a rail. Only used when `docked`.- onCollapse?: () => void;+ // Render frameless — no border, background, or title; the header keeps only+ // the controls row. Only used when `docked`.+ chromeless?: boolean;// When docked, render into this element via a portal (keeps the component in// its parent's React tree so canvas callbacks stay wired) instead of inline.portalTarget?: HTMLElement | null;@@ -434,7 +434,7 @@ export function WorkflowCopilotChat({initialMessageFixOrigin,onInitialMessageConsumed,docked = false,- onCollapse,+ chromeless = false,portalTarget,}: WorkflowCopilotChatProps = {}) {const copilotV2Flag = useFeatureFlag("ENABLE_WORKFLOW_COPILOT_V2");@@ -2060,7 +2060,9 @@ export function WorkflowCopilotChat({<divclassName={docked- ? "relative flex h-full w-full flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1 text-foreground"+ ? chromeless+ ? "relative flex h-full w-full flex-col overflow-hidden text-foreground"+ : "relative flex h-full w-full flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1 text-foreground": "fixed z-50 flex flex-col rounded-lg border border-border bg-slate-elevation1 text-foreground shadow-2xl"}style={@@ -2077,21 +2079,27 @@ export function WorkflowCopilotChat({{/* Header */}<divclassName={- "flex items-center justify-between border-b border-border px-4" +- (docked ? " h-14 shrink-0" : " cursor-move py-2")+ "flex items-center border-b border-border px-4" ++ (docked+ ? chromeless+ ? " h-11 shrink-0 justify-end"+ : " h-14 shrink-0 justify-between"+ : " cursor-move justify-between py-2")}onMouseDown={docked ? undefined : handleMouseDown}>- <div className="flex items-center gap-2">- <h3 className="text-sm font-semibold text-foreground">- {docked ? "Copilot" : "Agent Copilot (Beta)"}- </h3>- {docked ? (- <span className="rounded bg-studio-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-studio-accent-2">- Beta- </span>- ) : null}- </div>+ {chromeless ? null : (+ <div className="flex items-center gap-2">+ <h3 className="text-sm font-semibold text-foreground">+ {docked ? "Copilot" : "Agent Copilot (Beta)"}+ </h3>+ {docked ? (+ <span className="rounded bg-studio-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-studio-accent-2">+ Beta+ </span>+ ) : null}+ </div>+ )}<div className="flex items-center gap-2"><WorkflowCopilotHistoryworkflowPermanentId={workflowPermanentId}@@ -2109,18 +2117,8 @@ export function WorkflowCopilotChat({</button><div className="h-2 w-2 rounded-full bg-emerald-500"></div><span className="text-xs text-muted-foreground">Active</span>- {docked ? (- onCollapse ? (- <button- type="button"- onClick={onCollapse}- className="ml-2 rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground"- title="Collapse Copilot"- >- <ChevronLeftIcon className="h-4 w-4" />- </button>- ) : null- ) : (+ {/* Only the floating window closes itself; docked chrome is external. */}+ {docked ? null : (<buttontype="button"onClick={() => onClose?.()}diff --git a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsxindex a5821ec5b..2b4dca309 100644--- a/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/Workspace.tsx@@ -157,11 +157,7 @@ import { WorkflowCopilotChat } from "../copilot/WorkflowCopilotChat";import { useStudioRunId } from "../studio/useStudioRunId";import { copilotRunId } from "./copilotRunId";import { useStudioShellContext } from "../studio/StudioShellContext";-import {- STUDIO_COPILOT_RAIL_WIDTH,- STUDIO_COPILOT_WIDTH,-} from "../studio/constants";-import { useStudioShellStore } from "@/store/StudioShellStore";+import { useStudioPanes } from "../studio/useStudioPanes";import { WorkflowCopilotButton } from "../copilot/WorkflowCopilotButton";import { resolveCopilotLiveBrowserReady } from "../copilot/browserReadiness";@@ -328,18 +324,8 @@ function Workspace({}: Props) {const { blockLabel, workflowPermanentId } = useParams();const { copilotPortalEl: studioCopilotPortalEl } = useStudioShellContext();- const studioCopilotCollapsed = useStudioShellStore((s) => s.copilotCollapsed);- const studioSetCopilotCollapsed = useStudioShellStore(- (s) => s.setCopilotCollapsed,- );- const studioSetTab = useStudioShellStore((s) => s.setTab);- // The studio canvas sits right of the Copilot column; offset the fit by the- // column width so the chain centers on the whole page, not just the pane.- const studioCanvasCenterOffset = embedded- ? studioCopilotCollapsed- ? STUDIO_COPILOT_RAIL_WIDTH- : STUDIO_COPILOT_WIDTH- : 0;+ const { panes: studioPanes, openPane: openStudioPane } = useStudioPanes();+ const studioCopilotOpen = studioPanes.includes("copilot");const location = useLocation();const navigate = useNavigate();const locationState = location.state as {@@ -1804,7 +1790,6 @@ function Workspace({onEdgesChange={onEdgesChange}initialTitle={initialTitle}workflow={workflow}- centerOffsetX={studioCanvasCenterOffset}embedded={embedded}onRequestDeleteNode={handleRequestDeleteNode}captureHistoryImmediately={captureWorkflowEditImmediately}@@ -2358,14 +2343,10 @@ function Workspace({)}<WorkflowCopilotChat- isOpen={- embedded ? !studioCopilotCollapsed : showBrowser && isCopilotOpen- }+ isOpen={embedded ? studioCopilotOpen : showBrowser && isCopilotOpen}docked={embedded}+ chromeless={embedded}portalTarget={embedded ? studioCopilotPortalEl : undefined}- onCollapse={- embedded ? () => studioSetCopilotCollapsed(true) : undefined- }onClose={() => setIsCopilotOpen(false)}onMessageCountChange={setCopilotMessageCount}buttonRef={copilotButtonRef}@@ -2548,10 +2529,10 @@ function Workspace({};// Hide chat and show comparison. The comparison renders on the- // editor canvas, so surface the editor tab when docked in the studio.+ // editor canvas, so surface the Editor pane when docked in the studio.setIsCopilotOpen(false);if (embedded) {- studioSetTab("editor");+ openStudioPane("editor");}setWorkflowPanelState({active: false,diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsxindex ee3b54f95..808ae853e 100644--- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx@@ -58,7 +58,11 @@ import { getInitialValues } from "@/routes/workflows/utils";import { useDebuggerLastRunValuesStore } from "@/store/DebuggerLastRunValuesStore";import { useBlockOutputStore } from "@/store/BlockOutputStore";import { useDebugStore } from "@/store/useDebugStore";-import { useStudioShellStore } from "@/store/StudioShellStore";+import {+ STUDIO_PANES_PARAM,+ resolveOpenPanes,+ withPanesOpen,+} from "@/routes/workflows/studio/panes";import { useRecordingStore } from "@/store/useRecordingStore";import { useWorkflowPanelStore } from "@/store/WorkflowPanelStore";import { useWorkflowSave } from "@/store/WorkflowHasChangesStore";@@ -559,10 +563,19 @@ function NodeHeader({});if (studioEnabled) {- useStudioShellStore.getState().setTab("run");- navigate(- `/workflows/${workflowPermanentId}/studio?wr=${response.data.run_id}&bl=${encodeURIComponent(label)}`,- );+ // One navigation carries the pane state (current panes plus Run and+ // Browser); other query params intentionally reset for the fresh run.+ const liveSearch = window.location.search || location.search;+ const panes = withPanesOpen(resolveOpenPanes(liveSearch), [+ "run",+ "browser",+ ]);+ const search = new URLSearchParams({+ wr: response.data.run_id,+ bl: label,+ });+ search.set(STUDIO_PANES_PARAM, panes.join(","));+ navigate(`/workflows/${workflowPermanentId}/studio?${search}`);} else {navigate(`/workflows/${workflowPermanentId}/${response.data.run_id}/${label}/build`,diff --git a/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsx b/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsxindex 193a8c2b1..d63ba9ed5 100644--- a/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/BrowserPiP.tsx@@ -11,6 +11,7 @@ import { cn } from "@/util/utils";import { useDebugSessionQuery } from "../hooks/useDebugSessionQuery";import { useStudioShellContext } from "./StudioShellContext";import { usePresence } from "./usePresence";+import { useStudioPanes } from "./useStudioPanes";/*** Picture-in-picture preview of the persistent debug browser. The stream node@@ -19,7 +20,7 @@ import { usePresence } from "./usePresence";export function BrowserPiP() {const minimized = useStudioShellStore((s) => s.pipMinimized);const setMinimized = useStudioShellStore((s) => s.setPipMinimized);- const setTab = useStudioShellStore((s) => s.setTab);+ const { openPane } = useStudioPanes();const { setEditorStreamSlot } = useStudioShellContext();const { workflowPermanentId } = useParams();@@ -87,9 +88,9 @@ export function BrowserPiP() {<div className="flex-1" /><buttontype="button"- onClick={() => setTab("browser")}- aria-label="Expand to Browser tab"- title="Expand to Browser tab"+ onClick={() => openPane("browser")}+ aria-label="Expand to Browser pane"+ title="Expand to Browser pane"className="rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"><EnterFullScreenIcon className="h-3.5 w-3.5" />@@ -106,9 +107,9 @@ export function BrowserPiP() {</div><buttontype="button"- onClick={() => setTab("browser")}- title="Expand to Browser tab"- aria-label="Expand to Browser tab"+ onClick={() => openPane("browser")}+ title="Expand to Browser pane"+ aria-label="Expand to Browser pane"className="relative block h-[12rem] w-full bg-slate-elevation2 text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring">{sessionId ? (diff --git a/skyvern-frontend/src/routes/workflows/studio/CopilotRail.tsx b/skyvern-frontend/src/routes/workflows/studio/CopilotRail.tsxdeleted file mode 100644index bc7014842..000000000--- a/skyvern-frontend/src/routes/workflows/studio/CopilotRail.tsx+++ /dev/null@@ -1,24 +0,0 @@-import { ChevronRightIcon } from "@radix-ui/react-icons";--export function CopilotRail({ onExpand }: { onExpand: () => void }) {- return (- <div className="flex h-full w-full flex-col items-center gap-3 rounded-lg border border-border bg-slate-elevation1 py-3">- <button- type="button"- onClick={onExpand}- title="Show Copilot"- aria-label="Show Copilot"- className="rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- >- <ChevronRightIcon className="h-4 w-4" />- </button>- <span className="h-2 w-2 rounded-full bg-studio-accent shadow-[0_0_0_4px_rgba(109,108,246,0.18)]" />- <span- className="mt-1 text-xs font-medium tracking-wide text-muted-foreground"- style={{ writingMode: "vertical-rl" }}- >- Copilot- </span>- </div>- );-}diff --git a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsxindex 884f5f8f6..09b67cb03 100644--- a/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/RunTab.tsx@@ -1,27 +1,20 @@-import {- useLocation,- useNavigate,- useParams,- useSearchParams,-} from "react-router-dom";--import { useStudioShellStore } from "@/store/StudioShellStore";+import { useNavigate, useParams, useSearchParams } from "react-router-dom";import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";import { RunView } from "./runview/RunView";+import { useStudioPanes } from "./useStudioPanes";import { useStudioRunId } from "./useStudioRunId";/**- * Run tab of the studio shell — the fused hero + filmstrip RunView. Shows the+ * Run pane of the studio shell — the fused hero + filmstrip RunView. Shows the* run in the URL when present, otherwise the workflow's most recent run.*/export function RunTab() {const navigate = useNavigate();- const location = useLocation();const urlRunId = useStudioRunId();const [searchParams] = useSearchParams();const { workflowPermanentId } = useParams();- const setCopilotCollapsed = useStudioShellStore((s) => s.setCopilotCollapsed);+ const { openPane } = useStudioPanes();// isPending (not isLoading) stays true while the query is disabled waiting for// globalWorkflows, so the empty state can't flash before the run lookup settles.const { data: runs, isPending: runsPending } = useWorkflowRunsQuery({@@ -39,13 +32,12 @@ export function RunTab() {workflowRunId={runId}runIdPending={!urlRunId && runsPending}onFix={(seedMessage) => {- // Seed via location.state (Workspace reads it as the copilot's initialMessage);- // replace so Fix adds no Back-able entry and the message can't re-fire on Back.- navigate(`${location.pathname}${location.search}`, {+ // One replace-navigation opens the Copilot pane and seeds the message via+ // location.state (Workspace reads it as the copilot's initialMessage), so+ // the pane write can't race a separate state-only navigation.+ openPane("copilot", {state: { copilotMessage: seedMessage, copilotFixOrigin: true },- replace: true,});- setCopilotCollapsed(false);}}onRetry={isBlockRundiff --git a/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.test.tsxindex 9d8ba0360..d26afb05f 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.test.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.test.tsx@@ -1,19 +1,13 @@// @vitest-environment jsdom-import {- act,- fireEvent,- render,- screen,- waitFor,-} from "@testing-library/react";+import { fireEvent, render, screen, waitFor } from "@testing-library/react";import { MemoryRouter, Route, Routes } from "react-router-dom";import { beforeEach, describe, expect, it, vi } from "vitest";-import { useStudioShellStore } from "@/store/StudioShellStore";import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";import { StudioBrowserStream } from "./StudioBrowserStream";+import { useStudioPanes } from "./useStudioPanes";const runtimeConfigMock = vi.hoisted(() => ({browserStreamingMode: "vnc",@@ -78,29 +72,47 @@ vi.mock("@/routes/browserSessions/BrowserSessionStream", () => ({const initialBrowserState = useStudioBrowserStore.getState();-function renderStudioBrowserStream() {+// Drives a real pane-state URL write, so the effect chain under test is the+// same one a spine click goes through.+function OpenBrowserPaneButton() {+ const { openPane } = useStudioPanes();+ return (+ <button type="button" onClick={() => openPane("browser")}>+ open browser pane+ </button>+ );+}++// The browser pane's visibility comes from ?panes= in the URL.+function renderStudioBrowserStream(initialPath: string) {return render(- <MemoryRouter initialEntries={["/workflows/wpid_test/studio"]}>+ <MemoryRouter initialEntries={[initialPath]}><Routes><Routepath="/workflows/:workflowPermanentId/studio"- element={<StudioBrowserStream />}+ element={+ <>+ <StudioBrowserStream />+ <OpenBrowserPaneButton />+ </>+ }/></Routes></MemoryRouter>,);}+const BROWSER_CLOSED_PATH = "/workflows/wpid_test/studio?panes=editor";+const BROWSER_OPEN_PATH = "/workflows/wpid_test/studio?panes=editor,browser";+beforeEach(() => {runtimeConfigMock.browserStreamingMode = "vnc";useStudioBrowserStore.setState(initialBrowserState, true);- useStudioShellStore.getState().reset();});describe("StudioBrowserStream browser activity notifications", () => {- it("marks activity while the user is away from the Browser tab", () => {- useStudioShellStore.getState().setTab("editor");- renderStudioBrowserStream();+ it("marks activity while the Browser pane is closed", () => {+ renderStudioBrowserStream(BROWSER_CLOSED_PATH);fireEvent.click(screen.getByRole("button", { name: "emit vnc frame" }));@@ -108,58 +120,66 @@ describe("StudioBrowserStream browser activity notifications", () => {});it("marks VNC activity after the initial stream connection", () => {- useStudioShellStore.getState().setTab("editor");- renderStudioBrowserStream();+ renderStudioBrowserStream(BROWSER_CLOSED_PATH);fireEvent.click(screen.getByRole("button", { name: "emit vnc ready" }));- act(() => {- useStudioBrowserStore.getState().clearActivity();- });+ useStudioBrowserStore.getState().clearActivity();fireEvent.click(screen.getByRole("button", { name: "emit vnc frame" }));expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(true);});- it("clears activity when the Browser tab is active", async () => {- useStudioShellStore.getState().setTab("editor");- renderStudioBrowserStream();+ it("clears activity when the Browser pane opens", async () => {+ renderStudioBrowserStream(BROWSER_CLOSED_PATH);fireEvent.click(screen.getByRole("button", { name: "emit vnc frame" }));expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(true);- act(() => {- useStudioShellStore.getState().setTab("browser");- });+ fireEvent.click(screen.getByRole("button", { name: "open browser pane" }));await waitFor(() => {expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(false);});});- it("keeps browser activity cleared while the Browser tab is visible", () => {- useStudioShellStore.getState().setTab("browser");- renderStudioBrowserStream();+ it("keeps browser activity cleared while the Browser pane is open", () => {+ renderStudioBrowserStream(BROWSER_OPEN_PATH);fireEvent.click(screen.getByRole("button", { name: "emit vnc frame" }));expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(false);});- it("marks CDP activity while the user is away from the Browser tab", () => {+ it("shows the stream control buttons only while the Browser pane is open", () => {+ const { unmount } = renderStudioBrowserStream(BROWSER_OPEN_PATH);+ expect(+ screen+ .getByRole("button", { name: "emit vnc frame" })+ .parentElement?.getAttribute("data-show-control-buttons"),+ ).toBe("yes");+ unmount();++ renderStudioBrowserStream(BROWSER_CLOSED_PATH);+ expect(+ screen+ .getByRole("button", { name: "emit vnc frame" })+ .parentElement?.getAttribute("data-show-control-buttons"),+ ).toBe("no");+ });++ it("marks CDP activity while the Browser pane is closed", () => {runtimeConfigMock.browserStreamingMode = "cdp";- useStudioShellStore.getState().setTab("editor");- renderStudioBrowserStream();+ renderStudioBrowserStream(BROWSER_CLOSED_PATH);fireEvent.click(screen.getByRole("button", { name: "emit cdp activity" }));expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(true);});- it("keeps CDP activity cleared while the Browser tab is visible", () => {+ it("keeps CDP activity cleared while the Browser pane is open", () => {runtimeConfigMock.browserStreamingMode = "cdp";- useStudioShellStore.getState().setTab("browser");- renderStudioBrowserStream();+ renderStudioBrowserStream(BROWSER_OPEN_PATH);fireEvent.click(screen.getByRole("button", { name: "emit cdp activity" }));@@ -168,7 +188,7 @@ describe("StudioBrowserStream browser activity notifications", () => {it("keeps the latest stream URL separate from unseen activity", () => {runtimeConfigMock.browserStreamingMode = "cdp";- renderStudioBrowserStream();+ renderStudioBrowserStream(BROWSER_OPEN_PATH);fireEvent.click(screen.getByRole("button", { name: "emit url" }));diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.tsxindex 19ce7b955..1f0188e7e 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioBrowserStream.tsx@@ -3,18 +3,19 @@ import { useParams } from "react-router-dom";import { useRecordingStore } from "@/store/useRecordingStore";import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";-import { useStudioShellStore } from "@/store/StudioShellStore";import { useDebugSessionQuery } from "../hooks/useDebugSessionQuery";import { StreamPresenter } from "./StreamPresenter";+import { useStudioPanes } from "./useStudioPanes";/*** The studio's single live-browser stream, portaled into a host node re-parented- * between the PiP and Browser tab so the socket persists instead of re-booting.+ * between the open panes so the socket persists instead of re-booting.*/export function StudioBrowserStream() {const { workflowPermanentId } = useParams();- const tab = useStudioShellStore((s) => s.tab);+ const { panes } = useStudioPanes();+ const browserPaneOpen = panes.includes("browser");const isRecording = useRecordingStore((s) => s.isRecording);const reloadNonce = useStudioBrowserStore((s) => s.reloadNonce);const setStreamUrl = useStudioBrowserStore((s) => s.setStreamUrl);@@ -33,10 +34,10 @@ export function StudioBrowserStream() {}, [browserSessionId, reset]);useEffect(() => {- if (tab === "browser") {+ if (browserPaneOpen) {clearActivity();}- }, [clearActivity, tab]);+ }, [clearActivity, browserPaneOpen]);const handleUrlChange = useCallback((url: string) => {@@ -46,12 +47,12 @@ export function StudioBrowserStream() {);const handleActivity = useCallback(() => {- if (tab === "browser") {+ if (browserPaneOpen) {clearActivity();return;}markActivity();- }, [clearActivity, markActivity, tab]);+ }, [clearActivity, markActivity, browserPaneOpen]);if (!browserSessionId) {return null;@@ -62,7 +63,7 @@ export function StudioBrowserStream() {key={`${browserSessionId}:${reloadNonce}`}browserSessionId={browserSessionId}interactive={false}- showControlButtons={tab === "browser"}+ showControlButtons={browserPaneOpen}isRecording={isRecording}onUrlChange={handleUrlChange}onActivity={handleActivity}diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsxindex 4d02bd29a..4a239f399 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioShell.tsx@@ -1,45 +1,98 @@-import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { useLayoutEffect, useMemo, useState, type ReactNode } from "react";import { createPortal } from "react-dom";-import { useSearchParams } from "react-router-dom";+import { Cross2Icon } from "@radix-ui/react-icons";import { useStudioShellStore } from "@/store/StudioShellStore";import { cn } from "@/util/utils";import { BrowserTab } from "./BrowserTab";-import { CopilotRail } from "./CopilotRail";import { EditorTab, type StudioWorkspaceProps } from "./EditorTab";import { RunTab } from "./RunTab";import { StudioBrowserStream } from "./StudioBrowserStream";-import {- STUDIO_COPILOT_COLLAPSE_EASE,- STUDIO_COPILOT_RAIL_WIDTH,- STUDIO_COPILOT_TRANSITION_EASE,- STUDIO_COPILOT_TRANSITION_MS,- STUDIO_COPILOT_WIDTH,- initialStudioTab,- studioPanelId,- studioTabId,-} from "./constants";+import { studioPanelId, studioTabId } from "./constants";+import { STUDIO_PANE_META } from "./paneMeta";+import { type StudioPaneId } from "./panes";import { StudioShellContext } from "./StudioShellContext";+import { StudioSpine } from "./StudioSpine";import { StudioTopBar } from "./StudioTopBar";import { StudioWorkflowPanels } from "./StudioWorkflowPanels";+import { useStudioPanes } from "./useStudioPanes";++// Width floors from the approved mock; the Copilot pane also holds a ceiling so+// a lone chat doesn't stretch across the whole stage.+const PANE_MIN_WIDTH: Record<StudioPaneId, number> = {+ copilot: 260,+ editor: 220,+ browser: 260,+ run: 220,+};+const COPILOT_MAX_WIDTH = 440;++function StudioPane({+ id,+ open,+ order,+ onClose,+ children,+}: {+ id: StudioPaneId;+ open: boolean;+ order: number | undefined;+ onClose: () => void;+ children: ReactNode;+}) {+ const { label, icon: Icon } = STUDIO_PANE_META[id];+ return (+ <section+ id={studioPanelId(id)}+ role="region"+ aria-label={label}+ style={{+ order,+ minWidth: PANE_MIN_WIDTH[id],+ maxWidth: id === "copilot" ? COPILOT_MAX_WIDTH : undefined,+ }}+ className={cn(+ "min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1",+ open+ ? "flex duration-200 motion-safe:animate-in motion-safe:fade-in"+ : "hidden",+ )}+ >+ <div className="flex h-9 shrink-0 items-center gap-2 border-b border-border px-3">+ <Icon className="size-3.5 shrink-0 text-studio-accent" aria-hidden />+ <span className="min-w-0 flex-1 truncate text-xs font-medium text-foreground">+ {label}+ </span>+ <button+ type="button"+ onClick={onClose}+ title={`Close ${label}`}+ aria-label={`Close ${label} pane`}+ className="rounded p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ >+ <Cross2Icon className="size-3.5" />+ </button>+ </div>+ <div className="min-h-0 min-w-0 flex-1">{children}</div>+ </section>+ );+}/**- * Spine + Stage shell: a persistent Copilot column beside a Stage that swaps the- * Editor and Run tabs. The Copilot is portaled in from the embedded Workspace.+ * Spine + panes shell: one vertical spine whose tabs (Copilot, Editor, Browser,+ * Run) each toggle a pane; open panes share the stage side by side in click+ * order (?panes=). The Copilot chat is portaled into its pane from Workspace.*/export function StudioShell(props: StudioWorkspaceProps) {- const tab = useStudioShellStore((s) => s.tab);- const setTab = useStudioShellStore((s) => s.setTab);- const copilotCollapsed = useStudioShellStore((s) => s.copilotCollapsed);- const setCopilotCollapsed = useStudioShellStore((s) => s.setCopilotCollapsed);+ const { panes, closePane } = useStudioPanes();const pipMinimized = useStudioShellStore((s) => s.pipMinimized);const [copilotPortalEl, setCopilotPortalEl] = useState<HTMLElement | null>(null,);// The live browser stream is mounted once into this detached host and- // re-parented into the active surface, so it never remounts on tab switch.+ // re-parented into the owning pane, so it never remounts on pane changes.const [streamHostEl] = useState(() => {const el = document.createElement("div");el.className = "h-full w-full";@@ -55,19 +108,21 @@ export function StudioShell(props: StudioWorkspaceProps) {null,);- // 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.+ const browserOpen = panes.includes("browser");+ const editorOpen = panes.includes("editor");+ const runOpen = panes.includes("run");++ // Move the persistent stream node into the highest-priority open surface:+ // Browser pane > Run pane with a live block run (runStreamSlot registers only+ // then) > Editor PiP > offscreen park, which keeps the socket warm.useLayoutEffect(() => {- const activeSlot =- tab === "browser"- ? browserStreamSlot- : tab === "editor" && !pipMinimized+ const activeSlot = browserOpen+ ? browserStreamSlot+ : runOpen && runStreamSlot+ ? runStreamSlot+ : editorOpen && !pipMinimized? editorStreamSlot- : tab === "run"- ? runStreamSlot- : null;+ : null;const dest = activeSlot ?? streamHolderEl;if (dest && streamHostEl.parentElement !== dest) {// BrowserStream re-asserts scaleViewport on its own resize, so it rescales@@ -75,7 +130,9 @@ export function StudioShell(props: StudioWorkspaceProps) {dest.appendChild(streamHostEl);}}, [- tab,+ browserOpen,+ editorOpen,+ runOpen,pipMinimized,editorStreamSlot,browserStreamSlot,@@ -94,98 +151,55 @@ export function StudioShell(props: StudioWorkspaceProps) {[copilotPortalEl],);- // Pick the initial tab from the deep link ONCE per mount; must not re-fire on- // later URL writes (the Run tab writes ?wr=/?active=) or it fights manual switches.- const [searchParams] = useSearchParams();- const deepLinkRunId = searchParams.get("wr");- const deepLinkActive = searchParams.get("active");- const initialTabAppliedRef = useRef(false);- useEffect(() => {- if (initialTabAppliedRef.current) {- return;- }- initialTabAppliedRef.current = true;- setTab(initialStudioTab({ runId: deepLinkRunId, active: deepLinkActive }));- }, [deepLinkRunId, deepLinkActive, setTab]);+ // The ✕ unmounts with its pane, so hand focus back to the pane's spine tab.+ const closeWithFocus = (id: StudioPaneId) => {+ closePane(id);+ document.getElementById(studioTabId(id))?.focus();+ };- const copilotWidth = copilotCollapsed- ? STUDIO_COPILOT_RAIL_WIDTH- : STUDIO_COPILOT_WIDTH;+ const paneProps = (id: StudioPaneId) => {+ const index = panes.indexOf(id);+ return {+ id,+ open: index >= 0,+ order: index >= 0 ? index : undefined,+ onClose: () => closeWithFocus(id),+ };+ };return (<StudioShellContext.Provider value={shellContextValue}><div className="flex h-full w-full flex-col"><StudioTopBar />- <div- className="grid min-h-0 flex-1"- style={{- gridTemplateColumns: `${copilotWidth}px minmax(0, 1fr)`,- gridTemplateRows: "minmax(0, 1fr)",- transition: `grid-template-columns ${STUDIO_COPILOT_TRANSITION_MS}ms ${- copilotCollapsed- ? STUDIO_COPILOT_COLLAPSE_EASE- : STUDIO_COPILOT_TRANSITION_EASE- }`,- }}- >- {/* Copilot portal target. Kept mounted (parked offscreen) when- collapsed so an in-flight Copilot stream isn't torn down. */}- <div className="relative h-full min-w-0 overflow-hidden">- {/* Fixed width so the chat doesn't reflow; the widening column clip- reveals it left→right, so no opacity fade is needed. */}- <div- ref={setCopilotPortalEl}- style={{ width: STUDIO_COPILOT_WIDTH }}- className={cn(- "h-full py-3 pl-3",- copilotCollapsed && "pointer-events-none",- )}- />- {/* Rail renders only while collapsed and unmounts immediately on- expand, so the collapsed UI can't linger over the content the- widening column is revealing (the open-flicker). */}- {copilotCollapsed ? (- <div- style={{ width: STUDIO_COPILOT_RAIL_WIDTH }}- className="absolute left-0 top-0 h-full py-3 pl-3 duration-300 animate-in fade-in"- >- <CopilotRail onExpand={() => setCopilotCollapsed(false)} />- </div>- ) : null}- </div>- <div className="relative h-full min-h-0 min-w-0 overflow-hidden">- <div- role="tabpanel"- id={studioPanelId("editor")}- aria-labelledby={studioTabId("editor")}- className={- tab === "editor" ? "h-full w-full" : "hidden h-full w-full"- }- >+ <div className="flex min-h-0 min-w-0 flex-1">+ <StudioSpine />+ {/* Panes keep a fixed DOM order (stable mounts for the canvas, chat and+ stream slots); the CSS order carries the click order instead, so+ screen-reader/Tab order stays the fixed order, not the visual one. */}+ <div className="relative flex min-h-0 min-w-0 flex-1 gap-3 overflow-hidden p-3">+ <StudioPane {...paneProps("copilot")}>+ {/* Copilot portal target. Kept mounted while the pane is closed so+ an in-flight Copilot turn isn't torn down. */}+ <div ref={setCopilotPortalEl} className="h-full w-full" />+ </StudioPane>+ <StudioPane {...paneProps("editor")}><EditorTab {...props} />- </div>+ </StudioPane>{/* Kept mounted (CSS-hidden) so its stream slot stays registered;the persistent stream node is re-parented in, not remounted. */}- <div- role="tabpanel"- id={studioPanelId("browser")}- aria-labelledby={studioTabId("browser")}- className={- tab === "browser" ? "h-full w-full" : "hidden h-full w-full"- }- >+ <StudioPane {...paneProps("browser")}><BrowserTab />- </div>- <div- role="tabpanel"- id={studioPanelId("run")}- aria-labelledby={studioTabId("run")}- className={- tab === "run" ? "h-full w-full" : "hidden h-full w-full"- }- >+ </StudioPane>+ <StudioPane {...paneProps("run")}><RunTab />- </div>+ </StudioPane>+ {panes.length === 0 ? (+ <div className="flex flex-1 items-center justify-center">+ <p className="max-w-[17rem] text-center text-sm text-muted-foreground">+ No panes open. Open one from the rail on the left.+ </p>+ </div>+ ) : null}<StudioWorkflowPanels /></div></div>diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioSpine.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioSpine.test.tsxnew file mode 100644index 000000000..770b3acf2--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/StudioSpine.test.tsx@@ -0,0 +1,231 @@+// @vitest-environment jsdom++import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { MemoryRouter, useLocation } from "react-router-dom";+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";++import { Status } from "@/api/types";+import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";++import { StudioSpine } from "./StudioSpine";++const { runsQueryMock, runWithWorkflowMock } = vi.hoisted(() => ({+ runsQueryMock: vi.fn(),+ runWithWorkflowMock: vi.fn(),+}));++vi.mock("../hooks/useWorkflowRunsQuery", () => ({+ useWorkflowRunsQuery: () => runsQueryMock(),+}));++vi.mock("../hooks/useWorkflowRunWithWorkflowQuery", () => ({+ useWorkflowRunWithWorkflowQuery: () => runWithWorkflowMock(),+}));++const initialBrowserState = useStudioBrowserStore.getState();++function LocationProbe() {+ const location = useLocation();+ return <output data-testid="search">{location.search}</output>;+}++function renderAt(path = "/workflows/wpid_abc/studio") {+ return render(+ <MemoryRouter initialEntries={[path]}>+ <StudioSpine />+ <LocationProbe />+ </MemoryRouter>,+ );+}++function tab(name: RegExp | string): HTMLButtonElement {+ return screen.getByRole("button", { name }) as HTMLButtonElement;+}++function currentPanes(): string | null {+ const search = screen.getByTestId("search").textContent ?? "";+ return new URLSearchParams(search).get("panes");+}++afterEach(cleanup);+beforeEach(() => {+ useStudioBrowserStore.setState(initialBrowserState, true);+ runsQueryMock.mockReturnValue({ data: [] });+ runWithWorkflowMock.mockReturnValue({ data: undefined });+});++describe("StudioSpine structure", () => {+ test("renders the four peer tabs with icon + label", () => {+ renderAt();+ for (const label of ["Copilot", "Editor", "Browser", "Run"]) {+ expect(tab(new RegExp(`^${label}`))).toBeTruthy();+ }+ });++ test("reflects the default panes (copilot + browser) as expanded", () => {+ renderAt();+ expect(tab(/^Copilot/).getAttribute("aria-expanded")).toBe("true");+ expect(tab(/^Browser/).getAttribute("aria-expanded")).toBe("true");+ expect(tab(/^Editor/).getAttribute("aria-expanded")).toBe("false");+ });++ test("reflects an explicit ?panes= list", () => {+ renderAt("/workflows/wpid_abc/studio?panes=editor");+ expect(tab(/^Editor/).getAttribute("aria-expanded")).toBe("true");+ expect(tab(/^Copilot/).getAttribute("aria-expanded")).toBe("false");+ expect(tab(/^Browser/).getAttribute("aria-expanded")).toBe("false");+ });++ test("explicit ?panes= wins over a run deep link", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.Completed }] });+ renderAt("/workflows/wpid_abc/studio?wr=run_1&panes=copilot");+ expect(tab(/^Copilot/).getAttribute("aria-expanded")).toBe("true");+ expect(tab(/^Run/).getAttribute("aria-expanded")).toBe("false");+ });++ test("a block-run deep link opens Run and Browser together", () => {+ renderAt("/workflows/wpid_abc/studio?wr=run_1&bl=block_1");+ expect(tab(/^Run/).getAttribute("aria-expanded")).toBe("true");+ expect(tab(/^Browser/).getAttribute("aria-expanded")).toBe("true");+ expect(tab(/^Copilot/).getAttribute("aria-expanded")).toBe("false");+ });+});++describe("StudioSpine pane toggling", () => {+ test("opening a closed pane appends it in click order", () => {+ renderAt();+ fireEvent.click(tab(/^Editor/));+ expect(currentPanes()).toBe("copilot,browser,editor");+ expect(tab(/^Editor/).getAttribute("aria-expanded")).toBe("true");+ });++ test("closing an open pane splices it out, keeping the rest in order", () => {+ renderAt("/workflows/wpid_abc/studio?panes=editor,copilot,browser");+ fireEvent.click(tab(/^Copilot/));+ expect(currentPanes()).toBe("editor,browser");+ });++ test("closing the last pane leaves an explicit empty list", () => {+ renderAt("/workflows/wpid_abc/studio?panes=editor");+ fireEvent.click(tab(/^Editor/));+ expect(currentPanes()).toBe("");+ });++ test("toggling preserves unrelated params", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.Completed }] });+ renderAt("/workflows/wpid_abc/studio?wr=run_1&bl=block_1");+ fireEvent.click(tab(/^Copilot/));+ const search = screen.getByTestId("search").textContent ?? "";+ const params = new URLSearchParams(search);+ expect(params.get("wr")).toBe("run_1");+ expect(params.get("bl")).toBe("block_1");+ expect(params.get("panes")).toBe("run,browser,copilot");+ });+});++describe("StudioSpine Run gating", () => {+ test("disables the Run tab until a run exists", () => {+ renderAt();+ expect(tab(/^Run/).disabled).toBe(true);+ });++ test("enables the Run tab when the workflow has a prior run", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.Running }] });+ renderAt();+ expect(tab(/^Run/).disabled).toBe(false);+ });++ test("enables the Run tab when the URL points at a run (?wr=)", () => {+ renderAt("/workflows/wpid_abc/studio?wr=run_1&panes=copilot");+ expect(tab(/^Run/).disabled).toBe(false);+ });+});++describe("StudioSpine run-status dot", () => {+ test("shows a status-colored dot for a finalized run", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.Completed }] });+ renderAt();+ const dot = tab(/^Run/).querySelector(+ "span.absolute.right-1",+ ) as HTMLElement | null;+ expect(dot).not.toBeNull();+ expect(dot?.className).toContain("bg-badge-success");+ });++ test("includes the finalized run status in the Run tab accessible name", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.TimedOut }] });+ renderAt();+ expect(screen.getByRole("button", { name: "Run, timed out" })).toBeTruthy();+ });++ test("omits the dot while the run is still in flight", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.Running }] });+ renderAt();+ expect(tab(/^Run/).querySelector("span.absolute.right-1")).toBeNull();+ });+});++describe("StudioSpine browser activity", () => {+ test("exposes unseen activity on the Browser tab while its pane is closed", () => {+ useStudioBrowserStore.getState().markActivity();+ renderAt("/workflows/wpid_abc/studio?panes=copilot");+ expect(+ screen.getByRole("button", { name: "Browser, new activity" }),+ ).toBeTruthy();+ });++ test("hides the activity dot while the Browser pane is open", () => {+ useStudioBrowserStore.getState().markActivity();+ renderAt("/workflows/wpid_abc/studio?panes=browser");+ expect(+ screen.queryByRole("button", { name: "Browser, new activity" }),+ ).toBeNull();+ });++ test("clears unseen activity when the Browser pane is opened", () => {+ useStudioBrowserStore.getState().markActivity();+ renderAt("/workflows/wpid_abc/studio?panes=copilot");+ fireEvent.click(tab(/Browser/));+ expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(false);+ expect(currentPanes()).toBe("copilot,browser");+ });+});++describe("StudioSpine keyboard navigation", () => {+ test("the rail is a single tab stop (roving tabindex)", () => {+ renderAt();+ expect(+ ["Copilot", "Editor", "Browser"].map(+ (l) => tab(new RegExp(`^${l}`)).tabIndex,+ ),+ ).toEqual([0, -1, -1]);+ });++ test("ArrowDown moves focus and wraps past the disabled Run tab", () => {+ renderAt();+ tab(/^Copilot/).focus();+ fireEvent.keyDown(tab(/^Copilot/), { key: "ArrowDown" });+ expect(document.activeElement).toBe(tab(/^Editor/));+ fireEvent.keyDown(tab(/^Editor/), { key: "ArrowDown" });+ expect(document.activeElement).toBe(tab(/^Browser/));+ fireEvent.keyDown(tab(/^Browser/), { key: "ArrowDown" });+ expect(document.activeElement).toBe(tab(/^Copilot/));+ });++ test("ArrowUp wraps to the last enabled tab and Home returns to the first", () => {+ runsQueryMock.mockReturnValue({ data: [{ status: Status.Completed }] });+ renderAt();+ tab(/^Copilot/).focus();+ fireEvent.keyDown(tab(/^Copilot/), { key: "ArrowUp" });+ expect(document.activeElement).toBe(tab(/^Run/));+ fireEvent.keyDown(tab(/^Run/), { key: "Home" });+ expect(document.activeElement).toBe(tab(/^Copilot/));+ });++ test("arrow keys move focus without toggling panes", () => {+ renderAt();+ fireEvent.keyDown(tab(/^Copilot/), { key: "ArrowDown" });+ expect(currentPanes()).toBeNull();+ expect(tab(/^Editor/).getAttribute("aria-expanded")).toBe("false");+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioSpine.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioSpine.tsxnew file mode 100644index 000000000..ac3b101a5--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/StudioSpine.tsx@@ -0,0 +1,189 @@+import { useState, type KeyboardEvent } from "react";+import { useParams } from "react-router-dom";++import { Status } from "@/api/types";+import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";+import { cn } from "@/util/utils";++import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";+import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";+import { studioPanelId, studioTabId } from "./constants";+import { STUDIO_PANE_META } from "./paneMeta";+import { STUDIO_PANE_IDS, type StudioPaneId } from "./panes";+import { finalizedRunStatus } from "./runProjections";+import { useStudioPanes } from "./useStudioPanes";+import { useStudioRunId } from "./useStudioRunId";++// Terminal-only (finalizedRunStatus never returns a live status); mirrors the+// StatusBadge variant buckets so the dot reads the same as the run chip.+function runStatusDotClass(status: Status): string {+ switch (status) {+ case Status.Completed:+ return "bg-badge-success";+ case Status.Terminated:+ return "bg-badge-terminated";+ case Status.Failed:+ case Status.Canceled:+ case Status.TimedOut:+ return "bg-badge-destructive";+ default:+ // Fallback for terminal statuses added after this mapping.+ return "bg-badge-warning";+ }+}++function runStatusLabel(status: Status): string {+ return status === Status.TimedOut ? "timed out" : status;+}++/**+ * The studio's single vertical tab spine: Copilot, Editor, Browser and Run are+ * peer tabs, each toggling its pane open or closed on the stage.+ */+export function StudioSpine() {+ const { panes, togglePane } = useStudioPanes();+ const hasUnseenBrowserActivity = useStudioBrowserStore(+ (s) => s.hasUnseenActivity,+ );+ const clearBrowserActivity = useStudioBrowserStore((s) => s.clearActivity);++ const urlRunId = useStudioRunId();+ const { workflowPermanentId } = useParams();+ const { data: urlRun } = useWorkflowRunWithWorkflowQuery(+ urlRunId ? { workflowRunId: urlRunId } : undefined,+ );+ const { data: runs } = useWorkflowRunsQuery({+ workflowPermanentId,+ page: 1,+ pageSize: 1,+ });+ const hasRun = Boolean(urlRunId) || (runs?.length ?? 0) > 0;+ const runStatus = finalizedRunStatus(+ urlRunId ? urlRun?.status : runs?.[0]?.status,+ );++ const onToggle = (id: StudioPaneId) => {+ if (id === "browser" && !panes.includes("browser")) {+ clearBrowserActivity();+ }+ togglePane(id);+ };++ // Roving tabindex (WAI-ARIA toolbar): the rail is one tab stop; arrow keys+ // move focus across the enabled tabs, Enter/Space toggles.+ const [focusedId, setFocusedId] = useState<StudioPaneId>(STUDIO_PANE_IDS[0]!);+ const enabledIds = STUDIO_PANE_IDS.filter((id) => !(id === "run" && !hasRun));+ const tabStopId = enabledIds.includes(focusedId) ? focusedId : enabledIds[0];+ const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {+ const keys = ["ArrowDown", "ArrowUp", "Home", "End"];+ if (!keys.includes(event.key) || enabledIds.length === 0) {+ return;+ }+ event.preventDefault();+ const current = Math.max(+ 0,+ enabledIds.indexOf(tabStopId ?? enabledIds[0]!),+ );+ const nextIndex =+ event.key === "ArrowDown"+ ? (current + 1) % enabledIds.length+ : event.key === "ArrowUp"+ ? (current - 1 + enabledIds.length) % enabledIds.length+ : event.key === "Home"+ ? 0+ : enabledIds.length - 1;+ const next = enabledIds[nextIndex]!;+ setFocusedId(next);+ document.getElementById(studioTabId(next))?.focus();+ };++ return (+ <nav+ aria-label="Studio panes"+ className="flex h-full w-16 shrink-0 flex-col items-center gap-1 border-r border-border bg-slate-elevation1 px-1.5 py-3"+ onKeyDown={onKeyDown}+ >+ {STUDIO_PANE_IDS.map((id) => {+ const { label, icon: Icon } = STUDIO_PANE_META[id];+ const open = panes.includes(id);+ const disabled = id === "run" && !hasRun;+ const showActivityDot =+ id === "browser" && hasUnseenBrowserActivity && !open;+ const showRunStatusDot = id === "run" && Boolean(runStatus);+ const ariaLabel = showActivityDot+ ? "Browser, new activity"+ : id === "run" && runStatus+ ? `Run, ${runStatusLabel(runStatus)}`+ : undefined;+ return (+ <button+ key={id}+ id={studioTabId(id)}+ type="button"+ aria-expanded={open}+ aria-controls={studioPanelId(id)}+ aria-label={ariaLabel}+ disabled={disabled}+ tabIndex={id === tabStopId ? 0 : -1}+ onFocus={() => setFocusedId(id)}+ title={+ disabled+ ? "Run: no runs yet"+ : runStatus && id === "run"+ ? `Run: ${runStatusLabel(runStatus)}`+ : `${open ? "Close" : "Open"} ${label}`+ }+ onClick={() => onToggle(id)}+ className={cn(+ "relative flex w-full flex-col items-center gap-1 rounded-md px-1 py-2 text-[10px] font-medium leading-none transition-colors",+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ open+ ? "bg-studio-accent/15 text-foreground"+ : "text-muted-foreground hover:bg-slate-elevation3 hover:text-foreground",+ disabled &&+ "cursor-default opacity-50 hover:bg-transparent hover:text-muted-foreground",+ )}+ >+ {open ? (+ <span+ aria-hidden+ className="absolute -left-1.5 bottom-2 top-2 w-[3px] rounded-r-full bg-studio-accent"+ />+ ) : null}+ <Icon+ className={cn("size-5", open && "text-studio-accent")}+ aria-hidden+ />+ {label}+ {showActivityDot ? (+ <span+ aria-hidden+ title="New browser activity"+ className="absolute right-1 top-1 flex size-2"+ >+ <span className="absolute inline-flex h-full w-full rounded-full bg-studio-accent opacity-75 motion-safe:animate-ping" />+ <span className="relative inline-flex size-2 rounded-full bg-studio-accent shadow-[0_0_0_3px_rgba(109,108,246,0.20)]" />+ </span>+ ) : showRunStatusDot && runStatus ? (+ <span+ aria-hidden+ className={cn(+ "absolute right-1 top-1 size-2 rounded-full",+ runStatusDotClass(runStatus),+ )}+ />+ ) : null}+ </button>+ );+ })}+ <span+ role="status"+ aria-live="polite"+ aria-atomic="true"+ className="sr-only"+ >+ {hasUnseenBrowserActivity ? "New browser activity" : ""}+ </span>+ </nav>+ );+}diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsxdeleted file mode 100644index 8a1e3857e..000000000--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.test.tsx+++ /dev/null@@ -1,114 +0,0 @@-// @vitest-environment jsdom--import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { fireEvent, render, screen } from "@testing-library/react";-import { MemoryRouter, Route, Routes } from "react-router-dom";-import { beforeEach, describe, expect, it, vi } from "vitest";--import { useStudioShellStore } from "@/store/StudioShellStore";-import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";--import { StudioTopBar } from "./StudioTopBar";--vi.mock("../editor/nodes/components/EditableNodeTitle", () => ({- EditableNodeTitle: ({ value }: { value: string }) => <div>{value}</div>,-}));--vi.mock("../editor/header/EditorOverflowMenu", () => ({- EditorOverflowMenu: () => <button type="button">More</button>,-}));--vi.mock("../editor/MakeACopyButton", () => ({- MakeACopyButton: () => <button type="button">Make a copy</button>,-}));--vi.mock("../editor/hooks/useSaveWorkflow", () => ({- useSaveWorkflow: () => vi.fn(),-}));--vi.mock("../hooks/useGlobalWorkflowsQuery", () => ({- useGlobalWorkflowsQuery: () => ({ data: [] }),-}));--vi.mock("../hooks/useWorkflowRunWithWorkflowQuery", () => ({- useWorkflowRunWithWorkflowQuery: () => ({ data: undefined }),-}));--vi.mock("../hooks/useWorkflowRunsQuery", () => ({- useWorkflowRunsQuery: () => ({ data: [] }),-}));--vi.mock("./useStudioRunId", () => ({- useStudioRunId: () => null,-}));--const initialBrowserState = useStudioBrowserStore.getState();--function renderStudioTopBar() {- const queryClient = new QueryClient({- defaultOptions: {- queries: {- retry: false,- },- },- });-- return render(- <QueryClientProvider client={queryClient}>- <MemoryRouter initialEntries={["/workflows/wpid_test/studio"]}>- <Routes>- <Route- path="/workflows/:workflowPermanentId/studio"- element={<StudioTopBar />}- />- </Routes>- </MemoryRouter>- </QueryClientProvider>,- );-}--beforeEach(() => {- useStudioBrowserStore.setState(initialBrowserState, true);- useStudioShellStore.getState().reset();-});--describe("StudioTopBar browser activity indicator", () => {- it("exposes unseen browser activity on the Browser tab and clears it when selected", () => {- useStudioShellStore.getState().setTab("editor");- useStudioBrowserStore.getState().markActivity();-- renderStudioTopBar();-- const browserTab = screen.getByRole("tab", {- name: "Browser, new activity",- });- expect(browserTab.getAttribute("aria-selected")).toBe("false");-- fireEvent.click(browserTab);-- expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(false);- expect(- screen- .getByRole("tab", { name: "Browser" })- .getAttribute("aria-selected"),- ).toBe("true");- });-- it("clears unseen browser activity on keyboard navigation to the Browser tab", () => {- useStudioShellStore.getState().setTab("editor");- useStudioBrowserStore.getState().markActivity();-- renderStudioTopBar();-- fireEvent.keyDown(screen.getByRole("tablist", { name: "Studio view" }), {- key: "ArrowRight",- });-- expect(useStudioBrowserStore.getState().hasUnseenActivity).toBe(false);- expect(- screen- .getByRole("tab", { name: "Browser" })- .getAttribute("aria-selected"),- ).toBe("true");- });-});diff --git a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsxindex 8e1a759d9..d508c23a8 100644--- a/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/StudioTopBar.tsx@@ -1,4 +1,4 @@-import { type KeyboardEvent, type ReactNode } from "react";+import { type ReactNode } from "react";import { AxiosError } from "axios";import {CalendarIcon,@@ -11,7 +11,6 @@ import { useNavigate, useParams } from "react-router-dom";import { getClient } from "@/api/AxiosClient";import { SaveIcon } from "@/components/icons/SaveIcon";-import { StatusBadge } from "@/components/StatusBadge";import { Button } from "@/components/ui/button";import {Dialog,@@ -26,8 +25,6 @@ import {import { toast } from "@/components/ui/use-toast";import { useCredentialGetter } from "@/hooks/useCredentialGetter";import { useRecordingStore } from "@/store/useRecordingStore";-import { useStudioShellStore, type StudioTab } from "@/store/StudioShellStore";-import { useStudioBrowserStore } from "@/store/useStudioBrowserStore";import { useWorkflowHasChangesStore } from "@/store/WorkflowHasChangesStore";import { useWorkflowPanelStore } from "@/store/WorkflowPanelStore";import { useWorkflowTitleStore } from "@/store/WorkflowTitleStore";@@ -39,9 +36,7 @@ import { MakeACopyButton } from "../editor/MakeACopyButton";import { useSaveWorkflow } from "../editor/hooks/useSaveWorkflow";import { useGlobalWorkflowsQuery } from "../hooks/useGlobalWorkflowsQuery";import { useWorkflowRunWithWorkflowQuery } from "../hooks/useWorkflowRunWithWorkflowQuery";-import { useWorkflowRunsQuery } from "../hooks/useWorkflowRunsQuery";-import { studioPanelId, studioTabId } from "./constants";-import { finalizedRunStatus, runOutcomeFromStatus } from "./runProjections";+import { runOutcomeFromStatus } from "./runProjections";import { useStudioRunId } from "./useStudioRunId";function useIsGlobalWorkflow(): boolean {@@ -54,133 +49,6 @@ function useIsGlobalWorkflow(): boolean {);}-function StudioTabs() {- const tab = useStudioShellStore((s) => s.tab);- const setTab = useStudioShellStore((s) => s.setTab);- const hasUnseenBrowserActivity = useStudioBrowserStore(- (s) => s.hasUnseenActivity,- );- const clearBrowserActivity = useStudioBrowserStore((s) => s.clearActivity);- const urlRunId = useStudioRunId();- const { workflowPermanentId } = useParams();- const { data: urlRun } = useWorkflowRunWithWorkflowQuery(- urlRunId ? { workflowRunId: urlRunId } : undefined,- );- const { data: runs } = useWorkflowRunsQuery({- workflowPermanentId,- page: 1,- pageSize: 1,- });- const latestRun = runs?.[0];- const hasRun = Boolean(urlRunId) || (runs?.length ?? 0) > 0;- const runStatus = finalizedRunStatus(- urlRunId ? urlRun?.status : latestRun?.status,- );-- const tabs: Array<{ id: StudioTab; label: string; disabled: boolean }> = [- { id: "editor", label: "Editor", disabled: false },- { id: "browser", label: "Browser", disabled: false },- { id: "run", label: "Run", disabled: !hasRun },- ];-- const selectTab = (nextTab: StudioTab) => {- if (nextTab === "browser") {- clearBrowserActivity();- }- setTab(nextTab);- };-- // Roving arrow-key navigation across the enabled tabs (WAI-ARIA tabs).- const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {- const keys = ["ArrowRight", "ArrowLeft", "Home", "End"];- if (!keys.includes(event.key)) {- return;- }- event.preventDefault();- const enabled = tabs.filter((t) => !t.disabled);- const current = enabled.findIndex((t) => t.id === tab);- const last = enabled.length - 1;- const nextIndex =- event.key === "ArrowRight"- ? (current + 1) % enabled.length- : event.key === "ArrowLeft"- ? (current - 1 + enabled.length) % enabled.length- : event.key === "Home"- ? 0- : last;- const next = enabled[nextIndex];- if (next) {- selectTab(next.id);- document.getElementById(studioTabId(next.id))?.focus();- }- };-- return (- <>- <div- role="tablist"- aria-label="Studio view"- className="flex items-center gap-1"- onKeyDown={onKeyDown}- >- {tabs.map((t) => {- const selected = tab === t.id;- const browserActivityLabel =- t.id === "browser" && hasUnseenBrowserActivity- ? "Browser, new activity"- : undefined;- return (- <button- key={t.id}- id={studioTabId(t.id)}- type="button"- role="tab"- aria-selected={selected}- aria-controls={studioPanelId(t.id)}- aria-label={browserActivityLabel}- tabIndex={selected ? 0 : -1}- disabled={t.disabled}- onClick={() => !t.disabled && selectTab(t.id)}- className={cn(- "flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",- "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",- selected- ? "bg-studio-accent/15 text-foreground ring-1 ring-inset ring-studio-accent/40"- : "text-muted-foreground hover:bg-slate-elevation3 hover:text-foreground",- t.disabled &&- "cursor-default opacity-50 hover:bg-transparent hover:text-muted-foreground",- )}- >- {t.label}- {t.id === "browser" && hasUnseenBrowserActivity ? (- <span- aria-hidden="true"- title="New browser activity"- className="relative flex size-2 shrink-0"- >- <span className="absolute inline-flex h-full w-full rounded-full bg-studio-accent opacity-75 motion-safe:animate-ping" />- <span className="relative inline-flex size-2 rounded-full bg-studio-accent shadow-[0_0_0_3px_rgba(109,108,246,0.20)]" />- </span>- ) : null}- {t.id === "run" && runStatus ? (- <StatusBadge- status={runStatus}- alwaysShowLabel- // overrides StatusBadge's md:px-2.5 to keep the chip compact in the tab bar- className="h-5 gap-1 px-1.5 py-0 text-[10px] md:w-auto md:px-1.5"- />- ) : null}- </button>- );- })}- </div>- <span role="status" aria-live="polite" className="sr-only">- {hasUnseenBrowserActivity ? "New browser activity" : ""}- </span>- </>- );-}-function TitleSection({ editable = true }: { editable?: boolean }) {const { title, setTitle } = useWorkflowTitleStore();const setHasChanges = useWorkflowHasChangesStore((s) => s.setHasChanges);@@ -353,8 +221,6 @@ export function StudioTopBar() {return (<div className="flex h-14 shrink-0 items-center gap-3 border-b border-border bg-slate-elevation2 px-4"><TitleSection editable={!isGlobalWorkflow} />- <div className="h-6 w-px bg-border" aria-hidden />- <StudioTabs /><div className="flex-1" />{isGlobalWorkflow ? (<MakeACopyButton />diff --git a/skyvern-frontend/src/routes/workflows/studio/constants.ts b/skyvern-frontend/src/routes/workflows/studio/constants.tsindex 332d03fa5..bf9ad74b6 100644--- a/skyvern-frontend/src/routes/workflows/studio/constants.ts+++ b/skyvern-frontend/src/routes/workflows/studio/constants.ts@@ -1,25 +1,7 @@-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;--// Duration (ms) of the Copilot column open/collapse transition.+// Duration (ms) of studio column-width transitions; the editor's viewport+// counter-translate tracks this window (see FlowRenderer).export const STUDIO_COPILOT_TRANSITION_MS = 300;-// Open uses an ease-out (quick reveal that settles). Collapse uses a symmetric-// ease-in-out: the ease-out is front-loaded, so on close it empties in the first-// ~third and reads as faster than the open — the even curve keeps them matched.-export const STUDIO_COPILOT_TRANSITION_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";-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).+// Stable element ids linking each spine tab to the pane it toggles.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.tsdeleted file mode 100644index 6753f9cdf..000000000--- a/skyvern-frontend/src/routes/workflows/studio/initialStudioTab.test.ts+++ /dev/null@@ -1,21 +0,0 @@-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/paneMeta.ts b/skyvern-frontend/src/routes/workflows/studio/paneMeta.tsnew file mode 100644index 000000000..bda78489e--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/paneMeta.ts@@ -0,0 +1,19 @@+import { type ComponentType } from "react";+import {+ ChatBubbleIcon,+ GlobeIcon,+ PlayIcon,+ Share1Icon,+} from "@radix-ui/react-icons";++import { type StudioPaneId } from "./panes";++export const STUDIO_PANE_META: Record<+ StudioPaneId,+ { label: string; icon: ComponentType<{ className?: string }> }+> = {+ copilot: { label: "Copilot", icon: ChatBubbleIcon },+ editor: { label: "Editor", icon: Share1Icon },+ browser: { label: "Browser", icon: GlobeIcon },+ run: { label: "Run", icon: PlayIcon },+};diff --git a/skyvern-frontend/src/routes/workflows/studio/panes.test.ts b/skyvern-frontend/src/routes/workflows/studio/panes.test.tsnew file mode 100644index 000000000..fe9554a78--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/panes.test.ts@@ -0,0 +1,190 @@+import { describe, expect, test } from "vitest";++import {+ DEFAULT_STUDIO_PANES,+ panesFromDeepLink,+ parsePanesParam,+ resolveOpenPanes,+ searchWithPanes,+ togglePane,+ withPaneClosed,+ withPaneOpen,+ withPanesOpen,+} from "./panes";++describe("parsePanesParam", () => {+ test("returns null when the param is absent", () => {+ expect(parsePanesParam(null)).toBeNull();+ });++ test("treats an empty value as an explicit empty list", () => {+ expect(parsePanesParam("")).toEqual([]);+ });++ test("preserves order", () => {+ expect(parsePanesParam("run,copilot,editor")).toEqual([+ "run",+ "copilot",+ "editor",+ ]);+ });++ test("drops unknown values", () => {+ expect(parsePanesParam("copilot,bogus,browser")).toEqual([+ "copilot",+ "browser",+ ]);+ });++ test("drops duplicates, keeping the first occurrence's position", () => {+ expect(parsePanesParam("browser,copilot,browser")).toEqual([+ "browser",+ "copilot",+ ]);+ });++ test("tolerates whitespace around entries", () => {+ expect(parsePanesParam(" copilot , browser ")).toEqual([+ "copilot",+ "browser",+ ]);+ });+});++describe("panesFromDeepLink", () => {+ test("a run deep link opens the Run pane", () => {+ expect(+ panesFromDeepLink({ runId: "wr_123", active: null, blockLabel: null }),+ ).toEqual(["run"]);+ });++ test("a pinned-item deep link opens the Run pane", () => {+ expect(+ panesFromDeepLink({ runId: null, active: "act_1", blockLabel: null }),+ ).toEqual(["run"]);+ });++ test("a block run opens Run and Browser together", () => {+ expect(+ panesFromDeepLink({+ runId: "wr_123",+ active: null,+ blockLabel: "block_1",+ }),+ ).toEqual(["run", "browser"]);+ });++ test("a block label without a run does not force the Run pane", () => {+ expect(+ panesFromDeepLink({ runId: null, active: null, blockLabel: "block_1" }),+ ).toEqual([...DEFAULT_STUDIO_PANES]);+ });++ test("no deep link falls back to the default panes", () => {+ expect(+ panesFromDeepLink({ runId: null, active: null, blockLabel: null }),+ ).toEqual(["copilot", "browser"]);+ });+});++describe("resolveOpenPanes", () => {+ test("no params resolves to the default panes", () => {+ expect(resolveOpenPanes("")).toEqual(["copilot", "browser"]);+ });++ test("?wr= resolves to the Run pane", () => {+ expect(resolveOpenPanes("?wr=wr_123")).toEqual(["run"]);+ });++ test("?wr= plus ?bl= resolves to Run and Browser", () => {+ expect(resolveOpenPanes("?wr=wr_123&bl=block_1")).toEqual([+ "run",+ "browser",+ ]);+ });++ test("?active= resolves to the Run pane", () => {+ expect(resolveOpenPanes("?active=act_1")).toEqual(["run"]);+ });++ test("an explicit ?panes= wins over the deep-link params", () => {+ expect(resolveOpenPanes("?wr=wr_123&bl=block_1&panes=copilot")).toEqual([+ "copilot",+ ]);+ });++ test("an explicit empty ?panes= wins over the deep-link params", () => {+ expect(resolveOpenPanes("?wr=wr_123&panes=")).toEqual([]);+ });++ test("unrelated params do not affect the default", () => {+ expect(resolveOpenPanes("?embed=true&cache-key-value=x")).toEqual([+ "copilot",+ "browser",+ ]);+ });+});++describe("pane list operations", () => {+ test("toggling a closed pane appends it (click order)", () => {+ expect(togglePane(["copilot", "browser"], "run")).toEqual([+ "copilot",+ "browser",+ "run",+ ]);+ });++ test("toggling an open pane splices it out, preserving the others' order", () => {+ expect(togglePane(["copilot", "run", "browser"], "run")).toEqual([+ "copilot",+ "browser",+ ]);+ });++ test("withPaneOpen is a no-op re-order-wise when already open", () => {+ expect(withPaneOpen(["run", "copilot"], "copilot")).toEqual([+ "run",+ "copilot",+ ]);+ });++ test("withPanesOpen appends only the missing panes, in the given order", () => {+ expect(withPanesOpen(["copilot", "browser"], ["run", "browser"])).toEqual([+ "copilot",+ "browser",+ "run",+ ]);+ });++ test("withPaneClosed removes the pane", () => {+ expect(withPaneClosed(["copilot", "browser"], "copilot")).toEqual([+ "browser",+ ]);+ });+});++describe("searchWithPanes", () => {+ test("adds ?panes= to an empty search, with readable commas", () => {+ expect(searchWithPanes("", ["copilot", "browser"])).toBe(+ "?panes=copilot,browser",+ );+ });++ test("preserves unrelated params and replaces an existing ?panes=", () => {+ const next = searchWithPanes("?wr=wr_1&panes=run", ["run", "editor"]);+ const params = new URLSearchParams(next);+ expect(params.get("wr")).toBe("wr_1");+ expect(params.get("panes")).toBe("run,editor");+ });++ test("serializes an empty list as an explicit empty value", () => {+ const params = new URLSearchParams(searchWithPanes("?wr=wr_1", []));+ expect(params.get("panes")).toBe("");+ expect(params.get("wr")).toBe("wr_1");+ });++ test("round-trips through resolveOpenPanes", () => {+ const next = searchWithPanes("?wr=wr_1", ["browser", "copilot"]);+ expect(resolveOpenPanes(next)).toEqual(["browser", "copilot"]);+ });+});diff --git a/skyvern-frontend/src/routes/workflows/studio/panes.ts b/skyvern-frontend/src/routes/workflows/studio/panes.tsnew file mode 100644index 000000000..6b5643e34--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/panes.ts@@ -0,0 +1,111 @@+export type StudioPaneId = "copilot" | "editor" | "browser" | "run";++export const STUDIO_PANE_IDS: readonly StudioPaneId[] = [+ "copilot",+ "editor",+ "browser",+ "run",+];++export const STUDIO_PANES_PARAM = "panes";++export const DEFAULT_STUDIO_PANES: readonly StudioPaneId[] = [+ "copilot",+ "browser",+];++function isStudioPaneId(value: string): value is StudioPaneId {+ return (STUDIO_PANE_IDS as readonly string[]).includes(value);+}++// Ordered open-pane list from an explicit ?panes= value; unknown entries and+// duplicates are dropped. null means the param was absent (callers fall back to+// the deep-link mapping); an empty value is an explicit "no panes open".+export function parsePanesParam(raw: string | null): StudioPaneId[] | null {+ if (raw === null) {+ return null;+ }+ const result: StudioPaneId[] = [];+ for (const token of raw.split(",")) {+ const id = token.trim();+ if (isStudioPaneId(id) && !result.includes(id)) {+ result.push(id);+ }+ }+ return result;+}++// Deep-link → panes mapping when ?panes= is absent: a block run shows its+// timeline beside the live debug stream; any other run reference lands on Run.+export function panesFromDeepLink(params: {+ runId: string | null;+ active: string | null;+ blockLabel: string | null;+}): StudioPaneId[] {+ if (params.runId && params.blockLabel) {+ return ["run", "browser"];+ }+ if (params.runId || params.active) {+ return ["run"];+ }+ return [...DEFAULT_STUDIO_PANES];+}++// Open panes for a studio search string. An explicit ?panes= wins over the+// legacy deep-link params (?wr= / ?active= / ?bl=).+export function resolveOpenPanes(search: string): StudioPaneId[] {+ const params = new URLSearchParams(search);+ const explicit = parsePanesParam(params.get(STUDIO_PANES_PARAM));+ if (explicit !== null) {+ return explicit;+ }+ return panesFromDeepLink({+ runId: params.get("wr"),+ active: params.get("active"),+ blockLabel: params.get("bl"),+ });+}++// Open panes append, close panes splice: list order is the layout order.+export function togglePane(+ panes: readonly StudioPaneId[],+ id: StudioPaneId,+): StudioPaneId[] {+ return panes.includes(id) ? panes.filter((p) => p !== id) : [...panes, id];+}++export function withPaneOpen(+ panes: readonly StudioPaneId[],+ id: StudioPaneId,+): StudioPaneId[] {+ return panes.includes(id) ? [...panes] : [...panes, id];+}++export function withPanesOpen(+ panes: readonly StudioPaneId[],+ ids: readonly StudioPaneId[],+): StudioPaneId[] {+ return ids.reduce<StudioPaneId[]>(+ (acc, id) => withPaneOpen(acc, id),+ [...panes],+ );+}++export function withPaneClosed(+ panes: readonly StudioPaneId[],+ id: StudioPaneId,+): StudioPaneId[] {+ return panes.filter((p) => p !== id);+}++// Serialize the open list into a search string, preserving unrelated params.+export function searchWithPanes(+ search: string,+ panes: readonly StudioPaneId[],+): string {+ const params = new URLSearchParams(search);+ params.set(STUDIO_PANES_PARAM, panes.join(","));+ // Commas are legal unencoded in query values and parse back identically;+ // keep them readable (?panes=copilot,browser).+ return `?${params.toString().replace(/%2C/g, ",")}`;+}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsxindex b2aa2c9e7..c94c9b2bf 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunHero.tsx@@ -31,6 +31,9 @@ type RunHeroProps = {// A block run shows the shared debug-session stream (re-parented in by the// shell), view-only, instead of mounting a separate run stream.showDebugStream: boolean;+ // The open Browser pane outranks this hero for the single stream node; point+ // at it instead of registering a slot that would stay black.+ debugStreamInBrowserPane?: boolean;provisioning: boolean;isPaused: boolean;failed: boolean;@@ -153,6 +156,7 @@ export function RunHero({heroLabel,running,showDebugStream,+ debugStreamInBrowserPane = false,provisioning,isPaused,failed,@@ -389,15 +393,21 @@ export function RunHero({</div>) : center === "stream" ? (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"- />+ debugStreamInBrowserPane ? (+ <div className="absolute inset-0 grid place-items-center px-6 text-center text-sm text-muted-foreground">+ This block run's live browser is showing in the Browser pane.+ </div>+ ) : (+ // The shell re-parents the persistent debug-session stream into this+ // slot (the same node as the Browser pane), so a block run shows its+ // live browser here, view-only. The slot unmounts when the user scrubs+ // or opens code/recording, which parks the node back offscreen.+ <div+ ref={setRunStreamSlot}+ data-testid="run-stream-slot"+ className="absolute inset-0"+ />+ )) : provisioning ? (// Mounting the stream while the run is still queued opens a socket// the backend never feeds; wait until the run is actually running.diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex 896cdb951..bf0c11378 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -14,7 +14,6 @@ import {isWorkflowRunBlock,} from "@/routes/workflows/types/workflowRunTypes";import { useRunViewStore } from "@/store/RunViewStore";-import { useStudioShellStore } from "@/store/StudioShellStore";import { type ApiCommandOptions } from "@/util/apiCommands";import { runsApiBaseUrl } from "@/util/env";import { cn } from "@/util/utils";@@ -41,6 +40,7 @@ import {formatElapsed,runOutcomeFromStatus,} from "../runProjections";+import { useStudioPanes } from "../useStudioPanes";import { RunHero } from "./RunHero";import { type HeroSelection } from "./HeroScreenshot";import { buildRunFixMessage } from "./runFixMessage";@@ -108,7 +108,9 @@ export function RunView({const pinFrame = useRunViewStore((s) => s.pinFrame);const resetRunView = useRunViewStore((s) => s.reset);const headerCompact = useRunViewStore((s) => s.headerCompact);- const studioTab = useStudioShellStore((s) => s.tab);+ const { panes: studioPanes } = useStudioPanes();+ const runPaneOpen = studioPanes.includes("run");+ const browserPaneOpen = studioPanes.includes("browser");const [searchParams, setSearchParams] = useSearchParams();const searchParamsRef = useRef(searchParams);searchParamsRef.current = searchParams;@@ -158,12 +160,15 @@ export function RunView({}setSearchParams((prev) => {+ // Build on the LIVE URL (prev is this render's closure): a concurrent+ // navigation (block-run launch, pane toggle) is already visible there.+ const base = window.location.search || `?${prev.toString()}`;+ const next = new URLSearchParams(base);const desired =pinnedFrameId && !/:\d+$/.test(pinnedFrameId) ? pinnedFrameId : null;- if ((prev.get("active") ?? null) === desired) {- return prev;+ if ((next.get("active") ?? null) === desired) {+ return next;}- const next = new URLSearchParams(prev);if (desired) {next.set("active", desired);} else {@@ -176,15 +181,15 @@ export function RunView({}, [pinnedFrameId, workflowRunId, setSearchParams]);// 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 Run pane being open: RunView stays mounted while its pane is closed.//// 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).+ // navigates to ?wr=&bl= via a separate router update, and this effect can fire 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") {+ if (!runPaneOpen) {return;}if (!workflowRunId) {@@ -195,16 +200,17 @@ export function RunView({}setSearchParams((prev) => {- if (prev.get("wr")) {- return prev;+ const base = window.location.search || `?${prev.toString()}`;+ const next = new URLSearchParams(base);+ if (next.get("wr")) {+ return next;}- const next = new URLSearchParams(prev);next.set("wr", workflowRunId);return next;},{ replace: true },);- }, [studioTab, workflowRunId, setSearchParams]);+ }, [runPaneOpen, workflowRunId, setSearchParams]);const frames = useMemo(() => buildFilmstrip(timeline), [timeline]);@@ -213,12 +219,12 @@ export function RunView({// 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+ // A block run executes in the debug session; in the Run pane show that same live// debug stream (the shared node) instead of a separate run stream — but only when// the run's browser session IS the current debug session. A historical block-run// link whose debug session is gone/different falls back to the normal run view.const showDebugStream =- studioTab === "run" &&+ runPaneOpen &&searchParams.has("bl") &&workflowRun?.browser_session_id != null &&workflowRun.browser_session_id === debugSession?.browser_session_id;@@ -383,6 +389,7 @@ export function RunView({heroLabel={heroLabel}running={running}showDebugStream={showDebugStream}+ debugStreamInBrowserPane={browserPaneOpen}provisioning={workflowRun.status === Status.Created ||workflowRun.status === Status.Queueddiff --git a/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts b/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.tsnew file mode 100644index 000000000..3cf86ac7d--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/studio/useStudioPanes.ts@@ -0,0 +1,66 @@+import { useCallback, useMemo } from "react";+import {+ useLocation,+ useNavigate,+ type NavigateOptions,+} from "react-router-dom";++import {+ resolveOpenPanes,+ searchWithPanes,+ togglePane as togglePaneIn,+ withPaneClosed,+ withPaneOpen,+ type StudioPaneId,+} from "./panes";++/**+ * Pane state lives in the URL (?panes=), so the open set and its order are+ * shareable and can never drift from navigation. Writes merge against the live+ * URL rather than this render's closure: pushState is synchronous, so a+ * concurrent navigate() (e.g. a block-run launch) is already visible there.+ */+export function useStudioPanes() {+ const location = useLocation();+ const navigate = useNavigate();++ const panes = useMemo(+ () => resolveOpenPanes(location.search),+ [location.search],+ );++ const applyPanes = useCallback(+ (+ compute: (current: StudioPaneId[]) => StudioPaneId[],+ options?: Pick<NavigateOptions, "state">,+ ) => {+ // window.location is blank under a memory router (tests); fall back to+ // the router's location, which is identical to the live URL in a browser.+ const liveSearch = window.location.search || location.search;+ const next = compute(resolveOpenPanes(liveSearch));+ navigate(+ { search: searchWithPanes(liveSearch, next) },+ { replace: true, ...options },+ );+ },+ [navigate, location.search],+ );++ const togglePane = useCallback(+ (id: StudioPaneId) => applyPanes((current) => togglePaneIn(current, id)),+ [applyPanes],+ );++ const openPane = useCallback(+ (id: StudioPaneId, options?: Pick<NavigateOptions, "state">) =>+ applyPanes((current) => withPaneOpen(current, id), options),+ [applyPanes],+ );++ const closePane = useCallback(+ (id: StudioPaneId) => applyPanes((current) => withPaneClosed(current, id)),+ [applyPanes],+ );++ return { panes, togglePane, openPane, closePane };+}diff --git a/skyvern-frontend/src/store/StudioShellStore.ts b/skyvern-frontend/src/store/StudioShellStore.tsindex bf846dd1e..8bd0f7cdb 100644--- a/skyvern-frontend/src/store/StudioShellStore.ts+++ b/skyvern-frontend/src/store/StudioShellStore.ts@@ -1,23 +1,14 @@import { create } from "zustand";import { persist, createJSONStorage } from "zustand/middleware";-export type StudioTab = "editor" | "browser" | "run";-type StudioShellState = {- tab: StudioTab;- copilotCollapsed: boolean;pipMinimized: boolean;- setTab: (tab: StudioTab) => void;- setCopilotCollapsed: (collapsed: boolean) => void;- toggleCopilot: () => void;setPipMinimized: (minimized: boolean) => void;togglePip: () => void;reset: () => void;};const DEFAULTS = {- tab: "editor" as StudioTab,- copilotCollapsed: false,pipMinimized: false,};@@ -27,10 +18,6 @@ export const useStudioShellStore = create<StudioShellState>()(persist((set) => ({...DEFAULTS,- setTab: (tab) => set({ tab }),- setCopilotCollapsed: (copilotCollapsed) => set({ copilotCollapsed }),- toggleCopilot: () =>- set((state) => ({ copilotCollapsed: !state.copilotCollapsed })),setPipMinimized: (pipMinimized) => set({ pipMinimized }),togglePip: () => set((state) => ({ pipMinimized: !state.pipMinimized })),reset: () => set(DEFAULTS),@@ -38,12 +25,14 @@ export const useStudioShellStore = create<StudioShellState>()({name: STUDIO_SHELL_STORAGE_KEY,storage: createJSONStorage(() => localStorage),- // `tab` is intentionally not persisted: the Run tab is gated on hasRun,- // so each session starts on the editor.- partialize: (state) => ({- copilotCollapsed: state.copilotCollapsed,- pipMinimized: state.pipMinimized,+ // v0 also persisted copilotCollapsed; pane visibility now lives in the URL.+ version: 1,+ migrate: (persisted) => ({+ pipMinimized: Boolean(+ (persisted as { pipMinimized?: unknown } | undefined)?.pipMinimized,+ ),}),+ partialize: (state) => ({ pipMinimized: state.pipMinimized }),},),);