From ed23f81f3a7845793eff20197eca4ea7b1c65bc1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 20 Jun 2026 00:45:43 +0000 Subject: [PATCH] fix: refresh NIP-82 app version chip when a new release arrives The Apps feed version chip read the latest SoftwareReleaseEvent (kind 30063) once via a produceState keyed only on the app event id. NIP-82 releases point back to the app through an `i` tag rather than an `a` tag, so they are never indexed as replies to the app note and never ping its flows. As a result a newer release arriving while the card was visible left the chip showing the old version. Re-scan LocalCache on every new-event bundle (the same pattern used by the calendar RSVP/calendar scans) so the chip updates without a manual refresh. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01EbCTsBoGtBCJ1rTKCcar6w --- .../amethyst/ui/note/types/SoftwareApp.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt index 65f9e9495d..af85b59512 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/SoftwareApp.kt @@ -189,9 +189,12 @@ fun RenderSoftwareApplication( /** * Looks up the latest NIP-82 [SoftwareReleaseEvent] for [app] from - * [LocalCache] and exposes the version string. Recomputes on event identity - * change; relay-driven recompositions of the surrounding feed will pick up - * newer releases via re-keying. + * [LocalCache] and exposes the version string. Releases (kind 30063) are + * separate events that point back to the app via an `i` tag, so they are not + * indexed as replies to the app note and never ping its flows. We therefore + * re-scan on every [LocalCache.live] new-event bundle so a newer release that + * arrives while the card is visible updates the version chip without a manual + * refresh. */ @Composable fun produceLatestReleaseVersion(app: SoftwareApplicationEvent) = @@ -200,6 +203,16 @@ fun produceLatestReleaseVersion(app: SoftwareApplicationEvent) = withContext(Dispatchers.Default) { findLatestNip82Release(app)?.version() } + + LocalCache.live.newEventBundles.collect { + val newVersion = + withContext(Dispatchers.Default) { + findLatestNip82Release(app)?.version() + } + if (newVersion != value) { + value = newVersion + } + } } fun findLatestNip82Release(app: SoftwareApplicationEvent): SoftwareReleaseEvent? {