posit-dev / positron

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

profvis::profvis() returns output in browser #3269

Open EmilHvitfeldt opened 5 months ago

EmilHvitfeldt commented 5 months ago

Positron Version:

Positron Version: 2024.05.0 (Universal) build 1306 Code - OSS Version: 1.89.0 Commit: a0232a7fadd6c2221a1d8db8fcb6e4ff42408dd6 Date: 2024-05-24T03:48:15.054Z Electron: 28.2.8 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0

Steps to reproduce the issue:

  1. run profvis::profvis({Sys.sleep(2)})

https://github.com/posit-dev/positron/assets/14034784/5ad13db9-0a86-4982-8663-3d49d953b29b

What did you expect to happen?

For the results to open in the viewer.

Related issue: https://github.com/posit-dev/positron/issues/2090

Were there any error messages in the output or Developer Tools console?

Nope

DavisVaughan commented 4 months ago

I am 80% sure this is https://github.com/posit-dev/positron/issues/3018

jmcphers commented 3 months ago

Profvis isn't showing up in the Viewer because it is explicitly asking not to, via viewer.suppress (which creates an object with suppress_viewer class instead of the htmlwidget class;)

https://github.com/r-lib/profvis/blob/b8233d3f5295be64aa6b5719db457a94cfd5ebf6/R/profvis.R#L224-L227

    sizingPolicy = htmlwidgets::sizingPolicy(
      padding = 0,
      browser.fill = TRUE,
      viewer.suppress = TRUE,
...

I'm guessing it does this to avoid getting opened in RStudio's viewer, which is usually not big enough to show a profvis visualization (plus RStudio wants to show it in an editor tab). But it's also keeping it from getting opened in Positron's viewer.

We will either need a change to Profvis to output something different or a change to Positron to ignore this directive in the case of Profvis (or give Profvis output special treatment in some way -- maybe we could open it in an editor tab like RStudio does).

DavisVaughan commented 2 months ago

profvis respects the global option profvis.print, which can be a function to decide how to handle profvis objects when they are printed out. This is what RStudio sets and uses

> getOption("profvis.print")
function (x) 
{
    .rs.profilePrint(x)
}

I imagine we should set this as well and either: