Make Open MCT installable and usable offline as a Progressive Web App
Is your feature request related to a problem? Please describe. Open MCT runs only as a regular browser tab. It cannot be installed as a standalone application on a desktop or mobile device, and it does not load at all without a network connection, even though the entire build is static and the demo application persists everything in local storage. Operators on flaky links or on mobile devices have no way to keep the application available.
Describe the solution you'd like Make Open MCT a Progressive Web App:
- Ship a web app manifest and installable icons (192px, 512px, maskable, SVG, and an Apple touch icon) with the build, and reference them from
index.html, so browsers offer to install Open MCT. - Ship a service worker that precaches the Open MCT build (
openmct.js, workers, themes, fonts, images,index.html) in a cache named after the build, serves those assets cache-first, serves page loads network-first with a cached fallback, and passes every other request (telemetry and persistence APIs, cross-origin, non-GET) straight to the network. - Add an
openmct.plugins.PWA()plugin that registers the service worker after the application starts, periodically checks for a new build, and shows a notification with a reload link when one has been installed. A new build must never be activated underneath an open page. - Generate the precache list at build time so that every build produces a new service worker version.
- Document the feature in API.md, and cover it with unit and e2e tests (manifest validity, registration scope, offline load and navigation, update notification and activation).
Describe alternatives you've considered
- Using a third-party service worker generator such as Workbox. It adds a dependency and a large amount of generality for what is a small, fixed set of static assets; a hand-written worker with a build-time asset list is easier to audit and to unit test.
- Registering the service worker unconditionally from
index.htmlinstead of via a plugin. A plugin keeps the behaviour opt-in for downstream applications and gives them a place to configure the worker URL, scope, and update behaviour.
Additional context
Service workers require a secure origin, so the offline behaviour applies to deployments served over HTTPS (and to localhost during development). Making telemetry or domain objects available offline is out of scope; the service worker deliberately never caches API responses.
Testing instructions:
npm run build:prod, then serve thedistdirectory over HTTP (for examplepython3 -m http.server 8099insidedist).- Open
http://localhost:8099/in Chrome. The address bar should offer to install the app; DevTools > Application should showserviceWorker.jsactivated and anopenmct-pwa-<hash>cache. - In DevTools > Network tick "Offline" and reload. The application should load and be usable.
- Rebuild (or edit the
versionindist/serviceWorkerManifest.js), go back online and wait up to an hour or run(await navigator.serviceWorker.ready).update()in the console. A "A new version of Open MCT is available." notification with a "Reload to update" link should appear; clicking it reloads onto the new build and removes the old cache.
Source: nasa/openmct