Soften visually jarring greyout when autoreloading #3915
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(Note: This mostly doesn't apply to Shiny for R, because autoreloading is pretty quick, but rather for Shiny for Python, which terminates the existing Shiny process before starting a new one.)
This change detects when Shiny is autoreloading, and instead of showing the typical disconnection treatment (dark grey), it initially shows nothing and then quickly fades to very light grey.
The goal is for instant autoreloads to feel seamless, but longer autoreloads to make it clear when the autoreload has completed, and still not feel as jarring as a full disconnect.
TODO
Testing Notes (softened greyout during autoreload)
This can only be tested when the copies of shiny-autoreload.js and shiny(.min).js and shiny.css from inst/www/shared are all copied to a Shiny for Python installation.
import time; time.sleep(3)
to the app.py, and save it. Now you should see it fade to a lighter grey before reloading.raise RuntimeError("boom")
to the app's server function. Now you should see the app turn the darker grey on load. (Autoreload should still work, but shouldn't make the dark grey lighter.)Testing Notes (auto-reload after computer sleep)
options(shiny.devmode=TRUE)
or Shiny for Python withshiny run --reload
or by using the Shiny for Python VS Code extension's "Run Shiny App" button.) If using RStudio, pop the Viewer out into an external window and use that browser to test instead of Viewer.With this change, the greyed-out apps should reload.