Skip to content

Add VersionMath.isSameVersion for prefix-tolerant equality checks#466

Merged
rainxchzed merged 4 commits into
mainfrom
fix/version-compare-prefix-tolerant
Apr 29, 2026
Merged

Add VersionMath.isSameVersion for prefix-tolerant equality checks#466
rainxchzed merged 4 commits into
mainfrom
fix/version-compare-prefix-tolerant

Conversation

@rainxchzed
Copy link
Copy Markdown
Member

@rainxchzed rainxchzed commented Apr 28, 2026

Summary by CodeRabbit

  • New Features

    • Added a semantic version equality helper to recognize equivalent versions despite formatting differences (prefixes, build metadata, blank/null).
  • Bug Fixes

    • Install/update button visibility, installed-version labels, and rollback availability now correctly reflect version equivalence, avoiding false differences due to tag formatting.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 93c37c76-b894-4cc0-9e07-5f04da81f823

📥 Commits

Reviewing files that changed from the base of the PR and between a40cae4 and 4070cca.

📒 Files selected for processing (1)
  • feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/SmartInstallButton.kt

Walkthrough

Adds a semantic version equality helper isSameVersion to core utilities and updates three presentation components to use it; AppHeader and DetailsState use semantic equality for display/rollback checks, while SmartInstallButton adjusts normalization logic so blank/missing values are handled as nulls before comparison.

Changes

Cohort / File(s) Summary
Version Utility
core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/util/VersionMath.kt
Added fun isSameVersion(a: String?, b: String?): Boolean that normalizes inputs and reuses compareVersions to return semantic equality (handles common tag prefixes and metadata).
Presentation — Details & Header
feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsState.kt, feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/AppHeader.kt
Replaced direct string equality checks with VersionMath.isSameVersion(...) when determining whether installed vs. release tags are the same for UI labels and rollback availability.
Presentation — Install CTA
feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/SmartInstallButton.kt
Updated normalization: trim and treat blank tag/installed strings as null, then use VersionMath.isSameVersion(...) for branching. UI now only shows install-version label when both normalized values are present and semantically different.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I sniffed the tags, both big and small,
I trimmed the v, I hopped through all,
I checked the seeds of semantic rhyme,
When versions match, we save the time—
A little hop, the code is bright. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a new isSameVersion helper method that performs prefix-tolerant equality checks, which is the core feature across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/version-compare-prefix-tolerant

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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/SmartInstallButton.kt`:
- Around line 257-261: The UI uses two different version-equality checks which
can produce contradictory states: replace the local normalizeVersion usage in
the Open/Uninstall gate with the centralized VersionMath.isSameVersion check so
both the install button branch and the Open/Uninstall branch use the same
comparison; update the Open/Uninstall logic in SmartInstallButton to call
VersionMath.isSameVersion(installedApp.installedVersion,
state.selectedRelease?.tagName) (handling the nullable selectedRelease/tagName)
instead of normalizeVersion so the composable consistently treats semantically
equal versions the same.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ae7243a7-637d-41bf-a2dd-20f20d2c4b79

📥 Commits

Reviewing files that changed from the base of the PR and between 376d4e7 and ee89ef1.

📒 Files selected for processing (4)
  • core/domain/src/commonMain/kotlin/zed/rainxch/core/domain/util/VersionMath.kt
  • feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/DetailsState.kt
  • feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/AppHeader.kt
  • feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/SmartInstallButton.kt

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/SmartInstallButton.kt`:
- Around line 97-102: The isSameVersionInstalled check uses
VersionMath.isSameVersion with possibly blank/null installedApp.installedVersion
and state.selectedRelease?.tagName, which treats two blank values as equal and
incorrectly drives the CTA; before calling VersionMath.isSameVersion (in the
isSameVersionInstalled computation and the analogous code around the other
branch), normalize both versions and require they are non-empty (e.g., val
normInstalled = installedApp.installedVersion?.trim()?.takeIf { it.isNotBlank()
} and val normSelected = state.selectedRelease?.tagName?.trim()?.takeIf {
it.isNotBlank() }) and only call VersionMath.isSameVersion(normInstalled,
normSelected) when both normInstalled and normSelected are non-null/non-blank;
also use the non-blank normalized selected tag when rendering install_version
fallback so you never render an empty tag.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4b282982-591e-4cc8-8465-230dcd114807

📥 Commits

Reviewing files that changed from the base of the PR and between ee89ef1 and a40cae4.

📒 Files selected for processing (1)
  • feature/details/presentation/src/commonMain/kotlin/zed/rainxch/details/presentation/components/SmartInstallButton.kt

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