Skip to content

feat: add branch sorting option#88

Merged
pol-rivero merged 4 commits intopol-rivero:mainfrom
kurtextrem:feature/branch-sorting
Mar 18, 2026
Merged

feat: add branch sorting option#88
pol-rivero merged 4 commits intopol-rivero:mainfrom
kurtextrem:feature/branch-sorting

Conversation

@kurtextrem
Copy link

@kurtextrem kurtextrem commented Mar 16, 2026

Description

Hi! Thanks for maintaining this. I love it.

What I also love is the "Recent branches" list. Especially with AI, I try multiple things at the same time. So just showing 5 is not enough. I thought about adding a setting that changes the amount of branches that are displayed in "Recent branches", but I figured: It's much more useful to either sort by recently added (what "Recent branches" currently does), or new, "Recently changed" (based on commits).

Screenshots

image image

Release notes

Notes:

  • Settings: Added an option in "Appearance" that allows to configure branch sorting (by alphabet - default, by recently added, or recently changed (last commit))

Copilot AI review requested due to automatic review settings March 16, 2026 08:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a user-configurable branch sorting preference that affects branch-selection views (e.g., branch dropdown/history compare), persisted in app state and exposed in Preferences.

Changes:

  • Introduces a BranchSortOrder preference stored in AppStore/localStorage and wired through UI props.
  • Updates branch grouping/sorting logic to support Alphabet, Recently Added (reflog order), and Recently Changed (by last commit date).
  • Adjusts recent-branch loading limits in GitStore based on the selected sort mode, and adds/updates unit tests.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
app/test/unit/group-branches-test.ts Adds coverage for new sort modes and recent-branch capping behavior.
app/src/ui/toolbar/branch-dropdown.tsx Threads branchSortOrder prop into branch dropdown rendering.
app/src/ui/repository.tsx Passes branchSortOrder down into repository view children.
app/src/ui/preferences/preferences.tsx Adds branchSortOrder to preferences state and persists via dispatcher.
app/src/ui/preferences/appearance.tsx Adds Appearance UI for selecting branch sort order.
app/src/ui/history/compare.tsx Passes branchSortOrder into compare sidebar branch list.
app/src/ui/dispatcher/dispatcher.ts Adds dispatcher API for updating branch sort order.
app/src/ui/branches/group-branches.ts Implements new grouping/sorting behavior based on sort order.
app/src/ui/branches/branches-container.tsx Threads branchSortOrder into BranchList.
app/src/ui/branches/branch-list.tsx Updates group header labeling based on sort order.
app/src/ui/app.tsx Passes app state branchSortOrder into relevant UI surfaces.
app/src/models/branch-sort-order.ts Adds the sort order model/default.
app/src/lib/stores/git-store.ts Adds sort-dependent recent-branch limits and extends loadBranches.
app/src/lib/stores/app-store.ts Persists the setting, reloads branches on change, and wires into initial load.
app/src/lib/app-state.ts Extends global app state with branchSortOrder.

You can also share your feedback on Copilot code review. Take the survey.

@pol-rivero
Copy link
Owner

Thanks for your PR! I agree that it would be nice to be able to sort branches by "Recently changed" instead of alphabetically.

Everything seems to be working fine, with the exception that local branches are no longer shown at the top.
I think they should remain grouped at the top (ordered by changed date), followed by all remote branches (ordered by date), because local branches are much more important than remote branches.

Old:

image

New:

image

@pol-rivero
Copy link
Owner

I have made the required changes to implement this setting. Now you should:

  1. Undo your changes to git-store.ts, branch-sort-order.ts and group-branches.ts
  2. Pull in my changes from the main branch
  3. Update my branch-list.tsx to use the user-selected sort instead of hardcoding BranchSortOrder.LastModified

I don't think renaming the headers is needed, they are pretty self-explanatory as they are.

Also, I have removed the RecentlyAdded sort, as we are not showing this information anywhere and it would be very tricky to implement. I think 99% of users will prefer the "LastModified" sort order, so I have set it as DEFAULT_BRANCH_SORT_ORDER. The remaining few will probably just want an alphabetical sort to restore the old behavior.

image

@kurtextrem kurtextrem force-pushed the feature/branch-sorting branch from f9d4f8a to 61736de Compare March 18, 2026 07:21
@kurtextrem kurtextrem force-pushed the feature/branch-sorting branch from 61736de to ed012e0 Compare March 18, 2026 07:40
@kurtextrem
Copy link
Author

Thank you! I pushed the changes.

However, I think "Recent branches" is worth keeping:
image

(with "Last modified" sorting)
It kinda feels odd (because they're not sorted by the date next to the branch), but in my case it makes sense - I was on the branch, amended a commit and pushed it. If this section disappears, it means the branch I was on 'right now' would move down in the list (out of my viewport actually).

@pol-rivero
Copy link
Owner

Sorry, I'm getting a bit confused by this line:

However, I think "Recent branches" is worth keeping

I never said we should remove the "Recent branches" section. In fact, in the screenshot of my last comment you can see this section.

@kurtextrem
Copy link
Author

I never said we should remove the "Recent branches" section. In fact, in the screenshot of #88 (comment) you can see this section.

I was referring to your reply here: #88 (comment). FWIW, I kept "Recent branches", so we should be good.

@pol-rivero
Copy link
Owner

Ah I see, maybe I didn't explain myself properly.
I've been able to test your changes and (almost) everything works flawlessly now. The only issues I could find were some branch lists that don't respect the user's choice and are always sorted using the default sorting (Last modified):

Right-click commit -> Cherry pick
image

To fix it, you can simply make branchSortOrder not optional in branch-list.tsx:64, and the compiler will force you to propagate the setting properly through all the intermediate components.

@kurtextrem
Copy link
Author

Done!

@pol-rivero
Copy link
Owner

Great! Thanks for your contribution :)

ESLint is complaining about an unused prop, but it looks like a false positive, I'll probably just add an ignore clause after merging the PR.

@pol-rivero pol-rivero merged commit 3a33154 into pol-rivero:main Mar 18, 2026
@kurtextrem
Copy link
Author

Thank you for the collab and especially so quickly. Was a really awesome experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants