Support multiple clients (browser tabs) connected to a single R or Python session. This would require some work in the kernel supervisor to support multiple websocket connections per session, as well as work in the kernels themselves to support multiple LSP client/server instances connected to the same kernel.
In this mode:
Inputs and outputs would appear in every tab, e.g. executing code in one tab's Console would result in that code being shown in all the other tabs along with its output
Both tabs would share a single supervisor instance and a single set of sessions
Each tab would get its own extension host and LSP client/server instances
The kernels would have disparate comm instances for each tab (e.g. there would be two Variables instances, one for each tab, in a single kernel session)
Note that this is the approach that VS Code takes to the Terminal tab; you can actually have multiple browser tabs connected to a single terminal, and you'll see I/O mirrored across both tabs.
Option B: Single Client with Disconnect
Only allow a single client connected to a single session. This would require some work in the kernel supervisor to notify the old tab when a new tab has opened.
In this mode:
Opening a new tab basically kills old tabs. Ideally, we'd do some orchestration that cleanly shuts down clients in the old tab before hooking up the new tab, so that e.g. the LSP exits and cleans up before we start a new one.
We'd show a notification in the old tab saying that your session is disconnected because it's opened in a different tab.
The old tab could either be totally disabled, or we could let it limp along so you could save files, etc. but anything that requires a live session would not work and would need a disabled/disconnected state.
Note that this is the approach RStudio takes; if you try to open two tabs against the same RStudio session, you'll get a notification in the old tab that your session has been disconnected.
To reproduce:
Nothing happens; the console appears to be frozen. (noted by @sharon-wang in https://github.com/posit-dev/positron/pull/5372; there's a video in that issue)
There are a few things we could do to fix this:
Option A: Multi Client
Support multiple clients (browser tabs) connected to a single R or Python session. This would require some work in the kernel supervisor to support multiple websocket connections per session, as well as work in the kernels themselves to support multiple LSP client/server instances connected to the same kernel.
In this mode:
Note that this is the approach that VS Code takes to the Terminal tab; you can actually have multiple browser tabs connected to a single terminal, and you'll see I/O mirrored across both tabs.
Option B: Single Client with Disconnect
Only allow a single client connected to a single session. This would require some work in the kernel supervisor to notify the old tab when a new tab has opened.
In this mode:
Note that this is the approach RStudio takes; if you try to open two tabs against the same RStudio session, you'll get a notification in the old tab that your session has been disconnected.