Skip to content

Conversation

@ryoppippi
Copy link
Owner

Summary

  • Add new 'both' option to statusline costSource parameter that displays both Claude Code and ccusage costs side by side
  • Allow users to compare Claude Code's native cost calculation with ccusage's token-based calculation
  • Update test data with realistic cost information and current Claude Code JSON structure

Changes

Core Implementation

  • Added 'both' to costSourceChoices enum
  • Modified cost calculation logic to support dual cost retrieval
  • Updated session display format to show: "$0.05 cc / $0.04 ccusage session"
  • Maintained backward compatibility with existing options (auto, ccusage, cc)

Test Data Updates

  • Updated all statusline test JSON files with realistic cost data
  • Added complete Claude Code hook structure including version, output_style, and cost fields
  • Used actual session IDs and file paths for more realistic testing

Usage Examples

# Show both costs side by side
echo "$hook_data" | ccusage statusline --cost-source both
# Output: 🤖 Sonnet 4 | 💰 $0.06 cc / $0.05 ccusage session / ...

# Existing options still work
echo "$hook_data" | ccusage statusline --cost-source auto
echo "$hook_data" | ccusage statusline --cost-source cc
echo "$hook_data" | ccusage statusline --cost-source ccusage

Test plan

  • Verify all existing cost source options still work correctly
  • Test new 'both' option displays both costs properly
  • Confirm test data updates don't break existing functionality
  • Run full test suite to ensure no regressions
  • Manual testing with various cost scenarios

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

coderabbitai bot commented Aug 22, 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.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 837f60e and 9ee477b.

📒 Files selected for processing (6)
  • config-schema.json (1 hunks)
  • src/commands/statusline.ts (5 hunks)
  • test/statusline-test-opus4.json (1 hunks)
  • test/statusline-test-sonnet4.json (1 hunks)
  • test/statusline-test-sonnet41.json (1 hunks)
  • test/statusline-test.json (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/statusline-both-costs

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
🪧 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 22, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

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.

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

  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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Aug 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/ryoppippi/ccusage@574

commit: 9ee477b

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

Comment on lines +421 to +430
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';
})();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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
@ryoppippi ryoppippi merged commit a5c4cc7 into main Aug 22, 2025
15 of 16 checks passed
@ryoppippi ryoppippi deleted the feat/statusline-both-costs branch August 22, 2025 11:25
ryoppippi added a commit that referenced this pull request Aug 22, 2025
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)
ryoppippi added a commit that referenced this pull request Aug 22, 2025
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)
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.

2 participants