From 8fd95474cb7dadcaba62b9ca63245b50374aa218 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 10 May 2026 12:31:18 +0000 Subject: [PATCH] fix(pipeline): snapshot live draft writes at persist time so they survive reload --- .../(logged)/pipeline/[folder]/+page.svelte | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/(root)/(logged)/pipeline/[folder]/+page.svelte b/frontend/src/routes/(root)/(logged)/pipeline/[folder]/+page.svelte index 337666ee7e..cb89947738 100644 --- a/frontend/src/routes/(root)/(logged)/pipeline/[folder]/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/pipeline/[folder]/+page.svelte @@ -183,7 +183,31 @@ let persistTimer: number | undefined = undefined $effect(() => { // Track deps explicitly so Svelte 5 re-runs on mutation. - const serialized = Array.from(drafts.entries()) + // For the active draft, also snapshot the latest live body writes + // at serialize time. Without this, edits made since the last + // pane-transition (the cleanup that calls onDraftPersist) are + // lost on reload — the draft restores with stale `outputAssets` + // and the graph drops the corresponding edges until the user + // re-opens the draft and types something new. + const liveWritesSnapshot = + liveBodyAssets.scriptPath != undefined && drafts.has(liveBodyAssets.scriptPath) + ? liveBodyAssets.assets + .filter((a) => { + const at = a.access_type ?? a.alt_access_type + return at === 'w' || at === 'rw' + }) + .map((a) => ({ kind: a.kind, path: a.path })) + : undefined + const liveWritesPath = liveBodyAssets.scriptPath + const serialized = Array.from(drafts.entries()).map(([p, d]) => { + if (liveWritesSnapshot != undefined && liveWritesPath === p) { + return [ + p, + { ...d, outputAssets: liveWritesSnapshot.length > 0 ? liveWritesSnapshot : undefined } + ] as [string, Draft] + } + return [p, d] as [string, Draft] + }) const activePath = activeDraftPath const key = storageKey untrack(() => {