diff --git a/kez-chat/web/src/routes/AddClaim.svelte b/kez-chat/web/src/routes/AddClaim.svelte index ae5470b..18dc69c 100644 --- a/kez-chat/web/src/routes/AddClaim.svelte +++ b/kez-chat/web/src/routes/AddClaim.svelte @@ -180,12 +180,20 @@ async function saveAndDone() { if (!envelope || !selected) return; - await addClaim({ - id: crypto.randomUUID(), - envelope, - channel: selected.key, - }); - step = "done"; + try { + // $state wraps `envelope` in a deep Proxy; structuredClone (used + // by idb-keyval) can't clone proxies and throws DataCloneError. + // $state.snapshot returns a plain, cloneable object. + await addClaim({ + id: crypto.randomUUID(), + envelope: $state.snapshot(envelope) as SignedClaimEnvelope, + channel: selected.key, + }); + step = "done"; + } catch (e) { + console.error("saveAndDone failed", e); + alert(`Failed to save claim: ${(e as Error).message}`); + } }