fix(desktop): don't report a bogus update count for a shallow checkout - #52201
Merged
Conversation
The desktop installer clones with `--depth 1`, so a public install's local history often shares no merge-base with the freshly fetched origin tip. In that state `git rev-list HEAD..origin/<branch> --count` enumerates the entire remote ancestry and returns a meaningless huge number, surfacing as e.g. "v0.17.0 (+12104)" in the update indicator (#51922). The official-SSH branch of checkUpdates() already sidesteps this by reporting a binary up-to-date check (`behind: currentSha === targetSha ? 0 : 1`), and hermes_cli/banner.py guards the identical class for the CLI banner. The passive desktop count path was the one place the shallow guard was missing. Detect shallow + no-merge-base up front and fall back to the same SHA-based binary check; full clones (developers / Docker dev images) keep the exact count path unchanged. The resolution logic lives in a pure update-count.cjs helper so it is unit-testable without booting Electron.
checkUpdates() ran `git rev-list HEAD..origin/<branch> --count` unconditionally in the parallel probe batch, even on the shallow + no-merge-base path where resolveBehindCount() ignores the result and falls back to a SHA compare. In the #51922 failure mode that count walks the entire remote ancestry (thousands of commits), so the work was pure latency on every update check for the exact case the fix targets. Split the probes into two phases: resolve --is-shallow-repository and merge-base first, then run rev-list --count only when shouldCountCommits says the number is meaningful (full clone, or shallow-with-merge-base). The shallow/no-merge-base SHA fallback is preserved unchanged.
teknium1
approved these changes
Jun 25, 2026
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…allow-update-count fix(desktop): don't report a bogus update count for a shallow checkout
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…allow-update-count fix(desktop): don't report a bogus update count for a shallow checkout
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…allow-update-count fix(desktop): don't report a bogus update count for a shallow checkout
19 tasks
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…allow-update-count fix(desktop): don't report a bogus update count for a shallow checkout
19 tasks
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…allow-update-count fix(desktop): don't report a bogus update count for a shallow checkout
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.
Salvages #51979 by @briandevans onto a
bb/branch (cherry-picked, authorship preserved) and rebased onto currentmain(resolved apackage.jsontest:desktop:platformsconflict — kept both the newupdate-count.test.cjsand main'swindow-state.test.cjs).What
A public desktop install is cloned
--depth 1, sogit rev-list HEAD..origin/<branch> --countenumerates the entire remote ancestry and returns a meaningless huge number — the indicator rendersv0.17.0 (+12104)(#51922). The non-SSH desktop count path incheckUpdates()was the one place missing the shallow guard that the SSH branch (behind: currentSha === targetSha ? 0 : 1) andbanner.py(count_commits_behind) already have.Adds a unit-testable
resolveBehindCount()helper that falls back to the binary SHA check on a shallow / no-merge-base checkout, and keeps the exact count for full clones.Verified on current main
node --test apps/desktop/electron/update-count.test.cjs→ 10/10 pass.Supersedes #51979. Fixes #51922.