fix(hub): drop hub PWA install to unblock standalone PWAs (#41) #44

Merged
padreug merged 1 commit from fix/issue-41-drop-hub-pwa into main 2026-05-06 06:08:58 +00:00
Owner

Summary

Fixes #41. The hub's manifest had scope: '/', which claimed the entire app.${domain} origin and made Chrome treat the path-mounted standalones (/libra/, /market/, /sortir/, …) as sub-areas of the already-installed hub PWA — suppressing the install affordance on each standalone.

Drop the hub's PWA install entirely. The hub is a tile-grid launcher; users install the standalones they actually use. The libra/market/sortir/etc. PWAs at deeper scopes are unaffected and remain independently installable.

Changes

  • vite.config.ts — removed the VitePWA(...) plugin block (and its import). No more manifest, no more SW registration, no more <link rel="manifest"> injection on the hub.
  • src/main.ts — dropped registerSW from virtual:pwa-register. Added decommissionHubServiceWorker() to clean up legacy SW registrations on existing-user upgrades.
  • src/lib/decommission-hub-sw.ts (new) — idempotent helper that unregisters any SW with scope === ${origin}/. Standalone SWs at deeper scopes (/libra/, /market/, …) are left alone. Safe to leave in place permanently.
  • public/sw.js — deleted. It was the source for a deprecated injectManifest strategy that hadn't been wired up; copied verbatim to dist/ by Vite but never referenced.

Verification

Built locally and confirmed the dist no longer contains sw.js, manifest.webmanifest, or <link rel="manifest"> in index.html.

Headed Chromium (Playwright MCP) at iPhone-13 viewport against the dev hub:

location: http://localhost:5173/
hasManifestLink: false
manifestHref: null
swRegistrations: []
swController: null

End-to-end browser verification of the production-side scope conflict is captured in #41 comment.

What this does NOT do

  • iOS Safari "Add to Home Screen" still works (those apple-mobile-web-app-* meta tags are independent of manifest install). Removing them is a separate decision; left in place to keep the diff focused on the Chrome scope-conflict bug.
  • Existing users with the hub PWA installed: the home-screen icon stays until the user uninstalls it. The decommission helper unregisters the service worker on next visit (so no more stale-cache surprises), but cannot remove the home-screen entry — only the user can.

Test plan

  • Build the hub with npm run build — no sw.js, no manifest.webmanifest in dist/.
  • Visit app.${domain} on a Chrome desktop instance that previously had the hub PWA installed: console shows [decommission-hub-sw] Unregistering 1 legacy hub service worker(s). and getRegistrations() is empty after.
  • Visit libra.${domain} (which 301s to app.${domain}/libra/): Chrome offers PWA install. Repeat for market/sortir/wallet/chat/forum/tasks.
  • Confirm the standalones at app.${domain}/libra/ etc. still register their own SWs (scope = /libra/, etc.) and are unaffected.

🤖 Generated with Claude Code

## Summary Fixes #41. The hub's manifest had `scope: '/'`, which claimed the entire `app.${domain}` origin and made Chrome treat the path-mounted standalones (`/libra/`, `/market/`, `/sortir/`, …) as sub-areas of the already-installed hub PWA — suppressing the install affordance on each standalone. Drop the hub's PWA install entirely. The hub is a tile-grid launcher; users install the standalones they actually use. The libra/market/sortir/etc. PWAs at deeper scopes are unaffected and remain independently installable. ## Changes - **`vite.config.ts`** — removed the `VitePWA(...)` plugin block (and its import). No more manifest, no more SW registration, no more `<link rel="manifest">` injection on the hub. - **`src/main.ts`** — dropped `registerSW` from `virtual:pwa-register`. Added `decommissionHubServiceWorker()` to clean up legacy SW registrations on existing-user upgrades. - **`src/lib/decommission-hub-sw.ts`** *(new)* — idempotent helper that unregisters any SW with scope === `${origin}/`. Standalone SWs at deeper scopes (`/libra/`, `/market/`, …) are left alone. Safe to leave in place permanently. - **`public/sw.js`** — deleted. It was the source for a deprecated `injectManifest` strategy that hadn't been wired up; copied verbatim to `dist/` by Vite but never referenced. ## Verification Built locally and confirmed the dist no longer contains `sw.js`, `manifest.webmanifest`, or `<link rel="manifest">` in `index.html`. Headed Chromium (Playwright MCP) at iPhone-13 viewport against the dev hub: ``` location: http://localhost:5173/ hasManifestLink: false manifestHref: null swRegistrations: [] swController: null ``` End-to-end browser verification of the production-side scope conflict is captured in [#41 comment](https://git.atitlan.io/aiolabs/webapp/issues/41#issuecomment-447). ## What this does NOT do - iOS Safari "Add to Home Screen" still works (those `apple-mobile-web-app-*` meta tags are independent of manifest install). Removing them is a separate decision; left in place to keep the diff focused on the Chrome scope-conflict bug. - Existing users with the hub PWA installed: the home-screen icon stays until the user uninstalls it. The decommission helper unregisters the *service worker* on next visit (so no more stale-cache surprises), but cannot remove the home-screen entry — only the user can. ## Test plan - [ ] Build the hub with `npm run build` — no `sw.js`, no `manifest.webmanifest` in `dist/`. - [ ] Visit `app.${domain}` on a Chrome desktop instance that previously had the hub PWA installed: console shows `[decommission-hub-sw] Unregistering 1 legacy hub service worker(s).` and `getRegistrations()` is empty after. - [ ] Visit `libra.${domain}` (which 301s to `app.${domain}/libra/`): Chrome offers PWA install. Repeat for market/sortir/wallet/chat/forum/tasks. - [ ] Confirm the standalones at `app.${domain}/libra/` etc. still register their own SWs (scope = `/libra/`, etc.) and are unaffected. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pre-#41 the hub shipped a Workbox SW with manifest scope `/`, which
claimed the entire app.ariege.io origin and made Chrome treat the
path-mounted standalones at /libra/, /market/, etc. as sub-areas of the
already-installed hub PWA — suppressing the install affordance for each
standalone.

Drop the VitePWA plugin from the hub entirely. The hub is a tile-grid
launcher; users install the standalones they actually use. Add a
decommission helper that runs on every hub boot and unregisters any
legacy hub SW, so users who installed the old hub PWA get cleaned up
automatically. Standalone SWs at deeper scopes are left alone.
padreug deleted branch fix/issue-41-drop-hub-pwa 2026-05-06 06:08:58 +00:00
Sign in to join this conversation.
No description provided.