From 8416afd965c7b0075595f87be707332f705d9a9a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 22 Apr 2026 19:12:19 +0000 Subject: [PATCH] debug(marmot): log removeMarmotGroupMember + syncMetadataTo transitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bug report: after tapping Remove on the Marmot Group Info screen, the target npub stays in the member list, and the only log line is the round-tripped kind:445 hitting the "Duplicate" branch in GroupEventHandler.add. The author-side path (Account.removeMarmotGroupMember → MarmotManager.removeMember → syncMetadataTo → publish) has no logging, so there's no way to tell which step broke — the MLS tree mutation, the local member-list push to chatroom.members, or the UI recomposition. Mirror the addMarmotGroupMember logging style on removeMarmotGroupMember (entry, no-op guards, built commit id, publish) so we can see whether the author path even runs end-to-end, and have syncMetadataTo log the group id and the previous→new member count so the StateFlow update becomes observable. No behavior change. --- .../vitorpamplona/amethyst/model/Account.kt | 22 +++++++++++++++++-- .../amethyst/commons/marmot/MarmotManager.kt | 5 +++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index d26302f4f..050bf1ae1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -2313,12 +2313,30 @@ class Account( targetLeafIndex: Int, groupRelays: Set, ) { - val manager = marmotManager ?: return - if (!isWriteable()) return + Log.d("MarmotDbg") { + "removeMarmotGroupMember: group=${nostrGroupId.take(8)}… targetLeafIndex=$targetLeafIndex " + + "groupRelays=${groupRelays.size}" + } + val manager = + marmotManager ?: run { + Log.w("MarmotDbg") { "removeMarmotGroupMember: marmotManager is NULL — no-op" } + return + } + if (!isWriteable()) { + Log.w("MarmotDbg") { "removeMarmotGroupMember: account is not writeable — no-op" } + return + } val outbound = manager.removeMember(nostrGroupId, targetLeafIndex) + Log.d("MarmotDbg") { + "removeMarmotGroupMember: built commit kind=${outbound.signedEvent.kind} id=${outbound.signedEvent.id.take(8)}…" + } val chatroom = marmotGroupList.getOrCreateGroup(nostrGroupId) manager.syncMetadataTo(nostrGroupId, chatroom) + Log.d("MarmotDbg") { + "removeMarmotGroupMember: publishing commit id=${outbound.signedEvent.id.take(8)}… " + + "to ${groupRelays.size} relay(s): ${groupRelays.map { it.url }}" + } client.publish(outbound.signedEvent, groupRelays) } diff --git a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt index d8a509ab8..06a132c53 100644 --- a/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt +++ b/commons/src/commonMain/kotlin/com/vitorpamplona/amethyst/commons/marmot/MarmotManager.kt @@ -566,9 +566,14 @@ class MarmotManager( chatroom.adminPubkeys.value = metadata.adminPubkeys chatroom.relays.value = metadata.relays } + val previousCount = chatroom.members.value.size val members = memberPubkeys(nostrGroupId) chatroom.members.value = members chatroom.memberCount.value = members.size + Log.d("MarmotDbg") { + "syncMetadataTo: group=${nostrGroupId.take(8)}… members $previousCount→${members.size} " + + "(leafs=${members.map { it.leafIndex }})" + } } }