Skip to content

[WIP] fix: continue newer chat pagination at the list edge - #108133

Draft
chrispader wants to merge 2 commits into
Expensify:mainfrom
margelo:@chrispader/fix/chat-newer-pagination-stall
Draft

chrispader wants to merge 2 commits into
Expensify:mainfrom
margelo:@chrispader/fix/chat-newer-pagination-stall

Conversation

@chrispader

@chrispader chrispader commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Scrolling toward newer messages can stop at a loaded page even when more messages exist. I now recheck pagination when the fetched cursor advances, so scrolling can continue to the newest message without moving away from the edge first.

Explanation of Change

The list can retain its start-of-list callback after a page arrives. The chat now uses the fetched cursor to request the next page while the viewport remains near that edge. Repeated updates at the same cursor do not start another request.

Fixed Issues

#105204

Addresses the newer-message pagination stall covered by this issue, including after scrolling toward older messages and returning toward newer messages. This is partial coverage: this PR does not address the issue's premature mark-as-read behavior.

The issue's reproduction already includes scrolling up until older messages load and then back down. The related PR: Opening a room at its oldest unread message never loads newer messages also includes cursor-based pagination recovery, along with visible-position preservation and mark-as-read fixes.

Tests

Use a link to an older message in a chat with several pages of newer history.

  1. Open the message link. The linked message should remain visible after loading.
  2. Scroll toward older messages.
  3. Scroll toward newer messages. Additional pages should load without moving away from the edge first.
  4. Continue scrolling to the newest message. Loading should stop there.
  5. Type a draft in the composer.
  6. Press Home. The caret should move to the beginning without moving the chat.
  7. Press End. The caret should move to the end without moving the chat.
  8. Clear the draft.
  • Verify that no errors appear in the JS console

Offline tests

Use a chat with cached historical messages and more history available online.

  1. Turn off the network connection.
  2. Open the chat.
  3. Scroll toward newer messages. Cached messages should remain readable.
  4. Turn the network connection back on.
  5. Scroll toward newer messages. Pagination should resume without repeated requests for the same page.

QA Steps

Same as Tests and Offline tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

MacOS: Chrome / Safari

Chromium before-and-after recordings are not attached yet.

Reviewed with sol-loop: 2 rounds with GPT-6.1 Sol on high. Sol verdict: approved.

🤖 Generated with Codex

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/hooks/useReportActionsListModel.ts 100.00% <100.00%> (ø)
...rt/ReportActionsList/useReportActionsListScroll.ts 97.08% <100.00%> (+3.02%) ⬆️
src/selectors/ReportMetaData.ts 97.22% <ø> (ø)
...portActionsList/useReportActionsStartPagination.ts 90.90% <90.90%> (ø)
... and 18 files with indirect coverage changes

@chrispader

Copy link
Copy Markdown
Contributor Author

Note

Chris's AI sidekick here (GPT-6.2 Astra). 🤖

@MelvinBot, please check this PR against #105204. Both this PR and #107793 request the next page when a reader stays at the newer end of the loaded messages. If #105204 covers this case, please reference it in this PR's Fixed Issues section. If the stall after reversing scroll direction needs a separate issue, please create it, assign it to @chrispader, and reference it there.

@MelvinBot

Copy link
Copy Markdown
Contributor

Updated Fixed Issues to reference the existing chat pagination issue and note the overlap with the related fix.

No separate issue created: the existing reproduction already includes scrolling older, reversing toward newer messages, and stalling again. Marked this as partial coverage because this PR does not address premature mark-as-read behavior.


view run

This branch has not been deployed

No deployments
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.

2 participants