From 350c061081760e4735d2e6f95019f13d68af5af3 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 31 Oct 2026 07:53:07 +0100 Subject: [PATCH] Focus the commits panel at startup when a bisect is in progress Lazygit starts in the files panel. During a bisect, this is rarely what the user needs. The commits panel shows how far the bisect has got, and the user marks the commits to test there. So start in the commits panel if a bisect is in progress, even if git doesn't know both a good and a bad commit yet. The same applies the first time the user switches to such a repo during a session. A filter path or a "status", "branch", "log" or "stash" argument still decides which panel to focus. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/gui.go | 8 +++-- .../tests/bisect/start_in_commits_panel.go | 32 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 pkg/integration/tests/bisect/start_in_commits_panel.go diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 803980c50..34da4c8af 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -666,7 +666,7 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs) types.Context { gui.applySidePanelConfig() - return initialContext(contextTree, startArgs) + return initialContext(contextTree, startArgs, gui.git.Bisect.GetInfo().Started()) } func (gui *Gui) loadCachedPullRequests() []*models.GithubPullRequest { @@ -754,7 +754,7 @@ func parseScreenModeArg(screenModeArg string) types.ScreenMode { } } -func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartArgs) types.IListContext { +func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartArgs, bisectStarted bool) types.IListContext { var initialContext types.IListContext = contextTree.Files if startArgs.FilterPath != "" { @@ -772,6 +772,10 @@ func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartAr default: panic("unhandled git arg") } + } else if bisectStarted { + // The commits panel shows how far the bisect has got, and the user + // marks the commits to test there + initialContext = contextTree.LocalCommits } return initialContext diff --git a/pkg/integration/tests/bisect/start_in_commits_panel.go b/pkg/integration/tests/bisect/start_in_commits_panel.go new file mode 100644 index 000000000..62825e753 --- /dev/null +++ b/pkg/integration/tests/bisect/start_in_commits_panel.go @@ -0,0 +1,32 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StartInCommitsPanel = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Focus the commits panel at startup when a bisect is in progress", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + // The bisect is in progress, although git knows only a bad commit + // so far + RunCommand([]string{"git", "bisect", "start"}). + RunCommand([]string{"git", "bisect", "bad"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-03").Contains("<-- bad").IsSelected(), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 04a481279..987713b3c 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -45,6 +45,7 @@ var tests = []*components.IntegrationTest{ bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog, bisect.StartFromTagsAndRemoteBranches, + bisect.StartInCommitsPanel, branch.CheckoutAutostash, branch.CheckoutByName, branch.CheckoutPreviousBranch,