Reloading with busy runtime looks frozen, breaks LSP
To reproduce:
- Start R
- Run
Sys.sleep(60)or another long-running command - Reload the Positron window (Cmd+R or Reload Window)
- Attempt to run another R command
It looks like you can run another R command, but you can't. The runtime appears to be frozen.
https://github.com/posit-dev/positron/assets/470418/d214ba80-fb11-4b78-b0b7-c1ff349c9de6
Shortly after reload, the LSP also fails to start:
The source of both of these problems is that Positron is trying to reconnect to a runtime that is busy running code, but Positron doesn't know it's busy running code. Consequently we don't show any busy UI, we offer an input prompt, and we try to start the LSP (which is not something you can do during a computation, at least not in R).
The right solution to this probably requires an intermediary layer (as in #1155), but perhaps as a stopgap we can implement it directly in the language packs in some way.
I see exactly the same behaviour in Python
This is necessary for Posit Workbench support; without it, if you close the browser while a computation is running and later reconnect, Python/R will be frozen until the computation is completed. This is very undesirable.
I have a change on a branch that addresses this using the new Jupyter kernel supervisor.
Update: In my testing this works OK for Python. R is better -- it does wait to reattach the LSP until R isn't busy -- but when it does reattach the LSP it crashes ark. This may be an ark bug or may be an ordering issue we can/should resolve on the Positron side.
Ready to verify for Python; I'll open a separate bug for R as noted above. Note that you'll need to enable the new supervisor to verify!
With the new supervisor enabled, it now waits for the running command to finish, and pops a toast message .