From af7b862e0239f5646a96f1c7bf9af4c7e2c11b25 Mon Sep 17 00:00:00 2001 From: Jonathan Dobson Date: Wed, 9 Jul 2025 18:29:50 -0400 Subject: [PATCH] add browser session to debug store; use new cancel endpoint from #5450 (#2914) --- .../editor/nodes/components/NodeHeader.tsx | 5 ++++- .../src/store/DebugStoreContext.tsx | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx index 89c3c950..cbbd53e2 100644 --- a/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx +++ b/skyvern-frontend/src/routes/workflows/editor/nodes/components/NodeHeader.tsx @@ -267,9 +267,12 @@ function NodeHeader({ const cancelBlock = useMutation({ mutationFn: async () => { + const browserSessionId = + debugStore.getCurrentBrowserSessionId() ?? + ""; const client = await getClient(credentialGetter); return client - .post(`/workflows/runs/${workflowRunId}/cancel`) + .post(`/runs/${browserSessionId}/workflow_run/${workflowRunId}/cancel/`) .then((response) => response.data); }, onSuccess: () => { diff --git a/skyvern-frontend/src/store/DebugStoreContext.tsx b/skyvern-frontend/src/store/DebugStoreContext.tsx index f774aa7c..9062a3ac 100644 --- a/skyvern-frontend/src/store/DebugStoreContext.tsx +++ b/skyvern-frontend/src/store/DebugStoreContext.tsx @@ -1,5 +1,6 @@ import React, { createContext, useMemo } from "react"; import { useLocation } from "react-router-dom"; +import { lsKeys } from "@/util/env"; function useIsDebugMode() { const location = useLocation(); @@ -9,8 +10,23 @@ function useIsDebugMode() { ); } +function getCurrentBrowserSessionId() { + const stored = localStorage.getItem(lsKeys.optimisticBrowserSession); + let browserSessionId: string | null = null; + try { + const parsed = JSON.parse(stored ?? ""); + const { browser_session_id } = parsed; + browserSessionId = browser_session_id as string; + } catch { + // pass + } + + return browserSessionId; +} + export type DebugStoreContextType = { isDebugMode: boolean; + getCurrentBrowserSessionId: () => string | null; }; export const DebugStoreContext = createContext< @@ -23,7 +39,9 @@ export const DebugStoreProvider: React.FC<{ children: React.ReactNode }> = ({ const isDebugMode = useIsDebugMode(); return ( - + {children} );