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

Add option to control startup behavior per language #6145

Merged
merged 29 commits into from
Jan 30, 2025

Conversation

jmcphers
Copy link
Collaborator

@jmcphers jmcphers commented Jan 28, 2025

This change adds a new option that can be used to gain more control of how Positron starts an interpreter for each language.

image

The default value, auto, gives the automatic behavior we have today; the others (enumerated in documentation elsewhere) are new behaviors.

In addition, this PR adds a new feature that allows a language pack to tell Positron which runtime to start for a workspace before discovering all the runtimes on the machine. This happens during the Starting phase of the startup lifecycle.

Addresses #3575.

Release Notes

New Features

Bug Fixes

  • N/A

QA Notes

This new option replaces the old interpreters.automaticStartup option (I think having both would be too confusing). If memory serves we're using that today in the qa-example-content repro. PR updating this option here: posit-dev/qa-example-content#44

As a debugging aid, I've added a way to show and clear which runtimes are "affiliated" with the workspace. The new Interpreter: Clear Saved Interpreter command can be used to show you which R/Python/etc. versions Positron has saved as the ones for your workspace.

image

We will ultimately need more and better UI for choosing what interpreter is associated with your project; this command should be seen as a stopgap/debugging aid.

I've also added a couple of options to the Zed test language runtime so that in a dev build you can try out the 'recommended for workspace' workflow.

image

Copy link

github-actions bot commented Jan 28, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@jmcphers jmcphers changed the title Feature/startup behavior configuration Add option to control startup behavior per language Jan 28, 2025
@jmcphers jmcphers requested a review from sharon-wang January 29, 2025 00:22
Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to set up my workspace as R-only and not see any other language runtimes 🎉

Showing the settings.json directly, as I can't seem to show the Python and Zed settings overrides at the same time in the Settings UI.
image

Clearing the affiliated interpreter worked well when I had startupBehavior "manual" 👍

extensions/positron-javascript/src/commands.ts Outdated Show resolved Hide resolved
// Remove the mainThreadLanguageRuntime instance id to the set of mainThreadLanguageRuntimes.
this._discoveryCompleteByExtHostId.delete(id);
this._logService.debug(`[Runtime startup] Unregistered extension host with id: ${id}.`);
// this._discoveryCompleteByExtHostId.set(id, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe leftover or unintentionally commented out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think this just needs to pass the right ID value. Thanks!

enumDescriptions: [
nls.localize(
'positron.runtime.startupBehavior.always',
"An interpreter will start in each new Positron window."),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say a bit more about which interpreter might start, to differentiate from auto and recommended? Perhaps we can say something like "the interpreter Positron has affiliated with the workspace", or something like "Positron will infer which interpreter to start based on previous usage and extension metadata." (although this is starting to sound like auto...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I took a crack at improving this in 8f0473c. This option is hard to describe succinctly and it really only makes sense when used for a specific language. I think only admins are likely to set it, though I could be wrong!

* right away, or any other value to save the runtime as the project
* default without starting it.
*/
recommendedWorkspaceRuntime(): Thenable<LanguageRuntimeMetadata | undefined>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking my understanding! Does this sound right?

Extensions will determine this recommended runtime, likely with this order of precedence:

  1. Has the user indicated a default runtime at the Workspace level? i.e. python.defaultInterpreterPath, an upcoming r.interpreters.default option; startupBehavior Immediately
  2. Is anything else in this workspace indicating a preferred runtime? i.e. Venv, DESCRIPTION, etc.; startupBehavior Immediately
  3. Consult User-level setting for default runtime? i.e. python.defaultInterpreterPath, an upcoming r.interpreters.default option; startupBehavior Implicit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just about! For (1) I don't think we want Immediately because having the admin specific default paths doesn't necessarily mean that we want to always start that interpreter (i.e. "use this python by default" != "always start python in every project").

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha -- thank you! Updating my notes accordingly 👌

Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

One last thought: where should we add some documentation on how to configure this -- Positron docs vs Admin docs?

@jmcphers
Copy link
Collaborator Author

Both are probably helpful! I think admin docs are the most important since the primary motivation is Workbench.

@jmcphers jmcphers merged commit 5177ff7 into main Jan 30, 2025
28 checks passed
@jmcphers jmcphers deleted the feature/startup-behavior-configuration branch January 30, 2025 21:36
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants