-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusion between static and dynamic app shortcuts #1
Comments
+1, I expected this method to return everything. We might need a flag to differentiate dynamic from static shortcuts maybe. |
That makes sense. I'm not sure what utility exposing the static shortcuts would provide though, and wanted to avoid lengthy names. It's probably better to be explicit and include I also favoured API simplicity for now as you can see, with only getters/setters. Do you folks have any thoughts on that? |
I like your simple approach. To be honest, I'm not even sure |
Taking a step back, why do we need to create two distinct classes of shortcuts? Why not allow the manifest-defined shortcuts to be read and modified too? Having a distinction just feels overly complex to me. Doubly so because there will be hard limits on the # that can be defined, which will vary by OS (and possibly browser). |
There a few reasons why, and I believe having this distinction will reduce the overall complexity. For one thing, the web app manifest is a static representation of the manifest, and non of its fields are mutable. It would make things inconsistent to add distinction for shortcuts. Also, some platforms have the distinction between static & dynamic shortcuts (like Android). Static shortcuts need to be declared in the manifest and can't be changed. The type of shortcut used also reflects the website's use-case. As for the shortcut hard limits, we can leave the number of shortcuts displayed as a UA decision, but enforce they appear in the order they were declared in. |
I agree to an extent… though app icons and shortcut icons may be modified by the OS in specific ways. It’s also possible for a Service Worker to intercept (and modify) requests for & responses to external resources referenced by the Manifest, right? When the sw-launch event lands, that will also allows scripting to adjust default behavior. I think the main issue I have with this approach is that drawing this distinction closes the door to progressive enhancement of a declarative baseline into an enhanced experience through scripting. I’ll give you an example: Consider a media PWA. They may want to offer a generic "Continue Watching" link which would be available regardless, defined in the Manifest. When the JS API is available, however, they could replace that with "Continue Watching {{ show_name }}". Only allowing dynamic Shortcuts to be set via scripting would require the author to choose a baseline experience for everyone or an enhanced experience for a smaller audience (and no experience if there’s a JS error).
Based on my research for v1 of this spec, I believe that Android and iOS are the only platforms that draw this distinction. If it’s a hindrance to implementing on those platforms and we generally agree that a single mutable list of Shortcuts is desirable, it seems like these implementation could consider them all dynamic shortcuts, regardless of where they are defined. (Although it’s worth noting that iOS seems to consider even dynamic shortcuts immutable.) Linux variants, macOS, and Windows (and, by extension, Electron) do not seem to draw this distinction. I think it might make sense to put this question out to the PWA community:
Thoughts? |
I'm still leaning towards keeping the distinction between static/dynamic, although you do raise some very good points. My reasoning is:
But yeah, I agree that there isn't a clear-cut solution. I like the idea of getting feedback from the PWA community. |
Agreed on the first point, but not the second. Static/declarative provides a great baseline.
Totally disagree on this point. Shortcuts defined in the Manifest cover the vast majority of use cases and provide a solid foundation (as I mentioned above). If it was JS API only, it would be inherently more fragile too.
Totally true. But it would be inherently more fragile (because it's JavaScript). Also, at least as I understand it, in creating two classes of shortcuts, you're making it impossible to interleave them in any way, which also may be undesirable and would force devs to go all in on the JS API if they wanted to have an early (as in ordering) shortcut with a dynamic label even if all the rest of the shortcuts are static.
Agreed. Static offer a TON of benefits & I am not suggesting we get rid of them at all. Question: In the Android implementation, would it be possible to pick up the manifest's shortcuts during the build process and have them implemented as dynamic shortcuts (as opposed to static shortcuts) under the hood? |
Can you explain why JavaScript is "fragile"? |
Sure! Because our JavaScript programs are executed on the client and we don’t control that environment, we can't guarantee that the code will run or that it will run as intended. See also:
These are just a couple of articles discussing this lack of control and how it can expose fragility. |
Kind of. If we register all web shortcuts as dynamic android shortcuts under the hood, we'd reach the state I was telling you about where you'd only get the shortcuts after launching the PWA. Also, shortcuts v1 was already launched and uses static shortcuts under the hood, migrating away from that would also require some work. |
I'll write up the details of both approaches and then share them to make sure it's all accurate. From there, I'll put together a survey to see what the preference of web developers is. |
On desktop, installation triggers the PWA to open/re-parent. Could Android follow that model too (rather than leaving you on the website)? That would mitigate this issue, no? For what it's worth, I also find remaining in the tab (and having to hunt for the PWA icon separately) confusing.
While I agree that it sucks to redo work, I don't think that should be a factor in deciding the best overall approach for the web platform. |
No, users need to explicitly launch the app. There are some technical reasons for that related to how Android works.
Agreed. I was just pointing it out. |
Here’s a draft post introducing the situation and setting up the poll. I originally thought about making a comparison table, but it got complicated quickly. I think if we wade too far into the weeds of implementation it will be overwhelming for folks and that end is honestly more on us than anyone else. I think it’s better to make it a (hopefully) simple question:
Feedback and corrections welcome. |
Thanks Aaron, this is great! I think you hit the right balance Edit: I'd just clarify that it's about javascript edit access to manifest shortcuts in your poll. I like the way @beaufortfrancois broke it into three options here |
Separate: I want immutable static shortcuts and separate dynamic shortcuts accessible from JavaScript. |
Combined [1]: I want JavaScript read access to all shortcuts, regardless of how they are defined. And I want to be able to add/update/remove new app shortcuts dynamically. Static ones still persist as they are defined once in the PWA manifest. |
Combined [2]: I want JavaScript read and write access to all shortcuts, regardless of how they are defined. This means I can edit/remove app shortcuts statically defined in the PWA manifest. |
If we would go with Combined [2], this means that when a website creates app shortcuts dynamically, then user installs the PWA with app shortcuts defined in its manifest, the browser would remove all app shortcuts previously created in JavaScript and replace all of them with static ones from the manifest. |
In order to fit these options, I may need to heavily edit or thread several tweets together :-) Will share a link shortly. |
As Shortcuts are only supported for installed PWAs currently, I don’t see this as an issue because the dynamic shortcuts will never be created without the static shortcuts preexisting them. |
Attempting to piece the poll together… How would you prefer to manage PWA Shortcuts in JavaScript? Read/write dynamic: I want immutable "static" Shortcuts and separate "dynamic" Shortcuts I can add/update/remove via JavaScript. Read all/write dynamic: I want JavaScript read access to all shortcuts, regardless of how they are defined and I want to be able to add/update/remove new app shortcuts dynamically. Static ones would persist as defined by the Manifest. Read/write all: I want JavaScript access to all shortcuts, regardless of how they are defined. This means I can update/remove Shortcuts defined in the Manifest too.
|
We'd still need to work out what would happen in that scenario if we go with the The poll looks great to me! |
@rayankans and I chatted via email, but I thought I’d summarize the results of the Twitter poll here. The sample size was small (31 respondents), so this should be taken with a grain of salt, but I do think it helps us gauge general interest.
Given the small sample size, I think we should do a bit more investigation before deciding on a direction to go:
Once we gather more information from developers in these two areas, we should start to see the contours of what’s needed as far as this API is concerned. |
Added the use cases here: https://github.com/rayankans/app-shortcuts/blob/master/use-cases.md |
What happens when the manifest updates its shortcuts after JavaScript has mutated them? |
The namespace
navigator.shortcuts
seems to imply that app shortcuts are defined there.However this seems to be specific to dynamic shortcuts.
I suspect web developers will expect to get both static and dynamic app shortcuts with
await navigator.shortcuts.getAll();
I know I did.We could either change the name of namespace with
navigator.dynamicAppShortcuts
(or something similar) or change the name of thegetAllI()
method withnavigator.shortcuts.getDynamicShortcuts()
.The text was updated successfully, but these errors were encountered: