Skip to content

feat(reactlog_widget): Add an htmlwidget for the reactlog (#160) - #161

Draft
schloerke wants to merge 2 commits into
mainfrom
schloerke/160-reactlog-htmlwidgets-add
Draft

schloerke wants to merge 2 commits into
mainfrom
schloerke/160-reactlog-htmlwidgets-add

Conversation

@schloerke

@schloerke schloerke commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #160. Adds reactlog_widget(), which shows the reactlog as an htmlwidget so it can be embedded in R Markdown or Quarto documents or shown in the RStudio viewer. Like reactlog_show(), log defaults to shiny::reactlog(), and ... (such as session_token) is passed on. For Shiny apps, adds reactlog_widget_output() / render_reactlog_widget() and a module, reactlog_widget_module_ui() / reactlog_widget_module_server(), which shows the widget with a refresh button. htmlwidgets, shinytest2, and withr are added to Suggests; rlang is added to Imports for rlang::check_installed().

The widget puts the CSS, JS, and SVG images into one HTML string and shows it in an <iframe srcdoc>, which keeps the app's globals and element ids apart from the host page. The page-building part of reactlog_render() moved into a helper, reactlog_page_html(). Both modules share one refresh button helper. No srcts/ changes.

Each widget carries its own copy of the ~590 KB JS file, and the log is a snapshot taken when the widget renders. In Shiny, the first render runs before Shiny's first idle, so the widget needs one refresh to show a full step. New shinytest2 tests check that the iframe module, render_reactlog_widget(), and the widget module each load new log entries after a refresh; unit tests check that the widget renders and has no leftover asset paths or broken base64 data.

reactlog_widget() inlines the reactlog page and shows it in an iframe,
so it can be embedded in R Markdown or Quarto. Like reactlog_show(),
log defaults to shiny::reactlog(). htmlwidgets is a suggested package,
checked at run time with rlang::check_installed().
…test2 tests

Add reactlog_widget_output() and render_reactlog_widget(), plus
reactlog_widget_module_ui() and reactlog_widget_module_server(), which
show the widget with a refresh button. Add shinytest2 tests that check
the iframe module, the render function, and the widget module load new
log entries after a refresh.

This branch has not been deployed

No deployments
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.

feat: add widget support

1 participant