Skip to content

feat(reshape): surface staleness banner when Cost Explorer cache is old#576

Open
cristim wants to merge 1 commit into
feat/multicloud-web-frontendfrom
feat/issue-150-staleness-banner
Open

feat(reshape): surface staleness banner when Cost Explorer cache is old#576
cristim wants to merge 1 commit into
feat/multicloud-web-frontendfrom
feat/issue-150-staleness-banner

Conversation

@cristim
Copy link
Copy Markdown
Member

@cristim cristim commented May 20, 2026

Summary

  • Backend: getReshapeRecommendations now reads GetRecommendationsFreshness and populates recs_staleness ("" / "soft" / "hard") and recs_collected_at on the response; freshness failures are non-fatal (logged, staleness fields omitted)
  • Frontend: loadReshapeRecommendations calls the new renderReshapeStalenessBanner which inserts a banner slot above the recommendations table using warning/error CSS classes with a relative-time age label
  • Tests: classifyRecsAge unit tests pin the 12h/24h thresholds; frontend banner snapshot tests cover all three staleness states

Closes #150

Test plan

  • go test ./internal/api/... passes
  • cd frontend && npx jest riexchange passes (37 tests)
  • cd frontend && npx tsc --noEmit passes
  • Dev env: pause the scheduler, wait 12h, open RI Exchange tab, verify soft banner appears

…ld (closes #150)

The reshape-recommendations page silently showed alternatives sourced
from a potentially-hours-old Cost Explorer cache with no freshness
signal. This adds a backend staleness classifier and a frontend banner
to warn users when the underlying data is stale.

Backend:
- classifyRecsAge maps an age duration to "" / "soft" / "hard" using
  12 h and 24 h thresholds (mirrors dashboard freshness rule).
- getReshapeRecommendations calls GetRecommendationsFreshness (already
  on StoreInterface) and populates recs_staleness + recs_collected_at
  on ReshapeRecommendationsResponse; freshness failures are non-fatal
  (logged, response ships without staleness metadata).
- getReshapeRecommendations returns the same recs in all cases so no
  existing behaviour changes for the reshape table itself.

Frontend:
- getReshapeRecommendations now returns ReshapeRecommendationsResponse
  instead of a bare array; existing callers updated.
- renderReshapeStalenessBanner inserts a banner slot immediately before
  the recommendations table with "warning" / "error" CSS classes and
  a relative-time age label.
- Test mocks updated to the new response shape; banner unit tests added.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Warning

Review limit reached

@cristim, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 2 reviews/hour. Refill in 26 minutes and 53 seconds.

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

⌛ How to resolve this issue?

After more review capacity refills, 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 have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ba597b7-52ce-4040-a53c-e366b5f671aa

📥 Commits

Reviewing files that changed from the base of the PR and between bc7bf0f and a027e4d.

📒 Files selected for processing (7)
  • frontend/src/__tests__/riexchange-permissions.test.ts
  • frontend/src/__tests__/riexchange.test.ts
  • frontend/src/api/index.ts
  • frontend/src/api/riexchange.ts
  • frontend/src/riexchange.ts
  • internal/api/handler_ri_exchange.go
  • internal/api/handler_ri_exchange_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-150-staleness-banner

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

@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/many Affects most users effort/s Hours type/feat New capability triaged Item has been triaged labels May 20, 2026
@cristim
Copy link
Copy Markdown
Member Author

cristim commented May 20, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

✅ 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
Copy link
Copy Markdown
Member Author

cristim commented May 22, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

✅ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/many Affects most users priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/feat New capability urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant