ML-169.9: add pagination stream reset fix task

This commit is contained in:
Claudio Ortolina
2026-05-19 12:51:29 +01:00
parent e42e28992a
commit ab8062ddc6
@@ -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
<!-- SECTION:DESCRIPTION:BEGIN -->
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.
<!-- SECTION:DESCRIPTION:END -->
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #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
<!-- AC:END -->