posit-dev / positron

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

R: Close Viewer after Shiny application exits #5344

Open jmcphers opened 1 week ago

jmcphers commented 1 week ago

System details:

Positron and OS details:

Positron Version: 2024.12.0 (Universal) build 21
Code - OSS Version: 1.93.0
Commit: 83d516172b17d2ae02da8b01411de646cb1117c9
Date: 2024-11-12T02:41:39.000Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

Interpreter details:

R 4.4.1

Describe the issue:

After a Shiny application exits, it is still visible in the Viewer.

Image

Steps to reproduce the issue:

Start R, then run the following code:

shiny::runExample("01_hello")

Then, press the Stop button in the Console. The Shiny app exits, but remains visible in the Viewer pane.

Expected or desired behavior:

Once the Shiny app has exited, it should be removed from the Viewer.

This would require Positron to either have some specific knowledge about how Shiny works, or to expose an API that the Shiny extension could use to implement this behavior.

For reference, here's where RStudio listens for Shiny's disconnected message to implement this behavior:

https://github.com/rstudio/rstudio/blob/main/src/gwt/src/org/rstudio/studio/client/shiny/ShinyDisconnectNotifier.java

(originally noted by @jennybc)