From 36ce4c6d442b14d319eaf602f74495cceceb3e49 Mon Sep 17 00:00:00 2001 From: Diego Imbert Date: Sun, 17 May 2026 00:31:44 +0200 Subject: [PATCH] fix(frontend): snapshot UserDraft proxy before structuredClone in resource save `states[ws].draft` is now a Svelte $state proxy (it flows through UserDraft's useLocalStorageValue cell). `structuredClone` can't clone a proxy and threw "Failed to execute 'structuredClone' on 'Window'", blocking resource saves. Snapshot to a plain object via `$state.snapshot` before assigning the dirty baseline. --- frontend/src/lib/components/ResourceEditor.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/ResourceEditor.svelte b/frontend/src/lib/components/ResourceEditor.svelte index ef1bf2b0a4..5f1ed4f423 100644 --- a/frontend/src/lib/components/ResourceEditor.svelte +++ b/frontend/src/lib/components/ResourceEditor.svelte @@ -299,8 +299,11 @@ }) } // Saved on the backend — drop the local autosave for this - // workspace and refresh the dirty baseline. - initialStates[ws] = structuredClone(s) + // workspace and refresh the dirty baseline. `s` is the + // UserDraft handle's draft, a Svelte $state proxy; + // `structuredClone` can't clone a proxy, so snapshot it to a + // plain object first. + initialStates[ws] = $state.snapshot(s) as ResourceState UserDraft.remove('resource', initialPath ?? '', { workspace: ws }) } sendUserToast(