Skip to content

Automate browser based workflows with AI

SKY-15304 Keep Copilot test runs on Live (#8356)

Andrew Neilsoncdf320b7c118
diff --git a/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx b/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx
index f4ceddef6..1f42b91ce 100644
--- a/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/BrowserTab.test.tsx
@@ -305,10 +305,27 @@ describe("BrowserTab view machine", () => {
expect(screen.getByTestId("hero-recording")).toBeTruthy();
});
+ it("keeps a finished Copilot-focused run on the live debug browser", () => {
+ seedRun({ status: Status.Completed });
+ mocks.timeline = [
+ buildBlockItem(
+ buildBlock({
+ actions: [buildAction({ screenshot_artifact_id: null })],
+ }),
+ ),
+ ];
+ mocks.debugSession = { browser_session_id: "pbs_test" };
+ renderBrowserPane(`${STUDIO_PATH}&wr=wr_1&wrs=copilot`);
+
+ expect(screen.getByTestId("browser-pane-stream-slot")).toBeTruthy();
+ expect(screen.queryByTestId("hero-recording")).toBeNull();
+ expect(screen.queryByTestId("hero-screenshot")).toBeNull();
+ });
+
it("shows the inspected step's screenshot when ?active= is set", () => {
seedRun({ status: Status.Completed });
mocks.debugSession = { browser_session_id: "pbs_test" };
- renderBrowserPane(`${STUDIO_PATH}&wr=wr_1&active=act_1`);
+ renderBrowserPane(`${STUDIO_PATH}&wr=wr_1&wrs=copilot&active=act_1`);
const shot = screen.getByTestId("hero-screenshot");
expect(JSON.parse(shot.getAttribute("data-selection") ?? "{}")).toEqual({
@@ -424,6 +441,23 @@ describe("BrowserTab view machine", () => {
});
describe("BrowserTab pills and selection sync", () => {
+ it("keeps explicit view controls authoritative during Copilot focus", () => {
+ seedRun({ status: Status.Completed, recordingUrl: "https://r.test/1.mp4" });
+ mocks.debugSession = { browser_session_id: "pbs_test" };
+ renderBrowserPane(`${STUDIO_PATH}&wr=wr_1&wrs=copilot`);
+
+ expect(screen.getByTestId("browser-pane-stream-slot")).toBeTruthy();
+
+ fireEvent.click(screen.getByRole("button", { name: "Screenshots" }));
+ expect(screen.getByTestId("hero-screenshot")).toBeTruthy();
+
+ fireEvent.click(screen.getByRole("button", { name: "Recording" }));
+ expect(screen.getByTestId("hero-recording")).toBeTruthy();
+
+ fireEvent.click(screen.getByRole("button", { name: "Debug browser" }));
+ expect(screen.getByTestId("browser-pane-stream-slot")).toBeTruthy();
+ });
+
it("switches views from the header pills", () => {
seedRun({ status: Status.Completed, recordingUrl: "https://r.test/1.mp4" });
mocks.debugSession = { browser_session_id: "pbs_test" };
diff --git a/skyvern-frontend/src/routes/workflows/studio/browserPaneView.test.ts b/skyvern-frontend/src/routes/workflows/studio/browserPaneView.test.ts
index bf366dbd8..93d791cdc 100644
--- a/skyvern-frontend/src/routes/workflows/studio/browserPaneView.test.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/browserPaneView.test.ts
@@ -8,6 +8,7 @@ const base = {
scrubbing: false,
inspectingRun: false,
blockRunInDebugSession: false,
+ systemFocused: false,
running: false,
hasRecording: false,
failed: false,
@@ -86,6 +87,40 @@ describe("resolveBrowserPaneView", () => {
).toBe("screenshots");
});
+ it("keeps a system-focused run live after it finishes", () => {
+ expect(
+ resolveBrowserPaneView({
+ ...base,
+ systemFocused: true,
+ inspectingRun: true,
+ hasRecording: true,
+ }),
+ ).toBe("live");
+ expect(
+ resolveBrowserPaneView({
+ ...base,
+ systemFocused: true,
+ inspectingRun: true,
+ failed: true,
+ }),
+ ).toBe("live");
+ });
+
+ it("keeps explicit replay authoritative during system focus", () => {
+ for (const intent of ["recording", "screenshots"] as const) {
+ expect(
+ resolveBrowserPaneView({ ...base, systemFocused: true, intent }),
+ ).toBe(intent);
+ }
+ expect(
+ resolveBrowserPaneView({
+ ...base,
+ systemFocused: true,
+ scrubbing: true,
+ }),
+ ).toBe("screenshots");
+ });
+
it("stays live for a block run in the debug session, even finalized", () => {
expect(
resolveBrowserPaneView({
diff --git a/skyvern-frontend/src/routes/workflows/studio/browserPaneView.ts b/skyvern-frontend/src/routes/workflows/studio/browserPaneView.ts
index 978753c44..54fd63446 100644
--- a/skyvern-frontend/src/routes/workflows/studio/browserPaneView.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/browserPaneView.ts
@@ -14,6 +14,8 @@ type ResolveBrowserPaneViewArgs = {
// A block-scoped run (?bl=) shares the live debug session; the live browser
// stays the surface even after it finalizes (the block-iterate loop).
blockRunInDebugSession: boolean;
+ // The Copilot introduced the run focus and still owns its automatic view.
+ systemFocused: boolean;
running: boolean;
hasRecording: boolean;
failed: boolean;
@@ -56,6 +58,7 @@ export function resolveBrowserPaneView({
scrubbing,
inspectingRun,
blockRunInDebugSession,
+ systemFocused,
running,
hasRecording,
failed,
@@ -79,6 +82,9 @@ export function resolveBrowserPaneView({
if (scrubbing) {
return "screenshots";
}
+ if (systemFocused) {
+ return "live";
+ }
if (blockRunInDebugSession) {
return "live";
}
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
index 5e3f00bd4..ba8816ed2 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.test.tsx
@@ -328,6 +328,22 @@ function SelectBlockOnCanvas({ label }: { label: string }) {
);
}
+function ReleaseCopilotRunFocus() {
+ const [params, setParams] = useSearchParams();
+ return (
+ <button
+ onClick={() => {
+ const next = new URLSearchParams(params);
+ next.delete("wr");
+ next.delete("wrs");
+ setParams(next, { replace: true });
+ }}
+ >
+ release copilot focus
+ </button>
+ );
+}
+
function renderRunView(
props: Partial<Parameters<typeof RunView>[0]> = {},
initialEntry = "/",
@@ -773,6 +789,30 @@ describe("RunView cold-open selection", () => {
expect(useRunViewStore.getState().pinnedFrameId).toBe("act_1");
});
+ test("a terminal Copilot-focused run stays unselected through release", () => {
+ seedTerminalRunWithActions();
+ const view = renderRunView(
+ {},
+ "/?wr=wr_1&wrs=copilot",
+ false,
+ <ReleaseCopilotRunFocus />,
+ );
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBeNull();
+ expect(view.getByTestId("location-search").textContent).not.toContain(
+ "active=",
+ );
+
+ fireEvent.click(
+ view.getByRole("button", { name: "release copilot focus" }),
+ );
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBeNull();
+ expect(view.getByTestId("location-search").textContent).not.toContain(
+ "active=",
+ );
+ });
+
test("a still-running run keeps following the live edge", () => {
seedRunningRun();
renderRunView({}, "/?wr=wr_1");
@@ -933,6 +973,35 @@ describe("RunView live-watch terminal transition", () => {
expect(useStudioBrowserStore.getState().view).toBe("auto");
});
+ test("a Copilot-focused watched run stays unselected when it finishes", () => {
+ seedWatchedRun(Status.Running);
+ const view = renderRunView({}, "/?wr=wr_1&wrs=copilot");
+
+ seedWatchedRun(Status.Completed);
+ view.rerenderRunView();
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBeNull();
+ expect(view.getByTestId("location-search").textContent).not.toContain(
+ "active=",
+ );
+ });
+
+ test("an explicit timeline pin still wins during Copilot focus", () => {
+ seedWatchedRun(Status.Running);
+ const view = renderRunView({}, "/?wr=wr_1&wrs=copilot");
+
+ act(() => useRunViewStore.getState().pinFrame("act_1"));
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("act_1");
+ expect(view.getByTestId("location-search").textContent).toContain(
+ "active=act_1",
+ );
+
+ seedWatchedRun(Status.Completed);
+ view.rerenderRunView();
+ expect(useRunViewStore.getState().pinnedFrameId).toBe("act_1");
+ });
+
test("a view pill pinned mid-watch is never overridden at run end", () => {
seedWatchedRun(Status.Running);
const view = renderRunView({}, "/?wr=wr_1");
@@ -1153,6 +1222,22 @@ describe("RunView failure presentation", () => {
expect(useRunViewStore.getState().pinnedFrameId).toBe("wrb_code");
});
+ test("a failed Copilot-focused run does not auto-pin its failing block", () => {
+ seedFailedCodeRun();
+ const { getByTestId } = renderRunView({}, "/?wr=wr_1&wrs=copilot");
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBeNull();
+ expect(getByTestId("location-search").textContent).not.toContain("active=");
+ });
+
+ test("a Copilot-focused latest failed run does not auto-pin its failing block", () => {
+ seedFailedCodeRun();
+ const { getByTestId } = renderRunView({}, "/?wrs=copilot");
+
+ expect(useRunViewStore.getState().pinnedFrameId).toBeNull();
+ expect(getByTestId("location-search").textContent).not.toContain("active=");
+ });
+
test("a failed latest-run Studio open lands on the failing block", () => {
seedFailedCodeRun();
const { getByTestId } = renderRunView();
diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
index fcf2a118d..d32678da3 100644
--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx
@@ -55,7 +55,11 @@ import {
runHasOutputs,
runOutcomeFromStatus,
} from "../runProjections";
-import { searchWithRunReference, toReadableSearch } from "../panes";
+import {
+ searchWithRunReference,
+ SYSTEM_RUN_FOCUS_PARAM,
+ toReadableSearch,
+} from "../panes";
import { useStudioPanes } from "../useStudioPanes";
import { collectBlockPrompts } from "./blockPrompts";
import { formatFailureReason } from "../../workflowRun/failureReasonFormat";
@@ -380,6 +384,9 @@ export function RunView({
const params = new URLSearchParams(
window.location.search || searchParamsRef.current.toString(),
);
+ if (params.has(SYSTEM_RUN_FOCUS_PARAM)) {
+ return;
+ }
// 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 =
diff --git a/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts b/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts
index 956877b12..395ab184d 100644
--- a/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts
+++ b/skyvern-frontend/src/routes/workflows/studio/useBrowserPaneView.ts
@@ -15,6 +15,7 @@ import {
resolveLiveSurface,
type BrowserPaneView,
} from "./browserPaneView";
+import { SYSTEM_RUN_FOCUS_PARAM } from "./panes";
import { useRunVisuals, type RunVisuals } from "./useRunVisuals";
import { useStudioInspectedRun } from "./useStudioInspectedRun";
@@ -87,6 +88,7 @@ export function useBrowserPaneView(): BrowserPaneViewState {
scrubbing: visuals.scrubbing,
inspectingRun: explicit,
blockRunInDebugSession,
+ systemFocused: searchParams.has(SYSTEM_RUN_FOCUS_PARAM),
running: visuals.running,
hasRecording: visuals.recordingUrls.length > 0,
failed: visuals.failed,