Skip to content

fix(home/kpi): unwrap recommendations envelope so Potential Monthly Savings reflects real total - #755

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/749-home-potential-savings
May 27, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
fix/749-home-potential-savings

Conversation

@cristim

@cristim cristim commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

QA exploratory testing found the Home page "Potential Monthly Savings" KPI showing $0 while the Opportunities page showed $212 - $314 for the same dataset (All Providers / All Accounts, 23 recommendations).

Root cause

/api/recommendations always returns an envelope:

{ "recommendations": [...], "summary": {...}, "regions": [...] }

The Opportunities page correctly read .recommendations. The Home dashboard's loadDashboard() instead guarded with Array.isArray(rawRecs), which is false for an object, silently coercing recs to []. With an empty array, groupRecsByCell returns an empty map, pageLevelRange reports cellCount: 0, and the savings display falls back to formatCurrency(0) = $0 -- even though 23 recommendations with real savings were available.

Fix

loadDashboard() now unwraps .recommendations from the envelope when the result is a non-array object, accepting either shape (envelope or flat array) so existing test mocks remain valid.

Files changed

  • frontend/src/dashboard.ts
  • frontend/src/__tests__/dashboard.test.ts

Test plan

  • Regression test #749 asserts the envelope shape produces a populated savings card, not $0.
  • All existing dashboard tests pass.
  • Manual: post-deploy, Home Potential Monthly Savings matches Opportunities for All/All, then with a Provider filter, then with an Account filter.

Closes #749.

Home showed $0 while Opportunities showed $212-$314 for the same
recommendation dataset. Root cause: the backend always returns the
envelope { recommendations: [...], summary: {...}, regions: [...] }
but loadDashboard() only checked Array.isArray(rawRecs), which is
false for an object, so recs was silently coerced to [] and the
pageLevelRange computation produced $0. The Opportunities page worked
because it cast the result to RecommendationsResponse and read
.recommendations directly. The Home KPI now unwraps .recommendations
from the envelope (with a flat-array fallback so test fixtures still
work), matching the Opportunities aggregator.

Closes #749.
@cristim cristim added triaged Item has been triaged priority/p1 Next up; this sprint severity/high Significant harm urgency/this-sprint Within the current sprint impact/all-users Affects every user effort/s Hours type/bug Defect labels May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 36 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91a3c355-d650-4495-aae0-b0007e6f5af8

📥 Commits

Reviewing files that changed from the base of the PR and between f5b76eb and f938b0d.

📒 Files selected for processing (2)
  • frontend/src/__tests__/dashboard.test.ts
  • frontend/src/dashboard.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/749-home-potential-savings

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

@cristim

cristim commented May 27, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 4332f6f into feat/multicloud-web-frontend May 27, 2026
5 checks passed
@cristim
cristim deleted the fix/749-home-potential-savings branch June 3, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/all-users Affects every user priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant