Skip to content
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

Provide extensions with additional context in activation method #115638

Closed
eamodio opened this issue Feb 2, 2021 · 6 comments
Closed

Provide extensions with additional context in activation method #115638

eamodio opened this issue Feb 2, 2021 · 6 comments
Assignees
Labels
extensions Issues concerning extensions extensions-development Issues for developing extensions under-discussion Issue is under discussion for relevance, priority, approach

Comments

@eamodio
Copy link
Contributor

eamodio commented Feb 2, 2021

It could be very helpful to provide some additional context into how/why an extension is being activated.

The main motivation for this to allow extensions to more easily/accurately decide on when to have certain "welcome" like experiences or avoid them in the many cases where they are not desired.

For example, if an extension was told in its activate method that it was just installed by the user directly (or through an extension pack), the extension might assume that a "welcome" experience might be desirable. But if the extension was installed because of settings sync, then a "welcome" experience is almost certainly NOT desirable.

Also by "welcome" experience, it could be anything from showing a webivew, notification, or merely switching to a view, etc.

Technically this can be achieved today, with sync'd keys, but it isn't simple to adopt and requires many extensions to do the same work.

Alternatively, instead of a "install" reason, maybe VS Code just does the "sync" work to provide a firstRun flag, so that an extension could just simply use that for its determination.

Additionally, it would be very nice (but largely out of scope for my specific ask here), would be provide the activation event (e.g. the reason) the activate method is getting called. For example, if you are getting activated because of a command, you might change your startup behavior.

If we decide to not do anything here, I would suggest that we add a sample/documentation on how an extension can implement this beahvior.

@tamuratak
Copy link
Contributor

Related to #44711.

@sandy081 sandy081 assigned alexdima and sandy081 and unassigned sandy081 and alexdima Feb 3, 2021
@alexdima
Copy link
Member

alexdima commented Feb 3, 2021

@sandy081 IMHO, I think extensions have been using a pattern where they show a welcome screen on activate by checking for a memento and then saving the memento once the Welcome screen is shown. This worked well, but worked well only on a single machine.

I like the idea to introduce explicit API like e.g. ctx.canShowWelcome. Given the deep connection with settings sync and command line installation (e.g. extension installed due to devcontainer.json), I think you would be a natural fit to own this API. You would know better than me, perhaps this could be implemented straight-forward with global state syncing.

A special API that is provided by vscode has the benefit that we could explicitly set ctx.canShowWelcome to false when we really don't want to show welcome screens, like e.g. when using vscode as a git commit message editor, or reviewing a PR in codespaces, etc.


Additionally, it would be very nice (but largely out of scope for my specific ask here), would be provide the activation event (e.g. the reason) the activate method is getting called. For example, if you are getting activated because of a command, you might change your startup behavior.

This has been requested before in #44711 . See #44711 (comment) for more background on why it might not be desireable to define a closed set of activation reasons, since those reasons might grow over time. (2a, 2b were added later)

@sandy081 sandy081 added extensions Issues concerning extensions extensions-development Issues for developing extensions feature-request Request for new features or functionality labels Feb 4, 2021
@sandy081 sandy081 added this to the Backlog milestone Feb 4, 2021
@sandy081
Copy link
Member

sandy081 commented Feb 4, 2021

/duplicate

#83451

@eamodio
Copy link
Contributor Author

eamodio commented Mar 2, 2021

@sandy081 I don't really think this is a duplicate -- this is just about extra activation "context" where some of that could be used for a welcome experience. It could also be used for startup optimization, etc. Additional context, could be how the extension was installed -- manually, manually via pack, sync, recommendation, etc, etc.

@sandy081 sandy081 removed the *duplicate Issue identified as a duplicate of another issue(s) label Mar 3, 2021
@sandy081
Copy link
Member

sandy081 commented Mar 3, 2021

@eamodio Opening this to understand more about your request - Can you please explain more about the use cases other than welcome experience?

@sandy081 sandy081 removed this from the Backlog milestone Mar 3, 2021
@sandy081 sandy081 added under-discussion Issue is under discussion for relevance, priority, approach and removed feature-request Request for new features or functionality labels Mar 3, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions extensions-development Issues for developing extensions under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

5 participants
@eamodio @alexdima @tamuratak @sandy081 and others