Skip to content

fix: ModelSelector now fetches billing status directly to fix Pro pla…#175

Merged
AnthonyRonning merged 2 commits intomasterfrom
fix-model-selector-billing-status
Aug 5, 2025
Merged

fix: ModelSelector now fetches billing status directly to fix Pro pla…#175
AnthonyRonning merged 2 commits intomasterfrom
fix-model-selector-billing-status

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Aug 5, 2025

…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

  • Bug Fixes
    • Improved accuracy of billing status display and access control by fetching billing status directly from the server when the user is authenticated.

…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>
@coderabbitai
Copy link

coderabbitai bot commented Aug 5, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

The ModelSelector.tsx component was updated to fetch the billingStatus using a React Query hook instead of extracting it from local state. The query retrieves the billing status asynchronously from the billing service and is only enabled if the user is authenticated. No exported or public entity signatures were changed.

Changes

Cohort / File(s) Change Summary
ModelSelector Billing Status Fetch Refactor
frontend/src/components/ModelSelector.tsx
Replaced local state extraction of billingStatus with a React Query hook that fetches billing status asynchronously from the billing service, conditioned on user authentication.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

  • fix: only check team status for team plans #170: Similar refactor of billing status fetching using React Query hooks and conditional enabling based on user authentication, focusing on different components and routes but sharing the approach to billing state management.

Poem

A bunny hopped through code so bright,
Swapped state for queries, felt just right.
Billing now fetched on the fly,
Only when users are logged in—oh my!
The carrots of progress, crisp and new,
This patch is fresh as morning dew. 🥕✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e02939d and dcf0b1a.

📒 Files selected for processing (1)
  • frontend/src/components/ModelSelector.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/ModelSelector.tsx
⏰ 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)
  • GitHub Check: build-ios
  • GitHub Check: build-linux
  • GitHub Check: build-macos (universal-apple-darwin)
  • GitHub Check: browseruse-tests
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-model-selector-billing-status

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 5, 2025

Deploying maple with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

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 useQuery configuration as other components (queryKey: ["billingStatus"], enabled by user authentication)
  • Maintaining the existing hasAccessToModel logic 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

Edit Code Review Bot Settings | Greptile

…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>
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

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

Edit Code Review Bot Settings | Greptile

@AnthonyRonning AnthonyRonning merged commit 920dc4f into master Aug 5, 2025
6 of 7 checks passed
@AnthonyRonning AnthonyRonning deleted the fix-model-selector-billing-status branch August 5, 2025 19:10
AnthonyRonning added a commit that referenced this pull request Aug 5, 2025
…or-billing-status"

This reverts commit 920dc4f, reversing
changes made to ce7e8b1.
@coderabbitai coderabbitai bot mentioned this pull request Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant