Activate the config for a package before displaying it#371
Conversation
|
Sorry to let this sit for so long, will hopefully review soon. |
|
This seems like the right thing to do, but I'm not sure about the visibility / stability of activateConfig - it's not documented, etc. I'm personally down with using it directly in a core package since I'm happy to keep settings-view updated to track API chances, but it sets an example for how other packages might want to interact with packages and we should consider whether it's an API we want to document & commit to for a year+ (or at least put a big warning PRIVATE API USE DON'T DO THIS AT HOME message in settings-view, which makes me feel a bit uneasy). I personally think activateConfig is pretty useful here and would like to merge but but there must be a reason that Package isn't part of the public API. Maybe someone else on @atom/core has some feedback / knows more about why Package is private. |
|
Currently the entire This really brings to light a problem with hanging our config off of the package's main module. The schema should really be a separate JSON file that can be read independently. It makes me somewhat nervous that this will cause us to require the main module of packages the user has deactivated. True, it won't call |
|
While I think that 99% of the time, requiring the main module and calling
... is a good halfway point if we have to compromise. I'm nervous about running unactivated package code as well, but I feel like modifying editor state upon require is such egregiously bad practice that if it does happen it will be quickly noticed / complained about / fixed by package authors. |
|
After sleeping on this, I really think we should set a good precedent and only require the main module when a package is actually active. It seems like not a huge deal right now, but reading and evaluating JS is a pretty nasty synchronous dependency to bake into expectations around simply rendering a config UI. Would anyone be interested in helping to move the config schema stuff to a separate file? We would still need to support config on the main module. In that case, I think we should show a disabled UI in the settings view. That will motivate people to move their config off the main module. |
|
Would it not make sense to apply this for now so that Packages work as expected whilst the Package API is changed? |
|
@kevinsawicki Can you chime in on this? I'm unsure how to proceed. To summarize: In order to display a config UI for inactive packages, we need to require the main module in order to retrieve their config schema. This demonstrates that config schemas shouldn't be on the main module, but in a separate file. But they are in the main module right now. So the question is, should we require the main module to I suppose we could always change the policy later when we add config schemas as separate files to show a disabled view for packages that don't offer an external config schema. |
|
FWIW I've come around to "deactivated packages should never load code" and changed my mind on |
|
Just to give some context, this type of code (calling It looks like it was removed here though I'm not sure if it was intentional or not: 2a1ca7e#diff-b7fdec02de14288c9a9e402b91ab5122L38 2a1ca7e#diff-b7fdec02de14288c9a9e402b91ab5122L215 So since it used to do this, I'd prefer to just resurrect how it was done since that process seemed to work for a long time, unless I'm missing a new wrinkle. |
|
I do think pushing the config schema into the |
|
@thedaniel I'm happy enough to follow @kevinsawicki's lead on this. Do you want to merge this at your discretion? |
|
I want to be dogmatic about it but I concede. @Arcath can you add a comment near the activateConfig call indicating it's a private api and not appropriate for use in 3rd party packages? With that I'll merge. |
There was a problem hiding this comment.
I think this should be done in a next tick (like it used to be) since activating the config for ~100 packages will probably take some time and at least the settings view will get a chance to render and "feel" like it is continuing to load while the configs are activating.
There was a problem hiding this comment.
This is on the installed-package view so its only loading the package you've opened not all of them.
|
Just added it now, sorry for taking so long I've been off ill the last week. |
|
This PR is no longer mergeable. Looking at the last few comments in this thread it seems that @thedaniel wanted to merge this is @Arcath made a change. That change was made by @Arcath a month ago but it seems that some other changes on master made the PR unmergeable. @thedaniel -- would you still be 👍 on merging this if the merge conflicts are resolved? |
|
@izuzak yeah, this can merge if the conflicts are resolved. We still need to make config static at some point but this is confusing to users in master right now. |
|
I went ahead and resolved the merge conflict. @kevinsawicki it would be really great to get a release out for this tomorrow or Tuesday in time for my workshop, because not loading the configuration until activation represents a hurdle I'd rather avoid explaining to people. |
|
@nathansobo when's your workshop? This broke viewing details for not-yet-installed packages so you're probably going to need another release before you talk to a class. |
|
I'm just going to remove activation commands for the package were building and make it a non-issue. Sorry for the breakage. |
|
No reason to apologize, I should have looked more closely before 👍 - also this wasn't broken in a release, just on master (i was mistaken) |
Was planning on releasing in the next hour or so |
0.191 is now out |
Fixes #356 by calling
Package.activateConfig()if the package is not yet active.