From 4e5dbed3d26307efd151f28eaed9c67b3ac64448 Mon Sep 17 00:00:00 2001 From: filemon Date: Mon, 6 Apr 2026 03:36:20 -0300 Subject: [PATCH] Fix all Kind 11125 write paths to preserve profile content JSON Critical safety fix: 9 out of 12 Kind 11125 publish paths were hardcoding content: '' which would silently erase any structured content (daily missions data) stored in the profile event. Every write path that updates an existing profile now preserves the existing event content via profile.event.content instead of overwriting with empty string. Fixed locations: - useBlobbiOnboarding.ts: reroll preview (line 378) and adopt (476) - BlobbiHatchingCeremony.tsx: add egg to has[] (302) and mark onboarding done (501) - useBlobbiMigration.ts: legacy migration (190) - useBlobbonautProfileNormalization.ts: tag normalization (85) - BlobbiPage.tsx: auto-fix onboardingDone (547) and companion toggle (1183) - useBlobbiPurchaseItem.ts: shop purchase (89) The only two paths that still use content: '' are initial profile creation flows (useBlobbiOnboarding auto-create and BlobbiHatchingCeremony silent setup) where no previous event exists. The useClaimMissionReward path already uses mergeProfileContent for proper read-modify-write of the content JSON. --- src/blobbi/core/hooks/useBlobbiMigration.ts | 2 +- src/blobbi/onboarding/components/BlobbiHatchingCeremony.tsx | 4 ++-- src/blobbi/onboarding/hooks/useBlobbiOnboarding.ts | 4 ++-- src/blobbi/shop/hooks/useBlobbiPurchaseItem.ts | 2 +- src/hooks/useBlobbonautProfileNormalization.ts | 2 +- src/pages/BlobbiPage.tsx | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/blobbi/core/hooks/useBlobbiMigration.ts b/src/blobbi/core/hooks/useBlobbiMigration.ts index a2817723..6101fb4c 100644 --- a/src/blobbi/core/hooks/useBlobbiMigration.ts +++ b/src/blobbi/core/hooks/useBlobbiMigration.ts @@ -188,7 +188,7 @@ export function useBlobbiMigration() { const profileEvent = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: profile.event.content, tags: profileTags, }); diff --git a/src/blobbi/onboarding/components/BlobbiHatchingCeremony.tsx b/src/blobbi/onboarding/components/BlobbiHatchingCeremony.tsx index 4cc2892e..abc6c1d2 100644 --- a/src/blobbi/onboarding/components/BlobbiHatchingCeremony.tsx +++ b/src/blobbi/onboarding/components/BlobbiHatchingCeremony.tsx @@ -300,7 +300,7 @@ export function BlobbiHatchingCeremony({ const updatedProfileEvent = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: currentProfile?.event.content ?? '', tags: updatedTags, }); @@ -499,7 +499,7 @@ export function BlobbiHatchingCeremony({ }); const profileEvent = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: currentProfile.event.content, tags: updatedTags, }); updateProfileEvent(profileEvent); diff --git a/src/blobbi/onboarding/hooks/useBlobbiOnboarding.ts b/src/blobbi/onboarding/hooks/useBlobbiOnboarding.ts index 030ee3da..719992db 100644 --- a/src/blobbi/onboarding/hooks/useBlobbiOnboarding.ts +++ b/src/blobbi/onboarding/hooks/useBlobbiOnboarding.ts @@ -376,7 +376,7 @@ export function useBlobbiOnboarding({ const profileEvent = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: profile.event.content, tags: updatedTags, }); @@ -474,7 +474,7 @@ export function useBlobbiOnboarding({ const profileEvent = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: profile.event.content, tags: updatedProfileTags, }); diff --git a/src/blobbi/shop/hooks/useBlobbiPurchaseItem.ts b/src/blobbi/shop/hooks/useBlobbiPurchaseItem.ts index 9cb1efd8..72a61ef3 100644 --- a/src/blobbi/shop/hooks/useBlobbiPurchaseItem.ts +++ b/src/blobbi/shop/hooks/useBlobbiPurchaseItem.ts @@ -87,7 +87,7 @@ export function useBlobbiPurchaseItem(currentProfile: BlobbonautProfile | null) // Publish updated profile event const event = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: currentProfile.event.content, tags: updatedTags, }); diff --git a/src/hooks/useBlobbonautProfileNormalization.ts b/src/hooks/useBlobbonautProfileNormalization.ts index 78fc68d3..f2519e9e 100644 --- a/src/hooks/useBlobbonautProfileNormalization.ts +++ b/src/hooks/useBlobbonautProfileNormalization.ts @@ -83,7 +83,7 @@ export function useBlobbonautProfileNormalization({ // Always publish to the NEW kind (11125), regardless of source kind const event = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: profile.event.content, tags: normalizedTags, }); diff --git a/src/pages/BlobbiPage.tsx b/src/pages/BlobbiPage.tsx index e5f07eb9..cab96ae2 100644 --- a/src/pages/BlobbiPage.tsx +++ b/src/pages/BlobbiPage.tsx @@ -545,7 +545,7 @@ function BlobbiContent() { }); publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: profile.event.content, tags: updatedTags, }).then(event => { updateProfileEvent(event); @@ -1181,7 +1181,7 @@ function BlobbiDashboard({ const event = await publishEvent({ kind: KIND_BLOBBONAUT_PROFILE, - content: '', + content: profile.event.content, tags: updatedTags, });