fix(kez-chat/web): snapshot envelope before storing in IndexedDB

Save claim was silently failing — button click did nothing. Cause:
\`envelope\` lives in \$state, which wraps the value in a deep Proxy;
idb-keyval calls structuredClone internally, which can't clone proxies
and throws DataCloneError. Without a try/catch the error vanished into
the console and the step transition never ran.

- Pass \$state.snapshot(envelope) to addClaim so IDB sees a plain object.
- Wrap in try/catch + alert so future IDB failures surface to the user
  instead of dying silently.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Jason Tudisco 2026-05-25 13:18:33 -06:00
parent 17d68dbb75
commit 8622da2ba4

View File

@ -180,12 +180,20 @@
async function saveAndDone() { async function saveAndDone() {
if (!envelope || !selected) return; if (!envelope || !selected) return;
await addClaim({ try {
id: crypto.randomUUID(), // $state wraps `envelope` in a deep Proxy; structuredClone (used
envelope, // by idb-keyval) can't clone proxies and throws DataCloneError.
channel: selected.key, // $state.snapshot returns a plain, cloneable object.
}); await addClaim({
step = "done"; 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}`);
}
} }
</script> </script>