Skip to content

fix(plans): scope Target Accounts search to selected plan provider - #711

Merged
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/703-account-picker-provider-filter
May 25, 2026
Merged

cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/703-account-picker-provider-filter

Conversation

@cristim

@cristim cristim commented May 25, 2026 •

Copy link
Copy Markdown
Member

Closes #703. Target Accounts search returned accounts from any provider regardless of the plan's selected provider; save then failed with 'plan provider mismatch' (the #209 validator).

Changes (frontend/src/plans.ts)

  • handlePlanAccountSearch (line 707): reads #plan-provider and passes { search, provider } to api.listAccounts (omits provider when not set).
  • setupPlanAccountsSection (line 741): reads current plan provider before loading existing assignments; filters listPlanAccounts results to only keep matching-provider rows (drops stale assignments from a previous provider switch).
  • setupPlanAccountsSection (line 762): disables the search input until a provider is picked.
  • Provider-change listener (new): clears planSelectedAccounts, re-renders empty chips, updates the hidden field, toggles input disabled.

Tests

5 new tests in Target Accounts provider filter (issue #703):

  • Account search passes the active plan provider
  • Switching provider clears chips and the hidden field
  • Search input disables/enables with provider selection

All 93 plans tests pass; full suite 1936/1936 pass.

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suite for the target accounts provider filter feature.
  • Bug Fixes

    • Account search now respects the currently selected plan provider when fetching results.
    • Switching providers automatically clears all previously selected accounts and their associations.
    • Account search input is disabled until a provider is selected, then re-enabled accordingly.

Review Change Stack

Pass the plan-provider select value as the provider filter to
api.listAccounts in handlePlanAccountSearch so only accounts
matching the plan's provider appear in suggestions. This prevents
a cross-provider assignment reaching the backend validator from
issue #209 (plan provider mismatch).

Also filter existing assignments by provider in
setupPlanAccountsSection so stale cross-provider chips are dropped
when the modal opens with a provider already selected.

On provider change (setupRampScheduleHandlers), clear all selected
accounts and re-render the chips to remove any chips whose provider
no longer matches. Disable the account search input until a provider
is picked so users cannot search before a provider is set.

Closes #703
@cristim cristim added triaged Item has been triaged priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-sprint Within the current sprint impact/few Limited audience effort/xs Trivial / one-liner type/bug Defect labels May 25, 2026
@coderabbitai

coderabbitai Bot commented May 25, 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 25 minutes and 50 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: 507e3e0b-e79f-4525-96d3-ca6165a6928d

📥 Commits

Reviewing files that changed from the base of the PR and between 147b1d8 and 4e3fbd5.

📒 Files selected for processing (2)
  • frontend/src/__tests__/plans.test.ts
  • frontend/src/plans.ts
📝 Walkthrough

Walkthrough

This PR implements provider-aware account search for plan target accounts. The account list fetch now includes the currently selected plan provider, existing accounts are filtered by provider on load, the search input is disabled until a provider is chosen, and clearing the provider resets all account selections and updates UI state accordingly.

Changes

Provider-aware account search and filtering

Layer / File(s) Summary
Account search with provider filtering
frontend/src/plans.ts, frontend/src/__tests__/plans.test.ts
handlePlanAccountSearch reads the current plan-provider value and passes it to api.listAccounts; test suite injects DOM elements, uses fake timers, and verifies search includes the selected provider in API calls (including default "aws" case).
Load-time account filtering and input state
frontend/src/plans.ts
setupPlanAccountsSection filters existing plan accounts to only those matching the current provider selection, and disables the account search input when no provider is selected.
Provider change state management
frontend/src/plans.ts, frontend/src/__tests__/plans.test.ts
When the plan provider changes via setupRampScheduleHandlers, all selected accounts are cleared, chips and hidden ID field are re-rendered, and the search input is disabled/enabled based on whether a provider is present; tests verify clearing behavior and input enable/disable state transitions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit hops through provider fields,
Each account filtered by what's revealed—
AWS, Azure—search knows the way,
No cross-provider mix today! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: scoping Target Accounts search to the selected plan provider, which is the core fix for issue #703.
Linked Issues check ✅ Passed All coding requirements from issue #703 are met: account search now filters by provider, stale cross-provider assignments are dropped, and the search input disables until a provider is selected.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #703: modifications to account-search logic and provider-aware filtering with supporting tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/703-account-picker-provider-filter

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

@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/plans.ts`:
- Around line 935-947: When the provider changes the code clears
planSelectedAccounts and updates inputs but doesn't clear the visible account
suggestions, so stale suggestions remain clickable; update the provider change
handler (the block that manipulates planSelectedAccounts, calls
renderPlanAccountChips and updatePlanAccountIdsField and reads providerSelect)
to also clear/hide the account suggestions UI and reset any suggestion state:
remove or empty the suggestions container (e.g., the element used to show
account suggestions such as "plan-account-suggestions"), hide it or set its
innerHTML to empty, and reset any related variables or selection state so no
previous-provider suggestions can be clicked after providerSelect changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a2a6e1c8-6eb4-4b43-b85d-8eb5791fcac7

📥 Commits

Reviewing files that changed from the base of the PR and between f3240f4 and 147b1d8.

📒 Files selected for processing (2)
  • frontend/src/__tests__/plans.test.ts
  • frontend/src/plans.ts

Comment thread frontend/src/plans.ts
When the user changes the plan provider, any open account-suggestion
dropdown from a previous search was left visible and clickable, allowing
a mismatched-provider account to be added. Clear the suggestion list,
hide the dropdown, and reset the search input on every provider change.

Adds a test asserting all three behaviours (contents cleared, hidden
class present, search value empty) after a provider change event.
@cristim

cristim commented May 25, 2026

Copy link
Copy Markdown
Member Author

Addressed CR Major finding (comment #3299775023): stale account suggestions were not cleared on provider change.

What was fixed (commit 4e3fbd5 on fix/703-account-picker-provider-filter):

In frontend/src/plans.ts provider change listener (line ~944):

  • Clear #plan-account-suggestions contents (textContent = '')
  • Hide the dropdown (classList.add('hidden')) - same pattern as handlePlanAccountSearch
  • Clear the search input value (accountSearchInput.value = '')

Test added in frontend/src/__tests__/plans.test.ts: 'switching provider clears and hides open account suggestion dropdown' - asserts all three behaviours (content empty, hidden class present, search value empty) after a provider change event.

94 tests, all passing.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

@cristim: Thanks for the detailed update — the fix looks well-targeted. Clearing #plan-account-suggestions contents, hiding the dropdown, and resetting the search input value on provider change covers all three stale-state vectors, and the new test validates each behaviour explicitly. Triggering a fresh review now.

✅ 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 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

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

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

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

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

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

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 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.

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

Labels

effort/xs Trivial / one-liner impact/few Limited audience 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