Skip to content

fix(auto-update): use semantic version comparison instead of string e…#3420

Open
grandmaster451 wants to merge 1 commit intocode-yeongyu:devfrom
grandmaster451:fix-version-comparison
Open

fix(auto-update): use semantic version comparison instead of string e…#3420
grandmaster451 wants to merge 1 commit intocode-yeongyu:devfrom
grandmaster451:fix-version-comparison

Conversation

@grandmaster451
Copy link
Copy Markdown

@grandmaster451 grandmaster451 commented Apr 14, 2026

…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

Before After

Testing

bun run typecheck
bun test

Related 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.

…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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@grandmaster451
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Apr 14, 2026
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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 !== 0 can 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 treats current < latest as 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
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 14, 2026

Choose a reason for hiding this comment

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

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
Fix with Cubic

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.

1 participant