fix(nests): evict author from prior room when presence moves to a new room

kind-10312 is replaceable per author, but the room a presence points to
(`a`-tag) can change when a speaker hops between rooms. The replaceable
cache only swaps the addressable's content -- it doesn't know which channel
the old version was attached to, so the prior room kept the stale entry in
both `notes` and the new `presenceNotes` index. NestsFeedFilter would then
falsely surface the prior room as "live" via that author until the entry
dropped out of the freshness window.

Capture the prior room from the existing addressable before consumeBaseReplaceable
swaps it. When the new event is a true replacement (createdAt > prior) and
the room differs, drop the author from the prior channel's presenceNotes
and remove the prior version note from its main notes index.
This commit is contained in:
Claude
2026-04-30 00:56:05 +00:00
parent d87fc36d21
commit 7845072f20
2 changed files with 34 additions and 0 deletions
@@ -60,6 +60,17 @@ class LiveActivitiesChannel(
presenceNotes.put(author, note)
}
/**
* Drop an author's presence entry. Called by `LocalCache` when a
* replaceable kind-10312 from this author lands in a *different*
* room — without this eviction, the old room would keep surfacing
* as "live" via stale presence until it drops out of the
* freshness window.
*/
fun removePresenceNote(author: HexKey) {
presenceNotes.remove(author)
}
fun address() = address
override fun relays() = info?.allRelayUrls()?.toSet()?.ifEmpty { null } ?: super.relays()