Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Warn the user when they are quitting the workflow page (#1172)
Shuchang Zhengb768ca0e86cc
diff --git a/skyvern-frontend/src/hooks/useShouldNotifyWhenClosingTab.ts b/skyvern-frontend/src/hooks/useShouldNotifyWhenClosingTab.tsnew file mode 100644index 000000000..b73cab15d--- /dev/null+++ b/skyvern-frontend/src/hooks/useShouldNotifyWhenClosingTab.ts@@ -0,0 +1,24 @@+import { useEffect } from "react";++function useShouldNotifyWhenClosingTab() {+ useEffect(() => {+ function f(event: BeforeUnloadEvent) {+ // this function is here to have a stable reference only++ // Recommended+ event.preventDefault();++ // Included for legacy support, e.g. Chrome/Edge < 119+ // refer to https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event+ event.returnValue = true;+ }++ window.addEventListener("beforeunload", f);++ return () => {+ window.removeEventListener("beforeunload", f);+ };+ }, []);+}++export { useShouldNotifyWhenClosingTab };diff --git a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsxindex 81fe4c3c4..6426d3583 100644--- a/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx+++ b/skyvern-frontend/src/routes/workflows/editor/FlowRenderer.tsx@@ -67,6 +67,7 @@ import { Button } from "@/components/ui/button";import { ReloadIcon } from "@radix-ui/react-icons";import { isLoopNode, LoopNode } from "./nodes/LoopNode/types";import { isTaskNode } from "./nodes/TaskNode/types";+import { useShouldNotifyWhenClosingTab } from "@/hooks/useShouldNotifyWhenClosingTab";function convertToParametersYAML(parameters: ParametersState,@@ -190,6 +191,7 @@ function FlowRenderer({const [title, setTitle] = useState(initialTitle);const nodesInitialized = useNodesInitialized();const { hasChanges, setHasChanges } = useWorkflowHasChangesStore();+ useShouldNotifyWhenClosingTab();const blocker = useBlocker(({ currentLocation, nextLocation }) => {return hasChanges && nextLocation.pathname !== currentLocation.pathname;});