Skip to content

fix(dashboard): merge per-service savings charts and populate current_savings (closes #908) - #910

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
feat/908-merge-savings-chart
Jun 2, 2026
Merged

cristim merged 1 commit into
feat/multicloud-web-frontendfrom
feat/908-merge-savings-chart

Conversation

@cristim

@cristim cristim commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

Closes #908. Merges the two Home per-service savings charts into one range chart with a current-savings underlay, and fixes the backend bug where per-service current_savings was never populated.

Backend bug fix

summarizeRecommendationsWithCoverage (internal/api/handler_dashboard.go) built by_service setting only PotentialSavings; ServiceSavings.CurrentSavings was always its float64 zero, so the frontend rendered an empty Current series.

Fix: also set svc.CurrentSavings += scaled, where scaled is the existing scaledSavings(rec, coverageByKey) value (rec.Savings * min(coverage,100)/100). This reuses the same coverage-scaled amount already used for the per-service potential, so current is keyed and scaled identically to potential. A regression test (TestSummarizeRecommendationsWithCoverage_PopulatesCurrentSavings) asserts non-zero, correctly-scaled current_savings per service; the existing table test now also asserts CurrentSavings.

Frontend merge

  • Removed the standalone renderSavingsChart "Potential Savings by Service" chart and its #savings-chart-section / #savings-chart container in index.html.
  • The surviving range chart (renderSavingsByService) now also draws each service's current (committed) savings as a separate bar in a DARKER shade of that service's potential hue. The darker shade is derived programmatically (darkenHexColor, ~30% per-channel reduction, hue preserved), not hardcoded per service.
  • Preserved: top-N "+N more" cap, Provider/Account chip re-render (driven by loadDashboard), empty/zero states, non-empty axis + legend labels (a11y), chart instance dedup.

Tests

  • go test ./internal/api/... green (1385 passing).
  • Frontend jest green (2210 passing): merged chart renders the current underlay per service, current bar uses a darker variant, current defaults to 0 when a service is absent from by_service, chip-change re-render, empty-state, plus darkenHexColor / parseHexColor unit tests. html.test.ts asserts the old chart is gone.
  • tsc --noEmit clean.

…_savings (closes #908)

Backend: summarizeRecommendationsWithCoverage now sets
ServiceSavings.CurrentSavings (previously never written, so the Home
chart's current series was always $0). It reuses scaledSavings, the same
coverage-scaled amount used for the per-service potential, so current is
keyed and scaled identically. Adds a regression test asserting non-zero
current_savings where coverage exists.

Frontend: collapses the two Home per-service charts into one. The old
standalone "Potential Savings by Service" grouped chart (renderSavingsChart)
and its #savings-chart container are removed. The surviving range chart now
draws each service's current (committed) savings as a separate bar in a
programmatically-darkened shade of that service's potential hue
(darkenHexColor, ~30% darker per channel, hue preserved). Preserves the
top-N "+N more" cap, chip filter re-render, empty/zero states, escaped
axis/legend labels, and chart dedup.
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/m Days type/bug Defect labels Jun 1, 2026
@coderabbitai

coderabbitai Bot commented Jun 1, 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 14 minutes and 58 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: 17747f69-8a90-4df5-8401-29f4b47c4a71

📥 Commits

Reviewing files that changed from the base of the PR and between 80c20d2 and 5ccc301.

📒 Files selected for processing (6)
  • frontend/src/__tests__/dashboard.test.ts
  • frontend/src/__tests__/html.test.ts
  • frontend/src/dashboard.ts
  • frontend/src/index.html
  • internal/api/handler_dashboard.go
  • internal/api/handler_dashboard_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/908-merge-savings-chart

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

@cristim

cristim commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 1, 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 commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 1, 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 commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 1, 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 1dbeef7 into feat/multicloud-web-frontend Jun 2, 2026
6 checks passed
@cristim
cristim deleted the feat/908-merge-savings-chart branch June 2, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/many Affects most users priority/p2 Backlog-worthy severity/medium Moderate 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