Repository navigation
Fix the sidebar losing the selected branch after a rebase - #760
Merged
Merged
Conversation
goneng
marked this pull request as ready for review
October 6, 2026 18:01
goneng
force-pushed
the
fix-sidebar-selection-after-rebase
branch
from
October 6, 2026 20:30
c518bcc to
da229dc
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Recreated worktree rows are matched by object identity, so a selected worktree branch can still lose selection.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Keeps the sidebar aligned with the checked-out branch across repository and worktree reloads.
Changes:
- Prevents restored selections from overwriting
currentBranch. - Preserves selection during branch removal and worktree rebuilds.
- Adds regression coverage for startup and branch rereads.
| File | Description |
|---|---|
Classes/Controllers/PBGitSidebarController.m |
Adjusts sidebar selection restoration. |
GitXTests/PBGitWindowWiringTests.m |
Tests selection after rereading HEAD. |
GitXTests/PBGitSidebarWorktreeGroupTests.m |
Tests selection after worktree lookup. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+181
to
+183
| restoringSelection = YES; | ||
| [sourceView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; | ||
| restoringSelection = NO; |
Keep the sidebar on the current branch when the outline is reloaded and when the repository re-reads which branch is current. - Restoring the selection after a reload no longer counts as a user selection, so it cannot write the stale branch back to currentBranch. - Rebuilding the worktree group and removing a branch preserve the selection like the other reloads do. The worktree lookup lands after startup, so a freshly opened window had nothing selected either. - Add tests for both paths.
goneng
force-pushed
the
fix-sidebar-selection-after-rebase
branch
from
October 7, 2026 22:24
da229dc to
648cf8e
Compare
hannesa2
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Keep the sidebar on the current branch after a rebase, and on a freshly opened window.
Problem
After "Rebase 'feat' onto 'master'" from the sidebar context menu, no branch was selected in the sidebar, while 'master' stayed highlighted in the history. A freshly opened window had no sidebar selection either.
Changes
readCurrentBranchre-selected the stale row and wrote it back tocurrentBranch, undoing the update.reloadData, which dropped it.feat), not the branch that was right-clicked.Test plan
PBGitWindowWiringTestsandPBGitSidebarWorktreeGroupTestspass. The two new tests fail without the change.featis selected at startup and after the rebase (read through accessibility).