From ab8062ddc62216777bd70efaf0e2d447dce431e3 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Tue, 19 May 2026 12:51:29 +0100 Subject: [PATCH] ML-169.9: add pagination stream reset fix task --- ...resets-on-pagination-within-same-search.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 backlog/tasks/ml-169.9 - Fix-Full-stream-resets-on-pagination-within-same-search.md diff --git a/backlog/tasks/ml-169.9 - Fix-Full-stream-resets-on-pagination-within-same-search.md b/backlog/tasks/ml-169.9 - Fix-Full-stream-resets-on-pagination-within-same-search.md new file mode 100644 index 00000000..1b6f0935 --- /dev/null +++ b/backlog/tasks/ml-169.9 - Fix-Full-stream-resets-on-pagination-within-same-search.md @@ -0,0 +1,55 @@ +--- +id: ML-169.9 +title: "Fix: Full stream resets on pagination within same search" +status: To Do +assignee: [] +created_date: "2026-05-19 11:48" +labels: + - perf + - fix +dependencies: [] +references: + - >- + backlog/documents/doc-27 - + Phase-4-Performance-Audit-Low-Hanging-Fruit-Findings.md +modified_files: + - lib/music_library_web/live_helpers/index_actions.ex + - lib/music_library_web/live/scrobbled_tracks_live/index.ex + - lib/music_library_web/live/artist_live/show.ex +parent_task_id: ML-169 +priority: medium +ordinal: 30000 +--- + +## Description + + + +Optimize stream behavior so that pagination within the same search does not trigger a full `stream(..., reset: true)`. Search and order changes still legitimately need resets. + +## Problem + +Every search query change, order toggle, or **pagination click** triggers a full `stream(..., reset: true)`. While `reset: true` is correct when the entire dataset changes (new search query), it's unnecessary for pagination within the same search — the existing items don't change, only new ones are appended. + +## Files + +- `lib/music_library_web/live_helpers/index_actions.ex:89` — `load_and_assign_records` uses `reset: true` +- `lib/music_library_web/live/scrobbled_tracks_live/index.ex:334` — `load_and_assign_tracks` uses `reset: true` +- `lib/music_library_web/live/artist_live/show.ex:698-699` — `assign_records` uses `reset: true` + +## Fix + +Use `stream(..., at: -1)` (append) for "load more" pagination. Only use `reset: true` when search text or order field changes. This requires distinguishing between a "new search" and "same search, next page" in the pagination handler. + + + +## Acceptance Criteria + + + +- [ ] #1 Pagination to next page appends records without full stream reset +- [ ] #2 Existing stream items remain visible during pagination +- [ ] #3 Search query change still triggers full stream reset +- [ ] #4 Order change still triggers full stream reset +- [ ] #5 No duplicate records appear after multiple pagination clicks +