git_ui: Close branch selector as soon as branch is selected #39725
+17
−27
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.
I noticed that branch picker doesn't close until the checkout operation is completed.
While normally it's not an issue, it becomes obvious if there are longer running post checkout hooks. In that case selecting a branch makes it feel like nothing has happened (there's a small indicator in the footer) so it's possible to click it multiple times. Closing the modal before the operation completes leads to the error modal saying
Failed to change branch. entity released. Please try again.
even though the checkout was successful.The new behavior is to close the branch picker as soon as the branch is selected. This also aligns with the existing behavior in
create_branch
wherecx.emit(DismissEvent);
is called without waiting forrepo.update
.And as I mentioned before there an indicator in the footer saying
git switch <branch_name>
with a spinner thingy.I also added a check in the picker's
open
function where it first checks if there's currently an active job and does not show the picker in that case.If this generally makes sense I can add the tests as well if needed.
P.S I checked how it works in VSCode and yes it also closes the branch picker as soon as the branch is selected. The only difference is that they show the loading indicator right next to the branch name (with a new branch) but in our case the current branch and activity indicator are located in different places.
Before
Screen.Recording.2025-10-08.at.12.59.27.AM.mp4
After
Screen.Recording.2025-10-08.at.1.07.49.AM.mp4