From ea2dbd9a77aa71d83314cf970abe054a5382bd3e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 24 Jun 2026 21:42:14 +0000 Subject: [PATCH] fix: keep lastNotes intact on CardFeedContentState.trimToSize() Clearing lastNotes caused the next additive update to call refreshSuspended(), reloading the full filter limit (~500 notes) from LocalCache and immediately undoing the trim. With lastNotes intact the fast additive path stays active: only genuinely new notifications are appended, so the card list remains near maxItems until the next full feed key change or navigation event. The Note refs in lastNotes are the same object instances already held by LocalCache. They are freed when MemoryTrimmingService prunes LocalCache and the following refreshSuspended() replaces lastNotes with the pruned set. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_019h2c44rAwexuUEP3kky2F3 --- .../notifications/CardFeedContentState.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt index eb048e8bd1..391bb761f2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/CardFeedContentState.kt @@ -411,13 +411,14 @@ class CardFeedContentState( val loaded = current.feed.value if (loaded.list.size > maxItems) { current.feed.tryEmit(LoadedFeedState(loaded.list.take(maxItems).toImmutableList(), loaded.showHidden)) - // lastNotes holds strong refs to every raw Note that was ever included in this - // feed (used for additive-dedup). Clearing it releases those refs so the Notes - // are no longer pinned in memory independently of LocalCache. - // The next additive update will find lastNotes == null, skip the fast path, and - // call refreshSuspended() — a single controlled rebuild from LocalCache. - lastNotes = null - lastAccount = null + // lastNotes is intentionally kept intact. Clearing it would cause the next + // additive update to fall through to refreshSuspended(), reloading up to + // limit() notes from LocalCache and undoing the trim immediately. With + // lastNotes intact, the fast additive path stays active: only genuinely + // new notifications are appended, so the card list stays near maxItems. + // The Note refs in lastNotes are the same objects already held by LocalCache; + // they are freed when pruneRepliesAndReactions() prunes LocalCache and the + // next full refreshSuspended() replaces lastNotes with the pruned set. } } }