Skip to content

iOS PWA runs stale builds until reinstalled — ship in-place auto-update + verify on device #37

Description

@EnesYilmazcode

Problem

The app is configured with registerType: 'autoUpdate' (vite.config.js), but on iOS a home-screen PWA is frozen and resumed rather than genuinely relaunched, so Safari's built-in service-worker update check rarely fires. Result: the phone keeps running an old build for days, and the current workaround (delete the icon → re-add to home screen) is dangerous — deleting the icon can drop the origin's IndexedDB, which holds every imported song, playlist, and star (src/lib/db.js, audioBlobs store).

Fix (implemented on branch claude/phone-app-auto-update-xgckp7)

  • src/lib/pwa.js: registers the SW via virtual:pwa-register and calls registration.update() on every return to foreground (visibilitychangevisible) plus hourly while open. With autoUpdate, a detected new build activates and reloads on its own.
  • src/main.jsx: calls requestPersistentStorage() at startup (previously only on import) so iOS is asked to mark the library durable every launch.
  • Hidden version readout to confirm updates actually land: long-press the tab bar → small pill with build <commit> · <date> <time> (stamped at build time via a Vite define), auto-hides after 5 s. Invisible in normal use.

Remaining work

  • Merge the branch and deploy (npm run deploy:sparky)
  • On the phone: open the installed app once with network, background it, wait for the next deploy, then reopen and long-press the tab bar — the commit hash should match the new deploy within one foreground cycle (worst case two: one to fetch, one to activate)
  • If activation lags, consider showing a subtle "restart to update" affordance or calling skipWaiting explicitly
  • Document in README: never remove/re-add the icon; to force-refresh, swipe the app away in the app switcher and reopen

Acceptance criteria

A new deploy is running on the phone within one open→close→open cycle, with zero manual steps and zero data loss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions