Skip to content

feat: show a warning on all screens when the server is not reachable - #7090

Open
mahibi wants to merge 1 commit into
masterfrom
showServerNotReachableWarning
Open

mahibi wants to merge 1 commit into
masterfrom
showServerNotReachableWarning

Conversation

@mahibi

@mahibi mahibi commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

When the device was online but the Nextcloud server could not be reached (server down, DNS failure, connection refused or timeout, proxy returning 502/504), the app showed no hint at all: requests just failed silently. The maintenance mode was only shown on the conversation list.

This PR adds one central warning panel that is shown on all screens, for XML and Compose screens alike, without code in the individual screens. It builds on the central approach of #6587.

How it works

  • ServerConnectionInterceptor watches the outcome of every request to the account's server:
    • an answer means connected
    • a failure to connect (unknown host, refused, connect timeout) or a 502/504 from a proxy means no connection
    • a 503 with X-Nextcloud-Maintenance-Mode: 1 means maintenance mode
    • timeouts after the connection was made (e.g. slow uploads) and WebSocket (signaling) requests are ignored
  • ServerConnectionMonitor keeps that status per server. While the server can't be used, and whenever the device connectivity changes, it checks the server with index.php/204 (the walled garden endpoint the desktop and Files clients use; only an exact 204 counts, so a captive portal page is not taken for the server). So the status also recovers on screens that send no requests.
  • BaseActivity puts every screen's content below a StatusBannerLayout, which shows "No connection to server" or the maintenance mode text. While the banner is shown, it takes over the status bar inset, so the content below doesn't pad for the status bar twice. Calls, the media viewer and the login screens opt out with showsStatusBanner = false.
  • The banner of the conversation list and the "Connection lost - Sent messages are queued" hint of the chat input are replaced by the central banner, so the warning is not shown twice.

Known limitation/ will be improved in a followup PR

While NetworkMonitor considers the device offline, the banner shows "No connection to server" as well, because the app doesn't sync or send then. NetworkMonitor requires the network to be validated by Android (by default against Google's servers), so on a LAN without internet the banner shows although the server could be reached. This matches the behaviour before this PR. Removing that dependency changes when the whole app syncs and sends, so it is left for a separate PR (it will address #6240).

How to test

  1. Stop the server (or block it in the network): "No connection to server" appears on the next request, or within 30 s on screens without own requests (e.g. settings).
  2. Start the server again: the banner disappears on the next request or within 30 s.
  3. occ maintenance:mode --on / --off: the maintenance banner appears and disappears.
  4. Airplane mode on/off: the banner appears and disappears almost immediately.
  5. With the banner shown, open the search on the conversation list: the search bar must not jump while the keyboard opens.
  6. Check the spacing below the status bar on Android 15+ and older, on XML screens (chat), Compose screens (conversation list, conversation info) and screens that pad for the system bars themselves (shared items, remote file browser).

🏁 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

@mahibi mahibi added this to the 26.0.0 milestone Nov 23, 2026
@mahibi mahibi self-assigned this Nov 23, 2026
When the device was online but the server could not be reached, the app
showed no hint at all, and only the conversation list knew about the
maintenance mode. Requests just failed silently.

The outcome of every request now feeds one central connection status
per server, and every screen shows it in the same banner above its
content, for XML and Compose screens alike. While the server can't be
used, it is checked again periodically so the banner also disappears on
screens that send no requests themselves.

The separate banner of the conversation list and the offline hint of
the chat input are replaced by the central banner, so the warning is
not shown twice.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@mahibi
mahibi force-pushed the showServerNotReachableWarning branch from d48639a to af14ee6 Compare November 23, 2026 11:59
@mahibi
mahibi marked this pull request as ready for review November 23, 2026 12:03
@mahibi mahibi added the 3. to review Waiting for reviews label Nov 23, 2026
@mahibi
mahibi requested a review from rapterjet2004 November 23, 2026 12:39
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.

1 participant