Skip to content

Android: stale server config (overlays) + no server-reachability/offline handling — port silo-apple graceful server-down work #33

Open

Description

@zZebrahz

Summary

Two related client behaviors that were recently addressed in silo-apple are still present in silo-android. Filing so Apple and Android stay aligned per the shared-client-behavior guidance.

silo-apple reference: commit 21bafb1 ("Graceful server-down handling: reachability monitor, fast timeouts, stale-content indicator, pre-play gating") plus follow-up work that (a) fixed load-once config staleness with a throttled foreground refreshIfStale, and (b) made server-reachability detection authoritative rather than inferred from status codes — so it works behind reverse proxies and tunnels. See the "Apple approach" sections below for the current, shipped design (it evolved past the original commit).

Problem 1 — Stale server config (overlays) until process restart

DefaultOverlayPrefsStore.hydrateIfNeeded() (android-shared/.../common/settings/OverlayPrefsStore.kt:114) is a permanent no-op once hasHydrated is set. Its only UI caller, ProvideCardOverlays (android-shared/.../common/overlays/CardOverlayUiState.kt), keys hydration on sessionKey (profile) and also calls hydrateIfNeeded(). There is no foreground / ON_RESUME refresh() anywhere.

Result: server-side overlay changes — the admin baseline, the global overlays.enabled kill switch, or the user's card_overlays edited on the web or another client — do not take effect until a full process restart or profile switch. LibraryPlaybackPrefsStore and profile prefs share the same load-once pattern.

Apple fix for reference: added OverlayPrefsStore.refreshIfStale(minInterval:) — a throttled re-fetch that falls through to hydrateIfNeeded() when never loaded, otherwise re-fetches unless a successful refresh happened within minInterval (30s). It's called on the foreground (scenePhase == .active) transition instead of the no-op hydrateIfNeeded(), and also on the .serverDidReconnect edge (below). AI-capabilities and request-feature stores get the same foreground/reconnect refresh treatment.

Problem 2 — No server-reachability / offline handling

Android has no ConnectionMonitor equivalent:

  • No server-status signal distinct from device connectivity.
  • No stale-cache indicator / "offline mode" banner.
  • No offline banner / tap-to-retry on browsing screens.
  • No health re-probe cadence, so a server that dies with the app open is only noticed when the next user-initiated request happens to fail.

What exists today is narrower: MainActivity.isOnline() is a one-shot device connectivity check used only for cold-launch routing; ConnectivityManager is used only in Downloads + OutboxSyncStarter; reconnect-with-backoff loops are playback / watch-together WebSocket-specific, not the catalog/API layer.

Apple approach for reference (current shipped design):

  • ConnectionMonitor singleton tracks two things: device path (NWPathMonitor) and server status (.unknown / .reachable / .unreachable). .unknown is optimistic — counts as reachable — so the first request after launch is never blocked.

  • The health probe is authoritative, not inferred. GET /api/v1/health on a short-timeout (~6s) session counts as reachable only if it decodes an actual HealthStatus payload. Any other outcome — transport failure, gateway status, or an error page that won't parse — flips the state to unreachable. This is the key fix: the earlier "any HTTP response means the server is alive" rule broke behind reverse proxies and tunnels, where killing the backend still produces an HTTP response (a proxy error page or a 200 HTML splash), so the app never detected the outage.

  • Gateway/tunnel failure statuses are classified as unreachable in the passive path too: 502, 503, 504 plus Cloudflare's full origin-failure family 520–527 and 530. The token-refresh path shares the same set, so a proxy outage fails the request but keeps the session instead of signing the user out.

  • Always-on foreground heartbeat. While foregrounded and the device has a network path, a loop probes on a cadence regardless of current status: ~20s while reachable (catch a silent disconnect) and ~8s while unreachable (catch recovery quickly). Paused on background, restarted + probed immediately on foreground and on regaining a network path. This is what makes "app open, server dies, no user action" detectable within seconds — the earlier design only probed while already unreachable and so never noticed the initial drop.

  • .serverDidReconnect broadcast on the down→up edge re-hydrates server-driven config (overlays, AI capabilities, request features) and repaints stale content, so the app self-heals without user action.

  • Pull-to-refresh runs the authoritative probe in parallel with the content reload on the main browsing screens, so pulling reliably flips the offline state (previously it only reloaded content).

  • Offline UX:

    • A persistent "Offline mode" banner (wifi-slash icon) above the header while browsing cached content.
    • A tappable "Can't reach server — tap to retry" pill on secondary browsing screens.
    • When the primary screen has nothing cached to show, a dedicated full-screen state — "Server is offline" (or "No internet connection" when the device itself is offline) with the active server's name — offering Try Again, View Downloads (when playable downloads exist), and Switch Server, instead of a generic error page.
    • Cold-launching with the server unreachable routes to Downloads when playable downloads exist (previously only happened when the device had no network at all).

Suggested scope

  1. Foreground refresh() for overlay/playback/profile config stores (fixes Problem 1 on its own; low risk).
  2. A server-reachability monitor fed by an authoritative /api/v1/health probe (decode-or-unreachable), with an always-on foreground re-probe cadence, gateway/tunnel status classification, and a reconnect broadcast.
  3. Offline indicator + pull-to-refresh/tap reconnect + a server-offline empty state routing to downloads/switch-server on the main browsing screens.

Server side needs no changes — this is all client behavior against existing endpoints (/api/v1/health, /settings/*).

Activity

  1. zZebrahz commented on Jul 5, 2026

    @zZebrahz
    ContributorAuthor

    I can handle this later, was just filing a note

  2. added
    bug
    triaged
    and removed
    triaged
    on Sep 20, 2026
  3. added theissue type on Sep 20, 2026
  4. removed
    bug
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions