Skip to content

Automate browser based workflows with AI

feat(SKY-10862): show which run occupies a browser session (#6691)

Celal Zamanoğlu3f4193844d7b
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx
index 93c9c2b86..9bd5252c1 100644
--- a/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSession.tsx
@@ -34,6 +34,7 @@ import {
import { getBrowserSessionRefetchIntervalMs } from "./browserSessionQueryUtils";
import { BrowserSessionDownloads } from "./BrowserSessionDownloads";
+import { BrowserSessionOccupiedBy } from "./BrowserSessionOccupiedBy";
import { BrowserSessionVideo } from "./BrowserSessionVideo";
import { BrowserSessionStream } from "./BrowserSessionStream";
import { BrowserSessionWorkflowRuns } from "./BrowserSessionWorkflowRuns";
@@ -157,6 +158,11 @@ function BrowserSession() {
/>
</div>
)}
+ {browserSession.runnable_id && (
+ <BrowserSessionOccupiedBy
+ runnableId={browserSession.runnable_id}
+ />
+ )}
</div>
)}
</div>
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionOccupiedBy.test.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSessionOccupiedBy.test.tsx
new file mode 100644
index 000000000..57d9deae9
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionOccupiedBy.test.tsx
@@ -0,0 +1,38 @@
+// @vitest-environment jsdom
+
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { MemoryRouter } from "react-router-dom";
+
+import { BrowserSessionOccupiedBy } from "./BrowserSessionOccupiedBy";
+
+vi.mock("@/routes/workflows/editor/Workspace", () => ({
+ CopyText: () => null,
+}));
+
+afterEach(cleanup);
+
+function renderBadge(runnableId: string) {
+ render(
+ <MemoryRouter
+ future={{ v7_relativeSplatPath: true, v7_startTransition: true }}
+ >
+ <BrowserSessionOccupiedBy runnableId={runnableId} />
+ </MemoryRouter>,
+ );
+}
+
+describe("BrowserSessionOccupiedBy", () => {
+ it("links a workflow run to its run detail page", () => {
+ renderBadge("wr_123");
+ expect(screen.getByText("In use by")).toBeTruthy();
+ const link = screen.getByRole("link", { name: "wr_123" });
+ expect(link.getAttribute("href")).toBe("/runs/wr_123");
+ });
+
+ it("links a task run to its run detail page", () => {
+ renderBadge("tsk_456");
+ const link = screen.getByRole("link", { name: "tsk_456" });
+ expect(link.getAttribute("href")).toBe("/runs/tsk_456");
+ });
+});
diff --git a/skyvern-frontend/src/routes/browserSessions/BrowserSessionOccupiedBy.tsx b/skyvern-frontend/src/routes/browserSessions/BrowserSessionOccupiedBy.tsx
new file mode 100644
index 000000000..c67d7c55b
--- /dev/null
+++ b/skyvern-frontend/src/routes/browserSessions/BrowserSessionOccupiedBy.tsx
@@ -0,0 +1,20 @@
+import { Link } from "react-router-dom";
+
+import { CopyText } from "@/routes/workflows/editor/Workspace";
+
+function BrowserSessionOccupiedBy({ runnableId }: { runnableId: string }) {
+ return (
+ <div className="flex items-center justify-end gap-1">
+ <span className="text-xs opacity-75">In use by</span>
+ <Link
+ to={`/runs/${runnableId}`}
+ className="max-w-[20rem] truncate font-mono text-xs text-primary underline-offset-4 hover:underline"
+ >
+ {runnableId}
+ </Link>
+ <CopyText className="opacity-75 hover:opacity-100" text={runnableId} />
+ </div>
+ );
+}
+
+export { BrowserSessionOccupiedBy };