From b935995fe6a4b3f901fc061ef0aad4e326745aae Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 9 Jul 2026 20:24:39 +0000 Subject: [PATCH] fix: open NIP-29 group posts in the group chat, not a thread view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tapping a NIP-29 message in Notifications (or the feed) fell through routeFor's `else -> Route.Note`, opening the generic thread view instead of the group chat — unlike every other chat NIP. Mirror the Marmot-group path: when a note is attached to a RelayGroupChannel gatherer, route to Route.RelayGroup (the channel carries the host relay). Add an `h`-tag + provenance-relay fallback for a group-scoped note that isn't attached to a channel yet, so it still opens the chat rather than a thread. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01B5MLY4hq5LXJ2D5WeLRyXj --- .../ui/navigation/routes/RouteMaker.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt index 3591a48368..579b779d5b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/routes/RouteMaker.kt @@ -46,6 +46,8 @@ import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent import com.vitorpamplona.quartz.nip28PublicChat.base.IsInPublicChatChannel import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent import com.vitorpamplona.quartz.nip29RelayGroups.GroupId +import com.vitorpamplona.quartz.nip29RelayGroups.groupId +import com.vitorpamplona.quartz.nip29RelayGroups.isGroupScoped import com.vitorpamplona.quartz.nip34Git.repository.GitRepositoryEvent import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent @@ -73,8 +75,25 @@ fun routeFor( return Route.MarmotGroupChat(marmotGroup.nostrGroupId) } + // NIP-29 relay-group content (kind 9 chat, 11 thread, 1111 comment, polls) should open the + // group chat screen — like every other chat NIP — not the generic thread view it would fall + // through to. A consumed group message is attached to its RelayGroupChannel (which carries the + // host relay), so route via that; fall back to the note's `h` tag + provenance relay otherwise. + val relayGroup = note.inGatherers?.firstNotNullOfOrNull { it as? RelayGroupChannel } + if (relayGroup != null) { + return routeFor(relayGroup) + } + val noteEvent = note.event ?: return Route.EventRedirect(note.idHex) + if (noteEvent.isGroupScoped()) { + val groupId = noteEvent.groupId() + val hostRelay = note.relays.firstOrNull() + if (groupId != null && hostRelay != null) { + return routeFor(GroupId(groupId, hostRelay)) + } + } + return routeFor(noteEvent, loggedIn) }