Skip to content

feat: Fully reload ui/server when autoreload occurs #4184

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

Merged
merged 16 commits into from
Apr 24, 2025
Merged

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented Feb 3, 2025

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 or server.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, in main, 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

@gadenbuie gadenbuie requested a review from jcheng5 February 3, 2025 23:05
jcheng5
jcheng5 previously approved these changes Feb 21, 2025
* 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
@gadenbuie gadenbuie requested a review from jcheng5 February 28, 2025 13:43
@gadenbuie gadenbuie dismissed jcheng5’s stale review February 28, 2025 13:44

Updated since approved, changes now include reloading global+support files in ui/server apps

@gadenbuie
Copy link
Member Author

@jcheng5 Can you take another quick look at this PR? After testing I realized that it's equally confusing not to load changes in global.R if you're using the ui.R/server.R app style. These changes add support for reloading those files when shiny.autoreload.r is TRUE: https://github.com/rstudio/shiny/pull/4184/files/aa4a609c4d82de5860522c986bae514836bb01ad..f52efec17ae08e2bf87279a2b8e58cb5914d219c

Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@gadenbuie gadenbuie merged commit f79a22b into main Apr 24, 2025
12 checks passed
@gadenbuie gadenbuie deleted the feat/full-reload branch April 24, 2025 17:53
@ShixiangWang
Copy link

Great

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.

autoreload doesn't load with Shiny modules Autoreload does not load css files
4 participants