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

Soften visually jarring greyout when autoreloading #3915

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Oct 16, 2023

(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

  • Putting computer to sleep with Shiny for Python in VSCode causes the autoreload to be broken. While I'm in this code, I'll have the auto-reload code try to reconnect.

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.

  • Launch a Shiny for Python app using the VS Code extension. Make it one that starts quickly.
  • Make a trivial change and save it. You should see it restart without a flash of grey.
  • Add import time; time.sleep(3) to the app.py, and save it. Now you should see it fade to a lighter grey before reloading.
  • Remove those lines, and add 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)

  • Launch a Shiny app with autoreload turned on. (This can either by Shiny for R with options(shiny.devmode=TRUE) or Shiny for Python with shiny 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.
  • Put the computer to sleep.
  • Wake the computer up. The Shiny apps you left running should be greyed out.
  • Make a trivial change to your app code and save it.

With this change, the greyed-out apps should reload.

@jcheng5 jcheng5 marked this pull request as ready for review October 17, 2023 00:39
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.
Also simplify the implementation for softening the grey curtain when
autoreload is in progress (only applies to Shiny for Python)
@jcheng5 jcheng5 force-pushed the autoreload-indication branch from 26dad15 to 798b336 Compare October 17, 2023 00:40
@jcheng5 jcheng5 requested a review from wch October 17, 2023 00:56
I added this cause I'm slightly worried about other server environments
sending the same 1012 close code.
@jcheng5 jcheng5 merged commit be6f671 into main Oct 18, 2023
11 checks passed
@jcheng5 jcheng5 deleted the autoreload-indication branch October 18, 2023 19:23
@cpsievert
Copy link
Collaborator

@jcheng5 just checking, did you want to mention this in the NEWS?

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.

3 participants