fix: ModelSelector now fetches billing status directly to fix Pro pla…#175
fix: ModelSelector now fetches billing status directly to fix Pro pla…#175AnthonyRonning merged 2 commits intomasterfrom
Conversation
…n access The ModelSelector component was using billingStatus from local state which could be null or stale after recent changes to other components. This caused the "Upgrade?" prompt to incorrectly appear for Pro plan users on models like DeepSeek R1. Now ModelSelector fetches billing status directly using useQuery, matching the pattern used in BillingStatus and AccountMenu components. This ensures accurate plan detection for model access restrictions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying maple with
|
| Latest commit: |
dcf0b1a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8671b62d.maple-ca8.pages.dev |
| Branch Preview URL: | https://fix-model-selector-billing-s.maple-ca8.pages.dev |
There was a problem hiding this comment.
Greptile Summary
This PR fixes a bug in the ModelSelector component where Pro plan users were incorrectly seeing "Upgrade?" prompts for premium models like DeepSeek R1. The root cause was that ModelSelector was relying on potentially stale billing status data from local state, which could become null or outdated after recent changes to other components.
The fix replaces the local state dependency with a direct useQuery call to fetch billing status, following the same pattern used in BillingStatus and AccountMenu components. This ensures the hasAccessToModel function has accurate, up-to-date billing information when determining model access permissions.
The change integrates well with the existing codebase architecture by:
- Using the established billing service pattern with
getBillingService().getBillingStatus() - Following the same
useQueryconfiguration as other components (queryKey: ["billingStatus"], enabled by user authentication) - Maintaining the existing
hasAccessToModellogic that checks plan names against model requirements
This approach ensures consistent billing data across all components while fixing the immediate user experience issue where paid users were prompted to upgrade for features they already had access to.
Confidence score: 4/5
- This PR is safe to merge with minimal risk as it follows established patterns and fixes a clear bug
- Score reflects straightforward logic changes using proven patterns, though there's a minor concern about local state synchronization
- Pay close attention to how other components might be affected by the removal of local state billing dependency
1 file reviewed, 1 comment
…lity Add setBillingStatus call to keep local state synchronized with fetched data, ensuring backward compatibility with any components that may still rely on the local billing state context. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Greptile Summary
This review covers only the changes made since the last review (commit e02939d), not the entire PR.
The most recent changes address the synchronization issue identified in the previous review. The developer has added the setBillingStatus(status) call within the queryFn of the useQuery hook in the ModelSelector component. This ensures that when the billing status is fetched directly from the server, it's also synchronized back to the local state that other components may still depend on.
This change maintains backward compatibility while fixing the core issue. The ModelSelector now follows a hybrid approach: it fetches fresh billing data directly via useQuery for its own access control decisions, but also updates the local state to keep the rest of the application's state management intact. This architectural decision reflects a cautious refactoring approach that fixes the immediate problem (stale billing status causing incorrect "Upgrade?" prompts for Pro users) without breaking existing component integrations that might still rely on the local state pattern.
The implementation now fully matches the pattern established in other components like BillingStatus, ensuring consistency across the codebase while preserving the existing state management architecture.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it addresses the identified synchronization issue
- Score reflects the addition of the missing state synchronization call that maintains backward compatibility
- No files require special attention as the change is a simple one-line addition that completes the fix
1 file reviewed, no comments
…n access
The ModelSelector component was using billingStatus from local state which could be null or stale after recent changes to other components. This caused the "Upgrade?" prompt to incorrectly appear for Pro plan users on models like DeepSeek R1.
Now ModelSelector fetches billing status directly using useQuery, matching the pattern used in BillingStatus and AccountMenu components. This ensures accurate plan detection for model access restrictions.
🤖 Generated with Claude Code
Summary by CodeRabbit