Repository navigation
Description
The problem
Commit history repeats an older commit and hides new commits when the branch only has a few commits
Description
When a branch has only a couple of commits, the History list can end up stale after a new commit lands: the newest commit never shows up, and the oldest commit is rendered twice. The commit selection and diff follow the same stale data, so clicking the duplicated row shows the wrong changes.
Steps to reproduce
- Create a repository and make two commits (e.g.
Initial commitandSecond commit). - Open the repository and go to the History tab so the list is populated. Because the list is shorter than the viewport, the app immediately loads the next batch.
- Create a third commit, either through the app or with
git commitwhile the app is open. - Go back to the History tab (or switch tabs and return).
Expected
Three rows, newest first:
Third commit
Second commit
Initial commit
Actual
Three rows, with the oldest commit duplicated and the new one missing:
Second commit
Initial commit
Initial commit
Cause
_loadNextCommitBatch in app/src/lib/stores/app-store.ts uses the number of already-loaded commits as the skip offset:
newCommits = await gitStore.loadCommitBatch('HEAD', commits.length)
...
commitSHAs: commits.concat(newCommits)That offset is only valid while HEAD doesn't move. Once a new commit lands, the offset points at a commit that is already in the list, so the old commit is appended again, while the new commit sits before offset 0 and is never loaded.
This is easy to hit with a short history because onScroll in app/src/ui/history/compare.tsx triggers a batch load as soon as commits.length - end <= CloseToBottomThreshold; with two or three commits the whole list is always "close to the bottom", so the stale append happens on every mount. With a longer history the first screen is full and the batch loader isn't reached in that state.
Proposed fix
Before appending a batch, compare the cached history tip (compareState.tip) with the current HEAD. If HEAD has moved, reload the list from the tip via _executeCompare instead of appending. As a safety net, filter appended SHAs against the ones already loaded.
Environment
- Windows 11 x64
- GitHub Desktop built from source, release build
- Electron 44.9.1
Attachments
history-small-repo.png— actual rendering with three commits: newest commit missing, oldest commit repeated.history-fixed.png— same flow after the proposed fix:Third / Second / Initial, no duplicates.
Release version
GitHub Desktop 2.7.0
Operating system
Windows 11
Steps to reproduce the behavior
No response
Log files
No response
Screenshots
No response
Additional context
No response
Activity
desktop-triage commentedon Nov 25, 2026
This is a reproducible bug: a clearly reproducible history-duplication defect on short commit lists with explicit repro steps, expected-vs-actual output, and a plausible root-cause pointer to
_loadNextCommitBatch. I'm requestingbugandpriority-3(confidence: HIGH on bug, MEDIUM on priority — few users notice this since it self-corrects on a restart/tab switch and only affects branches with very short history). This appears to overlap heavily with #22064 ("After committing on a branch with very few commits, the History view sometimes displays incorrectly"), which already has an open fix PR, #23025 ("Don't overwrite refreshed history with a stale commit batch"); #22064 is not a confirmed closed duplicate, but the symptom (stale/duplicated oldest commit, missing newest commit, self-corrects on restart) and proposed remedy (avoid blindly appending a stale batch when HEAD has moved) match closely enough that this issue and #23025 should be considered together.Initial hypothesis
The reported behavior is consistent with the code path in
loadNextCommitBatchReadCore, which computes the batch-load offset fromstate.compareState.commitSHAs.lengthrather than from the currentHEAD:desktop/app/src/lib/stores/app-store.ts
Lines 2126 to 2150 in 7d306ba
gitStore.loadCommitBatch('HEAD', commits.length)fetches starting at an offset that re-includes an already-loaded (older) commit while skipping past the newly created one, producing the observed duplicate-oldest/missing-newest rendering. This matches the open PR #23025's premise that a stale commit batch can overwrite freshly refreshed history, so this issue and the #23025 fix should likely be resolved together rather than independently re-investigated.Prevent stale history pagination from overwriting refreshed commits