fix(frontend): cache Stripe portal URL - #2892
Conversation
📝 WalkthroughWalkthroughThe Stripe portal flow removes the session check, caches successful URLs per organization for three minutes, handles failures as unavailable URLs, and awaits the shared URL before opening the portal. Tests cover pending requests, failures, expiration, callback changes, and organization isolation. ChangesStripe portal cache
Estimated code review effort: 3 (Moderate) | ~15–30 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
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 `@src/services/stripe.ts`:
- Around line 40-58: Update portalUrlCache and the cache access in openPortal so
entries are stored independently by organization ID rather than replacing a
single shared entry. Preserve the existing three-minute TTL and URL-fetch
behavior, and ensure the org-a, org-b, org-a sequence reuses org-a’s cached URL
with only two API calls; add coverage for this sequence.
🪄 Autofix
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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f8171303-67b7-4bb0-827d-2a7345fc3bed
📒 Files selected for processing (2)
src/services/stripe.tstests/stripe-portal-cache.unit.test.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/services/stripe.ts (1)
78-83: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPreserve transient user activation before awaiting
portalUrl.When
portalUrlis pending,openBlank(url)runs after the confirm click task. Browsers can blockwindow.open, so the portal does not open.On web, open a blank tab synchronously and navigate it after
portalUrlresolves. Close the tab and show the existing error toast when no URL is available. Add browser coverage for this pending-request path.🤖 Prompt for 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. In `@src/services/stripe.ts` around lines 78 - 83, Update the confirm handler around portalUrl to open a blank browser tab synchronously before awaiting the pending URL, then navigate that tab once the URL resolves. If no URL is returned, close the blank tab and retain the existing “Cannot open your portal” toast; add browser coverage for the pending-request flow.
🤖 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.
Outside diff comments:
In `@src/services/stripe.ts`:
- Around line 78-83: Update the confirm handler around portalUrl to open a blank
browser tab synchronously before awaiting the pending URL, then navigate that
tab once the URL resolves. If no URL is returned, close the blank tab and retain
the existing “Cannot open your portal” toast; add browser coverage for the
pending-request flow.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d855be2e-4333-438d-a927-2608dfc85d48
📒 Files selected for processing (2)
src/services/stripe.tstests/stripe-portal-cache.unit.test.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
|



Summary
Test plan
bun lintbun typecheckbun test:unitbun run buildNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Performance