fix: reorder pruning tiers in MemoryTrimmingService

Tier 2 (medium, >= RUNNING_LOW): pruneHiddenEvents + pruneHiddenMessages
  — muted/blocked content is known-safe to drop at low pressure.

Tier 3 (critical, >= RUNNING_CRITICAL): pruneOldMessages + pruneRepliesAndReactions
  — these are more aggressive since they remove content the user may
  still scroll back to, so reserve them for genuine memory emergencies.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-24 20:11:27 +00:00
parent 281955fb17
commit 4eb195fa5e
@@ -61,19 +61,19 @@ class MemoryTrimmingService(
cache.prunePastVersionsOfReplaceables()
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) {
// Tier 2: medium pressure — drop messages and unobserved reactions
val accounts = otherAccounts.mapNotNull { decodePublicKeyAsHexOrNull(it.npub) }.toSet()
cache.pruneOldMessages()
cache.pruneRepliesAndReactions(accounts)
}
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
// Tier 3: critical pressure — drop muted content
// Tier 2: medium pressure — drop events from muted/blocked users
account.forEach {
cache.pruneHiddenEvents(it)
cache.pruneHiddenMessages(it)
}
}
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
// Tier 3: critical pressure — drop old messages and unobserved reactions
val accounts = otherAccounts.mapNotNull { decodePublicKeyAsHexOrNull(it.npub) }.toSet()
cache.pruneOldMessages()
cache.pruneRepliesAndReactions(accounts)
}
}
suspend fun run(