From 4865422ddc4fb7c5c73307497092cdd63d5e2c0f Mon Sep 17 00:00:00 2001 From: shrimbly Date: Tue, 10 Mar 2026 21:39:46 +1300 Subject: [PATCH] feat: warn before closing tab with unsaved workflow changes Add beforeunload handler that prompts the user when they try to close the tab or navigate away while there are unsaved changes. Co-Authored-By: Claude Opus 4.6 --- src/app/page.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/app/page.tsx b/src/app/page.tsx index 0d0dd081..b5575860 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -19,6 +19,16 @@ export default function Home() { return () => cleanupAutoSave(); }, [initializeAutoSave, cleanupAutoSave]); + useEffect(() => { + const handleBeforeUnload = (e: BeforeUnloadEvent) => { + if (useWorkflowStore.getState().hasUnsavedChanges) { + e.preventDefault(); + } + }; + window.addEventListener("beforeunload", handleBeforeUnload); + return () => window.removeEventListener("beforeunload", handleBeforeUnload); + }, []); + return (