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 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-10-31 11:27:58 +01:00
co-authored by Claude Opus 5.5
parent e1336f03dd
commit 350c061081
3 changed files with 39 additions and 2 deletions
+6 -2
View File
@@ -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
@@ -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"),
)
},
})
+1
View File
@@ -45,6 +45,7 @@ var tests = []*components.IntegrationTest{
bisect.StartFromBranches,
bisect.StartFromSubCommitsAndReflog,
bisect.StartFromTagsAndRemoteBranches,
bisect.StartInCommitsPanel,
branch.CheckoutAutostash,
branch.CheckoutByName,
branch.CheckoutPreviousBranch,