feat(ui): Improve responsiveness and model display in usage reports by adhishthite · Pull Request #118 · ccusage/ccusage · GitHub
Skip to content

feat(ui): Improve responsiveness and model display in usage reports#118

Merged
ryoppippi merged 4 commits into
ccusage:mainfrom
adhishthite:main
Jun 20, 2025
Merged

feat(ui): Improve responsiveness and model display in usage reports#118
ryoppippi merged 4 commits into
ccusage:mainfrom
adhishthite:main

Conversation

@adhishthite

@adhishthite adhishthite commented Jun 19, 2025

Copy link
Copy Markdown
Contributor

🖥️ 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

coderabbitai Bot commented Jun 19, 2025

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
Contributor

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.

Comment thread src/utils.internal.ts Outdated
Comment thread src/utils.internal.ts Outdated
@ryoppippi ryoppippi requested a review from Copilot June 19, 2025 14:10

This comment was marked as outdated.

@ryoppippi

Copy link
Copy Markdown
Member

It looks really good. I'll review it later

@pkg-pr-new

pkg-pr-new Bot commented Jun 19, 2025

Copy link
Copy Markdown

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 <adhishthite@users.noreply.github.com>
…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 <adhishthite@users.noreply.github.com>
- 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 <adhishthite@users.noreply.github.com>
- 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 <adhishthite@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

@ryoppippi ryoppippi left a comment

Copy link
Copy Markdown
Member

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

3 participants