Skip to content

Automate browser based workflows with AI

feat(SKY-12600): add an artifact timeline tab to browser sessions (run view for MCP-driven sessions) (#7506)

Marc Kelechava0f973949cc44
diff --git a/skyvern-frontend/src/router.tsx b/skyvern-frontend/src/router.tsx
index e012fce4f..5dce61453 100644
--- a/skyvern-frontend/src/router.tsx
+++ b/skyvern-frontend/src/router.tsx
@@ -120,6 +120,7 @@ const router = createBrowserRouter([
{ path: "stream", element: <></> },
{ path: "recordings", element: <></> },
{ path: "downloads", element: <></> },
+ { path: "timeline", element: <></> },
{ path: "runs", element: <></> },
],
},
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSession.test.ts b/skyvern-frontend/src/routes/browserSessions/BrowserSession.test.ts
new file mode 100644
index 000000000..295a4572b
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSession.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from "vitest";
+
+import { getBrowserSessionTabFromPathname } from "./BrowserSession.utils";
+
+describe("getBrowserSessionTabFromPathname", () => {
+ it.each([
+ ["/browser-session/session-1/timeline", "timeline"],
+ ["/browser-session/session-1/downloads", "downloads"],
+ ] as const)("maps %s to %s", (pathname, tab) => {
+ expect(getBrowserSessionTabFromPathname(pathname)).toBe(tab);
+ });
+});
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx
index 9bd5252c1..b56940dcf 100644
--- a/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx
@@ -37,20 +37,14 @@ import { BrowserSessionDownloads } from "./BrowserSessionDownloads";
import { BrowserSessionOccupiedBy } from "./BrowserSessionOccupiedBy";
import { BrowserSessionVideo } from "./BrowserSessionVideo";
import { BrowserSessionStream } from "./BrowserSessionStream";
+import { BrowserSessionTimeline } from "./BrowserSessionTimeline";
import { BrowserSessionWorkflowRuns } from "./BrowserSessionWorkflowRuns";
-
-type TabName = "stream" | "recordings" | "downloads" | "runs";
+import { getBrowserSessionTabFromPathname } from "./BrowserSession.utils";
function BrowserSession() {
const { browserSessionId } = useParams();
const location = useLocation();
- const activeTab: TabName = location.pathname.endsWith("/recordings")
- ? "recordings"
- : location.pathname.endsWith("/downloads")
- ? "downloads"
- : location.pathname.endsWith("/runs")
- ? "runs"
- : "stream";
+ const activeTab = getBrowserSessionTabFromPathname(location.pathname);
const [isDialogOpen, setIsDialogOpen] = useState(false);
const [isSaveProfileDialogOpen, setIsSaveProfileDialogOpen] = useState(false);
const [vncFailed, setVncFailed] = useState(false);
@@ -175,6 +169,7 @@ function BrowserSession() {
{ label: "Stream", to: "stream" },
{ label: "Recordings", to: "recordings" },
{ label: "Downloads", to: "downloads" },
+ { label: "Timeline", to: "timeline" },
{ label: "Runs", to: "runs" },
]}
/>
@@ -272,6 +267,15 @@ function BrowserSession() {
>
<BrowserSessionDownloads />
</div>
+ <div
+ className="absolute left-0 top-0 h-full w-full"
+ style={{
+ visibility: activeTab === "timeline" ? "visible" : "hidden",
+ pointerEvents: activeTab === "timeline" ? "auto" : "none",
+ }}
+ >
+ <BrowserSessionTimeline />
+ </div>
<div
className="absolute left-0 top-0 h-full w-full overflow-auto p-1"
style={{
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSession.utils.ts b/skyvern-frontend/src/routes/browserSessions/BrowserSession.utils.ts
new file mode 100644
index 000000000..c07dfbb69
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSession.utils.ts
@@ -0,0 +1,9 @@
+const tabNames = ["recordings", "downloads", "timeline", "runs"] as const;
+
+type TabName = "stream" | (typeof tabNames)[number];
+
+function getBrowserSessionTabFromPathname(pathname: string): TabName {
+ return tabNames.find((tab) => pathname.endsWith(`/${tab}`)) ?? "stream";
+}
+
+export { getBrowserSessionTabFromPathname, type TabName };
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.test.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.test.tsx
new file mode 100644
index 000000000..68e1694a0
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.test.tsx
@@ -0,0 +1,210 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { render, screen, within } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { MemoryRouter, Route, Routes } from "react-router-dom";
+
+import { getClient } from "@/api/AxiosClient";
+
+import { BrowserSessionTimeline } from "./BrowserSessionTimeline";
+import {
+ buildSessionTimeline,
+ getSessionTimelineKindLabel,
+} from "./BrowserSessionTimeline.utils";
+
+vi.mock("@/api/AxiosClient", () => ({ getClient: vi.fn() }));
+vi.mock("@/hooks/useCredentialGetter", () => ({
+ useCredentialGetter: () => null,
+}));
+
+afterEach(() => vi.clearAllMocks());
+
+const artifact = (
+ checksum: string,
+ filename: string,
+ modified_at: string | null,
+) => ({
+ checksum,
+ filename,
+ modified_at,
+ url: `https://example.test/${filename}`,
+});
+
+function renderTimeline(browserSession: unknown, duplicate = false) {
+ const get = vi.fn().mockResolvedValue({ data: browserSession });
+ vi.mocked(getClient).mockResolvedValue({ get } as never);
+ const timeline = <BrowserSessionTimeline />;
+
+ render(
+ <MemoryRouter initialEntries={["/browser-session/session-1/timeline"]}>
+ <QueryClientProvider
+ client={
+ new QueryClient({ defaultOptions: { queries: { retry: false } } })
+ }
+ >
+ <Routes>
+ <Route
+ path="/browser-session/:browserSessionId/timeline"
+ element={
+ duplicate ? (
+ <>
+ {timeline}
+ {timeline}
+ </>
+ ) : (
+ timeline
+ )
+ }
+ />
+ </Routes>
+ </QueryClientProvider>
+ </MemoryRouter>,
+ );
+
+ return get;
+}
+
+describe("buildSessionTimeline", () => {
+ it("sorts by time, kind, and filename while preserving exact ties", () => {
+ const sameTime = "2026-07-16T11:00:00.000Z";
+ const timeline = buildSessionTimeline({
+ status: "completed",
+ downloadedFiles: [
+ artifact("zeta", "zeta.txt", sameTime),
+ artifact("alpha", "alpha.txt", sameTime),
+ artifact("first-tie", "same.txt", sameTime),
+ artifact("second-tie", "same.txt", sameTime),
+ artifact("newest", "newest.txt", "2026-07-16T12:00:00.000Z"),
+ artifact("no-time", "no-time.txt", null),
+ ],
+ recordings: [artifact("recording", "alpha.webm", sameTime)],
+ });
+
+ expect(timeline.map(({ checksum }) => checksum)).toEqual([
+ "newest",
+ "alpha",
+ "first-tie",
+ "second-tie",
+ "zeta",
+ "recording",
+ "no-time",
+ ]);
+ });
+
+ it("handles empty inputs, nullable URLs, filenames, and unknown kinds", () => {
+ expect(
+ buildSessionTimeline({
+ status: "completed",
+ downloadedFiles: null,
+ recordings: null,
+ }),
+ ).toEqual([]);
+
+ const timeline = buildSessionTimeline({
+ status: "completed",
+ downloadedFiles: [
+ { checksum: "no-url", filename: null, modified_at: null, url: null },
+ {
+ checksum: "url-name",
+ filename: null,
+ modified_at: null,
+ url: "https://example.test/files/report.csv?expiry=1",
+ },
+ ],
+ recordings: [],
+ });
+ expect(timeline[0]).toEqual(
+ expect.objectContaining({ filename: "Download 1", url: null }),
+ );
+ expect(timeline[1]?.filename).toBe("report.csv");
+ expect(getSessionTimelineKindLabel("future-kind")).toBe("Artifact");
+ });
+
+ it("orders mixed timezone-less and offset-carrying timestamps as UTC", () => {
+ const timeline = buildSessionTimeline({
+ status: "completed",
+ downloadedFiles: [
+ artifact("naive-oldest", "oldest.txt", "2026-07-16T11:00:00.000000"),
+ artifact("aware-middle", "middle.txt", "2026-07-16T11:30:00+00:00"),
+ ],
+ recordings: [
+ artifact("zulu-newest", "newest.webm", "2026-07-16T12:00:00.000Z"),
+ ],
+ });
+
+ expect(timeline.map(({ checksum }) => checksum)).toEqual([
+ "zulu-newest",
+ "aware-middle",
+ "naive-oldest",
+ ]);
+ });
+
+ it("suppresses recordings while running", () => {
+ const timeline = buildSessionTimeline({
+ status: "running",
+ downloadedFiles: [artifact("download", "download.txt", null)],
+ recordings: [artifact("recording", "session.webm", null)],
+ });
+ expect(timeline.map(({ kind }) => kind)).toEqual(["download"]);
+ });
+});
+
+describe("BrowserSessionTimeline", () => {
+ it("renders nullable URL rows without links", async () => {
+ renderTimeline({
+ status: "completed",
+ downloaded_files: [
+ { checksum: "no-url", filename: null, modified_at: null, url: null },
+ artifact("with-url", "report.csv", "2026-07-16T12:00:00.000Z"),
+ ],
+ recordings: [],
+ });
+
+ const row = (await screen.findByText("Download 1")).closest("li");
+ expect(row).not.toBeNull();
+ expect(within(row!).queryByRole("link")).toBeNull();
+ expect(screen.getByRole("link", { name: "Open report.csv" })).toBeTruthy();
+ });
+
+ it("falls back to the unavailable label for invalid timestamps", async () => {
+ renderTimeline({
+ status: "completed",
+ downloaded_files: [artifact("bad-time", "report.csv", "not-a-date")],
+ recordings: [],
+ });
+
+ await screen.findByText("report.csv");
+ expect(screen.getByText("Availability time unavailable")).toBeTruthy();
+ expect(screen.queryByText(/Invalid Date/)).toBeNull();
+ });
+
+ it("proxies file:// recording URLs through the artifact server", async () => {
+ renderTimeline({
+ status: "completed",
+ downloaded_files: [],
+ recordings: [
+ {
+ checksum: "local-rec",
+ filename: "local.webm",
+ modified_at: "2026-07-16T12:00:00.000Z",
+ url: "file:///data/videos/local.webm",
+ },
+ ],
+ });
+
+ const link = await screen.findByRole("link", { name: "Open local.webm" });
+ expect(link.getAttribute("href")).toContain(
+ `/artifact/recording?path=${encodeURIComponent("/data/videos/local.webm")}`,
+ );
+ });
+
+ it("renders the empty state and deduplicates shared query subscribers", async () => {
+ const get = renderTimeline(
+ { status: "completed", downloaded_files: null, recordings: null },
+ true,
+ );
+ const emptyState =
+ "No artifacts available yet — downloads and recordings will appear here as they become available.";
+ expect(await screen.findAllByText(emptyState)).toHaveLength(2);
+ expect(get).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.tsx
new file mode 100644
index 000000000..66cac8ec0
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.tsx
@@ -0,0 +1,139 @@
+import {
+ DownloadIcon,
+ ExternalLinkIcon,
+ FileIcon,
+ VideoIcon,
+} from "@radix-ui/react-icons";
+import { useQuery } from "@tanstack/react-query";
+import { useParams } from "react-router-dom";
+
+import { getClient } from "@/api/AxiosClient";
+import { ArtifactDownloadLink } from "@/components/ArtifactDownloadLink";
+import { useCredentialGetter } from "@/hooks/useCredentialGetter";
+import { type BrowserSession } from "@/routes/workflows/types/browserSessionTypes";
+import { basicLocalTimeFormat } from "@/util/timeFormat";
+
+import {
+ buildSessionTimeline,
+ getSessionTimelineKindLabel,
+} from "./BrowserSessionTimeline.utils";
+import { getRecordingUrl } from "./recordingUrl";
+
+const kindIcons: Record<string, typeof FileIcon> = {
+ download: DownloadIcon,
+ recording: VideoIcon,
+};
+
+function BrowserSessionTimeline() {
+ const { browserSessionId } = useParams();
+ const credentialGetter = useCredentialGetter();
+ const {
+ data: browserSession,
+ isLoading,
+ error,
+ } = useQuery<BrowserSession>({
+ queryKey: ["browserSession", browserSessionId],
+ queryFn: async () => {
+ const client = await getClient(credentialGetter, "sans-api-v1");
+ const response = await client.get(
+ `/browser_sessions/${browserSessionId}`,
+ );
+ return response.data;
+ },
+ enabled: !!browserSessionId,
+ });
+
+ const timeline = buildSessionTimeline({
+ downloadedFiles: browserSession?.downloaded_files,
+ recordings: browserSession?.recordings,
+ status: browserSession?.status,
+ });
+
+ if (isLoading) {
+ return (
+ <div className="flex h-full w-full items-center justify-center">
+ <div className="text-lg">Loading artifacts...</div>
+ </div>
+ );
+ }
+
+ if (error) {
+ return (
+ <div className="flex h-full w-full items-center justify-center">
+ <div className="text-lg text-red-500">
+ Error loading artifacts: {error.message}
+ </div>
+ </div>
+ );
+ }
+
+ if (timeline.length === 0) {
+ return (
+ <div className="flex h-full w-full items-center justify-center">
+ <div className="max-w-lg text-center text-lg text-gray-500">
+ No artifacts available yet — downloads and recordings will appear here
+ as they become available.
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <div className="h-full w-full overflow-auto p-4">
+ <div className="mb-4">
+ <h2 className="text-xl font-semibold">Artifact Timeline</h2>
+ <p className="text-sm text-gray-500">
+ When files from this session became available
+ </p>
+ </div>
+
+ <ul className="space-y-2">
+ {timeline.map((artifact, index) => {
+ const KindIcon = kindIcons[artifact.kind] ?? FileIcon;
+ const href =
+ artifact.kind === "recording"
+ ? getRecordingUrl(artifact.url)
+ : artifact.url;
+
+ return (
+ <li
+ key={`${artifact.kind}-${artifact.checksum ?? artifact.url ?? artifact.filename}-${index}`}
+ className="flex items-center gap-3 rounded-lg border p-3"
+ >
+ <KindIcon className="size-5 shrink-0" />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <span className="rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-gray-800 dark:text-gray-300">
+ {getSessionTimelineKindLabel(artifact.kind)}
+ </span>
+ <span className="truncate text-sm" title={artifact.filename}>
+ {artifact.filename}
+ </span>
+ </div>
+ <div className="mt-1 text-xs text-gray-500">
+ {artifact.modified_at
+ ? basicLocalTimeFormat(artifact.modified_at)
+ : "Availability time unavailable"}
+ </div>
+ </div>
+ {href && (
+ <ArtifactDownloadLink
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ aria-label={`Open ${artifact.filename}`}
+ className="flex shrink-0 items-center gap-1 rounded border px-2 py-1 text-xs hover:bg-muted"
+ >
+ <ExternalLinkIcon className="size-3" />
+ Open
+ </ArtifactDownloadLink>
+ )}
+ </li>
+ );
+ })}
+ </ul>
+ </div>
+ );
+}
+
+export { BrowserSessionTimeline };
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.utils.ts b/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.utils.ts
new file mode 100644
index 000000000..1ff977aeb
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionTimeline.utils.ts
@@ -0,0 +1,99 @@
+import { normalizeUtcTimestamp } from "@/util/timeFormat";
+
+import { areRecordingsIncomplete } from "./browserSessionQueryUtils";
+
+type SessionTimelineKind = "download" | "recording";
+
+type TimelineArtifactSource = {
+ checksum?: string | null;
+ filename?: string | null;
+ modified_at?: string | null;
+ url?: string | null;
+};
+
+type SessionTimelineItem = {
+ checksum: string | null;
+ filename: string;
+ kind: SessionTimelineKind;
+ modified_at: string | null;
+ url: string | null;
+};
+
+type BuildSessionTimelineOptions = {
+ downloadedFiles?: readonly TimelineArtifactSource[] | null;
+ recordings?: readonly TimelineArtifactSource[] | null;
+ status?: string | null;
+};
+
+const sessionTimelineKindLabels: Record<SessionTimelineKind, string> = {
+ download: "Download",
+ recording: "Recording",
+};
+
+function getSessionTimelineKindLabel(kind: string): string {
+ return sessionTimelineKindLabels[kind as SessionTimelineKind] ?? "Artifact";
+}
+
+function timelineFilename(
+ artifact: TimelineArtifactSource,
+ kind: SessionTimelineKind,
+ index: number,
+): string {
+ const urlPath = artifact.url?.split("?")[0];
+ return (
+ artifact.filename ||
+ urlPath?.split("/").pop() ||
+ `${getSessionTimelineKindLabel(kind)} ${index + 1}`
+ );
+}
+
+function timelineTimestamp(modifiedAt: string | null): number {
+ const timestamp = modifiedAt
+ ? Date.parse(normalizeUtcTimestamp(modifiedAt))
+ : Number.NaN;
+ return Number.isNaN(timestamp) ? Number.NEGATIVE_INFINITY : timestamp;
+}
+
+function validTimestamp(modifiedAt: string | null | undefined): string | null {
+ if (!modifiedAt) {
+ return null;
+ }
+ return Number.isNaN(Date.parse(normalizeUtcTimestamp(modifiedAt)))
+ ? null
+ : modifiedAt;
+}
+
+function buildSessionTimeline({
+ downloadedFiles,
+ recordings,
+ status,
+}: BuildSessionTimelineOptions): SessionTimelineItem[] {
+ const items: SessionTimelineItem[] = [
+ ...(downloadedFiles ?? []).map((file, index) => ({
+ checksum: file.checksum ?? null,
+ filename: timelineFilename(file, "download", index),
+ kind: "download" as const,
+ modified_at: validTimestamp(file.modified_at),
+ url: file.url ?? null,
+ })),
+ ...(areRecordingsIncomplete(status) ? [] : (recordings ?? [])).map(
+ (recording, index) => ({
+ checksum: recording.checksum ?? null,
+ filename: timelineFilename(recording, "recording", index),
+ kind: "recording" as const,
+ modified_at: validTimestamp(recording.modified_at),
+ url: recording.url ?? null,
+ }),
+ ),
+ ];
+
+ return items.sort(
+ (left, right) =>
+ timelineTimestamp(right.modified_at) -
+ timelineTimestamp(left.modified_at) ||
+ left.kind.localeCompare(right.kind) ||
+ left.filename.localeCompare(right.filename),
+ );
+}
+
+export { buildSessionTimeline, getSessionTimelineKindLabel };
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionVideo.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSessionVideo.tsx
index f04a5dd0a..bfe20242f 100644
--- a/skyvern-frontend/src/routes/browserSessions/BrowserSessionVideo.tsx
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionVideo.tsx
@@ -5,17 +5,10 @@ import { getClient } from "@/api/AxiosClient";
import { ArtifactVideo } from "@/components/ArtifactVideo";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { type Recording } from "@/routes/workflows/types/browserSessionTypes";
-import { artifactApiBaseUrl } from "@/util/env";
+import { basicLocalTimeFormat } from "@/util/timeFormat";
-function getRecordingUrl(url: string | null | undefined): string | null {
- if (!url) {
- return null;
- }
- if (url.startsWith("file://")) {
- return `${artifactApiBaseUrl}/artifact/recording?path=${url.slice(7)}`;
- }
- return url;
-}
+import { areRecordingsIncomplete } from "./browserSessionQueryUtils";
+import { getRecordingUrl } from "./recordingUrl";
function BrowserSessionVideo() {
const { browserSessionId } = useParams();
@@ -37,9 +30,10 @@ function BrowserSessionVideo() {
enabled: !!browserSessionId,
});
- const isSessionRunning = browserSession?.status === "running";
- // Don't show recordings while session is running - they're incomplete
- const recordings = isSessionRunning ? [] : browserSession?.recordings || [];
+ const recordingsIncomplete = areRecordingsIncomplete(browserSession?.status);
+ const recordings = recordingsIncomplete
+ ? []
+ : browserSession?.recordings || [];
if (isLoading) {
return (
@@ -67,7 +61,7 @@ function BrowserSessionVideo() {
No recordings available
</div>
<div className="text-sm text-gray-400">
- {isSessionRunning
+ {recordingsIncomplete
? "Recordings will be available after the session completes"
: "No recordings were created for this session"}
</div>
@@ -96,7 +90,7 @@ function BrowserSessionVideo() {
{recording.filename || `Recording ${index + 1}`}
{recording.modified_at && (
<span className="ml-2 text-sm text-gray-500">
- ({new Date(recording.modified_at).toLocaleString()})
+ ({basicLocalTimeFormat(recording.modified_at)})
</span>
)}
</h3>
diff --git a/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.test.ts b/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.test.ts
index f61e2863d..d2ee02e55 100644
--- a/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.test.ts
+++ b/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.test.ts
@@ -3,6 +3,8 @@ import { describe, expect, it } from "vitest";
import { getBrowserSessionRefetchIntervalMs } from "./browserSessionQueryUtils";
describe("getBrowserSessionRefetchIntervalMs", () => {
+ const now = Date.parse("2026-07-16T12:00:00.000Z");
+
it("polls while session status is bootstrapping", () => {
expect(getBrowserSessionRefetchIntervalMs(undefined)).toBe(1000);
expect(getBrowserSessionRefetchIntervalMs({ status: "created" })).toBe(
@@ -37,4 +39,72 @@ describe("getBrowserSessionRefetchIntervalMs", () => {
false,
);
});
+
+ it("polls briefly after completion while recordings are unavailable", () => {
+ expect(
+ getBrowserSessionRefetchIntervalMs(
+ {
+ status: "completed",
+ completed_at: "2026-07-16T11:59:00.000Z",
+ recordings: null,
+ },
+ now,
+ ),
+ ).toBe(10_000);
+ });
+
+ it("treats timezone-less completed_at as UTC regardless of runner timezone", () => {
+ expect(
+ getBrowserSessionRefetchIntervalMs(
+ {
+ status: "completed",
+ completed_at: "2026-07-16T11:59:00.000000",
+ recordings: [],
+ },
+ now,
+ ),
+ ).toBe(10_000);
+ });
+
+ it("stops post-terminal polling when completed_at is in the future", () => {
+ expect(
+ getBrowserSessionRefetchIntervalMs(
+ {
+ status: "completed",
+ completed_at: "2026-07-16T12:05:00.000Z",
+ recordings: [],
+ },
+ now,
+ ),
+ ).toBe(false);
+ });
+
+ it.each([
+ [
+ "recording available",
+ {
+ completed_at: "2026-07-16T11:59:00.000Z",
+ recordings: [
+ {
+ checksum: "recording-checksum",
+ filename: "session.webm",
+ modified_at: "2026-07-16T12:00:00.000Z",
+ url: "https://example.test/session.webm",
+ },
+ ],
+ },
+ ],
+ [
+ "window expired",
+ { completed_at: "2026-07-16T11:57:59.999Z", recordings: [] },
+ ],
+ ["completion timestamp missing", { completed_at: null, recordings: [] }],
+ ])("stops post-terminal polling when %s", (_name, state) => {
+ expect(
+ getBrowserSessionRefetchIntervalMs(
+ { status: "completed", ...state },
+ now,
+ ),
+ ).toBe(false);
+ });
});
diff --git a/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.ts b/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.ts
index 5a3cc9f2b..aa8fded3e 100644
--- a/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.ts
+++ b/skyvern-frontend/src/routes/browserSessions/browserSessionQueryUtils.ts
@@ -1,11 +1,21 @@
import { type BrowserSession } from "@/routes/workflows/types/browserSessionTypes";
+import { normalizeUtcTimestamp } from "@/util/timeFormat";
type BrowserSessionReadiness = Partial<
- Pick<BrowserSession, "status" | "browser_address">
->;
+ Pick<BrowserSession, "status" | "browser_address" | "completed_at">
+> & { recordings?: BrowserSession["recordings"] | null };
+
+const POST_TERMINAL_REFETCH_INTERVAL_MS = 10_000;
+const POST_TERMINAL_REFETCH_WINDOW_MS = 2 * 60 * 1000;
+
+// Playwright finalizes recordings at session close; mid-session files are partial.
+function areRecordingsIncomplete(status: string | null | undefined): boolean {
+ return status === "running";
+}
function getBrowserSessionRefetchIntervalMs(
browserSession: BrowserSessionReadiness | undefined,
+ now = Date.now(),
): number | false {
if (!browserSession?.status) {
return 1000;
@@ -22,7 +32,18 @@ function getBrowserSessionRefetchIntervalMs(
) {
return 1000;
}
+ const completedAt = browserSession.completed_at
+ ? Date.parse(normalizeUtcTimestamp(browserSession.completed_at))
+ : Number.NaN;
+ const completedAgoMs = now - completedAt;
+ if (
+ !browserSession.recordings?.length &&
+ completedAgoMs >= 0 &&
+ completedAgoMs < POST_TERMINAL_REFETCH_WINDOW_MS
+ ) {
+ return POST_TERMINAL_REFETCH_INTERVAL_MS;
+ }
return false;
}
-export { getBrowserSessionRefetchIntervalMs };
+export { areRecordingsIncomplete, getBrowserSessionRefetchIntervalMs };
diff --git a/skyvern-frontend/src/routes/browserSessions/recordingUrl.ts b/skyvern-frontend/src/routes/browserSessions/recordingUrl.ts
new file mode 100644
index 000000000..9fdd621b9
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/recordingUrl.ts
@@ -0,0 +1,13 @@
+import { artifactApiBaseUrl } from "@/util/env";
+
+function getRecordingUrl(url: string | null | undefined): string | null {
+ if (!url) {
+ return null;
+ }
+ if (url.startsWith("file://")) {
+ return `${artifactApiBaseUrl}/artifact/recording?path=${encodeURIComponent(url.slice(7))}`;
+ }
+ return url;
+}
+
+export { getRecordingUrl };
diff --git a/skyvern-frontend/src/util/timeFormat.test.ts b/skyvern-frontend/src/util/timeFormat.test.ts
index b8b3a0262..a4dcdebc4 100644
--- a/skyvern-frontend/src/util/timeFormat.test.ts
+++ b/skyvern-frontend/src/util/timeFormat.test.ts
@@ -5,8 +5,29 @@ import {
basicLocalTimeFormat,
basicTimeFormat,
formatExecutionTime,
+ normalizeUtcTimestamp,
} from "./timeFormat";
+describe("normalizeUtcTimestamp", () => {
+ test("appends Z to timezone-less timestamps", () => {
+ expect(normalizeUtcTimestamp("2026-03-04T18:30:00.123456")).toBe(
+ "2026-03-04T18:30:00.123Z",
+ );
+ });
+
+ test("leaves offset-carrying timestamps intact", () => {
+ expect(normalizeUtcTimestamp("2026-03-04T18:30:00+00:00")).toBe(
+ "2026-03-04T18:30:00+00:00",
+ );
+ expect(normalizeUtcTimestamp("2026-03-04T18:30:00-07:00")).toBe(
+ "2026-03-04T18:30:00-07:00",
+ );
+ expect(normalizeUtcTimestamp("2026-03-04T18:30:00Z")).toBe(
+ "2026-03-04T18:30:00Z",
+ );
+ });
+});
+
describe("basicLocalTimeFormat", () => {
test("appends Z to parse a no-suffix UTC timestamp as UTC, not local time", () => {
// Backend returns naive UTC timestamps without 'Z', e.g. "2026-03-04T18:30:00.000000".
diff --git a/skyvern-frontend/src/util/timeFormat.ts b/skyvern-frontend/src/util/timeFormat.ts
index c9894954e..bdb0428db 100644
--- a/skyvern-frontend/src/util/timeFormat.ts
+++ b/skyvern-frontend/src/util/timeFormat.ts
@@ -2,8 +2,9 @@ function normalizeUtcTimestamp(time: string): string {
// Adjust the fractional seconds to milliseconds (3 digits)
time = time.replace(/\.(\d{3})\d*/, ".$1");
- // Append 'Z' to indicate UTC time if not already present
- if (!time.endsWith("Z")) {
+ // Timezone-less timestamps are UTC (the backend serializes naive UTC
+ // datetimes); append 'Z' unless an offset is already present.
+ if (!/(?:Z|[+-]\d{2}:?\d{2})$/.test(time)) {
time += "Z";
}