Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[poc] embed html widgets in the console #12048

Closed
wants to merge 12 commits into from

Conversation

romainfrancois
Copy link
Contributor

Intent

display html widgets directly in the console. This may be useful for e.g. error messages, e.g. r-lib/rlang#1440

Approach

.rs.api.console_viewer() similar to .rs.api.viewer() (for widgets) but the rsult goes i the console:

image

Automated Tests

Indicate whether this change includes unit tests or integration tests, or link a work item or pull request to add those tests to another repo. If the change cannot or will not be covered by a test, indicate why.

QA Notes

Add additional information for QA on how to validate the change, paying special attention to the level of risk, adjacent areas that could be affected by the change, and any important contextual information not present in the linked issues.

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

@romainfrancois
Copy link
Contributor Author

This is still very rough, but if we get this to work, then it's just a matter of writing some htmltools ui code.

Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM!

One open question: do these widgets need to be persisted in some way in the console history, or do we need any special handling there? This is mainly relevant to RStudio Server, where we need to persist the console history for the user in case they reload the browser (or close and then later reconnect).

It's probably fine if we don't do anything here but worth testing to make sure that these widgets don't break anything (just in case).

src/cpp/r/R/Api.R Outdated Show resolved Hide resolved
src/cpp/session/include/session/SessionModuleContext.hpp Outdated Show resolved Hide resolved
src/cpp/r/R/Api.R Outdated Show resolved Hide resolved
src/cpp/session/modules/viewer/SessionViewer.cpp Outdated Show resolved Hide resolved
src/cpp/session/modules/viewer/SessionViewer.cpp Outdated Show resolved Hide resolved
LOG_ERROR(error);

// if it's in the temp dir then we can serve it via the help server,
// otherwise we need to show it in an external browser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still true?

if (isHTMLWidgetPath(filePath))
{
// view it
consoleShowWidget(module_context::sessionTempDirUrl(path), height);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: if there's only one "target" code path you could probably reduce the indentation in this function with some early returns for cases where validity conditions aren't satisfied.

@romainfrancois
Copy link
Contributor Author

Maybe the widgets should get some surrounding like results = "asis" in Rmd:

image

@romainfrancois
Copy link
Contributor Author

👀 .rs.recordHtmlWidget()

@romainfrancois
Copy link
Contributor Author

shelving this for now to declutter the pull requests, we may come back to this later, so keeping the branch just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants