Skip to content

perf(chat): prefetch and cache link previews, load older media earlier - #7043

Open
AndyScherzinger wants to merge 5 commits into
masterfrom
perf/link-preview-cache-and-media-viewer-paging
Open

AndyScherzinger wants to merge 5 commits into
masterfrom
perf/link-preview-cache-and-media-viewer-paging

Conversation

@AndyScherzinger

@AndyScherzinger AndyScherzinger commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Closes the prefetching gaps to the iOS app found when comparing what each client fetches while showing a chat. Attachments were already at parity (server thumbnails with blurhash placeholders, no server previews in classified conversations, GIFs, media viewer downloads), so the remaining gaps were link previews and media viewer paging.

  • Resolve each link preview only once while a chat is open. A link message requested its preview every time its bubble entered the composition again, e.g. after scrolling it out of view and back, and the result was never kept. Previews now go through a cache in the chat view model: each URL is requested once, concurrent calls share the request, a URL without a preview is remembered, and a failed request is retried on the next call. It keeps the 100 most recently used URLs and runs at most four requests in parallel. iOS keeps the resolved reference data on the message the same way.
  • Resolve link previews before their bubbles are shown. Whenever the message list changes, the previews of the 20 newest link messages are requested through that cache, so they are usually ready when the bubble appears. iOS does this through table row prefetching.
  • Load older media in the media viewer before the oldest item is reached. Older media were only loaded once the second oldest item was shown, so swiping back stalled at the edge. Loading now starts within the ten oldest items, like iOS does ten items before the end of its media list.

Both apps use the same references/resolve endpoint, so no API changes are involved. Link previews in classified conversations behave as before; the prefetch does not add requests for content that was not already requested on display.

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🚧 TODO

  • ...

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit d341162
Version 7043
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@AndyScherzinger
AndyScherzinger force-pushed the perf/link-preview-cache-and-media-viewer-paging branch from 9225803 to 67caebf Compare November 16, 2026 07:13
@AndyScherzinger AndyScherzinger added this to the 26.0.0 milestone Nov 16, 2026
@AndyScherzinger AndyScherzinger added enhancement New feature or request 3. to review Waiting for reviews labels Nov 16, 2026
@AndyScherzinger
AndyScherzinger marked this pull request as ready for review November 16, 2026 17:58
@AndyScherzinger
AndyScherzinger force-pushed the perf/link-preview-cache-and-media-viewer-paging branch 3 times, most recently from 0452433 to d341162 Compare November 22, 2026 10:09
@github-actions

Copy link
Copy Markdown
Contributor

Codacy

Lint

TypemasterPR
Warnings1716
Errors00

SpotBugs

CategoryBaseNew
Bad practice77
Correctness88
Dodgy code4040
Internationalization33
Malicious code vulnerability33
Performance77
Security1111
Total7979

The thumbnail of a link preview card was described with the format
string "%1$s sent an image." without its argument, so screen readers
read the placeholder out loud. The image only illustrates the card,
whose title, description and link are read out already, so it no
longer has a description of its own.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
A link message requested its preview every time its bubble entered the
composition again, e.g. when scrolling it out of view and back. The
HTTP cache answered repeated requests for an hour, but every request
still read and parsed the response again, and bubbles that asked for
the same URL at the same time each sent a request of their own.

Resolve link previews through a cache in the chat view model: each URL
is requested once, concurrent calls share the request, a URL without a
preview is remembered as such, and a failed request is made again by
the next call, also when nobody waited for it. The cache keeps the 100
most recently used URLs. iOS keeps the resolved reference data on the
message the same way.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Older media are added in front of the list. The pager identified its
pages by position, so the view model shifted the position afterwards
with scrollToPage. That shift was dropped while the user was dragging,
leaving them on an item further back while the title, share and save
referred to another one. Otherwise the wrong item was drawn for a frame
and the shown page was rebuilt, losing its zoom.

Identify the pages by their message id, so the pager keeps the shown
item in place when items are added in front, and remove the shift. As
page keys must be unique, duplicate items in the seed are dropped and
the view model is seeded only once, so a recreated activity cannot
start a second load of the same older media. The shown page is reported
at the end of every scroll, also when its position did not change
because items were added during the scroll.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
A failed request for older media was handled like the end of the
history, so older media could not be reached again until the viewer
was reopened, even after the connection was back.

Keep loading older media possible after a failure, so the next item
shown near the oldest one requests them again.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The media viewer only loaded older media once the second oldest item
was shown, so swiping back stalled at the edge until the request was
answered.

Load older media as soon as an item within the ten oldest is shown.
The existing guards still allow only one request at a time. iOS starts
loading more items ten items before the end of its media list.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger
AndyScherzinger force-pushed the perf/link-preview-cache-and-media-viewer-paging branch from d341162 to 327f20b Compare November 23, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant