-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(updater): prevent downgrade notifications when on newer version #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix(updater): prevent downgrade notifications when on newer version #1373
Conversation
Summary of ChangesHello @mateuszruszkowski, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the application's updater would incorrectly notify users about available updates that were actually older than their current local version. By integrating robust semantic version comparison, the system now intelligently determines if an update is truly an upgrade, thereby preventing misleading downgrade prompts and ensuring a more accurate update experience. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughAdds an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly addresses an issue where downgrade update notifications were being shown. The added semver comparison in both update-available and update-downloaded event handlers effectively prevents this. My main feedback is to refactor the duplicated version-checking logic into a shared helper function to improve code maintainability and ensure consistent logging. Overall, this is a good fix.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
apps/frontend/src/main/app-updater.ts (2)
501-523: Critical: Intentional downgrade flow may be broken by the new semver guards.The
downloadStableVersionfunction is designed to allow users to downgrade from beta to stable. However, the new semver guards in theupdate-downloadedevent handler (lines 139-142) will return early when the downloaded stable version is "older" than the current beta version, preventing the UI from showing the install prompt.Example scenario:
- User is on
v2.8.5-beta- User disables beta updates and triggers
downloadStableVersion()- Stable version
v2.8.4is downloadedupdate-downloadedfires, but the semver check seesv2.8.4 < v2.8.5-betaand returns early- User never sees the install prompt for the intentional downgrade
🐛 Suggested fix - check allowDowngrade flag
autoUpdater.on('update-downloaded', (info) => { const currentVersion = autoUpdater.currentVersion.version; const latestVersion = info.version; // Use proper semver comparison to detect if update is actually newer // This prevents offering downgrades (e.g., v2.7.4 when on v2.7.5) + // Skip this check if allowDowngrade is explicitly enabled (intentional downgrade) const isNewer = compareVersions(latestVersion, currentVersion) > 0; - if (!isNewer) { + if (!isNewer && !autoUpdater.allowDowngrade) { console.warn(`[app-updater] Ignoring downloaded update ${latestVersion} - current version ${currentVersion} is same or newer`); return; }Apply the same fix to the
update-availablehandler (lines 115-118).
105-128: Early return doesn't prevent download whenautoDownloadis enabled.When
autoDownloadis set totrue(line 35), electron-updater automatically downloads updates upon detecting them, regardless of whether theupdate-availableevent handler returns early. The early return here prevents the UI notification but does not prevent the download from starting in the background—potentially wasting bandwidth if a non-newer version is detected.To fully prevent unnecessary downloads, consider disabling automatic downloads and manually triggering them after version validation:
- Set
autoDownload = falseand calldownloadUpdate()only after confirming the version is newer, or- Accept that downloads may occur silently without user notification (current behavior).
🤖 Fix all issues with AI agents
In `@apps/frontend/src/main/app-updater.ts`:
- Around line 131-142: Extract the repeated semver check into a helper function
(e.g., isUpdateNewer(latestVersion: string, currentVersion: string): boolean)
that returns compareVersions(latestVersion, currentVersion) > 0; replace the
inline checks in the update handlers (including the
autoUpdater.on('update-downloaded', ...) block that uses compareVersions and the
two other places where the same pattern is used) with calls to
isUpdateNewer(...) and keep the same warning behavior and message formatting
(including latestVersion and currentVersion) so all three locations reuse the
single helper.
AndyMik90
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Auto Claude PR Review
Merge Verdict: 🟠 NEEDS REVISION
🟠 Needs revision - 1 structural/other issue(s) require attention.
Branch is out of date with base branch. Update branch first - if no conflicts arise, you can merge. If merge conflicts arise, resolve them and run follow-up review again. 1 non-blocking suggestion(s) to consider.
Risk Assessment
| Factor | Level | Notes |
|---|---|---|
| Complexity | Low | Based on lines changed |
| Security Impact | None | Based on security findings |
| Scope Coherence | Good | Based on structural review |
🚨 Blocking Issues (Must Fix)
- Branch Out of Date: PR branch is behind the base branch and needs to be updated
Findings Summary
- Low: 1 issue(s)
Generated by Auto Claude PR Review
Findings (1 selected of 1 total)
🔵 [02206f412f3d] [LOW] [Potential] Auto-download may still download non-newer versions
📁 apps/frontend/src/main/app-updater.ts:35
With autoUpdater.autoDownload = true (line 35), electron-updater initiates downloads automatically when it detects an 'update' is available. The version comparison check at lines 111-118 only prevents the UI notification from being shown - it does not cancel a download that has already been initiated by electron-updater's internal logic. This means bandwidth and disk space may be used downloading versions that won't be installed. However, this is a minor optimization concern since: (1) the scenario only occurs when electron-updater incorrectly reports an older version as an update, (2) the downloaded file won't be installed due to the check in update-downloaded handler, and (3) the PR's stated goal of preventing downgrade notifications IS achieved.
Suggested fix:
To fully prevent downloading non-newer versions, set `autoDownload = false` and manually call `downloadUpdate()` only after the version comparison passes. However, this is optional since the current implementation achieves the PR's goal.
This review was generated by Auto Claude.
a897aaf to
c136077
Compare
67a743f to
e83e445
Compare
Add version comparison check in update-available and update-downloaded event handlers to prevent notifying users about 'updates' that are actually older versions (e.g., showing v2.7.4 as update when on v2.7.5). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…r helper Address review comments from gemini-code-assist and coderabbitai: - Extract repeated version comparison pattern to shared helper function - Consolidate logging into isUpdateNewer() for consistent behavior - Reduces code duplication across update-available, update-downloaded, and checkForUpdates handlers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c136077 to
5157d37
Compare
Summary
Fixes an issue where users on a newer local version than the latest published release would incorrectly receive "update available" notifications suggesting a downgrade.
Changes:
checkForUpdates()inapp-updater.tssemver.gt()to detect when local version is already newer than latest releaseExample scenario: User is on v2.8.5-beta (local build) and latest release is v2.8.4 - previously this would show an update notification to "upgrade" to v2.8.4.
Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.