8000 fix(ui): stop list scroll jumps and pagination drift on load-more by ahmet-cetinkaya · Pull Request #314 · ahmet-cetinkaya/whph · GitHub
[go: up one dir, main page]

Skip to content

fix(ui): stop list scroll jumps and pagination drift on load-more - #314

Merged
ahmet-cetinkaya merged 1 commit into
mainfrom
fix/list-load-more-scroll
Sep 27, 2026
Merged

ahmet-cetinkaya merged 1 commit into
mainfrom
fix/list-load-more-scroll

Conversation

@ahmet-cetinkaya
Copy link
Copy Markdown
Owner

Problem

On mobile, scrolling paginated lists (notes, tasks, habits, tags, app usages, app usage rules) stutters and snaps back while more items load.

  • Load-more jumped back. Every list saved the scroll offset before a load-more and called jumpTo to return to it after the append. That cancelled the user's fling and pulled them back to where the load started.
  • Refresh restored stale offsets. Refresh saved the offset when it was requested, not when the data arrived. Habits' one-minute delayed refresh restored a minute-old position.
  • Pagination drifted after refresh. After a refresh, the next load-more used a stale pageIndex and re-fetched already-loaded rows. Most lists appended them as duplicates.
  • Late results were not guarded. A load-more that finished after a refresh could append to, or replace, the refreshed list.

Changes

  • Remove scroll save/restore around load-more in all 7 lists.

  • PaginationMixin.captureScrollOffset / restoreScrollOffset: the refresh offset is captured right before the data swap, and the restore is skipped while the user is scrolling.

  • New PaginationUtils:

    • page by a database-row cursor instead of the kept item count;
    • hasMore is based on counts;
    • duplicates are removed by id;
    • a per-list load generation drops stale results.

    Lists that filter rows after SQL paging, such as the Today page habits, therefore still reach every row.

  • The tag-rule and ignore-rule lists replace their data only on refresh.

  • Tags no longer clear the list on refresh, so the list doesn't drop back to 10 items.

No query, repository, MCP, sync or schema changes.

Tests

  • New tests: pagination_utils_test, pagination_mixin_test, notes_list_test, habits_list_scroll_test.
  • Fail-before on unmodified code:
    • notes list: 4/5 cases failed (snap-back after load-more, wrong page after refresh, stale restore, late page appended);
    • habits delayed refresh: failed.
  • All pass after the fix.
  • rps format and rps lint: pass.
  • Full flutter test: the only failures are pre-existing ones that also fail on main (desktop_server_sync_service_test.dart, desktop_sync_service_test.dart, integration/mcp_user_actions_test.dart).
  • Manual QA on an Android emulator: scrolling and loading behave correctly.

Known follow-ups (not in this PR)

  • Today page: if every habit on the first loaded page is already completed, the list shows the empty state with no Load More button. This happened before this PR too.
  • Grouped tasks/habits can still shift on append because groups are sorted on the client.
  • shrinkWrap and the page size should be measured in profile mode before changing them.

Lists saved the scroll offset before a load-more and jumped back to it
after the append, cancelling the user's fling and snapping them back.
Refresh captured the offset at request time (a minute early for habits'
delayed refresh), and after a refresh the next page was computed from a
stale pageIndex, re-fetching and duplicating loaded rows.

- Drop scroll save/restore around load-more in all paginated lists.
- Capture the refresh offset right before the data swap via
  PaginationMixin and skip the restore while the user is scrolling.
- Page by a DB-row cursor with id dedupe and a load generation that
  drops stale results (PaginationUtils), so filtered lists such as the
  Today page habits still reach every row.
@ahmet-cetinkaya
ahmet-cetinkaya merged commit dd59f2a into main Sep 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0