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.
This commit is contained in:
Diego Imbert
2026-05-17 00:31:44 +02:00
parent 3ba62c0ee2
commit 36ce4c6d44
@@ -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(