fix(auto-update): use semantic version comparison instead of string e…#3420
Open
grandmaster451 wants to merge 1 commit intocode-yeongyu:devfrom
Open
fix(auto-update): use semantic version comparison instead of string e…#3420grandmaster451 wants to merge 1 commit intocode-yeongyu:devfrom
grandmaster451 wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
…quality The update checker was using strict string comparison (===) to compare current and latest versions. This caused false-positive update notifications when versions were semantically equal but had different string representations (e.g., with/without 'v' prefix, different formatting). Changed to use compareVersions() which properly parses and compares semver versions, handling 'v' prefixes and other variations correctly. Fixes: incorrect 'v3.17.2 available' notifications when already on latest version
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
1 issue found across 1 file
Confidence score: 3/5
- There is a concrete logic risk in
src/hooks/auto-update-checker/checker/check-for-update.ts: using!== 0can classify downgrades as updates instead of only newer versions. - Because this can trigger incorrect update behavior for users, the change carries moderate regression risk despite being localized to one file.
- Pay close attention to
src/hooks/auto-update-checker/checker/check-for-update.ts- ensure version comparison only treatscurrent < latestas an available update.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/hooks/auto-update-checker/checker/check-for-update.ts">
<violation number="1" location="src/hooks/auto-update-checker/checker/check-for-update.ts:59">
P2: Only treat this as an update when the current version is older than the latest one; `!== 0` also flags downgrades as updates.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| } | ||
|
|
||
| const needsUpdate = currentVersion !== latestVersion | ||
| const needsUpdate = compareVersions(currentVersion, latestVersion) !== 0 |
There was a problem hiding this comment.
P2: Only treat this as an update when the current version is older than the latest one; !== 0 also flags downgrades as updates.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/auto-update-checker/checker/check-for-update.ts, line 59:
<comment>Only treat this as an update when the current version is older than the latest one; `!== 0` also flags downgrades as updates.</comment>
<file context>
@@ -55,7 +56,7 @@ export async function checkForUpdate(directory: string): Promise<UpdateCheckResu
}
- const needsUpdate = currentVersion !== latestVersion
+ const needsUpdate = compareVersions(currentVersion, latestVersion) !== 0
log(
`[auto-update-checker] Current: ${currentVersion}, Latest (${channel}): ${latestVersion}, NeedsUpdate: ${needsUpdate}`
</file context>
Suggested change
| const needsUpdate = compareVersions(currentVersion, latestVersion) !== 0 | |
| const needsUpdate = compareVersions(currentVersion, latestVersion) < 0 |
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.
…quality
The update checker was using strict string comparison (===) to compare current and latest versions. This caused false-positive update notifications when versions were semantically equal but had different string representations (e.g., with/without 'v' prefix, different formatting).
Changed to use compareVersions() which properly parses and compares semver versions, handling 'v' prefixes and other variations correctly.
Fixes: incorrect 'v3.17.2 available' notifications when already on latest version
Summary
Changes
Screenshots
Testing
bun run typecheck bun testRelated Issues
Summary by cubic
Fix incorrect update prompts by switching the auto-update checker to semantic version comparison. Replaces string equality with
compareVersions, correctly handling 'v' prefixes and other semver variations.Written for commit 003e45a. Summary will update on new commits.