Skip to content

Conversation

@adhishthite
Copy link
Contributor

@adhishthite adhishthite commented Jun 19, 2025

🖥️ Improve Table Responsiveness and Model Display

📋 Summary

This PR significantly improves the user experience for viewing Claude Code usage reports on smaller terminal sizes by implementing responsive table layouts and enhanced model formatting.

🎯 Key Features

1. Smart Responsive Tables

  • Compact Mode: Automatically activates when terminal width < 100 characters
  • Column Prioritization: Hides less critical columns (Cache Create, Cache Read, Total Tokens) in compact mode
  • Essential Data: Always shows Date, Models, Input, Output, and Cost (USD)
  • User Guidance: Clear messaging when in compact mode

2. Enhanced Model Display

  • Multiline Format: Models now display as bulleted lists instead of comma-separated text
  • Space Efficient: Significantly reduces horizontal space usage
  • Professional Appearance: Clean • model-name format for better readability

3. Universal Support

  • All Commands: Works across daily, monthly, session, and blocks commands
  • Seamless Switching: Automatically adapts based on terminal width
  • Consistent Experience: Same behavior across all report types

🔧 Technical Implementation

New Components

  • ResponsiveTable class with compact mode detection
  • formatModelsDisplayMultiline() function for bulleted model lists
  • Automatic terminal width detection using COLUMNS environment variable
  • Smart column filtering based on available space

Enhanced Features

  • Compact mode threshold configuration (default: 100 characters)
  • Dynamic table head and column alignment switching
  • Comprehensive test coverage for new functionality

📸 Visual Comparison

Before
Screenshot 2025-06-19 at 10 25 38 AM

After (Wide Terminal)
Screenshot 2025-06-19 at 10 27 32 AM

After (Compact Mode - 70 columns)
Screenshot 2025-06-19 at 10 26 23 AM


✅ Quality Assurance

  • Comprehensive Tests: Added 5 new test cases for multiline formatting
  • Code Quality: Passes ESLint, TypeScript checks, and existing test suite
  • Backward Compatibility: All existing functionality preserved
  • Cross-Platform: Works on all terminal sizes and operating systems

🎉 User Benefits

  1. Better Mobile/Small Screen Experience: Reports are now readable on narrow terminals
  2. Cleaner Model Display: Professional bulleted lists instead of cramped comma-separated text
  3. Space Efficiency: Models column uses significantly less horizontal space
  4. Smart Adaptation: Automatically shows the best layout for current terminal size
  5. Clear Guidance: Users know exactly how to see full data when needed

This enhancement makes Claude Code usage reports accessible and readable regardless of terminal size, while maintaining a professional appearance and all existing functionality.

Summary by CodeRabbit

  • New Features

    • Tables now automatically switch to a compact mode when the terminal window is narrow, improving readability on smaller screens.
    • Model lists in usage reports are now displayed in a multiline, bulleted format for enhanced clarity.
  • Enhancements

    • Informational messages guide users to expand their terminal width to view additional metrics when in compact mode.

@coderabbitai
Copy link

coderabbitai bot commented Jun 19, 2025

Warning

Rate limit exceeded

@ryoppippi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 58 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 3c33f26ae7bdd41f04cf03d72a12808eee6bf8bf and e9b1961.

📒 Files selected for processing (6)
  • README.md (3 hunks)
  • src/_utils.ts (12 hunks)
  • src/commands/blocks.ts (3 hunks)
  • src/commands/daily.ts (4 hunks)
  • src/commands/monthly.ts (4 hunks)
  • src/commands/session.ts (5 hunks)

Walkthrough

The changes introduce a multiline model display formatter and enhance the ResponsiveTable class to support a compact mode that adapts table layouts based on terminal width. Multiple commands are updated to use these features, resulting in improved table formatting and model display, especially for narrow terminal environments.

Changes

File(s) Change Summary
src/commands/blocks.ts Updated to use multiline model display when not in compact mode.
src/commands/daily.ts, src/commands/monthly.ts, src/commands/session.ts Updated imports to use multiline model display; enhanced table rendering with compact mode and user guidance for narrow terminals.
src/utils.internal.ts Enhanced ResponsiveTable with compact mode, new table options, and helper methods; added formatModelsDisplayMultiline function and tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Command
    participant ResponsiveTable
    participant Utils

    User->>Command: Run usage report command
    Command->>Utils: formatModelsDisplayMultiline(models)
    Utils-->>Command: Multiline formatted model string
    Command->>ResponsiveTable: Instantiate with compact options
    Command->>ResponsiveTable: Add rows with model info
    Command->>ResponsiveTable: toString()
    ResponsiveTable->>ResponsiveTable: Check terminal width for compact mode
    ResponsiveTable-->>Command: Rendered table string
    Command->>User: Display table and compact mode info (if needed)
Loading

Possibly related PRs

  • ryoppippi/ccusage#52: Adds detailed model breakdown data and integrates model usage columns and breakdown rows into usage report commands, modifying the same commands and formatting utilities related to model display.
  • ryoppippi/ccusage#83: Introduces the ResponsiveTable class, which the current PR extends with compact mode and multiline model display, directly building upon the earlier implementation.

Suggested reviewers

  • ryoppippi

Poem

In a warren of code, where tables reside,
A rabbit hopped in and made columns divide.
With compact displays and models that sprawl,
Each metric now fits, whether wide screen or small.
Multiline magic, a hop and a cheer—
Table bunnies rejoice, for tidy rows are here! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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

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 @adhishthite, 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 significantly improves the user experience for viewing Claude Code usage reports by implementing responsive table layouts and enhancing the display of model names. The changes ensure that usage reports are accessible and readable across various terminal sizes, from wide displays to narrow mobile screens, while maintaining a professional and clean appearance.

Highlights

  • Responsive Table Layout: The ResponsiveTable class has been enhanced to automatically adapt to terminal width. In compact mode (terminal width < 100 characters), less critical columns like 'Cache Create', 'Cache Read', and 'Total Tokens' are hidden, while essential data ('Date', 'Models', 'Input', 'Output', 'Cost (USD)') remains visible. This ensures readability on smaller screens.
  • Enhanced Model Display: A new formatModelsDisplayMultiline function has been introduced to display model names as a bulleted list (e.g., - model-name) instead of a comma-separated string. This significantly improves readability and reduces horizontal space usage, especially when multiple models are present.
  • Universal Application & User Guidance: These UI improvements are applied across all usage report commands (daily, monthly, session, and blocks). Additionally, when the table is rendered in compact mode, a clear message is displayed to the user, informing them that they are in compact mode and how to view the full data.
  • Terminal Width Detection: The table's responsiveness now prioritizes the COLUMNS environment variable for terminal width detection, falling back to process.stdout.columns if the environment variable is not set.
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 is currently in preview and 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 to provide feedback.

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 PR introduces valuable enhancements for responsive table layouts and improved model name formatting in usage reports. The implementation is largely solid, with new functionalities well-integrated across various commands. Key suggestions include improving the error handling for mismatched compact headers and expanding unit test coverage for the ResponsiveTable's compact mode logic to ensure long-term maintainability and correctness.

@ryoppippi ryoppippi requested a review from Copilot June 19, 2025 14:10

This comment was marked as outdated.

@ryoppippi
Copy link
Owner

It looks really good. I'll review it later

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 19, 2025

Open in StackBlitz

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

commit: e9b1961

@ryoppippi ryoppippi requested a review from Copilot June 20, 2025 10:48

This comment was marked as outdated.

ryoppippi and others added 4 commits June 20, 2025 11:59
- Add ResponsiveTable class with automatic terminal width detection

- Implement compact mode for narrow terminals (< 100 characters)

- Add smart column filtering for essential data in compact mode

- Include comprehensive test coverage for compact mode behavior

- Add formatModelsDisplayMultiline function for bulleted model lists

The responsive table automatically adapts layout based on terminal width,

showing essential columns in compact mode while maintaining full data

in wide terminals. Includes proper error handling and fallback behavior.

Co-authored-by: adhishthite <[email protected]>
…commands

- Add compact mode configuration for daily, monthly, and session reports

- Use multiline model display format for better readability

- Include compact mode guidance messages for users

- Configure essential columns for narrow terminal display

Each command now automatically adapts to terminal width, showing

Date, Models, Input, Output, and Cost columns in compact mode

while preserving all data in wide terminals.

Co-authored-by: adhishthite <[email protected]>
- Use consistent multiline model display across all commands

- Remove unused compact parameter from formatModels function

- Fix ESLint unused parameter warning

This ensures all commands use the same bulleted list format

for model names, improving consistency across the application.

Co-authored-by: adhishthite <[email protected]>
- Document responsive table behavior and compact mode functionality

- Add visual examples for both wide and narrow terminal displays

- Update feature list with new responsive capabilities

- Include guidance on terminal width requirements

The documentation now clearly explains how the responsive tables

work and provides visual examples of the output in different

terminal sizes, helping users understand the feature benefits.

Co-authored-by: adhishthite <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the responsiveness and model display of Claude Code usage reports by introducing compact mode support and multiline model formatting. Key changes include:

  • Updating table initialization in session, monthly, daily, and blocks commands to support responsive compact mode.
  • Replacing the old formatModelsDisplay with the new formatModelsDisplayMultiline function for improved model display.
  • Updating the README documentation to reflect the enhanced responsive table behavior.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/commands/session.ts Updated table creation and model formatting for compact mode support.
src/commands/monthly.ts Similar updates to support responsive layouts and multiline models.
src/commands/daily.ts Added compact mode parameters and multiline model formatting.
src/commands/blocks.ts Adjusted model formatting function to use multiline display consistently.
README.md Revised documentation to include details on the new responsive display.
Comments suppressed due to low confidence (1)

src/commands/blocks.ts:78

  • [nitpick] Since the compact flag is no longer used and the function always applies the multiline format, consider renaming the function to something like 'formatModelsDisplayMultiline' for clarity and consistency.
 */

Copy link
Owner

@ryoppippi ryoppippi left a comment

Choose a reason for hiding this comment

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

LTGM thanks

@ryoppippi ryoppippi merged commit 6cbbd6a into ryoppippi:main Jun 20, 2025
7 checks passed
ryoppippi added a commit that referenced this pull request Jun 22, 2025
feat(ui): Improve responsiveness and model display in usage reports
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