-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: Fully reload ui/server when autoreload occurs #4184
base: main
Are you sure you want to change the base?
Conversation
* feat: Use {watcher} * chore: shikokuchuo/watcher@dev * chore: watcher is on CRAN now * chore: Undo air format changes * feat: Use `shiny.autoreload.interval` for watcher latency * chore: Simply track last time auto-reload changed * docs: rewrite options docs for clarity
Updated since approved, changes now include reloading global+support files in ui/server apps
@jcheng5 Can you take another quick look at this PR? After testing I realized that it's equally confusing not to load changes in |
DESCRIPTION
Outdated
lifecycle (>= 0.2.0), | ||
watcher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would feel better if watcher
wasn't a hard requirement because of its somewhat non-standard system dependencies for building from source.
We do, unfortunately, have lots of users/customers running older versions of R where binaries won't be available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want to go all the way to this end, but in b3f2948 I restored the legacy autoreload behavior and moved watcher
to suggests, with a warning to install watcher
for an improved experience.
if (!isFALSE(getOption("shiny.autoreload.legacy_warning", TRUE))) { | ||
cli::cli_warn( | ||
c( | ||
"Using legacy autoreload file watching. Please install {.pkg watcher} for a more performant autoreload file watcher.", | ||
"i" = "Set {.run options(shiny.autoreload.legacy_warning = FALSE)} to suppress this warning." | ||
), | ||
.frequency = "regularly", | ||
.frequency_id = "shiny.autoreload.legacy_warning" | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpsievert Should this use get_devmode_option()
? And if so, what would that look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, I don't think shiny.autoreload.legacy_warning
should be documented anywhere, but I do envision someone wanting to suppress the message entirely if they don't want to use watcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like get_devmode_option()
is necessary. The only reason to use it is if you want the option's default to be different when devmode(TRUE)
is activated
This PR updates the auto reload to fully reload both the UI and server source code when any change is detected in the watched autoreload files.
Previously, auto reload would trigger a refresh of the app but the UI or server functions would be updated only if the
ui.R
orserver.R
files themselves changed (or both if using a single-file app source).This PR updates auto reloading so that any change to the files matching
shiny.autoreload.pattern
causes both the UI and server source to be reloaded.This fixes two long-standing open issues:
Fixes #2711
Fixes #1142
Example app
For testing, the following app sources R files and uses stylesheets outside the main
app.R
. Currently, inmain
, any changes to the supporting files causes the app to be reloaded but the reloaded app does not reflect the changes.After this PR, changes to support files are reflected after the reload.
Example app on shinylive.
TODO