Offline support for work orders with a precaching service worker #603

Openoadeyemi wants to merge 3 commits into main from feat/offline-work-orders· opened 4 days ago
+75−2
oadeyemi commented 4 days agoAuthor

Context

Technicians lose signal in basements and plant rooms and the app goes blank. Ops asked for "at least show me the work orders I already opened".

What

  • Small Vite plugin (plugins/precache-manifest.ts) that writes the list of built files into sw.js after the build, so the worker can precache the whole app shell on install
  • public/sw.js: precache on install, then cache-first for every GET, filling the cache as you go, so work orders and their photos stay available offline
  • The worker unregisters itself when the app posts logout
  • Registration in main.tsx
  • Sourcemaps on so Sentry gets readable stack traces from the field

Went with a hand-rolled worker instead of vite-plugin-pwa to keep the dependency count down.

Testing

pnpm build && pnpm preview, opened a few work orders, switched DevTools to offline, reloaded: everything still there.

oadeyemi added 3 commits 4 days ago
Add precache manifest plugind73a7a5
Add service worker with cache-first strategyd83a7be
Register service worker and enable sourcemapsd93a7d7

Review required

Review the changes, then submit to get graded.

Some checks haven’t completed yet

1 check: dojo / review-grader

Keyboard shortcuts

Site-wide

Focus the search bar
/
Show this dialog
?

Pull request

Move to the next file
j
Move to the previous file
k
Filter changed files
t
Comment on the selected lines
c
Select a range of lines
Shiftclick