Repository navigation
Add multi-session support to Positron - #2415
Merged
Merged
Conversation
This was referenced Mar 8, 2024
Contributor
softwarenerd
suggested changes
Mar 11, 2024
softwarenerd
left a comment
Contributor
There was a problem hiding this comment.
The only real issue I found with this PR is that, for me anyway, it totally breaks R and Python.
Here are a couple of screen recordings:
Screen.Recording.2024-03-10.at.6.14.41.PM.mov
Screen.Recording.2024-03-10.at.6.14.41.PM.mov
I did ALL the things (including rebuild.sh).
I can't start R or Python. I can start Zed:
| import { JupyterSerializedSession, workspaceStateKey } from './JupyterSessionSerialization'; | ||
|
|
||
| /** | ||
| * LangaugeRuntimeAdapter wraps a JupyterKernel in a LanguageRuntime compatible interface. |
Contributor
There was a problem hiding this comment.
Nit: It's now LanguageRuntimeSessionAdapter.
| * runtime. | ||
| */ | ||
| private async runtimeManagerForRuntime(metadata: ILanguageRuntimeMetadata): Promise<LanguageRuntimeManager | undefined> { | ||
| // Doe we already have a manager for this runtime? This happens when we |
| * @param sessionMode The mode in which the session is to be run. | ||
| * @param notebookUri The URI of the notebook document, if in notebook mode. | ||
| * | ||
| * Returns a Thenable that resolves with the ID of the newly created |
Contributor
There was a problem hiding this comment.
Nit comment: A Thenable that resolves to the new language runtime session instead of the ID.
softwarenerd
approved these changes
Mar 12, 2024
softwarenerd
left a comment
Contributor
There was a problem hiding this comment.
Thunderbirds Are Go!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This change adds the infrastructure necessary to support multiple sessions per interpreter to Positron.
Its primary payload is support for making notebook sessions first-class citizens in Positron that can be connected to any of Positron's UI components, but it also addresses a number of other issues and is designed to support other multi-session scenarios.
Primarily addresses #1625.
Also addresses (directly or indirectly):
#1123
#2022
#1067
#634
#1456
Depends on (needs merge coordinated with) https://github.com/posit-dev/positron-python/pull/413.
Approach
Before this change, Positron had a single interface for language runtimes, which bundled two concepts into a class called
LanguageRuntime:metadata(its path, icon, ID, etc.)The main change in this PR is the unbundling of these two concepts into separate entities:
LanguageRuntimeMetadatafor the first andLanguageRuntimeSessionfor the second.Language packs no longer need to provide both of these objects at once; now, it is only necessary to provide the metadata to tell Positron what runtimes are available.
When Positron is ready to start a session, it uses the metadata to ask the language pack to start a new session. The session object that is returned contains the controls for interacting with that specific session.
Services
Before this change, a single
LanguageRuntimeServicehandled everything associated with runtimes. I have decomposed this service into three separate services in order to keep the original service from becoming too monolithic. Because services cannot have cyclic dependencies, the dependency graph is unidirectional:LanguageRuntimeService
This service is a shell of its former self. All it does is provide a store of runtimes that are currently registered, and notify interested parties when that set changes. It could also be called the
RuntimeRegistrationService.RuntimeSessionService
This service provides facilities for maintaining the set of active runtime sessions of all kinds, including "console" sessions (the only kind understood prior to this PR) and "notebook" sessions (the kind introduced here).
Requests to start new sessions, query the set of active sessions, etc. all go through the
RuntimeSessionService.RuntimeStartupService
This service manages the tangled and asynchronous process that coordinates the startup of, and/or reconnection to, the correct runtime(s) for the current workspace. It attempts to organize this process into a sequence of well-defined phases.
Extension Model
The language packs have undergone significant changes to support this work. Most notably, the concept of a "provider" that creates a runtime from metadata is gone. In its place is a new concept: a
RuntimeManager. It has three responsibilities:These changes have enabled a number of improvements to the language packs. Moving a lot of code that use to run at startup time to session creation time has improved performance and fixed a number of bugs.
Session Startup Sequence
The session startup process typically works as follows:
The most notable difference from how things work today is the provisioning step; it takes the place of the creation of the
LanguageRuntimeobject, which used to occur at discovery time.Debugging tools
Finally, this change also includes a debugging tool that lets you:
The tool is only intended for developers and fairly advanced debugging, so it's hidden by default. To turn it on, go here: