Skip to content

Conversation

@Shironex
Copy link
Collaborator

@Shironex Shironex commented Jan 9, 2026

Summary

  • Fix hardcoded planType: 'plus' that was incorrectly returned as default when CLI test succeeded
  • Read plan type from correct JWT path: claims['https://api.openai.com/auth'].chatgpt_plan_type
  • Add subscription expiry check - automatically override to 'free' if subscription has expired
  • Use getCodexAuthPath() from @automaker/platform instead of manual path construction
  • Remove unused imports (os, fs, path) and unused class properties
  • Clean up code and add minimal essential logging (only errors and important events)

Test plan

  • Verify Codex usage shows correct plan type (free/plus/pro) based on JWT
  • Verify expired subscriptions show as "free" plan
  • Verify rate limit detection still works and shows correct plan from error response

🤖 Generated with Claude Code

- Fix hardcoded 'plus' planType that was returned as default
- Read plan type from correct JWT path: https://api.openai.com/auth.chatgpt_plan_type
- Add subscription expiry check - override to 'free' if expired
- Use getCodexAuthPath() from @automaker/platform instead of manual path
- Remove unused imports (os, fs, path) and class properties
- Clean up code and add minimal essential logging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the Codex usage service to accurately determine a user's plan type and subscription status. It addresses issues with hardcoded plan values, introduces a mechanism to detect and handle expired subscriptions, and improves the overall reliability of plan detection by prioritizing information from the authentication JWT. Additionally, it includes significant code cleanup and logging enhancements for better maintainability.

Highlights

  • Accurate Plan Type Detection: The logic for determining the Codex plan type has been significantly improved, moving away from a hardcoded 'plus' value. It now correctly reads the 'chatgpt_plan_type' from the JWT claims within the authentication token.
  • Subscription Expiry Handling: A new check has been implemented to detect expired subscriptions. If a subscription is found to be expired, the plan type is automatically overridden to 'free', ensuring accurate representation of user access.
  • Refactored Authentication Path: The method for locating the Codex authentication file has been standardized by utilizing 'getCodexAuthPath()' from the '@automaker/platform' library, improving consistency and maintainability.
  • Code Cleanup and Logging: Unused imports ('os', 'fs', 'path') and class properties have been removed. Logging has been streamlined to focus on errors and important events, enhancing code clarity and debugging.
  • Robust JWT Parsing: The JWT parsing logic has been made more robust, including checks for malformed tokens and adapting to Node.js environments by using 'Buffer' for base64 decoding.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great improvement. It correctly fixes the hardcoded planType and introduces a more robust way of detecting the plan from the JWT in the auth file, including checking for subscription expiry. The code cleanup, such as removing unused imports and properties and switching to a structured logger, is also very welcome.

I've added a few suggestions to further improve the robustness of the new JWT parsing logic by adding more type checks, and to refactor a function to reduce code duplication, which will make the code easier to maintain in the future.

Shironex and others added 2 commits January 9, 2026 22:25
- Add typeof checks for fallback claim values to prevent runtime errors
- Make openaiAuth parsing more robust with proper type validation
- Add isNaN check for date parsing to handle invalid dates
- Refactor fetchFromAuthFile to reuse getPlanTypeFromAuthFile (DRY)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Shironex Shironex self-assigned this Jan 9, 2026
@Shironex Shironex added Ready-To-Merge A feature or bug has been improved/fixed and a final review is requested before merging. Testers-Requested Request for others to test an enhancement or bug fix/etc. labels Jan 9, 2026
@Shironex Shironex merged commit 950a97d into v0.9.0rc Jan 9, 2026
6 checks passed
@Shironex Shironex deleted the fix/codex-usage-plan-detection branch January 9, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready-To-Merge A feature or bug has been improved/fixed and a final review is requested before merging. Testers-Requested Request for others to test an enhancement or bug fix/etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants