Opening httpgd plot in external window through VSCode Workbench proxy server

When using VSCode on Posit Workbench with R plots configured to open using httpgd, I get an option to open the plot in an external window. That link will fail, somewhat predictably, because the link is to a localhost address and Workbench is accessed over the internet. Doing this will start a proxy server to get around this, but I can't get httpgd to work through the proxy server - initially because the URL in the proxy server is incomplete, but even when this is corrected, it doesn't seem to display plots.

Steps to recreate:

  1. In Posit Workbench, open a VSCode session
  2. Install httpgd
  3. in VSCode settings, activate that R plots should open in httpgd:
    "r.plot.useHttpgd": true
    
  4. In an R Interactive session, create a simple plot, e.g.
    plot(1:10)
    
  5. Hover a mouse over the plot that appears, then choose "open in external browser" in the menu that appears above the plot. This will open a new tab that should fail.
  6. In the RStudio/Posit Workbench menu, find the proxied server for "R". This will open a new tab that should display a 404. Leave this page open for now and return to VSCode.
    image
  7. In the R console run httpgd::hgd_url() and note the slug of the address. In this example the slug would be live?token=LylcTruU
    httpgd::hgd_url()
    ## [1] "http://127.0.0.1:40705/live?token=LylcTruU"
    
  8. Go back to the page from step 6 and add the slug from step 7 to the end of the URL. Load the new address. The httpgd layout should appear, but no plots seem to be present.

I can get this to work on Visual Studio Code running locally, but can't seem to get plots to appear in Workbench. I'm not sure whether this is a httpgd issue or a configuration setting I need to change in Posit Workbench or VSCode for the proxied servers to work slightly differently.

Does anyone have ideas on where to look next in diagnosing this issue?

Thanks

Try using rserver-url to generate the address of the plot you want to visit:

https://docs.posit.co/ide/server-pro/user/posit-workbench/guide/python.html#url-prefixes