posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.82k stars 90 forks source link

Workbench: Python and R sessions, if opened in multiple browser tabs, work only in the most recent browser tab #5374

Open jmcphers opened 1 week ago

jmcphers commented 1 week ago

To reproduce:

  1. Start a Positron
  2. Start one or more Python or R Consoles and execute a few commands
  3. Open the same Positron session in a new browser tab
  4. Execute a few more Python or R commands in the Console
  5. Switch back to the original tab
  6. Attempt to execute Python or R commands in the Console

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.