Handling async repo list fetching
Created by: quinnkeast
Problem
When the user finishes selecting repositories from the "Add/manage repositories" view, the current behaviour is to immediately redirect them to the "Repositories" view with the list of all repositories. When the user chooses to "Sync all repositories" the request is made asynchronously by our backend, because it may take a long time to fetch a list of all the repositories from the code hosts. The problem with this immediate redirect to the "Repositories" view is we may not have finished fetching the list of repositories yet, so they just get a blank screen.
In this scenario, we're just fetching the repository listing—not cloning the repos.
A "loading" state on the "Repositories" view isn't the right timing/context for this fetching activity. We fetch those repositories in response to the user's save action—which is when something might go wrong. By the time the user is redirected to the "Repositories" view, they should see the outcome of their action, not the action in progress. This is even more important when there may be some repositories ready to list, but not all.
Proposal
(This is tentative depending on our worst-case scenarios.)
Instead, I propose we communicate what's going on in the context of the "Add/manage repositories" view. This way, we surface the status in the context of the user's immediate action. When the user clicks save, we'll disable the save button and display a loading state in the button that will update periodically. This gives us way more leeway time-wise and also gives us a microcopy opportunity to turn a potential delay into a positive emotional moment.
A relatively quick async process would look like this:
A longer process would look like this:
And a really long process would look like this:
That was a full 15 seconds of async delay!
Handling the user navigating away:
If the user leaves the view while the async fetch is underway, it won't interrupt the fetch (since it's being handled in the backend). If they visit the "Repositories" view before fetching is complete, we will show a message to make sure they know it's incomplete.


