microbit-foundation / python-editor-v3

Micro:bit Educational Foundation Python Editor V3
https://python.microbit.org
MIT License
57 stars 37 forks source link

PWA functionality including offline mode (featured flagged) #1170

Closed microbit-robert closed 4 months ago

microbit-robert commented 5 months ago

Notable behaviours:

There are two levels of feature gating:

github-actions[bot] commented 5 months ago

Preview build will be at https://review-python-editor-v3.microbit.org/pwa/

microbit-matt-hillsdon commented 5 months ago

all available languages are precached

Does that mean everyone pays the cost of every language now? Before interactivity or after/in the background?

microbit-robert commented 5 months ago

all available languages are precached

Does that mean everyone pays the cost of every language now? Before interactivity or after/in the background?

For this version, yes. We need to be more specific in what we precache. Maybe nothing language specific and save that for runtime. It does feel like the plugin might not suit our needs. We'll either end up creating just the service worker from scratch, or ditch the plugin and do everything from scratch.

Edit: This has now been resolved by using a mixture of precaching for our fallback language (English) and runtime caching for all other languages.

microbit-robert commented 5 months ago

Toast shown when changing language while offline and language assets are not already cached. Text is a working placeholder and needs discussion.

image

microbit-matt-hillsdon commented 4 months ago
image

This feels a bit odd when in PWA mode as there's no obvious affordance to reload the page. Ideally we'd find a more neutral phrasing.

Perhaps it's best not to change the user's language in this circumstance? That removes the English bias and prevents the weird app state of having chosen but not used a language. So maybe:

Language not available offline

Make sure you are online then try again.
microbit-matt-hillsdon commented 4 months ago

I'll merge this tomorrow when I'm more available for any fallout.

microbit-matt-hillsdon commented 4 months ago

This isn't working in practice as we used scoped service workers but the scope is /v/beta/ but typically access is at /v/beta for staging/production. Ideally we wouldn't redirect to the less pretty URLs.

We could register against a slashless scope by adding a header. It's a prefix match so that's a bit awkward, e.g. /v/3 would also match /v/31 and /v/beta would match /v/betamax. The former seems worth some consideration. Alternatively we just have one and accept the extra reload when switching between versions.

microbit-matt-hillsdon commented 4 months ago

We could register against a slashless scope by adding a header. It's a prefix match so that's a bit awkward

We did this and it now seems to be working. Still behind the flag you need to set in localStorage.