Repository navigation
fix(pwa): follow the phone's rotation lock in the installed app - #159
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe web manifest no longer sets an orientation preference. The service worker no longer serves it from cache-first paths. Tests cover both changes and verify that versioned icons and JavaScript assets still use the fetch listener. ChangesPWA manifest behavior
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Installed Android PWAs can generally follow the phone’s rotation setting, and the updated service worker no longer serves a cached manifest. No material merge risk is established. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change does not appear to expand access to private data or backend services. Replacing the installed app’s cache may, however, leave its offline fallback unavailable until a successful online visit replenishes it. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
…an upgrade (#165) ## Change Follow-up to #159. Reports kept coming after v0.3.32 that the installed Android app still rotates with auto-rotate locked. **Cause.** A service worker from 0.3.31 or older serves `/manifest.webmanifest` cache-first. On the first launch after the server upgrades, that old worker still controls the page, so the document's manifest is the cached one with `orientation: "any"`. The document keeps that manifest after the new worker activates. Chrome's WebAPK update check (`WebApkUpdateManager`, at most once per 24 h per launch) compares against this stale manifest, finds no change, and records the check. The rotation fix then waits at least another day, plus Chrome's charging + unmetered requirement for the re-mint. - `index.html`: the manifest link is `/manifest.webmanifest?v=2`. No old worker has that URL cached, so its cache-first path misses and fetches the current manifest from the network. The server serves it by pathname (`no-cache`, `application/manifest+json`). The installed app keeps its identity: `webapk_update_data_fetcher.cc` accepts a new manifest URL when the manifest `id` (`/`) matches. Existing 0.3.32 installs that already launched once are unaffected by this change and update on the next daily check. Reinstalling applies the fix at once. ## Validation - Chrome 151 + Playwright: installed with v0.3.31's `sw.js` and manifest, then switched the server to the current files and relaunched. `Page.getAppManifest` on the first launch after upgrade: `orientation: "any"` with the plain link (no network request for the manifest), none with `?v=2` (manifest fetched from the network). The second launch has no orientation in both cases. - `bun run build`: `dist/index.html` links `/manifest.webmanifest?v=2`. - Real server: `GET /manifest.webmanifest?v=2` answers 200, `application/manifest+json`, `Cache-Control: no-cache`, no `orientation`. - `HERDR_TEST_MODE=unit bun test ./src/pwa.test.ts`: 2 pass.
Change
Reported: the installed PWA on Android rotates sideways when the phone is tilted, even with auto-rotate locked.
Cause. The manifest set
"orientation": "any". Chrome for Android mapsanytoSCREEN_ORIENTATION_FULL_SENSOR, which rotates by the sensor and ignores the system rotation lock. Chromium changed this toFULL_USERonly in June 2026 (commit 73b80c267b, crbug 40880635), so current and older Chrome releases still behave this way. With noorientation, the lock type isDEFAULT, which maps toSCREEN_ORIENTATION_USER(orUNSPECIFIEDon older Chrome). Both follow the phone's setting, and the app still rotates when auto-rotate is on.Second cause, which kept the fix from reaching installs.
sw.jsserved/manifest.webmanifestcache-first under a cache name that never changed. The browser rereads the manifest to update an installed app (WebAPKORIENTATION_DIFFERS), so every install stayed on the manifest it first cached.server/static.tsalready marks the manifest as must-revalidate; the service worker was overriding that.public/manifest.webmanifest:orientationremoved.public/sw.js: the manifest is no longer cache-first, so it goes through the HTTP cache and revalidates.CACHE_NAMEbumped to v3, so activation deletes the manifest already cached on devices.src/pwa.test.ts: the manifest has no orientation, and the realsw.jsfetch listener leaves the manifest alone while icons and hashed assets stay cache-first. Both tests fail against the previous files.Existing installs pick this up the next time Chrome checks the installed app for updates (on launch, at most about once a day). Reinstalling applies it at once. iOS ignores the manifest orientation and already follows its rotation lock.
Test plan
bun run typecheckbun run test:unit(441 pass)src/pwa.test.tsfails on the old manifest andsw.js, passes on the new onesbun run build:dist/manifest.webmanifesthas noorientation;dist/sw.jsisherdr-web-ui-v3-ramand has no cache-first manifest