Skip to content

fix: keep fleet stats stable during status and search filtering#13951

Merged
kubestellar-hive[bot] merged 1 commit into
kubestellar:mainfrom
ashnaaseth2325-oss:fix/cluster-locations-stats-tiles
May 16, 2026
Merged

fix: keep fleet stats stable during status and search filtering#13951
kubestellar-hive[bot] merged 1 commit into
kubestellar:mainfrom
ashnaaseth2325-oss:fix/cluster-locations-stats-tiles

Conversation

@ashnaaseth2325-oss
Copy link
Copy Markdown
Contributor

SUMMARY

This PR fixes ClusterLocations stats tiles so fleet-level metrics remain stable when users apply status chips or local search filters. The change separates global/reachability scoping from UI-level filtering, ensuring the stats bar always reflects the full scoped fleet while the map markers and cluster list continue to respond to active filters.

Primary changes are in web/src/components/cards/ClusterLocations.tsx, specifically the filtering pipeline and stats computation logic.

FIX

// Before
const clusters = useMemo(() => {
  if (statusFilter === 'healthy') {
    result = result.filter(c => c.healthy)
  }
  return result
}, [..., statusFilter])

const stats = useMemo(() => ({
  totalClusters: clusters.length,
}), [clusters])

// After
const baseClusters = useMemo(() => {
  return allClusters.filter(c => c.reachable !== false)
}, [...])

const clusters = useMemo(() => {
  let result = baseClusters
  if (statusFilter === 'healthy') {
    result = result.filter(c => c.healthy)
  }
  return result
}, [baseClusters, statusFilter])

const stats = useMemo(() => ({
  totalClusters: baseClusters.length,
}), [baseClusters])

Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
Copilot AI review requested due to automatic review settings May 15, 2026 21:04
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label May 15, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 15, 2026

Deploy Preview for kubestellarconsole ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3ded2ae
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a078a5799e8b000085b5f87
😎 Deploy Preview https://deploy-preview-13951.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions
Copy link
Copy Markdown
Contributor

👋 Hey @ashnaaseth2325-oss — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the cluster filtering pipeline in ClusterLocations so that fleet-level stats tiles remain stable when users apply status chip or local search filters. A new baseClusters memo holds the global/reachability-scoped fleet, while the existing clusters memo layers on UI filters used only by the map markers and cluster list.

Changes:

  • Split filtering into two memos: baseClusters (global scope) and clusters (UI filters layered on top).
  • Recomputed stats (healthyClusters, totalClusters, uniqueRegions, providerCount) directly from baseClusters rather than the filtered clusters/regionGroups.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Clean, well-scoped fix. Separating baseClusters (global/reachability scope) from clusters (with status chip and search applied) correctly ensures stats tiles reflect the full fleet rather than the filtered view. The useMemo dependency arrays are minimal and correct. LGTM ✅

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@kubestellar-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

Clean, well-scoped fix. Separating baseClusters (global/reachability scope) from clusters (with status chip and search applied) correctly ensures stats tiles reflect the full fleet rather than the filtered view. The useMemo dependency arrays are minimal and correct. LGTM ✅

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Security Review ✅ No security concerns. This is a pure UI logic fix splitting cluster filtering into base (for stats) and filtered (for display). No data flows or trust boundaries affected.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Clean fix — separating base clusters from UI-filtered clusters so stats tiles stay stable. LGTM.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@kubestellar-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

Clean fix — separating base clusters from UI-filtered clusters so stats tiles stay stable. LGTM.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Security review: PASS

UI-only refactor separating base cluster filtering from display filtering. No API changes, no new data flows, no security implications.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@kubestellar-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

Security review: PASS

UI-only refactor separating base cluster filtering from display filtering. No API changes, no new data flows, no security implications.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Security review ✅ — No concerns.

Pure UI logic refactor: splits clusters memo into baseClusters (global/reachability scope) and clusters (status chip + search). Stats tiles now read from baseClusters so fleet totals don't fluctuate with local filters. No API changes, no new data flows, no XSS vectors.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

LGTM. Clean separation of baseClusters (for stats) from filtered clusters (for map/list). Stats tiles now correctly read from the unfiltered scoped set.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@kubestellar-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

LGTM. Clean separation of baseClusters (for stats) from filtered clusters (for map/list). Stats tiles now correctly read from the unfiltered scoped set.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

Security review: ✅ No concerns

UI-only change refactoring the filtering pipeline in ClusterLocations. Separates base scoping from display filtering so stats stay stable. No security implications — no new external inputs, no href changes, no data fetching changes.

@kubestellar-hive
Copy link
Copy Markdown
Contributor

Hi @ashnaaseth2325-oss — the logic in this PR looks good! Splitting clusters into baseClusters (global/reachability filter) and clusters (status chip + search) so the stats tiles don't shift when a filter is active is exactly the right approach.

The CI failures are all caused by a stale branch — main has moved significantly since this PR was created. Please rebase onto current main to clear them:

git fetch origin main
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

Once the rebase is pushed CI will re-run. Let us know if you run into any conflicts!

Copy link
Copy Markdown
Contributor

@kubestellar-hive kubestellar-hive Bot left a comment

Choose a reason for hiding this comment

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

sec-check ✅ — Pure frontend logic refactor: splits cluster filtering into baseClusters (global scope) and clusters (status/search). Stats read from baseClusters so they stay stable during local filtering. No new data flows, no DOM sinks, no security concerns.

@kubestellar-prow
Copy link
Copy Markdown
Contributor

@kubestellar-hive[bot]: changing LGTM is restricted to collaborators

Details

In response to this:

sec-check ✅ — Pure frontend logic refactor: splits cluster filtering into baseClusters (global scope) and clusters (status/search). Stats read from baseClusters so they stay stable during local filtering. No new data flows, no DOM sinks, no security concerns.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubestellar-hive
Copy link
Copy Markdown
Contributor

🔒 Security Review: ✅ PASS

No security issues found. Clean refactor — proper array safety, no XSS vectors, no injection risks. Safe to merge.

@kubestellar-hive kubestellar-hive Bot merged commit 635da55 into kubestellar:main May 16, 2026
47 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants