From 9f79be128cc6335906dccd97d94f36253bd95011 Mon Sep 17 00:00:00 2001 From: claudespiral Date: Tue, 3 Feb 2026 21:13:06 -0500 Subject: [PATCH] fix: populate replyMetadata for DM replies E2E encrypted messages only contain repliesToMessageId - the relay hub cannot do server-side joins. This populates replyMetadata by looking up the parent message locally when saving, enabling the existing reply display UI to show 'Replying to X'. Mirrors the pattern used by Farcaster DMs where inReplyTo context comes from the API (server has access to message content). --- services/storage/mmkvAdapter.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/services/storage/mmkvAdapter.ts b/services/storage/mmkvAdapter.ts index 236229e..3fcca21 100644 --- a/services/storage/mmkvAdapter.ts +++ b/services/storage/mmkvAdapter.ts @@ -123,6 +123,19 @@ export class MMKVAdapter implements StorageAdapter { const data = storage.getString(key); const messages: Message[] = data ? JSON.parse(data) : []; + // Populate replyMetadata for replies (E2E encrypted, so client must do this lookup) + const content = message.content as Record | undefined; + if (content?.repliesToMessageId && !message.replyMetadata) { + const parentMessage = messages.find((m) => m.messageId === content.repliesToMessageId); + const parentContent = parentMessage?.content as Record | undefined; + if (parentContent?.senderId) { + message.replyMetadata = { + parentAuthor: parentContent.senderId as string, + parentChannelId: parentMessage.channelId, + }; + } + } + // Update or add message const existingIdx = messages.findIndex((m) => m.messageId === message.messageId); if (existingIdx >= 0) {