Repository navigation
Prevent stale pagination from overwriting refreshed history - #23238
Merged
Merged
Conversation
Discard a completed history batch when its captured commit list has been replaced while the Git read was in flight. This preserves new commits and prevents duplicate rows after committing from the Changes tab. Cover stale empty, fallback, and local batches, as well as normal pagination. Fixes #23234
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the fix that prevents stale pagination batches from overwriting refreshed history.
No open issues 🎉
What changed in this PR
Prevents late history pagination requests from overwriting refreshed history, addressing missing new commits and duplicate older rows on short branches.
Changes:
- Discards completed batches when the cached history array has changed during loading.
- Adds regression coverage for stale empty, duplicate, and local batches, plus unchanged-history pagination.
| File | Description |
|---|---|
| app/test/unit/stores/app-store-history-test.ts | Tests stale-batch rejection and normal pagination. |
| app/src/lib/stores/app-store.ts | Guards against appending a batch to an outdated history snapshot. |
Review effort: Balanced
sergiou87
marked this pull request as ready for review
November 26, 2026 09:13
sergiou87
enabled auto-merge
November 26, 2026 09:13
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
bb77c689b8c074d9432457eb2ca6860768b10a86↑ Full unit suite, lint, and production compilation pass.
↑ Rebuilt app preserves all three history rows and their correct diffs in the recorded flow.
↓ Windows remains untested.
↑ Live unmodified app reproduces the missing newest commit and duplicated oldest commit.
↓ Windows and the separately reported incorrect-diff symptom have not been reproduced.
Closes #23234
Description
Discard a completed history batch if the cached commit list has changed since the batch started. This prevents a stale pagination request from replacing freshly loaded history after a commit.
With a short branch, History immediately requests another batch. A new commit can refresh
[Second, Initial]to[Third, Second, Initial]while the old request is still running. The oldHEADrequest with skip offset2then returnsInitialand previously overwrote the refreshed list with[Second, Initial, Initial]. The refreshed tip remained cached, so subsequent tab/focus refreshes did not repair the list.The guard compares the captured array with the current immutable history snapshot after either local or fallback pagination completes. Deduplicating the returned SHAs alone would not preserve the missing newest commit. No extra Git read or pagination behavior change is needed.
Related: #22064 and the existing proposal in #23025, which uses the same guard. This PR adds live before/after evidence and regression coverage for empty, duplicate, and local stale batches plus normal pagination.
Reproduction
Create a fresh two-commit repository (Bash, macOS/Linux)
This creates a temporary repository and changes only its local Git configuration. It does not modify an existing repository or global Git configuration.
Second / Initial.Third commit contentas a third line incommit-history.txt.Thirdas the summary, and commit through Desktop.Second / Initial / Initial; after the fix, expectThird / Second / Initial.This is an asynchronous race, so timing can vary. The recordings use real Git operations and live Playwright navigation, without delayed Git commands, injected state, or a scripted E2E test. The setup script has also been run successfully.
Validation
npm test -- app/test/unit/stores/app-store-history-test.ts: before the fix, three cases failed and normal pagination passed.npm test -- app/test/unit/stores/app-store-history-test.ts app/test/unit/stores/app-store-indicators-test.ts: passed, 10 tests.GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=safe.bareRepository GIT_CONFIG_VALUE_0=all npm test: passed, 3,613 tests; two skipped. Initial plainnpm testhad four unrelated bare-repository failures caused by localsafe.bareRepository=explicit; all 28 tests in those two files passed with this process-local fixture allowance. No global configuration was changed.npm run lint:fixandnpm run lint: passed.NODE_ENV=production RELEASE_CHANNEL=beta TS_NODE_PROJECT=script/tsconfig.json NODE_OPTIONS=--max_old_space_size=8192 node_modules/.bin/webpack --config app/webpack.production.ts --stats errors-warnings: passed with four dependency warnings. Initialnpm run compile:prodexhausted its fixed 4 GB heap; the equivalent build succeeded with 8 GB.git diff --check: passed.Validation covers revision
bb77c689b8c074d9432457eb2ca6860768b10a86. The compiled renderer's AppStore source exactly matches that revision.Screenshots
Before: GitHub Desktop 3.7.1-beta1 on macOS. Git has three commits, but History repeats
Initialand omitsThird. Switching tabs and refocusing leave the stale list intact. The affected source matches the development baseline.before.mp4
After: The rebuilt app at the assessed revision shows
Third / Second / Initial. The selected UI SHAs match Git (b86d020,e732990,2238d80), and each diff shows its corresponding added line. Tab changes and refocusing preserve the correct history. The startup-only Move to Applications prompt is trimmed; the reproduction plays at its original speed.after.mp4
The reported wrong-diff symptom was not independently reproduced: both duplicated rows in the before run referred to the same Initial SHA and showed its actual diff. Windows has not been tested.
Release notes
Notes: [Fixed] Keep new commits visible without duplicate history rows after committing on a short branch
Team-authored review
Evidence: Validation and before/after recordings.
Review path: Lightweight review. This is a nondestructive history-state fix with regression coverage and live before/after evidence. No mandatory deep-review criterion or specific author concern requires escalation.