Skip to content

ux(purchases): re-query Savings History chart on filter chip change (closes #503) - #578

Merged
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
ux/purchases-savings-history-filter
May 22, 2026
Merged

ux(purchases): re-query Savings History chart on filter chip change (closes #503)#578
cristim merged 1 commit into
feat/multicloud-web-frontendfrom
ux/purchases-savings-history-filter

Conversation

@cristim

@cristim cristim commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the Purchases-tab Savings History chart, which had the same filter bug fixed for the Home page (#498 / PR #500) and Opportunities (#477 / PR #488): it did not re-query when the provider/account filter chips changed, and ignored the account filter.

Fix

frontend/src/modules/savings-history.ts now subscribes to state.subscribeProvider / state.subscribeAccount (mirroring PR #500's pattern), fires the chart reload only when the Purchases tab is active (microtask-coalesced), and passes the account filter through to the query.

Scope

Test plan

  • savings-history.test.ts: chip change triggers a reload; account filter passes through; inactive-tab guard
  • app.test.ts updated for the new wiring

Closes #503.

The Purchases-tab Savings History chart (modules/savings-history.ts) only
wired its local period dropdown and refresh button, so changing the global
Provider or Account topbar chip did not refresh it (the tab had to be left
and re-entered), and it ignored the account filter entirely.

Mirror the PR #500 / #488 pattern:
- isPurchasesTabActive() guards the reload so a chip change while the user
  is on another tab defers (switchTab reloads on entry).
- queueMicrotask coalesces the account-then-provider subscriber pair fired
  from one user action (the #185 ordering rule), collapsing two reloads
  into one and avoiding stale-overwrite races.
- loadSavingsHistory() now forwards the selected account_id (single-select,
  matching the backend) and the provider chip to getSavingsAnalytics. The
  provider param is honoured by the backend once #502 lands; until then
  account_ids does the filtering.

Adds regression tests covering subscriber wiring, the active-tab guard,
coalescing, account_id passthrough, and two consecutive account changes
producing distinct fetches. Updates app.test.ts's state mock to expose the
new subscribe getters since it exercises the real savings-history module.

Closes #503
@cristim cristim added bug Something isn't working 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/s Hours type/bug Defect labels May 20, 2026
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@cristim has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 17 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a78007f5-65bd-4fa7-b335-3c20ae53c43a

📥 Commits

Reviewing files that changed from the base of the PR and between bc8831b and f2ac57b.

📒 Files selected for processing (3)
  • frontend/src/__tests__/app.test.ts
  • frontend/src/__tests__/savings-history.test.ts
  • frontend/src/modules/savings-history.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ux/purchases-savings-history-filter

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

@cristim

cristim commented May 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 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 May 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 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 12aba9d into feat/multicloud-web-frontend May 22, 2026
5 checks passed
@cristim
cristim deleted the ux/purchases-savings-history-filter branch June 3, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort/s Hours 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