feat: no connection screen on web and mobile #120

Merged
joshuafhiggins merged 1 commits from t3/offline-connection-screen into main 2026-11-19 19:25:10 -05:00
Owner

Without a connection, oTunes shows broken or endlessly loading pages, and on web the browser replaces the whole app with its own "You're offline" page, which also stops playback. Downloaded music is there, but hard to reach.

What changed

No connection screen. When the network or server can't be reached, page content is replaced with "No connection" and a link to Downloads. Downloads, Other Downloaded Songs, albums and playlists opened from Downloads (?from=downloads), and the player are never covered. The screen clears on its own when the connection returns.

  • Detection lives in packages/convex/client/connectivity.ts: offline when the platform says so, or when the Convex socket stays closed for more than 5 seconds.
  • Web: OfflineGate in the app layout, also using Next's useOffline() (experimental.useOffline), so a failed navigation waits for the connection instead of reloading the page.
  • Mobile: an overlay in the shared tab screenLayout, using expo-network for device connectivity. Screens stay mounted underneath, so you land back where you were. Settings stays reachable so you can switch servers. Needs a dev client rebuild for expo-network.

Web works after reloads and launches while offline. downloads-sw.js now also, in production builds only:

  • keeps the last good copy of each page (network first) and falls back to Downloads for pages never saved
  • keeps app code from /_next/static (cache first) and deletes code unused for a month
  • saves Downloads and each downloaded album and playlist page ahead of time, and clears saved pages on sign-out

Links to Downloads are fully prefetched, and fall back to a full page load if an offline navigation stalls.

Testing

Ran a production build locally against the test server's backend in headless Chrome, then stopped the Next server: saved pages reload with the no-connection screen, unsaved pages redirect to Downloads, "Go to Downloads" works, and the app recovers when the server comes back. Not yet tested: real downloaded albums offline, sign-out clearing, installed PWA mode, the mobile apps on a device.


Made by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

Without a connection, oTunes shows broken or endlessly loading pages, and on web the browser replaces the whole app with its own "You're offline" page, which also stops playback. Downloaded music is there, but hard to reach. ## What changed **No connection screen.** When the network or server can't be reached, page content is replaced with "No connection" and a link to Downloads. Downloads, Other Downloaded Songs, albums and playlists opened from Downloads (`?from=downloads`), and the player are never covered. The screen clears on its own when the connection returns. - Detection lives in `packages/convex/client/connectivity.ts`: offline when the platform says so, or when the Convex socket stays closed for more than 5 seconds. - Web: `OfflineGate` in the app layout, also using Next's `useOffline()` (`experimental.useOffline`), so a failed navigation waits for the connection instead of reloading the page. - Mobile: an overlay in the shared tab `screenLayout`, using `expo-network` for device connectivity. Screens stay mounted underneath, so you land back where you were. Settings stays reachable so you can switch servers. **Needs a dev client rebuild** for `expo-network`. **Web works after reloads and launches while offline.** `downloads-sw.js` now also, in production builds only: - keeps the last good copy of each page (network first) and falls back to Downloads for pages never saved - keeps app code from `/_next/static` (cache first) and deletes code unused for a month - saves Downloads and each downloaded album and playlist page ahead of time, and clears saved pages on sign-out Links to Downloads are fully prefetched, and fall back to a full page load if an offline navigation stalls. ## Testing Ran a production build locally against the test server's backend in headless Chrome, then stopped the Next server: saved pages reload with the no-connection screen, unsaved pages redirect to Downloads, "Go to Downloads" works, and the app recovers when the server comes back. Not yet tested: real downloaded albums offline, sign-out clearing, installed PWA mode, the mobile apps on a device. --- Made by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, running in T3 Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
joshuafhiggins added 1 commit 2026-11-19 19:25:03 -05:00
- Replace page content with a no-connection screen linking to Downloads when
  the network or server is unreachable; Downloads and the player stay usable
- Detect it from the Convex socket plus Next's useOffline on web and
  expo-network on mobile, and recover on reconnect
- Keep pages and app code in the service worker so reloads and launches work
  offline instead of showing the browser's offline page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joshuafhiggins force-pushed t3/offline-connection-screen from e017fc8d6b to e5d6beb781 2026-11-19 19:25:03 -05:00 Compare
joshuafhiggins merged commit 4a87d782d1 into main 2026-11-19 19:25:10 -05:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joshuafhiggins/otunes#120