Skip to content

Prevent stale pagination from overwriting refreshed history - #23238

Merged
sergiou87 merged 1 commit into
developmentfrom
fix-dupe-commits
Nov 26, 2026
Merged

sergiou87 merged 1 commit into
developmentfrom
fix-dupe-commits

Conversation

@sergiou87

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: bb77c689b8c074d9432457eb2ca6860768b10a86

Dimension Assessment Rationale
Change confidence 9/10 ↑ Three regression cases fail before the fix and pass afterward; unchanged-history pagination remains covered.
↑ 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.
Diagnosis confidence 9.5/10 ↑ Tests demonstrate a late batch overwriting refreshed history.
↑ Live unmodified app reproduces the missing newest commit and duplicated oldest commit.
Evidence fit 8.5/10 ↑ Live reproduction matches the reported history rows and persistence through tab/focus changes.
↓ 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 old HEAD request with skip offset 2 then returns Initial and 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.

set -euo pipefail

repo="$(mktemp -d "${TMPDIR:-/tmp}/desktop-history-repro.XXXXXX")"
git -C "$repo" init --initial-branch=main
git -C "$repo" config user.name 'Desktop Reproduction'
git -C "$repo" config user.email '[email protected]'
git -C "$repo" config commit.gpgsign false

printf 'Initial commit content\n' > "$repo/commit-history.txt"
git -C "$repo" add -- commit-history.txt
git -C "$repo" commit -m 'Initial'

printf 'Second commit content\n' >> "$repo/commit-history.txt"
git -C "$repo" add -- commit-history.txt
git -C "$repo" commit -m 'Second'

printf '\nAdd this repository to GitHub Desktop: %s\n' "$repo"
  1. Add the printed repository path through File > Add Local Repository.
  2. Open History, showing Second / Initial.
  3. Append Third commit content as a third line in commit-history.txt.
  4. Open Changes, enter Third as the summary, and commit through Desktop.
  5. Immediately return to History. Before the fix, the recorded result is Second / Initial / Initial; after the fix, expect Third / Second / Initial.
  6. Select each commit to inspect its SHA and diff, then switch tabs and return.

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 plain npm test had four unrelated bare-repository failures caused by local safe.bareRepository=explicit; all 28 tests in those two files passed with this process-local fixture allowance. No global configuration was changed.
  • npm run lint:fix and npm 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. Initial npm run compile:prod exhausted 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 Initial and omits Third. 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.

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
Copilot AI balanced review requested due to automatic review settings November 26, 2026 09:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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
sergiou87 marked this pull request as ready for review November 26, 2026 09:13
@sergiou87
sergiou87 requested a review from a team as a code owner November 26, 2026 09:13
@sergiou87
sergiou87 requested a review from babakks November 26, 2026 09:13
@sergiou87
sergiou87 enabled auto-merge November 26, 2026 09:13

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@sergiou87
sergiou87 merged commit 4fbdf90 into development Nov 26, 2026
25 checks passed
@sergiou87
sergiou87 deleted the fix-dupe-commits branch November 26, 2026 10:22
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.

Commit history repeats an older commit and hides new commits when the branch only has a few commits

4 participants