Fix double v prefix and version comparison in update banner#1615
Fix double v prefix and version comparison in update banner#1615
Conversation
The version API response already includes the "v" prefix, causing "vv0.30.3" in the display. Also adds semver comparison to ensure the banner only shows when the latest version is actually newer than the current one.
Paragon SummaryThis pull request review identified 2 issues across 1 category in 1 file. The review analyzed code changes, potential bugs, security vulnerabilities, performance issues, and code quality concerns using automated analysis tools. This PR fixes a visual bug where the version update banner displayed a duplicated "v" prefix (e.g., "vv0.30.3") and adds proper semver comparison logic so the banner only appears when an actual newer version is available. Key changes:
Confidence score: 4/5
1 file reviewed, 2 comments Severity breakdown: Medium: 2 Tip: |
| return version.startsWith('v') ? version.slice(1) : version; | ||
| } | ||
|
|
||
| function isNewerVersion(latest: string, current: string): boolean { |
There was a problem hiding this comment.
Bug: Version comparison breaks with pre-release tags
Version comparison breaks with pre-release tags. The .map(Number) produces NaN for non-numeric parts like beta. Filter out or handle non-numeric version segments.
View Details
Location: src/renderer/components/Shared/VersionUpdateBanner.tsx (lines 22)
Analysis
**Version comparison breaks with pre-release tags. The **
| What fails | isNewerVersion function produces NaN values when version strings contain non-numeric parts like 'beta', 'rc', 'alpha' |
| Result | NaN comparisons always return false, so pre-release versions may be incorrectly compared or banner may not show when it should |
| Expected | Pre-release versions should be handled gracefully, either by ignoring suffixes or treating them as older than the base version |
| Impact | Users with pre-release builds may see incorrect update banner behavior |
How to reproduce
Call isNewerVersion('v0.30.3-beta', 'v0.30.2') - the 'beta' becomes NaN and comparison failsAI Fix Prompt
Fix this issue: Version comparison breaks with pre-release tags. The .`map`(Number) produces NaN for non-numeric parts like beta. Filter out or handle non-numeric version segments.
Location: src/renderer/components/Shared/VersionUpdateBanner.tsx (lines 22)
Problem: isNewerVersion function produces NaN values when version strings contain non-numeric parts like 'beta', 'rc', 'alpha'
Current behavior: NaN comparisons always return false, so pre-release versions may be incorrectly compared or banner may not show when it should
Expected: Pre-release versions should be handled gracefully, either by ignoring suffixes or treating them as older than the base version
Steps to reproduce: Call isNewerVersion('v0.30.3-beta', 'v0.30.2') - the 'beta' becomes NaN and comparison fails
Provide a code fix.
Tip: Reply with @paragon-run to automatically fix this issue
|
|
||
| if (updateCheckDisabled) return null; | ||
| if (!data?.update_available) return null; | ||
| if (!data?.update_available || !data.latest_version) return null; |
There was a problem hiding this comment.
Bug: current_version is used without null check
current_version is used without null check. If API returns undefined current_version, isNewerVersion breaks. Add null check for data.current_version.
View Details
Location: src/renderer/components/Shared/VersionUpdateBanner.tsx (lines 48)
Analysis
current_version is used without null check. If API returns undefined current_version, isNewerVersion
| What fails | data.current_version is passed to isNewerVersion without checking if it exists, unlike the explicit check added for data.latest_version |
| Result | isNewerVersion receives undefined/null, leading to 'undefined'.split('.') and incorrect comparisons |
| Expected | Should return null early if current_version is missing, same pattern as latest_version check |
| Impact | Could cause runtime errors or incorrect banner behavior if API returns incomplete data |
How to reproduce
If API returns { update_available: true, latest_version: 'v0.31.0', current_version: null } or undefined current_versionPatch Details
- if (!data?.update_available || !data.latest_version) return null;
+ if (!data?.update_available || !data.latest_version || !data.current_version) return null;AI Fix Prompt
Fix this issue: current_version is used without null check. If API returns undefined current_version, isNewerVersion breaks. Add null check for data.current_version.
Location: src/renderer/components/Shared/VersionUpdateBanner.tsx (lines 48)
Problem: data.current_version is passed to isNewerVersion without checking if it exists, unlike the explicit check added for data.latest_version
Current behavior: isNewerVersion receives undefined/null, leading to 'undefined'.split('.') and incorrect comparisons
Expected: Should return null early if current_version is missing, same pattern as latest_version check
Steps to reproduce: If API returns { update_available: true, latest_version: 'v0.31.0', current_version: null } or undefined current_version
Provide a code fix.
Tip: Reply with @paragon-run to automatically fix this issue
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
isNewerVersion) so the banner only appears when the latest version is actually newer than the current oneTest plan