-
-
Notifications
You must be signed in to change notification settings - Fork 317
feat(statusline): add 'both' cost source option to display cc and ccusage costs #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sage costs - Add 'both' option to costSource choices that shows both Claude Code and ccusage costs side by side - Update cost calculation logic to support dual cost display - Modify session display format to show "cc cost cc / ccusage cost ccusage" when both mode is active - Update test data files with realistic cost information and current Claude Code JSON structure - Maintain backward compatibility with existing cost source options (auto, ccusage, cc) The both option displays costs in format: "$0.05 cc / $0.04 ccusage session" This allows users to compare Claude Code's cost calculation with ccusage's calculation.
|
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. Warning Rate limit exceeded@ryoppippi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 1 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (6)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 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/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ccusage-guide | 9ee477b | Commit Preview URL Branch Preview URL |
Aug 22 2025, 11:26 AM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @ryoppippi, 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 introduces a new both option to the statusline command, allowing users to simultaneously view cost calculations from both Claude Code's native system and ccusage's token-based method. This enhancement provides a direct comparison of the two cost sources, improving transparency and user insight into session expenditures. Additionally, the PR updates existing test data to reflect realistic Claude Code JSON structures and cost information, ensuring robust testing and accuracy.
Highlights
- New Cost Source Option: Added a both option to the statusline command's costSource parameter, enabling the display of both Claude Code and ccusage costs.
- Dual Cost Display Logic: Implemented logic to retrieve and format both Claude Code (cc) and ccusage costs, presenting them side-by-side in the status line output (e.g., "$0.05 cc / $0.04 ccusage session").
- Refactored Cost Calculation: Modified the internal cost calculation function to return an object containing individual ccCost and ccusageCost values, facilitating flexible display options.
- Enhanced Test Data: Updated all statusline test JSON files to include realistic cost data and a complete Claude Code hook structure (version, output_style, cost fields), improving test accuracy and coverage.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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
-
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. ↩
commit: |
Change format from '/bin/zsh.06 cc / /bin/zsh.05 ccusage' to '(/bin/zsh.06 cc / /bin/zsh.05 ccusage)' This makes the dual cost display more visually distinct and easier to read.
There was a problem hiding this 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 introduces a new 'both' option for the costSource parameter in the statusline command, allowing users to view costs from both Claude Code (cc) and ccusage simultaneously. The implementation refactors the cost calculation logic to handle multiple cost values and updates the display format accordingly. The changes are well-structured, and the test data has been updated to reflect more realistic scenarios. My review includes one suggestion to improve the robustness of the display logic for the new 'both' option, ensuring it behaves as expected even when cost data is unavailable.
| const sessionDisplay = (() => { | ||
| // If both costs are available, show them side by side | ||
| if (ccCost != null || ccusageCost != null) { | ||
| const ccDisplay = ccCost != null ? formatCurrency(ccCost) : 'N/A'; | ||
| const ccusageDisplay = ccusageCost != null ? formatCurrency(ccusageCost) : 'N/A'; | ||
| return `(${ccDisplay} cc / ${ccusageDisplay} ccusage)`; | ||
| } | ||
| // Single cost display | ||
| return sessionCost != null ? formatCurrency(sessionCost) : 'N/A'; | ||
| })(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logic to decide the session cost display format relies on ccCost or ccusageCost being non-null. This works fine when at least one cost is available in 'both' mode. However, if both ccCost and ccusageCost are unavailable (e.g., hookData.cost is missing and loadSessionUsageById fails), the condition ccCost != null || ccusageCost != null becomes false.
This causes the display to fall back to the single cost format, which will show "N/A" because sessionCost is also undefined in 'both' mode. The user would expect to see "N/A cc / N/A ccusage" to understand that both calculations were attempted but failed.
A more robust approach is to explicitly check if the costSource is 'both'. This ensures the correct format is always used for that option, regardless of whether the cost values could be retrieved.
const sessionDisplay = (() => {
// If 'both' mode is selected, always show the side-by-side format
if (ctx.values.costSource === 'both') {
const ccDisplay = ccCost != null ? formatCurrency(ccCost) : 'N/A';
const ccusageDisplay = ccusageCost != null ? formatCurrency(ccusageCost) : 'N/A';
return `${ccDisplay} cc / ${ccusageDisplay} ccusage`;
}
// Single cost display
return sessionCost != null ? formatCurrency(sessionCost) : 'N/A';
})();Auto-generated schema update to include the new 'both' option in costSource enum
Add comprehensive documentation for the new --cost-source option in statusline command: - Document all four cost source modes: auto, ccusage, cc, both - Add setup examples for settings.json configuration - Show output format differences for both mode - Explain when to use each mode with practical guidance - Update output format examples with both costs display References recent PRs: - feat(statusline): add costSource option to use Claude Code session cost (#571) - feat(statusline): add 'both' cost source option to display cc and ccusage costs (#574)
Add comprehensive documentation for the new --cost-source option in statusline command: - Document all four cost source modes: auto, ccusage, cc, both - Add setup examples for settings.json configuration - Show output format differences for both mode - Explain when to use each mode with practical guidance - Update output format examples with both costs display References recent PRs: - feat(statusline): add costSource option to use Claude Code session cost (#571) - feat(statusline): add 'both' cost source option to display cc and ccusage costs (#574)
Summary
Changes
Core Implementation
costSourceChoicesenum"$0.05 cc / $0.04 ccusage session"Test Data Updates
Usage Examples
Test plan