From 3892ade0a3ad25f991ade036c6d31caa8971fda5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 19:26:13 +0000 Subject: [PATCH 1/2] fix(concord): render imeta-only images in the chat feed too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The earlier imeta-only fix patched RenderChat (the thread-view path), but the Concord channel feed renders messages through ChatMessageCompose → RenderRegularTextNote, which handed the raw decrypted content straight to the media renderer. So a NIP-C7/Concord image message from an interop client (e.g. Ditto/Soapbox Armada) — empty content, image carried only as a NIP-92 `imeta` tag — never rendered in the feed, even though the encrypted blob's key/nonce were already registered for transparent decryption at ingest. Extract appendMissingImetaUrls into a shared helper (ui/note/types/ ImetaContent.kt) and apply it in RenderRegularTextNote against the decrypted content, symmetric to the RenderChat fix and to ChannelChat.imageMessage which appends the URL on send. Normal messages whose imeta URLs are already inline are untouched. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01SF85F6GHu7aQZYpTGNYdWk --- .../amethyst/ui/note/types/Chat.kt | 17 +------ .../amethyst/ui/note/types/ImetaContent.kt | 47 +++++++++++++++++++ .../chats/feed/types/RenderRegularTextNote.kt | 10 +++- 3 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Chat.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Chat.kt index c516dc6b9a..a95b8763fe 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Chat.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Chat.kt @@ -41,10 +41,8 @@ import com.vitorpamplona.amethyst.ui.note.elements.DisplayUncitedHashtags import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer import com.vitorpamplona.amethyst.ui.theme.placeholderText -import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip01Core.tags.hashtags.hasHashtags import com.vitorpamplona.quartz.nip10Notes.BaseNoteEvent -import com.vitorpamplona.quartz.nip92IMeta.imetas @Composable fun RenderChat( @@ -66,7 +64,7 @@ fun RenderChat( // from the content so those attachments render — symmetric to ChannelChat.imageMessage, which // appends the URL on send. Encrypted-blob key/nonce are already registered by URL, so the shared // pipeline fetches and decrypts them transparently. - val displayContent = remember(noteEvent) { appendMissingImetaUrls(noteEvent) } + val displayContent = remember(noteEvent) { appendMissingImetaUrls(noteEvent.content, noteEvent) } // A boosted note inside a zap/nutzap/onchain activity card is always shown as a // compact 2-line preview, even when the logged-in user is only a zap-split @@ -129,16 +127,3 @@ fun RenderChat( } } } - -/** - * Returns [event]'s content with every NIP-92 `imeta` URL that is not already present appended on its - * own line, so an attachment carried only as an `imeta` tag (empty/incomplete content) still renders. - * Returns the original content unchanged when every imeta URL is already inline (the common case), so - * normal messages are untouched. - */ -private fun appendMissingImetaUrls(event: Event): String { - val content = event.content - val missing = event.imetas().map { it.url }.filter { it.isNotBlank() && !content.contains(it) } - if (missing.isEmpty()) return content - return (listOf(content) + missing).filter { it.isNotBlank() }.joinToString("\n") -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt new file mode 100644 index 0000000000..c80843e15a --- /dev/null +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Vitor Pamplona + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the + * Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.vitorpamplona.amethyst.ui.note.types + +import com.vitorpamplona.quartz.nip01Core.core.Event +import com.vitorpamplona.quartz.nip92IMeta.imetas + +/** + * Returns [content] with every NIP-92 `imeta` URL on [event] that is not already present appended on + * its own line, so an attachment carried only as an `imeta` tag (empty/incomplete content) still + * renders. The shared media renderer only shows media whose URL appears in the text, but some + * NIP-C7/Concord clients (e.g. Ditto/Soapbox Armada) attach an image purely as an `imeta` tag and + * leave the content empty — symmetric to + * [com.vitorpamplona.quartz.concord.cord03Channels.ChannelChat.imageMessage], which appends the URL + * on send. Encrypted-blob key/nonce are already registered by URL, so the shared pipeline fetches and + * decrypts them transparently. + * + * Returns [content] unchanged when [event] is null or every imeta URL is already inline (the common + * case), so normal messages are untouched. + */ +fun appendMissingImetaUrls( + content: String, + event: Event?, +): String { + if (event == null) return content + val missing = event.imetas().map { it.url }.filter { it.isNotBlank() && !content.contains(it) } + if (missing.isEmpty()) return content + return (listOf(content) + missing).filter { it.isNotBlank() }.joinToString("\n") +} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderRegularTextNote.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderRegularTextNote.kt index ba32f860f2..df8138c44a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderRegularTextNote.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/feed/types/RenderRegularTextNote.kt @@ -33,6 +33,7 @@ import com.vitorpamplona.amethyst.ui.components.SensitivityWarning import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.note.LoadDecryptedContentOrNull +import com.vitorpamplona.amethyst.ui.note.types.appendMissingImetaUrls import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.stringRes @@ -53,8 +54,15 @@ fun RenderRegularTextNote( ) { val tags = remember(note.event) { note.event?.tags?.toImmutableListOfLists() ?: EmptyTagList } + // Some NIP-C7/Concord clients (e.g. Ditto/Soapbox Armada) attach an image purely as a + // NIP-92 `imeta` tag and leave the content empty. The shared renderer only shows media + // whose URL appears in the text, so append any imeta URL missing from the (decrypted) + // content — encrypted-blob key/nonce are already registered by URL, so the shared + // pipeline fetches and decrypts them transparently. + val displayContent = remember(note.event, eventContent) { appendMissingImetaUrls(eventContent, note.event) } + TranslatableRichTextViewer( - content = eventContent, + content = displayContent, canPreview = canPreview, quotesLeft = if (innerQuote) 0 else 1, modifier = Modifier, From 00e5443247707b6406c2a86620d997f19ad738ee Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 15 Jul 2026 19:53:36 +0000 Subject: [PATCH 2/2] fix(concord): only fill content from imeta URLs when content is blank Narrow appendMissingImetaUrls to fire only when the message content is blank: in that case return the imeta URLs joined one per line, otherwise leave the content exactly as-is. A message that already carries text is never rewritten, so inline URLs and ordering are preserved untouched. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01SF85F6GHu7aQZYpTGNYdWk --- .../amethyst/ui/note/types/ImetaContent.kt | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt index c80843e15a..8ddd7facc2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/ImetaContent.kt @@ -24,24 +24,23 @@ import com.vitorpamplona.quartz.nip01Core.core.Event import com.vitorpamplona.quartz.nip92IMeta.imetas /** - * Returns [content] with every NIP-92 `imeta` URL on [event] that is not already present appended on - * its own line, so an attachment carried only as an `imeta` tag (empty/incomplete content) still - * renders. The shared media renderer only shows media whose URL appears in the text, but some - * NIP-C7/Concord clients (e.g. Ditto/Soapbox Armada) attach an image purely as an `imeta` tag and - * leave the content empty — symmetric to + * When [content] is blank, returns [event]'s NIP-92 `imeta` URLs joined one per line so an attachment + * carried only as an `imeta` tag (empty content) still renders. The shared media renderer only shows + * media whose URL appears in the text, but some NIP-C7/Concord clients (e.g. Ditto/Soapbox Armada) + * attach an image purely as an `imeta` tag and leave the content empty — symmetric to * [com.vitorpamplona.quartz.concord.cord03Channels.ChannelChat.imageMessage], which appends the URL * on send. Encrypted-blob key/nonce are already registered by URL, so the shared pipeline fetches and * decrypts them transparently. * - * Returns [content] unchanged when [event] is null or every imeta URL is already inline (the common - * case), so normal messages are untouched. + * Returns [content] unchanged whenever it is non-blank (the common case) or [event] is null / carries + * no imeta URLs, so any message that already has text is untouched. */ fun appendMissingImetaUrls( content: String, event: Event?, ): String { - if (event == null) return content - val missing = event.imetas().map { it.url }.filter { it.isNotBlank() && !content.contains(it) } - if (missing.isEmpty()) return content - return (listOf(content) + missing).filter { it.isNotBlank() }.joinToString("\n") + if (event == null || content.isNotBlank()) return content + val urls = event.imetas().map { it.url }.filter { it.isNotBlank() } + if (urls.isEmpty()) return content + return urls.joinToString("\n") }