feat(recommendations): per-rec deterministic seeding in multi-account fan-out (closes #197) - #838
Conversation
…ts (closes #197) Multi-account fan-out buckets now expose per-rec Payment dropdowns so each rec gets its own override-seeded default instead of silently falling back to the toolbar value for the whole bucket. Changes: - FanOutBucket gains optional perRecPayments map (rec.id -> payment), populated only for buckets spanning 2+ distinct cloud_account_ids. Each rec's default is seeded from its account's AccountServiceOverride (matching provider+service, normalized, support-checked), falling back to the bucket-level payment. - openFanOutModal now pre-fetches overrides for ALL accounts across all buckets (was: only sole-account buckets). Single-account buckets are unaffected; the extra fetch just removes the narrowing guard. - renderFanOutBucketSection renders a per-rec list with individual Payment selects (.fanout-per-rec-payment) when perRecPayments is set. Each select carries data-rec-id so tests and app code can target it. - handleFanOutExecute (app.ts) uses perRecPayments.get(r.id) for the POST payment field, falling back to b.payment for single-account buckets and for any rec not in the map. - getFanOutBuckets deep-copies perRecPayments to prevent callers from mutating module state. - Tests (h) + (i): assert per-rec map seeding from overrides and that dropdown changes propagate to module state.
|
Warning Review limit reached
More reviews will be available in 54 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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR extends the fan-out bulk purchase flow to support per-recommendation payment overrides in multi-account buckets. The interface adds a ChangesPer-Recommendation Payment Overrides for Multi-Account Fan-Out
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
|
pr-iterate: CR appears to be blocked by org-level usage limits ( |
|
🧠 Learnings used✅ Action performedFull review finished. |
|
@coderabbitai review |
Rate Limit Exceeded
|
|
@coderabbitai full review Generated by Claude Code |
|
🧠 Learnings used✅ Action performedFull review finished. |
There was a problem hiding this comment.
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/recommendations.ts`:
- Around line 3401-3425: openFanOutModal() currently eagerly populates
perRecPayments for every rec, which makes the bucket-level dropdown a no-op for
rows that should fallback to seed.payment; change the logic so perRecPayments is
left undefined or only contains explicit overrides (e.g., when
overridesByAccount provides a different payment or the user has manually changed
a row) instead of setting every rec to bucketPayment, ensure the execute path
uses perRecPayments.get(rec.id) ?? seed.payment, and update the bucket-level
change handler to either remove per-rec entries that should follow the new
bucket default or sync visible per-rec selects for ids absent from the map; look
for symbols openFanOutModal, perRecPayments, seed.payment, overridesByAccount
and the bucket-level change handler and adjust them accordingly.
🪄 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: f828f1d6-1f03-4e2e-b74d-d5cff59c516f
📒 Files selected for processing (3)
frontend/src/__tests__/recommendations.test.tsfrontend/src/app.tsfrontend/src/recommendations.ts
… rows openFanOutModal eagerly wrote every rec of a multi-account bucket into perRecPayments, and the execute path prefers that map over b.payment via `perRecPayments.get(id) ?? b.payment`. Once the map was fully populated the fallback was dead, so changing the bucket-level Payment dropdown only mutated b.payment while unedited rows still posted their stale per-rec value. The visible bucket-level control was a no-op for any row that originally followed the bucket default. Treat perRecPayments as an explicit-override set: seed only recs whose payment differs from the bucket default, drop a per-rec entry when the user selects the current bucket default again, and re-sync visible per-rec selects (that have no override) when the bucket-level dropdown changes. Skip the re-sync for rows whose service does not support the new payment so the shown value never diverges from the POST payload. Adds a regression test asserting the bucket-level change propagates to the resolved payment for non-overridden recs, and updates the per-rec test to the override-only contract. Both fail pre-fix.
CR follow-up: bucket-level Payment no-op for multi-account bucketsAddressed the outstanding CodeRabbit finding on Finding (Major / Quick win): "Bucket-level Payment is a no-op for multi-account buckets."
@coderabbitai full review |
|
Triggering the full review now. ✏️ Learnings added
🧠 Learnings used✅ Action performedFull review finished. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Summary
FanOutBucketgains optionalperRecPayments: Map<string, BulkPurchasePayment>populated for buckets spanning 2+ distinctcloud_account_idvalues; each rec's default is seeded from its account'sAccountServiceOverride, falling back to the bucket-level payment.openFanOutModalnow pre-fetches overrides for all accounts (was: sole-account buckets only), so per-rec seeding has the data it needs.renderFanOutBucketSectionrenders individual.fanout-per-rec-paymentselects withdata-rec-idwhenperRecPaymentsis set; the change handler mutates module state, andhandleFanOutExecuteusesperRecPayments.get(r.id)per POST.Test plan
cd frontend && npm ci && node_modules/.bin/jest --testPathPattern="recommendations.test.ts$" --no-coverage- 321 tests passgo build ./...- no backend breakage🤖 Generated with claude-flow
Summary by CodeRabbit
New Features