From 079ebef72b3b8cad799e54fb88fc4f8fa1863d0d Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Tue, 12 May 2026 14:13:51 +0200 Subject: [PATCH] fix(frontend): don't UserDraft.remove flows while route is still mounted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /flows/add and /flows/edit routes drive FlowBuilder from a flowStore whose getter reads flowHandle.draft directly. Calling UserDraft.remove synchronously before goto() therefore wiped the in-memory entry, made flowStore.val collapse to emptyFlow(), and tripped UnsavedConfirmationModal against the just-saved value — even though the deploy/save-draft itself succeeded. Drop those explicit removes in onSaveInitial, /add onDeploy, and /edit onDeploy. The empty-path entry self-cleans on unmount via onDestroy ref counting; for the non-empty edit path the next visit's load-time diff will silently overwrite localStorage when the local autosave matches the deployed value. Restore-draft/restore-deployed keep their explicit remove because they navigate to the same route (no modal) and loadFlow immediately rehydrates the handle. Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/routes/(root)/(logged)/flows/add/+page.svelte | 2 -- .../(root)/(logged)/flows/edit/[...path]/+page.svelte | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/routes/(root)/(logged)/flows/add/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/add/+page.svelte index cca44fef67..8ab3393924 100644 --- a/frontend/src/routes/(root)/(logged)/flows/add/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/add/+page.svelte @@ -174,11 +174,9 @@ { - UserDraft.remove('flow', '') goto(`/flows/edit/${e.path}?selected=${e.id}`) }} onDeploy={(e) => { - UserDraft.remove('flow', '') goto(`/flows/get/${e.path}?workspace=${$workspaceStore}`) }} onDetails={(e) => { diff --git a/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte b/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte index bcae4935e6..788f957ed3 100644 --- a/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/flows/edit/[...path]/+page.svelte @@ -270,7 +270,11 @@ {:else} { - UserDraft.remove('flow', flowDraftPath) + // Don't UserDraft.remove here — the route's flowStore reads the + // handle's draft directly, so clearing it before goto would blank + // the flow value and trip UnsavedConfirmationModal. The entry's + // ref count drops on unmount and the next visit's load-time diff + // will silently overwrite localStorage with the deployed value. goto(`/flows/get/${e.path}?workspace=${$workspaceStore}`) }} onDetails={(e) => {