From 550a6d88a74fbfcd6dfa1d5fa3c4f47ece334f78 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 30 Oct 2026 20:37:56 +0100 Subject: [PATCH] Scroll a newly conflicted commit into view in background refreshes When a refresh finds a new conflicted commit, it selects it so that the user sees where the rebase stopped. A background refresh keeps the scroll position of the views it updates though. If the conflicted commit is outside the visible part of the commits view, the selection moves to a commit that the user can't see. Scroll the selection into view whenever the refresh moves it to a newly conflicted commit. Co-Authored-By: Claude Opus 5.5 --- pkg/gui/controllers/helpers/refresh_helper.go | 9 ++++++++- .../background_refresh_scrolls_to_conflicted_commit.go | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index b919eb84b..e8477c35b 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -906,7 +906,14 @@ func (self *RefreshHelper) refreshCommitsWithLimit(captured capturedCommitState, // The caller set the selection index deliberately; leave it untouched. } - self.rerenderView(self.c.Contexts().LocalCommits, env.focusOpts()) + focusOpts := env.focusOpts() + if newConflictedCommitIdx != nil { + // We selected a commit that the user needs to look at next, so + // scroll it into view even if the refresh keeps the scroll position + // otherwise. + focusOpts.KeepScrollPosition = false + } + self.rerenderView(self.c.Contexts().LocalCommits, focusOpts) }) return nil diff --git a/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go b/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go index ea4c0b308..e0c1d1605 100644 --- a/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go +++ b/pkg/integration/tests/ui/background_refresh_scrolls_to_conflicted_commit.go @@ -31,10 +31,7 @@ var BackgroundRefreshScrollsToConflictedCommit = NewIntegrationTest(NewIntegrati }). // The conflicted commit, below the 30 pending todos and their header SelectedLineIdx(31). - /* EXPECTED: SelectedLineIsVisible(). SelectedLine(Contains("<-- CONFLICT --- this will conflict")) - ACTUAL: */ - OriginY(0) }, })