Skip to content

[stable-25.0.x] fix(chat): make the push message prefetch actually run on a flaky connection - #6740

Merged
mahibi merged 4 commits into
stable-25.0.xfrom
backport/6727/stable-25.0.x
Sep 21, 2026
Merged

mahibi merged 4 commits into
stable-25.0.xfrom
backport/6727/stable-25.0.x

Conversation

@backportbot

@backportbot backportbot Bot commented Sep 21, 2026

Copy link
Copy Markdown

Backport of #6727

Warning, This backport's changes differ from the original and might be incomplete 鈿狅笍

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

A failed chat pull was retried with a progressively smaller limit (100 ->
50 -> 10 -> 5). For a background catch-up that means a connection which
fails a few times before succeeding persists a five message chat block,
and since the chat screen renders the latest block, the conversation
opens nearly empty even though the prefetch reported success.

Keep the requested limit across retries and back off in time instead, so
a struggling or rate limiting server is not hammered by four immediate
requests either.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
catchUpRoom refused to fetch whenever NetworkMonitor reported the device
as offline. That flag is a StateFlow shared while subscribed, and every
collector is UI scoped, so a worker started by a push notification reads
whatever value was cached when the monitor was constructed and no
callback ever updates it. A process that was backgrounded while offline
therefore skips every catch-up for as long as it lives, and because the
check requires NET_CAPABILITY_VALIDATED it also skips on a connected but
unvalidated network, which is exactly the flaky wifi case the prefetch
exists for.

Drop the pre-check. Callers are already gated by a WorkManager
NetworkType.CONNECTED constraint, and a request that fails because the
device is offline is reported as a failed sync and retried with backoff,
which is strictly better than skipping a fetch that would have
succeeded.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
isOnline is exposed as a StateFlow shared while subscribed, so its
upstream network callback only runs while something collects it. Reading
the value does not subscribe, and every collector in the app is UI
scoped, so background code that samples the value - a worker handling a
push notification, sending a queued message - sees the value captured
when the singleton was constructed and never an update.

Share the flow eagerly. The scope already lives for the whole process,
so this replaces repeated register and unregister cycles with a single
long lived network callback.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@backportbot backportbot Bot added 3. to review Waiting for reviews AI assisted labels Sep 21, 2026
@backportbot backportbot Bot added this to the 25.0.1 milestone Sep 21, 2026
@AndyScherzinger
AndyScherzinger force-pushed the backport/6727/stable-25.0.x branch from 6b981ef to 3c56c63 Compare September 21, 2026 10:21
@AndyScherzinger
AndyScherzinger marked this pull request as ready for review September 21, 2026 10:24
The backport of #6694 brought the IOException and HttpException catch
clauses into ChatViewModel but not their imports, so stable-25.0.x has
not compiled since. Add them back in the same place master keeps them.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@github-actions

Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/talk-android/actions/runs/35593076856/artifacts/10635461681
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@mahibi
mahibi merged commit 3fba624 into stable-25.0.x Sep 21, 2026
13 of 17 checks passed
@mahibi
mahibi deleted the backport/6727/stable-25.0.x branch September 21, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants