# Updates that reach phones (and the PWA basics)

## Installable
- `manifest.webmanifest`: name, short_name, start_url, `display: standalone`, theme and background colours, icons (SVG plus 192 and 512 PNG, and a 180×180 `apple-touch-icon.png`).
- `<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">` and safe-area padding (`env(safe-area-inset-top)` etc.) so nothing hides under the clock or home bar.
- Show people how to add it, per browser: iPhone Safari (Share → Add to Home Screen), iPhone Chrome (Share → Add to Home Screen), Android Chrome (⋮ → Install app), Samsung Internet, desktop Chrome/Edge (install icon in the address bar), Mac Safari (File → Add to Dock).

## The service worker
- `sw.js` with `const VERSION = "app-v12"`. Bump it on **every** release that changes anything in `public/`, or phones keep the old files.
- Cache the app shell under the version name; delete old caches on `activate`; `skipWaiting()` and `clients.claim()`.
- Never cache `/api/` or large media; let them go to the network.

## Letting people know
- Settings → "Check for updates": calls `registration.update()`; if a new worker is installing or waiting, reload when it takes over; otherwise "You're up to date · version 12".
- When a new worker takes over in the background (`controllerchange`) and the app was already controlled, show a bar: "A new version is ready · Restart". Don't reload mid-entry without asking.
- iPhone keeps home-screen apps suspended rather than restarting them: check for updates on `visibilitychange` when the app comes back.
- After the first release that adds these, tell the user to close and reopen the app once the old way.

## Mixed versions
For a few minutes after a release, phones run different versions. Keep the server accepting what older versions send, and keep new fields optional. If a new feature would confuse an old phone (e.g. a new kind of timer), tell the user to update both phones first.
