Skip to content

fix(clusters): hide overlapping version tags in the version picker#1532

Merged
dawsontoth merged 4 commits into
stagefrom
fix/hide-overlapping-cluster-version-tags
Jul 20, 2026
Merged

fix(clusters): hide overlapping version tags in the version picker#1532
dawsontoth merged 4 commits into
stagefrom
fix/hide-overlapping-cluster-version-tags

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

What & why

Closes #1531.

The HarperVersions endpoint can return the same version under more than one release tag — e.g. 5.1.21 tagged both stable and next. The cluster version picker (ClusterVersion.tsx) mapped the raw list straight through, so it offered the same version twice and, because it uses the version string as the React key, the duplicates also collided on their keys.

Per the issue, when two entries are identical but carry different tags we should surface only the most-preferred one.

Change

Dedupe in getHarperVersionsQuery.ts itself, so both the create and edit flows are covered (the edit-only useMemo in upsert/index.tsx does its own version filtering but is skipped entirely when creating a new cluster).

  • New pure helper dedupeHarperVersionsByTag collapses entries sharing a version string to a single entry.
  • Tag preference, most- to least-preferred: stable > next > beta > alpha, and any of those beats an unrecognized tag (HARPER_VERSION_TAG_PREFERENCE).
  • Kept entries retain their original position in the list (backed by Map insertion order).
  • Widened the HarperVersion.name type from the incomplete 'stable' | 'next' | 'current' union to string, reflecting that the endpoint also emits beta/alpha and potentially unknown tags.

Testing

  • New unit tests in getHarperVersionsQuery.test.ts cover the exact issue example (5.1.21 stable+next → only stable), the full preference order, known-beats-unknown, a lone unknown tag, order preservation, and the empty case.
  • Full suite green (1727 passed), plus tsc -b, oxlint, and dprint.

Note: the live endpoint doesn't reliably emit overlapping tags on demand, so this was verified via the pure-function unit tests rather than the browser flow; the picker's rendering is unchanged.

🤖 Generated with Claude Code

The HarperVersions endpoint can return the same version under more than
one tag (e.g. 5.1.21 as both stable and next). The cluster version picker
mapped the raw list straight through, so it offered the same version
twice — and used the version string as the React key, so the duplicates
collided.

Dedupe in the query itself so both the create and edit flows are covered
(the edit-only memo in upsert/index.tsx skips its own filtering when
creating). Versions sharing a version string collapse to a single entry,
keeping the most-preferred tag: stable > next > beta > alpha > anything
unrecognized. Kept entries retain their original position.

Closes #1531

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dawsontoth
dawsontoth requested a review from a team as a code owner July 17, 2026 14:52

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 introduces a deduplication mechanism for Harper versions, prioritizing tags based on a defined preference order (stable > next > beta > alpha). It includes comprehensive unit tests for the new deduplication logic. The feedback suggests removing redundant optional chaining and defensive guards when accessing the response value, as the TypeScript type system already guarantees its presence.

Comment thread src/features/clusters/queries/getHarperVersionsQuery.ts Outdated
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 50.99% 5434 / 10655
🔵 Statements 51.56% 5818 / 11282
🔵 Functions 43.21% 1331 / 3080
🔵 Branches 44.46% 3666 / 8245
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/clusters/queries/getHarperVersionsQuery.ts 100% 100% 100% 100%
Generated in workflow #1544 for commit 90887a5 by the Vitest Coverage Report Action

dawsontoth and others added 2 commits July 17, 2026 10:54
… (review)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ches

Adds tests that drive getHarperVersionsOptions().queryFn against a mocked
apiClient (asserting the endpoint, dedupe application, and query config)
and a case where a less-preferred tag arrives after a more-preferred one,
bringing getHarperVersionsQuery.ts to full coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@kriszyp kriszyp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I am the guilty party here, I think at some point accidentally published a release as both stable and next. Sorry about that. But thank you for adding a check for that.

Comment thread src/features/clusters/queries/getHarperVersionsQuery.ts
…faces (review)

The `as HarperVersionsResponse` cast isn't schema-backed (the endpoint's
OpenAPI description is broken), so a body missing `value` throws inside
the queryFn. Pin that it surfaces the error rather than swallowing it —
React Query's onError toasts it and consumers null-check
harperVersions?.value, so it fails safely.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dawsontoth
dawsontoth added this pull request to the merge queue Jul 20, 2026
Merged via the queue into stage with commit 9bceaf3 Jul 20, 2026
2 checks passed
@dawsontoth
dawsontoth deleted the fix/hide-overlapping-cluster-version-tags branch July 20, 2026 14:37
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.

Hide Overlapping Version Tags

2 participants