From 975da9b8a9bd8186ca353e9cddc4bd4cd83c4ecd Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 21 Jul 2026 20:38:41 +0200 Subject: [PATCH] Block input and batch UI updates when switching repos On startup we don't want to block input during the initial refresh (it should be possible to press, say, `4` to jump to the commits panel right after startup without a delay), and we also want panels to show their contents as soon as possible; it doesn't matter so much that it's not in sync, we go from empty to populated here. However, when switching repos it can be confusing that some panels that are slow to update still show the old repo's data while others already show the new one's data, so update the UI only when everything is ready, and also block input to prevent accidentally trying to act on the old, stale data. --- pkg/gui/gui.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 8776040e7..912d46567 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -1103,12 +1103,31 @@ func (gui *Gui) runSubprocess(cmdObj *oscommands.CmdObj) error { return err } +var isFirstRefreshAfterStartup = true + func (gui *Gui) loadNewRepo() error { if err := gui.updateRecentRepoList(); err != nil { return err } - gui.c.Refresh(types.RefreshOptions{DontBlockRepoSwitch: true}) + // On startup we don't want to block input during the initial refresh (it + // should be possible to press, say, `4` to jump to the commits panel right + // after startup without a delay), and we also want panels to show their + // contents as soon as possible; it doesn't matter so much that it's not in + // sync, we go from empty to populated here. However, when switching repos + // it can be confusing that some panels that are slow to update still show + // the old repo's data while others already show the new one's data, so + // update the UI only when everything is ready, and also block input to + // prevent accidentally trying to act on the old, stale data. + options := types.RefreshOptions{DontBlockRepoSwitch: true} + refresh := gui.c.Refresh + if isFirstRefreshAfterStartup { + isFirstRefreshAfterStartup = false + } else { + options.BatchUIUpdates = true + refresh = gui.c.RefreshBlockingInput + } + refresh(options) if err := gui.os.UpdateWindowTitle(); err != nil { return err